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/source/ppt/pptshapecontext.cxx | |
parent | 47d83021c1fb1fb51cb268f7549d9d0f92531e66 (diff) |
ooxml10: oox-fix-placeholder-layout.diff from ooo-build
Diffstat (limited to 'oox/source/ppt/pptshapecontext.cxx')
-rw-r--r-- | oox/source/ppt/pptshapecontext.cxx | 54 |
1 files changed, 43 insertions, 11 deletions
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; |