diff options
author | Tor Lillqvist <tml@openoffice.org> | 2010-03-23 13:54:34 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@openoffice.org> | 2010-03-23 13:54:34 +0200 |
commit | d9889b7620a5cddc8b8776653540d70343bdcf59 (patch) | |
tree | 05aab0a2c65e8e43de1f1960c115556fea904785 /oox | |
parent | 47d83021c1fb1fb51cb268f7549d9d0f92531e66 (diff) |
ooxml10: oox-fix-placeholder-layout.diff from ooo-build
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/drawingml/shape.hxx | 1 | ||||
-rw-r--r-- | oox/source/ppt/pptshapecontext.cxx | 54 |
2 files changed, 44 insertions, 11 deletions
diff --git a/oox/inc/oox/drawingml/shape.hxx b/oox/inc/oox/drawingml/shape.hxx index 7dad1be76635..dccc9319a84f 100644 --- a/oox/inc/oox/drawingml/shape.hxx +++ b/oox/inc/oox/drawingml/shape.hxx @@ -126,6 +126,7 @@ public: void setSubType( sal_uInt32 nSubType ) { mnSubType = nSubType; } sal_Int32 getSubType() const { return mnSubType; } void setIndex( sal_uInt32 nIndex ) { mnIndex = nIndex; } + sal_Int32 getIndex() { return mnIndex; } // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value) void setDefaults(); diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx index 472f5292770e..d3f1be6f9f4c 100644 --- a/oox/source/ppt/pptshapecontext.cxx +++ b/oox/source/ppt/pptshapecontext.cxx @@ -83,6 +83,26 @@ oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, st return aShapePtr; } +oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes ) +{ + oox::drawingml::ShapePtr aShapePtr; + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); + while( aRevIter != rShapes.rend() ) + { + if ( (*aRevIter)->getIndex() == nIdx ) + { + aShapePtr = *aRevIter; + break; + } + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren(); + aShapePtr = findPlaceholderByIndex( nIdx, rChildren ); + if ( aShapePtr.get() ) + break; + aRevIter++; + } + return aShapePtr; +} + // if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes ) { @@ -107,14 +127,27 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In { sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) ); mpShapePtr->setSubType( nSubType ); - mpShapePtr->setIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); - if ( nSubType ) + OUString sIdx( xAttribs->getOptionalValue( XML_idx ) ); + sal_Bool bHasIdx = sIdx.getLength() > 0; + sal_Int32 nIdx = sIdx.toInt32(); + mpShapePtr->setIndex( nIdx ); + + if ( nSubType || bHasIdx ) { PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() ); if ( pPPTShapePtr ) { oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation(); - if ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) + oox::drawingml::ShapePtr pPlaceholder; + + if ( bHasIdx && eShapeLocation == Slide ) + { + // TODO: use id to shape map + SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() ); + if ( pMasterPersist.get() ) + pPlaceholder = findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() ); + } + if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) ) { // inheriting properties from placeholder objects by cloning shape @@ -152,7 +185,6 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In } if ( nFirstPlaceholder ) { - oox::drawingml::ShapePtr pPlaceholder; if ( eShapeLocation == Layout ) // for layout objects the referenced object can be found within the same shape tree pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, mpSlidePersistPtr->getShapes()->getChildren() ); else if ( eShapeLocation == Slide ) // normal slide shapes have to search within the corresponding master tree for referenced objects @@ -161,15 +193,15 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In if ( pMasterPersist.get() ) pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pMasterPersist->getShapes()->getChildren() ); } - if ( pPlaceholder.get() ) - { - mpShapePtr->applyShapeReference( *pPlaceholder.get() ); - PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() ); - if ( pPPTShape ) - pPPTShape->setReferenced( sal_True ); - } } } + if ( pPlaceholder.get() ) + { + mpShapePtr->applyShapeReference( *pPlaceholder.get() ); + PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() ); + if ( pPPTShape ) + pPPTShape->setReferenced( sal_True ); + } } } break; |