diff options
author | YogeshBharate <yogesh.bharate@synerzip.com> | 2014-01-10 19:15:10 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-13 18:03:41 +0100 |
commit | b23867abd8427da361dfa5edb9b41fbbd064ae10 (patch) | |
tree | 79987a894b82f3b311b66bf45958675986e4e763 | |
parent | c4ff46485f0461de6a2804ae859dbbc81b6af105 (diff) |
fdo#73247: Code fixed for Shape rotation not preserved in RT
Problem Description:
- When we create the shape with text, rotated it with some angle,
the rotation angle is not preserved after roundtrip.
Implementation:
- Use the FrameInteroGrabBag to preserve the rotation angle.
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/7367
Change-Id: I8a44e82d21f08ecb221cdbfef73f02a652f2bad3
-rw-r--r-- | oox/source/drawingml/shape.cxx | 23 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo73247.docx | bin | 0 -> 17526 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 36 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 8 |
5 files changed, 72 insertions, 4 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index b191762efe29..9437f0252499 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -657,7 +657,28 @@ Reference< XShape > Shape::createAndInsert( } aShapeProps.erase(PROP_LineColor); } - + if(mnRotation) + { + uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY); + const OUString aGrabBagPropName = "FrameInteropGrabBag"; + uno::Sequence<beans::PropertyValue> aGrabBag; + xPropertySet->getPropertyValue(aGrabBagPropName) >>= aGrabBag; + beans::PropertyValue aPair; + aPair.Name = "mso-rotation-angle"; + aPair.Value = uno::makeAny(mnRotation); + if (aGrabBag.hasElements()) + { + sal_Int32 nLength = aGrabBag.getLength(); + aGrabBag.realloc(nLength + 1); + aGrabBag[nLength] = aPair; + } + else + { + aGrabBag.realloc(1); + aGrabBag[0] = aPair; + } + xPropertySet->setPropertyValue(aGrabBagPropName, uno::makeAny(aGrabBag)); + } // TextFrames have ShadowFormat, not individual shadow properties. boost::optional<sal_Int32> oShadowDistance; if (aShapeProps.hasProperty(PROP_ShadowXDistance)) diff --git a/sw/qa/extras/ooxmlexport/data/fdo73247.docx b/sw/qa/extras/ooxmlexport/data/fdo73247.docx Binary files differnew file mode 100644 index 000000000000..63ad782f605b --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo73247.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 46488de589db..d4f5e3fb471b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2404,6 +2404,15 @@ DECLARE_OOXMLEXPORT_TEST(testFdo65833, "fdo65833.docx") assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:group", "editas", "canvas"); } +DECLARE_OOXMLEXPORT_TEST(testFdo73247, "fdo73247.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:xfrm", + "rot", "1969698"); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index a94cd68adfa3..e498c096b4ad 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -304,9 +304,43 @@ void DocxAttributeOutput::WriteDMLTextFrame(sw::Frame* pParentFrame) XML_txBox, "1", FSEND); + uno::Any aRotation ; + const SdrObject* pSdrObj = rFrmFmt.FindRealSdrObject(); + uno::Reference< drawing::XShape > xShape( ((SdrObject*)pSdrObj)->getUnoShape(), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xPropertySet( xShape, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropertySet->getPropertySetInfo(); + OUString pName = "FrameInteropGrabBag"; + sal_Int32 nRotation = 0; + + if ( xPropSetInfo->hasPropertyByName( pName ) ) + { + uno::Sequence< beans::PropertyValue > propList; + xPropertySet->getPropertyValue( pName ) >>= propList; + for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp ) + { + OUString propName = propList[nProp].Name; + if ( propName == "mso-rotation-angle") + { + aRotation = propList[nProp].Value ; + break; + } + } + } + aRotation >>= nRotation ; + OString sRotation(OString::number(nRotation)); // Shape properties m_pSerializer->startElementNS(XML_wps, XML_spPr, FSEND); - m_pSerializer->startElementNS(XML_a, XML_xfrm, FSEND); + if(nRotation) + { + m_pSerializer->startElementNS(XML_a, XML_xfrm, + XML_rot, sRotation.getStr(), + FSEND); + + } + else + { + m_pSerializer->startElementNS(XML_a, XML_xfrm, FSEND); + } m_pSerializer->singleElementNS(XML_a, XML_off, XML_x, "0", XML_y, "0", diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 57255088763c..226dc5c928af 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1820,9 +1820,9 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape if (xSInfo->supportsService("com.sun.star.text.TextFrame")) { // Extract the special "btLr text frame" mode, requested by oox, if needed. - uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShapePropertySet(xShape, uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aGrabBag; - xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag; + xShapePropertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag; for (int i = 0; i < aGrabBag.getLength(); ++i) { if (aGrabBag[i].Name == "mso-layout-flow-alt") @@ -1835,6 +1835,10 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape uno::Reference<text::XTextContent> xTextContent(xShape, uno::UNO_QUERY_THROW); uno::Reference<text::XTextRange> xTextRange(xTextAppend->createTextCursorByRange(xTextAppend->getEnd()), uno::UNO_QUERY_THROW); xTextAppend->insertTextContent(xTextRange, xTextContent, sal_False); + + uno::Reference<beans::XPropertySet> xPropertySet(xTextContent, uno::UNO_QUERY); + // we need to re-set this value to xTextContent, then only values are preserved. + xPropertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aGrabBag)); } else if (nAnchorType != text::TextContentAnchorType_AS_CHARACTER) { |