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 20 : 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 20 : , mpStyleSheet(0)
144 : {
145 : DBG(printf ("PPTWriterBase::PPTWriterBase()\n"));
146 20 : }
147 :
148 0 : 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 0 : , mpStyleSheet(0)
163 : {
164 0 : }
165 :
166 40 : 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 20 : if ( mbStatusIndicator && mXStatusIndicator.is() )
173 0 : mXStatusIndicator->end();
174 20 : }
175 :
176 20 : void PPTWriterBase::exportPPT( const std::vector< com::sun::star::beans::PropertyValue >& rMediaData )
177 : {
178 20 : if ( !InitSOIface() )
179 0 : return;
180 :
181 : FontCollectionEntry aDefaultFontDesc( OUString( "Times New Roman" ),
182 : ROMAN,
183 : awt::FontPitch::VARIABLE,
184 20 : RTL_TEXTENCODING_MS_1252 );
185 20 : maFontCollection.GetId( aDefaultFontDesc ); // default is always times new roman
186 :
187 20 : if ( !GetPageByIndex( 0, NOTICE ) )
188 0 : return;
189 :
190 20 : sal_Int32 nWidth = 21000;
191 20 : if ( ImplGetPropertyValue( mXPagePropSet, OUString( "Width" ) ) )
192 20 : mAny >>= nWidth;
193 20 : sal_Int32 nHeight = 29700;
194 20 : if ( ImplGetPropertyValue( mXPagePropSet, OUString( "Height" ) ) )
195 20 : mAny >>= nHeight;
196 :
197 20 : maNotesPageSize = MapSize( awt::Size( nWidth, nHeight ) );
198 :
199 20 : if ( !GetPageByIndex( 0, MASTER ) )
200 0 : return;
201 :
202 20 : nWidth = 28000;
203 20 : if ( ImplGetPropertyValue( mXPagePropSet, OUString( "Width" ) ) )
204 20 : mAny >>= nWidth;
205 20 : nHeight = 21000;
206 20 : if ( ImplGetPropertyValue( mXPagePropSet, OUString( "Height" ) ) )
207 20 : mAny >>= nHeight;
208 20 : maDestPageSize = MapSize( awt::Size( nWidth, nHeight ) );
209 20 : maPageSize = awt::Size(nWidth, nHeight);
210 :
211 : DBG(printf( "call exportDocumentPre()\n"));
212 20 : exportPPTPre(rMediaData);
213 :
214 20 : if ( !GetStyleSheets() )
215 0 : return;
216 :
217 20 : if ( !ImplCreateDocument() )
218 0 : return;
219 :
220 : sal_uInt32 i;
221 :
222 40 : for ( i = 0; i < mnPages; i++ )
223 : {
224 20 : if ( GetPageByIndex( i, NORMAL ) ) {
225 20 : sal_uInt32 nMasterNum = GetMasterIndex( NORMAL );
226 20 : ImplWriteLayout( GetLayoutOffset( mXPagePropSet ), nMasterNum );
227 : }
228 : }
229 :
230 40 : for ( i = 0; i < mnMasterPages; i++ )
231 : {
232 20 : if ( !CreateSlideMaster( i ) )
233 0 : return;
234 : }
235 20 : if ( !CreateMainNotes() )
236 0 : return;
237 :
238 40 : for ( i = 0; i < mnPages; i++ )
239 : {
240 : DBG(printf( "call ImplCreateSlide( %" SAL_PRIuUINT32 " )\n", i));
241 20 : if ( !CreateSlide( i ) )
242 0 : return;
243 : }
244 :
245 40 : for ( i = 0; i < mnPages; i++ )
246 : {
247 20 : if ( !CreateNotes( i ) )
248 0 : return;
249 : }
250 :
251 : DBG(printf( "call exportDocumentPost()\n"));
252 20 : exportPPTPost();
253 : }
254 :
255 20 : bool PPTWriterBase::InitSOIface()
256 : {
257 : while( true )
258 : {
259 20 : mXDrawPagesSupplier = Reference< XDrawPagesSupplier >( mXModel, UNO_QUERY );
260 20 : if ( !mXDrawPagesSupplier.is() )
261 0 : break;
262 :
263 20 : mXMasterPagesSupplier = Reference< XMasterPagesSupplier >( mXModel, UNO_QUERY );
264 20 : if ( !mXMasterPagesSupplier.is() )
265 0 : break;
266 20 : mXDrawPages = mXMasterPagesSupplier->getMasterPages();
267 20 : if ( !mXDrawPages.is() )
268 0 : break;
269 20 : mnMasterPages = mXDrawPages->getCount();
270 20 : mXDrawPages = mXDrawPagesSupplier->getDrawPages();
271 20 : if( !mXDrawPages.is() )
272 0 : break;
273 20 : mnPages = mXDrawPages->getCount();
274 20 : if ( !GetPageByIndex( 0, NORMAL ) )
275 0 : break;
276 :
277 20 : return true;
278 : }
279 0 : return false;
280 : }
281 :
282 200 : bool PPTWriterBase::GetPageByIndex( sal_uInt32 nIndex, PageType ePageType )
283 : {
284 : while( true )
285 : {
286 200 : if ( ePageType != meLatestPageType )
287 : {
288 160 : switch( ePageType )
289 : {
290 : case NORMAL :
291 : case NOTICE :
292 : {
293 120 : mXDrawPages = mXDrawPagesSupplier->getDrawPages();
294 120 : if( !mXDrawPages.is() )
295 200 : return false;
296 : }
297 120 : break;
298 :
299 : case MASTER :
300 : {
301 40 : mXDrawPages = mXMasterPagesSupplier->getMasterPages();
302 40 : if( !mXDrawPages.is() )
303 0 : return false;
304 : }
305 40 : break;
306 : default:
307 0 : break;
308 : }
309 160 : meLatestPageType = ePageType;
310 : }
311 200 : Any aAny( mXDrawPages->getByIndex( nIndex ) );
312 200 : aAny >>= mXDrawPage;
313 200 : if ( !mXDrawPage.is() )
314 0 : break;
315 200 : if ( ePageType == NOTICE )
316 : {
317 80 : Reference< XPresentationPage > aXPresentationPage( mXDrawPage, UNO_QUERY );
318 80 : if ( !aXPresentationPage.is() )
319 0 : break;
320 80 : mXDrawPage = aXPresentationPage->getNotesPage();
321 80 : if ( !mXDrawPage.is() )
322 0 : break;
323 : }
324 200 : mXPagePropSet = Reference< XPropertySet >( mXDrawPage, UNO_QUERY );
325 200 : if ( !mXPagePropSet.is() )
326 0 : break;
327 :
328 200 : mXShapes = Reference< XShapes >( mXDrawPage, UNO_QUERY );
329 200 : 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 200 : bool bHasBackground = GetPropertyValue( aAny, mXPagePropSet, OUString( "Background" ), true );
335 200 : if ( bHasBackground )
336 66 : bHasBackground = ( aAny >>= mXBackgroundPropSet );
337 200 : if ( !bHasBackground )
338 : {
339 134 : Reference< XMasterPageTarget > aXMasterPageTarget( mXDrawPage, UNO_QUERY );
340 134 : if ( aXMasterPageTarget.is() )
341 : {
342 134 : Reference< XDrawPage > aXMasterDrawPage;
343 134 : aXMasterDrawPage = aXMasterPageTarget->getMasterPage();
344 134 : if ( aXMasterDrawPage.is() )
345 : {
346 134 : Reference< XPropertySet > aXMasterPagePropSet;
347 268 : aXMasterPagePropSet = Reference< XPropertySet >
348 134 : ( aXMasterDrawPage, UNO_QUERY );
349 134 : if ( aXMasterPagePropSet.is() )
350 : {
351 134 : bool bBackground = GetPropertyValue( aAny, aXMasterPagePropSet, OUString( "Background" ) );
352 134 : if ( bBackground )
353 : {
354 134 : aAny >>= mXBackgroundPropSet;
355 : }
356 134 : }
357 134 : }
358 134 : }
359 : }
360 200 : return true;
361 0 : }
362 0 : return false;
363 : }
364 :
365 20 : bool PPTWriterBase::CreateSlide( sal_uInt32 nPageNum )
366 : {
367 20 : Any aAny;
368 :
369 20 : if ( !GetPageByIndex( nPageNum, NORMAL ) )
370 0 : return false;
371 :
372 20 : sal_uInt32 nMasterNum = GetMasterIndex( NORMAL );
373 20 : SetCurrentStyleSheet( nMasterNum );
374 :
375 40 : Reference< XPropertySet > aXBackgroundPropSet;
376 20 : bool bHasBackground = GetPropertyValue( aAny, mXPagePropSet, OUString( "Background" ) );
377 20 : if ( bHasBackground )
378 2 : bHasBackground = ( aAny >>= aXBackgroundPropSet );
379 :
380 20 : sal_uInt16 nMode = 7; // Bit 1: Follow master objects, Bit 2: Follow master scheme, Bit 3: Follow master background
381 20 : if ( bHasBackground )
382 2 : 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 20 : if ( GetPropertyValue( aAny, mXPagePropSet, OUString( "IsBackgroundObjectsVisible" ) ) )
396 : {
397 20 : bool bBackgroundObjectsVisible = false;
398 20 : if ( aAny >>= bBackgroundObjectsVisible )
399 : {
400 20 : if ( !bBackgroundObjectsVisible )
401 0 : nMode &= ~1;
402 : }
403 : }
404 :
405 20 : ImplWriteSlide( nPageNum, nMasterNum, nMode, bHasBackground, aXBackgroundPropSet );
406 :
407 40 : return true;
408 : };
409 :
410 20 : bool PPTWriterBase::CreateNotes( sal_uInt32 nPageNum )
411 : {
412 20 : if ( !GetPageByIndex( nPageNum, NOTICE ) )
413 0 : return false;
414 20 : SetCurrentStyleSheet( GetMasterIndex( NORMAL ) );
415 :
416 20 : ImplWriteNotes( nPageNum );
417 :
418 20 : return true;
419 : };
420 :
421 20 : bool PPTWriterBase::CreateSlideMaster( sal_uInt32 nPageNum )
422 : {
423 20 : if ( !GetPageByIndex( nPageNum, MASTER ) )
424 0 : return false;
425 20 : SetCurrentStyleSheet( nPageNum );
426 :
427 20 : if ( !ImplGetPropertyValue( mXPagePropSet, OUString( "Background" ) ) ) // load background shape
428 0 : return false;
429 20 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXBackgroundPropSet;
430 20 : if ( !( mAny >>= aXBackgroundPropSet ) )
431 0 : return false;
432 :
433 20 : ImplWriteSlideMaster( nPageNum, aXBackgroundPropSet );
434 :
435 20 : return true;
436 : };
437 :
438 40 : sal_Int32 PPTWriterBase::GetLayoutOffset( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const
439 : {
440 40 : ::com::sun::star::uno::Any aAny;
441 40 : sal_Int32 nLayout = 20;
442 40 : if ( GetPropertyValue( aAny, rXPropSet, OUString( "Layout" ) ), sal_True )
443 40 : aAny >>= nLayout;
444 :
445 : DBG(printf("GetLayoutOffset %" SAL_PRIdINT32 "\n", nLayout));
446 :
447 40 : return nLayout;
448 : }
449 :
450 0 : sal_Int32 PPTWriterBase::GetLayoutOffsetFixed( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const
451 : {
452 0 : sal_Int32 nLayout = GetLayoutOffset( rXPropSet );
453 :
454 0 : if ( ( nLayout >= 21 ) && ( nLayout <= 26 ) ) // NOTES _> HANDOUT6
455 0 : nLayout = 20;
456 0 : if ( ( nLayout >= 27 ) && ( nLayout <= 30 ) ) // VERTICAL LAYOUT
457 0 : nLayout -= 6;
458 0 : else if ( nLayout > 30 )
459 0 : nLayout = 20;
460 :
461 0 : return nLayout;
462 : }
463 :
464 0 : PHLayout& PPTWriterBase::GetLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const
465 : {
466 0 : return pPHLayout[ GetLayoutOffsetFixed( rXPropSet ) ];
467 : }
468 :
469 0 : PHLayout& PPTWriterBase::GetLayout( sal_Int32 nOffset ) const
470 : {
471 0 : if( nOffset >= 0 && nOffset < EPP_LAYOUT_SIZE )
472 0 : 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 60 : sal_uInt32 PPTWriterBase::GetMasterIndex( PageType ePageType )
480 : {
481 60 : sal_uInt32 nRetValue = 0;
482 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPageTarget >
483 60 : aXMasterPageTarget( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
484 :
485 60 : if ( aXMasterPageTarget.is() )
486 : {
487 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
488 60 : aXDrawPage = aXMasterPageTarget->getMasterPage();
489 60 : if ( aXDrawPage.is() )
490 : {
491 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
492 60 : aXPropertySet( aXDrawPage, ::com::sun::star::uno::UNO_QUERY );
493 :
494 60 : if ( aXPropertySet.is() )
495 : {
496 60 : if ( ImplGetPropertyValue( aXPropertySet, OUString( "Number" ) ) )
497 60 : nRetValue |= *(sal_Int16*)mAny.getValue();
498 60 : if ( nRetValue & 0xffff ) // avoid overflow
499 60 : nRetValue--;
500 60 : }
501 60 : }
502 : }
503 60 : if ( ePageType == NOTICE )
504 0 : nRetValue += mnMasterPages;
505 60 : return nRetValue;
506 : }
507 :
508 100 : bool PPTWriterBase::SetCurrentStyleSheet( sal_uInt32 nPageNum )
509 : {
510 100 : bool bRet = false;
511 100 : if ( nPageNum >= maStyleSheetList.size() )
512 0 : nPageNum = 0;
513 : else
514 100 : bRet = true;
515 100 : mpStyleSheet = maStyleSheetList[ nPageNum ];
516 100 : return bRet;
517 : }
518 :
519 20 : bool PPTWriterBase::GetStyleSheets()
520 : {
521 : int nInstance, nLevel;
522 20 : bool bRetValue = false;
523 : sal_uInt32 nPageNum;
524 :
525 40 : for ( nPageNum = 0; nPageNum < mnMasterPages; nPageNum++ )
526 : {
527 : Reference< XNamed >
528 20 : aXNamed;
529 :
530 : Reference< XNameAccess >
531 40 : aXNameAccess;
532 :
533 : Reference< XStyleFamiliesSupplier >
534 40 : aXStyleFamiliesSupplier( mXModel, UNO_QUERY );
535 :
536 : Reference< XPropertySet >
537 40 : aXPropSet( mXModel, UNO_QUERY );
538 :
539 80 : sal_uInt16 nDefaultTab = ( aXPropSet.is() && ImplGetPropertyValue( aXPropSet, OUString( "TabStop" ) ) )
540 20 : ? (sal_uInt16)( *(sal_Int32*)mAny.getValue() / 4.40972 )
541 60 : : 1250;
542 :
543 20 : maStyleSheetList.push_back( new PPTExStyleSheet( nDefaultTab, (PPTExBulletProvider&)*this ) );
544 20 : SetCurrentStyleSheet( nPageNum );
545 20 : if ( GetPageByIndex( nPageNum, MASTER ) )
546 40 : aXNamed = Reference< XNamed >
547 20 : ( mXDrawPage, UNO_QUERY );
548 :
549 20 : if ( aXStyleFamiliesSupplier.is() )
550 20 : aXNameAccess = aXStyleFamiliesSupplier->getStyleFamilies();
551 :
552 20 : bRetValue = aXNamed.is() && aXNameAccess.is() && aXStyleFamiliesSupplier.is();
553 20 : if ( bRetValue )
554 : {
555 160 : for ( nInstance = EPP_TEXTTYPE_Title; nInstance <= EPP_TEXTTYPE_CenterTitle; nInstance++ )
556 : {
557 140 : OUString aStyle;
558 280 : OUString aFamily;
559 140 : switch ( nInstance )
560 : {
561 : case EPP_TEXTTYPE_CenterTitle :
562 : case EPP_TEXTTYPE_Title :
563 : {
564 40 : aStyle = "title";
565 40 : aFamily = aXNamed->getName();
566 : }
567 40 : break;
568 : case EPP_TEXTTYPE_Body :
569 : {
570 20 : aStyle = "outline1"; // SD_LT_SEPARATOR
571 20 : aFamily = aXNamed->getName();
572 : }
573 20 : break;
574 : case EPP_TEXTTYPE_Other :
575 : {
576 20 : aStyle = "standard";
577 20 : aFamily = "graphics";
578 : }
579 20 : break;
580 : case EPP_TEXTTYPE_CenterBody :
581 : {
582 20 : aStyle = "subtitle";
583 20 : aFamily = aXNamed->getName();
584 : }
585 20 : break;
586 : }
587 140 : if ( !aStyle.isEmpty() && !aFamily.isEmpty() )
588 : {
589 : try
590 : {
591 100 : Reference< XNameAccess >xNameAccess;
592 100 : if ( aXNameAccess->hasByName( aFamily ) )
593 : {
594 100 : Any aAny( aXNameAccess->getByName( aFamily ) );
595 100 : xNameAccess.set(aAny, css::uno::UNO_QUERY);
596 100 : if( xNameAccess.is() )
597 : {
598 100 : Reference< XNameAccess > aXFamily;
599 100 : if ( aAny >>= aXFamily )
600 : {
601 100 : if ( aXFamily->hasByName( aStyle ) )
602 : {
603 100 : aAny = aXFamily->getByName( aStyle );
604 : Reference< XStyle > xStyle(
605 100 : aAny, css::uno::UNO_QUERY);
606 100 : if( xStyle.is() )
607 : {
608 100 : Reference< XStyle > aXStyle;
609 100 : aAny >>= aXStyle;
610 : Reference< XPropertySet >
611 200 : xPropSet( aXStyle, UNO_QUERY );
612 100 : if( xPropSet.is() )
613 100 : mpStyleSheet->SetStyleSheet( xPropSet, maFontCollection, nInstance, 0 );
614 500 : for ( nLevel = 1; nLevel < 5; nLevel++ )
615 : {
616 400 : if ( nInstance == EPP_TEXTTYPE_Body )
617 : {
618 80 : sal_Unicode cTemp = aStyle[aStyle.getLength() - 1];
619 80 : aStyle = aStyle.copy(0, aStyle.getLength() - 1) + OUString(++cTemp);
620 80 : if ( aXFamily->hasByName( aStyle ) )
621 : {
622 80 : aXFamily->getByName( aStyle ) >>= xStyle;
623 80 : if( xStyle.is() )
624 : {
625 : Reference< XPropertySet >
626 80 : xPropertySet( xStyle, UNO_QUERY );
627 80 : if ( xPropertySet.is() )
628 80 : mpStyleSheet->SetStyleSheet( xPropertySet, maFontCollection, nInstance, nLevel );
629 : }
630 : }
631 : }
632 : else
633 320 : mpStyleSheet->SetStyleSheet( xPropSet, maFontCollection, nInstance, nLevel );
634 100 : }
635 100 : }
636 : }
637 100 : }
638 100 : }
639 100 : }
640 : }
641 0 : catch( Exception& )
642 : {
643 :
644 : }
645 : }
646 140 : }
647 20 : for ( ; nInstance <= EPP_TEXTTYPE_QuarterBody; nInstance++ )
648 : {
649 :
650 : }
651 : }
652 20 : }
653 20 : return bRetValue;
654 : }
655 :
656 20 : bool PPTWriterBase::CreateMainNotes()
657 : {
658 20 : if ( !GetPageByIndex( 0, NOTICE ) )
659 0 : return false;
660 20 : SetCurrentStyleSheet( 0 );
661 :
662 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPageTarget >
663 20 : aXMasterPageTarget( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
664 :
665 20 : if ( !aXMasterPageTarget.is() )
666 0 : return false;
667 :
668 20 : mXDrawPage = aXMasterPageTarget->getMasterPage();
669 20 : if ( !mXDrawPage.is() )
670 0 : return false;
671 :
672 40 : mXPropSet = ::com::sun::star::uno::Reference<
673 : ::com::sun::star::beans::XPropertySet >
674 20 : ( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
675 20 : if ( !mXPropSet.is() )
676 0 : return false;
677 :
678 40 : mXShapes = ::com::sun::star::uno::Reference<
679 : ::com::sun::star::drawing::XShapes >
680 20 : ( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
681 20 : if ( !mXShapes.is() )
682 0 : return false;
683 :
684 20 : return ImplCreateMainNotes();
685 : }
686 :
687 960 : awt::Size PPTWriterBase::MapSize( const awt::Size& rSize )
688 : {
689 960 : Size aRetSize( OutputDevice::LogicToLogic( Size( rSize.Width, rSize.Height ), maMapModeSrc, maMapModeDest ) );
690 :
691 960 : if ( !aRetSize.Width() )
692 8 : aRetSize.Width()++;
693 960 : if ( !aRetSize.Height() )
694 8 : aRetSize.Height()++;
695 960 : return awt::Size( aRetSize.Width(), aRetSize.Height() );
696 : }
697 :
698 920 : awt::Point PPTWriterBase::MapPoint( const awt::Point& rPoint )
699 : {
700 920 : Point aRet( OutputDevice::LogicToLogic( Point( rPoint.X, rPoint.Y ), maMapModeSrc, maMapModeDest ) );
701 920 : 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 920 : bool PPTWriterBase::GetShapeByIndex( sal_uInt32 nIndex, bool bGroup )
714 : {
715 : while(true)
716 : {
717 920 : if ( ( bGroup == false ) || ( GetCurrentGroupLevel() == 0 ) )
718 : {
719 906 : Any aAny( mXShapes->getByIndex( nIndex ) );
720 906 : aAny >>= mXShape;
721 : }
722 : else
723 : {
724 14 : Any aAny( GetCurrentGroupAccess()->getByIndex( GetCurrentGroupIndex() ) );
725 14 : aAny >>= mXShape;
726 : }
727 920 : if ( !mXShape.is() )
728 0 : break;
729 :
730 920 : Any aAny( mXShape->queryInterface( cppu::UnoType<XPropertySet>::get()));
731 920 : aAny >>= mXPropSet;
732 :
733 920 : if ( !mXPropSet.is() )
734 0 : break;
735 920 : maPosition = MapPoint( mXShape->getPosition() );
736 920 : maSize = MapSize( mXShape->getSize() );
737 920 : maRect = Rectangle( Point( maPosition.X, maPosition.Y ), Size( maSize.Width, maSize.Height ) );
738 :
739 : OStringBuffer aTypeBuffer(OUStringToOString(
740 1840 : mXShape->getShapeType(), RTL_TEXTENCODING_UTF8));
741 : // remove "com.sun.star."
742 920 : aTypeBuffer.remove(0, RTL_CONSTASCII_LENGTH("com.sun.star."));
743 :
744 920 : sal_Int32 nPos = aTypeBuffer.toString().indexOf("Shape");
745 920 : aTypeBuffer.remove(nPos, RTL_CONSTASCII_LENGTH("Shape"));
746 920 : mType = aTypeBuffer.makeStringAndClear();
747 :
748 920 : mbPresObj = mbEmptyPresObj = false;
749 920 : if ( ImplGetPropertyValue( OUString( "IsPresentationObject" ) ) )
750 920 : mAny >>= mbPresObj;
751 :
752 920 : if ( mbPresObj && ImplGetPropertyValue( OUString( "IsEmptyPresentationObject" ) ) )
753 856 : mAny >>= mbEmptyPresObj;
754 :
755 : mnAngle = ( PropValue::GetPropertyValue( aAny,
756 1840 : mXPropSet, OUString( "RotateAngle" ), true ) )
757 892 : ? *((sal_Int32*)aAny.getValue() )
758 1812 : : 0;
759 :
760 920 : return true;
761 0 : }
762 0 : return false;
763 : }
764 :
765 20 : sal_Int8 PPTWriterBase::GetTransition( sal_Int16 nTransitionType, sal_Int16 nTransitionSubtype, FadeEffect eEffect, sal_uInt8& nDirection )
766 : {
767 20 : sal_Int8 nPPTTransitionType = 0;
768 20 : nDirection = 0;
769 :
770 20 : 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 20 : return nPPTTransitionType;
843 : }
844 :
845 0 : sal_Int8 PPTWriterBase::GetTransition( FadeEffect eEffect, sal_uInt8& nDirection )
846 : {
847 0 : sal_Int8 nPPTTransitionType = 0;
848 :
849 0 : 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 0 : nDirection = 2;
963 0 : break;
964 : }
965 :
966 0 : return nPPTTransitionType;
967 : }
968 :
969 24 : bool PPTWriterBase::ContainsOtherShapeThanPlaceholders( bool bForOOMLX )
970 : {
971 24 : sal_uInt32 nShapes = mXShapes->getCount();
972 24 : bool bOtherThanPlaceHolders = false;
973 :
974 24 : if ( nShapes )
975 72 : for ( sal_uInt32 nIndex = 0; ( nIndex < nShapes ) && ( bOtherThanPlaceHolders == false ); nIndex++ )
976 : {
977 48 : if ( GetShapeByIndex( nIndex ) && mType != "drawing.Page" )
978 : {
979 140 : if( bForOOMLX &&
980 72 : ( mType == "presentation.Page" ||
981 24 : mType == "presentation.Notes" ) ) {
982 44 : Reference< XSimpleText > rXText( mXShape, UNO_QUERY );
983 :
984 44 : if( rXText.is() && !rXText->getString().isEmpty() )
985 4 : bOtherThanPlaceHolders = true;
986 : }
987 : else
988 4 : bOtherThanPlaceHolders = true;
989 : }
990 : DBG(printf("mType == %s\n", mType.getStr()));
991 : }
992 :
993 24 : return bOtherThanPlaceHolders;
994 24 : }
995 :
996 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|