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

Luboš Luňák l.lunak at suse.cz
Tue Mar 26 09:20:32 PDT 2013


 starmath/source/ooxmlexport.cxx                 |    7 +++++++
 starmath/source/ooxmlimport.cxx                 |   22 +++++++++++++++++-----
 sw/qa/extras/ooxmlexport/data/math-literal.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx        |    9 +++++++++
 4 files changed, 33 insertions(+), 5 deletions(-)

New commits:
commit 0fd8f9808435f1eedf7065964eb09e69501975c3
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Mar 26 17:14:54 2013 +0100

    testcase for the previous starmath docx fixes
    
    Based on the one broken case in
    http://mail-archives.apache.org/mod_mbox/openoffice-dev/201303.mbox/<5150A98B.8050901@yandex.ru>
    
    Change-Id: I3f8f1b8d8239e12a3315c6d8aa0cddee47af4a85

diff --git a/sw/qa/extras/ooxmlexport/data/math-literal.docx b/sw/qa/extras/ooxmlexport/data/math-literal.docx
new file mode 100644
index 0000000..b62bd23
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/math-literal.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index da09b12..808bf63 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -84,6 +84,7 @@ public:
     void testTextframeGradient();
     void testCellBtlr();
     void testTableStylerPrSz();
+    void testMathLiteral();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -128,6 +129,7 @@ void Test::run()
         {"textframe-gradient.docx", &Test::testTextframeGradient},
         {"cell-btlr.docx", &Test::testCellBtlr},
         {"table-style-rPr-sz.docx", &Test::testTableStylerPrSz},
+        {"math-literal.docx", &Test::testMathLiteral},
     };
     // Don't test the first import of these, for some reason those tests fail
     const char* aBlacklist[] = {
@@ -650,6 +652,13 @@ void Test::testTableStylerPrSz()
 //    CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, getProperty<awt::FontSlant>(getRun(xPara, 1), "CharPosture"));
 }
 
+void Test::testMathLiteral()
+{
+    CHECK_FORMULA( "iiint from {V} to <?> {\"div\" \"F\"}  dV= llint from {S} to <?> {\"F\" ∙ \"n \" dS}",
+        getFormula( getRun( getParagraph( 1 ), 1 )));
+}
+
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 0682a1cedfddb0db58553f8cbfe619964bd1888a
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Mar 26 17:04:26 2013 +0100

    export quoted parts of math formulas properly to docx mathml
    
    Change-Id: I7950ff78c23e5e6c58ffceaa9c2a2f52e3408b26

diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index a918cb2..22f813c 100644
--- a/starmath/source/ooxmlexport.cxx
+++ b/starmath/source/ooxmlexport.cxx
@@ -75,6 +75,13 @@ void SmOoxmlExport::HandleText( const SmNode* pNode, int /*nLevel*/)
 {
     m_pSerializer->startElementNS( XML_m, XML_r, FSEND );
 
+    if( pNode->GetToken().eType == TTEXT ) // literal text (in quotes)
+    {
+        m_pSerializer->startElementNS( XML_m, XML_rPr, FSEND );
+        m_pSerializer->singleElementNS( XML_m, XML_lit, FSEND );
+        m_pSerializer->singleElementNS( XML_m, XML_nor, FSEND );
+        m_pSerializer->endElementNS( XML_m, XML_rPr );
+    }
     if( version == ECMA_DIALECT )
     { // HACK: MSOffice2007 does not import characters properly unless this font is explicitly given
         m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND );
commit a75adeae36d96d507a774b91eb586e89f8035c3e
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Mar 26 16:07:52 2013 +0100

    m:nor and m:lit math docx tags lead to quoting
    
    The meaning should not be exactly the same, but it looks like there's
    no better way to express this (or rather quoting means both).
    
    Change-Id: I024ce6c89667a69f685bb84d768095100b0090b1

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index e3a48ca..648f808 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -570,11 +570,21 @@ OUString SmOoxmlImport::handleNary()
 OUString SmOoxmlImport::handleR()
 {
     stream.ensureOpeningTag( M_TOKEN( r ));
-    if( XmlStream::Tag rPr = stream.checkOpeningTag( OOX_TOKEN( doc, rPr )))
-    { // TODO
-//        stream.checkOpeningTag( OOX_TOKEN( doc, rFonts ));
-//        stream.ensureClosingTag( OOX_TOKEN( doc, rFonts ));
-        stream.ensureClosingTag( OOX_TOKEN( doc, rPr ));
+    bool normal = false;
+    bool literal = false;
+    if( XmlStream::Tag rPr = stream.checkOpeningTag( M_TOKEN( rPr )))
+    {
+        if( XmlStream::Tag litTag = stream.checkOpeningTag( M_TOKEN( lit )))
+        {
+            literal = litTag.attribute( M_TOKEN( val ), true );
+            stream.ensureClosingTag( M_TOKEN( lit ));
+        }
+        if( XmlStream::Tag norTag = stream.checkOpeningTag( M_TOKEN( nor )))
+        {
+            normal = norTag.attribute( M_TOKEN( val ), true );
+            stream.ensureClosingTag( M_TOKEN( nor ));
+        }
+        stream.ensureClosingTag( M_TOKEN( rPr ));
     }
     OUString text;
     while( !stream.atEnd() && stream.currentToken() != CLOSING( stream.currentToken()))
@@ -597,6 +607,8 @@ OUString SmOoxmlImport::handleR()
         }
     }
     stream.ensureClosingTag( M_TOKEN( r ));
+    if( normal || literal )
+        text = "\"" + text + "\"";
     return text.replaceAll("{", "\\{").replaceAll("}", "\\}");
 }
 


More information about the Libreoffice-commits mailing list