summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-04-18 16:47:14 +0200
committerDavid Tardon <dtardon@redhat.com>2014-04-19 15:51:13 +0000
commitd65fff78bfcb4c557d35eec8293c9109ab34fc03 (patch)
tree78ff91a558d3d040696d941f6140f98b11945032
parenta5cc073852a57adf62fa83b29e1259a35169b10c (diff)
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) (cherry picked from commit 6b6e4d471c2954d34d280398ed1c986d7fb27ae1) Conflicts: writerfilter/source/rtftok/rtfsprm.hxx Change-Id: I2538f440e29cef6d40db2ea914e4afcbfe411890 Reviewed-on: https://gerrit.libreoffice.org/9100 Tested-by: David Tardon <dtardon@redhat.com> Reviewed-by: David Tardon <dtardon@redhat.com>
-rw-r--r--sw/qa/extras/rtfimport/data/fdo75735.rtf8
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx7
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx2
-rw-r--r--writerfilter/source/rtftok/rtfsprm.cxx6
-rw-r--r--writerfilter/source/rtftok/rtfsprm.hxx2
5 files changed, 22 insertions, 3 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo75735.rtf b/sw/qa/extras/rtfimport/data/fdo75735.rtf
new file mode 100644
index 000000000000..7d844bd485e9
--- /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 4d61147eaa65..908178f71f74 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>
@@ -1628,6 +1629,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 b5a5f1333975..d06f6bcd170c 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -83,7 +83,7 @@ static Id lcl_getParagraphBorder(sal_uInt32 nIndex)
static void lcl_putNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId, RTFValue::Pointer_t pValue,
bool bOverwrite = true, 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 ace6735faad3..2af212136027 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -78,9 +78,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 dc82256092c3..19f0514f5a39 100644
--- a/writerfilter/source/rtftok/rtfsprm.hxx
+++ b/writerfilter/source/rtftok/rtfsprm.hxx
@@ -48,7 +48,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 existing entries.
void set(Id nKeyword, RTFValue::Pointer_t pValue, bool bOverwrite = true);
bool erase(Id nKeyword);