summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-08-06 16:31:29 +0200
committerLuboš Luňák <l.lunak@suse.cz>2013-08-08 14:30:55 +0000
commit88fec7695f5f3c9574bc305e31120758004493cf (patch)
tree248dce1a6452093fc9cc6d0bf9931c91b382bef1
parent01ad0524859ae9566fc063179c80fc6a67f7bb0c (diff)
fdo#47440 import RTF_SHPBX/YPAGE for Writer pictures, too
Previously this was only handled for drawinglayer shapes. (cherry picked from commit b755df14a431543f1b70246a5e58830a0a480602) Change-Id: I7ce440a27ebe44fc867b8a7f4ee62217076677f0 Reviewed-on: https://gerrit.libreoffice.org/5303 Reviewed-by: Luboš Luňák <l.lunak@suse.cz> Tested-by: Luboš Luňák <l.lunak@suse.cz>
-rw-r--r--sw/qa/extras/rtfimport/data/fdo47440.rtf27
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx11
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx21
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx6
4 files changed, 56 insertions, 9 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo47440.rtf b/sw/qa/extras/rtfimport/data/fdo47440.rtf
new file mode 100644
index 000000000000..e21627ed0bbf
--- /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 dd8b72cc6e46..d432f0b22d17 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -149,6 +149,7 @@ public:
void testFdo64637();
void testFdo67365();
void testFdo67498();
+ void testFdo47440();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -285,6 +286,7 @@ void Test::run()
{"fdo64637.rtf", &Test::testFdo64637},
{"fdo67365.rtf", &Test::testFdo67365},
{"fdo67498.rtf", &Test::testFdo67498},
+ {"fdo47440.rtf", &Test::testFdo47440},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1378,6 +1380,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 5ff313230ace..5895057e2e00 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -840,17 +840,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);
@@ -2660,9 +2663,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;
@@ -4785,6 +4790,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 5bedc6140d24..a4e73ad34f05 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -243,8 +243,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;
};