summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-03-14 12:11:13 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-03-14 13:32:29 +0100
commit7c53577f325e5260c538f9ca42cda54ca1a24b7a (patch)
treec9a5b665d98fc24c7a57c855f9885c621d3ebdc0
parentaf88ab2ee9167279cb70a577fb399d23f2ce136f (diff)
RTF import: fix dobxpage before dptxbx
The problem was that dobxpage arrived first, set HoriOrientRelation to FRAME, then dptxbx tried to apply defaults, which overwrote the already set HoriOrientRelation. Fix this by only applying properties which are not set yet. Change-Id: I108f3363a2758eee0242533fe92e511e8c522b68
-rw-r--r--sw/qa/extras/rtfimport/data/dptxbx-relation.rtf5
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx6
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx16
3 files changed, 26 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfimport/data/dptxbx-relation.rtf b/sw/qa/extras/rtfimport/data/dptxbx-relation.rtf
new file mode 100644
index 000000000000..82f0741284bd
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/dptxbx-relation.rtf
@@ -0,0 +1,5 @@
+{\rtf1
+{\*\do\dobxpage\dobypara\dodhgt8192\dptxbx\dptxbxmar0
+{\dptxbxtext\ltrpar\f4\fs20\cf1\vertalc\qc\ltrch To:\par}
+\dpx941\dpy2114\dpxsize1349\dpysize221\dplinehollow0}
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 5965aae2e1e0..01814b92c1f3 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1528,6 +1528,12 @@ DECLARE_RTFIMPORT_TEST(testFdo69289, "fdo69289.rtf")
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength());
}
+DECLARE_RTFIMPORT_TEST(testDptxbxRelation, "dptxbx-relation.rtf")
+{
+ // This was FRAME, not PAGE_FRAME, even if dobxpage is in the document.
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(getShape(1), "HoriOrientRelation"));
+}
+
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 1f9306e42dcc..f5935f6c076f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2237,6 +2237,17 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
return 0;
}
+// Checks if rName is contained at least once in rProperties as a key.
+bool lcl_findPropertyName(const std::vector<beans::PropertyValue>& rProperties, const OUString& rName)
+{
+ for (std::vector<beans::PropertyValue>::const_iterator it = rProperties.begin(); it != rProperties.end(); ++it)
+ {
+ if (it->Name == rName)
+ return true;
+ }
+ return false;
+}
+
int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
{
setNeedSect();
@@ -2848,7 +2859,10 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.text.TextFrame"), uno::UNO_QUERY);
std::vector<beans::PropertyValue> aDefaults = m_pSdrImport->getTextFrameDefaults(false);
for (size_t i = 0; i < aDefaults.size(); ++i)
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aDefaults[i]);
+ {
+ if (!lcl_findPropertyName(m_aStates.top().aDrawingObject.aPendingProperties, aDefaults[i].Name))
+ m_aStates.top().aDrawingObject.aPendingProperties.push_back(aDefaults[i]);
+ }
checkFirstRun();
Mapper().startShape(m_aStates.top().aDrawingObject.xShape);
m_aStates.top().aDrawingObject.bHadShapeText = true;