[Libreoffice-commits] core.git: sw/qa sw/source

YogeshBharate yogesh.bharate at synerzip.com
Thu Nov 14 01:26:30 PST 2013


 sw/qa/extras/ooxmlexport/data/font-name-is-empty.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx              |   17 ++++++++++++++++
 sw/source/filter/ww8/wrtw8sty.cxx                     |   19 ++++++++++--------
 3 files changed, 28 insertions(+), 8 deletions(-)

New commits:
commit fab11968a83b988316c94625ea874cb206314da6
Author: YogeshBharate <yogesh.bharate at synerzip.com>
Date:   Fri Oct 18 19:38:05 2013 +0530

    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

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 0000000..5ee8cad
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/font-name-is-empty.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 69c3b58..5141d36 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 0b55430..454bf2e 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


More information about the Libreoffice-commits mailing list