summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorYogeshBharate <yogesh.bharate@synerzip.com>2013-10-18 19:38:05 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-11-14 10:26:07 +0100
commitfab11968a83b988316c94625ea874cb206314da6 (patch)
treefae8a599b5ce8aff3b7cc532a3981dce57e323f6 /sw
parent56368292012a0521d663361d53c70267fdb7b0d1 (diff)
Code changes and unit test to check no empty font name is exported
Problem Description: In fontTable.xml, empty font name gets exported. So while exporting check no empty font name is exported. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/6319 Change-Id: Icaa58d23b7754925291867b4c9557c8232f77d69
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/font-name-is-empty.docxbin0 -> 6991 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx17
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx19
3 files changed, 28 insertions, 8 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/font-name-is-empty.docx b/sw/qa/extras/ooxmlexport/data/font-name-is-empty.docx
new file mode 100644
index 000000000000..5ee8cad1ac72
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/font-name-is-empty.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 69c3b589a9b4..5141d360cc7f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1532,6 +1532,23 @@ DECLARE_OOXML_TEST(testCharHighlight, "char_highlight.docx")
}
}
+DECLARE_OOXML_TEST(testFontNameIsEmpty, "font-name-is-empty.docx")
+{
+ // Check no empty font name is exported
+ // This test does not fail, if the document contains a font with empty name.
+
+ xmlDocPtr pXmlFontTable = parseExport("word/fontTable.xml");
+ xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlFontTable, "/w:fonts/w:font");
+ sal_Int32 length = xmlXPathNodeSetGetLength(pXmlNodes);
+ for(sal_Int32 index = 0; index < length; index++){
+ xmlNodePtr pXmlNode = pXmlNodes->nodeTab[index];
+ OUString attrVal = OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST("name")));
+ if (attrVal == ""){
+ CPPUNIT_FAIL("Font name is empty.");
+ }
+ }
+}
+
DECLARE_OOXML_TEST(testMultiColumnLineSeparator, "multi-column-line-separator-SAVED.docx")
{
// Check for the Column Separator value.It should be FALSE as the document doesnt contains separator line.
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 0b55430e9b7a..454bf2e766ea 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -838,16 +838,19 @@ void wwFont::WriteDocx( DocxAttributeOutput* rAttrOutput ) const
{
// no font embedding, panose id, subsetting, ... implemented
- rAttrOutput->StartFont( msFamilyNm );
+ if (!msFamilyNm.isEmpty())
+ {
+ rAttrOutput->StartFont( msFamilyNm );
- if ( mbAlt )
- rAttrOutput->FontAlternateName( msAltNm );
- rAttrOutput->FontCharset( sw::ms::rtl_TextEncodingToWinCharset( meChrSet ), meChrSet );
- rAttrOutput->FontFamilyType( meFamily );
- rAttrOutput->FontPitchType( mePitch );
- rAttrOutput->EmbedFont( msFamilyNm, meFamily, mePitch, meChrSet );
+ if ( mbAlt )
+ rAttrOutput->FontAlternateName( msAltNm );
+ rAttrOutput->FontCharset( sw::ms::rtl_TextEncodingToWinCharset( meChrSet ), meChrSet );
+ rAttrOutput->FontFamilyType( meFamily );
+ rAttrOutput->FontPitchType( mePitch );
+ rAttrOutput->EmbedFont( msFamilyNm, meFamily, mePitch, meChrSet );
- rAttrOutput->EndFont();
+ rAttrOutput->EndFont();
+ }
}
void wwFont::WriteRtf( const RtfAttributeOutput* rAttrOutput ) const