oox: initial import of wpg:wgp

We import something that's visible, but the position of the shape is not
correct yet.

Change-Id: Ie68f0ebad1cc992a6c8d7704d7262f7e983f3b19
This commit is contained in:
Miklos Vajna 2013-11-27 11:40:46 +01:00
parent a2f7db5bc6
commit ec746c830c
5 changed files with 137 additions and 1 deletions

View file

@ -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/WpgContext \
oox/source/shape/WpsContext \
oox/source/token/namespacemap \
oox/source/token/propertynames \

View file

@ -23,6 +23,7 @@
#include "ShapeDrawingFragmentHandler.hxx"
#include "LockedCanvasContext.hxx"
#include "WpsContext.hxx"
#include "WpgContext.hxx"
#include "oox/vml/vmldrawingfragment.hxx"
#include "oox/vml/vmlshape.hxx"
#include "oox/drawingml/themefragmenthandler.hxx"
@ -136,6 +137,26 @@ uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getWpsContext
return mxWpsContext;
}
uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getWpgContext(sal_Int32 nElement)
{
if (!mxWpgContext.is())
{
FragmentHandler2Ref rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
ShapePtr pMasterShape;
switch (getBaseToken(nElement))
{
case XML_wgp:
mxWpgContext.set(new WpgContext(*rFragmentHandler));
break;
default:
break;
}
}
return mxWpgContext;
}
uno::Reference<xml::sax::XFastContextHandler>
ShapeContextHandler::getGraphicShapeContext(::sal_Int32 Element )
{
@ -216,6 +237,9 @@ ShapeContextHandler::getContextHandler()
case NMSP_wps:
xResult.set(getWpsContext(mnStartToken));
break;
case NMSP_wpg:
xResult.set(getWpgContext(mnStartToken));
break;
default:
xResult.set(getGraphicShapeContext(mnStartToken));
break;
@ -240,7 +264,7 @@ void SAL_CALL ShapeContextHandler::startFastElement
mpThemePtr.reset(new Theme());
if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas) || Element == C_TOKEN(chart) || Element == WPS_TOKEN(wsp))
if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas) || Element == C_TOKEN(chart) || Element == WPS_TOKEN(wsp) || Element == WPG_TOKEN(wgp))
{
// Parse the theme relation, if available; the diagram won't have colors without it.
if (!msRelationFragmentPath.isEmpty())
@ -432,6 +456,18 @@ ShapeContextHandler::getShape() throw (uno::RuntimeException)
mxWpsContext.clear();
}
}
else if (mxWpgContext.is())
{
ShapePtr pShape = dynamic_cast<WpgContext*>(mxWpgContext.get())->getShape();
if (pShape)
{
basegfx::B2DHomMatrix aMatrix;
pShape->setPosition(maPosition);
pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
xResult = pShape->getXShape();
mxWpgContext.clear();
}
}
else if (mpShape.get() != NULL)
{
basegfx::B2DHomMatrix aTransformation;

View file

@ -155,6 +155,7 @@ private:
css::uno::Reference<XFastContextHandler> mxDiagramShapeContext;
css::uno::Reference<XFastContextHandler> mxLockedCanvasContext;
css::uno::Reference<XFastContextHandler> mxWpsContext;
css::uno::Reference<XFastContextHandler> mxWpgContext;
css::uno::Reference<XFastContextHandler> mxChartShapeContext;
core::XmlFilterRef mxFilterBase;
@ -169,6 +170,7 @@ private:
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> getWpgContext(sal_Int32 nElement);
css::uno::Reference<XFastContextHandler> getContextHandler();
};

View file

@ -0,0 +1,59 @@
/* -*- 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 "WpgContext.hxx"
#include <oox/drawingml/shapepropertiescontext.hxx>
#include <oox/drawingml/shapegroupcontext.hxx>
using namespace com::sun::star;
namespace oox { namespace shape {
WpgContext::WpgContext(ContextHandler2Helper& rParent)
: ContextHandler2(rParent)
{
mpShape.reset(new oox::drawingml::Shape("com.sun.star.drawing.GroupShape"));
}
WpgContext::~WpgContext()
{
}
oox::drawingml::ShapePtr WpgContext::getShape()
{
return mpShape;
}
oox::core::ContextHandlerRef WpgContext::onCreateContext(sal_Int32 nElementToken, const oox::AttributeList& /*rAttribs*/)
{
switch (getBaseToken(nElementToken))
{
case XML_wgp:
break;
case XML_cNvGrpSpPr:
break;
case XML_grpSpPr:
return new oox::drawingml::ShapePropertiesContext(*this, *mpShape);
break;
case XML_wsp:
{
oox::drawingml::ShapePtr pShape(new oox::drawingml::Shape("com.sun.star.drawing.CustomShape"));
return new oox::drawingml::ShapeContext(*this, mpShape, pShape);
}
break;
default:
SAL_WARN("oox", "WpgContext::createFastChildContext: unhandled element: " << getBaseToken(nElementToken));
break;
}
return 0;
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -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_WPGCONTEXT_HXX
#define INCLUDED_OOX_SOURCE_SHAPE_WPGCONTEXT_HXX
#include "oox/core/contexthandler2.hxx"
#include "oox/drawingml/shape.hxx"
namespace oox { namespace shape {
/// Wpg is the drawingML equivalent of v:group.
class WpgContext : public oox::core::ContextHandler2
{
public:
WpgContext(oox::core::ContextHandler2Helper& rParent);
virtual ~WpgContext();
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: */