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

Miklos Vajna vmiklos at collabora.co.uk
Fri Mar 21 02:12:49 PDT 2014


 oox/source/core/xmlfilterbase.cxx        |   17 ++++++++++++++++-
 sw/qa/extras/inc/swmodeltestbase.hxx     |    1 +
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx |    4 ++++
 3 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit 5299cc26d136af179328f6e560040e1eabe8b9c8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Mar 21 09:40:58 2014 +0100

    DOCX export of paragraph count in app.xml
    
    Change-Id: Ie2fd4af3340c48c915eada74760cb414848f8a8b

diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 130ae9e..5fc7c87 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -639,7 +639,6 @@ writeAppProperties( XmlFilterBase& rSelf, Reference< XDocumentProperties > xProp
     writeElement( pAppProps, XML_Characters,            "characters" );
     writeElement( pAppProps, XML_PresentationFormat,    "presentation format" );
     writeElement( pAppProps, XML_Lines,                 "lines" );
-    writeElement( pAppProps, XML_Paragraphs,            "paragraphs" );
     writeElement( pAppProps, XML_Slides,                "slides" );
     writeElement( pAppProps, XML_Notes,                 "notes" );
 #endif  /* def OOXTODO */
@@ -663,6 +662,22 @@ writeAppProperties( XmlFilterBase& rSelf, Reference< XDocumentProperties > xProp
     writeElement( pAppProps, XML_AppVersion,            "app version" );
     writeElement( pAppProps, XML_DocSecurity,           "doc security" );
 #endif  /* def OOXTODO */
+
+    uno::Sequence<beans::NamedValue> aStats = xProperties->getDocumentStatistics();
+    for (sal_Int32 i = 0; i < aStats.getLength(); ++i)
+    {
+        sal_Int32 nValue = 0;
+        if (aStats[i].Value >>= nValue)
+        {
+            OUString aValue = OUString::number(nValue);
+            if (aStats[i].Name == "ParagraphCount")
+            {
+                writeElement(pAppProps, XML_Paragraphs, aValue);
+                break;
+            }
+        }
+    }
+
     pAppProps->endElement( XML_Properties );
 }
 
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 1fb6c48..20d76cc 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -554,6 +554,7 @@ protected:
         xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("m"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/math"));
         xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ContentType"), BAD_CAST("http://schemas.openxmlformats.org/package/2006/content-types"));
         xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("lc"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas"));
+        xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("extended-properties"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"));
         xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx);
         return pXmlXpathObj->nodesetval;
     }
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 360c502..a1542d9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -106,6 +106,10 @@ DECLARE_OOXMLEXPORT_TEST(testZoom, "zoom.docx")
     int nNext = getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "next");
     int nRsid = getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "rsid");
     CPPUNIT_ASSERT(nNext < nRsid);
+
+    pXmlDoc = parseExport("docProps/app.xml");
+    // One paragraph in the document.
+    assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Paragraphs", "1");
 }
 
 DECLARE_OOXMLEXPORT_TEST(defaultTabStopNotInStyles, "empty.odt")


More information about the Libreoffice-commits mailing list