Kaydet (Commit) a44e42b9 authored tarafından Miklos Vajna's avatar Miklos Vajna

filter: handle ooxml shapes in EscherPropertyContainer::GetCustomShapeType()

The problem was that the shapes produced by the drawingML import had
types like ooxml-triangle, and EnhancedCustomShapeTypeNames::Get() only
handles VML/binary MSO shapes (e.g. isosceles-triangle). Add an OOXML
mode, and in that case use msfilter::util::GETVMLShapeType() instead,
and only fall back to EnhancedCustomShapeTypeNames::Get() if necessary.

Change-Id: Ic93ba4719133dd3e96c17d2562642a03e559fefa
üst f5e2d313
......@@ -22,6 +22,7 @@
#include <svx/svdomedia.hxx>
#include <svx/xflftrit.hxx>
#include <filter/msfilter/escherex.hxx>
#include <filter/msfilter/util.hxx>
#include <svx/unoapi.hxx>
#include <svx/svdobj.hxx>
#include <svx/svdoashp.hxx>
......@@ -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)
{
......
......@@ -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: */
......@@ -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;
};
......
......@@ -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
......
......@@ -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 )
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment