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

Maxime de Roucy mderoucy at linagora.com
Mon Feb 25 01:43:51 PST 2013


 sw/qa/extras/rtfimport/data/fdo53594.rtf       |   42 +++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |   10 +++--
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   41 ++++++++++++++++++++++--
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    4 +-
 4 files changed, 89 insertions(+), 8 deletions(-)

New commits:
commit 50822d440519bcc95fc4e5d45844c1328e72d6b2
Author: Maxime de Roucy <mderoucy at linagora.com>
Date:   Mon Feb 25 09:45:52 2013 +0100

    testcase for fdo#53594
    
    Change-Id: I834b3cf0b5a46627ff0b532e27a73deeaefe7c47
    Reviewed-on: https://gerrit.libreoffice.org/2376
    Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
    Tested-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/sw/qa/extras/rtfimport/data/fdo53594.rtf b/sw/qa/extras/rtfimport/data/fdo53594.rtf
new file mode 100644
index 0000000..55468a6
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo53594.rtf
@@ -0,0 +1,42 @@
+{\rtf1\ansi\deff3\adeflang1025
+{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset0 Nimbus Roman No9 L{\*\falt Times New Roman};}{\f4\fswiss\fprq2\fcharset0 Nimbus Sans L{\*\falt Arial};}{\f5\fnil\fprq2\fcharset0 DejaVu Sans;}}
+{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
+{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af5\langfe2052\dbch\af5\afs24\alang1081\loch\f3\fs24\lang1036 Standard;}
+{\s15\sbasedon0\snext16\sb240\sa120\keepn\dbch\af5\dbch\af5\afs28\loch\f4\fs28 Titre;}
+{\s16\sbasedon0\snext16\sb0\sa120 Corps de texte;}
+{\s17\sbasedon16\snext17\sb0\sa120 Liste;}
+{\s18\sbasedon0\snext18\sb120\sa120\noline\i\afs24\ai\fs24 L\u233\'e9gende;}
+{\s19\sbasedon0\snext19\noline Index;}
+{\s20\sbasedon0\snext20\noline Contenu de tableau;}
+}{\info{\author Maxime DE\~ROUCY}{\creatim\yr2013\mo2\dy22\hr18\min15}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOffice}{\vern3600}}\deftab709
+\viewscale150
+{\*\pgdsctbl
+{\pgdsc0\pgdscuse195\pgwsxn11906\pghsxn16838\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Standard;}}
+\formshade\paperh16838\paperw11906\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\sectunlocked1\pgndec\pgwsxn11906\pghsxn16838\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
+\trowd\trql\ltrrow\trpaddft3\trpaddt0\trpaddfl3\trpaddl0\trpaddfb3\trpaddb0\trpaddfr3\trpaddr0\clbrdrt\brdrhair\brdrw1\brdrcf1\clbrdrl\brdrhair\brdrw1\brdrcf1\clbrdrb\brdrhair\brdrw1\brdrcf1\cellx4819\clbrdrt\brdrhair\brdrw1\brdrcf1\clbrdrl\brdrhair\brdrw1\brdrcf1\clbrdrb\brdrhair\brdrw1\brdrcf1\clbrdrr\brdrhair\brdrw1\brdrcf1\cellx9638\pgndec\pard\plain \s20\noline\intbl\rtlch \ltrch\loch
+\cell\pard\plain \s20\noline\intbl{\rtlch \ltrch
+{\object\objemb{\*\objdata }{\result{\dn1{\*\shppict{\pict{\*\picprop{\sp{\sn wzDescription}{\sv }}{\sp{\sn wzName}{\sv }}}\picscalex99\picscaley95\piccropl0\piccropr0\piccropt0\piccropb0\picw2258\pich480\picwgoal1280\pichgoal272\wmetafile8
+010009000003a80200001000d40100000000d401000026060f009e03574d46430100000000000100599900000000010000007c030000000000007c0300000100
+00006c000000000000000000000054000000110000000000000000000000d1080000df01000020454d46000001007c0300001c00000002000000000000000000
+0000000000005500000012000000160000000400000000000000000000000000000034580000c0120000110000000c000000080000000b000000100000006000
+0000600000000900000010000000ec090000ec0900000c0000001000000000000000000000000a000000100000000000000000000000140000000c0000000d00
+0000120000000c0000000100000021000000080000002100000008000000220000000c000000ffffffff140000000c0000000d000000520000004c0100000100
+00009ffeffff0000000000000000000000009001000000000000000000224e0069006d006200750073002000530061006e00730020004c000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+0000160000000c00000018000000180000000c00000000000000250000000c0000000100000054000000880000002300000036010000c8040000f70200000100
+0000000000000000000023000000360100000a0000004c0000000200000000000000000000000000000000000000600000006f006c00650020006f0062006a00
+6500630074009f000000350000009e000000500000009f0000009e000000350000009f000000840000007b0000002100000008000000220000000c000000ffff
+ffff140000000c0000000d0000002100000008000000220000000c000000ffffffff140000000c0000000d0000002100000008000000220000000c000000ffff
+ffff140000000c0000000d000000220000000c000000ffffffff140000000c0000000d0000000e00000014000000000000001000000014000000050000000b02
+00000000050000000c02e001d20804000000020101000400000004010d0008000000fa0200000000000000000000040000002d01000007000000fc020000ffff
+ff000000040000002d0101001c000000fb0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000040000002d010200040000002e011800050000000902ffffff000400000007010300030000001e00030000001e00040000002701ffff08000000fa02
+050000000000ffffff00040000002d01030004000000f0010000050000000902000000001c000000fb029ffe000000000000900100000000000000224e696d62
+75732053616e73204c00000000000000000000000000000000000000040000002d01000004000000f001020016000000320a360123000a0000006f6c65206f62
+6a6563749f0035009e0050009f009e0035009f0084007b00030000001e00040000002701ffff030000001e00040000002701ffff030000001e00040000002701
+ffff040000002701ffff030000000000}}}}}}\cell\row\pard\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af5\langfe2052\dbch\af5\afs24\alang1081\loch\f3\fs24\lang1036\rtlch \ltrch\loch
+
+\par }
\ No newline at end of file
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 446e9c9..f923762 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -104,7 +104,7 @@ public:
     void testFdo49659();
     void testFdo46966();
     void testFdo52066();
-    void testFdo48033();
+    void testFdo48033_53594();
     void testFdo36089();
     void testFdo49892();
     void testFdo48446();
@@ -218,7 +218,8 @@ void Test::run()
         {"fdo49659.rtf", &Test::testFdo49659},
         {"fdo46966.rtf", &Test::testFdo46966},
         {"fdo52066.rtf", &Test::testFdo52066},
-        {"fdo48033.rtf", &Test::testFdo48033},
+        {"fdo48033.rtf", &Test::testFdo48033_53594},
+        {"fdo53594.rtf", &Test::testFdo48033_53594},
         {"fdo36089.rtf", &Test::testFdo36089},
         {"fdo49892.rtf", &Test::testFdo49892},
         {"fdo48446.rtf", &Test::testFdo48446},
@@ -741,10 +742,11 @@ void Test::testFdo52066()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(19)), xShape->getSize().Height);
 }
 
-void Test::testFdo48033()
+void Test::testFdo48033_53594()
 {
     /*
-     * The problem was that the picture was in the first cell, instead of the second one.
+     * The problem was that the picture (48033) or OLE object (53594) was in the first cell,
+     * instead of the second one.
      *
      * oTable = ThisComponent.TextTables(0)
      * oParas = oTable.getCellByName("B1").Text.createEnumeration
commit 0c9afe307eae8310de04de458c13b5c14a4e17da
Author: Maxime de Roucy <mderoucy at linagora.com>
Date:   Wed Feb 20 14:27:47 2013 +0100

    RTF IMPORT : considere OLE objects as pictures
    
    resolve fdo#53594 : Import RTF file but ole are not well positioned in
    table/cells
    
    If the OLE object is in a container, don't try to import it as
    OLE object (use the \objdata element) but use the \result element which
    is the appareance of the object (it's a picture).
    
    Change-Id: Id97b36ce89beae02885cf82383321c14b58f2ea5
    Reviewed-on: https://gerrit.libreoffice.org/2243
    Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
    Tested-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 9d5de81..14c7486 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -716,6 +716,9 @@ int RTFDocumentImpl::resolvePict(bool bInline)
         if ( xShapes.is() )
             xShapes->add( xShape );
     }
+
+    // check if the picture is in an OLE object and if the \objdata element is used
+    // (see RTF_OBJECT in RTFDocumentImpl::dispatchDestination)
     if (m_bObject)
     {
         // Set bitmap
@@ -736,6 +739,7 @@ int RTFDocumentImpl::resolvePict(bool bInline)
         m_aObjectAttributes.set(NS_ooxml::LN_shape, pShapeValue);
         return 0;
     }
+
     if (xPropertySet.is())
         xPropertySet->setPropertyValue("GraphicURL", uno::Any(aGraphicUrl));
 
@@ -1446,11 +1450,34 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
             m_aStates.top().nDestinationState = DESTINATION_COMMENT;
             break;
         case RTF_OBJECT:
-            m_aStates.top().nDestinationState = DESTINATION_OBJECT;
-            m_bObject = true;
+            {
+                // begining of an OLE Object
+                m_aStates.top().nDestinationState = DESTINATION_OBJECT;
+
+                // check if the object is in a special container (e.g. a table)
+                if (!m_pCurrentBuffer)
+                {
+                    // the object is in a table or another container.
+                    // Don't try to treate it as an OLE object (fdo#53594).
+                    // Use the \result (RTF_RESULT) element of the object instead,
+                    // the result element contain picture representing the OLE Object.
+                    m_bObject = true;
+                }
+            }
             break;
         case RTF_OBJDATA:
-            m_aStates.top().nDestinationState = DESTINATION_OBJDATA;
+            // check if the object is in a special container (e.g. a table)
+            if (m_pCurrentBuffer)
+            {
+                // the object is in a table or another container.
+                // Use the \result (RTF_RESULT) element of the object instead,
+                // of the \objdata.
+                m_aStates.top().nDestinationState = DESTINATION_SKIP;
+            }
+            else
+            {
+                m_aStates.top().nDestinationState = DESTINATION_OBJDATA;
+            }
             break;
         case RTF_RESULT:
             m_aStates.top().nDestinationState = DESTINATION_RESULT;
@@ -3861,6 +3888,14 @@ int RTFDocumentImpl::popState()
     break;
     case DESTINATION_OBJECT:
     {
+        if (!m_bObject)
+        {
+            // if the object is in a special container we will use the \result
+            // element instead of the \objdata
+            // (see RTF_OBJECT in RTFDocumentImpl::dispatchDestination)
+            break;
+        }
+
         RTFSprms aObjAttributes;
         RTFSprms aObjSprms;
         RTFValue::Pointer_t pValue(new RTFValue(m_aObjectAttributes, m_aObjectSprms));
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index d61efef..82490eb 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -561,7 +561,9 @@ namespace writerfilter {
 
                 RTFSprms m_aObjectSprms;
                 RTFSprms m_aObjectAttributes;
-                /// If we are in an object group.
+                /** If we are in an object group and if the we use its
+                 *  \objdata element.
+                 *  (if we don't use the \objdata we use the \result element)*/
                 bool m_bObject;
                 /// Contents of the objdata group.
                 boost::shared_ptr<SvStream> m_pObjectData;


More information about the Libreoffice-commits mailing list