Kaydet (Commit) 6b6e4d47 authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#75735 RTF import: fix COW when writing a nested structure

Regression from a48e2fd9 (fdo#44736 -
convert RTFSprms to a copy-on-write structure., 2012-12-07)

Change-Id: I2538f440e29cef6d40db2ea914e4afcbfe411890
üst fbcdc3ec
{\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.\
}
}
......@@ -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: */
......@@ -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;
......
......@@ -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)
{
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment