[Libreoffice-commits] core.git: filter/source include/filter oox/source sw/qa
Miklos Vajna
vmiklos at collabora.co.uk
Tue Dec 3 02:58:47 PST 2013
filter/source/msfilter/escherex.cxx | 23 ++++++++++++++++++----
filter/source/msfilter/eschesdo.cxx | 17 +++++++++++-----
filter/source/msfilter/eschesdo.hxx | 4 ++-
include/filter/msfilter/escherex.hxx | 6 +++--
oox/source/export/vmlexport.cxx | 2 -
sw/qa/extras/ooxmlexport/data/ooxml-triangle.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 7 ++++++
7 files changed, 46 insertions(+), 13 deletions(-)
New commits:
commit a44e42b9cd08d1ac8438ed2944cf174ffd68b80e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Dec 3 10:50:44 2013 +0100
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
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 320c1b5..4f94859 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -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)
{
diff --git a/filter/source/msfilter/eschesdo.cxx b/filter/source/msfilter/eschesdo.cxx
index 1a6e33d..af2a954 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 f011285..9d90e6a 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 59001c6..5cc33c6 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 f87e773..f65ce8a 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 0000000..4279fbf
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 8fa9ded..bc04e9c 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();
More information about the Libreoffice-commits
mailing list