From 798aef37ac80ceaeeed75adebb53992bdf57bb0d Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 12 Jun 2012 17:11:10 +0200 Subject: Revert "rework getting shape for the .docx import filter" Stupid containers with shared_ptr. Trying to remove the object from it gets it deleted because it's owned by the shared_ptr and there's no sensible way to wrestle it out of it. This will need to be redone somehow. This reverts commit 04d600d4be7c50db4b3b505039eb8bc96856f593. --- oox/inc/oox/vml/vmlshapecontainer.hxx | 6 ++++-- oox/source/shape/ShapeContextHandler.cxx | 5 ++++- oox/source/vml/vmlshapecontainer.cxx | 11 ++++------- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'oox') diff --git a/oox/inc/oox/vml/vmlshapecontainer.hxx b/oox/inc/oox/vml/vmlshapecontainer.hxx index 9b11c6ca5a0b..288062566a00 100644 --- a/oox/inc/oox/vml/vmlshapecontainer.hxx +++ b/oox/inc/oox/vml/vmlshapecontainer.hxx @@ -92,14 +92,16 @@ public: template< typename Functor > const ShapeBase* findShape( const Functor& rFunctor ) const; - /** Returns and removes the last shape in the collection (Word only). */ - const ShapeBase* takeLastShape(); + /** Returns the first shape in the collection (Word only). */ + const ShapeBase* getFirstShape() const; /** Creates and inserts all UNO shapes into the passed container. */ void convertAndInsert( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, const ShapeParentAnchor* pParentAnchor = 0 ) const; + inline void clearShapes( ) { maShapes.clear( ); } + private: typedef RefVector< ShapeType > ShapeTypeVector; typedef RefVector< ShapeBase > ShapeVector; diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index 241ae868ca2b..04e2330ca14d 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -280,8 +280,11 @@ ShapeContextHandler::getShape() throw (uno::RuntimeException) if ( getContextHandler() == getDrawingShapeContext() ) { mpDrawing->finalizeFragmentImport(); - if( const ::oox::vml::ShapeBase* pShape = mpDrawing->getShapes().takeLastShape() ) + if( const ::oox::vml::ShapeBase* pShape = mpDrawing->getShapes().getFirstShape() ) + { xResult = pShape->convertAndInsert( xShapes ); + mpDrawing->getShapes( ).clearShapes( ); + } } else if (mxDiagramShapeContext.is()) { diff --git a/oox/source/vml/vmlshapecontainer.cxx b/oox/source/vml/vmlshapecontainer.cxx index 144aa78f7c28..0309839a9817 100644 --- a/oox/source/vml/vmlshapecontainer.cxx +++ b/oox/source/vml/vmlshapecontainer.cxx @@ -118,14 +118,11 @@ const ShapeBase* ShapeContainer::getShapeById( const OUString& rShapeId, bool bD return 0; } -const ShapeBase* ShapeContainer::takeLastShape() +const ShapeBase* ShapeContainer::getFirstShape() const { - assert( mrDrawing.getType() == VMLDRAWING_WORD ); - if( maShapes.empty()) - return NULL; - const ShapeBase* ret = maShapes.back().get(); - maShapes.pop_back(); - return ret; + OSL_ENSURE( mrDrawing.getType() == VMLDRAWING_WORD, "ShapeContainer::getFirstShape - illegal call, Word filter only" ); + OSL_ENSURE( maShapes.size() == 1, "ShapeContainer::getFirstShape - single shape expected" ); + return maShapes.get( 0 ).get(); } void ShapeContainer::convertAndInsert( const Reference< XShapes >& rxShapes, const ShapeParentAnchor* pParentAnchor ) const -- cgit