richedit: Extend the usage of underlinetype from charformat2 in richedit.

This commit is contained in:
Eric Pouech 2008-01-01 22:03:58 +01:00 committed by Alexandre Julliard
parent 13f86afe1f
commit 6b591ef23a
4 changed files with 61 additions and 10 deletions

View File

@ -332,10 +332,11 @@ static void ME_RTFCharAttrHook(RTF_Info *info)
{
case rtfPlain:
/* FIXME add more flags once they're implemented */
fmt.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR | CFM_BACKCOLOR | CFM_SIZE | CFM_WEIGHT;
fmt.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINETYPE | CFM_STRIKEOUT | CFM_COLOR | CFM_BACKCOLOR | CFM_SIZE | CFM_WEIGHT;
fmt.dwEffects = CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR;
fmt.yHeight = 12*20; /* 12pt */
fmt.wWeight = 400;
fmt.bUnderlineType = CFU_UNDERLINENONE;
break;
case rtfBold:
fmt.dwMask = CFM_BOLD;
@ -346,13 +347,24 @@ static void ME_RTFCharAttrHook(RTF_Info *info)
fmt.dwEffects = info->rtfParam ? fmt.dwMask : 0;
break;
case rtfUnderline:
fmt.dwMask = CFM_UNDERLINE;
fmt.dwEffects = info->rtfParam ? fmt.dwMask : 0;
fmt.bUnderlineType = CFU_CF1UNDERLINE;
fmt.dwMask = CFM_UNDERLINETYPE;
fmt.bUnderlineType = info->rtfParam ? CFU_CF1UNDERLINE : CFU_UNDERLINENONE;
break;
case rtfDotUnderline:
fmt.dwMask = CFM_UNDERLINETYPE;
fmt.bUnderlineType = info->rtfParam ? CFU_UNDERLINEDOTTED : CFU_UNDERLINENONE;
break;
case rtfDbUnderline:
fmt.dwMask = CFM_UNDERLINETYPE;
fmt.bUnderlineType = info->rtfParam ? CFU_UNDERLINEDOUBLE : CFU_UNDERLINENONE;
break;
case rtfWordUnderline:
fmt.dwMask = CFM_UNDERLINETYPE;
fmt.bUnderlineType = info->rtfParam ? CFU_UNDERLINEWORD : CFU_UNDERLINENONE;
break;
case rtfNoUnderline:
fmt.dwMask = CFM_UNDERLINE;
fmt.dwEffects = 0;
fmt.dwMask = CFM_UNDERLINETYPE;
fmt.bUnderlineType = CFU_UNDERLINENONE;
break;
case rtfStrikeThru:
fmt.dwMask = CFM_STRIKEOUT;

View File

@ -44,7 +44,7 @@ void ME_MakeFirstParagraph(HDC hDC, ME_TextBuffer *text)
cf.dwMask |= CFM_ALLCAPS|CFM_BOLD|CFM_DISABLED|CFM_EMBOSS|CFM_HIDDEN;
cf.dwMask |= CFM_IMPRINT|CFM_ITALIC|CFM_LINK|CFM_OUTLINE|CFM_PROTECTED;
cf.dwMask |= CFM_REVISED|CFM_SHADOW|CFM_SMALLCAPS|CFM_STRIKEOUT;
cf.dwMask |= CFM_SUBSCRIPT|CFM_UNDERLINE|CFM_WEIGHT;
cf.dwMask |= CFM_SUBSCRIPT|CFM_UNDERLINETYPE|CFM_WEIGHT;
cf.dwEffects = CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR;
lstrcpyW(cf.szFaceName, lf.lfFaceName);
@ -53,7 +53,7 @@ void ME_MakeFirstParagraph(HDC hDC, ME_TextBuffer *text)
cf.dwEffects |= CFE_BOLD;
cf.wWeight = lf.lfWeight;
if (lf.lfItalic) cf.dwEffects |= CFE_ITALIC;
if (lf.lfUnderline) cf.dwEffects |= CFE_UNDERLINE;
cf.bUnderlineType = (lf.lfUnderline) ? CFU_CF1UNDERLINE : CFU_UNDERLINENONE;
if (lf.lfStrikeOut) cf.dwEffects |= CFE_STRIKEOUT;
cf.bPitchAndFamily = lf.lfPitchAndFamily;
cf.bCharSet = lf.lfCharSet;

View File

@ -938,8 +938,8 @@ void ME_GetCharFormat(ME_TextEditor *editor, int nFrom, int nTo, CHARFORMAT2W *p
do {
/* FIXME add more style feature comparisons */
int nAttribs = CFM_SIZE | CFM_FACE | CFM_COLOR;
int nEffects = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE;
int nAttribs = CFM_SIZE | CFM_FACE | CFM_COLOR | CFM_UNDERLINETYPE;
int nEffects = CFM_BOLD | CFM_ITALIC;
run = ME_FindItemFwd(run, diRun);
@ -962,6 +962,8 @@ void ME_GetCharFormat(ME_TextEditor *editor, int nFrom, int nTo, CHARFORMAT2W *p
}
if (pFmt->yHeight != tmp.yHeight)
pFmt->dwMask &= ~CFM_SIZE;
if (pFmt->bUnderlineType != tmp.bUnderlineType)
pFmt->dwMask &= ~CFM_UNDERLINETYPE;
if (pFmt->dwMask & CFM_COLOR)
{
if (!((pFmt->dwEffects&CFE_AUTOCOLOR) & (tmp.dwEffects&CFE_AUTOCOLOR)))

View File

@ -85,6 +85,20 @@ CHARFORMAT2W *ME_ToCFAny(CHARFORMAT2W *to, CHARFORMAT2W *from)
CHARFORMATA *t = (CHARFORMATA *)to;
CopyMemory(t, from, FIELD_OFFSET(CHARFORMATA, szFaceName));
WideCharToMultiByte(0, 0, from->szFaceName, -1, t->szFaceName, sizeof(t->szFaceName), 0, 0);
if (from->dwMask & CFM_UNDERLINETYPE)
{
switch (from->bUnderlineType)
{
case CFU_CF1UNDERLINE:
to->dwMask |= CFM_UNDERLINE;
to->dwEffects |= CFE_UNDERLINE;
break;
case CFU_UNDERLINENONE:
to->dwMask |= CFM_UNDERLINE;
to->dwEffects &= ~CFE_UNDERLINE;
break;
}
}
t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */
return to;
}
@ -92,6 +106,20 @@ CHARFORMAT2W *ME_ToCFAny(CHARFORMAT2W *to, CHARFORMAT2W *from)
{
CHARFORMATW *t = (CHARFORMATW *)to;
CopyMemory(t, from, sizeof(*t));
if (from->dwMask & CFM_UNDERLINETYPE)
{
switch (from->bUnderlineType)
{
case CFU_CF1UNDERLINE:
to->dwMask |= CFM_UNDERLINE;
to->dwEffects |= CFE_UNDERLINE;
break;
case CFU_UNDERLINENONE:
to->dwMask |= CFM_UNDERLINE;
to->dwEffects &= ~CFE_UNDERLINE;
break;
}
}
t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */
return to;
}
@ -187,6 +215,13 @@ ME_Style *ME_ApplyStyle(ME_Style *sSrc, CHARFORMAT2W *style)
else
s->fmt.dwEffects &= ~CFE_AUTOCOLOR;
}
if (style->dwMask & CFM_UNDERLINE)
{
s->fmt.dwMask |= CFM_UNDERLINETYPE;
s->fmt.dwMask &= ~CFM_UNDERLINE;
s->fmt.bUnderlineType = (style->dwEffects & CFM_UNDERLINE) ?
CFU_CF1UNDERLINE : CFU_UNDERLINENONE;
}
return s;
}
@ -286,6 +321,8 @@ ME_LogFontFromStyle(HDC hDC, LOGFONTW *lf, const ME_Style *s, int nZoomNumerator
lf->lfItalic = 1;
if (s->fmt.dwEffects & s->fmt.dwMask & (CFM_UNDERLINE | CFE_LINK))
lf->lfUnderline = 1;
if (s->fmt.dwMask & CFM_UNDERLINETYPE && s->fmt.bUnderlineType == CFU_CF1UNDERLINE)
lf->lfUnderline = 1;
if (s->fmt.dwEffects & s->fmt.dwMask & CFM_STRIKEOUT)
lf->lfStrikeOut = 1;
if (s->fmt.dwEffects & s->fmt.dwMask & (CFM_SUBSCRIPT|CFM_SUPERSCRIPT))