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

Miklos Vajna vmiklos at suse.cz
Mon Jul 1 02:44:18 PDT 2013


 sw/qa/extras/rtfimport/data/fdo47802.rtf       |   46 +++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |   10 +++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   25 +++++++++----
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    4 +-
 writerfilter/source/rtftok/rtfvalue.cxx        |   32 ++++++++++++++++-
 writerfilter/source/rtftok/rtfvalue.hxx        |    7 +++
 6 files changed, 113 insertions(+), 11 deletions(-)

New commits:
commit d892671c118158490b08d24eea7398330a23599b
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jul 1 11:37:30 2013 +0200

    fdo#47802 testcase
    
    Change-Id: Ib3e399efb0d1116473bc5ff0e1b858b2cfa4aec8

diff --git a/sw/qa/extras/rtfimport/data/fdo47802.rtf b/sw/qa/extras/rtfimport/data/fdo47802.rtf
new file mode 100644
index 0000000..cbbf94f
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo47802.rtf
@@ -0,0 +1,46 @@
+{\rtf1
+\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440
+\ltrrow\trowd \cellx4680\cellx9468\pard\plain \ltrpar\ql \li0\ri0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\yts15 \rtlch\fcs1 
+\af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid5924912 
+{\shp
+{\*\shpinst\shpleft705\shptop-130\shpright1920\shpbottom335\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 1}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn lTxid}
+{\sv 65536}
+}
+{\sp
+{\sn dhgt}
+{\sv 251658240}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 1}
+}
+{\shptxt \ltrpar \pard\plain \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 
+\af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1038\langfe1033\langnp1038\insrsid5924912 C}
+{\par }
+}
+}
+}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid5924912 A\cell B\cell 
+}
+\pard\plain \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 
+{\row }
+\pard \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 61de96e..6b628c3 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -149,6 +149,7 @@ public:
     void testN823655();
     void testFdo66040();
     void testN823675();
+    void testFdo47802();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -283,6 +284,7 @@ void Test::run()
         {"n823655.rtf", &Test::testN823655},
         {"fdo66040.rtf", &Test::testFdo66040},
         {"n823675.rtf", &Test::testN823675},
+        {"fdo47802.rtf", &Test::testFdo47802},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1377,6 +1379,14 @@ void Test::testN823675()
     CPPUNIT_ASSERT_EQUAL(OUString("Symbol"), aFont.Name);
 }
 
+void Test::testFdo47802()
+{
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    // Shape inside table was ignored.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 818d80eb0cee65d1bcc4fdb74b32a7c42cc1336e
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jun 28 16:47:49 2013 +0200

    RTF import: support shapes inside tables
    
    This is a better fix for fdo#47802, now that shape import is no longer
    buffered.
    
    Change-Id: Idce6d11e6774d1fe7fc04b6a52d5b77a3879381e

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 31cc365..96bfce6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1197,6 +1197,10 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer)
             Mapper().endCharacterGroup();
         else if (aPair.first == BUFFER_PAR)
             parBreak();
+        else if (aPair.first == BUFFER_STARTSHAPE)
+            m_pSdrImport->resolve(aPair.second->getShape(), false);
+        else if (aPair.first == BUFFER_ENDSHAPE)
+            m_pSdrImport->close();
         else
             SAL_WARN("writerfilter", "should not happen");
     }
@@ -1313,11 +1317,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
             m_aStates.top().nDestinationState = DESTINATION_SHAPE;
             break;
         case RTF_SHPINST:
-            // Don't try to support shapes inside tables for now.
-            if (m_aStates.top().pCurrentBuffer != &m_aTableBuffer)
-                m_aStates.top().nDestinationState = DESTINATION_SHAPEINSTRUCTION;
-            else
-                m_aStates.top().nDestinationState = DESTINATION_SKIP;
+            m_aStates.top().nDestinationState = DESTINATION_SHAPEINSTRUCTION;
             break;
         case RTF_NESTTABLEPROPS:
             // Don't try to support nested tables having table styles for now.
@@ -1445,7 +1445,15 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
             dispatchFlag(RTF_PARD);
             m_bNeedPap = true;
             if (nKeyword == RTF_SHPTXT)
-                m_pSdrImport->resolve(m_aStates.top().aShape, false);
+            {
+                if (!m_aStates.top().pCurrentBuffer)
+                    m_pSdrImport->resolve(m_aStates.top().aShape, false);
+                else
+                {
+                    RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aShape));
+                    m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_STARTSHAPE, pValue));
+                }
+            }
             break;
         case RTF_FORMFIELD:
             if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
@@ -4602,7 +4610,10 @@ int RTFDocumentImpl::popState()
             if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT && !m_aStates.top().aDrawingObject.bHadShapeText)
             {
                 m_aStates.top().bHadShapeText = true;
-                m_pSdrImport->close();
+                if (!m_aStates.top().pCurrentBuffer)
+                    m_pSdrImport->close();
+                else
+                    m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_ENDSHAPE, RTFValue::Pointer_t()));
             }
             break;
         default:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index e48fe5d..0d77b6e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -195,7 +195,9 @@ namespace writerfilter {
             BUFFER_TEXT,
             BUFFER_UTEXT,
             BUFFER_ENDRUN,
-            BUFFER_PAR
+            BUFFER_PAR,
+            BUFFER_STARTSHAPE,
+            BUFFER_ENDSHAPE
         };
 
         /// Form field types
commit 7a8f720cc0b1e84339341919f9520cb25ce5df34
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jun 28 16:39:48 2013 +0200

    RTFValue: support storing RTFShape
    
    Change-Id: Ia24fe7556598ad88f3b72a62bef2361a3fd0a712

diff --git a/writerfilter/source/rtftok/rtfvalue.cxx b/writerfilter/source/rtftok/rtfvalue.cxx
index a9f31f8..b786b09 100644
--- a/writerfilter/source/rtftok/rtfvalue.cxx
+++ b/writerfilter/source/rtftok/rtfvalue.cxx
@@ -8,6 +8,7 @@
  */
 
 #include <rtfreferenceproperties.hxx>
+#include <rtfdocumentimpl.hxx>
 
 namespace writerfilter {
 namespace rtftok {
@@ -15,7 +16,8 @@ namespace rtftok {
 
 RTFValue::RTFValue(int nValue, OUString sValue, RTFSprms rAttributes,
         RTFSprms rSprms, uno::Reference<drawing::XShape> xShape,
-        uno::Reference<io::XInputStream> xStream, uno::Reference<embed::XEmbeddedObject> xObject, bool bForceString)
+        uno::Reference<io::XInputStream> xStream, uno::Reference<embed::XEmbeddedObject> xObject, bool bForceString,
+        RTFShape aShape)
     : m_nValue(nValue),
     m_sValue(sValue),
     m_xShape(xShape),
@@ -25,6 +27,7 @@ RTFValue::RTFValue(int nValue, OUString sValue, RTFSprms rAttributes,
 {
     m_pAttributes.reset(new RTFSprms(rAttributes));
     m_pSprms.reset(new RTFSprms(rSprms));
+    m_pShape.reset(new RTFShape(aShape));
 }
 
 RTFValue::RTFValue(int nValue)
@@ -37,6 +40,7 @@ RTFValue::RTFValue(int nValue)
 {
     m_pAttributes.reset(new RTFSprms());
     m_pSprms.reset(new RTFSprms());
+    m_pShape.reset(new RTFShape());
 }
 
 RTFValue::RTFValue(OUString sValue, bool bForce)
@@ -49,6 +53,7 @@ RTFValue::RTFValue(OUString sValue, bool bForce)
 {
     m_pAttributes.reset(new RTFSprms());
     m_pSprms.reset(new RTFSprms());
+    m_pShape.reset(new RTFShape());
 }
 
 RTFValue::RTFValue(RTFSprms rAttributes)
@@ -61,6 +66,7 @@ RTFValue::RTFValue(RTFSprms rAttributes)
 {
     m_pAttributes.reset(new RTFSprms(rAttributes));
     m_pSprms.reset(new RTFSprms());
+    m_pShape.reset(new RTFShape());
 }
 
 RTFValue::RTFValue(RTFSprms rAttributes, RTFSprms rSprms)
@@ -73,6 +79,7 @@ RTFValue::RTFValue(RTFSprms rAttributes, RTFSprms rSprms)
 {
     m_pAttributes.reset(new RTFSprms(rAttributes));
     m_pSprms.reset(new RTFSprms(rSprms));
+    m_pShape.reset(new RTFShape());
 }
 
 RTFValue::RTFValue(uno::Reference<drawing::XShape> rShape)
@@ -85,6 +92,7 @@ RTFValue::RTFValue(uno::Reference<drawing::XShape> rShape)
 {
     m_pAttributes.reset(new RTFSprms());
     m_pSprms.reset(new RTFSprms());
+    m_pShape.reset(new RTFShape());
 }
 
 RTFValue::RTFValue(uno::Reference<io::XInputStream> rStream)
@@ -97,6 +105,7 @@ RTFValue::RTFValue(uno::Reference<io::XInputStream> rStream)
 {
     m_pAttributes.reset(new RTFSprms());
     m_pSprms.reset(new RTFSprms());
+    m_pShape.reset(new RTFShape());
 }
 
 RTFValue::RTFValue(uno::Reference<embed::XEmbeddedObject> xObject)
@@ -109,6 +118,20 @@ RTFValue::RTFValue(uno::Reference<embed::XEmbeddedObject> xObject)
 {
     m_pAttributes.reset(new RTFSprms());
     m_pSprms.reset(new RTFSprms());
+    m_pShape.reset(new RTFShape());
+}
+
+RTFValue::RTFValue(RTFShape aShape)
+    : m_nValue(),
+    m_sValue(),
+    m_xShape(),
+    m_xStream(),
+    m_xObject(),
+    m_bForceString(false)
+{
+    m_pAttributes.reset(new RTFSprms());
+    m_pSprms.reset(new RTFSprms());
+    m_pShape.reset(new RTFShape(aShape));
 }
 
 RTFValue::~RTFValue()
@@ -149,6 +172,11 @@ uno::Any RTFValue::getAny() const
     return ret;
 }
 
+RTFShape& RTFValue::getShape() const
+{
+    return *m_pShape;
+}
+
 writerfilter::Reference<Properties>::Pointer_t RTFValue::getProperties()
 {
     writerfilter::Reference<Properties>::Pointer_t const pProperties(
@@ -177,7 +205,7 @@ std::string RTFValue::toString() const
 
 RTFValue* RTFValue::Clone()
 {
-    return new RTFValue(m_nValue, m_sValue, *m_pAttributes, *m_pSprms, m_xShape, m_xStream, m_xObject, m_bForceString);
+    return new RTFValue(m_nValue, m_sValue, *m_pAttributes, *m_pSprms, m_xShape, m_xStream, m_xObject, m_bForceString, *m_pShape);
 }
 
 bool RTFValue::equals(RTFValue& rOther)
diff --git a/writerfilter/source/rtftok/rtfvalue.hxx b/writerfilter/source/rtftok/rtfvalue.hxx
index 02bf931..d42be11 100644
--- a/writerfilter/source/rtftok/rtfvalue.hxx
+++ b/writerfilter/source/rtftok/rtfvalue.hxx
@@ -17,6 +17,7 @@
 namespace writerfilter {
     namespace rtftok {
         class RTFSprms;
+        class RTFShape;
         /// Value of an RTF keyword
         class RTFValue
             : public Value
@@ -24,7 +25,8 @@ namespace writerfilter {
             public:
                 typedef boost::shared_ptr<RTFValue> Pointer_t;
                 RTFValue(int nValue, OUString sValue, RTFSprms rAttributes, RTFSprms rSprms, uno::Reference<drawing::XShape> rShape,
-                        uno::Reference<io::XInputStream> rStream, uno::Reference<embed::XEmbeddedObject> rObject, bool bForceString);
+                        uno::Reference<io::XInputStream> rStream, uno::Reference<embed::XEmbeddedObject> rObject, bool bForceString,
+                        RTFShape aShape);
                 RTFValue(int nValue);
                 RTFValue(OUString sValue, bool bForce = false);
                 RTFValue(RTFSprms rAttributes);
@@ -32,6 +34,7 @@ namespace writerfilter {
                 RTFValue(uno::Reference<drawing::XShape> rShape);
                 RTFValue(uno::Reference<io::XInputStream> rStream);
                 RTFValue(uno::Reference<embed::XEmbeddedObject> rObject);
+                RTFValue(RTFShape aShape);
                 virtual ~RTFValue();
                 void setString(OUString sValue);
                 virtual int getInt() const;
@@ -44,6 +47,7 @@ namespace writerfilter {
                 virtual RTFValue* Clone();
                 RTFSprms& getAttributes();
                 RTFSprms& getSprms();
+                RTFShape& getShape() const;
                 bool equals(RTFValue& rOther);
             private:
                 RTFValue& operator=(RTFValue const& rOther);
@@ -55,6 +59,7 @@ namespace writerfilter {
                 uno::Reference<io::XInputStream> m_xStream;
                 uno::Reference<embed::XEmbeddedObject> m_xObject;
                 bool m_bForceString;
+                boost::shared_ptr<RTFShape> m_pShape;
         };
     } // namespace rtftok
 } // namespace writerfilter


More information about the Libreoffice-commits mailing list