Kaydet (Commit) b755df14 authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#47440 import RTF_SHPBX/YPAGE for Writer pictures, too

Previously this was only handled for drawinglayer shapes.

Change-Id: I7ce440a27ebe44fc867b8a7f4ee62217076677f0
üst 7b4bdab8
{\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
}
...@@ -159,6 +159,7 @@ public: ...@@ -159,6 +159,7 @@ public:
void testN820504(); void testN820504();
void testFdo67365(); void testFdo67365();
void testFdo67498(); void testFdo67498();
void testFdo47440();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
...@@ -303,6 +304,7 @@ void Test::run() ...@@ -303,6 +304,7 @@ void Test::run()
{"n820504.rtf", &Test::testN820504}, {"n820504.rtf", &Test::testN820504},
{"fdo67365.rtf", &Test::testFdo67365}, {"fdo67365.rtf", &Test::testFdo67365},
{"fdo67498.rtf", &Test::testFdo67498}, {"fdo67498.rtf", &Test::testFdo67498},
{"fdo47440.rtf", &Test::testFdo47440},
}; };
header(); header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
...@@ -1478,6 +1480,15 @@ void Test::testFdo67498() ...@@ -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")); 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_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -836,17 +836,20 @@ int RTFDocumentImpl::resolvePict(bool bInline) ...@@ -836,17 +836,20 @@ int RTFDocumentImpl::resolvePict(bool bInline)
if (aAnchorWrapAttributes.size()) if (aAnchorWrapAttributes.size())
aAnchorSprms.set(NS_ooxml::LN_EG_WrapType_wrapSquare, pAnchorWrapValue); 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) if (m_aStates.top().aShape.nLeft > 0)
{
writerfilter::dmapper::PositionHandler::setPositionOffset(OUString::number(MM100_TO_EMU(m_aStates.top().aShape.nLeft)), false); 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) if (m_aStates.top().aShape.nTop > 0)
{
writerfilter::dmapper::PositionHandler::setPositionOffset(OUString::number(MM100_TO_EMU(m_aStates.top().aShape.nTop)), true); 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_CT_Anchor_docPr, pDocprValue);
aAnchorSprms.set(NS_ooxml::LN_graphic_graphic, pGraphicValue); aAnchorSprms.set(NS_ooxml::LN_graphic_graphic, pGraphicValue);
...@@ -2684,9 +2687,11 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) ...@@ -2684,9 +2687,11 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
break; break;
case RTF_SHPBXPAGE: case RTF_SHPBXPAGE:
m_aStates.top().aShape.nHoriOrientRelation = text::RelOrientation::PAGE_FRAME; m_aStates.top().aShape.nHoriOrientRelation = text::RelOrientation::PAGE_FRAME;
m_aStates.top().aShape.nHoriOrientRelationToken = NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page;
break; break;
case RTF_SHPBYPAGE: case RTF_SHPBYPAGE:
m_aStates.top().aShape.nVertOrientRelation = text::RelOrientation::PAGE_FRAME; m_aStates.top().aShape.nVertOrientRelation = text::RelOrientation::PAGE_FRAME;
m_aStates.top().aShape.nVertOrientRelationToken = NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page;
break; break;
case RTF_DPLINEHOLLOW: case RTF_DPLINEHOLLOW:
m_aStates.top().aDrawingObject.nFLine = 0; m_aStates.top().aDrawingObject.nFLine = 0;
...@@ -4855,6 +4860,8 @@ RTFShape::RTFShape() ...@@ -4855,6 +4860,8 @@ RTFShape::RTFShape()
nBottom(0), nBottom(0),
nHoriOrientRelation(0), nHoriOrientRelation(0),
nVertOrientRelation(0), nVertOrientRelation(0),
nHoriOrientRelationToken(0),
nVertOrientRelationToken(0),
nWrap(-1) nWrap(-1)
{ {
} }
......
...@@ -100,8 +100,10 @@ namespace writerfilter { ...@@ -100,8 +100,10 @@ namespace writerfilter {
sal_Int32 nRight; sal_Int32 nRight;
sal_Int32 nBottom; sal_Int32 nBottom;
boost::optional<sal_Int32> oZ; ///< Z-Order of the shape. boost::optional<sal_Int32> oZ; ///< Z-Order of the shape.
sal_Int16 nHoriOrientRelation; sal_Int16 nHoriOrientRelation; ///< Horizontal text::RelOrientation for drawinglayer shapes.
sal_Int16 nVertOrientRelation; 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; int nWrap;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment