oox/Library_oox.mk | 1 oox/source/shape/LockedCanvasContext.cxx | 66 ++++++++++++++++++++++++++ oox/source/shape/LockedCanvasContext.hxx | 40 +++++++++++++++ oox/source/shape/ShapeContextHandler.cxx | 37 ++++++++++++++ oox/source/shape/ShapeContextHandler.hxx | 2 oox/source/token/namespaces.hxx.tail | 1 oox/source/token/namespaces.txt | 1 writerfilter/source/dmapper/GraphicImport.cxx | 1 writerfilter/source/ooxml/model.xml | 23 +++++++++ 9 files changed, 171 insertions(+), 1 deletion(-)
New commits: commit a9966b272151fa66c4a7c74bcb2505ef2ea94a6e Author: Miklos Vajna <vmik...@suse.cz> Date: Thu Jun 20 10:37:46 2013 +0200 fdo#43641 oox: initial import of lc:lockedCanvas If that canvas contains a single shape, the result looks OK. If it contains a groupshape, we also import something, but then the position / size is still to be improved. Change-Id: Ic4e4c08016a05a5e3acb005c3a642981ba4fb16d diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk index 3d8743f..45f4b9c 100644 --- a/oox/Library_oox.mk +++ b/oox/Library_oox.mk @@ -266,6 +266,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\ oox/source/ppt/timenodelistcontext \ oox/source/ppt/timetargetelementcontext \ oox/source/ppt/extdrawingfragmenthandler \ + oox/source/shape/LockedCanvasContext \ oox/source/shape/ShapeContextHandler \ oox/source/shape/ShapeDrawingFragmentHandler \ oox/source/shape/ShapeFilterBase \ diff --git a/oox/source/shape/LockedCanvasContext.cxx b/oox/source/shape/LockedCanvasContext.cxx new file mode 100644 index 0000000..9a7e9c0 --- /dev/null +++ b/oox/source/shape/LockedCanvasContext.cxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "LockedCanvasContext.hxx" +#include <oox/drawingml/shapegroupcontext.hxx> + +using namespace com::sun::star; + +namespace oox { namespace shape { + +LockedCanvasContext::LockedCanvasContext( ContextHandler& rParent ) +: ContextHandler( rParent ) +{ +} + +LockedCanvasContext::~LockedCanvasContext() +{ +} + +oox::drawingml::ShapePtr LockedCanvasContext::getShape() +{ + return mpShape; +} + +uno::Reference< xml::sax::XFastContextHandler > LockedCanvasContext::createFastChildContext( sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttribs*/ ) throw (xml::sax::SAXException, uno::RuntimeException) +{ + uno::Reference< xml::sax::XFastContextHandler > xRet; + + switch( getBaseToken( aElementToken ) ) + { + case XML_lockedCanvas: + break; + case XML_nvGrpSpPr: + break; + case XML_grpSpPr: + break; + case XML_sp: + { + oox::drawingml::ShapePtr pMasterShape; + mpShape.reset(new oox::drawingml::Shape("com.sun.star.drawing.CustomShape")); + xRet = new oox::drawingml::ShapeContext( *this, pMasterShape, mpShape ); + } + break; + case XML_grpSp: + { + oox::drawingml::ShapePtr pMasterShape; + mpShape.reset(new oox::drawingml::Shape("com.sun.star.drawing.GroupShape")); + xRet = new oox::drawingml::ShapeGroupContext( *this, pMasterShape, mpShape ); + } + break; + default: + SAL_WARN("oox", "LockedCanvasContext::createFastChildContext: unhandled element:" << getBaseToken(aElementToken)); + break; + } + return xRet; +} + +} } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/shape/LockedCanvasContext.hxx b/oox/source/shape/LockedCanvasContext.hxx new file mode 100644 index 0000000..c93d49d --- /dev/null +++ b/oox/source/shape/LockedCanvasContext.hxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef OOX_SHAPE_LOCKEDCANVASCONTEXT +#define OOX_SHAPE_LOCKEDCANVASCONTEXT + +#include "oox/core/contexthandler.hxx" +#include "oox/drawingml/shape.hxx" + +namespace oox { namespace shape { + +/// Locked canvas is kind of a container for drawingml shapes: it can even contain group shapes. +class LockedCanvasContext : public oox::core::ContextHandler +{ +public: + LockedCanvasContext( oox::core::ContextHandler& rParent ); + virtual ~LockedCanvasContext(); + + virtual com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 Element, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + oox::drawingml::ShapePtr getShape(); + +protected: + + oox::drawingml::ShapePtr mpShape; +}; + + +} } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index 9c8da2d..5c1f990 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -21,6 +21,7 @@ #include "ShapeContextHandler.hxx" #include "ShapeDrawingFragmentHandler.hxx" +#include "LockedCanvasContext.hxx" #include "oox/vml/vmldrawingfragment.hxx" #include "oox/vml/vmlshape.hxx" #include "oox/drawingml/themefragmenthandler.hxx" @@ -69,6 +70,26 @@ ShapeContextHandler::~ShapeContextHandler() { } +uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getLockedCanvasContext(sal_Int32 nElement) +{ + if (!mxLockedCanvasContext.is()) + { + FragmentHandlerRef rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath)); + ShapePtr pMasterShape; + + switch (nElement & 0xffff) + { + case XML_lockedCanvas: + mxLockedCanvasContext.set(new LockedCanvasContext(*rFragmentHandler)); + break; + default: + break; + } + } + + return mxLockedCanvasContext; +} + uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getGraphicShapeContext(::sal_Int32 Element ) { @@ -140,6 +161,9 @@ ShapeContextHandler::getContextHandler() case NMSP_dmlDiagram: xResult.set(getDiagramShapeContext()); break; + case NMSP_dmlLockedCanvas: + xResult.set(getLockedCanvasContext(mnStartToken)); + break; default: xResult.set(getGraphicShapeContext(mnStartToken)); break; @@ -164,7 +188,7 @@ void SAL_CALL ShapeContextHandler::startFastElement mpThemePtr.reset(new Theme()); - if (Element == DGM_TOKEN(relIds)) + if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas)) { // Parse the theme relation, if available; the diagram won't have colors without it. if (!msRelationFragmentPath.isEmpty()) @@ -309,6 +333,17 @@ ShapeContextHandler::getShape() throw (uno::RuntimeException) } mxDiagramShapeContext.clear(); } + else if (mxLockedCanvasContext.is()) + { + ShapePtr pShape = dynamic_cast<LockedCanvasContext*>(mxLockedCanvasContext.get())->getShape(); + if (pShape) + { + basegfx::B2DHomMatrix aMatrix; + pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties()); + xResult = pShape->getXShape(); + mxLockedCanvasContext.clear(); + } + } else if (mpShape.get() != NULL) { basegfx::B2DHomMatrix aTransformation; diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx index f8cdcb7..c704606 100644 --- a/oox/source/shape/ShapeContextHandler.hxx +++ b/oox/source/shape/ShapeContextHandler.hxx @@ -149,6 +149,7 @@ private: css::uno::Reference<XFastContextHandler> mxDrawingFragmentHandler; css::uno::Reference<XFastContextHandler> mxGraphicShapeContext; css::uno::Reference<XFastContextHandler> mxDiagramShapeContext; + css::uno::Reference<XFastContextHandler> mxLockedCanvasContext; core::XmlFilterRef mxFilterBase; drawingml::ThemePtr mpThemePtr; @@ -159,6 +160,7 @@ private: css::uno::Reference<XFastContextHandler> getGraphicShapeContext(::sal_Int32 Element); css::uno::Reference<XFastContextHandler> getDrawingShapeContext(); css::uno::Reference<XFastContextHandler> getDiagramShapeContext(); + css::uno::Reference<XFastContextHandler> getLockedCanvasContext(sal_Int32 nElement); css::uno::Reference<XFastContextHandler> getContextHandler(); }; commit 363dafefad14411a16f6ea9d2ee0d55b67bc9c8d Author: Miklos Vajna <vmik...@suse.cz> Date: Wed Jun 19 17:41:34 2013 +0200 fdo#43641 writerfilter: tokenize lc:lockedCanvas These are just the minimal changes, so that writerfilter calls into oox::shape::ShapeContextHandler, which does the real work. Change-Id: Ia53731ac8592964b70e8a438ed09262463c05360 diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 8403f72..a6c6295 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1205,6 +1205,7 @@ void GraphicImport::lcl_sprm(Sprm & rSprm) case NS_ooxml::LN_graphic_graphic: case NS_ooxml::LN_pic_pic: case NS_ooxml::LN_dgm_relIds: + case NS_ooxml::LN_lc_lockedCanvas: { writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); if( pProperties.get()) diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index cdafa91..c9f2d4f 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -26,6 +26,7 @@ <namespace-alias name="urn:schemas-microsoft-com:vml" alias="vml" id="vml"/> <namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/picture" alias="picture" id="dmlPicture"/> <namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/diagram" alias="diagram" id="dmlDiagram"/> + <namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas" alias="lockedCanvas" id="dmlLockedCanvas"/> <namespace-alias name="urn:schemas-microsoft-com:office:word" alias="vml_wordprocessingDrawing" id="vmlWord"/> <namespace-alias name="http://schemas.openxmlformats.org/wordprocessingml/2006/main" alias="wordprocessingml" id="doc"/> <namespace-alias name="http://schemas.openxmlformats.org/officeDocument/2006/math" alias="math" id="officeMath"/> @@ -5165,6 +5166,7 @@ <zeroOrMore> <ref name="pic"/> <ref name="relIds"/> + <ref name="lockedCanvas"/> <element> <anyName/> <ref name="BUILT_IN_ANY_TYPE"/> @@ -5191,6 +5193,7 @@ <resource name="CT_GraphicalObjectData" resource="Properties" tag="shape"> <element name="pic" tokenid="ooxml:CT_GraphicalObjectData_pic"/> <element name="relIds" tokenid="ooxml:CT_GraphicalObjectData_relIds"/> + <element name="lockedCanvas" tokenid="ooxml:CT_GraphicalObjectData_lockedCanvas"/> <attribute name="uri" tokenid="ooxml:CT_GraphicalObjectData_uri"/> </resource> <resource name="CT_GraphicalObject" resource="Properties" tag="shape"> @@ -8454,6 +8457,19 @@ <ref name="CT_RelIds"/> </element> </define> + <define xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" name="CT_GvmlGroupShape"> + <element name="nvGrpSpPr"> + <ref name="CT_NonVisualGroupDrawingShapeProps"/> + </element> + <element name="grpSpPr"> + <ref name="CT_GroupShapeProperties"/> + </element> + </define> + <define name="lockedCanvas"> + <element xmlns:lc="http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas" name="lc:lockedCanvas"> + <ref name="CT_GvmlGroupShape"/> + </element> + </define> </grammar> <resource name="CT_PictureNonVisual" resource="Properties" tag="shape"> <element name="cNvPr" tokenid="ooxml:CT_PictureNonVisual_cNvPr"/> @@ -8476,6 +8492,13 @@ <resource name="relIds" resource="Shape" tag="shape"> <element xmlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/diagram" name="dgm:relIds" tokenid="ooxml:dgm_relIds"/> </resource> + <resource xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="CT_GvmlGroupShape" resource="Shape" tag="shape"> + <element name="a:nvGrpSpPr" tokenid="ooxml:CT_GvmlGroupShape_nvGrpSpPr"/> + <element name="a:grpSpPr" tokenid="ooxml:CT_GvmlGroupShape_grpSpPr"/> + </resource> + <resource name="lockedCanvas" resource="Shape" tag="shape"> + <element xmlns:lc="http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas" name="lc:lockedCanvas" tokenid="ooxml:lc_lockedCanvas"/> + </resource> </namespace> <namespace name="vml-main" file="vml-main.rng" todo="ignore"> <start name="shape"/> commit 32b93c5c4f0663eefd1e1979875f8af659c463df Author: Miklos Vajna <vmik...@suse.cz> Date: Wed Jun 19 17:13:29 2013 +0200 fdo#43641 oox: add support for the lockedCanvas namespace The plan is that once these are here, the writerfilter ooxml tokenizer can refer to them. And then the writerfilter will call back to oox to do the real drawingml import. Change-Id: Ibc0d9838f3db717004a3bc8b80a408a39c8f0886 diff --git a/oox/source/token/namespaces.hxx.tail b/oox/source/token/namespaces.hxx.tail index 7b1e869..b684ea5 100644 --- a/oox/source/token/namespaces.hxx.tail +++ b/oox/source/token/namespaces.hxx.tail @@ -51,6 +51,7 @@ inline sal_Int32 getNamespace( sal_Int32 nToken ) { return nToken & NMSP_MASK; } #define XML_TOKEN( token ) OOX_TOKEN( xml, token ) #define VMLPPT_TOKEN( token ) OOX_TOKEN( vmlPowerpoint, token ) #define DSP_TOKEN( token ) OOX_TOKEN( dsp, token ) +#define LC_TOKEN( token ) OOX_TOKEN( dmlLockedCanvas, token ) // ============================================================================ diff --git a/oox/source/token/namespaces.txt b/oox/source/token/namespaces.txt index 98f8dcf..78ba6ba 100644 --- a/oox/source/token/namespaces.txt +++ b/oox/source/token/namespaces.txt @@ -49,6 +49,7 @@ dsp http://schemas.microsoft.com/office/drawing/2008/diagram dmlChart http://schemas.openxmlformats.org/drawingml/2006/chart dmlChartDr http://schemas.openxmlformats.org/drawingml/2006/chartDrawing dmlDiagram http://schemas.openxmlformats.org/drawingml/2006/diagram +dmlLockedCanvas http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas dmlPicture http://schemas.openxmlformats.org/drawingml/2006/picture dmlSpreadDr http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing dmlWordDr http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits