summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2013-12-11 16:29:28 +0100
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2013-12-11 17:39:02 +0100
commitece66b11bd3d294eb27f185c1513744fe28ca523 (patch)
tree282a0bcc0c68aae7253a275fa0f5d08e98b4540c /sw
parent1835074d525d12629008f8a6d5ed27402d18f4b3 (diff)
fdo#64232: export w:themeFontLang setting to docx
We store the values of themeFontLang tag to the document grab bag so we can save it back to the document on export time. Added unit tests to check that the attribute is properly set back and also that the theme fonts are correctly applied to the text. Change-Id: Ia54c513796ba38a571396ca7b72dfd28463c15fd
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/theme-preservation.docxbin8129 -> 14739 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx28
-rw-r--r--sw/source/filter/ww8/docxexport.cxx35
3 files changed, 60 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/theme-preservation.docx b/sw/qa/extras/ooxmlexport/data/theme-preservation.docx
index c1d879aa05df..ff7c5700c965 100644
--- a/sw/qa/extras/ooxmlexport/data/theme-preservation.docx
+++ b/sw/qa/extras/ooxmlexport/data/theme-preservation.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index c4efcfda32d8..726783889794 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2047,7 +2047,7 @@ DECLARE_OOXMLEXPORT_TEST(testThemePreservation, "theme-preservation.docx")
if (!pXmlStyles)
return;
assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "asciiTheme", "minorHAnsi");
- assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "eastAsiaTheme", "minorEastAsia");
+ assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "cstheme", "minorBidi");
// check the font theme values in style definitions
assertXPath(pXmlStyles, "/w:styles/w:style[1]/w:rPr/w:rFonts", "eastAsiaTheme", "minorEastAsia");
@@ -2056,8 +2056,30 @@ DECLARE_OOXMLEXPORT_TEST(testThemePreservation, "theme-preservation.docx")
xmlDocPtr pXmlDocument = parseExport("word/document.xml");
if (!pXmlDocument)
return;
- assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:r[1]/w:rPr/w:rFonts", "hAnsiTheme", "majorBidi");
- assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:r[1]/w:rPr/w:rFonts", "cstheme", "majorBidi");
+ assertXPath(pXmlDocument, "/w:document/w:body/w:p[5]/w:r[1]/w:rPr/w:rFonts", "hAnsiTheme", "majorHAnsi");
+ assertXPath(pXmlDocument, "/w:document/w:body/w:p[5]/w:r[1]/w:rPr/w:rFonts", "asciiTheme", "majorHAnsi");
+
+ // check the themeFontLang values in settings file
+ xmlDocPtr pXmlSettings = parseExport("word/settings.xml");
+ if (!pXmlSettings)
+ return;
+ assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "val", "en-US");
+ assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "eastAsia", "zh-CN");
+ assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "bidi", "he-IL");
+
+ // check fonts have been applied properly
+ sal_Unicode fontName[2]; //represents the string "宋体"
+ fontName[0] = 0x5b8b;
+ fontName[1] = 0x4f53;
+ CPPUNIT_ASSERT_EQUAL(OUString(fontName, 2), getProperty<OUString>(getParagraph(1), "CharFontNameAsian"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Arial"),
+ getProperty<OUString>(getParagraph(2), "CharFontNameComplex"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Trebuchet MS"),
+ getProperty<OUString>(getParagraph(3, "Default style theme font"), "CharFontName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Arial Black"),
+ getProperty<OUString>(getRun(getParagraph(4, "Direct format font"), 1), "CharFontName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Trebuchet MS"),
+ getProperty<OUString>(getParagraph(5, "Major theme font"), "CharFontName"));
}
DECLARE_OOXMLEXPORT_TEST(testcantSplit, "2_table_doc.docx")
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index bbc367332b6d..f825819b26ee 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -753,6 +753,41 @@ void DocxExport::WriteSettings()
if( m_pAttrOutput->HasEndnotes())
m_pAttrOutput->WriteFootnoteEndnotePr( pFS, XML_endnotePr, pDoc->GetEndNoteInfo(), XML_endnote );
+ // Has themeFontLang information
+ uno::Reference< beans::XPropertySet > xPropSet( pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
+
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
+ OUString pName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
+ if ( xPropSetInfo->hasPropertyByName( pName ) )
+ {
+ uno::Sequence< beans::PropertyValue > propList;
+ xPropSet->getPropertyValue( pName ) >>= propList;
+ for( sal_Int32 i=0; i < propList.getLength(); ++i )
+ {
+ if ( propList[i].Name == "ThemeFontLangProps" )
+ {
+ uno::Sequence< beans::PropertyValue > themeFontLangProps;
+ propList[i].Value >>= themeFontLangProps;
+ OUString aValues[3];
+ for( sal_Int32 j=0; j < themeFontLangProps.getLength(); ++j )
+ {
+ if( themeFontLangProps[j].Name == "val" )
+ themeFontLangProps[j].Value >>= aValues[0];
+ else if( themeFontLangProps[j].Name == "eastAsia" )
+ themeFontLangProps[j].Value >>= aValues[1];
+ else if( themeFontLangProps[j].Name == "bidi" )
+ themeFontLangProps[j].Value >>= aValues[2];
+ }
+ pFS->singleElementNS( XML_w, XML_themeFontLang,
+ FSNS( XML_w, XML_val ), OUStringToOString( aValues[0], RTL_TEXTENCODING_UTF8 ).getStr(),
+ FSNS( XML_w, XML_eastAsia ), OUStringToOString( aValues[1], RTL_TEXTENCODING_UTF8 ).getStr(),
+ FSNS( XML_w, XML_bidi ), OUStringToOString( aValues[2], RTL_TEXTENCODING_UTF8 ).getStr(),
+ FSEND );
+ break;
+ }
+ }
+ }
+
pFS->endElementNS( XML_w, XML_settings );
}