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

Miklos Vajna vmiklos at suse.cz
Tue Aug 6 07:57:51 PDT 2013


 sw/qa/extras/rtfimport/data/fdo47440.rtf       |   27 +++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |   11 ++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   21 ++++++++++++-------
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    6 +++--
 4 files changed, 56 insertions(+), 9 deletions(-)

New commits:
commit b755df14a431543f1b70246a5e58830a0a480602
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Aug 6 16:31:29 2013 +0200

    fdo#47440 import RTF_SHPBX/YPAGE for Writer pictures, too
    
    Previously this was only handled for drawinglayer shapes.
    
    Change-Id: I7ce440a27ebe44fc867b8a7f4ee62217076677f0

diff --git a/sw/qa/extras/rtfimport/data/fdo47440.rtf b/sw/qa/extras/rtfimport/data/fdo47440.rtf
new file mode 100644
index 0000000..e21627e
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo47440.rtf
@@ -0,0 +1,27 @@
+{\rtf1\ansi\deff0
+\viewkind1\paperw11900\paperh16840\marglsxn400\margrsxn400\margtsxn400\margbsxn400\deftab800
+{\shp
+{\*\shpinst\shpbxpage\shpbypage\shpwr5\shpfhdr0\shpfblwtxt0\shpz5\shpleft9700\shpright11420\shptop400\shpbottom1460
+{\sp
+{\sn shapeType}
+{\sv 75}
+}
+{\sp
+{\sn fFilled}
+{\sv 0}
+}
+{\sp
+{\sn fLockAspectRatio}
+{\sv 0}
+}
+{\sp
+{\sn pib}
+{\sv 
+{\pict\pngblip
+47494638396110001000d5ff00000000ffffffc0c0c0555f00ffffaafcfcfcf6f6f6eaeaeae6e6e6e4e4e4e3e3e3c2c2c2c1c1c1bcbcbcb5b5b5b3b3b3b0b0b0adadada5a5a5a2a2a2a1a1a19f9f9f9494948a8a8a8888888686867b7b7b6c6c6c5c5c5c4e4e4e4b4b4b4747474646463d3d3d3c3c3c2e2e2e2525251b1b1b18181810101009090906060603030300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021f90401000002002c0000000010001000000684408170482c0a06c8a4728924389f506833b281302a8e6b164b18103024c52111504cca67332102e0042e9a40d9319f8300a343c1200f54e47f7e2a00001e0b0a7d0d728a010d838400261a7c0d94947784252700127e9d159f6c8411140019080ea7a9a85f842122281612b1b3b25d6b1f29291d0fbbbdbc5d5e51c34e4cc64a46c94341003b}
+}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 44cdbdf..5c7eb69 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -159,6 +159,7 @@ public:
     void testN820504();
     void testFdo67365();
     void testFdo67498();
+    void testFdo47440();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -303,6 +304,7 @@ void Test::run()
         {"n820504.rtf", &Test::testN820504},
         {"fdo67365.rtf", &Test::testFdo67365},
         {"fdo67498.rtf", &Test::testFdo67498},
+        {"fdo47440.rtf", &Test::testFdo47440},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1478,6 +1480,15 @@ void Test::testFdo67498()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(5954)), getProperty<sal_Int32>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "LeftMargin"));
 }
 
+void Test::testFdo47440()
+{
+    // Vertical and horizontal orientation of the picture wasn't imported (was text::RelOrientation::FRAME).
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(0), "HoriOrientRelation"));
+    CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(0), "VertOrientRelation"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 1ca8f17..49fe964 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -836,17 +836,20 @@ int RTFDocumentImpl::resolvePict(bool bInline)
         if (aAnchorWrapAttributes.size())
             aAnchorSprms.set(NS_ooxml::LN_EG_WrapType_wrapSquare, pAnchorWrapValue);
 
-        // See OOXMLFastContextHandler::positionOffset(), we can't just put values in an RTFValue.
+        // See OOXMLFastContextHandler::positionOffset(), we can't just put offset values in an RTFValue.
+        RTFSprms aPoshSprms;
+        if (m_aStates.top().aShape.nHoriOrientRelationToken > 0)
+            aPoshSprms.set(NS_ooxml::LN_CT_PosH_relativeFrom, RTFValue::Pointer_t(new RTFValue(m_aStates.top().aShape.nHoriOrientRelationToken)));
         if (m_aStates.top().aShape.nLeft > 0)
-        {
             writerfilter::dmapper::PositionHandler::setPositionOffset(OUString::number(MM100_TO_EMU(m_aStates.top().aShape.nLeft)), false);
-            aAnchorSprms.set(NS_ooxml::LN_CT_Anchor_positionH, RTFValue::Pointer_t(new RTFValue(RTFSprms())));
-        }
+        aAnchorSprms.set(NS_ooxml::LN_CT_Anchor_positionH, RTFValue::Pointer_t(new RTFValue(aPoshSprms)));
+
+        RTFSprms aPosvSprms;
+        if (m_aStates.top().aShape.nVertOrientRelationToken > 0)
+            aPosvSprms.set(NS_ooxml::LN_CT_PosV_relativeFrom, RTFValue::Pointer_t(new RTFValue(m_aStates.top().aShape.nVertOrientRelationToken)));
         if (m_aStates.top().aShape.nTop > 0)
-        {
             writerfilter::dmapper::PositionHandler::setPositionOffset(OUString::number(MM100_TO_EMU(m_aStates.top().aShape.nTop)), true);
-            aAnchorSprms.set(NS_ooxml::LN_CT_Anchor_positionV, RTFValue::Pointer_t(new RTFValue(RTFSprms())));
-        }
+        aAnchorSprms.set(NS_ooxml::LN_CT_Anchor_positionV, RTFValue::Pointer_t(new RTFValue(aPosvSprms)));
 
         aAnchorSprms.set(NS_ooxml::LN_CT_Anchor_docPr, pDocprValue);
         aAnchorSprms.set(NS_ooxml::LN_graphic_graphic, pGraphicValue);
@@ -2684,9 +2687,11 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                 break;
         case RTF_SHPBXPAGE:
                 m_aStates.top().aShape.nHoriOrientRelation = text::RelOrientation::PAGE_FRAME;
+                m_aStates.top().aShape.nHoriOrientRelationToken = NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page;
                 break;
         case RTF_SHPBYPAGE:
                 m_aStates.top().aShape.nVertOrientRelation = text::RelOrientation::PAGE_FRAME;
+                m_aStates.top().aShape.nVertOrientRelationToken = NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page;
                 break;
         case RTF_DPLINEHOLLOW:
                 m_aStates.top().aDrawingObject.nFLine = 0;
@@ -4855,6 +4860,8 @@ RTFShape::RTFShape()
     nBottom(0),
     nHoriOrientRelation(0),
     nVertOrientRelation(0),
+    nHoriOrientRelationToken(0),
+    nVertOrientRelationToken(0),
     nWrap(-1)
 {
 }
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 86b6912..0f5e9d8 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -100,8 +100,10 @@ namespace writerfilter {
                 sal_Int32 nRight;
                 sal_Int32 nBottom;
                 boost::optional<sal_Int32> oZ; ///< Z-Order of the shape.
-                sal_Int16 nHoriOrientRelation;
-                sal_Int16 nVertOrientRelation;
+                sal_Int16 nHoriOrientRelation; ///< Horizontal text::RelOrientation for drawinglayer shapes.
+                sal_Int16 nVertOrientRelation; ///< Vertical text::RelOrientation for drawinglayer shapes.
+                sal_uInt32 nHoriOrientRelationToken; ///< Horizontal dmapper token for Writer pictures.
+                sal_uInt32 nVertOrientRelationToken; ///< Vertical dmapper token for Writer pictures.
                 int nWrap;
         };
 


More information about the Libreoffice-commits mailing list