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
This commit is contained in:
BIN
sw/qa/extras/odfexport/data/shape-relsize.odt
Executable file
BIN
sw/qa/extras/odfexport/data/shape-relsize.odt
Executable file
Binary file not shown.
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user