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 "eppt.hxx"
21 : #include "epptdef.hxx"
22 :
23 : #include <tools/globname.hxx>
24 : #include <tools/datetime.hxx>
25 : #include <tools/poly.hxx>
26 : #include <tools/stream.hxx>
27 : #include <vcl/graph.hxx>
28 : #include <vcl/bmpacc.hxx>
29 : #include <vcl/gradient.hxx>
30 : #include <vcl/virdev.hxx>
31 : #include <rtl/ustring.hxx>
32 : #include <rtl/strbuf.hxx>
33 : #include <vcl/fltcall.hxx>
34 : #include <vcl/wmf.hxx>
35 : #include <sfx2/docfile.hxx>
36 : #include <sfx2/docinf.hxx>
37 : #include <svx/unoapi.hxx>
38 : #include <svx/svdobj.hxx>
39 : #include <svx/svdoole2.hxx>
40 : #include <svx/svdmodel.hxx>
41 : #include <svx/svdpage.hxx>
42 : #include <com/sun/star/view/PaperOrientation.hpp>
43 : #include <com/sun/star/view/PaperFormat.hpp>
44 : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
45 : #include <com/sun/star/office/XAnnotation.hpp>
46 : #include <com/sun/star/office/XAnnotationAccess.hpp>
47 : #include <com/sun/star/office/XAnnotationEnumeration.hpp>
48 : #include <com/sun/star/geometry/RealPoint2D.hpp>
49 : #include <com/sun/star/util/DateTime.hpp>
50 : #include <com/sun/star/animations/TransitionType.hpp>
51 : #include <com/sun/star/animations/TransitionSubType.hpp>
52 : #include <com/sun/star/awt/FontDescriptor.hpp>
53 : #include <com/sun/star/awt/FontFamily.hpp>
54 : #include <com/sun/star/awt/FontPitch.hpp>
55 : #include <com/sun/star/container/XNamed.hpp>
56 : #include <com/sun/star/container/XNameAccess.hpp>
57 : #include <com/sun/star/presentation/XPresentationPage.hpp>
58 : #include <com/sun/star/text/XSimpleText.hpp>
59 : #include <com/sun/star/style/XStyle.hpp>
60 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
61 : #include <editeng/svxenum.hxx>
62 : #include <editeng/flditem.hxx>
63 : #include <sot/storinfo.hxx>
64 : #include <filter/msfilter/msoleexp.hxx>
65 : #include <filter/msfilter/msdffimp.hxx>
66 : #include <filter/msfilter/svxmsbas.hxx>
67 :
68 : #ifdef DEBUG
69 : #define DBG(x) x
70 : #include <stdio.h>
71 : #else
72 : #define DBG(x)
73 : #endif
74 :
75 : using namespace com::sun::star;
76 :
77 : using namespace ::com::sun::star::animations;
78 : using namespace ::com::sun::star::awt::FontFamily;
79 : using namespace ::com::sun::star::awt::FontPitch;
80 : using namespace ::com::sun::star::presentation;
81 :
82 : using ::com::sun::star::awt::FontDescriptor;
83 : using ::com::sun::star::beans::XPropertySet;
84 : using ::com::sun::star::container::XNameAccess;
85 : using ::com::sun::star::container::XNamed;
86 : using ::com::sun::star::drawing::XDrawPagesSupplier;
87 : using ::com::sun::star::drawing::XMasterPagesSupplier;
88 : using ::com::sun::star::drawing::XShapes;
89 : using ::com::sun::star::drawing::XMasterPageTarget;
90 : using ::com::sun::star::drawing::XDrawPage;
91 : using ::com::sun::star::frame::XModel;
92 : using ::com::sun::star::style::XStyleFamiliesSupplier;
93 : using ::com::sun::star::style::XStyle;
94 : using ::com::sun::star::task::XStatusIndicator;
95 : using ::com::sun::star::text::XSimpleText;
96 : using ::com::sun::star::uno::Any;
97 : using ::com::sun::star::uno::Exception;
98 : using ::com::sun::star::uno::Reference;
99 : using ::com::sun::star::uno::UNO_QUERY;
100 :
101 : static PHLayout pPHLayout[] =
102 : {
103 : { EppLayout::TITLESLIDE, { 0x0d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x10, true, true, false },
104 : { EppLayout::TITLEANDBODYSLIDE, { 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, true, false },
105 : { EppLayout::TITLEANDBODYSLIDE, { 0x0d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
106 : { EppLayout::TWOCOLUMNSANDTITLE, { 0x0d, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, true, true },
107 : { EppLayout::TWOCOLUMNSANDTITLE, { 0x0d, 0x0e, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
108 : { EppLayout::BLANCSLIDE, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, false, false, false },
109 : { EppLayout::TWOCOLUMNSANDTITLE, { 0x0d, 0x0e, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, true, true, false },
110 : { EppLayout::TWOCOLUMNSANDTITLE, { 0x0d, 0x14, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
111 : { EppLayout::TITLEANDBODYSLIDE, { 0x0d, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x15, 0x0d, 0x0e, true, false, false },
112 : { EppLayout::TWOCOLUMNSANDTITLE, { 0x0d, 0x16, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, true, true, false },
113 : { EppLayout::TWOCOLUMNSANDTITLE, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
114 : { EppLayout::TITLEANDBODYSLIDE, { 0x0d, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, false, false },
115 : { EppLayout::RIGHTCOLUMN2ROWS, { 0x0d, 0x0e, 0x13, 0x13, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
116 : { EppLayout::TWOCOLUMNSANDTITLE, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
117 : { EppLayout::TWOROWSANDTITLE, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
118 : { EppLayout::LEFTCOLUMN2ROWS, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
119 : { EppLayout::TOPROW2COLUMN, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
120 : { EppLayout::TWOROWSANDTITLE, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
121 : { EppLayout::FOUROBJECTS, { 0x0d, 0x13, 0x13, 0x13, 0x13, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, false, false },
122 : { EppLayout::ONLYTITLE, { 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, false, false },
123 : { EppLayout::BLANCSLIDE, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, false, false, false },
124 : { EppLayout::TITLERIGHT2BODIESLEFT, { 0x11, 0x12, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x11, 0x12, true, true, false },
125 : { EppLayout::TITLERIGHTBODYLEFT, { 0x11, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x11, 0x12, true, true, false },
126 : { EppLayout::TITLEANDBODYSLIDE, { 0x0d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x12, true, true, false },
127 : { EppLayout::TWOCOLUMNSANDTITLE, { 0x0d, 0x16, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x12, true, true, false }
128 : };
129 :
130 26 : PPTWriterBase::PPTWriterBase()
131 : : mXModel(0)
132 : , mXStatusIndicator(0)
133 : , mbStatusIndicator(false)
134 : , mbPresObj(false)
135 : , mbEmptyPresObj(false)
136 : , mnAngle(0)
137 : , mnPages(0)
138 : , mnMasterPages(0)
139 : , maFraction(1, 576)
140 : , maMapModeSrc(MAP_100TH_MM)
141 : , maMapModeDest(MAP_INCH, Point(), maFraction, maFraction)
142 : , meLatestPageType(NORMAL)
143 26 : , mpStyleSheet(0)
144 : {
145 : DBG(printf ("PPTWriterBase::PPTWriterBase()\n"));
146 26 : }
147 :
148 3 : PPTWriterBase::PPTWriterBase( const Reference< XModel > & rXModel,
149 : const Reference< XStatusIndicator > & rXStatInd )
150 : : mXModel(rXModel)
151 : , mXStatusIndicator(rXStatInd)
152 : , mbStatusIndicator(false)
153 : , mbPresObj(false)
154 : , mbEmptyPresObj(false)
155 : , mnAngle(0)
156 : , mnPages(0)
157 : , mnMasterPages(0)
158 : , maFraction(1, 576)
159 : , maMapModeSrc(MAP_100TH_MM)
160 : , maMapModeDest(MAP_INCH, Point(), maFraction, maFraction)
161 : , meLatestPageType (NORMAL)
162 3 : , mpStyleSheet(0)
163 : {
164 3 : }
165 :
166 58 : PPTWriterBase::~PPTWriterBase()
167 : {
168 : // Possibly unnecessary sanity check for mXStatusIndicator.is().
169 : // In 3.3 we had a bug report of a crash where it was null,
170 : // https://bugzilla.novell.com/show_bug.cgi?id=694119 (non-public,
171 : // bug report, sorry).
172 29 : if ( mbStatusIndicator && mXStatusIndicator.is() )
173 0 : mXStatusIndicator->end();
174 29 : }
175 :
176 29 : void PPTWriterBase::exportPPT( const std::vector< com::sun::star::beans::PropertyValue >& rMediaData )
177 : {
178 29 : if ( !InitSOIface() )
179 0 : return;
180 :
181 : FontCollectionEntry aDefaultFontDesc( OUString( "Times New Roman" ),
182 : ROMAN,
183 : awt::FontPitch::VARIABLE,
184 29 : RTL_TEXTENCODING_MS_1252 );
185 29 : maFontCollection.GetId( aDefaultFontDesc ); // default is always times new roman
186 :
187 29 : if ( !GetPageByIndex( 0, NOTICE ) )
188 0 : return;
189 :
190 29 : sal_Int32 nWidth = 21000;
191 29 : if ( ImplGetPropertyValue( mXPagePropSet, OUString( "Width" ) ) )
192 29 : mAny >>= nWidth;
193 29 : sal_Int32 nHeight = 29700;
194 29 : if ( ImplGetPropertyValue( mXPagePropSet, OUString( "Height" ) ) )
195 29 : mAny >>= nHeight;
196 :
197 29 : maNotesPageSize = MapSize( awt::Size( nWidth, nHeight ) );
198 :
199 29 : if ( !GetPageByIndex( 0, MASTER ) )
200 0 : return;
201 :
202 29 : nWidth = 28000;
203 29 : if ( ImplGetPropertyValue( mXPagePropSet, OUString( "Width" ) ) )
204 29 : mAny >>= nWidth;
205 29 : nHeight = 21000;
206 29 : if ( ImplGetPropertyValue( mXPagePropSet, OUString( "Height" ) ) )
207 29 : mAny >>= nHeight;
208 29 : maDestPageSize = MapSize( awt::Size( nWidth, nHeight ) );
209 29 : maPageSize = awt::Size(nWidth, nHeight);
210 :
211 : DBG(printf( "call exportDocumentPre()\n"));
212 29 : exportPPTPre(rMediaData);
213 :
214 29 : if ( !GetStyleSheets() )
215 0 : return;
216 :
217 29 : if ( !ImplCreateDocument() )
218 0 : return;
219 :
220 : sal_uInt32 i;
221 :
222 62 : for ( i = 0; i < mnPages; i++ )
223 : {
224 33 : if ( GetPageByIndex( i, NORMAL ) ) {
225 33 : sal_uInt32 nMasterNum = GetMasterIndex( NORMAL );
226 33 : ImplWriteLayout( GetLayoutOffset( mXPagePropSet ), nMasterNum );
227 : }
228 : }
229 :
230 58 : for ( i = 0; i < mnMasterPages; i++ )
231 : {
232 29 : if ( !CreateSlideMaster( i ) )
233 0 : return;
234 : }
235 29 : if ( !CreateMainNotes() )
236 0 : return;
237 :
238 62 : for ( i = 0; i < mnPages; i++ )
239 : {
240 : DBG(printf( "call ImplCreateSlide( %" SAL_PRIuUINT32 " )\n", i));
241 33 : if ( !CreateSlide( i ) )
242 0 : return;
243 : }
244 :
245 62 : for ( i = 0; i < mnPages; i++ )
246 : {
247 33 : if ( !CreateNotes( i ) )
248 0 : return;
249 : }
250 :
251 : DBG(printf( "call exportDocumentPost()\n"));
252 29 : exportPPTPost();
253 : }
254 :
255 29 : bool PPTWriterBase::InitSOIface()
256 : {
257 : while( true )
258 : {
259 29 : mXDrawPagesSupplier = Reference< XDrawPagesSupplier >( mXModel, UNO_QUERY );
260 29 : if ( !mXDrawPagesSupplier.is() )
261 0 : break;
262 :
263 29 : mXMasterPagesSupplier = Reference< XMasterPagesSupplier >( mXModel, UNO_QUERY );
264 29 : if ( !mXMasterPagesSupplier.is() )
265 0 : break;
266 29 : mXDrawPages = mXMasterPagesSupplier->getMasterPages();
267 29 : if ( !mXDrawPages.is() )
268 0 : break;
269 29 : mnMasterPages = mXDrawPages->getCount();
270 29 : mXDrawPages = mXDrawPagesSupplier->getDrawPages();
271 29 : if( !mXDrawPages.is() )
272 0 : break;
273 29 : mnPages = mXDrawPages->getCount();
274 29 : if ( !GetPageByIndex( 0, NORMAL ) )
275 0 : break;
276 :
277 29 : return true;
278 : }
279 0 : return false;
280 : }
281 :
282 342 : bool PPTWriterBase::GetPageByIndex( sal_uInt32 nIndex, PageType ePageType )
283 : {
284 : while( true )
285 : {
286 342 : if ( ePageType != meLatestPageType )
287 : {
288 241 : switch( ePageType )
289 : {
290 : case NORMAL :
291 : case NOTICE :
292 : {
293 180 : mXDrawPages = mXDrawPagesSupplier->getDrawPages();
294 180 : if( !mXDrawPages.is() )
295 342 : return false;
296 : }
297 180 : break;
298 :
299 : case MASTER :
300 : {
301 61 : mXDrawPages = mXMasterPagesSupplier->getMasterPages();
302 61 : if( !mXDrawPages.is() )
303 0 : return false;
304 : }
305 61 : break;
306 : default:
307 0 : break;
308 : }
309 241 : meLatestPageType = ePageType;
310 : }
311 342 : Any aAny( mXDrawPages->getByIndex( nIndex ) );
312 342 : aAny >>= mXDrawPage;
313 342 : if ( !mXDrawPage.is() )
314 0 : break;
315 342 : if ( ePageType == NOTICE )
316 : {
317 125 : Reference< XPresentationPage > aXPresentationPage( mXDrawPage, UNO_QUERY );
318 125 : if ( !aXPresentationPage.is() )
319 0 : break;
320 125 : mXDrawPage = aXPresentationPage->getNotesPage();
321 125 : if ( !mXDrawPage.is() )
322 0 : break;
323 : }
324 342 : mXPagePropSet = Reference< XPropertySet >( mXDrawPage, UNO_QUERY );
325 342 : if ( !mXPagePropSet.is() )
326 0 : break;
327 :
328 342 : mXShapes = Reference< XShapes >( mXDrawPage, UNO_QUERY );
329 342 : if ( !mXShapes.is() )
330 0 : break;
331 :
332 : /* try to get the "real" background PropertySet. If the normal page is not supporting this property, it is
333 : taken the property from the master */
334 342 : bool bHasBackground = GetPropertyValue( aAny, mXPagePropSet, OUString( "Background" ), true );
335 342 : if ( bHasBackground )
336 117 : bHasBackground = ( aAny >>= mXBackgroundPropSet );
337 342 : if ( !bHasBackground )
338 : {
339 225 : Reference< XMasterPageTarget > aXMasterPageTarget( mXDrawPage, UNO_QUERY );
340 225 : if ( aXMasterPageTarget.is() )
341 : {
342 225 : Reference< XDrawPage > aXMasterDrawPage;
343 225 : aXMasterDrawPage = aXMasterPageTarget->getMasterPage();
344 225 : if ( aXMasterDrawPage.is() )
345 : {
346 225 : Reference< XPropertySet > aXMasterPagePropSet;
347 450 : aXMasterPagePropSet = Reference< XPropertySet >
348 225 : ( aXMasterDrawPage, UNO_QUERY );
349 225 : if ( aXMasterPagePropSet.is() )
350 : {
351 225 : bool bBackground = GetPropertyValue( aAny, aXMasterPagePropSet, OUString( "Background" ) );
352 225 : if ( bBackground )
353 : {
354 225 : aAny >>= mXBackgroundPropSet;
355 : }
356 225 : }
357 225 : }
358 225 : }
359 : }
360 342 : return true;
361 0 : }
362 0 : return false;
363 : }
364 :
365 33 : bool PPTWriterBase::CreateSlide( sal_uInt32 nPageNum )
366 : {
367 33 : Any aAny;
368 :
369 33 : if ( !GetPageByIndex( nPageNum, NORMAL ) )
370 0 : return false;
371 :
372 33 : sal_uInt32 nMasterNum = GetMasterIndex( NORMAL );
373 33 : SetCurrentStyleSheet( nMasterNum );
374 :
375 66 : Reference< XPropertySet > aXBackgroundPropSet;
376 33 : bool bHasBackground = GetPropertyValue( aAny, mXPagePropSet, OUString( "Background" ) );
377 33 : if ( bHasBackground )
378 1 : bHasBackground = ( aAny >>= aXBackgroundPropSet );
379 :
380 33 : sal_uInt16 nMode = 7; // Bit 1: Follow master objects, Bit 2: Follow master scheme, Bit 3: Follow master background
381 33 : if ( bHasBackground )
382 1 : nMode &=~4;
383 :
384 : /* sj: Don't know what's IsBackgroundVisible for, have to ask cl
385 : if ( GetPropertyValue( aAny, mXPagePropSet, OUString( "IsBackgroundVisible" ) ) )
386 : {
387 : bool bBackgroundVisible;
388 : if ( aAny >>= bBackgroundVisible )
389 : {
390 : if ( bBackgroundVisible )
391 : nMode &= ~4;
392 : }
393 : }
394 : */
395 33 : if ( GetPropertyValue( aAny, mXPagePropSet, OUString( "IsBackgroundObjectsVisible" ) ) )
396 : {
397 33 : bool bBackgroundObjectsVisible = false;
398 33 : if ( aAny >>= bBackgroundObjectsVisible )
399 : {
400 33 : if ( !bBackgroundObjectsVisible )
401 0 : nMode &= ~1;
402 : }
403 : }
404 :
405 33 : ImplWriteSlide( nPageNum, nMasterNum, nMode, bHasBackground, aXBackgroundPropSet );
406 :
407 66 : return true;
408 : };
409 :
410 33 : bool PPTWriterBase::CreateNotes( sal_uInt32 nPageNum )
411 : {
412 33 : if ( !GetPageByIndex( nPageNum, NOTICE ) )
413 0 : return false;
414 33 : SetCurrentStyleSheet( GetMasterIndex( NORMAL ) );
415 :
416 33 : ImplWriteNotes( nPageNum );
417 :
418 33 : return true;
419 : };
420 :
421 29 : bool PPTWriterBase::CreateSlideMaster( sal_uInt32 nPageNum )
422 : {
423 29 : if ( !GetPageByIndex( nPageNum, MASTER ) )
424 0 : return false;
425 29 : SetCurrentStyleSheet( nPageNum );
426 :
427 29 : if ( !ImplGetPropertyValue( mXPagePropSet, OUString( "Background" ) ) ) // load background shape
428 0 : return false;
429 29 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXBackgroundPropSet;
430 29 : if ( !( mAny >>= aXBackgroundPropSet ) )
431 0 : return false;
432 :
433 29 : ImplWriteSlideMaster( nPageNum, aXBackgroundPropSet );
434 :
435 29 : return true;
436 : };
437 :
438 66 : sal_Int32 PPTWriterBase::GetLayoutOffset( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet )
439 : {
440 66 : ::com::sun::star::uno::Any aAny;
441 66 : sal_Int32 nLayout = 20;
442 66 : if ( GetPropertyValue( aAny, rXPropSet, OUString( "Layout" ), true ) )
443 66 : aAny >>= nLayout;
444 :
445 : DBG(printf("GetLayoutOffset %" SAL_PRIdINT32 "\n", nLayout));
446 :
447 66 : return nLayout;
448 : }
449 :
450 5 : sal_Int32 PPTWriterBase::GetLayoutOffsetFixed( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet )
451 : {
452 5 : sal_Int32 nLayout = GetLayoutOffset( rXPropSet );
453 :
454 5 : if ( ( nLayout >= 21 ) && ( nLayout <= 26 ) ) // NOTES _> HANDOUT6
455 0 : nLayout = 20;
456 5 : if ( ( nLayout >= 27 ) && ( nLayout <= 30 ) ) // VERTICAL LAYOUT
457 0 : nLayout -= 6;
458 5 : else if ( nLayout > 30 )
459 0 : nLayout = 20;
460 :
461 5 : return nLayout;
462 : }
463 :
464 5 : PHLayout& PPTWriterBase::GetLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet )
465 : {
466 5 : return pPHLayout[ GetLayoutOffsetFixed( rXPropSet ) ];
467 : }
468 :
469 11 : PHLayout& PPTWriterBase::GetLayout( sal_Int32 nOffset )
470 : {
471 11 : if( nOffset >= 0 && nOffset < EPP_LAYOUT_SIZE )
472 11 : return pPHLayout[ nOffset ];
473 :
474 : DBG(printf("asked %" SAL_PRIdINT32 " for layout outside of 0,%d array scope\n", nOffset, EPP_LAYOUT_SIZE ));
475 :
476 0 : return pPHLayout[ 0 ];
477 : }
478 :
479 104 : sal_uInt32 PPTWriterBase::GetMasterIndex( PageType ePageType )
480 : {
481 104 : sal_uInt32 nRetValue = 0;
482 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPageTarget >
483 104 : aXMasterPageTarget( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
484 :
485 104 : if ( aXMasterPageTarget.is() )
486 : {
487 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
488 104 : aXDrawPage = aXMasterPageTarget->getMasterPage();
489 104 : if ( aXDrawPage.is() )
490 : {
491 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
492 104 : aXPropertySet( aXDrawPage, ::com::sun::star::uno::UNO_QUERY );
493 :
494 104 : if ( aXPropertySet.is() )
495 : {
496 104 : if ( ImplGetPropertyValue( aXPropertySet, OUString( "Number" ) ) )
497 104 : nRetValue |= *static_cast<sal_Int16 const *>(mAny.getValue());
498 104 : if ( nRetValue & 0xffff ) // avoid overflow
499 104 : nRetValue--;
500 104 : }
501 104 : }
502 : }
503 104 : if ( ePageType == NOTICE )
504 0 : nRetValue += mnMasterPages;
505 104 : return nRetValue;
506 : }
507 :
508 158 : bool PPTWriterBase::SetCurrentStyleSheet( sal_uInt32 nPageNum )
509 : {
510 158 : bool bRet = false;
511 158 : if ( nPageNum >= maStyleSheetList.size() )
512 0 : nPageNum = 0;
513 : else
514 158 : bRet = true;
515 158 : mpStyleSheet = maStyleSheetList[ nPageNum ];
516 158 : return bRet;
517 : }
518 :
519 29 : bool PPTWriterBase::GetStyleSheets()
520 : {
521 : int nInstance, nLevel;
522 29 : bool bRetValue = false;
523 : sal_uInt32 nPageNum;
524 :
525 58 : for ( nPageNum = 0; nPageNum < mnMasterPages; nPageNum++ )
526 : {
527 : Reference< XNamed >
528 29 : aXNamed;
529 :
530 : Reference< XNameAccess >
531 58 : aXNameAccess;
532 :
533 : Reference< XStyleFamiliesSupplier >
534 58 : aXStyleFamiliesSupplier( mXModel, UNO_QUERY );
535 :
536 : Reference< XPropertySet >
537 58 : aXPropSet( mXModel, UNO_QUERY );
538 :
539 116 : sal_uInt16 nDefaultTab = ( aXPropSet.is() && ImplGetPropertyValue( aXPropSet, OUString( "TabStop" ) ) )
540 29 : ? (sal_uInt16)( *static_cast<sal_Int32 const *>(mAny.getValue()) / 4.40972 )
541 87 : : 1250;
542 :
543 29 : maStyleSheetList.push_back( new PPTExStyleSheet( nDefaultTab, dynamic_cast<PPTExBulletProvider*>(this) ) );
544 29 : SetCurrentStyleSheet( nPageNum );
545 29 : if ( GetPageByIndex( nPageNum, MASTER ) )
546 58 : aXNamed = Reference< XNamed >
547 29 : ( mXDrawPage, UNO_QUERY );
548 :
549 29 : if ( aXStyleFamiliesSupplier.is() )
550 29 : aXNameAccess = aXStyleFamiliesSupplier->getStyleFamilies();
551 :
552 29 : bRetValue = aXNamed.is() && aXNameAccess.is() && aXStyleFamiliesSupplier.is();
553 29 : if ( bRetValue )
554 : {
555 232 : for ( nInstance = EPP_TEXTTYPE_Title; nInstance <= EPP_TEXTTYPE_CenterTitle; nInstance++ )
556 : {
557 203 : OUString aStyle;
558 406 : OUString aFamily;
559 203 : switch ( nInstance )
560 : {
561 : case EPP_TEXTTYPE_CenterTitle :
562 : case EPP_TEXTTYPE_Title :
563 : {
564 58 : aStyle = "title";
565 58 : aFamily = aXNamed->getName();
566 : }
567 58 : break;
568 : case EPP_TEXTTYPE_Body :
569 : {
570 29 : aStyle = "outline1"; // SD_LT_SEPARATOR
571 29 : aFamily = aXNamed->getName();
572 : }
573 29 : break;
574 : case EPP_TEXTTYPE_Other :
575 : {
576 29 : aStyle = "standard";
577 29 : aFamily = "graphics";
578 : }
579 29 : break;
580 : case EPP_TEXTTYPE_CenterBody :
581 : {
582 29 : aStyle = "subtitle";
583 29 : aFamily = aXNamed->getName();
584 : }
585 29 : break;
586 : }
587 203 : if ( !aStyle.isEmpty() && !aFamily.isEmpty() )
588 : {
589 : try
590 : {
591 145 : Reference< XNameAccess >xNameAccess;
592 145 : if ( aXNameAccess->hasByName( aFamily ) )
593 : {
594 145 : Any aAny( aXNameAccess->getByName( aFamily ) );
595 145 : xNameAccess.set(aAny, css::uno::UNO_QUERY);
596 145 : if( xNameAccess.is() )
597 : {
598 145 : Reference< XNameAccess > aXFamily;
599 145 : if ( aAny >>= aXFamily )
600 : {
601 145 : if ( aXFamily->hasByName( aStyle ) )
602 : {
603 145 : aAny = aXFamily->getByName( aStyle );
604 : Reference< XStyle > xStyle(
605 145 : aAny, css::uno::UNO_QUERY);
606 145 : if( xStyle.is() )
607 : {
608 145 : Reference< XStyle > aXStyle;
609 145 : aAny >>= aXStyle;
610 : Reference< XPropertySet >
611 290 : xPropSet( aXStyle, UNO_QUERY );
612 145 : if( xPropSet.is() )
613 145 : mpStyleSheet->SetStyleSheet( xPropSet, maFontCollection, nInstance, 0 );
614 725 : for ( nLevel = 1; nLevel < 5; nLevel++ )
615 : {
616 580 : if ( nInstance == EPP_TEXTTYPE_Body )
617 : {
618 116 : sal_Unicode cTemp = aStyle[aStyle.getLength() - 1];
619 116 : aStyle = aStyle.copy(0, aStyle.getLength() - 1) + OUString(++cTemp);
620 116 : if ( aXFamily->hasByName( aStyle ) )
621 : {
622 116 : aXFamily->getByName( aStyle ) >>= xStyle;
623 116 : if( xStyle.is() )
624 : {
625 : Reference< XPropertySet >
626 116 : xPropertySet( xStyle, UNO_QUERY );
627 116 : if ( xPropertySet.is() )
628 116 : mpStyleSheet->SetStyleSheet( xPropertySet, maFontCollection, nInstance, nLevel );
629 : }
630 : }
631 : }
632 : else
633 464 : mpStyleSheet->SetStyleSheet( xPropSet, maFontCollection, nInstance, nLevel );
634 145 : }
635 145 : }
636 : }
637 145 : }
638 145 : }
639 145 : }
640 : }
641 0 : catch( Exception& )
642 : {
643 :
644 : }
645 : }
646 203 : }
647 29 : for ( ; nInstance <= EPP_TEXTTYPE_QuarterBody; nInstance++ )
648 : {
649 :
650 : }
651 : }
652 29 : }
653 29 : return bRetValue;
654 : }
655 :
656 29 : bool PPTWriterBase::CreateMainNotes()
657 : {
658 29 : if ( !GetPageByIndex( 0, NOTICE ) )
659 0 : return false;
660 29 : SetCurrentStyleSheet( 0 );
661 :
662 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPageTarget >
663 29 : aXMasterPageTarget( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
664 :
665 29 : if ( !aXMasterPageTarget.is() )
666 0 : return false;
667 :
668 29 : mXDrawPage = aXMasterPageTarget->getMasterPage();
669 29 : if ( !mXDrawPage.is() )
670 0 : return false;
671 :
672 58 : mXPropSet = ::com::sun::star::uno::Reference<
673 : ::com::sun::star::beans::XPropertySet >
674 29 : ( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
675 29 : if ( !mXPropSet.is() )
676 0 : return false;
677 :
678 58 : mXShapes = ::com::sun::star::uno::Reference<
679 : ::com::sun::star::drawing::XShapes >
680 29 : ( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
681 29 : if ( !mXShapes.is() )
682 0 : return false;
683 :
684 29 : return ImplCreateMainNotes();
685 : }
686 :
687 1266 : awt::Size PPTWriterBase::MapSize( const awt::Size& rSize )
688 : {
689 1266 : Size aRetSize( OutputDevice::LogicToLogic( Size( rSize.Width, rSize.Height ), maMapModeSrc, maMapModeDest ) );
690 :
691 1266 : if ( !aRetSize.Width() )
692 4 : aRetSize.Width()++;
693 1266 : if ( !aRetSize.Height() )
694 26 : aRetSize.Height()++;
695 1266 : return awt::Size( aRetSize.Width(), aRetSize.Height() );
696 : }
697 :
698 1187 : awt::Point PPTWriterBase::MapPoint( const awt::Point& rPoint )
699 : {
700 1187 : Point aRet( OutputDevice::LogicToLogic( Point( rPoint.X, rPoint.Y ), maMapModeSrc, maMapModeDest ) );
701 1187 : return awt::Point( aRet.X(), aRet.Y() );
702 : }
703 :
704 0 : Rectangle PPTWriterBase::MapRectangle( const awt::Rectangle& rRect )
705 : {
706 0 : ::com::sun::star::awt::Point aPoint( rRect.X, rRect.Y );
707 0 : ::com::sun::star::awt::Size aSize( rRect.Width, rRect.Height );
708 0 : ::com::sun::star::awt::Point aP( MapPoint( aPoint ) );
709 0 : ::com::sun::star::awt::Size aS( MapSize( aSize ) );
710 0 : return Rectangle( Point( aP.X, aP.Y ), Size( aS.Width, aS.Height ) );
711 : }
712 :
713 1187 : bool PPTWriterBase::GetShapeByIndex( sal_uInt32 nIndex, bool bGroup )
714 : {
715 : while(true)
716 : {
717 1187 : if ( !bGroup || ( GetCurrentGroupLevel() == 0 ) )
718 : {
719 1180 : Any aAny( mXShapes->getByIndex( nIndex ) );
720 1180 : aAny >>= mXShape;
721 : }
722 : else
723 : {
724 7 : Any aAny( GetCurrentGroupAccess()->getByIndex( GetCurrentGroupIndex() ) );
725 7 : aAny >>= mXShape;
726 : }
727 1187 : if ( !mXShape.is() )
728 0 : break;
729 :
730 1187 : Any aAny( mXShape->queryInterface( cppu::UnoType<XPropertySet>::get()));
731 1187 : aAny >>= mXPropSet;
732 :
733 1187 : if ( !mXPropSet.is() )
734 0 : break;
735 1187 : maPosition = MapPoint( mXShape->getPosition() );
736 1187 : maSize = MapSize( mXShape->getSize() );
737 1187 : maRect = Rectangle( Point( maPosition.X, maPosition.Y ), Size( maSize.Width, maSize.Height ) );
738 :
739 : OStringBuffer aTypeBuffer(OUStringToOString(
740 2374 : mXShape->getShapeType(), RTL_TEXTENCODING_UTF8));
741 : // remove "com.sun.star."
742 1187 : aTypeBuffer.remove(0, RTL_CONSTASCII_LENGTH("com.sun.star."));
743 :
744 1187 : sal_Int32 nPos = aTypeBuffer.toString().indexOf("Shape");
745 1187 : aTypeBuffer.remove(nPos, RTL_CONSTASCII_LENGTH("Shape"));
746 1187 : mType = aTypeBuffer.makeStringAndClear();
747 :
748 1187 : mbPresObj = mbEmptyPresObj = false;
749 1187 : if ( ImplGetPropertyValue( OUString( "IsPresentationObject" ) ) )
750 1187 : mAny >>= mbPresObj;
751 :
752 1187 : if ( mbPresObj && ImplGetPropertyValue( OUString( "IsEmptyPresentationObject" ) ) )
753 1135 : mAny >>= mbEmptyPresObj;
754 :
755 : mnAngle = ( PropValue::GetPropertyValue( aAny,
756 2374 : mXPropSet, OUString( "RotateAngle" ), true ) )
757 1146 : ? *static_cast<sal_Int32 const *>(aAny.getValue())
758 2333 : : 0;
759 :
760 1187 : return true;
761 0 : }
762 0 : return false;
763 : }
764 :
765 33 : sal_Int8 PPTWriterBase::GetTransition( sal_Int16 nTransitionType, sal_Int16 nTransitionSubtype, FadeEffect eEffect, sal_uInt8& nDirection )
766 : {
767 33 : sal_Int8 nPPTTransitionType = 0;
768 33 : nDirection = 0;
769 :
770 33 : switch( nTransitionType )
771 : {
772 : case TransitionType::FADE :
773 : {
774 0 : if ( nTransitionSubtype == TransitionSubType::CROSSFADE )
775 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_SMOOTHFADE;
776 0 : else if ( nTransitionSubtype == TransitionSubType::FADEOVERCOLOR )
777 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_FADE;
778 : }
779 0 : break;
780 : case PPT_TRANSITION_TYPE_COMB :
781 : {
782 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_COMB;
783 0 : if ( nTransitionSubtype == TransitionSubType::COMBVERTICAL )
784 0 : nDirection++;
785 : }
786 0 : break;
787 : case TransitionType::PUSHWIPE :
788 : {
789 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_PUSH;
790 0 : switch( nTransitionSubtype )
791 : {
792 0 : case TransitionSubType::FROMRIGHT: nDirection = 0; break;
793 0 : case TransitionSubType::FROMBOTTOM: nDirection = 1; break;
794 0 : case TransitionSubType::FROMLEFT: nDirection = 2; break;
795 0 : case TransitionSubType::FROMTOP: nDirection = 3; break;
796 : }
797 : }
798 0 : break;
799 : case TransitionType::PINWHEELWIPE :
800 : {
801 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_WHEEL;
802 0 : switch( nTransitionSubtype )
803 : {
804 0 : case TransitionSubType::ONEBLADE: nDirection = 1; break;
805 0 : case TransitionSubType::TWOBLADEVERTICAL : nDirection = 2; break;
806 0 : case TransitionSubType::THREEBLADE : nDirection = 3; break;
807 0 : case TransitionSubType::FOURBLADE: nDirection = 4; break;
808 0 : case TransitionSubType::EIGHTBLADE: nDirection = 8; break;
809 : }
810 : }
811 0 : break;
812 : case TransitionType::FANWIPE :
813 : {
814 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_WEDGE;
815 : }
816 0 : break;
817 : case TransitionType::ELLIPSEWIPE :
818 : {
819 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_CIRCLE;
820 : }
821 0 : break;
822 : case TransitionType::FOURBOXWIPE :
823 : {
824 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_PLUS;
825 : }
826 0 : break;
827 : case TransitionType::IRISWIPE :
828 : {
829 0 : switch( nTransitionSubtype ) {
830 : case TransitionSubType::RECTANGLE:
831 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_ZOOM;
832 0 : nDirection = (eEffect == FadeEffect_FADE_FROM_CENTER) ? 0 : 1;
833 0 : break;
834 : default:
835 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_DIAMOND;
836 0 : break;
837 : }
838 : }
839 0 : break;
840 : }
841 :
842 33 : return nPPTTransitionType;
843 : }
844 :
845 5 : sal_Int8 PPTWriterBase::GetTransition( FadeEffect eEffect, sal_uInt8& nDirection )
846 : {
847 5 : sal_Int8 nPPTTransitionType = 0;
848 :
849 5 : switch ( eEffect )
850 : {
851 : default :
852 : case FadeEffect_RANDOM :
853 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_RANDOM;
854 0 : break;
855 :
856 : case FadeEffect_HORIZONTAL_STRIPES :
857 0 : nDirection++;
858 : case FadeEffect_VERTICAL_STRIPES :
859 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_BLINDS;
860 0 : break;
861 :
862 : case FadeEffect_VERTICAL_CHECKERBOARD :
863 0 : nDirection++;
864 : case FadeEffect_HORIZONTAL_CHECKERBOARD :
865 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_CHECKER;
866 0 : break;
867 :
868 : case FadeEffect_MOVE_FROM_UPPERLEFT :
869 0 : nDirection++;
870 : case FadeEffect_MOVE_FROM_UPPERRIGHT :
871 0 : nDirection++;
872 : case FadeEffect_MOVE_FROM_LOWERLEFT :
873 0 : nDirection++;
874 : case FadeEffect_MOVE_FROM_LOWERRIGHT :
875 0 : nDirection++;
876 : case FadeEffect_MOVE_FROM_TOP :
877 0 : nDirection++;
878 : case FadeEffect_MOVE_FROM_LEFT :
879 0 : nDirection++;
880 : case FadeEffect_MOVE_FROM_BOTTOM :
881 0 : nDirection++;
882 : case FadeEffect_MOVE_FROM_RIGHT :
883 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_COVER;
884 0 : break;
885 :
886 : case FadeEffect_DISSOLVE :
887 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_DISSOLVE;
888 0 : break;
889 :
890 : case FadeEffect_VERTICAL_LINES :
891 0 : nDirection++;
892 : case FadeEffect_HORIZONTAL_LINES :
893 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_RANDOM_BARS;
894 0 : break;
895 :
896 : case FadeEffect_CLOSE_HORIZONTAL :
897 0 : nDirection++;
898 : case FadeEffect_OPEN_HORIZONTAL :
899 0 : nDirection++;
900 : case FadeEffect_CLOSE_VERTICAL :
901 0 : nDirection++;
902 : case FadeEffect_OPEN_VERTICAL :
903 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_SPLIT;
904 0 : break;
905 :
906 : case FadeEffect_FADE_FROM_UPPERLEFT :
907 0 : nDirection++;
908 : case FadeEffect_FADE_FROM_UPPERRIGHT :
909 0 : nDirection++;
910 : case FadeEffect_FADE_FROM_LOWERLEFT :
911 0 : nDirection++;
912 : case FadeEffect_FADE_FROM_LOWERRIGHT :
913 0 : nDirection += 4;
914 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_STRIPS;
915 0 : break;
916 :
917 : case FadeEffect_UNCOVER_TO_LOWERRIGHT :
918 0 : nDirection++;
919 : case FadeEffect_UNCOVER_TO_LOWERLEFT :
920 0 : nDirection++;
921 : case FadeEffect_UNCOVER_TO_UPPERRIGHT :
922 0 : nDirection++;
923 : case FadeEffect_UNCOVER_TO_UPPERLEFT :
924 0 : nDirection++;
925 : case FadeEffect_UNCOVER_TO_BOTTOM :
926 0 : nDirection++;
927 : case FadeEffect_UNCOVER_TO_RIGHT :
928 0 : nDirection++;
929 : case FadeEffect_UNCOVER_TO_TOP :
930 0 : nDirection++;
931 : case FadeEffect_UNCOVER_TO_LEFT :
932 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_PULL;
933 0 : break;
934 :
935 : case FadeEffect_FADE_FROM_TOP :
936 0 : nDirection++;
937 : case FadeEffect_FADE_FROM_LEFT :
938 0 : nDirection++;
939 : case FadeEffect_FADE_FROM_BOTTOM :
940 0 : nDirection++;
941 : case FadeEffect_FADE_FROM_RIGHT :
942 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_WIPE;
943 0 : break;
944 :
945 : case FadeEffect_ROLL_FROM_TOP :
946 0 : nDirection++;
947 : case FadeEffect_ROLL_FROM_LEFT :
948 0 : nDirection++;
949 : case FadeEffect_ROLL_FROM_BOTTOM :
950 0 : nDirection++;
951 : case FadeEffect_ROLL_FROM_RIGHT :
952 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_WIPE;
953 0 : break;
954 :
955 : case FadeEffect_FADE_TO_CENTER :
956 0 : nDirection++;
957 : case FadeEffect_FADE_FROM_CENTER :
958 0 : nPPTTransitionType = PPT_TRANSITION_TYPE_ZOOM;
959 0 : break;
960 :
961 : case FadeEffect_NONE :
962 5 : nDirection = 2;
963 5 : break;
964 : }
965 :
966 5 : return nPPTTransitionType;
967 : }
968 :
969 30 : bool PPTWriterBase::ContainsOtherShapeThanPlaceholders( bool bForOOMLX )
970 : {
971 30 : sal_uInt32 nShapes = mXShapes->getCount();
972 30 : bool bOtherThanPlaceHolders = false;
973 :
974 30 : if ( nShapes )
975 90 : for ( sal_uInt32 nIndex = 0; ( nIndex < nShapes ) && !bOtherThanPlaceHolders; nIndex++ )
976 : {
977 60 : if ( GetShapeByIndex( nIndex ) && mType != "drawing.Page" )
978 : {
979 178 : if( bForOOMLX &&
980 90 : ( mType == "presentation.Page" ||
981 30 : mType == "presentation.Notes" ) ) {
982 58 : Reference< XSimpleText > rXText( mXShape, UNO_QUERY );
983 :
984 58 : if( rXText.is() && !rXText->getString().isEmpty() )
985 2 : bOtherThanPlaceHolders = true;
986 : }
987 : else
988 2 : bOtherThanPlaceHolders = true;
989 : }
990 : DBG(printf("mType == %s\n", mType.getStr()));
991 : }
992 :
993 30 : return bOtherThanPlaceHolders;
994 12 : }
995 :
996 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|