[Libreoffice-commits] core.git: filter/source include/filter include/oox oox/source sw/qa
Vinaya Mandke
vinaya.mandke at synerzip.com
Mon Jan 13 08:49:32 PST 2014
filter/source/msfilter/escherex.cxx | 5 +++++
filter/source/msfilter/eschesdo.cxx | 24 ++++++++++++++++++++++++
include/filter/msfilter/escherex.hxx | 4 +++-
include/oox/export/vmlexport.hxx | 2 +-
include/oox/vml/vmlshape.hxx | 2 ++
oox/source/export/vmlexport.cxx | 18 +++++++++++++++---
oox/source/vml/vmlshape.cxx | 22 ++++++++++++++++++++++
oox/source/vml/vmlshapecontext.cxx | 2 ++
sw/qa/extras/ooxmlexport/data/fdo65833.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 ++++++++++
10 files changed, 84 insertions(+), 5 deletions(-)
New commits:
commit c4ff46485f0461de6a2804ae859dbbc81b6af105
Author: Vinaya Mandke <vinaya.mandke at synerzip.com>
Date: Wed Jan 8 18:54:51 2014 +0530
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
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 782dcfc..129831e 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 16311df..fa697ee 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 e24996c..d69e49d 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 876ff7b..bc7bf29 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 fcfb967..e45c87d 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 c594cd5..85003b7 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 731931d..31828db 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 95c98a2..9e51e2a 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
new file mode 100644
index 0000000..097015e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo65833.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 7727bc1..46488de 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();
More information about the Libreoffice-commits
mailing list