diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-06-20 10:37:46 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-06-20 10:46:56 +0200 |
commit | a9966b272151fa66c4a7c74bcb2505ef2ea94a6e (patch) | |
tree | 1cbf55ac34526c60ee0fbf0bfa59bd3e02410fe2 /oox | |
parent | 363dafefad14411a16f6ea9d2ee0d55b67bc9c8d (diff) |
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
Diffstat (limited to 'oox')
-rw-r--r-- | oox/Library_oox.mk | 1 | ||||
-rw-r--r-- | oox/source/shape/LockedCanvasContext.cxx | 66 | ||||
-rw-r--r-- | oox/source/shape/LockedCanvasContext.hxx | 40 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.cxx | 37 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.hxx | 2 |
5 files changed, 145 insertions, 1 deletions
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk index 3d8743fe4f40..45f4b9cc494a 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 000000000000..9a7e9c0ff55c --- /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 000000000000..c93d49d54aad --- /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 9c8da2d0549d..5c1f990a5ab9 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 f8cdcb77bfc0..c70460644729 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(); }; |