diff options
author | Vinaya Mandke <vinaya.mandke@synerzip.com> | 2014-01-08 18:54:51 +0530 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2014-01-13 22:04:34 +0200 |
commit | c7a075b3c79afdb42704a4a0d9e2b027d8751fb6 (patch) | |
tree | ad330b5e10b8c594fa9e1dd8a1a8c7ccb8f9ed63 | |
parent | cceaf00a034850f209add1b8288fca579c877a36 (diff) |
fdo#65833 Fix to preserve VML Canvas Information
Grab-bagged the "editas" attribute of v:group and added UT for
the same
Please verify this fix on MS Office 2007 as it renders the mc:Fallback VML part
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/7335
Change-Id: I4e4456997621089967514009005ee775b71d6d69
-rw-r--r-- | filter/source/msfilter/escherex.cxx | 5 | ||||
-rw-r--r-- | filter/source/msfilter/eschesdo.cxx | 24 | ||||
-rw-r--r-- | include/filter/msfilter/escherex.hxx | 4 | ||||
-rw-r--r-- | include/oox/export/vmlexport.hxx | 2 | ||||
-rw-r--r-- | include/oox/vml/vmlshape.hxx | 2 | ||||
-rw-r--r-- | oox/source/export/vmlexport.cxx | 18 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 22 | ||||
-rw-r--r-- | oox/source/vml/vmlshapecontext.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo65833.docx | bin | 0 -> 34539 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 |
10 files changed, 84 insertions, 5 deletions
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 782dcfcecaaf..129831e396f2 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -5081,6 +5081,11 @@ void EscherEx::ReplacePersistOffset( sal_uInt32 nKey, sal_uInt32 nOffset ) PtReplace( ESCHER_Persist_PrivateEntry | nKey, nOffset ); } +void EscherEx::SetEditAs( OUString rEditAs ) +{ + mEditAs = rEditAs; +} + sal_uInt32 EscherEx::GetPersistOffset( sal_uInt32 nKey ) { return PtGetOffsetByID( ESCHER_Persist_PrivateEntry | nKey ); diff --git a/filter/source/msfilter/eschesdo.cxx b/filter/source/msfilter/eschesdo.cxx index 16311df438e3..fa697ee0beae 100644 --- a/filter/source/msfilter/eschesdo.cxx +++ b/filter/source/msfilter/eschesdo.cxx @@ -191,6 +191,30 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj, if( const SdrObject* pSdrObj = rObj.GetSdrObject() ) if (!pSdrObj->GetName().isEmpty()) aShapeName = pSdrObj->GetName(); + uno::Reference< drawing::XShape> mXShape(rObj.GetShapeRef(), uno::UNO_QUERY); + if (mXShape.is()) + { + uno::Reference<beans::XPropertySet> xPropertySet(mXShape, uno::UNO_QUERY); + if (xPropertySet.is()) + { + uno::Sequence<beans::PropertyValue> aGrabBag; + uno::Reference< XPropertySetInfo > xPropInfo = xPropertySet->getPropertySetInfo(); + if ( xPropInfo.is() && xPropInfo->hasPropertyByName( "InteropGrabBag" ) ) + { + xPropertySet->getPropertyValue( "InteropGrabBag" ) >>= aGrabBag; + for (int i=0; i< aGrabBag.getLength(); i++) + { + if (aGrabBag[i].Name == "mso-edit-as") + { + OUString rEditAs; + aGrabBag[i].Value >>= rEditAs; + mpEscherEx->SetEditAs(rEditAs); + break; + } + } + } + } + } Point aTextRefPoint; diff --git a/include/filter/msfilter/escherex.hxx b/include/filter/msfilter/escherex.hxx index e24996cd9521..d69e49d04674 100644 --- a/include/filter/msfilter/escherex.hxx +++ b/include/filter/msfilter/escherex.hxx @@ -1588,6 +1588,7 @@ class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable sal_Bool mbEscherDg; sal_Bool mbOleEmf; // OLE is EMF instead of WMF bool mbOOXML; + OUString mEditAs; virtual sal_Bool DoSeek( sal_uInt32 nKey ); @@ -1643,7 +1644,8 @@ public: sal_Bool SeekToPersistOffset( sal_uInt32 nKey ); virtual sal_Bool InsertAtPersistOffset( sal_uInt32 nKey, sal_uInt32 nValue ); // nValue is being inserted into the Stream where it's appropriate (overwrite modus), without that the // current StreamPosition changes - + void SetEditAs( OUString rEditAs ); + rtl::OUString GetEditAs() { return mEditAs; } SvStream& GetStream() const { return *mpOutStrm; } sal_uLong GetStreamPos() const { return mpOutStrm->Tell(); } diff --git a/include/oox/export/vmlexport.hxx b/include/oox/export/vmlexport.hxx index 876ff7ba9b66..bc7bf294b09e 100644 --- a/include/oox/export/vmlexport.hxx +++ b/include/oox/export/vmlexport.hxx @@ -133,7 +133,7 @@ private: void AddLineDimensions( const Rectangle& rRectangle ); /// Add position and size to the OStringBuffer. - void AddRectangleDimensions( OStringBuffer& rBuffer, const Rectangle& rRectangle ); + void AddRectangleDimensions( OStringBuffer& rBuffer, const Rectangle& rRectangle, sal_Bool rbAbsolutePos = true ); }; } // namespace vml diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx index fcfb9671c643..e45c87d1139b 100644 --- a/include/oox/vml/vmlshape.hxx +++ b/include/oox/vml/vmlshape.hxx @@ -84,6 +84,7 @@ struct OOX_DLLPUBLIC ShapeTypeModel sal_Bool mbVisible; ///< Visible or Hidden OUString maWrapStyle; ///< Wrapping mode for text. OUString maArcsize; ///< round rectangles arc size + OUString maEditAs; ///< Edit As type (e.g. "canvas" etc) StrokeModel maStrokeModel; ///< Border line formatting. FillModel maFillModel; ///< Shape fill formatting. @@ -205,6 +206,7 @@ struct ShapeModel OUString maControl1; ///< Bezier control point 1 OUString maControl2; ///< Bezier control point 2 OUString maVmlPath; ///< VML path for this shape + OUString maEditAs; ///< VML EditAs for shape explicit ShapeModel(); ~ShapeModel(); diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index c594cd5cc2b3..85003b7d5445 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -129,9 +129,18 @@ sal_uInt32 VMLExport::EnterGroup( const OUString& rShapeName, const Rectangle* p if ( rShapeName.getLength() ) pAttrList->add( XML_alt, OUStringToOString( rShapeName, RTL_TEXTENCODING_UTF8 ) ); + sal_Bool rbAbsolutePos = true; + //editAs + OUString rEditAs = EscherEx::GetEditAs(); + if (!rEditAs.isEmpty()) + { + pAttrList->add(XML_editas, OUStringToOString( rEditAs, RTL_TEXTENCODING_UTF8 )); + rbAbsolutePos = false; + } + // style if ( pRect ) - AddRectangleDimensions( aStyle, *pRect ); + AddRectangleDimensions( aStyle, *pRect, rbAbsolutePos ); if ( !aStyle.isEmpty() ) pAttrList->add( XML_style, aStyle.makeStringAndClear() ); @@ -844,12 +853,15 @@ void VMLExport::AddLineDimensions( const Rectangle& rRectangle ) .makeStringAndClear() ); } -void VMLExport::AddRectangleDimensions( OStringBuffer& rBuffer, const Rectangle& rRectangle ) +void VMLExport::AddRectangleDimensions( OStringBuffer& rBuffer, const Rectangle& rRectangle, sal_Bool rbAbsolutePos) { if ( !rBuffer.isEmpty() ) rBuffer.append( ";" ); - rBuffer.append( "position:absolute;" ); + if (rbAbsolutePos) + { + rBuffer.append( "position:absolute;" ); + } if ( mnGroupLevel == 1 ) { diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 731931df66ea..31828dbba891 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -1068,6 +1068,28 @@ Reference< XShape > GroupShape::implConvertAndInsert( const Reference< XShapes > catch( Exception& ) { } + + if (!maTypeModel.maEditAs.isEmpty()) + { + uno::Reference<beans::XPropertySet> xPropertySet(xGroupShape, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aGrabBag; + xPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag; + beans::PropertyValue aPair; + aPair.Name = "mso-edit-as"; + aPair.Value = uno::makeAny(maTypeModel.maEditAs); + if (aGrabBag.hasElements()) + { + sal_Int32 nLength = aGrabBag.getLength(); + aGrabBag.realloc(nLength + 1); + aGrabBag[nLength] = aPair; + } + else + { + aGrabBag.realloc(1); + aGrabBag[0] = aPair; + } + xPropertySet->setPropertyValue("InteropGrabBag", uno::makeAny(aGrabBag)); + } // Make sure group shapes are inline as well, unless there is an explicit different style. PropertySet aPropertySet(xGroupShape); lcl_SetAnchorType(aPropertySet, maTypeModel); diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 95c98a281fb6..9e51e2a4177b 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -312,6 +312,8 @@ ShapeTypeContext::ShapeTypeContext( ContextHandler2Helper& rParent, ShapeType& r // For roundrect we may have a arcsize attribute to read mrTypeModel.maArcsize = rAttribs.getString( XML_arcsize,OUString( ) ); + // editas + mrTypeModel.maEditAs = rAttribs.getString(XML_editas, OUString()); } ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) diff --git a/sw/qa/extras/ooxmlexport/data/fdo65833.docx b/sw/qa/extras/ooxmlexport/data/fdo65833.docx Binary files differnew file mode 100644 index 000000000000..097015eed172 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo65833.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 7727bc1a5e26..46488de589db 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2394,6 +2394,16 @@ DECLARE_OOXMLEXPORT_TEST(testPreserveXfieldTOC, "PreserveXfieldTOC.docx") OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content)); CPPUNIT_ASSERT(contents.match(" TOC \\x \\f \\o \"1-3\" \\h")); } + +DECLARE_OOXMLEXPORT_TEST(testFdo65833, "fdo65833.docx") +{ + // The "editas" attribute for vml group shape was not preserved. + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:group", "editas", "canvas"); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); |