Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "oox/ppt/timenode.hxx"
21 : : #include "oox/ppt/pptshape.hxx"
22 : : #include "oox/ppt/slidepersist.hxx"
23 : : #include "oox/drawingml/fillproperties.hxx"
24 : : #include "oox/drawingml/shapepropertymap.hxx"
25 : : #include "oox/helper/propertyset.hxx"
26 : : #include "oox/vml/vmldrawing.hxx"
27 : : #include "oox/core/xmlfilterbase.hxx"
28 : :
29 : : #include <com/sun/star/style/XStyle.hpp>
30 : : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
31 : : #include <com/sun/star/container/XNamed.hpp>
32 : : #include <com/sun/star/beans/XMultiPropertySet.hpp>
33 : : #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
34 : :
35 : : using namespace ::com::sun::star;
36 : : using namespace ::oox::core;
37 : : using namespace ::com::sun::star::uno;
38 : : using namespace ::com::sun::star::drawing;
39 : : using namespace ::com::sun::star::container;
40 : : using namespace ::com::sun::star::animations;
41 : :
42 : : namespace oox { namespace ppt {
43 : :
44 : 24 : SlidePersist::SlidePersist( XmlFilterBase& rFilter, sal_Bool bMaster, sal_Bool bNotes,
45 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxPage,
46 : : oox::drawingml::ShapePtr pShapesPtr, const drawingml::TextListStylePtr & pDefaultTextStyle )
47 [ + - ]: 24 : : mpDrawingPtr( new oox::vml::Drawing( rFilter, rxPage, oox::vml::VMLDRAWING_POWERPOINT ) )
48 : : , mxPage( rxPage )
49 : : , maShapesPtr( pShapesPtr )
50 : : , mnLayoutValueToken( 0 )
51 : : , mbMaster( bMaster )
52 : : , mbNotes ( bNotes )
53 : : , maDefaultTextStylePtr( pDefaultTextStyle )
54 [ + - ]: 24 : , maTitleTextStylePtr( new oox::drawingml::TextListStyle )
55 [ + - ]: 24 : , maBodyTextStylePtr( new oox::drawingml::TextListStyle )
56 [ + - ]: 24 : , maNotesTextStylePtr( new oox::drawingml::TextListStyle )
57 [ + - ][ + - ]: 120 : , maOtherTextStylePtr( new oox::drawingml::TextListStyle )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
58 : : {
59 : 24 : if ( pDefaultTextStyle )
60 : : {
61 : : /*
62 : : maTitleTextStylePtr->apply( *pDefaultTextStyle.get() );
63 : : maBodyTextStylePtr->apply( *pDefaultTextStyle.get() );
64 : : maNotesTextStylePtr->apply( *pDefaultTextStyle.get() );
65 : : maOtherTextStylePtr->apply( *pDefaultTextStyle.get() );
66 : : */
67 : : }
68 : : #if OSL_DEBUG_LEVEL > 0
69 : : mxDebugPage = mxPage;
70 : : #endif
71 : 24 : }
72 : :
73 : : #if OSL_DEBUG_LEVEL > 0
74 : : ::com::sun::star::uno::WeakReference< ::com::sun::star::drawing::XDrawPage > SlidePersist::mxDebugPage;
75 : : #endif
76 : :
77 [ + - ][ + - ]: 24 : SlidePersist::~SlidePersist()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
78 : : {
79 : 24 : }
80 : :
81 : 9 : sal_Int16 SlidePersist::getLayoutFromValueToken()
82 : : {
83 : 9 : sal_Int16 nLayout = 20; // 20 == blanc (so many magic numbers :-( the description at com.sun.star.presentation.DrawPage.Layout does not help)
84 [ - - - - : 9 : switch( mnLayoutValueToken )
- - - - -
- + - - -
- + - - -
- - - - -
- + ]
85 : : {
86 : 0 : case XML_blank: nLayout = 20; break;
87 : 0 : case XML_chart: nLayout = 2; break;
88 : 0 : case XML_chartAndTx: nLayout = 7; break;
89 : 0 : case XML_clipArtAndTx: nLayout = 9; break;
90 : 0 : case XML_clipArtAndVertTx: nLayout = 24; break;
91 : 0 : case XML_fourObj: nLayout = 18; break;
92 : 0 : case XML_obj: nLayout = 11; break;
93 : 0 : case XML_objAndTx: nLayout = 13; break;
94 : 0 : case XML_objOverTx: nLayout = 14; break;
95 : 0 : case XML_tbl: nLayout = 8; break;
96 : 3 : case XML_title: nLayout = 0; break;
97 : 0 : case XML_titleOnly: nLayout = 19; break;
98 : : case XML_twoObj:
99 : 0 : case XML_twoColTx: nLayout = 3; break;
100 : 0 : case XML_twoObjAndTx: nLayout = 15; break;
101 : 0 : case XML_twoObjOverTx: nLayout = 16; break;
102 : 3 : case XML_tx: nLayout = 1; break;
103 : 0 : case XML_txAndChart: nLayout = 4; break;
104 : 0 : case XML_txAndClipArt: nLayout = 6; break;
105 : 0 : case XML_txAndMedia: nLayout = 6; break;
106 : 0 : case XML_txAndObj: nLayout = 10; break;
107 : 0 : case XML_txAndTwoObj: nLayout = 12; break;
108 : 0 : case XML_txOverObj: nLayout = 17; break;
109 : 0 : case XML_vertTitleAndTx: nLayout = 22; break;
110 : 0 : case XML_vertTitleAndTxOverChart: nLayout = 21; break;
111 : 0 : case XML_vertTx: nLayout = 23; break;
112 : :
113 : : case XML_twoTxTwoObj:
114 : : case XML_twoObjAndObj:
115 : : case XML_objTx:
116 : : case XML_picTx:
117 : : case XML_secHead:
118 : : case XML_objOnly:
119 : : case XML_objAndTwoObj:
120 : : case XML_mediaAndTx:
121 : : case XML_dgm:
122 : : case XML_cust:
123 : : default:
124 : 3 : nLayout = 20;
125 : : }
126 : 9 : return nLayout;
127 : : }
128 : :
129 : 21 : void SlidePersist::createXShapes( XmlFilterBase& rFilterBase )
130 : : {
131 [ + - ]: 21 : applyTextStyles( rFilterBase );
132 : :
133 [ + - ][ + - ]: 21 : Reference< XShapes > xShapes( getPage(), UNO_QUERY );
134 : :
135 : 21 : std::vector< oox::drawingml::ShapePtr >& rShapes( maShapesPtr->getChildren() );
136 : 21 : std::vector< oox::drawingml::ShapePtr >::iterator aShapesIter( rShapes.begin() );
137 [ + - ][ + + ]: 51 : while( aShapesIter != rShapes.end() )
138 : : {
139 [ + - ]: 30 : std::vector< oox::drawingml::ShapePtr >& rChildren( (*aShapesIter++)->getChildren() );
140 : 30 : std::vector< oox::drawingml::ShapePtr >::iterator aChildIter( rChildren.begin() );
141 [ + - ][ + + ]: 138 : while( aChildIter != rChildren.end() )
142 : : {
143 [ - + ]: 108 : PPTShape* pPPTShape = dynamic_cast< PPTShape* >( (*aChildIter).get() );
144 [ + - ]: 108 : basegfx::B2DHomMatrix aTransformation;
145 [ + - ]: 108 : if ( pPPTShape )
146 [ + - ][ + - ]: 108 : pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, aTransformation, 0, &getShapeMap() );
[ + - ]
147 : : else
148 [ # # ][ # # ]: 0 : (*aChildIter)->addShape( rFilterBase, getTheme().get(), xShapes, aTransformation, 0, &getShapeMap() );
[ # # ]
149 [ + - ]: 108 : aChildIter++;
150 [ + - ]: 108 : }
151 : : }
152 : :
153 [ + - ][ + - ]: 21 : Reference< XAnimationNodeSupplier > xNodeSupplier( getPage(), UNO_QUERY);
154 [ + + ]: 21 : if( xNodeSupplier.is() )
155 : : {
156 [ + - ][ + - ]: 18 : Reference< XAnimationNode > xNode( xNodeSupplier->getAnimationNode() );
157 [ - + ][ # # ]: 18 : if( xNode.is() && !maTimeNodeList.empty() )
[ - + ]
158 : : {
159 [ # # ]: 0 : SlidePersistPtr pSlidePtr( shared_from_this() );
160 [ # # ][ # # ]: 0 : TimeNodePtr pNode(maTimeNodeList.front());
161 : : OSL_ENSURE( pNode, "pNode" );
162 : :
163 [ # # ][ # # ]: 0 : pNode->setNode( rFilterBase, xNode, pSlidePtr );
[ # # ]
164 : 18 : }
165 : 21 : }
166 : 21 : }
167 : :
168 : 21 : void SlidePersist::createBackground( const XmlFilterBase& rFilterBase )
169 : : {
170 [ + + ]: 21 : if ( mpBackgroundPropertiesPtr )
171 : : {
172 : 6 : sal_Int32 nPhClr = maBackgroundColor.isUsed() ?
173 [ + - ][ + - ]: 6 : maBackgroundColor.getColor( rFilterBase.getGraphicHelper() ) : API_RGB_TRANSPARENT;
[ + - ]
174 : :
175 [ + - ][ + - ]: 6 : ::oox::drawingml::ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper() );
176 [ + - ][ + - ]: 6 : mpBackgroundPropertiesPtr->pushToPropMap( aPropMap, rFilterBase.getGraphicHelper(), 0, nPhClr );
177 [ + - ][ + - ]: 6 : PropertySet( mxPage ).setProperty( PROP_Background, aPropMap.makePropertySet() );
[ + - ][ + - ]
178 : : }
179 : 21 : }
180 : :
181 : 144 : void setTextStyle( Reference< beans::XPropertySet >& rxPropSet, const XmlFilterBase& rFilter,
182 : : oox::drawingml::TextListStylePtr& pTextListStylePtr, int nLevel )
183 : : {
184 [ + - ]: 144 : ::oox::drawingml::TextParagraphPropertiesPtr pTextParagraphPropertiesPtr( pTextListStylePtr->getListStyle()[ nLevel ] );
185 [ - + ]: 144 : if( pTextParagraphPropertiesPtr == NULL )
186 : : {
187 : : // no properties. return
188 : 144 : return;
189 : : }
190 : :
191 : 144 : PropertyMap& rTextParagraphPropertyMap( pTextParagraphPropertiesPtr->getTextParagraphPropertyMap() );
192 : :
193 [ + - ]: 144 : PropertySet aPropSet( rxPropSet );
194 [ + - ]: 144 : aPropSet.setProperties( rTextParagraphPropertyMap );
195 [ + - ][ + - ]: 144 : pTextParagraphPropertiesPtr->getTextCharacterProperties().pushToPropSet( aPropSet, rFilter );
[ + - ][ + - ]
196 : : }
197 : :
198 : 21 : void SlidePersist::applyTextStyles( const XmlFilterBase& rFilterBase )
199 : : {
200 [ + + ]: 21 : if ( mbMaster )
201 : : {
202 : : try
203 : : {
204 [ + - ][ + - ]: 9 : Reference< style::XStyleFamiliesSupplier > aXStyleFamiliesSupplier( rFilterBase.getModel(), UNO_QUERY_THROW );
205 [ + - ][ + - ]: 9 : Reference< container::XNameAccess > aXNameAccess( aXStyleFamiliesSupplier->getStyleFamilies() );
206 [ + - ]: 9 : Reference< container::XNamed > aXNamed( mxPage, UNO_QUERY_THROW );
207 : :
208 [ + - ][ + - ]: 9 : if ( aXNameAccess.is() && aXNamed.is() )
[ + - ]
209 : : {
210 [ + - ]: 9 : oox::drawingml::TextListStylePtr pTextListStylePtr;
211 : 9 : rtl::OUString aStyle;
212 : 9 : rtl::OUString aFamily;
213 : :
214 [ + - ]: 9 : const rtl::OUString sOutline( RTL_CONSTASCII_USTRINGPARAM( "outline1" ) );
215 [ + - ]: 9 : const rtl::OUString sTitle( RTL_CONSTASCII_USTRINGPARAM( "title" ) );
216 [ + - ]: 9 : const rtl::OUString sStandard( RTL_CONSTASCII_USTRINGPARAM( "standard" ) );
217 [ + - ]: 9 : const rtl::OUString sSubtitle( RTL_CONSTASCII_USTRINGPARAM( "subtitle" ) );
218 : :
219 [ + + ]: 45 : for( int i = 0; i < 4; i++ ) // todo: aggregation of bodystyle (subtitle)
220 : : {
221 [ + + + - : 36 : switch( i )
- + ]
222 : : {
223 : : case 0 : // title style
224 : : {
225 [ + - ]: 9 : pTextListStylePtr = maTitleTextStylePtr;
226 : 9 : aStyle = sTitle;
227 [ + - ][ + - ]: 9 : aFamily= aXNamed->getName();
228 : 9 : break;
229 : : }
230 : : case 1 : // body style
231 : : {
232 [ + - ]: 9 : pTextListStylePtr = maBodyTextStylePtr;
233 : 9 : aStyle = sOutline;
234 [ + - ][ + - ]: 9 : aFamily= aXNamed->getName();
235 : 9 : break;
236 : : }
237 : : case 3 : // notes style
238 : : {
239 [ + - ]: 9 : pTextListStylePtr = maNotesTextStylePtr;
240 : 9 : aStyle = sTitle;
241 [ + - ][ + - ]: 9 : aFamily= aXNamed->getName();
242 : 9 : break;
243 : : }
244 : : case 4 : // standard style
245 : : {
246 [ # # ]: 0 : pTextListStylePtr = maOtherTextStylePtr;
247 : 0 : aStyle = sStandard;
248 [ # # ]: 0 : aFamily = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) );
249 : 0 : break;
250 : : }
251 : : case 5 : // subtitle
252 : : {
253 [ # # ]: 0 : pTextListStylePtr = maBodyTextStylePtr;
254 : 0 : aStyle = sSubtitle;
255 [ # # ][ # # ]: 0 : aFamily = aXNamed->getName();
256 : 0 : break;
257 : : }
258 : : }
259 : 36 : Reference< container::XNameAccess > xFamilies;
260 [ + - ][ + - ]: 36 : if ( aXNameAccess->hasByName( aFamily ) )
[ + - ]
261 : : {
262 [ + - ][ + - ]: 36 : if( aXNameAccess->getByName( aFamily ) >>= xFamilies )
[ + - ][ + - ]
263 : : {
264 [ + - ][ + - ]: 36 : if ( xFamilies->hasByName( aStyle ) )
[ + - ]
265 : : {
266 : 36 : Reference< style::XStyle > aXStyle;
267 [ + - ][ + - ]: 36 : if ( xFamilies->getByName( aStyle ) >>= aXStyle )
[ + - ][ + - ]
268 : : {
269 [ + - ]: 36 : Reference< beans::XPropertySet > xPropSet( aXStyle, UNO_QUERY_THROW );
270 [ + - ]: 36 : setTextStyle( xPropSet, rFilterBase, maDefaultTextStylePtr, 0 );
271 [ + - ]: 36 : setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, 0 );
272 [ + + ]: 36 : if ( i == 1 /* BodyStyle */ )
273 : : {
274 [ + + ]: 45 : for ( int nLevel = 1; nLevel < 5; nLevel++ )
275 : : {
276 : : {
277 : 36 : sal_Char pOutline[ 9 ] = "outline1";
278 : 36 : pOutline[ 7 ] = static_cast< sal_Char >( '0' + nLevel );
279 : 36 : rtl::OUString sOutlineStyle( rtl::OUString::createFromAscii( pOutline ) );
280 [ + - ][ + - ]: 36 : if ( xFamilies->hasByName( sOutlineStyle ) )
[ + - ]
281 : : {
282 [ + - ][ + - ]: 36 : xFamilies->getByName( sOutlineStyle ) >>= aXStyle;
[ + - ]
283 [ + - ]: 36 : if( aXStyle.is() )
284 [ + - ][ + - ]: 36 : xPropSet = Reference< beans::XPropertySet >( aXStyle, UNO_QUERY_THROW );
285 : 36 : }
286 : : }
287 [ + - ]: 36 : setTextStyle( xPropSet, rFilterBase, maDefaultTextStylePtr, nLevel );
288 [ + - ]: 36 : setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, nLevel );
289 : : }
290 : 36 : }
291 : 36 : }
292 : : }
293 : : }
294 : : }
295 [ + - ]: 45 : }
296 [ # # ]: 9 : }
297 : : }
298 : 0 : catch( const Exception& )
299 : : {
300 : : }
301 : : }
302 : 21 : }
303 : :
304 : 0 : void SlidePersist::hideShapesAsMasterShapes()
305 : : {
306 : 0 : std::vector< oox::drawingml::ShapePtr >& rShapes( maShapesPtr->getChildren() );
307 : 0 : std::vector< oox::drawingml::ShapePtr >::iterator aShapesIter( rShapes.begin() );
308 [ # # ][ # # ]: 0 : while( aShapesIter != rShapes.end() )
309 : : {
310 [ # # ][ # # ]: 0 : while( aShapesIter != rShapes.end() )
311 : : {
312 [ # # ]: 0 : std::vector< oox::drawingml::ShapePtr >& rChildren( (*aShapesIter++)->getChildren() );
313 : 0 : std::vector< oox::drawingml::ShapePtr >::iterator aChildIter( rChildren.begin() );
314 [ # # ][ # # ]: 0 : while( aChildIter != rChildren.end() ) {
315 [ # # ][ # # ]: 0 : PPTShape* pPPTShape = dynamic_cast< PPTShape* >( (*aChildIter++).get() );
316 : : OSL_TRACE("hide shape with id: %s", rtl::OUStringToOString(pPPTShape->getId(), RTL_TEXTENCODING_UTF8 ).getStr());
317 : 0 : pPPTShape->setHiddenMasterShape( true );
318 : : }
319 : : }
320 : : }
321 : 0 : }
322 : :
323 [ + - ][ + - ]: 285 : } }
324 : :
325 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|