update dev300-m58
[ooovba.git] / applied_patches / 0339-oox-fix-placeholder-layout.diff
blob885635f25c4b047fb7b30f3ad4169b3a20b54a69
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)
12 void setDefaults();
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
18 return aShapePtr;
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() )
26 + {
27 + if ( (*aRevIter)->getIndex() == nIdx )
28 + {
29 + aShapePtr = *aRevIter;
30 + break;
31 + }
32 + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
33 + aShapePtr = findPlaceholderByIndex( nIdx, rChildren );
34 + if ( aShapePtr.get() )
35 + break;
36 + aRevIter++;
37 + }
38 + return aShapePtr;
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() );
49 - if ( nSubType )
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() );
58 if ( pPPTShapePtr )
60 oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation();
61 - if ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) )
62 + oox::drawingml::ShapePtr pPlaceholder;
64 + if ( bHasIdx && eShapeLocation == Slide )
65 + {
66 + // TODO: use id to shape map
67 + SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
68 + if ( pMasterPersist.get() )
69 + pPlaceholder = findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() );
70 + }
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() )
88 - {
89 - mpShapePtr->applyShapeReference( *pPlaceholder.get() );
90 - PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
91 - if ( pPPTShape )
92 - pPPTShape->setReferenced( sal_True );
93 - }
96 + if ( pPlaceholder.get() )
97 + {
98 + mpShapePtr->applyShapeReference( *pPlaceholder.get() );
99 + PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
100 + if ( pPPTShape )
101 + pPPTShape->setReferenced( sal_True );
105 break;