1 diff --git oox/inc/oox/drawingml/shape.hxx oox/inc/oox/drawingml/shape.hxx
2 index 5a7e7e5..5405d9d 100644
3 --- oox/inc/oox/drawingml/shape.hxx
4 +++ oox/inc/oox/drawingml/shape.hxx
5 @@ -112,6 +112,7 @@ public:
6 void setSubType( sal_uInt32 nSubType ) { mnSubType = nSubType; }
7 sal_Int32 getSubType() const { return mnSubType; }
8 void setIndex( sal_uInt32 nIndex ) { mnIndex = nIndex; }
9 + sal_Int32 getIndex() { return mnIndex; }
11 // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value)
13 diff --git oox/source/ppt/pptshapecontext.cxx oox/source/ppt/pptshapecontext.cxx
14 index f87d03d..5acf932 100644
15 --- oox/source/ppt/pptshapecontext.cxx
16 +++ oox/source/ppt/pptshapecontext.cxx
17 @@ -85,6 +85,26 @@ oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, st
21 +oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes )
23 + oox::drawingml::ShapePtr aShapePtr;
24 + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
25 + while( aRevIter != rShapes.rend() )
27 + if ( (*aRevIter)->getIndex() == nIdx )
29 + aShapePtr = *aRevIter;
32 + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
33 + aShapePtr = findPlaceholderByIndex( nIdx, rChildren );
34 + if ( aShapePtr.get() )
41 // if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder
42 oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
44 @@ -109,14 +129,27 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In
46 sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) );
47 mpShapePtr->setSubType( nSubType );
48 - mpShapePtr->setIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() );
50 + OUString sIdx( xAttribs->getOptionalValue( XML_idx ) );
51 + sal_Bool bHasIdx = sIdx.getLength() > 0;
52 + sal_Int32 nIdx = sIdx.toInt32();
53 + mpShapePtr->setIndex( nIdx );
55 + if ( nSubType || bHasIdx )
57 PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() );
60 oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation();
61 - if ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) )
62 + oox::drawingml::ShapePtr pPlaceholder;
64 + if ( bHasIdx && eShapeLocation == Slide )
66 + // TODO: use id to shape map
67 + SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
68 + if ( pMasterPersist.get() )
69 + pPlaceholder = findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() );
71 + if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) )
73 // inheriting properties from placeholder objects by cloning shape
75 @@ -154,7 +187,6 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In
77 if ( nFirstPlaceholder )
79 - oox::drawingml::ShapePtr pPlaceholder;
80 if ( eShapeLocation == Layout ) // for layout objects the referenced object can be found within the same shape tree
81 pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, mpSlidePersistPtr->getShapes()->getChildren() );
82 else if ( eShapeLocation == Slide ) // normal slide shapes have to search within the corresponding master tree for referenced objects
83 @@ -163,15 +195,15 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In
84 if ( pMasterPersist.get() )
85 pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pMasterPersist->getShapes()->getChildren() );
87 - if ( pPlaceholder.get() )
89 - mpShapePtr->applyShapeReference( *pPlaceholder.get() );
90 - PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
92 - pPPTShape->setReferenced( sal_True );
96 + if ( pPlaceholder.get() )
98 + mpShapePtr->applyShapeReference( *pPlaceholder.get() );
99 + PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
101 + pPPTShape->setReferenced( sal_True );