summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-08-14 10:05:26 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-08-14 10:06:59 +0100
commit2cd01f9c90dec1c3b4409d5268cd642d397df136 (patch)
treea3f090d26080ff4946162faa791f8eec266ec222 /sw
parent7bfb229230a439c2edb3e8452fe0d3430f9931ce (diff)
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
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/ww8par.cxx37
1 files changed, 30 insertions, 7 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 505369cc7fd3..ee4e34b7a10f 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)