From 4da81e4a0bda96c3d25aa22341f94b58e584cefb Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 25 Feb 2014 11:47:32 +0100 Subject: [PATCH] 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 --- sw/qa/extras/odfexport/data/shape-relsize.odt | Bin 0 -> 10706 bytes sw/qa/extras/odfexport/odfexport.cxx | 8 ++++++ xmloff/source/draw/ximpshap.cxx | 26 ++++++++++++++++++ xmloff/source/draw/ximpshap.hxx | 2 ++ 4 files changed, 36 insertions(+) create mode 100755 sw/qa/extras/odfexport/data/shape-relsize.odt diff --git a/sw/qa/extras/odfexport/data/shape-relsize.odt b/sw/qa/extras/odfexport/data/shape-relsize.odt new file mode 100755 index 0000000000000000000000000000000000000000..05a3ffa591ff145caaf1899656ce0f96f9a007d9 GIT binary patch literal 10706 zcmeHtWmp{Bwryjd(W31V8)f%&Et|>1C1B(p+AOHXZZt5aB-7F|n007`&yFUc5 zGP5!QyV@FoY;7&g3_xHr8*8AGwIQPo$id8k(Z<%u+R(@SnSkw$>)W^0MNnNCZgtr=Utoh$!BFb^`!V00ij! zJrjXcJOBWmLQ+IX*(GIX1|o;;Ow?oNWa8|tjpI7}>2MxKMUvK^vKlu!p0vr8X;CGH zIH_js7G~DXBBI;(U_Rqu^mx9@H+UnbKqIRlfEJDp-6w#Y9%*~z_)B;wp){cy|E{lV zi$3L&v9Z(f*=*t@nW1pWmMRo?hTa9s1?|Uk=Czo#!e%zt~BU2ZLQLf-cLX3~Z`R-2inATU9Yoi7Bfb*qWGCPho z#xt9qhFg6U&GuzO+1CdSL~COminr^RrH$O17e+3w#hR^mTlM%hn`V7QdCM6_ z$H&>(*ck2`5I7xDQ*X7_pZKDt0L(ozH%AgCW@2o->5!Y7YpJd2X=Kz@|5{zW%m^0` zuhw$1!sF^RDT%<1mJ3ondVPKEkBk=(5WuL@m>}`Y@~x((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$iZ!qXk`!s=dDBlD_VV}ql+G$wf~ zxdB{pgdvxYlgM7iaOtOEZ6(HgSG9+6RvblrG^`9F(G%&Pub5_slXBh;7nx>?tdPDM z9zJ^;Hqi?eeLV{V%GO#!ml-FkFke=83n!ih9(|jkwD_VklwqtdYpCV)^@+-GU0_l{ zbFCO%pVeXzY75|qhKh<4154`3Y2Y%yJU$_u_RCoVjt;$)O+l0sQN}3>RQC%a6F+!+ z=2*N9G19({aCAH;!OepzaLqpYM_mhE)}5znRL*=1r{7#HW!|@ol9%`o6VNY@!e=NU zw4k5a=s5ESCfEwj_uBHQJn5%9SVI5i4lOSQ1&s~(=c=iDpZ=x&Swreuq99}t=Q z-G3^UdSD@jdFcChOS%si!9(d30FdoHcVBk((*iHtzZQ6ZS={|$*1xWfU$gXoF#hqT zjrMcS{#WF$siz;vcC34G{_jN8uc%+2{(qnxasQeN_!al7`2WC_kp3JBejxuoYaVp) zN1Gx0yFUC)6@MQ4A7B9BVe0;91oz7vzlzOYRq~&C9(3|YQ~V9j&#L(+)9-cj2UF;8 znEpXU|0kdQ>mvJ;cH}ptKQ#4E)Bf)HpPhwB@potaRb&5|=Vxn#e#7%abN`v;XKS2) z!}3=R{%4+_tttHt&ks%hljZlS{HK2bfR%fe-)gkH6x@B57XZMxe+Au(IqUO>Z~q0k C@;v$g literal 0 HcmV?d00001 diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index db752040e4a9..3d2450f4cb92 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -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(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(getShape(1), "RelativeWidth")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty(getShape(1), "RelativeHeight")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index d9c95a03b671..8ba56a37d23b 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -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 xPropertySet(xShape, uno::UNO_QUERY); + uno::Reference 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(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(nTmp); + } + else if (IsXMLToken(rLocalName, XML_REL_HEIGHT)) + { + if (sax::Converter::convertPercent(nTmp, rValue)) + mnRelHeight = static_cast(nTmp); + } + } else if( (XML_NAMESPACE_NONE == nPrefix) || (XML_NAMESPACE_XML == nPrefix) ) { if( IsXMLToken( rLocalName, XML_ID ) ) diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx index a4b8786840b8..6ddb83b12b79 100644 --- a/xmloff/source/draw/ximpshap.hxx +++ b/xmloff/source/draw/ximpshap.hxx @@ -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;