merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0593-oox-pptx-import-fix-placeholder-text-style.diff
blobb03fa9344f823b13852efa1713360c7a44204bb9
1 diff -rup oox-orig-1/inc/oox/ppt/pptshape.hxx oox/inc/oox/ppt/pptshape.hxx
2 --- oox-orig-1/inc/oox/ppt/pptshape.hxx 2009-05-20 12:26:31.000000000 +0200
3 +++ oox/inc/oox/ppt/pptshape.hxx 2009-05-20 12:42:49.000000000 +0200
4 @@ -66,6 +66,10 @@ public:
5 void setReferenced( sal_Bool bReferenced ){ mbReferenced = bReferenced; };
6 void setPlaceholder( oox::drawingml::ShapePtr pPlaceholder ) { mpPlaceholder = pPlaceholder; }
8 + static oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes );
9 + static oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes );
10 + static oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes );
12 protected:
14 oox::drawingml::ShapePtr mpPlaceholder;
15 diff -rup oox-orig-1/source/ppt/pptshapecontext.cxx oox/source/ppt/pptshapecontext.cxx
16 --- oox-orig-1/source/ppt/pptshapecontext.cxx 2009-05-20 12:26:32.000000000 +0200
17 +++ oox/source/ppt/pptshapecontext.cxx 2009-05-20 12:44:46.000000000 +0200
18 @@ -65,53 +65,6 @@ PPTShapeContext::PPTShapeContext( Contex
22 -static oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
24 - oox::drawingml::ShapePtr aShapePtr;
25 - std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
26 - while( aRevIter != rShapes.rend() )
27 - {
28 - if ( (*aRevIter)->getSubType() == nMasterPlaceholder )
29 - {
30 - aShapePtr = *aRevIter;
31 - break;
32 - }
33 - std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
34 - aShapePtr = findPlaceholder( nMasterPlaceholder, rChildren );
35 - if ( aShapePtr.get() )
36 - break;
37 - aRevIter++;
38 - }
39 - return aShapePtr;
42 -static oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes )
44 - oox::drawingml::ShapePtr aShapePtr;
45 - std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
46 - while( aRevIter != rShapes.rend() )
47 - {
48 - if ( (*aRevIter)->getIndex() == nIdx )
49 - {
50 - aShapePtr = *aRevIter;
51 - break;
52 - }
53 - std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
54 - aShapePtr = findPlaceholderByIndex( nIdx, rChildren );
55 - if ( aShapePtr.get() )
56 - break;
57 - aRevIter++;
58 - }
59 - return aShapePtr;
62 -// if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder
63 -static oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
65 - oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, rShapes );
66 - return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, rShapes );
69 Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
71 Reference< XFastContextHandler > xRet;
72 @@ -147,7 +100,7 @@ Reference< XFastContextHandler > PPTShap
73 // TODO: use id to shape map
74 SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
75 if ( pMasterPersist.get() )
76 - pPlaceholder = findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() );
77 + pPlaceholder = PPTShape::findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() );
79 if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) )
81 @@ -188,12 +141,12 @@ Reference< XFastContextHandler > PPTShap
82 if ( nFirstPlaceholder )
84 if ( eShapeLocation == Layout ) // for layout objects the referenced object can be found within the same shape tree
85 - pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, mpSlidePersistPtr->getShapes()->getChildren() );
86 + pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, mpSlidePersistPtr->getShapes()->getChildren() );
87 else if ( eShapeLocation == Slide ) // normal slide shapes have to search within the corresponding master tree for referenced objects
89 SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
90 if ( pMasterPersist.get() )
91 - pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pMasterPersist->getShapes()->getChildren() );
92 + pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pMasterPersist->getShapes()->getChildren() );
96 diff -rup oox-orig-1/source/ppt/pptshape.cxx oox/source/ppt/pptshape.cxx
97 --- oox-orig-1/source/ppt/pptshape.cxx 2009-05-20 12:26:32.000000000 +0200
98 +++ oox/source/ppt/pptshape.cxx 2009-05-20 14:01:11.000000000 +0200
99 @@ -163,6 +163,17 @@ void PPTShape::addShape(
103 + // use placeholder index if possible
104 + if( mnSubType && getIndex() && rSlidePersist.getMasterPersist().get() ) {
105 + oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholderByIndex( getIndex(), rSlidePersist.getMasterPersist()->getShapes()->getChildren() );
106 + if( pPlaceholder.get() && pPlaceholder->getTextBody() ) {
107 + TextListStylePtr pNewTextListStyle (new TextListStyle());
109 + pNewTextListStyle->apply( pPlaceholder->getTextBody()->getTextListStyle() );
110 + aMasterTextListStyle = pNewTextListStyle;
114 // use style from master slide for placeholders only, otherwise use slide's style, which might be the default style from presentation
115 if ( !aMasterTextListStyle.get() )
116 aMasterTextListStyle = ( mnSubType && rSlidePersist.getMasterPersist().get() ) ? rSlidePersist.getMasterPersist()->getOtherTextStyle() : rSlidePersist.getOtherTextStyle();
117 @@ -203,4 +214,51 @@ void PPTShape::applyShapeReference( cons
118 Shape::applyShapeReference( rReferencedShape );
121 +oox::drawingml::ShapePtr PPTShape::findPlaceholder( const sal_Int32 nMasterPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
123 + oox::drawingml::ShapePtr aShapePtr;
124 + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
125 + while( aRevIter != rShapes.rend() )
127 + if ( (*aRevIter)->getSubType() == nMasterPlaceholder )
129 + aShapePtr = *aRevIter;
130 + break;
132 + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
133 + aShapePtr = findPlaceholder( nMasterPlaceholder, rChildren );
134 + if ( aShapePtr.get() )
135 + break;
136 + aRevIter++;
138 + return aShapePtr;
141 +oox::drawingml::ShapePtr PPTShape::findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes )
143 + oox::drawingml::ShapePtr aShapePtr;
144 + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
145 + while( aRevIter != rShapes.rend() )
147 + if ( (*aRevIter)->getIndex() == nIdx )
149 + aShapePtr = *aRevIter;
150 + break;
152 + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
153 + aShapePtr = findPlaceholderByIndex( nIdx, rChildren );
154 + if ( aShapePtr.get() )
155 + break;
156 + aRevIter++;
158 + return aShapePtr;
161 +// if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder
162 +oox::drawingml::ShapePtr PPTShape::findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
164 + oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, rShapes );
165 + return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, rShapes );