diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 320c1b5692a2..4f94859c0139 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -3761,7 +3762,7 @@ void EscherPropertyContainer::CreateCustomShapeProperties( const MSO_SPT eShapeT } } -MSO_SPT EscherPropertyContainer::GetCustomShapeType( const uno::Reference< drawing::XShape > & rXShape, sal_uInt32& nMirrorFlags, OUString& rShapeType ) +MSO_SPT EscherPropertyContainer::GetCustomShapeType( const uno::Reference< drawing::XShape > & rXShape, sal_uInt32& nMirrorFlags, OUString& rShapeType, bool bOOXML ) { MSO_SPT eShapeType = mso_sptNil; nMirrorFlags = 0; @@ -3782,7 +3783,20 @@ MSO_SPT EscherPropertyContainer::GetCustomShapeType( const uno::Reference< drawi if ( rProp.Name == "Type" ) { if ( rProp.Value >>= rShapeType ) - eShapeType = EnhancedCustomShapeTypeNames::Get( rShapeType ); + { + if (bOOXML) + { + // In case of VML export, try to handle the + // ooxml- prefix in rShapeType. If that fails, + // just do the same as the binary export. + OString aType = OUStringToOString(rShapeType, RTL_TEXTENCODING_UTF8); + eShapeType = msfilter::util::GETVMLShapeType(aType); + if (eShapeType == mso_sptNil) + eShapeType = EnhancedCustomShapeTypeNames::Get(rShapeType); + } + else + eShapeType = EnhancedCustomShapeTypeNames::Get( rShapeType ); + } } else if ( rProp.Name == "MirroredX" ) { @@ -4933,7 +4947,7 @@ public: virtual ~SvNullStream() {} }; -EscherEx::EscherEx( const EscherExGlobalRef& rxGlobal, SvStream* pOutStrm ) : +EscherEx::EscherEx( const EscherExGlobalRef& rxGlobal, SvStream* pOutStrm, bool bOOXML ) : mxGlobal ( rxGlobal ), mpOutStrm ( pOutStrm ), mbOwnsStrm ( false ), @@ -4944,7 +4958,8 @@ EscherEx::EscherEx( const EscherExGlobalRef& rxGlobal, SvStream* pOutStrm ) : mnHellLayerId ( USHRT_MAX ), mbEscherSpgr ( sal_False ), - mbEscherDg ( sal_False ) + mbEscherDg ( sal_False ), + mbOOXML(bOOXML) { if (!mpOutStrm) { diff --git a/filter/source/msfilter/eschesdo.cxx b/filter/source/msfilter/eschesdo.cxx index 1a6e33d01368..af2a9541dc4d 100644 --- a/filter/source/msfilter/eschesdo.cxx +++ b/filter/source/msfilter/eschesdo.cxx @@ -254,7 +254,7 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj, sal_uInt32 nMirrorFlags; OUString sCustomShapeType; - MSO_SPT eShapeType = aPropOpt.GetCustomShapeType( rObj.GetShapeRef(), nMirrorFlags, sCustomShapeType ); + MSO_SPT eShapeType = aPropOpt.GetCustomShapeType( rObj.GetShapeRef(), nMirrorFlags, sCustomShapeType, rObj.GetOOXML() ); if ( sCustomShapeType == "col-502ad400" || sCustomShapeType == "col-60da8460" ) { ADD_SHAPE( ESCHER_ShpInst_PictureFrame, 0xa00 ); @@ -953,7 +953,7 @@ void EscherEx::AddUnoShapes( const Reference< XShapes >& rxShapes ) sal_uInt32 EscherEx::AddSdrObject( const SdrObject& rObj ) { - ImplEESdrObject aObj( *mpImplEscherExSdr, rObj ); + ImplEESdrObject aObj( *mpImplEscherExSdr, rObj, mbOOXML ); if( aObj.IsValid() ) return mpImplEscherExSdr->ImplWriteTheShape( aObj ); return 0; @@ -1006,13 +1006,14 @@ const SdrObject* EscherEx::GetSdrObject( const Reference< XShape >& rShape ) ImplEESdrObject::ImplEESdrObject( ImplEscherExSdr& rEx, - const SdrObject& rObj ) : + const SdrObject& rObj, bool bOOXML ) : mnShapeId( 0 ), mnTextSize( 0 ), mnAngle( 0 ), mbValid( sal_False ), mbPresObj( sal_False ), - mbEmptyPresObj( sal_False ) + mbEmptyPresObj( sal_False ), + mbOOXML(bOOXML) { SdrPage* pPage = rObj.GetPage(); DBG_ASSERT( pPage, "ImplEESdrObject::ImplEESdrObject: no SdrPage" ); @@ -1033,7 +1034,8 @@ ImplEESdrObject::ImplEESdrObject( ImplEESdrWriter& rEx, mnAngle( 0 ), mbValid( sal_False ), mbPresObj( sal_False ), - mbEmptyPresObj( sal_False ) + mbEmptyPresObj( sal_False ), + mbOOXML(false) { Init( rEx ); } @@ -1255,4 +1257,9 @@ sal_Bool ImplEESdrObject::ImplHasText() const return xXText.is() && !xXText->getString().isEmpty(); } +bool ImplEESdrObject::GetOOXML() const +{ + return mbOOXML; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/msfilter/eschesdo.hxx b/filter/source/msfilter/eschesdo.hxx index f01128533318..9d90e6a709e1 100644 --- a/filter/source/msfilter/eschesdo.hxx +++ b/filter/source/msfilter/eschesdo.hxx @@ -43,12 +43,13 @@ class ImplEESdrObject sal_Bool mbValid : 1; sal_Bool mbPresObj : 1; sal_Bool mbEmptyPresObj : 1; + bool mbOOXML; void Init( ImplEESdrWriter& rEx ); public: ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mXPropSet; - ImplEESdrObject( ImplEscherExSdr& rEx, const SdrObject& rObj ); + ImplEESdrObject( ImplEscherExSdr& rEx, const SdrObject& rObj, bool bOOXML = false ); ImplEESdrObject( ImplEESdrWriter& rEx, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rShape ); ~ImplEESdrObject(); @@ -85,6 +86,7 @@ public: sal_uInt32 ImplGetText(); sal_Bool ImplHasText() const; + bool GetOOXML() const; }; diff --git a/include/filter/msfilter/escherex.hxx b/include/filter/msfilter/escherex.hxx index 59001c6aa072..5cc33c6111d7 100644 --- a/include/filter/msfilter/escherex.hxx +++ b/include/filter/msfilter/escherex.hxx @@ -1337,7 +1337,8 @@ public: static MSO_SPT GetCustomShapeType( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape, sal_uInt32& nMirrorFlags, - OUString& rShapeType + OUString& rShapeType, + bool bOOXML = false ); // helper functions which are also used in ooxml export @@ -1584,12 +1585,13 @@ class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable sal_Bool mbEscherSpgr; sal_Bool mbEscherDg; sal_Bool mbOleEmf; // OLE is EMF instead of WMF + bool mbOOXML; virtual sal_Bool DoSeek( sal_uInt32 nKey ); public: - explicit EscherEx( const EscherExGlobalRef& rxGlobal, SvStream* pOutStrm ); + explicit EscherEx( const EscherExGlobalRef& rxGlobal, SvStream* pOutStrm, bool bOOXML = false ); virtual ~EscherEx(); /** Creates and returns a new shape identifier, updates the internal shape diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index f87e773c112d..f65ce8af2e2d 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -42,7 +42,7 @@ using namespace oox::vml; using namespace com::sun::star; VMLExport::VMLExport( ::sax_fastparser::FSHelperPtr pSerializer, VMLTextExport* pTextExport ) - : EscherEx( EscherExGlobalRef(new EscherExGlobal(0)), 0 ) + : EscherEx( EscherExGlobalRef(new EscherExGlobal(0)), 0, /*bOOXML=*/true ) , m_pSerializer( pSerializer ) , m_pTextExport( pTextExport ) , m_eHOri( 0 ) diff --git a/sw/qa/extras/ooxmlexport/data/ooxml-triangle.docx b/sw/qa/extras/ooxmlexport/data/ooxml-triangle.docx new file mode 100644 index 000000000000..4279fbfb05b2 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/ooxml-triangle.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 8fa9ded37802..bc04e9c38670 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2034,6 +2034,13 @@ DECLARE_OOXMLEXPORT_TEST(testTableLineSpacing, "table_atleast.docx") assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:pPr/w:spacing", "line", "320"); } +DECLARE_OOXMLEXPORT_TEST(testOoxmlTriangle, "ooxml-triangle.docx") +{ + // The problem was that ooxml-triangle shape type wasn't handled by VML + // export (only isosceles-triangle), leading to a missing shape. + getShape(1); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT();