diff options
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/inc/DummyXShape.hxx | 5 | ||||
-rw-r--r-- | chart2/source/view/main/DummyXShape.cxx | 29 |
2 files changed, 26 insertions, 8 deletions
diff --git a/chart2/source/view/inc/DummyXShape.hxx b/chart2/source/view/inc/DummyXShape.hxx index 9de599dd7158..ef117abd2a3b 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 26184f8ebfef..2e208f29bf1c 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; } |