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

xmloff: import style:rel-width/height for drawinglayer shapes

In case the underlying UNO object supports that, which is the case for
Writer. Export was already working before.

Change-Id: I4676c8349ebe1959da004d6e1a024a342da45049
üst ea7685ce
......@@ -350,6 +350,14 @@ DECLARE_ODFEXPORT_TEST(testTextFrameVertAdjust, "textframe-vertadjust.odt")
xFrame.set(getTextFrameByName("Rectangle 3"), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM, getProperty<drawing::TextVerticalAdjust>(xFrame, "TextVerticalAdjust"));
}
DECLARE_ODFEXPORT_TEST(testShapeRelsize, "shape-relsize.odt")
{
// These were all 0, as style:rel-width/height was ignored on import for shapes.
CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty<sal_Int16>(getShape(1), "RelativeWidth"));
CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty<sal_Int16>(getShape(1), "RelativeHeight"));
}
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -151,6 +151,8 @@ SdXMLShapeContext::SdXMLShapeContext(
, mbIsUserTransformed(sal_False)
, mnZOrder(-1)
, maSize(1, 1)
, mnRelWidth(0)
, mnRelHeight(0)
, maPosition(0, 0)
, maUsedTransformation()
, mbVisible(true)
......@@ -454,6 +456,16 @@ void SdXMLShapeContext::AddShape(uno::Reference< drawing::XShape >& xShape)
xImp->shapeWithZIndexAdded( xShape, mnZOrder );
}
if (mnRelWidth || mnRelHeight)
{
uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
if (mnRelWidth && xPropertySetInfo->hasPropertyByName("RelativeWidth"))
xPropertySet->setPropertyValue("RelativeWidth", uno::makeAny(mnRelWidth));
if (mnRelHeight && xPropertySetInfo->hasPropertyByName("RelativeHeight"))
xPropertySet->setPropertyValue("RelativeHeight", uno::makeAny(mnRelHeight));
}
if( !maShapeId.isEmpty() )
{
uno::Reference< uno::XInterface > xRef( static_cast<uno::XInterface *>(xShape.get()) );
......@@ -888,6 +900,20 @@ void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rL
maShapeDescription = rValue;
}
}
else if (nPrefix == XML_NAMESPACE_STYLE)
{
sal_Int32 nTmp;
if (IsXMLToken(rLocalName, XML_REL_WIDTH))
{
if (sax::Converter::convertPercent(nTmp, rValue))
mnRelWidth = static_cast<sal_Int16>(nTmp);
}
else if (IsXMLToken(rLocalName, XML_REL_HEIGHT))
{
if (sax::Converter::convertPercent(nTmp, rValue))
mnRelHeight = static_cast<sal_Int16>(nTmp);
}
}
else if( (XML_NAMESPACE_NONE == nPrefix) || (XML_NAMESPACE_XML == nPrefix) )
{
if( IsXMLToken( rLocalName, XML_ID ) )
......
......@@ -73,6 +73,8 @@ protected:
SdXMLImExTransform2D mnTransform;
com::sun::star::awt::Size maSize;
sal_Int16 mnRelWidth;
sal_Int16 mnRelHeight;
com::sun::star::awt::Point maPosition;
basegfx::B2DHomMatrix maUsedTransformation;
......
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