[Libreoffice-commits] .: sw/source
Caolán McNamara
caolan at kemper.freedesktop.org
Tue Aug 14 02:07:45 PDT 2012
sw/source/filter/ww8/ww8par.cxx | 37 ++++++++++++++++++++++++++++++-------
1 file changed, 30 insertions(+), 7 deletions(-)
New commits:
commit 2cd01f9c90dec1c3b4409d5268cd642d397df136
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Aug 14 10:05:26 2012 +0100
minimize fractured text spans
There's a mismatch between writer and word as to the categorization
of text, which is a pain.
Change-Id: Id087034e72113d718a98ad21db1c09c79d1d4772
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 505369c..ee4e34b 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2731,6 +2731,20 @@ namespace
return nScript;
}
+
+ bool samePitchIgnoreUnknown(FontPitch eA, FontPitch eB)
+ {
+ return (eA == eB || eA == PITCH_DONTKNOW || eB == PITCH_DONTKNOW);
+ }
+
+ bool sameFontIgnoringIrrelevantFields(const SvxFontItem &rA, const SvxFontItem &rB)
+ {
+ //Ignoring CharSet, and ignoring unknown pitch
+ return rA.GetFamilyName() == rB.GetFamilyName() &&
+ rA.GetStyleName() == rB.GetStyleName() &&
+ rA.GetFamily() == rB.GetFamily() &&
+ samePitchIgnoreUnknown(rA.GetPitch(), rB.GetPitch());
+ }
}
//In writer we categorize text into CJK, CTL and "Western" for everything else.
@@ -2826,13 +2840,23 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const rtl::OUString& rAddS
bool bWriterWillUseSameFontAsWordAutomatically = false;
- if (
- (nWriterScript == i18n::ScriptType::ASIAN && nForceFromFontId == RES_CHRATR_CJK_FONT) ||
- (nWriterScript == i18n::ScriptType::COMPLEX && nForceFromFontId == RES_CHRATR_CTL_FONT) ||
- (nWriterScript == i18n::ScriptType::LATIN && nForceFromFontId == RES_CHRATR_FONT)
- )
+ if (nWriterScript != i18n::ScriptType::WEAK)
{
- bWriterWillUseSameFontAsWordAutomatically = true;
+ if (
+ (nWriterScript == i18n::ScriptType::ASIAN && nForceFromFontId == RES_CHRATR_CJK_FONT) ||
+ (nWriterScript == i18n::ScriptType::COMPLEX && nForceFromFontId == RES_CHRATR_CTL_FONT) ||
+ (nWriterScript == i18n::ScriptType::LATIN && nForceFromFontId == RES_CHRATR_FONT)
+ )
+ {
+ bWriterWillUseSameFontAsWordAutomatically = true;
+ }
+ else
+ {
+ const SvxFontItem *pSourceFont = (const SvxFontItem*)GetFmtAttr(nForceFromFontId);
+ sal_uInt16 nDestId = aIds[nWriterScript-1];
+ const SvxFontItem *pDestFont = (const SvxFontItem*)GetFmtAttr(nDestId);
+ bWriterWillUseSameFontAsWordAutomatically = sameFontIgnoringIrrelevantFields(*pSourceFont, *pDestFont);
+ }
}
//Writer won't use the same font as word, so force the issue
@@ -2873,7 +2897,6 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const rtl::OUString& rAddS
if (nPos < nLen)
nScript = lcl_getScriptType(xBI, rAddString, nPos);
}
-
}
void SwWW8ImplReader::simpleAddTextToParagraph(const String& rAddString)
More information about the Libreoffice-commits
mailing list