diff options
author | Muthu Subramanian <sumuthu@suse.com> | 2012-04-26 19:19:03 +0530 |
---|---|---|
committer | Muthu Subramanian <sumuthu@suse.com> | 2012-04-26 19:21:09 +0530 |
commit | eb5f2df4d6f6c215429130b4c27d076f6777e5da (patch) | |
tree | 9f2d6b8bf4553d8603ddba12b987f8a535db1cd9 /oox/source | |
parent | a3b8ddf3b7519b9112fdc7ba05b44209113be47b (diff) |
n758565: Wrong master slide shape being used.
* Changed <ph> idx to OptValue.
* Duplicate code removal.
Diffstat (limited to 'oox/source')
-rw-r--r-- | oox/source/drawingml/shape.cxx | 3 | ||||
-rw-r--r-- | oox/source/ppt/pptgraphicshapecontext.cxx | 48 | ||||
-rw-r--r-- | oox/source/ppt/pptshape.cxx | 13 | ||||
-rw-r--r-- | oox/source/ppt/pptshapecontext.cxx | 23 |
4 files changed, 25 insertions, 62 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index ad5dd59b04b4..0019195b14d9 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -84,7 +84,6 @@ Shape::Shape( const sal_Char* pServiceName ) , mpCustomShapePropertiesPtr( new CustomShapeProperties ) , mpMasterTextListStyle( new TextListStyle ) , mnSubType( 0 ) -, mnSubTypeIndex( -1 ) , meFrameType( FRAMETYPE_GENERIC ) , mnRotation( 0 ) , mbFlipH( false ) @@ -114,7 +113,7 @@ Shape::Shape( const ShapePtr& pSourceShape ) , msName( pSourceShape->msName ) , msId( pSourceShape->msId ) , mnSubType( pSourceShape->mnSubType ) -, mnSubTypeIndex( pSourceShape->mnSubTypeIndex ) +, moSubTypeIndex( pSourceShape->moSubTypeIndex ) , maShapeStyleRefs( pSourceShape->maShapeStyleRefs ) , maSize( pSourceShape->maSize ) , maPosition( pSourceShape->maPosition ) diff --git a/oox/source/ppt/pptgraphicshapecontext.cxx b/oox/source/ppt/pptgraphicshapecontext.cxx index 11a9a27f8f13..70fa5dd5ab20 100644 --- a/oox/source/ppt/pptgraphicshapecontext.cxx +++ b/oox/source/ppt/pptgraphicshapecontext.cxx @@ -63,51 +63,11 @@ PPTGraphicShapeContext::PPTGraphicShapeContext( ContextHandler& rParent, const S { } -static oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, 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)->getSubType() == nMasterPlaceholder ) - { - aShapePtr = *aRevIter; - break; - } - std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren(); - aShapePtr = findPlaceholder( nMasterPlaceholder, rChildren ); - if ( aShapePtr.get() ) - break; - ++aRevIter; - } - return aShapePtr; -} - -static 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)->getSubTypeIndex() == 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 static oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes ) { - oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, rShapes ); - return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, rShapes ); + oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, rShapes ); + return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : PPTShape::findPlaceholder( nSecondPlaceholder, rShapes ); } Reference< XFastContextHandler > PPTGraphicShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) @@ -145,8 +105,8 @@ Reference< XFastContextHandler > PPTGraphicShapeContext::createFastChildContext( { // TODO: use id to shape map SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() ); - if ( pMasterPersist.get() ) - pPlaceholder = findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() ); + if ( pMasterPersist.get() && xAttribs->hasAttribute( XML_idx ) ) + pPlaceholder = PPTShape::findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() ); } if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) ) { diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 2b017f064f1d..2e2f4f47cbd9 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -262,10 +262,10 @@ void PPTShape::addShape( OSL_TRACE("shape service: %s", rtl::OUStringToOString(sServiceName, RTL_TEXTENCODING_UTF8 ).getStr()); // use placeholder index if possible - if( mnSubType && getSubTypeIndex() && getSubTypeIndex() != -1 && rSlidePersist.getMasterPersist().get() ) { - oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholderByIndex( getSubTypeIndex(), rSlidePersist.getMasterPersist()->getShapes()->getChildren() ); + if( mnSubType && getSubTypeIndex().has() && rSlidePersist.getMasterPersist().get() ) { + oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholderByIndex( getSubTypeIndex().get(), rSlidePersist.getMasterPersist()->getShapes()->getChildren() ); if( pPlaceholder.get()) { - OSL_TRACE("found placeholder with index: %d and type: %s", getSubTypeIndex(), lclDebugSubType( mnSubType )); + OSL_TRACE("found placeholder with index: %d and type: %s", getSubTypeIndex().get(), lclDebugSubType( mnSubType )); } if( pPlaceholder.get() ) { PPTShape* pPPTPlaceholder = dynamic_cast< PPTShape* >( pPlaceholder.get() ); @@ -290,7 +290,7 @@ void PPTShape::addShape( OSL_TRACE("placeholder has parent placeholder: %s type: %s index: %d", rtl::OUStringToOString( pPPTPlaceholder->mpPlaceholder->getId(), RTL_TEXTENCODING_UTF8 ).getStr(), lclDebugSubType( pPPTPlaceholder->mpPlaceholder->getSubType() ), - pPPTPlaceholder->mpPlaceholder->getSubTypeIndex() ); + pPPTPlaceholder->mpPlaceholder->getSubTypeIndex().get() ); OSL_TRACE("has textbody %d", pPPTPlaceholder->mpPlaceholder->getTextBody() != NULL ); TextListStylePtr pPlaceholderStyle = getSubTypeTextListStyle( rSlidePersist, pPPTPlaceholder->mpPlaceholder->getSubType() ); if( pPPTPlaceholder->mpPlaceholder->getTextBody() ) @@ -403,13 +403,10 @@ oox::drawingml::ShapePtr PPTShape::findPlaceholderByIndex( const sal_Int32 nIdx, { oox::drawingml::ShapePtr aShapePtr; - if( nIdx == -1) - return aShapePtr; - std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); while( aRevIter != rShapes.rend() ) { - if ( (*aRevIter)->getSubTypeIndex() == nIdx ) + if ( (*aRevIter)->getSubTypeIndex().has() && (*aRevIter)->getSubTypeIndex().get() == nIdx ) { aShapePtr = *aRevIter; break; diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx index cc62b822f6c0..0333f5ab2e1f 100644 --- a/oox/source/ppt/pptshapecontext.cxx +++ b/oox/source/ppt/pptshapecontext.cxx @@ -62,35 +62,40 @@ PPTShapeContext::PPTShapeContext( ContextHandler& rParent, const SlidePersistPtr { } -oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, sal_Int32 nSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes ) +oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, const OptValue< sal_Int32 >& oSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes ) { oox::drawingml::ShapePtr aShapePtr; + oox::drawingml::ShapePtr aTmpShapePtr; std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); while( aRevIter != rShapes.rend() ) { if ( (*aRevIter)->getSubType() == nMasterPlaceholder ) { - if ( ( nSubTypeIndex == -1 ) || ( nSubTypeIndex == (*aRevIter)->getSubTypeIndex() ) ) + if( !oSubTypeIndex.has() && aTmpShapePtr == NULL ) + aTmpShapePtr = *aRevIter; + if( (*aRevIter)->getSubTypeIndex() == oSubTypeIndex ) { aShapePtr = *aRevIter; break; } } std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren(); - aShapePtr = findPlaceholder( nMasterPlaceholder, nSubTypeIndex, rChildren ); + aShapePtr = findPlaceholder( nMasterPlaceholder, oSubTypeIndex, rChildren ); if ( aShapePtr.get() ) break; ++aRevIter; } + if( aShapePtr == NULL ) + return aTmpShapePtr; return aShapePtr; } // if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, - sal_Int32 nSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes ) + const OptValue< sal_Int32 >& oSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes ) { - oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, nSubTypeIndex, rShapes ); - return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, nSubTypeIndex, rShapes ); + oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, oSubTypeIndex, rShapes ); + return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, oSubTypeIndex, rShapes ); } Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) @@ -168,7 +173,8 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In oox::drawingml::ShapePtr pPlaceholder; if ( eShapeLocation == Layout ) // for layout objects the referenced object can be found within the same shape tree { - pPlaceholder = PPTShape::findPlaceholderByIndex( pPPTShapePtr->getSubTypeIndex(), mpSlidePersistPtr->getShapes()->getChildren() ); + if( pPPTShapePtr->getSubTypeIndex().has() ) + pPlaceholder = PPTShape::findPlaceholderByIndex( pPPTShapePtr->getSubTypeIndex().get(), mpSlidePersistPtr->getShapes()->getChildren() ); if ( !pPlaceholder.get() ) pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pPPTShapePtr->getSubTypeIndex(), mpSlidePersistPtr->getShapes()->getChildren() ); @@ -177,7 +183,8 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In { SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() ); if ( pMasterPersist.get() ) { - pPlaceholder = PPTShape::findPlaceholderByIndex( pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() ); + if( pPPTShapePtr->getSubTypeIndex().has() ) + pPlaceholder = PPTShape::findPlaceholderByIndex( pPPTShapePtr->getSubTypeIndex().get(), pMasterPersist->getShapes()->getChildren() ); if ( !pPlaceholder.get() ) pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() ); |