1 Ugliest fix ever - copy'n'pastes all the code
3 From: Thorsten Behrens <thb@openoffice.org>
8 oox/inc/oox/ppt/pptgraphicshapecontext.hxx | 49 ++++++
9 oox/source/ppt/makefile.mk | 1
10 oox/source/ppt/pptgraphicshapecontext.cxx | 238 ++++++++++++++++++++++++++++
11 oox/source/ppt/pptshapecontext.cxx | 6 -
12 oox/source/ppt/pptshapegroupcontext.cxx | 3
13 5 files changed, 293 insertions(+), 4 deletions(-)
14 create mode 100644 oox/inc/oox/ppt/pptgraphicshapecontext.hxx
15 create mode 100644 oox/source/ppt/pptgraphicshapecontext.cxx
18 diff --git oox/inc/oox/ppt/pptgraphicshapecontext.hxx oox/inc/oox/ppt/pptgraphicshapecontext.hxx
20 index 0000000..12dad26
22 +++ oox/inc/oox/ppt/pptgraphicshapecontext.hxx
24 +/*************************************************************************
26 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28 + * Copyright 2008 by Sun Microsystems, Inc.
30 + * OpenOffice.org - a multi-platform office productivity suite
32 + * $RCSfile: pptshapecontext.hxx,v $
35 + * This file is part of OpenOffice.org.
37 + * OpenOffice.org is free software: you can redistribute it and/or modify
38 + * it under the terms of the GNU Lesser General Public License version 3
39 + * only, as published by the Free Software Foundation.
41 + * OpenOffice.org is distributed in the hope that it will be useful,
42 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
43 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44 + * GNU Lesser General Public License version 3 for more details
45 + * (a copy is included in the LICENSE file that accompanied this code).
47 + * You should have received a copy of the GNU Lesser General Public License
48 + * version 3 along with OpenOffice.org. If not, see
49 + * <http://www.openoffice.org/license.html>
50 + * for a copy of the LGPLv3 License.
52 + ************************************************************************/
54 +#ifndef OOX_PPT_PPTGRAPHICSHAPECONTEXT_HXX
55 +#define OOX_PPT_PPTGRAPHICSHAPECONTEXT_HXX
57 +#include "oox/drawingml/graphicshapecontext.hxx"
59 +namespace oox { namespace ppt {
61 +class PPTGraphicShapeContext : public ::oox::drawingml::GraphicShapeContext
63 + SlidePersistPtr mpSlidePersistPtr;
66 + PPTGraphicShapeContext( ::oox::core::ContextHandler& rParent, const SlidePersistPtr pSlidePersistPtr, oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pShapePtr );
67 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
72 +#endif // OOX_PPT_PPTGRAPHICSHAPEGROUPCONTEXT_HXX
73 diff --git oox/source/ppt/makefile.mk oox/source/ppt/makefile.mk
74 index 1dfc87c..4deca6a 100644
75 --- oox/source/ppt/makefile.mk
76 +++ oox/source/ppt/makefile.mk
77 @@ -56,6 +56,7 @@ SLOFILES = \
78 $(SLO)$/customshowlistcontext.obj \
79 $(SLO)$/layoutfragmenthandler.obj\
80 $(SLO)$/pptfilterhelpers.obj\
81 + $(SLO)$/pptgraphicshapecontext.obj \
82 $(SLO)$/pptimport.obj\
83 $(SLO)$/pptshape.obj \
84 $(SLO)$/pptshapecontext.obj \
85 diff --git oox/source/ppt/pptgraphicshapecontext.cxx oox/source/ppt/pptgraphicshapecontext.cxx
87 index 0000000..97e104c
89 +++ oox/source/ppt/pptgraphicshapecontext.cxx
91 +/*************************************************************************
93 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
95 + * Copyright 2008 by Sun Microsystems, Inc.
97 + * OpenOffice.org - a multi-platform office productivity suite
99 + * $RCSfile: pptshapecontext.cxx,v $
102 + * This file is part of OpenOffice.org.
104 + * OpenOffice.org is free software: you can redistribute it and/or modify
105 + * it under the terms of the GNU Lesser General Public License version 3
106 + * only, as published by the Free Software Foundation.
108 + * OpenOffice.org is distributed in the hope that it will be useful,
109 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
110 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
111 + * GNU Lesser General Public License version 3 for more details
112 + * (a copy is included in the LICENSE file that accompanied this code).
114 + * You should have received a copy of the GNU Lesser General Public License
115 + * version 3 along with OpenOffice.org. If not, see
116 + * <http://www.openoffice.org/license.html>
117 + * for a copy of the LGPLv3 License.
119 + ************************************************************************/
121 +#include <com/sun/star/xml/sax/FastToken.hpp>
122 +#include <com/sun/star/drawing/LineStyle.hpp>
123 +#include <com/sun/star/beans/XMultiPropertySet.hpp>
124 +#include <com/sun/star/lang/XMultiServiceFactory.hpp>
125 +#include <com/sun/star/container/XNamed.hpp>
127 +#include "oox/ppt/pptshape.hxx"
128 +#include "oox/ppt/pptgraphicshapecontext.hxx"
129 +#include "oox/ppt/pptshapepropertiescontext.hxx"
130 +#include "oox/ppt/slidepersist.hxx"
131 +#include "oox/drawingml/shapestylecontext.hxx"
132 +#include "oox/core/namespaces.hxx"
133 +#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
134 +#include "oox/drawingml/lineproperties.hxx"
135 +#include "oox/drawingml/drawingmltypes.hxx"
136 +#include "oox/drawingml/customshapegeometry.hxx"
137 +#include "oox/drawingml/textbodycontext.hxx"
138 +#include "tokens.hxx"
140 +using rtl::OUString;
141 +using namespace oox::core;
142 +using namespace ::com::sun::star;
143 +using namespace ::com::sun::star::uno;
144 +using namespace ::com::sun::star::drawing;
145 +using namespace ::com::sun::star::beans;
146 +using namespace ::com::sun::star::text;
147 +using namespace ::com::sun::star::xml::sax;
149 +namespace oox { namespace ppt {
152 +PPTGraphicShapeContext::PPTGraphicShapeContext( ContextHandler& rParent, const SlidePersistPtr pSlidePersistPtr, oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pShapePtr )
153 +: oox::drawingml::GraphicShapeContext( rParent, pMasterShapePtr, pShapePtr )
154 +, mpSlidePersistPtr( pSlidePersistPtr )
158 +static oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
160 + oox::drawingml::ShapePtr aShapePtr;
161 + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
162 + while( aRevIter != rShapes.rend() )
164 + if ( (*aRevIter)->getSubType() == nMasterPlaceholder )
166 + aShapePtr = *aRevIter;
169 + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
170 + aShapePtr = findPlaceholder( nMasterPlaceholder, rChildren );
171 + if ( aShapePtr.get() )
178 +static oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes )
180 + oox::drawingml::ShapePtr aShapePtr;
181 + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
182 + while( aRevIter != rShapes.rend() )
184 + if ( (*aRevIter)->getIndex() == nIdx )
186 + aShapePtr = *aRevIter;
189 + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren();
190 + aShapePtr = findPlaceholderByIndex( nIdx, rChildren );
191 + if ( aShapePtr.get() )
198 +// if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder
199 +static oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
201 + oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, rShapes );
202 + return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, rShapes );
205 +Reference< XFastContextHandler > PPTGraphicShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
207 + Reference< XFastContextHandler > xRet;
209 + switch( aElementToken )
211 + // nvSpPr CT_ShapeNonVisual begin
212 +// case NMSP_PPT|XML_drElemPr:
214 + case NMSP_PPT|XML_cNvPr:
215 + mpShapePtr->setId( xAttribs->getOptionalValue( XML_id ) );
216 + mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) );
218 + case NMSP_PPT|XML_ph:
220 + sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) );
221 + mpShapePtr->setSubType( nSubType );
222 + OUString sIdx( xAttribs->getOptionalValue( XML_idx ) );
223 + sal_Bool bHasIdx = sIdx.getLength() > 0;
224 + sal_Int32 nIdx = sIdx.toInt32();
225 + mpShapePtr->setIndex( nIdx );
227 + if ( nSubType || bHasIdx )
229 + PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() );
230 + if ( pPPTShapePtr )
232 + oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation();
233 + oox::drawingml::ShapePtr pPlaceholder;
235 + if ( bHasIdx && eShapeLocation == Slide )
237 + // TODO: use id to shape map
238 + SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
239 + if ( pMasterPersist.get() )
240 + pPlaceholder = findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() );
242 + if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) )
244 + // inheriting properties from placeholder objects by cloning shape
246 + sal_Int32 nFirstPlaceholder = 0;
247 + sal_Int32 nSecondPlaceholder = 0;
250 + case XML_ctrTitle : // slide/layout
251 + nFirstPlaceholder = XML_ctrTitle;
252 + nSecondPlaceholder = XML_title;
254 + case XML_subTitle : // slide/layout
255 + nFirstPlaceholder = XML_subTitle;
256 + nSecondPlaceholder = XML_title;
258 + case XML_obj : // slide/layout
259 + nFirstPlaceholder = XML_body;
261 + case XML_dt : // slide/layout/master/notes/notesmaster/handoutmaster
262 + case XML_sldNum : // slide/layout/master/notes/notesmaster/handoutmaster
263 + case XML_ftr : // slide/layout/master/notes/notesmaster/handoutmaster
264 + case XML_hdr : // notes/notesmaster/handoutmaster
265 + case XML_body : // slide/layout/master/notes/notesmaster
266 + case XML_title : // slide/layout/master/
267 + case XML_chart : // slide/layout
268 + case XML_tbl : // slide/layout
269 + case XML_clipArt : // slide/layout
270 + case XML_dgm : // slide/layout
271 + case XML_media : // slide/layout
272 + case XML_sldImg : // notes/notesmaster
273 + case XML_pic : // slide/layout
274 + nFirstPlaceholder = nSubType;
278 + if ( nFirstPlaceholder )
280 + if ( eShapeLocation == Layout ) // for layout objects the referenced object can be found within the same shape tree
281 + pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, mpSlidePersistPtr->getShapes()->getChildren() );
282 + else if ( eShapeLocation == Slide ) // normal slide shapes have to search within the corresponding master tree for referenced objects
284 + SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
285 + if ( pMasterPersist.get() )
286 + pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pMasterPersist->getShapes()->getChildren() );
290 + if ( pPlaceholder.get() )
292 + mpShapePtr->applyShapeReference( *pPlaceholder.get() );
293 + PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
295 + pPPTShape->setReferenced( sal_True );
296 + pPPTShapePtr->setPlaceholder( pPlaceholder );
302 + // nvSpPr CT_ShapeNonVisual end
304 + case NMSP_PPT|XML_spPr:
305 + xRet = new PPTShapePropertiesContext( *this, *mpShapePtr );
308 + case NMSP_PPT|XML_style:
309 + xRet = new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr );
312 + case NMSP_PPT|XML_txBody:
314 + oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody );
315 + mpShapePtr->setTextBody( xTextBody );
316 + xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody );
322 + xRet.set( GraphicShapeContext::createFastChildContext( aElementToken, xAttribs ) );
329 diff --git oox/source/ppt/pptshapecontext.cxx oox/source/ppt/pptshapecontext.cxx
330 index 762f758..80546ff 100644
331 --- oox/source/ppt/pptshapecontext.cxx
332 +++ oox/source/ppt/pptshapecontext.cxx
333 @@ -65,7 +65,7 @@ PPTShapeContext::PPTShapeContext( ContextHandler& rParent, const SlidePersistPtr
337 -oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
338 +static oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
340 oox::drawingml::ShapePtr aShapePtr;
341 std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
342 @@ -85,7 +85,7 @@ oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, st
346 -oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes )
347 +static oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes )
349 oox::drawingml::ShapePtr aShapePtr;
350 std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() );
351 @@ -106,7 +106,7 @@ oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, std::vect
354 // if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder
355 -oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
356 +static oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
358 oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, rShapes );
359 return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, rShapes );
360 diff --git oox/source/ppt/pptshapegroupcontext.cxx oox/source/ppt/pptshapegroupcontext.cxx
361 index fd0f312..a77f90b 100644
362 --- oox/source/ppt/pptshapegroupcontext.cxx
363 +++ oox/source/ppt/pptshapegroupcontext.cxx
365 #include <com/sun/star/container/XNamed.hpp>
367 #include "oox/ppt/pptshape.hxx"
368 +#include "oox/ppt/pptgraphicshapecontext.hxx"
369 #include "oox/ppt/pptshapecontext.hxx"
370 #include "oox/ppt/pptshapegroupcontext.hxx"
371 #include "oox/drawingml/graphicshapecontext.hxx"
372 @@ -104,7 +105,7 @@ Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( s
373 xRet.set( new PPTShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.CustomShape" ) ) ) );
375 case NMSP_PPT|XML_pic: // CT_Picture
376 - xRet.set( new oox::drawingml::GraphicShapeContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) ) );
377 + xRet.set( new PPTGraphicShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) ) );
379 case NMSP_PPT|XML_graphicFrame: // CT_GraphicalObjectFrame
380 xRet.set( new oox::drawingml::GraphicalObjectFrameContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.OLE2Shape" ) ) ) );