[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sd/qa starmath/source

Michael Stahl mstahl at redhat.com
Wed Jan 27 01:14:35 PST 2016


 sd/qa/unit/data/pptx/Math.pptx  |binary
 sd/qa/unit/export-tests.cxx     |   31 +++++++++++++++++++++++++++++++
 starmath/source/ooxmlexport.cxx |    6 +++---
 3 files changed, 34 insertions(+), 3 deletions(-)

New commits:
commit 623cc2aba9d747572e5bcc9a443253456791c684
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Jan 21 18:20:12 2016 +0100

    starmath: fix OOXML export of non-BMP Unicode
    
    (cherry picked from commit 331a0a347e2ed238ff41c8cd7815b946cc95ac0f)
    
    Change-Id: Iafaeb9ea2e96ee6d8cc96174731ba3845c230b5e
    Reviewed-on: https://gerrit.libreoffice.org/21785
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/sd/qa/unit/data/pptx/Math.pptx b/sd/qa/unit/data/pptx/Math.pptx
new file mode 100644
index 0000000..fef2067
Binary files /dev/null and b/sd/qa/unit/data/pptx/Math.pptx differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 33e1ba5..e07693b 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -142,6 +142,7 @@ public:
     void testTdf91378();
     void testBnc822341();
     void testMathObject();
+    void testMathObjectPPT2010();
     void testTdf80224();
     void testTdf92527();
 
@@ -182,6 +183,7 @@ public:
 
     CPPUNIT_TEST(testBnc822341);
     CPPUNIT_TEST(testMathObject);
+    CPPUNIT_TEST(testMathObjectPPT2010);
     CPPUNIT_TEST(testTdf80224);
 
     CPPUNIT_TEST(testExportTransitionsPPTX);
@@ -1179,6 +1181,35 @@ void SdExportTest::testMathObject()
     xDocShRef->DoClose();
 }
 
+void SdExportTest::testMathObjectPPT2010()
+{
+    // Check import / export of math object
+#if 0 // disabled on release branch, needs 332a796366b7cb91dff41de4b9ffb17843112a3e
+    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("sd/qa/unit/data/pptx/Math.pptx"), PPTX);
+    utl::TempFile tempFile1;
+    xDocShRef = saveAndReload(xDocShRef, PPTX, &tempFile1);
+
+    // Export an MS specific ole object (imported from a PPTX document)
+    {
+        xmlDocPtr pXmlDocContent = parseExport(tempFile1, "ppt/slides/slide1.xml");
+        assertXPath(pXmlDocContent,
+            "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice",
+            "Requires",
+            "a14");
+        assertXPathContent(pXmlDocContent,
+            "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice/p:sp/p:txBody/a:p/a14:m/m:oMath/m:sSup/m:e/m:r[1]/m:t",
+            OUString::fromUtf8("\xf0\x9d\x91\x8e")); // non-BMP char
+
+        const SdrPage *pPage = GetPage(1, xDocShRef);
+        const SdrObject* pObj = dynamic_cast<SdrObject*>(pPage->GetObj(0));
+        CPPUNIT_ASSERT_MESSAGE("no object", pObj != nullptr);
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(OBJ_OLE2), pObj->GetObjIdentifier());
+    }
+
+    xDocShRef->DoClose();
+#endif
+}
+
 void SdExportTest::testBulletMarginAndIndentation()
 {
     ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx"), PPTX );
diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index 277fb25..63f7cd4 100644
--- a/starmath/source/ooxmlexport.cxx
+++ b/starmath/source/ooxmlexport.cxx
@@ -75,6 +75,7 @@ void SmOoxmlExport::HandleText( const SmNode* pNode, int /*nLevel*/)
     m_pSerializer->startElementNS( XML_m, XML_t, FSNS( XML_xml, XML_space ), "preserve", FSEND );
     const SmTextNode* pTemp = static_cast<const SmTextNode* >(pNode);
     SAL_INFO( "starmath.ooxml", "Text:" << OUStringToOString( pTemp->GetText(), RTL_TEXTENCODING_UTF8 ).getStr());
+    OUStringBuffer buf(pTemp->GetText());
     for(sal_Int32 i=0;i<pTemp->GetText().getLength();i++)
     {
 #if 0
@@ -94,9 +95,7 @@ void SmOoxmlExport::HandleText( const SmNode* pNode, int /*nLevel*/)
             nFace = 0x7;
         *pS << sal_uInt8(nFace+128); //typeface
 #endif
-        sal_uInt16 nChar = pTemp->GetText()[i];
-        m_pSerializer->writeEscaped( OUString( SmTextNode::ConvertSymbolToUnicode(nChar)));
-
+        buf[i] = SmTextNode::ConvertSymbolToUnicode(buf[i]);
 #if 0
         //Mathtype can only have these sort of character
         //attributes on a single character, starmath can put them
@@ -127,6 +126,7 @@ void SmOoxmlExport::HandleText( const SmNode* pNode, int /*nLevel*/)
         }
 #endif
     }
+    m_pSerializer->writeEscaped(buf.makeStringAndClear());
     m_pSerializer->endElementNS( XML_m, XML_t );
     m_pSerializer->endElementNS( XML_m, XML_r );
 }


More information about the Libreoffice-commits mailing list