diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-04-18 16:47:14 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2014-04-22 09:45:46 +0200 |
commit | 761932cbcc2479bfd4a7af15488587cfe685996d (patch) | |
tree | 19d0b243b58ddb8ad8a6584af0f80e92f6f0c5bf /writerfilter | |
parent | 99bf0a6a94b6a8c92b18390f863ac46b71815200 (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>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 2 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfsprm.cxx | 6 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfsprm.hxx | 2 |
3 files changed, 7 insertions, 3 deletions
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); |