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

Miklos Vajna vmiklos at collabora.co.uk
Fri Apr 18 08:35:10 PDT 2014


 sw/qa/extras/rtfimport/data/fdo75735.rtf       |    8 ++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |    7 +++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    2 +-
 writerfilter/source/rtftok/rtfsprm.cxx         |    6 +++++-
 writerfilter/source/rtftok/rtfsprm.hxx         |    2 +-
 5 files changed, 22 insertions(+), 3 deletions(-)

New commits:
commit 6b6e4d471c2954d34d280398ed1c986d7fb27ae1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Apr 18 16:47:14 2014 +0200

    fdo#75735 RTF import: fix COW when writing a nested structure
    
    Regression from a48e2fd9049797110b3b2505c363557284987ca8 (fdo#44736 -
    convert RTFSprms to a copy-on-write structure., 2012-12-07)
    
    Change-Id: I2538f440e29cef6d40db2ea914e4afcbfe411890

diff --git a/sw/qa/extras/rtfimport/data/fdo75735.rtf b/sw/qa/extras/rtfimport/data/fdo75735.rtf
new file mode 100644
index 0000000..7d844bd
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo75735.rtf
@@ -0,0 +1,8 @@
+{\rtf1\ansi
+{\fonttbl \f0\froman Times;}
+\pard\tx1440\plain
+{\tx360\tx720\tx1080\tab\tab\tab\tab This is line one.\
+}
+{\tx480\tx960\tab\tab\tab This is line two.\
+}
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 19196a0..1e3ad95 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -22,6 +22,7 @@
 #include <com/sun/star/style/LineSpacing.hpp>
 #include <com/sun/star/style/LineSpacingMode.hpp>
 #include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/style/TabStop.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/table/BorderLineStyle.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
@@ -1656,6 +1657,12 @@ DECLARE_RTFIMPORT_TEST(testFdo77267, "fdo77267.rtf")
     CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
 }
 
+DECLARE_RTFIMPORT_TEST(testFdo75735, "fdo75735.rtf")
+{
+    // Number of tabstops in the second paragraph should be 3, was 6.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty< uno::Sequence<style::TabStop> >(getParagraph(2), "ParaTabStops").getLength());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 1a0fd1a..7fffb14 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -77,7 +77,7 @@ static Id lcl_getParagraphBorder(sal_uInt32 nIndex)
 static void lcl_putNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId, RTFValue::Pointer_t pValue,
         RTFOverwrite eOverwrite = OVERWRITE_YES, bool bAttribute = true)
 {
-    RTFValue::Pointer_t pParent = rSprms.find(nParent);
+    RTFValue::Pointer_t pParent = rSprms.find(nParent, /*bFirst=*/true, /*bForWrite=*/true);
     if (!pParent.get())
     {
         RTFSprms aAttributes;
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index dc55aca..48ce468 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -79,9 +79,13 @@ std::string RTFSprm::toString() const
     return aBuf.makeStringAndClear().getStr();
 }
 
-RTFValue::Pointer_t RTFSprms::find(Id nKeyword, bool bFirst)
+RTFValue::Pointer_t RTFSprms::find(Id nKeyword, bool bFirst, bool bForWrite)
 {
     RTFValue::Pointer_t pValue;
+
+    if (bForWrite)
+        ensureCopyBeforeWrite();
+
     for (RTFSprms::Iterator_t i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
         if (i->first == nKeyword)
         {
diff --git a/writerfilter/source/rtftok/rtfsprm.hxx b/writerfilter/source/rtftok/rtfsprm.hxx
index 6b25fa4..de5cd59 100644
--- a/writerfilter/source/rtftok/rtfsprm.hxx
+++ b/writerfilter/source/rtftok/rtfsprm.hxx
@@ -61,7 +61,7 @@ namespace writerfilter {
             RTFSprms(const RTFSprms& rSprms);
             ~RTFSprms();
             RTFSprms& operator=(const RTFSprms& rOther);
-            RTFValue::Pointer_t find(Id nKeyword, bool bFirst = true);
+            RTFValue::Pointer_t find(Id nKeyword, bool bFirst = true, bool bForWrite = false);
             /// Does the same as ->push_back(), except that it can overwrite or ignore existing entries.
             void set(Id nKeyword, RTFValue::Pointer_t pValue, RTFOverwrite eOverwrite = OVERWRITE_YES);
             bool erase(Id nKeyword);


More information about the Libreoffice-commits mailing list