diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-13 10:35:36 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-13 15:42:37 +0100 |
commit | 400d5d8a90f1f2737f87b7011294cddb8071768f (patch) | |
tree | e6051036a3b6acab885f08f67c6e15ccea516786 /oox | |
parent | cd29a30fcf0bf6c66762e4872bf1b8ced5b0262d (diff) |
oox: initial import of wps:wsp
We import something that's visible, but the shape is always inline, even
when it has to be anchored.
Change-Id: I6e20aa1a208f06731098ad21bb51c1ca840213d0
Diffstat (limited to 'oox')
-rw-r--r-- | oox/Library_oox.mk | 1 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.cxx | 37 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.hxx | 2 | ||||
-rw-r--r-- | oox/source/shape/WpsContext.cxx | 58 | ||||
-rw-r--r-- | oox/source/shape/WpsContext.hxx | 38 |
5 files changed, 135 insertions, 1 deletions
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk index dd30e70c3735..7bd371017d4c 100644 --- a/oox/Library_oox.mk +++ b/oox/Library_oox.mk @@ -277,6 +277,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\ oox/source/shape/ShapeContextHandler \ oox/source/shape/ShapeDrawingFragmentHandler \ oox/source/shape/ShapeFilterBase \ + oox/source/shape/WpsContext \ oox/source/token/namespacemap \ oox/source/token/propertynames \ oox/source/token/tokenmap \ diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index dbbd41d71623..8286def8ffe4 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -22,6 +22,7 @@ #include "ShapeContextHandler.hxx" #include "ShapeDrawingFragmentHandler.hxx" #include "LockedCanvasContext.hxx" +#include "WpsContext.hxx" #include "oox/vml/vmldrawingfragment.hxx" #include "oox/vml/vmlshape.hxx" #include "oox/drawingml/themefragmenthandler.hxx" @@ -115,6 +116,26 @@ uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getChartShape return mxChartShapeContext; } +uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getWpsContext(sal_Int32 nElement) +{ + if (!mxWpsContext.is()) + { + FragmentHandler2Ref rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath)); + ShapePtr pMasterShape; + + switch (getBaseToken(nElement)) + { + case XML_wsp: + mxWpsContext.set(new WpsContext(*rFragmentHandler)); + break; + default: + break; + } + } + + return mxWpsContext; +} + uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getGraphicShapeContext(::sal_Int32 Element ) { @@ -192,6 +213,9 @@ ShapeContextHandler::getContextHandler() case NMSP_dmlChart: xResult.set(getChartShapeContext(mnStartToken)); break; + case NMSP_wps: + xResult.set(getWpsContext(mnStartToken)); + break; default: xResult.set(getGraphicShapeContext(mnStartToken)); break; @@ -216,7 +240,7 @@ void SAL_CALL ShapeContextHandler::startFastElement mpThemePtr.reset(new Theme()); - if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas) || Element == C_TOKEN(chart) ) + if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas) || Element == C_TOKEN(chart) || Element == WPS_TOKEN(wsp)) { // Parse the theme relation, if available; the diagram won't have colors without it. if (!msRelationFragmentPath.isEmpty()) @@ -396,6 +420,17 @@ ShapeContextHandler::getShape() throw (uno::RuntimeException) xResult = pShapePtr->getXShape(); mxChartShapeContext.clear(); } + else if (mxWpsContext.is()) + { + ShapePtr pShape = dynamic_cast<WpsContext*>(mxWpsContext.get())->getShape(); + if (pShape) + { + basegfx::B2DHomMatrix aMatrix; + pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties()); + xResult = pShape->getXShape(); + mxWpsContext.clear(); + } + } else if (mpShape.get() != NULL) { basegfx::B2DHomMatrix aTransformation; diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx index d7a49a128d4e..11fdc0b5d6bb 100644 --- a/oox/source/shape/ShapeContextHandler.hxx +++ b/oox/source/shape/ShapeContextHandler.hxx @@ -150,6 +150,7 @@ private: css::uno::Reference<XFastContextHandler> mxGraphicShapeContext; css::uno::Reference<XFastContextHandler> mxDiagramShapeContext; css::uno::Reference<XFastContextHandler> mxLockedCanvasContext; + css::uno::Reference<XFastContextHandler> mxWpsContext; css::uno::Reference<XFastContextHandler> mxChartShapeContext; core::XmlFilterRef mxFilterBase; @@ -163,6 +164,7 @@ private: css::uno::Reference<XFastContextHandler> getDrawingShapeContext(); css::uno::Reference<XFastContextHandler> getDiagramShapeContext(); css::uno::Reference<XFastContextHandler> getLockedCanvasContext(sal_Int32 nElement); + css::uno::Reference<XFastContextHandler> getWpsContext(sal_Int32 nElement); css::uno::Reference<XFastContextHandler> getContextHandler(); }; diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx new file mode 100644 index 000000000000..7b9077005b74 --- /dev/null +++ b/oox/source/shape/WpsContext.cxx @@ -0,0 +1,58 @@ +/* -*- 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 "WpsContext.hxx" +#include <oox/drawingml/shapepropertiescontext.hxx> +#include <oox/drawingml/shapestylecontext.hxx> + +using namespace com::sun::star; + +namespace oox { namespace shape { + +WpsContext::WpsContext(ContextHandler2Helper& rParent) +: ContextHandler2(rParent) +{ + mpShape.reset(new oox::drawingml::Shape("com.sun.star.drawing.CustomShape")); +} + +WpsContext::~WpsContext() +{ +} + +oox::drawingml::ShapePtr WpsContext::getShape() +{ + return mpShape; +} + +oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken, const oox::AttributeList& /*rAttribs*/) +{ + switch (getBaseToken(nElementToken)) + { + case XML_wsp: + break; + case XML_cNvSpPr: + break; + case XML_spPr: + return new oox::drawingml::ShapePropertiesContext(*this, *mpShape); + break; + case XML_style: + return new oox::drawingml::ShapeStyleContext(*this, *mpShape); + break; + case XML_bodyPr: + break; + default: + SAL_WARN("oox", "WpsContext::createFastChildContext: unhandled element:" << getBaseToken(nElementToken)); + break; + } + return 0; +} + +} } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/shape/WpsContext.hxx b/oox/source/shape/WpsContext.hxx new file mode 100644 index 000000000000..cb05de8ae080 --- /dev/null +++ b/oox/source/shape/WpsContext.hxx @@ -0,0 +1,38 @@ +/* -*- 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 INCLUDED_OOX_SOURCE_SHAPE_WPSCONTEXT_HXX +#define INCLUDED_OOX_SOURCE_SHAPE_WPSCONTEXT_HXX + +#include "oox/core/contexthandler2.hxx" +#include "oox/drawingml/shape.hxx" + +namespace oox { namespace shape { + +/// Wps is the drawingML equivalent of v:shape. +class WpsContext : public oox::core::ContextHandler2 +{ +public: + WpsContext(oox::core::ContextHandler2Helper& rParent); + virtual ~WpsContext(); + + virtual oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElementToken, const oox::AttributeList& rAttribs) SAL_OVERRIDE; + + oox::drawingml::ShapePtr getShape(); + +protected: + oox::drawingml::ShapePtr mpShape; +}; + + +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |