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

Miklos Vajna vmiklos at collabora.co.uk
Fri Mar 14 05:32:51 PDT 2014


 sw/qa/extras/rtfimport/data/dptxbx-relation.rtf |    5 +++++
 sw/qa/extras/rtfimport/rtfimport.cxx            |    6 ++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx  |   16 +++++++++++++++-
 3 files changed, 26 insertions(+), 1 deletion(-)

New commits:
commit 7c53577f325e5260c538f9ca42cda54ca1a24b7a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Mar 14 12:11:13 2014 +0100

    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

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 0000000..82f0741
--- /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 5965aae..01814b9 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 1f9306e..f5935f6 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;


More information about the Libreoffice-commits mailing list