[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - oox/Library_oox.mk oox/source

Miklos Vajna vmiklos at suse.cz
Sat Jun 22 21:19:15 PDT 2013


 oox/Library_oox.mk                       |    1 
 oox/source/shape/LockedCanvasContext.cxx |   66 +++++++++++++++++++++++++++++++
 oox/source/shape/LockedCanvasContext.hxx |   40 ++++++++++++++++++
 oox/source/shape/ShapeContextHandler.cxx |   37 ++++++++++++++++-
 oox/source/shape/ShapeContextHandler.hxx |    2 
 5 files changed, 145 insertions(+), 1 deletion(-)

New commits:
commit 85b05fac54b1b9ed87f5603001a4885a14f3a5ab
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Jun 20 10:37:46 2013 +0200

    fdo#43641 oox: initial import of lc:lockedCanvas
    
    If that canvas contains a single shape, the result looks OK. If it
    contains a groupshape, we also import something, but then the position /
    size is still to be improved.
    
    Change-Id: Ic4e4c08016a05a5e3acb005c3a642981ba4fb16d
    (cherry picked from commit a9966b272151fa66c4a7c74bcb2505ef2ea94a6e)
    Reviewed-on: https://gerrit.libreoffice.org/4422
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 3d8743f..45f4b9c 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -266,6 +266,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
     oox/source/ppt/timenodelistcontext \
     oox/source/ppt/timetargetelementcontext \
     oox/source/ppt/extdrawingfragmenthandler \
+    oox/source/shape/LockedCanvasContext \
     oox/source/shape/ShapeContextHandler \
     oox/source/shape/ShapeDrawingFragmentHandler \
     oox/source/shape/ShapeFilterBase \
diff --git a/oox/source/shape/LockedCanvasContext.cxx b/oox/source/shape/LockedCanvasContext.cxx
new file mode 100644
index 0000000..9a7e9c0
--- /dev/null
+++ b/oox/source/shape/LockedCanvasContext.cxx
@@ -0,0 +1,66 @@
+/* -*- 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 "LockedCanvasContext.hxx"
+#include <oox/drawingml/shapegroupcontext.hxx>
+
+using namespace com::sun::star;
+
+namespace oox { namespace shape {
+
+LockedCanvasContext::LockedCanvasContext( ContextHandler& rParent )
+: ContextHandler( rParent )
+{
+}
+
+LockedCanvasContext::~LockedCanvasContext()
+{
+}
+
+oox::drawingml::ShapePtr LockedCanvasContext::getShape()
+{
+    return mpShape;
+}
+
+uno::Reference< xml::sax::XFastContextHandler > LockedCanvasContext::createFastChildContext( sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttribs*/ ) throw (xml::sax::SAXException, uno::RuntimeException)
+{
+    uno::Reference< xml::sax::XFastContextHandler > xRet;
+
+    switch( getBaseToken( aElementToken ) )
+    {
+    case XML_lockedCanvas:
+        break;
+    case XML_nvGrpSpPr:
+        break;
+    case XML_grpSpPr:
+        break;
+    case XML_sp:
+        {
+            oox::drawingml::ShapePtr pMasterShape;
+            mpShape.reset(new oox::drawingml::Shape("com.sun.star.drawing.CustomShape"));
+            xRet = new oox::drawingml::ShapeContext( *this, pMasterShape, mpShape );
+        }
+        break;
+    case XML_grpSp:
+        {
+            oox::drawingml::ShapePtr pMasterShape;
+            mpShape.reset(new oox::drawingml::Shape("com.sun.star.drawing.GroupShape"));
+            xRet = new oox::drawingml::ShapeGroupContext( *this, pMasterShape, mpShape );
+        }
+        break;
+    default:
+        SAL_WARN("oox", "LockedCanvasContext::createFastChildContext: unhandled element:" << getBaseToken(aElementToken));
+        break;
+    }
+    return xRet;
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/shape/LockedCanvasContext.hxx b/oox/source/shape/LockedCanvasContext.hxx
new file mode 100644
index 0000000..c93d49d
--- /dev/null
+++ b/oox/source/shape/LockedCanvasContext.hxx
@@ -0,0 +1,40 @@
+/* -*- 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 OOX_SHAPE_LOCKEDCANVASCONTEXT
+#define OOX_SHAPE_LOCKEDCANVASCONTEXT
+
+#include "oox/core/contexthandler.hxx"
+#include "oox/drawingml/shape.hxx"
+
+namespace oox { namespace shape {
+
+/// Locked canvas is kind of a container for drawingml shapes: it can even contain group shapes.
+class LockedCanvasContext : public oox::core::ContextHandler
+{
+public:
+    LockedCanvasContext( oox::core::ContextHandler& rParent );
+    virtual ~LockedCanvasContext();
+
+    virtual com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 Element, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException);
+
+    oox::drawingml::ShapePtr getShape();
+
+protected:
+
+    oox::drawingml::ShapePtr mpShape;
+};
+
+
+} }
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index 9c8da2d..5c1f990 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -21,6 +21,7 @@
 
 #include "ShapeContextHandler.hxx"
 #include "ShapeDrawingFragmentHandler.hxx"
+#include "LockedCanvasContext.hxx"
 #include "oox/vml/vmldrawingfragment.hxx"
 #include "oox/vml/vmlshape.hxx"
 #include "oox/drawingml/themefragmenthandler.hxx"
@@ -69,6 +70,26 @@ ShapeContextHandler::~ShapeContextHandler()
 {
 }
 
+uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getLockedCanvasContext(sal_Int32 nElement)
+{
+    if (!mxLockedCanvasContext.is())
+    {
+        FragmentHandlerRef rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
+        ShapePtr pMasterShape;
+
+        switch (nElement & 0xffff)
+        {
+            case XML_lockedCanvas:
+                mxLockedCanvasContext.set(new LockedCanvasContext(*rFragmentHandler));
+                break;
+            default:
+                break;
+        }
+    }
+
+    return mxLockedCanvasContext;
+}
+
 uno::Reference<xml::sax::XFastContextHandler>
 ShapeContextHandler::getGraphicShapeContext(::sal_Int32 Element )
 {
@@ -140,6 +161,9 @@ ShapeContextHandler::getContextHandler()
         case NMSP_dmlDiagram:
             xResult.set(getDiagramShapeContext());
             break;
+        case NMSP_dmlLockedCanvas:
+            xResult.set(getLockedCanvasContext(mnStartToken));
+            break;
         default:
             xResult.set(getGraphicShapeContext(mnStartToken));
             break;
@@ -164,7 +188,7 @@ void SAL_CALL ShapeContextHandler::startFastElement
 
     mpThemePtr.reset(new Theme());
 
-    if (Element == DGM_TOKEN(relIds))
+    if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas))
     {
         // Parse the theme relation, if available; the diagram won't have colors without it.
         if (!msRelationFragmentPath.isEmpty())
@@ -309,6 +333,17 @@ ShapeContextHandler::getShape() throw (uno::RuntimeException)
             }
             mxDiagramShapeContext.clear();
         }
+        else if (mxLockedCanvasContext.is())
+        {
+            ShapePtr pShape = dynamic_cast<LockedCanvasContext*>(mxLockedCanvasContext.get())->getShape();
+            if (pShape)
+            {
+                basegfx::B2DHomMatrix aMatrix;
+                pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
+                xResult = pShape->getXShape();
+                mxLockedCanvasContext.clear();
+            }
+        }
         else if (mpShape.get() != NULL)
         {
             basegfx::B2DHomMatrix aTransformation;
diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx
index f8cdcb7..c704606 100644
--- a/oox/source/shape/ShapeContextHandler.hxx
+++ b/oox/source/shape/ShapeContextHandler.hxx
@@ -149,6 +149,7 @@ private:
     css::uno::Reference<XFastContextHandler> mxDrawingFragmentHandler;
     css::uno::Reference<XFastContextHandler> mxGraphicShapeContext;
     css::uno::Reference<XFastContextHandler> mxDiagramShapeContext;
+    css::uno::Reference<XFastContextHandler> mxLockedCanvasContext;
 
     core::XmlFilterRef mxFilterBase;
     drawingml::ThemePtr mpThemePtr;
@@ -159,6 +160,7 @@ private:
     css::uno::Reference<XFastContextHandler> getGraphicShapeContext(::sal_Int32 Element);
     css::uno::Reference<XFastContextHandler> getDrawingShapeContext();
     css::uno::Reference<XFastContextHandler> getDiagramShapeContext();
+    css::uno::Reference<XFastContextHandler> getLockedCanvasContext(sal_Int32 nElement);
     css::uno::Reference<XFastContextHandler> getContextHandler();
 };
 


More information about the Libreoffice-commits mailing list