[Libreoffice-commits] core.git: 3 commits - oox/Library_oox.mk oox/source writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Nov 27 04:09:12 PST 2013
oox/Library_oox.mk | 1
oox/source/shape/ShapeContextHandler.cxx | 38 ++++++++++++++++
oox/source/shape/ShapeContextHandler.hxx | 2
oox/source/shape/WpgContext.cxx | 59 ++++++++++++++++++++++++++
oox/source/shape/WpgContext.hxx | 38 ++++++++++++++++
oox/source/token/namespaces.hxx.tail | 1
oox/source/token/namespaces.txt | 1
oox/source/token/tokens.txt | 1
writerfilter/source/dmapper/GraphicImport.cxx | 1
writerfilter/source/ooxml/model.xml | 23 ++++++++++
10 files changed, 164 insertions(+), 1 deletion(-)
New commits:
commit ec746c830c4ce86e446b929a88a3376a51871314
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Nov 27 11:40:46 2013 +0100
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
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 7bd3710..b7e763c 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/WpgContext \
oox/source/shape/WpsContext \
oox/source/token/namespacemap \
oox/source/token/propertynames \
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index bcf43c8..c12518d 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -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;
diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx
index 0c21313..7a9b93c 100644
--- a/oox/source/shape/ShapeContextHandler.hxx
+++ b/oox/source/shape/ShapeContextHandler.hxx
@@ -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();
};
diff --git a/oox/source/shape/WpgContext.cxx b/oox/source/shape/WpgContext.cxx
new file mode 100644
index 0000000..f83fe75
--- /dev/null
+++ b/oox/source/shape/WpgContext.cxx
@@ -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: */
diff --git a/oox/source/shape/WpgContext.hxx b/oox/source/shape/WpgContext.hxx
new file mode 100644
index 0000000..3a60986
--- /dev/null
+++ b/oox/source/shape/WpgContext.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_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: */
commit a2f7db5bc6f26281f2ca1ddb828a6ef501c8c2ec
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Nov 27 11:29:47 2013 +0100
writerfilter: tokenize wpg:wgp
These are just the minimal changes, so that writerfilter calls into
oox::shape::ShapeContextHandler, which does the real work.
Change-Id: I7830178efd6ed75da6737a67d9d24dcf59337954
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 25056d6..aeea2d0 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1260,6 +1260,7 @@ void GraphicImport::lcl_sprm(Sprm & rSprm)
case NS_ooxml::LN_lc_lockedCanvas:
case NS_ooxml::LN_c_chart:
case NS_ooxml::LN_wps_wsp:
+ case NS_ooxml::LN_wpg_wgp:
{
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 2e0a300..86c9138 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -28,6 +28,7 @@
<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="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" alias="wps" id="wps"/>
+ <namespace-alias name="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" alias="wpg" id="wpg"/>
<namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/chart" alias="chart" id="dmlChart"/>
<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"/>
@@ -5173,6 +5174,7 @@
<ref name="lockedCanvas"/>
<ref name="chart"/>
<ref name="wsp"/>
+ <ref name="wgp"/>
<element>
<anyName/>
<ref name="BUILT_IN_ANY_TYPE"/>
@@ -5202,6 +5204,7 @@
<element name="lockedCanvas" tokenid="ooxml:CT_GraphicalObjectData_lockedCanvas"/>
<element name="chart" tokenid="ooxml:CT_GraphicalObjectData_chart"/>
<element name="wsp" tokenid="ooxml:CT_GraphicalObjectData_wsp"/>
+ <element name="wgp" tokenid="ooxml:CT_GraphicalObjectData_wgp"/>
<attribute name="uri" tokenid="ooxml:CT_GraphicalObjectData_uri"/>
</resource>
<resource name="CT_GraphicalObject" resource="Properties" tag="shape">
@@ -8501,6 +8504,19 @@
<ref name="CT_WordprocessingShape"/>
</element>
</define>
+ <define name="CT_WordprocessingGroup">
+ <element name="cNvGrpSpPr">
+ <ref name="CT_NonVisualGroupDrawingShapeProps"/>
+ </element>
+ <element name="grpSpPr">
+ <ref name="CT_WordprocessingGroup"/>
+ </element>
+ </define>
+ <define name="wgp">
+ <element xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" name="wpg:wgp">
+ <ref name="CT_WordprocessingGroup"/>
+ </element>
+ </define>
</grammar>
<resource name="CT_PictureNonVisual" resource="Properties" tag="shape">
<element name="cNvPr" tokenid="ooxml:CT_PictureNonVisual_cNvPr"/>
@@ -8543,6 +8559,13 @@
<resource name="wsp" resource="Shape" tag="shape">
<element xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" name="wps:wsp" tokenid="ooxml:wps_wsp"/>
</resource>
+ <resource xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" name="CT_WordprocessingGroup" resource="Shape" tag="shape">
+ <element name="wpg:cNvGrpSpPr" tokenid="ooxml:CT_WordprocessingGroup_cNvGrpSpPr"/>
+ <element name="wpg:grpSpPr" tokenid="ooxml:CT_WordprocessingGroup_grpSpPr"/>
+ </resource>
+ <resource name="wgp" resource="Shape" tag="shape">
+ <element xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" name="wpg:wgp" tokenid="ooxml:wpg_wgp"/>
+ </resource>
</namespace>
<namespace name="vml-main" file="vml-main.rng" todo="ignore">
commit 83a918016d317d5fb58bb778124310a97204574f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Nov 27 10:49:32 2013 +0100
oox: add support for the wpg 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: I00eec562e32df359231d1a170367ab75702f0049
diff --git a/oox/source/token/namespaces.hxx.tail b/oox/source/token/namespaces.hxx.tail
index a0489fe..e0baeae 100644
--- a/oox/source/token/namespaces.hxx.tail
+++ b/oox/source/token/namespaces.hxx.tail
@@ -53,6 +53,7 @@ inline sal_Int32 getNamespace( sal_Int32 nToken ) { return nToken & NMSP_MASK; }
#define DSP_TOKEN( token ) OOX_TOKEN( dsp, token )
#define LC_TOKEN( token ) OOX_TOKEN( dmlLockedCanvas, token )
#define WPS_TOKEN( token ) OOX_TOKEN( wps, token )
+#define WPG_TOKEN( token ) OOX_TOKEN( wpg, token )
// ============================================================================
diff --git a/oox/source/token/namespaces.txt b/oox/source/token/namespaces.txt
index 0083bca..e62c38d 100644
--- a/oox/source/token/namespaces.txt
+++ b/oox/source/token/namespaces.txt
@@ -72,6 +72,7 @@ sprm http://sprm
mce http://schemas.openxmlformats.org/markup-compatibility/2006
mceTest http://schemas.openxmlformats.org/spreadsheetml/2006/main/v2
wps http://schemas.microsoft.com/office/word/2010/wordprocessingShape
+wpg http://schemas.microsoft.com/office/word/2010/wordprocessingGroup
# extlst namespaces
diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt
index 64c2ca1..51f797e 100644
--- a/oox/source/token/tokens.txt
+++ b/oox/source/token/tokens.txt
@@ -5607,6 +5607,7 @@ wedgeEllipseCallout
wedgeRectCallout
wedgeRoundRectCallout
weight
+wgp
wheat
wheel
whenNotActive
More information about the Libreoffice-commits
mailing list