richedit: Fixed rtf reader bug that caused large start indents.

The problem was that the paragraph format was being retrieved,
slightly modified and then used to set the paragraph format, without
limiting the mask to what was being set.  The PFM_OFFSETINDENT mask flag
being valid meant that dxStartIndent specifies a relative offset, thus
dxStartIndent was doubled.
This commit is contained in:
Dylan Smith 2008-08-06 17:10:49 -04:00 committed by Alexandre Julliard
parent 687a00c0af
commit 6a65f3b38e
1 changed files with 14 additions and 7 deletions

View File

@ -472,14 +472,14 @@ static void ME_RTFParAttrHook(RTF_Info *info)
} }
case rtfFirstIndent: case rtfFirstIndent:
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
fmt.dwMask |= PFM_STARTINDENT | PFM_OFFSET; fmt.dwMask = PFM_STARTINDENT | PFM_OFFSET;
fmt.dxStartIndent += info->rtfParam; fmt.dxStartIndent += info->rtfParam;
fmt.dxOffset = -info->rtfParam; fmt.dxOffset = -info->rtfParam;
break; break;
case rtfLeftIndent: case rtfLeftIndent:
/* we assume rtfLeftIndent is always specified before rtfFirstIndent */ /* we assume rtfLeftIndent is always specified before rtfFirstIndent */
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
fmt.dwMask |= PFM_STARTINDENT; fmt.dwMask = PFM_STARTINDENT;
fmt.dxStartIndent = info->rtfParam; fmt.dxStartIndent = info->rtfParam;
fmt.dxOffset = 0; fmt.dxOffset = 0;
break; break;
@ -504,11 +504,11 @@ static void ME_RTFParAttrHook(RTF_Info *info)
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
if (!(fmt.dwMask & PFM_TABSTOPS)) if (!(fmt.dwMask & PFM_TABSTOPS))
{ {
fmt.dwMask |= PFM_TABSTOPS;
fmt.cTabCount = 0; fmt.cTabCount = 0;
} }
if (fmt.cTabCount < MAX_TAB_STOPS && info->rtfParam < 0x1000000) if (fmt.cTabCount < MAX_TAB_STOPS && info->rtfParam < 0x1000000)
fmt.rgxTabs[fmt.cTabCount++] = info->rtfParam; fmt.rgxTabs[fmt.cTabCount++] = info->rtfParam;
fmt.dwMask = PFM_TABSTOPS;
break; break;
case rtfKeep: case rtfKeep:
fmt.dwMask = PFM_KEEP; fmt.dwMask = PFM_KEEP;
@ -571,85 +571,92 @@ static void ME_RTFParAttrHook(RTF_Info *info)
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
if (!(fmt.dwMask & PFM_BORDER)) if (!(fmt.dwMask & PFM_BORDER))
{ {
fmt.dwMask |= PFM_BORDER;
fmt.wBorderSpace = 0; fmt.wBorderSpace = 0;
fmt.wBorderWidth = 1; fmt.wBorderWidth = 1;
fmt.wBorders = 0; fmt.wBorders = 0;
} }
fmt.wBorders |= 1; fmt.wBorders |= 1;
fmt.dwMask = PFM_BORDER;
break; break;
case rtfBorderRight: case rtfBorderRight:
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
if (!(fmt.dwMask & PFM_BORDER)) if (!(fmt.dwMask & PFM_BORDER))
{ {
fmt.dwMask |= PFM_BORDER;
fmt.wBorderSpace = 0; fmt.wBorderSpace = 0;
fmt.wBorderWidth = 1; fmt.wBorderWidth = 1;
fmt.wBorders = 0; fmt.wBorders = 0;
} }
fmt.wBorders |= 2; fmt.wBorders |= 2;
fmt.dwMask = PFM_BORDER;
break; break;
case rtfBorderTop: case rtfBorderTop:
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
if (!(fmt.dwMask & PFM_BORDER)) if (!(fmt.dwMask & PFM_BORDER))
{ {
fmt.dwMask |= PFM_BORDER;
fmt.wBorderSpace = 0; fmt.wBorderSpace = 0;
fmt.wBorderWidth = 1; fmt.wBorderWidth = 1;
fmt.wBorders = 0; fmt.wBorders = 0;
} }
fmt.wBorders |= 4; fmt.wBorders |= 4;
fmt.dwMask = PFM_BORDER;
break; break;
case rtfBorderBottom: case rtfBorderBottom:
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
if (!(fmt.dwMask & PFM_BORDER)) if (!(fmt.dwMask & PFM_BORDER))
{ {
fmt.dwMask |= PFM_BORDER;
fmt.wBorderSpace = 0; fmt.wBorderSpace = 0;
fmt.wBorderWidth = 1; fmt.wBorderWidth = 1;
fmt.wBorders = 0; fmt.wBorders = 0;
} }
fmt.wBorders |= 8; fmt.wBorders |= 8;
fmt.dwMask = PFM_BORDER;
break; break;
case rtfBorderSingle: case rtfBorderSingle:
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
/* we assume that borders have been created before (RTF spec) */ /* we assume that borders have been created before (RTF spec) */
fmt.wBorders &= ~0x700; fmt.wBorders &= ~0x700;
fmt.wBorders |= 1 << 8; fmt.wBorders |= 1 << 8;
fmt.dwMask = PFM_BORDER;
break; break;
case rtfBorderThick: case rtfBorderThick:
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
/* we assume that borders have been created before (RTF spec) */ /* we assume that borders have been created before (RTF spec) */
fmt.wBorders &= ~0x700; fmt.wBorders &= ~0x700;
fmt.wBorders |= 2 << 8; fmt.wBorders |= 2 << 8;
fmt.dwMask = PFM_BORDER;
break; break;
case rtfBorderShadow: case rtfBorderShadow:
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
/* we assume that borders have been created before (RTF spec) */ /* we assume that borders have been created before (RTF spec) */
fmt.wBorders &= ~0x700; fmt.wBorders &= ~0x700;
fmt.wBorders |= 10 << 8; fmt.wBorders |= 10 << 8;
fmt.dwMask = PFM_BORDER;
break; break;
case rtfBorderDouble: case rtfBorderDouble:
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
/* we assume that borders have been created before (RTF spec) */ /* we assume that borders have been created before (RTF spec) */
fmt.wBorders &= ~0x700; fmt.wBorders &= ~0x700;
fmt.wBorders |= 7 << 8; fmt.wBorders |= 7 << 8;
fmt.dwMask = PFM_BORDER;
break; break;
case rtfBorderDot: case rtfBorderDot:
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
/* we assume that borders have been created before (RTF spec) */ /* we assume that borders have been created before (RTF spec) */
fmt.wBorders &= ~0x700; fmt.wBorders &= ~0x700;
fmt.wBorders |= 11 << 8; fmt.wBorders |= 11 << 8;
fmt.dwMask = PFM_BORDER;
break; break;
case rtfBorderWidth: case rtfBorderWidth:
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
/* we assume that borders have been created before (RTF spec) */ /* we assume that borders have been created before (RTF spec) */
fmt.wBorderWidth |= ((info->rtfParam / 15) & 7) << 8; fmt.wBorderWidth |= ((info->rtfParam / 15) & 7) << 8;
fmt.dwMask = PFM_BORDER;
break; break;
case rtfBorderSpace: case rtfBorderSpace:
ME_GetSelectionParaFormat(info->editor, &fmt); ME_GetSelectionParaFormat(info->editor, &fmt);
/* we assume that borders have been created before (RTF spec) */ /* we assume that borders have been created before (RTF spec) */
fmt.wBorderSpace = info->rtfParam; fmt.wBorderSpace = info->rtfParam;
fmt.dwMask = PFM_BORDER;
break; break;
} }
if (fmt.dwMask) { if (fmt.dwMask) {