[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - sw/qa writerfilter/source

Miklos Vajna vmiklos at suse.cz
Sun Aug 11 12:44:40 PDT 2013


 sw/qa/extras/rtfimport/data/fdo53556.rtf       |   49 ++++++++++
 sw/qa/extras/rtfimport/data/posh-posv.rtf      |   24 +++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |   28 +++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   40 ++++++--
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    5 +
 writerfilter/source/rtftok/rtfsdrimport.cxx    |  118 +++++++++++++++++++++----
 writerfilter/source/rtftok/rtfsdrimport.hxx    |    8 +
 7 files changed, 244 insertions(+), 28 deletions(-)

New commits:
commit b93ad36d89b16890ba213c9e5e44973591a2d65c
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Jun 15 19:05:50 2013 +0200

    fdo#53556 RTF import: fix visibility and text wrapping issues
    
    This is a backport of 6 commits from master:
    
    - the first 3 are earlier fixes on master, without them the test doc
      has only 1 shape imported out of 3 (on master, this was already fine)
    - the next 2 are the real fixes
    - the last one is the testcase
    
    (cherry picked from commits 9d640dc6ad0f0b58fa62b70f78478e2bc8796e69,
    2fc088afdf6dcb2defbd462a9e64ba7e53ba5caf,
    4ab658b56f5c6ff0082d38d8ace1924d11e30e96,
    03f0cbd354646733977e4dec754c0113a5cbc3c9,
    9f1f7199736e2ae07b34849ba66f61a1ef5782e8 and
    aa6959ba2c4ef1b718d8249fd47faaf677b16111)
    
    Conflicts:
    	sw/qa/extras/rtfimport/rtfimport.cxx
    	writerfilter/source/rtftok/rtfdocumentimpl.cxx
    	writerfilter/source/rtftok/rtfdocumentimpl.hxx
    	writerfilter/source/rtftok/rtfsdrimport.cxx
    
    Change-Id: If58376aec31ab00cab19221beed73e8275a834d2
    Reviewed-on: https://gerrit.libreoffice.org/5328
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/rtfimport/data/fdo53556.rtf b/sw/qa/extras/rtfimport/data/fdo53556.rtf
new file mode 100644
index 0000000..aafa11c
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo53556.rtf
@@ -0,0 +1,49 @@
+{\rtf1\ansi\deff0\viewkind1\paperw12240\paperh15840\marglsxn0\margrsxn0\margtsxn0\margbsxn0
+{\shp\shpbxpage\shpbypage\shpwr5\shpfhdr0\shpfblwtxt0\shpz3\shpleft1000\shpright12000\shptop1000\shpbottom1800
+{\sp
+{\sn fFilled}
+{\sv 0}
+}
+{\shpinst
+{\sp
+{\sn fLine}
+{\sv 0}
+}
+{\shptxt
+{\pard\cb1 \qc\sl367 \f0\fs32\b\cf2 ARL STATISTICS 2011-2012\line WORKSHEET\plain\par}
+}
+}
+}
+{\shp\shpbxpage\shpbypage\shpwr5\shpfhdr0\shpfblwtxt0\shpz18\shpleft1000\shpright4700\shptop900\shpbottom15040
+{\sp
+{\sn fFilled}
+{\sv 0}
+}
+{\shpinst
+{\sp
+{\sn shapeType}
+{\sv 1}
+}
+{\sp
+{\sn fLine}
+{\sv 0}
+}
+}
+}
+{\shp\shpbxpage\shpbypage\shpwr5\shpfhdr0\shpfblwtxt0\shpz2\shpleft1000\shpright12000\shptop2480\shpbottom3320
+{\sp
+{\sn fFilled}
+{\sv 0}
+}
+{\shpinst
+{\sp
+{\sn fLine}
+{\sv 0}
+}
+{\shptxt
+{\pard\cb1 \ql\sl252 \f0\fs22\cf2 This worksheet is designed to help you plan your submission for the 2011-2012 ARL Statistics. The figures on this worksheet should be similar to those in the Summary page of your web form, except in cases where data are unavailable. If an exact figure is unavailable, use NA/UA. If the appropriate answer is zero or none, use 0.\plain\par}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/data/posh-posv.rtf b/sw/qa/extras/rtfimport/data/posh-posv.rtf
new file mode 100644
index 0000000..5ff1fe8
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/posh-posv.rtf
@@ -0,0 +1,24 @@
+{\rtf1
+{\shp
+{\*\shpinst\shpleft0\shptop0\shpright3727\shpbottom2212\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 202}
+}
+{\shptxt test}
+{\sp
+{\sn fFitShapeToText}
+{\sv 1}
+}
+{\sp
+{\sn posh}
+{\sv 2}
+}
+{\sp
+{\sn posv}
+{\sv 2}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index d432f0b..0a56525 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -10,6 +10,7 @@
 #include <com/sun/star/document/XImporter.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
 #include <com/sun/star/drawing/LineStyle.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/graphic/GraphicType.hpp>
@@ -34,6 +35,8 @@
 #include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/text/WrapTextMode.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
 
 #include <rtl/ustring.hxx>
@@ -150,6 +153,8 @@ public:
     void testFdo67365();
     void testFdo67498();
     void testFdo47440();
+    void testPoshPosv();
+    void testFdo53556();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -287,6 +292,8 @@ void Test::run()
         {"fdo67365.rtf", &Test::testFdo67365},
         {"fdo67498.rtf", &Test::testFdo67498},
         {"fdo47440.rtf", &Test::testFdo47440},
+        {"posh-posv.rtf", &Test::testPoshPosv},
+        {"fdo53556.rtf", &Test::testFdo53556},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1389,6 +1396,27 @@ void Test::testFdo47440()
     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(0), "VertOrientRelation"));
 }
 
+void Test::testPoshPosv()
+{
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty<sal_Int16>(xDraws->getByIndex(0), "HoriOrient"));
+    CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, getProperty<sal_Int16>(xDraws->getByIndex(0), "VertOrient"));
+}
+
+void Test::testFdo53556()
+{
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    // This was drawing::FillStyle_SOLID, which resulted in being non-transparent, hiding text which would be visible.
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xDraws->getByIndex(2), "FillStyle"));
+
+    // This was a com.sun.star.drawing.CustomShape, which resulted in lack of word wrapping in the bugdoc.
+    uno::Reference<beans::XPropertySet> xShapeProperties(xDraws->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xShapeProperties, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), xShapeDescriptor->getShapeType());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 5895057..2383c11 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1467,10 +1467,11 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_SHPTXT:
         case RTF_DPTXBXTEXT:
             m_aStates.top().nDestinationState = DESTINATION_SHAPETEXT;
+            checkFirstRun();
             dispatchFlag(RTF_PARD);
             m_bNeedPap = true;
-            OSL_ENSURE(!m_aShapetextBuffer.size(), "shapetext buffer is not empty");
-            m_aStates.top().pCurrentBuffer = &m_aShapetextBuffer;
+            if (nKeyword == RTF_SHPTXT)
+                m_pSdrImport->resolve(m_aStates.top().aShape, false);
             break;
         case RTF_FORMFIELD:
             if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
@@ -2251,7 +2252,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                 // Reset everything.
                 m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms;
                 m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes;
-                if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT)
+                if (m_aStates.top().pCurrentBuffer != &m_aShapetextBuffer)
                     m_aStates.top().pCurrentBuffer = 0;
             }
             else
@@ -2573,6 +2574,9 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                                 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]);
+                                checkFirstRun();
+                                Mapper().startShape(m_aStates.top().aDrawingObject.xShape);
+                                m_aStates.top().aDrawingObject.bHadShapeText = true;
                             }
                             break;
                         default:
@@ -3891,12 +3895,16 @@ int RTFDocumentImpl::popState()
             break;
         case DESTINATION_SHAPEPROPERTYVALUE:
             if (aState.aShape.aProperties.size())
+            {
                 aState.aShape.aProperties.back().second = m_aStates.top().aDestinationText.makeStringAndClear();
+                if (m_aStates.top().bHadShapeText)
+                    m_pSdrImport->append(aState.aShape.aProperties.back().first, aState.aShape.aProperties.back().second);
+            }
             break;
         case DESTINATION_PICPROP:
         case DESTINATION_SHAPEINSTRUCTION:
-            if (!m_bObject && !aState.bInListpicture)
-                m_pSdrImport->resolve(m_aStates.top().aShape);
+            if (!m_bObject && !aState.bInListpicture && !m_aStates.top().bHadShapeText)
+                m_pSdrImport->resolve(m_aStates.top().aShape, true);
             break;
         case DESTINATION_BOOKMARKSTART:
             {
@@ -4160,8 +4168,11 @@ int RTFDocumentImpl::popState()
 
                 m_pSdrImport->resolveFLine(xPropertySet, rDrawing.nFLine);
 
-                Mapper().startShape(xShape);
-                replayShapetext();
+                if (!m_aStates.top().aDrawingObject.bHadShapeText)
+                {
+                    Mapper().startShape(xShape);
+                    replayShapetext();
+                }
                 Mapper().endShape();
             }
             break;
@@ -4614,6 +4625,14 @@ int RTFDocumentImpl::popState()
                     m_xDocumentProperties->setTitle(aState.aDestinationText.makeStringAndClear());
             }
             break;
+        case DESTINATION_SHAPETEXT:
+            // If we're leaving the shapetext group (it may have nested ones) and this is a shape, not an old drawingobject.
+            if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT && !m_aStates.top().aDrawingObject.bHadShapeText)
+            {
+                m_aStates.top().bHadShapeText = true;
+                m_pSdrImport->close();
+            }
+            break;
         default:
             {
                 if (m_aStates.size() && m_aStates.top().nDestinationState == DESTINATION_PICT)
@@ -4751,7 +4770,9 @@ RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl)
     pCurrentBuffer(0),
     bHasTableStyle(false),
     bInListpicture(false),
-    bStartedTrackchange(false)
+    bStartedTrackchange(false),
+    bInBackground(false),
+    bHadShapeText(false)
 {
 }
 
@@ -4807,7 +4828,8 @@ RTFDrawingObject::RTFDrawingObject()
     bHasFillColor(false),
     nDhgt(0),
     nFLine(-1),
-    nPolyLineCount(0)
+    nPolyLineCount(0),
+    bHadShapeText(false)
 {
 }
 
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index a4e73ad..b16a3a5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -266,6 +266,7 @@ namespace writerfilter {
                 sal_Int32 nFLine;
                 sal_Int32 nPolyLineCount;
                 uno::Sequence<awt::Point> aPolyLinePoints;
+                bool bHadShapeText;
         };
 
         /// Stores the properties of a picture.
@@ -402,6 +403,10 @@ namespace writerfilter {
                 /// If we're inside a \listpicture group.
                 bool bInListpicture;
                 bool bStartedTrackchange; ///< Track change is started, need to end it before popping.
+                /// If we're inside a \background group.
+                bool bInBackground;
+
+                bool bHadShapeText;
         };
 
         class RTFTokenizer;
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 07913b1..765ea71 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -14,6 +14,7 @@
 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/text/HoriOrientation.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
@@ -40,7 +41,8 @@ namespace rtftok {
 
 RTFSdrImport::RTFSdrImport(RTFDocumentImpl& rDocument,
         uno::Reference<lang::XComponent> const& xDstDoc)
-    : m_rImport(rDocument)
+    : m_rImport(rDocument),
+    m_bTextFrame(false)
 {
     uno::Reference<drawing::XDrawPageSupplier> xDrawings(xDstDoc, uno::UNO_QUERY);
     if (xDrawings.is())
@@ -114,13 +116,74 @@ void RTFSdrImport::resolveFLine(uno::Reference<beans::XPropertySet> xPropertySet
         xPropertySet->setPropertyValue("LineStyle", uno::makeAny(drawing::LineStyle_NONE));
 }
 
-void RTFSdrImport::resolve(RTFShape& rShape)
+void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> xShape, OUString aKey, OUString aValue)
+{
+    uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+    sal_Int16 nHoriOrient = 0;
+    sal_Int16 nVertOrient = 0;
+    bool bFilled = true;
+    if (aKey == "posh")
+    {
+        switch (aValue.toInt32())
+        {
+            case 1:
+                nHoriOrient = text::HoriOrientation::LEFT;
+                break;
+            case 2:
+                nHoriOrient = text::HoriOrientation::CENTER;
+                break;
+            case 3:
+                nHoriOrient = text::HoriOrientation::RIGHT;
+                break;
+            case 4:
+                nHoriOrient = text::HoriOrientation::INSIDE;
+                break;
+            case 5:
+                nHoriOrient = text::HoriOrientation::OUTSIDE;
+                break;
+            default:
+                break;
+        }
+    }
+    else if (aKey == "posv")
+    {
+        switch (aValue.toInt32())
+        {
+            case 1:
+                nVertOrient = text::VertOrientation::TOP;
+                break;
+            case 2:
+                nVertOrient = text::VertOrientation::CENTER;
+                break;
+            case 3:
+                nVertOrient = text::VertOrientation::BOTTOM;
+                break;
+            default:
+                break;
+        }
+    }
+    else if (aKey == "fFilled")
+        bFilled = aValue.toInt32() == 1;
+
+    if (nHoriOrient != 0)
+        xPropertySet->setPropertyValue("HoriOrient", uno::makeAny(nHoriOrient));
+    if (nVertOrient != 0)
+        xPropertySet->setPropertyValue("VertOrient", uno::makeAny(nVertOrient));
+    if (!bFilled)
+    {
+        if (m_bTextFrame)
+            xPropertySet->setPropertyValue("BackColorTransparency", uno::makeAny(sal_Int32(100)));
+        else
+            xPropertySet->setPropertyValue("FillStyle", uno::makeAny(drawing::FillStyle_NONE));
+    }
+}
+
+void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
 {
     int nType = -1;
     bool bPib = false;
     bool bCustom = false;
-    bool bTextFrame = false;
-    bool bFilled = true;
+    m_bTextFrame = false;
 
     uno::Reference<drawing::XShape> xShape;
     uno::Reference<beans::XPropertySet> xPropertySet;
@@ -140,6 +203,13 @@ void RTFSdrImport::resolve(RTFShape& rShape)
     oox::vml::FillModel aFillModel; // Gradient.
     oox::vml::ShadowModel aShadowModel; // Shadow.
 
+    // The spec doesn't state what is the default for shapeType, Word seems to implement it as a rectangle.
+    if (std::find_if(rShape.aProperties.begin(),
+                rShape.aProperties.end(),
+                boost::bind(&OUString::equals, boost::bind(&std::pair<OUString, OUString>::first, _1), OUString("shapeType")))
+            == rShape.aProperties.end())
+        rShape.aProperties.insert(rShape.aProperties.begin(), std::pair<OUString, OUString>("shapeType", OUString::number(ESCHER_ShpInst_Rectangle)));
+
     for (std::vector< std::pair<OUString, OUString> >::iterator i = rShape.aProperties.begin();
             i != rShape.aProperties.end(); ++i)
     {
@@ -153,10 +223,10 @@ void RTFSdrImport::resolve(RTFShape& rShape)
                     break;
                 case ESCHER_ShpInst_Rectangle:
                 case ESCHER_ShpInst_TextBox:
-                    if (!m_rImport.getShapetextBuffer().empty())
+                    if (!bClose)
                     {
                         createShape("com.sun.star.text.TextFrame", xShape, xPropertySet);
-                        bTextFrame = true;
+                        m_bTextFrame = true;
                         std::vector<beans::PropertyValue> aDefaults = getTextFrameDefaults(true);
                         for (size_t j = 0; j < aDefaults.size(); ++j)
                             xPropertySet->setPropertyValue(aDefaults[j].Name, aDefaults[j].Value);
@@ -171,12 +241,12 @@ void RTFSdrImport::resolve(RTFShape& rShape)
 
             // Defaults
             aAny <<= (sal_uInt32)0xffffff; // White in Word, kind of blue in Writer.
-            if (xPropertySet.is() && !bTextFrame)
+            if (xPropertySet.is() && !m_bTextFrame)
                 xPropertySet->setPropertyValue("FillColor", aAny);
         }
         else if ( i->first == "wzName" )
         {
-            if (bTextFrame)
+            if (m_bTextFrame)
             {
                 uno::Reference<container::XNamed> xNamed(xShape, uno::UNO_QUERY);
                 xNamed->setName(i->second);
@@ -194,7 +264,7 @@ void RTFSdrImport::resolve(RTFShape& rShape)
         else if (i->first == "fillColor" && xPropertySet.is())
         {
             aAny <<= msfilter::util::BGRToRGB(i->second.toInt32());
-            if (bTextFrame)
+            if (m_bTextFrame)
                 xPropertySet->setPropertyValue("BackColor", aAny);
             else
                 xPropertySet->setPropertyValue("FillColor", aAny);
@@ -393,6 +463,8 @@ void RTFSdrImport::resolve(RTFShape& rShape)
         else if (i->first == "shadowOffsetX")
             // EMUs to points
             aShadowModel.moOffset.set(OUString::number(i->second.toDouble() / 12700) + "pt");
+        else if (i->first == "posh" || i->first == "posv" || i->first == "fFilled")
+            applyProperty(xShape, i->first, i->second);
         else if (i->first == "posrelh")
         {
             switch (i->second.toInt32())
@@ -415,15 +487,13 @@ void RTFSdrImport::resolve(RTFShape& rShape)
                     break;
             }
         }
-        else if (i->first == "fFilled")
-            bFilled = i->second.toInt32() == 1;
         else
             SAL_INFO("writerfilter", "TODO handle shape property '" << i->first << "':'" << i->second << "'");
     }
 
     if (xPropertySet.is())
     {
-        if (!bTextFrame)
+        if (!m_bTextFrame)
         {
             xPropertySet->setPropertyValue("LineColor", aLineColor);
             xPropertySet->setPropertyValue("LineWidth", aLineWidth);
@@ -443,13 +513,11 @@ void RTFSdrImport::resolve(RTFShape& rShape)
         }
         if (rShape.oZ)
             resolveDhgt(xPropertySet, *rShape.oZ);
-        if (bTextFrame)
+        if (m_bTextFrame)
             // Writer textframes implement text::WritingMode2, which is a different data type.
             xPropertySet->setPropertyValue("WritingMode", uno::makeAny(sal_Int16(eWritingMode)));
         else
             xPropertySet->setPropertyValue("TextWritingMode", uno::makeAny(eWritingMode));
-        if (!bFilled)
-            xPropertySet->setPropertyValue("BackColorTransparency", uno::makeAny(sal_Int32(100)));
     }
 
     if (nType == ESCHER_ShpInst_PictureFrame) // picture frame
@@ -459,7 +527,7 @@ void RTFSdrImport::resolve(RTFShape& rShape)
         return;
     }
 
-    if (m_xDrawPage.is() && !bTextFrame)
+    if (m_xDrawPage.is() && !m_bTextFrame)
         m_xDrawPage->add(xShape);
     if (bCustom && xShape.is())
     {
@@ -499,7 +567,7 @@ void RTFSdrImport::resolve(RTFShape& rShape)
     // Set position and size
     if (xShape.is())
     {
-        if (bTextFrame)
+        if (m_bTextFrame)
         {
             xPropertySet->setPropertyValue("HoriOrientPosition", uno::makeAny(rShape.nLeft));
             xPropertySet->setPropertyValue("VertOrientPosition", uno::makeAny(rShape.nTop));
@@ -533,10 +601,24 @@ void RTFSdrImport::resolve(RTFShape& rShape)
 
     // Send it to dmapper
     m_rImport.Mapper().startShape(xShape);
-    m_rImport.replayShapetext();
+    if (bClose)
+    {
+        m_rImport.replayShapetext();
+        m_rImport.Mapper().endShape();
+    }
+    m_xShape = xShape;
+}
+
+void RTFSdrImport::close()
+{
     m_rImport.Mapper().endShape();
 }
 
+void RTFSdrImport::append(OUString aKey, OUString aValue)
+{
+    applyProperty(m_xShape, aKey, aValue);
+}
+
 } // namespace rtftok
 } // namespace writerfilter
 
diff --git a/writerfilter/source/rtftok/rtfsdrimport.hxx b/writerfilter/source/rtftok/rtfsdrimport.hxx
index 165c86f..f177e44 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.hxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.hxx
@@ -21,7 +21,9 @@ namespace writerfilter {
                 RTFSdrImport(RTFDocumentImpl& rImport, uno::Reference<lang::XComponent> const& xDstDoc);
                 virtual ~RTFSdrImport();
 
-                void resolve(RTFShape& rShape);
+                void resolve(RTFShape& rShape, bool bClose);
+                void close();
+                void append(OUString aKey, OUString aValue);
                 void resolveDhgt(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nZOrder);
                 void resolveFLine(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nFLine);
                 /**
@@ -32,9 +34,13 @@ namespace writerfilter {
                 std::vector<beans::PropertyValue> getTextFrameDefaults(bool bNew);
             private:
                 void createShape(OUString aService, uno::Reference<drawing::XShape>& xShape, uno::Reference<beans::XPropertySet>& xPropertySet);
+                void applyProperty(uno::Reference<drawing::XShape> xShape, OUString aKey, OUString aValue);
 
                 RTFDocumentImpl& m_rImport;
                 uno::Reference<drawing::XDrawPage> m_xDrawPage;
+                uno::Reference<drawing::XShape> m_xShape;
+                /// If m_xShape is imported as a Writer text frame (instead of a drawinglayer rectangle).
+                bool m_bTextFrame;
         };
     } // namespace rtftok
 } // namespace writerfilter


More information about the Libreoffice-commits mailing list