[Libreoffice-commits] .: 3 commits - starmath/qa starmath/source sw/CppunitTest_sw_subsequent_rtfexport.mk sw/qa writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Thu Jul 26 04:21:33 PDT 2012


 starmath/qa/testdocuments/README               |    2 
 starmath/source/rtfexport.cxx                  |   25 ++-
 sw/CppunitTest_sw_subsequent_rtfexport.mk      |    3 
 sw/qa/extras/rtfexport/data/math-accents.rtf   |  189 +++++++++++++++++++++++++
 sw/qa/extras/rtfexport/data/math-eqarray.rtf   |   96 ++++++++++++
 sw/qa/extras/rtfexport/rtfexport.cxx           |   24 ++-
 sw/qa/extras/swmodeltestbase.hxx               |   23 ++-
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   16 +-
 8 files changed, 364 insertions(+), 14 deletions(-)

New commits:
commit a572af02752164a62478052113707c5f9bc705da
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Jul 26 12:54:37 2012 +0200

    add tests for RTF_MACC and RTF_MEQARR
    
    Change-Id: Id33672d0acef4d79239e0ee8a86d5a244ac736e7

diff --git a/starmath/qa/testdocuments/README b/starmath/qa/testdocuments/README
new file mode 100644
index 0000000..416e082
--- /dev/null
+++ b/starmath/qa/testdocuments/README
@@ -0,0 +1,2 @@
+You can find test documents here for DOCX. RTF test documents are at
+sw/qa/extras/rtfexport/data/math-*.rtf.
diff --git a/sw/CppunitTest_sw_subsequent_rtfexport.mk b/sw/CppunitTest_sw_subsequent_rtfexport.mk
index bdc47cd..a0dd451 100644
--- a/sw/CppunitTest_sw_subsequent_rtfexport.mk
+++ b/sw/CppunitTest_sw_subsequent_rtfexport.mk
@@ -65,6 +65,7 @@ $(eval $(call gb_CppunitTest_use_ure,sw_subsequent_rtfexport))
 $(eval $(call gb_CppunitTest_use_components,sw_subsequent_rtfexport,\
     comphelper/util/comphelp \
     configmgr/source/configmgr \
+    embeddedobj/util/embobj \
     fileaccess/source/fileacc \
     filter/source/config/cache/filterconfig1 \
     framework/util/fwk \
@@ -73,6 +74,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_subsequent_rtfexport,\
     package/util/package2 \
     sax/source/expatwrap/expwrap \
     sfx2/util/sfx \
+    starmath/util/sm \
     svl/source/fsstor/fsstorage \
     svtools/util/svt \
     sw/util/msword \
@@ -81,6 +83,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_subsequent_rtfexport,\
     toolkit/util/tk \
     ucb/source/core/ucb1 \
     ucb/source/ucp/file/ucpfile1 \
+    unotools/util/utl \
     unoxml/source/service/unoxml \
     writerfilter/util/writerfilter \
 ))
diff --git a/sw/qa/extras/rtfexport/data/math-accents.rtf b/sw/qa/extras/rtfexport/data/math-accents.rtf
new file mode 100644
index 0000000..2dcaf70
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/math-accents.rtf
@@ -0,0 +1,189 @@
+{\rtf1
+{\mmath
+{\*\moMathPara 
+{\*\moMath 
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mchr \u769 \'b4}
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 
+\i\f34\insrsid26133 \hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mchr \u768 `}
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 
+\i\f34\insrsid26133 \hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mchr \u780 ?}
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 
+\i\f34\insrsid26133 \hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mchr \u774 ?}
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 
+\i\f34\insrsid26133 \hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mchr \u778 \'b0}
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 
+\i\f34\insrsid26133 \hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mchr \u8407 ?}
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 
+\i\f34\insrsid26133 \hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mchr \u771 ~}
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 
+\i\f34\insrsid26133 \hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \i\f34\insrsid26133 
+\hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mchr \u729 ?}
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \i\f34\insrsid26133 
+\hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mchr \u8407 ?}
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \i\f34\insrsid26133 
+\hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mchr \u8407 ?}
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \i\f34\insrsid26133 
+\hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\macc
+{\maccPr
+{\mchr \u771 ~}
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \i\f34\insrsid26133 
+\hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+{\mbar
+{\mbarPr
+{\mctrlPr\f34 }
+}
+{\me
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \i\f34\insrsid26133 
+\hich\af34\dbch\af42\loch\f34 
+{\mr\mscr0\msty2 a}
+}
+{\rtlch\fcs1 \af1 \ltrch\fcs0 \f34\insrsid26133 }
+}
+}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfexport/data/math-eqarray.rtf b/sw/qa/extras/rtfexport/data/math-eqarray.rtf
new file mode 100644
index 0000000..8e499ae
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/math-eqarray.rtf
@@ -0,0 +1,96 @@
+{\rtf1
+{\mmath
+{\*\moMathPara 
+{\*\moMath 
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 y}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 =}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 
+\i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid14308624 }
+{\md
+{\mdPr
+{\mbegChr \'7b}
+{\mendChr }
+{\mctrlPr\i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033 }
+}
+{\me
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 
+\i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid14308624 }
+{\meqArr
+{\meqArrPr
+{\mctrlPr\i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033 }
+}
+{\me
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 
+\i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 0,  }
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 
+\hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 x}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 <0}
+}
+{\rtlch\fcs1 \af31507 
+\ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid14308624 }
+}
+{\me
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 1,  }
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 x}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 
+\i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 =0}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid14308624 }
+}
+{\me
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid14308624 }
+{\msSup
+{\msSupPr
+{\mctrlPr\i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033 }
+}
+{\me
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 
+\i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 x}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid14308624 }
+}
+{\msup
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 2}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 
+\i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid14308624 }
+}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 ,  
+}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 x}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 
+\i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid9447840 \hich\af34\dbch\af31505\loch\f34 
+{\mr\mscr0\msty2 >0}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid14308624 }
+}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\lang1033\langfe1033\loch\af34\hich\af34\dbch\af31505\langnp1033\insrsid14308624 }
+}
+}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index ff23b6a..64950a6 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -27,11 +27,11 @@
 
 #include "../swmodeltestbase.hxx"
 
-#include <com/sun/star/frame/XStorable.hpp>
-#include <com/sun/star/view/XViewSettingsSupplier.hpp>
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/text/XPageCursor.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/view/XViewSettingsSupplier.hpp>
 
 #include <unotools/tempfile.hxx>
 #include <vcl/svapp.hxx>
@@ -51,6 +51,8 @@ public:
     void testFdo50831();
     void testFdo48335();
     void testFdo38244();
+    void testMathAccents();
+    void testMathEqarray();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -62,6 +64,8 @@ public:
     CPPUNIT_TEST(testFdo50831);
     CPPUNIT_TEST(testFdo48335);
     CPPUNIT_TEST(testFdo38244);
+    CPPUNIT_TEST(testMathAccents);
+    CPPUNIT_TEST(testMathEqarray);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -202,6 +206,22 @@ void Test::testFdo38244()
     CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
 }
 
+void Test::testMathAccents()
+{
+    roundtrip("math-accents.rtf");
+    OUString aActual = getFormula(getRun(getParagraph(1), 1));
+    OUString aExpected("acute {a} grave {a} check {a} breve {a} circle {a} widevec {a} widetilde {a} widehat {a} dot {a} widevec {a} widevec {a} widetilde {a} underline {a}");
+    CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
+}
+
+void Test::testMathEqarray()
+{
+    roundtrip("math-eqarray.rtf");
+    OUString aActual = getFormula(getRun(getParagraph(1), 1));
+    OUString aExpected("y = left lbrace stack { 0, x < 0 # 1, x = 0 # {x} ^ {2} , x > 0 } right none");
+    CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/swmodeltestbase.hxx b/sw/qa/extras/swmodeltestbase.hxx
index 39e41da..b0ec460 100644
--- a/sw/qa/extras/swmodeltestbase.hxx
+++ b/sw/qa/extras/swmodeltestbase.hxx
@@ -25,6 +25,7 @@
  * instead of those above.
  */
 
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/text/XTextRange.hpp>
@@ -162,7 +163,7 @@ protected:
     }
 
     // Get paragraph (counted from 1), optionally check it contains the given text.
-    uno::Reference< text::XTextRange > getParagraph( int number, rtl::OUString content ) const
+    uno::Reference< text::XTextRange > getParagraph( int number, rtl::OUString content = OUString() ) const
     {
         uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
         uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
@@ -177,6 +178,26 @@ protected:
         return paragraph;
     }
 
+    /// Get run (counted from 1) of a paragraph.
+    uno::Reference<text::XTextRange> getRun(uno::Reference<text::XTextRange> xParagraph, int number) const
+    {
+        uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+        for (int i = 1; i < number; ++i)
+            xRunEnum->nextElement();
+        uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+        return xRun;
+    }
+
+    /// Get math formula string of a run.
+    OUString getFormula(uno::Reference<text::XTextRange> xRun) const
+    {
+        uno::Reference<container::XContentEnumerationAccess> xContentEnumAccess(xRun, uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> xContentEnum(xContentEnumAccess->createContentEnumeration(""), uno::UNO_QUERY);
+        uno::Reference<beans::XPropertySet> xFormula(xContentEnum->nextElement(), uno::UNO_QUERY);
+        return getProperty<OUString>(getProperty< uno::Reference<beans::XPropertySet> >(xFormula, "Model"), "Formula");
+    }
+
     uno::Reference<lang::XComponent> mxComponent;
     xmlBufferPtr mpXmlBuffer;
 };
commit e0c5698f064d988baf906e8c9d87554b668fde92
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Jul 26 11:19:43 2012 +0200

    RTF_MR: ignore if collected text is empty
    
    Sending an empty run would result in adding a space to the formula,
    leading to incorrect result.
    
    Change-Id: I1a01493cead726f667db0065deb4c145cba4ffa7

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 3b0c4b4..e41ec9e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3616,11 +3616,17 @@ int RTFDocumentImpl::popState()
     }
     break;
     case DESTINATION_MR:
-        m_aMathBuffer.appendOpeningTag(M_TOKEN(r));
-        m_aMathBuffer.appendOpeningTag(M_TOKEN(t));
-        m_aMathBuffer.appendCharacters(m_aStates.top().aDestinationText.makeStringAndClear());
-        m_aMathBuffer.appendClosingTag(M_TOKEN(t));
-        m_aMathBuffer.appendClosingTag(M_TOKEN(r));
+    {
+        OUString aStr = m_aStates.top().aDestinationText.makeStringAndClear();
+        if (!aStr.isEmpty())
+        {
+            m_aMathBuffer.appendOpeningTag(M_TOKEN(r));
+            m_aMathBuffer.appendOpeningTag(M_TOKEN(t));
+            m_aMathBuffer.appendCharacters(aStr);
+            m_aMathBuffer.appendClosingTag(M_TOKEN(t));
+            m_aMathBuffer.appendClosingTag(M_TOKEN(r));
+        }
+    }
     break;
     case DESTINATION_MF: m_aMathBuffer.appendClosingTag(M_TOKEN(f)); break;
     case DESTINATION_MFPR: m_aMathBuffer.appendClosingTag(M_TOKEN(fPr)); break;
commit c098c3e35ed22bc26841f4c3976b2fc02cdf4642
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Jul 26 10:07:10 2012 +0200

    export RTF_MEQARR
    
    Change-Id: Ic2c1ca04c23b41ae36aa0a8866dc9b7776ccad64

diff --git a/starmath/source/rtfexport.cxx b/starmath/source/rtfexport.cxx
index 2031fe0..b8cebd7 100644
--- a/starmath/source/rtfexport.cxx
+++ b/starmath/source/rtfexport.cxx
@@ -46,7 +46,7 @@ bool SmRtfExport::ConvertFromStarMath(OStringBuffer& rBuffer)
     m_pBuffer = &rBuffer;
     m_pBuffer->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE "\\moMath");
     HandleNode(m_pTree, 0);
-    m_pBuffer->append("}");
+    m_pBuffer->append("}"); // moMath
     return true;
 }
 
@@ -74,6 +74,9 @@ void SmRtfExport::HandleNode(const SmNode* pNode, int nLevel)
         case NOPER:
             HandleOperator(static_cast<const SmOperNode*>(pNode), nLevel);
             break;
+        case NUNHOR:
+            HandleUnaryOperation(static_cast<const SmUnHorNode*>(pNode), nLevel);
+            break;
         case NBINHOR:
             HandleBinaryOperation(static_cast<const SmBinHorNode*>(pNode), nLevel);
             break;
@@ -134,9 +137,17 @@ void SmRtfExport::HandleAllSubNodes(const SmNode* pNode, int nLevel)
     }
 }
 
-void SmRtfExport::HandleVerticalStack(const SmNode* /*pNode*/, int /*nLevel*/)
+void SmRtfExport::HandleVerticalStack(const SmNode* pNode, int nLevel)
 {
-    SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC);
+    m_pBuffer->append("{\\meqArr ");
+    int size = pNode->GetNumSubNodes();
+    for (int i = 0; i < size; ++i)
+    {
+        m_pBuffer->append("{\\me ");
+        HandleNode(pNode->GetSubNode( i ), nLevel + 1);
+        m_pBuffer->append("}"); // me
+    }
+    m_pBuffer->append("}"); // meqArr
 }
 
 void SmRtfExport::HandleText(const SmNode* pNode, int /*nLevel*/)
@@ -152,7 +163,7 @@ void SmRtfExport::HandleText(const SmNode* pNode, int /*nLevel*/)
         m_pBuffer->append(msfilter::rtfutil::OutString(aValue, RTL_TEXTENCODING_MS_1252));
     }
 
-    m_pBuffer->append("}");
+    m_pBuffer->append("}"); // mr
 }
 
 void SmRtfExport::HandleFractions(const SmNode* pNode, int nLevel, const char* type)
@@ -176,9 +187,9 @@ void SmRtfExport::HandleFractions(const SmNode* pNode, int nLevel, const char* t
     m_pBuffer->append("}"); // mf
 }
 
-void SmRtfExport::HandleUnaryOperation(const SmUnHorNode* /*pNode*/, int /*nLevel*/)
+void SmRtfExport::HandleUnaryOperation(const SmUnHorNode* pNode, int nLevel)
 {
-    SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC);
+    HandleAllSubNodes(pNode, nLevel);
 }
 
 void SmRtfExport::HandleBinaryOperation(const SmBinHorNode* pNode, int nLevel)
@@ -303,6 +314,8 @@ OString mathSymbolToString(const SmNode* node)
 {
     assert(node->GetType() == NMATH);
     const SmTextNode* txtnode = static_cast<const SmTextNode*>(node);
+    if (txtnode->GetText().Len() == 0)
+        return OString();
     assert(txtnode->GetText().Len() == 1);
     sal_Unicode chr = SmTextNode::ConvertSymbolToUnicode(txtnode->GetText().GetChar(0));
     OUString aValue(chr);


More information about the Libreoffice-commits mailing list