Kaydet (Commit) cf74b7fb authored tarafından Markus Mohrhard's avatar Markus Mohrhard

make it possible to avoid XShape/XShapes in the backend

Change-Id: I9aa4b71d12bb6720e2197dc1de6f06c61f27d6ee
üst d821f5aa
...@@ -46,6 +46,7 @@ class DummyXShape : public cppu::WeakImplHelper6< ...@@ -46,6 +46,7 @@ class DummyXShape : public cppu::WeakImplHelper6<
com::sun::star::lang::XServiceInfo > com::sun::star::lang::XServiceInfo >
{ {
public: public:
DummyXShape();
// XNamed // XNamed
virtual OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException); virtual OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException);
...@@ -105,6 +106,7 @@ private: ...@@ -105,6 +106,7 @@ private:
com::sun::star::awt::Size maSize; com::sun::star::awt::Size maSize;
com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxParent; com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxParent;
DummyXShape* mpParent;
}; };
...@@ -141,7 +143,8 @@ public: ...@@ -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); 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: 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;
}; };
} }
......
...@@ -18,6 +18,11 @@ namespace chart { ...@@ -18,6 +18,11 @@ namespace chart {
namespace dummy { namespace dummy {
DummyXShape::DummyXShape():
mpParent(NULL)
{
}
OUString DummyXShape::getName() OUString DummyXShape::getName()
throw(uno::RuntimeException) throw(uno::RuntimeException)
{ {
...@@ -217,15 +222,25 @@ void DummyXShapes::release() ...@@ -217,15 +222,25 @@ void DummyXShapes::release()
void DummyXShapes::add( const uno::Reference< drawing::XShape>& xShape ) void DummyXShapes::add( const uno::Reference< drawing::XShape>& xShape )
throw(uno::RuntimeException) 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 ) void DummyXShapes::remove( const uno::Reference< drawing::XShape>& xShape )
throw(uno::RuntimeException) throw(uno::RuntimeException)
{ {
std::vector< uno::Reference<drawing::XShape> >::iterator itr = std::find(maShapes.begin(), maShapes.end(), xShape); std::vector< uno::Reference<drawing::XShape> >::iterator itr = std::find(maUNOShapes.begin(), maUNOShapes.end(), xShape);
if(itr != maShapes.end())
maShapes.erase(itr); 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() uno::Type DummyXShapes::getElementType()
...@@ -237,13 +252,13 @@ uno::Type DummyXShapes::getElementType() ...@@ -237,13 +252,13 @@ uno::Type DummyXShapes::getElementType()
sal_Bool DummyXShapes::hasElements() sal_Bool DummyXShapes::hasElements()
throw(uno::RuntimeException) throw(uno::RuntimeException)
{ {
return !maShapes.empty(); return !maUNOShapes.empty();
} }
sal_Int32 DummyXShapes::getCount() sal_Int32 DummyXShapes::getCount()
throw(uno::RuntimeException) throw(uno::RuntimeException)
{ {
return maShapes.size(); return maUNOShapes.size();
} }
uno::Any DummyXShapes::getByIndex(sal_Int32 nIndex) uno::Any DummyXShapes::getByIndex(sal_Int32 nIndex)
...@@ -251,7 +266,7 @@ uno::Any DummyXShapes::getByIndex(sal_Int32 nIndex) ...@@ -251,7 +266,7 @@ uno::Any DummyXShapes::getByIndex(sal_Int32 nIndex)
uno::RuntimeException) uno::RuntimeException)
{ {
uno::Any aShape; uno::Any aShape;
aShape <<= maShapes[nIndex]; aShape <<= maUNOShapes[nIndex];
return aShape; return aShape;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment