[Libreoffice-commits] core.git: Branch 'private/moggi/abstract-chart-rendering' - chart2/source

Markus Mohrhard markus.mohrhard at googlemail.com
Tue Oct 15 08:07:12 PDT 2013


 chart2/source/view/inc/DummyXShape.hxx  |    5 ++++-
 chart2/source/view/main/DummyXShape.cxx |   29 ++++++++++++++++++++++-------
 2 files changed, 26 insertions(+), 8 deletions(-)

New commits:
commit f79bd63e3de597d07b64894b9124d773c1e10590
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Oct 15 17:06:31 2013 +0200

    make it possible to avoid XShape/XShapes in the backend
    
    Change-Id: I9aa4b71d12bb6720e2197dc1de6f06c61f27d6ee

diff --git a/chart2/source/view/inc/DummyXShape.hxx b/chart2/source/view/inc/DummyXShape.hxx
index 9de599d..ef117ab 100644
--- a/chart2/source/view/inc/DummyXShape.hxx
+++ b/chart2/source/view/inc/DummyXShape.hxx
@@ -46,6 +46,7 @@ class DummyXShape : public cppu::WeakImplHelper6<
                     com::sun::star::lang::XServiceInfo >
 {
 public:
+    DummyXShape();
 
     // XNamed
     virtual OUString SAL_CALL getName(  ) throw(::com::sun::star::uno::RuntimeException);
@@ -105,6 +106,7 @@ private:
     com::sun::star::awt::Size maSize;
 
     com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxParent;
+    DummyXShape* mpParent;
 
 };
 
@@ -141,7 +143,8 @@ public:
     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
 
 private:
-    std::vector<com::sun::star::uno::Reference< com::sun::star::drawing::XShape > > maShapes;
+    std::vector<com::sun::star::uno::Reference< com::sun::star::drawing::XShape > > maUNOShapes;
+    std::vector<DummyXShape*> maShapes;
 };
 
 }
diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 26184f8..2e208f2 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -18,6 +18,11 @@ namespace chart {
 
 namespace dummy {
 
+DummyXShape::DummyXShape():
+    mpParent(NULL)
+{
+}
+
 OUString DummyXShape::getName()
     throw(uno::RuntimeException)
 {
@@ -217,15 +222,25 @@ void DummyXShapes::release()
 void DummyXShapes::add( const uno::Reference< drawing::XShape>& xShape )
     throw(uno::RuntimeException)
 {
-    maShapes.push_back(xShape);
+    DummyXShape* pChild = dynamic_cast<DummyXShape*>(xShape.get());
+    assert(pChild);
+    maUNOShapes.push_back(xShape);
+    pChild->setParent(static_cast< ::cppu::OWeakObject* >( this ));
+    maShapes.push_back(pChild);
 }
 
 void DummyXShapes::remove( const uno::Reference< drawing::XShape>& xShape )
     throw(uno::RuntimeException)
 {
-    std::vector< uno::Reference<drawing::XShape> >::iterator itr = std::find(maShapes.begin(), maShapes.end(), xShape);
-    if(itr != maShapes.end())
-        maShapes.erase(itr);
+    std::vector< uno::Reference<drawing::XShape> >::iterator itr = std::find(maUNOShapes.begin(), maUNOShapes.end(), xShape);
+
+    DummyXShape* pChild = dynamic_cast<DummyXShape*>((*itr).get());
+    std::vector< DummyXShape* >::iterator itrShape = std::find(maShapes.begin(), maShapes.end(), pChild);
+    if(itrShape != maShapes.end())
+        maShapes.erase(itrShape);
+
+    if(itr != maUNOShapes.end())
+        maUNOShapes.erase(itr);
 }
 
 uno::Type DummyXShapes::getElementType()
@@ -237,13 +252,13 @@ uno::Type DummyXShapes::getElementType()
 sal_Bool DummyXShapes::hasElements()
     throw(uno::RuntimeException)
 {
-    return !maShapes.empty();
+    return !maUNOShapes.empty();
 }
 
 sal_Int32 DummyXShapes::getCount()
     throw(uno::RuntimeException)
 {
-    return maShapes.size();
+    return maUNOShapes.size();
 }
 
 uno::Any DummyXShapes::getByIndex(sal_Int32 nIndex)
@@ -251,7 +266,7 @@ uno::Any DummyXShapes::getByIndex(sal_Int32 nIndex)
             uno::RuntimeException)
 {
     uno::Any aShape;
-    aShape <<= maShapes[nIndex];
+    aShape <<= maUNOShapes[nIndex];
     return aShape;
 }
 


More information about the Libreoffice-commits mailing list