summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2013-09-17 18:54:21 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-09-20 10:06:05 +0200
commit13e8e9e2fe32bc77058b5869c39948b683fb81ec (patch)
tree9489788b389b3d76761ad194e214bcaf7b797f96 /oox
parente0abdc0c2a4e7ff938c720a8967a6b55e9f1a2fd (diff)
fdo#40594 Fix for chart missing issue in Writer (for docx)
1. Enabled parsing of chart in writer module. 2. While parsing chart is read as ole2shape. Then converted into TextEmbedded object for chart. 3. While exporting postponed chart writing after rpr tag. 4. Generated unique id for each chart. 5. Corrected content type of chart in export. Change-Id: I6a1ca0c34e03e17cc3dd8a183580132ea7af5c48 Reviewed-on: https://gerrit.libreoffice.org/5976 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'oox')
-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);