diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-06-13 18:04:51 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-06-19 11:52:40 +0200 |
commit | 886e29cff76d0358889aa676dbe90765950c990e (patch) | |
tree | 0945fb0e3f2917e0a78f860ae5346bfd18e5156e /oox/inc | |
parent | 544ab2ed627e207adb54a0db9b31388e29d041a8 (diff) |
rework handling the case of recursive ooxml shapes again
Another attempt, whoever has written this apparently didn't consider
the possibility of recursion at all, and this still feels a bit hackish.
Writerfilter keeps just one oox::shape::ShapeContextHandler object during
the entire time of parsing the document, because e.g. <v:shapetype> needs
to be reachable even across VML block (see sw testcases for bnc#705956).
This however presents a problem when VML contains <w:txbxContent> which
contains another VML, as this code previously just took whatever has been
read and returned it to writerfilter, and it broke with recursion.
So now try to mark recursion entry and returns the right shape.
Related to 36c12c246d886b2d96d7a2d4d0c250db9d925c74 and the previous
commits it reverted.
Change-Id: I949a6b52ec7540aa59b047c7b6e908b10fb3bdc1
Diffstat (limited to 'oox/inc')
-rw-r--r-- | oox/inc/oox/vml/vmlshapecontainer.hxx | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/oox/inc/oox/vml/vmlshapecontainer.hxx b/oox/inc/oox/vml/vmlshapecontainer.hxx index 20671bbb05f3..f6be8e39dedd 100644 --- a/oox/inc/oox/vml/vmlshapecontainer.hxx +++ b/oox/inc/oox/vml/vmlshapecontainer.hxx @@ -32,6 +32,7 @@ #include <com/sun/star/awt/Rectangle.hpp> #include "oox/helper/refmap.hxx" #include "oox/helper/refvector.hxx" +#include <stack> namespace com { namespace sun { namespace star { namespace drawing { class XShapes; } @@ -92,16 +93,29 @@ public: template< typename Functor > const ShapeBase* findShape( const Functor& rFunctor ) const; - /** Returns the first shape in the collection (Word only). */ - const ShapeBase* getFirstShape() const; + /** + (Word only) Returns the last shape in the collection, if it is after the last + mark from pushMark(), and removes it. + */ + boost::shared_ptr< ShapeBase > takeLastShape(); + /** + Adds a recursion mark to the stack. It is possible that a shape contains <w:txbxContent> + which contains another shape, and writerfilter needs to know which shape is from the inner + ooxml context and which from the outer ooxml context, while it is necessary to keep + at least shape types across such blocks. Therefore this function marks beginning + of each shape xml block, and takeLastShape() returns only shapes from this block. + */ + void pushMark(); + /** + Removes a recursion mark. + */ + void popMark(); /** 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; @@ -113,6 +127,7 @@ private: ShapeVector maShapes; ///< All shape definitions. ShapeTypeMap maTypesById; ///< All shape templates mapped by identifier. ShapeMap maShapesById; ///< All shape definitions mapped by identifier. + std::stack< size_t > markStack; ///< Recursion marks from pushMark()/popMark(). }; // ---------------------------------------------------------------------------- |