summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/shape/ShapeContextHandler.cxx54
-rw-r--r--oox/source/shape/ShapeContextHandler.hxx2
2 files changed, 50 insertions, 6 deletions
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index 461a1fe175aa..3e7efb0827b0 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -90,6 +90,31 @@ uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getLockedCanv
return mxLockedCanvasContext;
}
+/*
+ * This method creates new ChartGraphicDataContext Object.
+ */
+uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getChartShapeContext(sal_Int32 nElement)
+{
+ if (!mxChartShapeContext.is())
+ {
+ ContextHandler2Helper *rFragmentHandler
+ (new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
+ ShapePtr pMasterShape;
+
+ switch (nElement & 0xffff)
+ {
+ case XML_chart:
+ mpShape.reset(new Shape("com.sun.star.drawing.OLE2Shape" ));
+ mxChartShapeContext.set(new ChartGraphicDataContext(*rFragmentHandler, mpShape, true));
+ break;
+ default:
+ break;
+ }
+ }
+
+ return mxChartShapeContext;
+}
+
uno::Reference<xml::sax::XFastContextHandler>
ShapeContextHandler::getGraphicShapeContext(::sal_Int32 Element )
{
@@ -164,6 +189,9 @@ ShapeContextHandler::getContextHandler()
case NMSP_dmlLockedCanvas:
xResult.set(getLockedCanvasContext(mnStartToken));
break;
+ case NMSP_dmlChart:
+ xResult.set(getChartShapeContext(mnStartToken));
+ break;
default:
xResult.set(getGraphicShapeContext(mnStartToken));
break;
@@ -188,18 +216,21 @@ void SAL_CALL ShapeContextHandler::startFastElement
mpThemePtr.reset(new Theme());
- if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas))
+ if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas) || Element == C_TOKEN(chart) )
{
// Parse the theme relation, if available; the diagram won't have colors without it.
if (!msRelationFragmentPath.isEmpty())
{
FragmentHandlerRef rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
OUString aThemeFragmentPath = rFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "theme" ) );
- uno::Reference<xml::sax::XFastSAXSerializable> xDoc(mxFilterBase->importFragment(aThemeFragmentPath), uno::UNO_QUERY_THROW);
- mxFilterBase->importFragment(new ThemeFragmentHandler(*mxFilterBase, aThemeFragmentPath, *mpThemePtr ), xDoc);
- ShapeFilterBase* pShapeFilterBase(dynamic_cast<ShapeFilterBase*>(mxFilterBase.get()));
- if (pShapeFilterBase)
- pShapeFilterBase->setCurrentTheme(mpThemePtr);
+ if(!aThemeFragmentPath.isEmpty())
+ {
+ uno::Reference<xml::sax::XFastSAXSerializable> xDoc(mxFilterBase->importFragment(aThemeFragmentPath), uno::UNO_QUERY_THROW);
+ mxFilterBase->importFragment(new ThemeFragmentHandler(*mxFilterBase, aThemeFragmentPath, *mpThemePtr ), xDoc);
+ ShapeFilterBase* pShapeFilterBase(dynamic_cast<ShapeFilterBase*>(mxFilterBase.get()));
+ if (pShapeFilterBase)
+ pShapeFilterBase->setCurrentTheme(mpThemePtr);
+ }
}
createFastChildContext(Element, Attribs);
@@ -353,6 +384,17 @@ ShapeContextHandler::getShape() throw (uno::RuntimeException)
mxLockedCanvasContext.clear();
}
}
+ else if (mxChartShapeContext.is())
+ {
+ basegfx::B2DHomMatrix aMatrix;
+ ChartGraphicDataContext* pChartGraphicDataContext = dynamic_cast<ChartGraphicDataContext*>(mxChartShapeContext.get());
+ oox::drawingml::ShapePtr pShapePtr( pChartGraphicDataContext->getShape());
+ // See SwXTextDocument::createInstance(), ODF import uses the same hack.
+ pShapePtr->setServiceName("com.sun.star.drawing.temporaryForXMLImportOLE2Shape");
+ pShapePtr->addShape( *mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShapePtr->getFillProperties() );
+ xResult = pShapePtr->getXShape();
+ mxChartShapeContext.clear();
+ }
else if (mpShape.get() != NULL)
{
basegfx::B2DHomMatrix aTransformation;
diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx
index 2d500efbe2cc..a1e8e0297055 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> mxChartShapeContext;
core::XmlFilterRef mxFilterBase;
drawingml::ThemePtr mpThemePtr;
@@ -158,6 +159,7 @@ private:
OUString msRelationFragmentPath;
css::uno::Reference<XFastContextHandler> getGraphicShapeContext(::sal_Int32 Element);
+ css::uno::Reference<XFastContextHandler> getChartShapeContext(::sal_Int32 Element);
css::uno::Reference<XFastContextHandler> getDrawingShapeContext();
css::uno::Reference<XFastContextHandler> getDiagramShapeContext();
css::uno::Reference<XFastContextHandler> getLockedCanvasContext(sal_Int32 nElement);