[Libreoffice-commits] .: Branch 'libreoffice-4-0' - sw/qa writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Dec 8 05:35:48 PST 2012


 sw/qa/extras/rtfimport/data/fdo49934.rtf       |    7 +++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |    8 ++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   21 +++++++++++++++++----
 3 files changed, 32 insertions(+), 4 deletions(-)

New commits:
commit b4e305d778d153fa768a8c8cabd111efdd34c2fa
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Dec 8 14:04:16 2012 +0100

    fdo#49934 fix RTF import of column break in case no columns are defined
    
    It turns out on that case the column break should be parsed as a page
    break.
    
    Change-Id: I5dddc8f334fab35bc2ff03fd8127989ab6a601f3
    (cherry picked from commit 257a4090af068085143d71d60e6032ba0b998804)

diff --git a/sw/qa/extras/rtfimport/data/fdo49934.rtf b/sw/qa/extras/rtfimport/data/fdo49934.rtf
new file mode 100644
index 0000000..19ba5cd
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo49934.rtf
@@ -0,0 +1,7 @@
+{\rtf1\ansi\uc1\deff0\deflang1024
+\paperw11960\paperh16900\margl1991\margr1422\margt1422\margb1138\pgnstart0\widowctrl\qj\ftnbj\f0\aftnnar
+{\pard\plain\s0\qj\widctlpar\f0\fs24\sl240\slmult1 \sb60 \fi0 Lorem ipsum, lacus.\par
+\column
+\pard\plain\s0\qj\widctlpar\f0\fs24\sl240\slmult1 \sb60 \fi0 Suspendisse ut massa. Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam tincidunt urna. Nulla ullamcorper vesti- bulum turpis. Pellentesque cursus luctus mauris.\par
+}
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 826ca96..2df2e05 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -128,6 +128,7 @@ public:
     void testFdo55525();
     void testFdo57708();
     void testFdo54473();
+    void testFdo49934();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -206,6 +207,7 @@ void Test::run()
         {"fdo55525.rtf", &Test::testFdo55525},
         {"fdo57708.rtf", &Test::testFdo57708},
         {"fdo54473.rtf", &Test::testFdo54473},
+        {"fdo49934.rtf", &Test::testFdo49934},
     };
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
     {
@@ -950,6 +952,12 @@ void Test::testFdo54473()
     CPPUNIT_ASSERT_EQUAL(OUString("ForeignTxt"), getProperty<OUString>(getRun(getParagraph(1), 3, "character "), "CharStyleName"));
 }
 
+void Test::testFdo49934()
+{
+    // Column break without columns defined should be a page break, but it was just ignored.
+    CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 78bd105..54390ea 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1759,10 +1759,23 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
             break;
         case RTF_COLUMN:
             {
-                sal_uInt8 sBreak[] = { 0xe };
-                Mapper().startCharacterGroup();
-                Mapper().text(sBreak, 1);
-                Mapper().endCharacterGroup();
+                bool bColumns = false; // If we have multiple columns
+                RTFValue::Pointer_t pCols = m_aStates.top().aSectionSprms.find(NS_ooxml::LN_EG_SectPrContents_cols);
+                if (pCols.get())
+                {
+                    RTFValue::Pointer_t pNum = pCols->getAttributes().find(NS_ooxml::LN_CT_Columns_num);
+                    if (pNum.get() && pNum->getInt() > 1)
+                        bColumns = true;
+                }
+                if (bColumns)
+                {
+                    sal_uInt8 sBreak[] = { 0xe };
+                    Mapper().startCharacterGroup();
+                    Mapper().text(sBreak, 1);
+                    Mapper().endCharacterGroup();
+                }
+                else
+                    dispatchSymbol(RTF_PAGE);
             }
             break;
         case RTF_CHFTN:


More information about the Libreoffice-commits mailing list