Update ooo320-m1
[ooovba.git] / sd / source / filter / eppt / eppt.cxx
blob4f29f503b84a1ade5727a1a9ba000c6aa364c09c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: eppt.cxx,v $
10 * $Revision: 1.64.78.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <eppt.hxx>
34 #include "epptdef.hxx"
35 #include <tools/globname.hxx>
36 #include <tools/datetime.hxx>
37 #include <tools/poly.hxx>
38 #include <vcl/graph.hxx>
39 #include <vcl/bmpacc.hxx>
40 #include <vcl/gradient.hxx>
41 #include <rtl/ustring.hxx>
42 #include <tools/stream.hxx>
43 #include <svtools/fltcall.hxx>
44 #include <sfx2/docfile.hxx>
45 #include <svx/unoapi.hxx>
46 #include <svx/svdobj.hxx>
47 #include <svx/svdoole2.hxx>
48 #include <svx/svdmodel.hxx>
49 #include <svx/svdpage.hxx>
50 #include <com/sun/star/view/PaperOrientation.hpp>
51 #include <com/sun/star/view/PaperFormat.hpp>
52 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
53 #include <com/sun/star/office/XAnnotation.hpp>
54 #include <com/sun/star/office/XAnnotationAccess.hpp>
55 #include <com/sun/star/office/XAnnotationEnumeration.hpp>
56 #include <com/sun/star/geometry/RealPoint2D.hpp>
57 #include <com/sun/star/util/DateTime.hpp>
58 #include <tools/zcodec.hxx>
59 #include <svx/svxenum.hxx>
60 #include <sot/storinfo.hxx>
61 #include <svx/msoleexp.hxx>
62 #include <vcl/virdev.hxx>
63 #include <svtools/wmf.hxx>
64 #include <svx/msdffimp.hxx>
65 #include <svx/flditem.hxx>
66 #include <sfx2/docinf.hxx>
68 #define PPT_TRANSITION_TYPE_NONE 0
69 #define PPT_TRANSITION_TYPE_RANDOM 1
70 #define PPT_TRANSITION_TYPE_BLINDS 2
71 #define PPT_TRANSITION_TYPE_CHECKER 3
72 #define PPT_TRANSITION_TYPE_COVER 4
73 #define PPT_TRANSITION_TYPE_DISSOLVE 5
74 #define PPT_TRANSITION_TYPE_FADE 6
75 #define PPT_TRANSITION_TYPE_PULL 7
76 #define PPT_TRANSITION_TYPE_RANDOM_BARS 8
77 #define PPT_TRANSITION_TYPE_STRIPS 9
78 #define PPT_TRANSITION_TYPE_WIPE 10
79 #define PPT_TRANSITION_TYPE_ZOOM 11
80 #define PPT_TRANSITION_TYPE_SPLIT 13
82 // effects, new in xp
83 #define PPT_TRANSITION_TYPE_DIAMOND 17
84 #define PPT_TRANSITION_TYPE_PLUS 18
85 #define PPT_TRANSITION_TYPE_WEDGE 19
86 #define PPT_TRANSITION_TYPE_PUSH 20
87 #define PPT_TRANSITION_TYPE_COMB 21
88 #define PPT_TRANSITION_TYPE_NEWSFLASH 22
89 #define PPT_TRANSITION_TYPE_SMOOTHFADE 23
90 #define PPT_TRANSITION_TYPE_WHEEL 26
91 #define PPT_TRANSITION_TYPE_CIRCLE 27
93 using namespace com::sun::star;
95 static PHLayout pPHLayout[] =
97 { EPP_LAYOUT_TITLESLIDE, { 0x0d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x10, TRUE, TRUE, FALSE },
98 { EPP_LAYOUT_TITLEANDBODYSLIDE, { 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, TRUE, TRUE, FALSE },
99 { EPP_LAYOUT_TITLEANDBODYSLIDE, { 0x0d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, TRUE, TRUE, FALSE },
100 { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, TRUE, TRUE, TRUE },
101 { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x0e, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, TRUE, TRUE, FALSE },
102 { EPP_LAYOUT_BLANCSLIDE, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, FALSE, FALSE, FALSE },
103 { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x0e, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, TRUE, TRUE, FALSE },
104 { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x14, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, TRUE, TRUE, FALSE },
105 { EPP_LAYOUT_TITLEANDBODYSLIDE, { 0x0d, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x15, 0x0d, 0x0e, TRUE, FALSE, FALSE },
106 { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x16, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, TRUE, TRUE, FALSE },
107 { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE },
108 { EPP_LAYOUT_TITLEANDBODYSLIDE, { 0x0d, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, FALSE, FALSE },
109 { EPP_LAYOUT_RIGHTCOLUMN2ROWS, { 0x0d, 0x0e, 0x13, 0x13, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE },
110 { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE },
111 { EPP_LAYOUT_2ROWSANDTITLE, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE },
112 { EPP_LAYOUT_LEFTCOLUMN2ROWS, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE },
113 { EPP_LAYOUT_TOPROW2COLUMN, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE },
114 { EPP_LAYOUT_2ROWSANDTITLE, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, TRUE, FALSE },
115 { EPP_LAYOUT_4OBJECTS, { 0x0d, 0x13, 0x13, 0x13, 0x13, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, TRUE, FALSE, FALSE },
116 { EPP_LAYOUT_ONLYTITLE, { 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, TRUE, FALSE, FALSE },
117 { EPP_LAYOUT_BLANCSLIDE, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, FALSE, FALSE, FALSE },
118 { EPP_LAYOUT_TITLERIGHT2BODIESLEFT, { 0x11, 0x12, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x11, 0x12, TRUE, TRUE, FALSE },
119 { EPP_LAYOUT_TITLERIGHTBODYLEFT, { 0x11, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x11, 0x12, TRUE, TRUE, FALSE },
120 { EPP_LAYOUT_TITLEANDBODYSLIDE, { 0x0d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x12, TRUE, TRUE, FALSE },
121 { EPP_LAYOUT_2COLUMNSANDTITLE, { 0x0d, 0x16, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x12, TRUE, TRUE, FALSE }
124 //============================ PPTWriter ==================================
126 PPTWriter::PPTWriter( SvStorageRef& rSvStorage,
127 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rXModel,
128 ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > & rXStatInd,
129 SvMemoryStream* pVBA, sal_uInt32 nCnvrtFlags ) :
130 mbStatus ( sal_False ),
131 mbUseNewAnimations ( sal_True ),
132 mnLatestStatValue ( 0 ),
133 maFraction ( 1, 576 ),
134 maMapModeSrc ( MAP_100TH_MM ),
135 maMapModeDest ( MAP_INCH, Point(), maFraction, maFraction ),
136 meLatestPageType ( NORMAL ),
137 mXModel ( rXModel ),
138 mXStatusIndicator ( rXStatInd ),
139 mbStatusIndicator ( FALSE ),
140 mpCurUserStrm ( NULL ),
141 mpStrm ( NULL ),
142 mpPicStrm ( NULL ),
143 mpPptEscherEx ( NULL ),
144 mnVBAOleOfs ( 0 ),
145 mpVBA ( pVBA ),
146 mnExEmbed ( 0 ),
147 mpExEmbed ( new SvMemoryStream ),
148 mnPagesWritten ( 0 ),
149 mnTxId ( 0x7a2f64 )
151 sal_uInt32 i;
152 if ( !ImplInitSOIface() )
153 return;
155 FontCollectionEntry aDefaultFontDesc( String( RTL_CONSTASCII_USTRINGPARAM( "Times New Roman" ) ),
156 ::com::sun::star::awt::FontFamily::ROMAN,
157 ::com::sun::star::awt::FontPitch::VARIABLE,
158 RTL_TEXTENCODING_MS_1252 );
159 maFontCollection.GetId( aDefaultFontDesc ); // default is always times new roman
161 if ( !ImplGetPageByIndex( 0, NOTICE ) )
162 return;
163 INT32 nWidth = 21000;
164 if ( ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ) ) )
165 mAny >>= nWidth;
166 INT32 nHeight = 29700;
167 if ( ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) ) )
168 mAny >>= nHeight;
170 maNotesPageSize = ImplMapSize( ::com::sun::star::awt::Size( nWidth, nHeight ) );
172 if ( !ImplGetPageByIndex( 0, MASTER ) )
173 return;
174 nWidth = 28000;
175 if ( ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ) ) )
176 mAny >>= nWidth;
177 nHeight = 21000;
178 if ( ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) ) )
179 mAny >>= nHeight;
180 maDestPageSize = ImplMapSize( ::com::sun::star::awt::Size( nWidth, nHeight ) );
182 mrStg = rSvStorage;
183 if ( !mrStg.Is() )
184 return;
186 // MasterPages + Slides und Notizen + NotesMasterPage
187 mnDrawings = mnMasterPages + ( mnPages << 1 ) + 1;
189 if ( mXStatusIndicator.is() )
191 mbStatusIndicator = TRUE;
192 mnStatMaxValue = ( mnPages + mnMasterPages ) * 5;
193 mXStatusIndicator->start( String( RTL_CONSTASCII_USTRINGPARAM( "PowerPoint Export" ) ),
194 mnStatMaxValue + ( mnStatMaxValue >> 3 ) );
197 SvGlobalName aGName( 0x64818d10L, 0x4f9b, 0x11cf, 0x86, 0xea, 0x00, 0xaa, 0x00, 0xb9, 0x29, 0xe8 );
198 mrStg->SetClass( aGName, 0, String( RTL_CONSTASCII_USTRINGPARAM( "MS PowerPoint 97" ) ) );
200 if ( !ImplCreateCurrentUserStream() )
201 return;
203 mpStrm = mrStg->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "PowerPoint Document" ) ) );
204 if ( !mpStrm )
205 return;
207 if ( !mpPicStrm )
208 mpPicStrm = mrStg->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "Pictures" ) ) );
210 mpPptEscherEx = new PptEscherEx( *mpStrm, mnDrawings );
212 if ( !ImplGetStyleSheets() )
213 return;
215 if ( !ImplCreateDocument() )
216 return;
218 for ( i = 0; i < mnMasterPages; i++ )
220 if ( !ImplCreateMaster( i ) )
221 return;
223 if ( !ImplCreateMainNotes() )
224 return;
225 maTextRuleList.First(); // rewind list, so we can get the current or next entry without
226 // searching, all entrys are sorted#
227 for ( i = 0; i < mnPages; i++ )
229 if ( !ImplCreateSlide( i ) )
230 return;
232 for ( i = 0; i < mnPages; i++ )
234 if ( !ImplCreateNotes( i ) )
235 return;
237 if ( !ImplCloseDocument() )
238 return;
240 if ( mbStatusIndicator )
242 mXStatusIndicator->setText( String( RTL_CONSTASCII_USTRINGPARAM( "PowerPoint Export" ) ) );
243 sal_uInt32 nValue = mnStatMaxValue + ( mnStatMaxValue >> 3 );
244 if ( nValue > mnLatestStatValue )
246 mXStatusIndicator->setValue( nValue );
247 mnLatestStatValue = nValue;
251 ImplWriteOLE( nCnvrtFlags );
253 ImplWriteVBA( pVBA );
255 if ( !ImplWriteAtomEnding() )
256 return;
258 if ( !ImplCreateDocumentSummaryInformation( nCnvrtFlags ) )
259 return;
261 mbStatus = TRUE;
265 // ---------------------------------------------------------------------------------------------
267 PPTWriter::~PPTWriter()
269 void* pPtr;
270 delete mpExEmbed;
271 delete mpPptEscherEx;
273 std::vector< PPTExStyleSheet* >::iterator aStyleSheetIter( maStyleSheetList.begin() );
274 while( aStyleSheetIter < maStyleSheetList.end() )
275 delete *aStyleSheetIter++;
277 for ( pPtr = maTextRuleList.First(); pPtr; pPtr = maTextRuleList.Next() )
278 delete (TextRuleEntry*)pPtr;
279 for ( pPtr = maSlideNameList.First(); pPtr; pPtr = maSlideNameList.Next() )
280 delete (::rtl::OUString*)pPtr;
281 for ( pPtr = maHyperlink.First(); pPtr; pPtr = maHyperlink.Next() )
282 delete (EPPTHyperlink*)pPtr;
283 for ( pPtr = maExOleObj.First(); pPtr; pPtr = maExOleObj.Next() )
284 delete (PPTExOleObjEntry*)pPtr;
286 if ( mbStatusIndicator )
287 mXStatusIndicator->end();
290 // ---------------------------------------------------------------------------------------------
292 static inline sal_uInt32 PPTtoEMU( INT32 nPPT )
294 return (sal_uInt32)( (double)nPPT * 1587.5 );
297 // ---------------------------------------------------------------------------------------------
299 sal_Bool PPTWriter::ImplCreateCurrentUserStream()
301 mpCurUserStrm = mrStg->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "Current User" ) ) );
302 if ( !mpCurUserStrm )
303 return FALSE;
304 char pUserName[] = "Current User";
305 sal_uInt32 nLenOfUserName = strlen( pUserName );
306 sal_uInt32 nSizeOfRecord = 0x14 + ( ( nLenOfUserName + 4 ) & ~ 3 );
308 *mpCurUserStrm << (sal_uInt16)0 << (sal_uInt16)EPP_CurrentUserAtom << nSizeOfRecord;
309 *mpCurUserStrm << (sal_uInt32)0x14 // Len
310 << (sal_uInt32)0xe391c05f; // Magic
312 sal_uInt32 nEditPos = mpCurUserStrm->Tell();
313 *mpCurUserStrm << (sal_uInt32)0x0 // OffsetToCurrentEdit;
314 << (sal_uInt16)nLenOfUserName //
315 << (sal_uInt16)0x3f4 // DocFileVersion
316 << (sal_uInt8)3 // MajorVersion
317 << (sal_uInt8)0 // MinorVersion
318 << (sal_uInt16)0; // Pad Word
319 pUserName[ nLenOfUserName ] = 8;
320 mpCurUserStrm->Write( pUserName, nLenOfUserName + 1 );
321 for ( sal_uInt32 i = 0x15 + nLenOfUserName; i < nSizeOfRecord; i++ )
323 *mpCurUserStrm << (sal_uInt8)0; // pad bytes
325 mpCurUserStrm->Seek( nEditPos );
326 return TRUE;
329 // ---------------------------------------------------------------------------------------------
331 sal_Bool PPTWriter::ImplCreateDocumentSummaryInformation( sal_uInt32 nCnvrtFlags )
333 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
334 mXModel, uno::UNO_QUERY_THROW);
335 uno::Reference<document::XDocumentProperties> xDocProps(
336 xDPS->getDocumentProperties());
338 if (xDocProps.is()) {
340 // no idea what this is...
341 static sal_uInt8 aGuid[ 0x52 ] =
343 0x4e, 0x00, 0x00, 0x00,
344 '{',0,'D',0,'B',0,'1',0,'A',0,'C',0,'9',0,'6',0,'4',0,'-',0,
345 'E',0,'3',0,'9',0,'C',0,'-',0,'1',0,'1',0,'D',0,'2',0,'-',0,
346 'A',0,'1',0,'E',0,'F',0,'-',0,'0',0,'0',0,'6',0,'0',0,'9',0,
347 '7',0,'D',0,'A',0,'5',0,'6',0,'8',0,'9',0,'}',0
349 uno::Sequence<sal_uInt8> aGuidSeq(aGuid, 0x52);
351 SvMemoryStream aHyperBlob;
352 ImplCreateHyperBlob( aHyperBlob );
354 uno::Sequence<sal_uInt8> aHyperSeq(aHyperBlob.Tell());
355 const sal_uInt8* pBlob(
356 static_cast<const sal_uInt8*>(aHyperBlob.GetData()));
357 for (sal_Int32 j = 0; j < aHyperSeq.getLength(); ++j) {
358 aHyperSeq[j] = pBlob[j];
361 if ( nCnvrtFlags & 0x8000 )
363 uno::Sequence<sal_uInt8> aThumbSeq;
364 if ( ImplGetPageByIndex( 0, NORMAL ) &&
365 ImplGetPropertyValue( mXPagePropSet,
366 String( RTL_CONSTASCII_USTRINGPARAM( "PreviewBitmap" ) ) ) )
368 aThumbSeq =
369 *static_cast<const uno::Sequence<sal_uInt8>*>(mAny.getValue());
371 sfx2::SaveOlePropertySet( xDocProps, mrStg,
372 &aThumbSeq, &aGuidSeq, &aHyperSeq);
374 else
376 sfx2::SaveOlePropertySet( xDocProps, mrStg,
377 NULL, &aGuidSeq, &aHyperSeq );
381 return sal_True;
384 // ---------------------------------------------------------------------------------------------
386 void PPTWriter::ImplWriteExtParaHeader( SvMemoryStream& rSt, sal_uInt32 nRef, sal_uInt32 nInstance, sal_uInt32 nSlideId )
388 if ( rSt.Tell() )
390 aBuExOutlineStream << (sal_uInt32)( ( EPP_PST_ExtendedParagraphHeaderAtom << 16 )
391 | ( nRef << 4 ) )
392 << (sal_uInt32)8
393 << (sal_uInt32)nSlideId
394 << (sal_uInt32)nInstance;
395 aBuExOutlineStream.Write( rSt.GetData(), rSt.Tell() );
399 // ---------------------------------------------------------------------------------------------
401 void PPTWriter::ImplCreateHeaderFooterStrings( SvStream& rStrm, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPagePropSet )
403 if ( rXPagePropSet.is() )
405 rtl::OUString aString;
406 ::com::sun::star::uno::Any aAny;
407 if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "HeaderText" ) ), sal_True ) )
409 if ( aAny >>= aString )
410 PPTWriter::WriteCString( rStrm, aString, 1 );
412 if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FooterText" ) ), sal_True ) )
414 if ( aAny >>= aString )
415 PPTWriter::WriteCString( rStrm, aString, 2 );
417 if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "DateTimeText" ) ), sal_True ) )
419 if ( aAny >>= aString )
420 PPTWriter::WriteCString( rStrm, aString, 0 );
425 // ---------------------------------------------------------------------------------------------
427 void PPTWriter::ImplCreateHeaderFooters( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPagePropSet )
429 if ( rXPagePropSet.is() )
431 sal_Bool bVal = sal_False;
432 sal_uInt32 nVal = 0;
433 ::com::sun::star::uno::Any aAny;
434 if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsHeaderVisible" ) ), sal_True ) )
436 if ( ( aAny >>= bVal ) && bVal )
437 nVal |= 0x100000;
439 if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsFooterVisible" ) ), sal_True ) )
441 if ( ( aAny >>= bVal ) && bVal )
442 nVal |= 0x200000;
444 if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsDateTimeVisible" ) ), sal_True ) )
446 if ( ( aAny >>= bVal ) && bVal )
447 nVal |= 0x010000;
449 if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsPageNumberVisible" ) ), sal_True ) )
451 if ( ( aAny >>= bVal ) && bVal )
452 nVal |= 0x080000;
454 if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsDateTimeFixed" ) ), sal_True ) )
456 if ( ( aAny >>= bVal ) && !bVal )
457 nVal |= 0x20000;
458 else
459 nVal |= 0x40000;
461 if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "DateTimeFormat" ) ), sal_True ) )
463 sal_Int32 nFormat = *(sal_Int32*)aAny.getValue();
464 SvxDateFormat eDateFormat = (SvxDateFormat)( nFormat & 0xf );
465 SvxTimeFormat eTimeFormat = (SvxTimeFormat)( ( nFormat >> 4 ) & 0xf );
466 switch( eDateFormat )
468 case SVXDATEFORMAT_F :
469 nFormat = 1;
470 break;
471 case SVXDATEFORMAT_D :
472 nFormat = 2;
473 break;
474 case SVXDATEFORMAT_C :
475 nFormat = 4;
476 break;
477 default:
478 case SVXDATEFORMAT_A :
479 nFormat = 0;
481 switch( eTimeFormat )
483 case SVXTIMEFORMAT_24_HM :
484 nFormat = 9;
485 break;
486 case SVXTIMEFORMAT_12_HM :
487 nFormat = 11;
488 break;
489 case SVXTIMEFORMAT_24_HMS :
490 nFormat = 10;
491 break;
492 case SVXTIMEFORMAT_12_HMS :
493 nFormat = 12;
494 break;
495 default:
496 break;
498 nVal |= nFormat;
501 mpPptEscherEx->OpenContainer( EPP_HeadersFooters, 0 );
502 mpPptEscherEx->AddAtom( 4, EPP_HeadersFootersAtom );
503 *mpStrm << nVal;
504 ImplCreateHeaderFooterStrings( *mpStrm, rXPagePropSet );
505 mpPptEscherEx->CloseContainer();
509 // ---------------------------------------------------------------------------------------------
511 sal_Bool PPTWriter::ImplCreateDocument()
513 sal_uInt32 i;
514 sal_uInt16 nSlideType = EPP_SLIDESIZE_TYPECUSTOM;
516 sal_uInt32 nWidth = maDestPageSize.Width;
517 sal_uInt32 nHeight = maDestPageSize.Height;
519 if ( ( nWidth == 0x1680 ) && ( nHeight == 0x10e0 ) )
520 nSlideType = EPP_SLIDESIZE_TYPEONSCREEN;
521 else if ( ( nWidth == 0x1200 ) && ( nHeight == 0x240 ) )
522 nSlideType = EPP_SLIDESIZE_TYPEBANNER;
523 else if ( ( nWidth == 0x1950 ) && ( nHeight == 0x10e0 ) )
524 nSlideType = EPP_SLIDESIZE_TYPE35MM;
525 else if ( ( nWidth == 0x1860 ) && ( nHeight == 0x10e0 ) )
526 nSlideType = EPP_SLIDESIZE_TYPEA4PAPER;
528 mpPptEscherEx->OpenContainer( EPP_Document );
529 // CREATE DOCUMENT ATOM
530 mpPptEscherEx->AddAtom( 40, EPP_DocumentAtom, 1 );
531 *mpStrm << nWidth // Slide Size in Master coordinates X
532 << nHeight // " " " " " Y
533 << (INT32)maNotesPageSize.Width // Notes Page Size X
534 << (INT32)maNotesPageSize.Height // " " " Y
535 << (INT32)1 << (INT32)2; // the scale used when the Powerpoint document is embedded. the default is 1:2
536 mpPptEscherEx->InsertPersistOffset( EPP_MAINNOTESMASTER_PERSIST_KEY, mpStrm->Tell() );
537 *mpStrm << (sal_uInt32)0 // Reference to NotesMaster ( 0 if none );
538 << (sal_uInt32)0 // Reference to HandoutMaster ( 0 if none );
539 << (sal_Int16)1 // Number of the first slide;
540 << nSlideType // Size of the document slides ( default: EPP_SLIDESIZETYPEONSCREEN )
541 << (sal_uInt8)0 // bool1 indicates if document was saved with embedded true type fonts
542 << (sal_uInt8)0 // bool1 indicates if the placeholders on the title slide are omitted
543 << (sal_uInt8)0 // bool1 right to left ( flag for Bidi version )
544 << (sal_uInt8)1; // bool1 visibility of comments shapes
546 mpPptEscherEx->PtInsert( EPP_Persist_Document, mpStrm->Tell() );
548 mpPptEscherEx->OpenContainer( EPP_HeadersFooters, 3 ); //Master footer (default)
549 mpPptEscherEx->AddAtom( 4, EPP_HeadersFootersAtom );
550 *mpStrm << (sal_uInt32)0x25000d;
551 if ( ImplGetPageByIndex( 0, MASTER ) )
552 ImplCreateHeaderFooterStrings( *mpStrm, mXPagePropSet );
553 mpPptEscherEx->CloseContainer();
554 mpPptEscherEx->OpenContainer( EPP_HeadersFooters, 4 ); //NotesMaster footer (default)
555 mpPptEscherEx->AddAtom( 4, EPP_HeadersFootersAtom );
556 *mpStrm << (sal_uInt32)0x3d000d;
557 if ( ImplGetPageByIndex( 0, NOTICE ) )
558 ImplCreateHeaderFooterStrings( *mpStrm, mXPagePropSet );
559 mpPptEscherEx->CloseContainer();
561 mpPptEscherEx->OpenContainer( EPP_SlideListWithText ); // Animation info fuer die Slides
563 sal_uInt32 nShapes;
564 sal_Bool bOtherThanPlaceHolders;
566 for ( i = 0; i < mnPages; i++ )
568 sal_uInt32 nPOffset, nPObjects;
569 sal_Bool bOutliner, bTitle;
571 bOtherThanPlaceHolders = bOutliner = bTitle = FALSE;
572 nPObjects = 0;
574 mpPptEscherEx->AddAtom( 20, EPP_SlidePersistAtom );
575 mpPptEscherEx->InsertPersistOffset( EPP_MAINSLIDE_PERSIST_KEY | i, mpStrm->Tell() );
576 *mpStrm << (sal_uInt32)0; // psrReference - logical reference to the slide persist object ( EPP_MAINSLIDE_PERSIST_KEY )
577 nPOffset = mpStrm->Tell();
578 *mpStrm << (sal_uInt32)0 // flags - only bit 3 used, if set then slide contains shapes other than placeholders
579 << (INT32)0 // numberTexts - number of placeholder texts stored with the persist object. Allows to display outline view without loading the slide persist objects
580 << (INT32)i + 0x100 // slideId - Unique slide identifier, used for OLE link monikers for example
581 << (sal_uInt32)0; // reserved, usualy 0
583 if ( !ImplGetPageByIndex( i, NORMAL ) ) // sehr aufregend: noch einmal ueber alle seiten
584 return FALSE;
585 ImplSetCurrentStyleSheet( ImplGetMasterIndex( NORMAL ) );
587 const PHLayout& rLayout = ImplGetLayout( mXPagePropSet );
589 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed >
590 aXName( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
592 if ( aXName.is() )
594 ::rtl::OUString aStr = aXName->getName();
595 ::rtl::OUString *pUStr = new ::rtl::OUString( aStr );
596 maSlideNameList.Insert( pUStr, LIST_APPEND );
598 else
599 maSlideNameList.Insert( new ::rtl::OUString(), LIST_APPEND );
601 nShapes = mXShapes->getCount();
603 sal_Bool bSecOutl = FALSE;
604 if ( nShapes && ( rLayout.bTitlePossible || rLayout.bOutlinerPossible ) )
606 for ( sal_uInt32 nIndex = 0; nIndex < nShapes; nIndex++ )
608 if ( !ImplGetShapeByIndex( nIndex ) )
609 continue;
611 if ( mbPresObj && ( ( mType == "presentation.Outliner" ) || ( mType == "presentation.Subtitle" ) ) )
613 if ( bOutliner == FALSE )
615 bOutliner = TRUE;
616 mnTextStyle = EPP_TEXTSTYLE_BODY;
617 sal_uInt32 nTextType = EPP_TEXTTYPE_Body;
618 if ( bSecOutl )
619 nTextType = EPP_TEXTTYPE_HalfBody;
620 else if ( mType == "presentation.Subtitle" )
621 nTextType = EPP_TEXTTYPE_CenterBody;
623 TextRuleEntry* pRule = new TextRuleEntry( i );
624 SvMemoryStream aExtBu( 0x200, 0x200 );
625 if ( !mbEmptyPresObj )
626 ImplGetText();
627 ImplWriteTextStyleAtom( *mpStrm, nTextType, nPObjects, pRule, aExtBu, NULL );
628 ImplWriteExtParaHeader( aExtBu, nPObjects++, nTextType, i + 0x100 );
629 maTextRuleList.Insert( (void*)pRule, LIST_APPEND );
630 if ( rLayout.bSecOutlinerPossible )
632 if ( ( nIndex + 1 ) < nShapes )
634 if ( ImplGetShapeByIndex( nIndex + 1 ) && mType == "presentation.Outliner" )
636 bSecOutl = TRUE;
637 TextRuleEntry* pTempRule = new TextRuleEntry( i );
638 SvMemoryStream aTmpStrm( 0x200, 0x200 );
639 if ( !mbEmptyPresObj )
640 ImplGetText();
641 ImplWriteTextStyleAtom( *mpStrm, nTextType, nPObjects, pTempRule, aTmpStrm, NULL );
642 ImplWriteExtParaHeader( aTmpStrm, nPObjects++, nTextType, i + 0x100 );
643 maTextRuleList.Insert( (void*)pTempRule, LIST_APPEND );
649 else if ( rLayout.bTitlePossible && ( mType == "presentation.TitleText" ) )
651 if ( bTitle == FALSE )
653 bTitle = TRUE;
654 mnTextStyle = EPP_TEXTSTYLE_TITLE;
655 TextRuleEntry* pRule = new TextRuleEntry( i );
656 SvMemoryStream aExtBu( 0x200, 0x200 );
657 if ( !mbEmptyPresObj )
658 ImplGetText();
659 ImplWriteTextStyleAtom( *mpStrm, EPP_TEXTTYPE_Title, nPObjects, pRule, aExtBu, NULL );
660 ImplWriteExtParaHeader( aExtBu, nPObjects++, EPP_TEXTTYPE_Title, i + 0x100 );
661 maTextRuleList.Insert( (void*)pRule, LIST_APPEND );
664 else
666 if ( mbEmptyPresObj )
667 nPObjects++;
668 else
669 bOtherThanPlaceHolders = TRUE; // muss noch auf background und leeren Title/outliner geprueft werden !!!
671 if ( bOutliner && bTitle && bOtherThanPlaceHolders )
672 break;
675 if ( nPObjects )
677 sal_uInt32 nOldPos = mpStrm->Tell();
678 mpStrm->Seek( nPOffset );
679 *mpStrm << (sal_uInt32)( ( bOtherThanPlaceHolders ) ? 4 : 0 );
680 *mpStrm << nPObjects;
681 mpStrm->Seek( nOldPos );
684 mpPptEscherEx->CloseContainer(); // EPP_SlideListWithText
686 mpPptEscherEx->OpenContainer( EPP_SlideListWithText, 2 ); // Animation info fuer die notes
687 for( i = 0; i < mnPages; i++ )
689 if ( !ImplGetPageByIndex( i, NOTICE ) )
690 return FALSE;
692 nShapes = mXShapes->getCount();
694 bOtherThanPlaceHolders = FALSE;
695 if ( nShapes )
697 for ( sal_uInt32 nIndex = 0; ( nIndex < nShapes ) && ( bOtherThanPlaceHolders == FALSE ); nIndex++ )
699 if ( ImplGetShapeByIndex( nIndex ) && ( mType != "drawing.Page" ) )
700 bOtherThanPlaceHolders = TRUE;
703 mpPptEscherEx->AddAtom( 20, EPP_SlidePersistAtom );
704 mpPptEscherEx->InsertPersistOffset( EPP_MAINNOTES_PERSIST_KEY | i, mpStrm->Tell() );
705 *mpStrm << (sal_uInt32)0
706 << (sal_uInt32)( ( bOtherThanPlaceHolders ) ? 4 : 0 )
707 << (INT32)0
708 << (INT32)i + 0x100
709 << (sal_uInt32)0;
711 mpPptEscherEx->CloseContainer(); // EPP_SlideListWithText
713 ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XPresentationSupplier >
714 aXPresSupplier( mXModel, ::com::sun::star::uno::UNO_QUERY ); ;
715 if ( aXPresSupplier.is() )
717 ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XPresentation >
718 aXPresentation( aXPresSupplier->getPresentation() );
719 if ( aXPresentation.is() )
721 mXPropSet = ::com::sun::star::uno::Reference<
722 ::com::sun::star::beans::XPropertySet >
723 ( aXPresentation, ::com::sun::star::uno::UNO_QUERY );
724 if ( mXPropSet.is() )
726 ::rtl::OUString aCustomShow;
727 sal_uInt32 nPenColor = 0x1000000;
728 INT32 nRestartTime = 0x7fffffff;
729 sal_Int16 nStartSlide = 0;
730 sal_Int16 nEndSlide = 0;
731 sal_uInt32 nFlags = 0; // Bit 0: Auto advance
732 // Bit 1 Skip builds ( do not allow slide effects )
733 // Bit 2 Use slide range
734 // Bit 3 Use named show
735 // Bit 4 Browse mode on
736 // Bit 5 Kiosk mode on
737 // Bit 7 loop continously
738 // Bit ? show scrollbar
740 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CustomShow" ) ) ) )
742 aCustomShow = ( *(::rtl::OUString*)mAny.getValue() );
743 if ( aCustomShow.getLength() )
745 nFlags |= 8;
748 if ( ( nFlags & 8 ) == 0 )
750 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "FirstPage" ) ) ) )
752 ::rtl::OUString aSlideName( *(::rtl::OUString*)mAny.getValue() );
753 ::rtl::OUString* pStr;
754 for ( pStr = (::rtl::OUString*)maSlideNameList.First(); pStr;
755 pStr = (::rtl::OUString*)maSlideNameList.Next(), nStartSlide++ )
757 if ( *pStr == aSlideName )
759 nStartSlide++;
760 nFlags |= 4;
761 nEndSlide = (sal_uInt16)mnPages;
762 break;
765 if ( !pStr )
766 nStartSlide = 0;
770 // if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "DiaName" ) ) ) )
771 // {
772 // }
773 // if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsAlwaysOnTop" ) ) ) )
774 // {
775 // }
776 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) ) ) )
778 sal_Bool bBool = sal_False;
779 mAny >>= bBool;
780 if ( !bBool )
781 nFlags |= 1;
784 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsEndless" ) ) ) ) // muesste eigendlich heissen IsNotEndless !=)"§()&
786 sal_Bool bBool = sal_False;
787 mAny >>= bBool;
788 if ( bBool )
789 nFlags |= 0x80;
791 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsFullScreen" ) ) ) )
793 sal_Bool bBool = sal_False;
794 mAny >>= bBool;
795 if ( !bBool )
796 nFlags |= 0x11;
798 // if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsMouseVisible" ) ) ) )
799 // {
800 // }
801 // if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ) ) )
802 // {
803 // }
804 // if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "StartWithNavigator" ) ) ) )
805 // {
806 // }
807 // if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "UsePen" ) ) ) )
808 // {
809 // }
810 mpPptEscherEx->AddAtom( 80, EPP_SSDocInfoAtom, 1 );
811 *mpStrm << nPenColor << nRestartTime << nStartSlide << nEndSlide;
813 sal_uInt32 nCustomShowNameLen = aCustomShow.getLength();
814 if ( nCustomShowNameLen > 31 )
815 nCustomShowNameLen = 31;
816 if ( nCustomShowNameLen ) // named show identifier
818 const sal_Unicode* pCustomShow = aCustomShow.getStr();
819 for ( i = 0; i < nCustomShowNameLen; i++ )
821 *mpStrm << (sal_uInt16)( pCustomShow[ i ] );
824 for ( i = nCustomShowNameLen; i < 32; i++, *mpStrm << (sal_uInt16)0 ) ;
826 *mpStrm << nFlags;
827 ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XCustomPresentationSupplier >
828 aXCPSup( mXModel, ::com::sun::star::uno::UNO_QUERY );
829 if ( aXCPSup.is() )
831 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
832 aXCont( aXCPSup->getCustomPresentations() );
833 if ( aXCont.is() )
835 ::com::sun::star::uno::Sequence< ::rtl::OUString> aNameSeq( aXCont->getElementNames() );
836 const ::rtl::OUString* pUString = aNameSeq.getArray();
837 sal_uInt32 nCount = aNameSeq.getLength();
838 if ( nCount )
840 mpPptEscherEx->OpenContainer( EPP_NamedShows );
841 sal_uInt32 nCustomShowIndex = 0;
842 for( i = 0; i < nCount; i++ ) // Anzahl der Custom Shows
844 if ( pUString[ i ].getLength() )
846 mpPptEscherEx->OpenContainer( EPP_NamedShow, nCustomShowIndex++ );
848 sal_uInt32 nNamedShowLen = pUString[ i ].getLength();
849 if ( nNamedShowLen > 31 )
850 nNamedShowLen = 31;
851 mpPptEscherEx->AddAtom( nNamedShowLen << 1, EPP_CString );
852 const sal_Unicode* pCustomShowName = pUString[ i ].getStr();
853 for ( sal_uInt32 k = 0; k < nNamedShowLen; *mpStrm << (sal_uInt16)( pCustomShowName[ k++ ] ) ) ;
854 mAny = aXCont->getByName( pUString[ i ] );
855 if ( mAny.getValue() )
858 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > aXIC;
859 if ( mAny >>= aXIC )
861 mpPptEscherEx->BeginAtom();
863 INT32 nSlideCount = aXIC->getCount();
864 for ( INT32 j = 0; j < nSlideCount; j++ ) // Anzahl der Slides
866 mAny = aXIC->getByIndex( j );
867 if ( mAny.getValue() )
869 ::com::sun::star::uno::Reference<
870 ::com::sun::star::drawing::XDrawPage > aXDrawPage;
871 if ( mAny >>= aXDrawPage )
873 ::com::sun::star::uno::Reference<
874 ::com::sun::star::container::XNamed >
875 aXName( aXDrawPage, ::com::sun::star::uno::UNO_QUERY );
876 if ( aXName.is() )
878 ::rtl::OUString aSlideName( aXName->getName() );
879 sal_uInt32 nPageNumber = 0;
880 for ( ::rtl::OUString* pSlideName = (::rtl::OUString*)maSlideNameList.First();
881 pSlideName;
882 pSlideName = (::rtl::OUString*)maSlideNameList.Next(), nPageNumber++ )
884 if ( *pSlideName == aSlideName )
886 *mpStrm << (sal_uInt32)( nPageNumber + 0x100 ); // unique slide id
887 break;
894 mpPptEscherEx->EndAtom( EPP_NamedShowSlides );
897 mpPptEscherEx->CloseContainer(); // EPP_NamedShow
900 mpPptEscherEx->CloseContainer(); // EPP_NamedShows
907 mpPptEscherEx->AddAtom( 0, EPP_EndDocument );
908 mpPptEscherEx->CloseContainer(); // EPP_Document
909 return TRUE;
912 // ---------------------------------------------------------------------------------------------
914 sal_Bool PPTWriter::ImplCreateHyperBlob( SvMemoryStream& rStrm )
916 sal_uInt32 nCurrentOfs, nParaOfs, nParaCount = 0;
917 // SfxOlePropertySection does this...
918 // rStrm << (sal_uInt32)0x41; // property type VT_BLOB
919 nParaOfs = rStrm.Tell();
920 rStrm << (sal_uInt32)0; // property size
921 rStrm << (sal_uInt32)0; // property count
923 for ( EPPTHyperlink* pLink = (EPPTHyperlink*)maHyperlink.First(); pLink; pLink = (EPPTHyperlink*)maHyperlink.Next() )
925 nParaCount += 6;
926 rStrm << (sal_uInt32)3 // Type VT_I4
927 << (sal_uInt32)7 // (VTI4 - Private1)
928 << (sal_uInt32)3 // Type VT_I4
929 << (sal_uInt32)6 // (VTI4 - Private2)
930 << (sal_uInt32)3 // Type VT_I4
931 << (sal_uInt32)0; // (VTI4 - Private3)
933 // INFO
934 // HIWORD: = 0 : do not change anything
935 // = 1 : replace the hyperlink with the target and subadress in the following two VTLPWSTR
936 // = 2 : delete the hyperlink
937 // LOWORD: = 0 : graphic shown as background (link)
938 // = 1 : graphic shown as shape (link)
939 // = 2 : graphic is used to fill a shape
940 // = 3 : graphic used to fill a shape outline (future use)
941 // = 4 : hyperlink attached to a shape
942 // = 5 : " " " " (Word) field
943 // = 6 : " " " " (Excel) range
944 // = 7 : " " " " (PPT) text range
945 // = 8 : " " " " (Project) task
947 sal_uInt32 nUrlLen = pLink->aURL.Len();
948 const sal_Unicode* pUrl = pLink->aURL.GetBuffer();
950 sal_uInt32 nInfo = 7;
952 rStrm << (sal_uInt32)3 // Type VT_I4
953 << nInfo; // Info
955 switch( pLink->nType & 0xff )
957 case 1 : // click action to slidenumber
959 rStrm << (sal_uInt32)0x1f << (sal_uInt32)1 << (sal_uInt32)0; // path
960 rStrm << (sal_uInt32)0x1f << (sal_uInt32)( nUrlLen + 1 );
961 for ( sal_uInt32 i = 0; i < nUrlLen; i++ )
963 rStrm << pUrl[ i ];
965 rStrm << (sal_uInt16)0;
967 break;
968 case 2 :
970 sal_uInt32 i;
972 rStrm << (sal_uInt32)0x1f
973 << (sal_uInt32)( nUrlLen + 1 );
974 for ( i = 0; i < nUrlLen; i++ )
976 rStrm << pUrl[ i ];
978 if ( ! ( i & 1 ) )
979 rStrm << (sal_uInt16)0;
980 rStrm << (sal_uInt16)0
981 << (sal_uInt32)0x1f
982 << (sal_uInt32)1
983 << (sal_uInt32)0;
985 break;
988 nCurrentOfs = rStrm.Tell();
989 rStrm.Seek( nParaOfs );
990 rStrm << (sal_uInt32)( nCurrentOfs - ( nParaOfs + 4 ) );
991 rStrm << nParaCount;
992 rStrm.Seek( nCurrentOfs );
993 return TRUE;
996 PHLayout& PPTWriter::ImplGetLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const
998 ::com::sun::star::uno::Any aAny;
999 sal_Int16 nLayout = 20;
1000 if ( GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Layout" ) ) ), sal_True )
1001 aAny >>= nLayout;
1003 if ( ( nLayout >= 21 ) && ( nLayout <= 26 ) ) // NOTES _> HANDOUT6
1004 nLayout = 20;
1005 if ( ( nLayout >= 27 ) && ( nLayout <= 30 ) ) // VERTICAL LAYOUT
1006 nLayout -= 6;
1007 else if ( nLayout > 30 )
1008 nLayout = 20;
1009 return pPHLayout[ nLayout ];
1013 // ---------------------------------------------------------------------------------------------
1015 sal_Bool PPTWriter::ImplCreateMaster( sal_uInt32 nPageNum )
1017 if ( !ImplGetPageByIndex( nPageNum, MASTER ) )
1018 return FALSE;
1019 ImplSetCurrentStyleSheet( nPageNum );
1021 if ( !ImplGetPropertyValue( mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ) ) ) // Backgroundshape laden
1022 return FALSE;
1023 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXBackgroundPropSet;
1024 if ( !( mAny >>= aXBackgroundPropSet ) )
1025 return FALSE;
1027 sal_uInt32 nFillColor = 0xffffff;
1028 sal_uInt32 nFillBackColor = 0x000000;
1030 ::com::sun::star::drawing::FillStyle aFS = ::com::sun::star::drawing::FillStyle_NONE;
1031 if ( ImplGetPropertyValue( aXBackgroundPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ) ) ) )
1032 mAny >>= aFS;
1033 switch ( aFS )
1035 case ::com::sun::star::drawing::FillStyle_GRADIENT :
1037 if ( ImplGetPropertyValue( aXBackgroundPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ) ) ) )
1039 nFillColor = EscherPropertyContainer::GetGradientColor( (::com::sun::star::awt::Gradient*)mAny.getValue(), 0 );
1040 nFillBackColor = EscherPropertyContainer::GetGradientColor( (::com::sun::star::awt::Gradient*)mAny.getValue(), 1 );
1043 break;
1045 case ::com::sun::star::drawing::FillStyle_SOLID :
1047 if ( ImplGetPropertyValue( aXBackgroundPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ) ) )
1049 nFillColor = mpPptEscherEx->GetColor( *((sal_uInt32*)mAny.getValue()) );
1050 nFillBackColor = nFillColor ^ 0xffffff;
1053 break;
1055 default:
1056 break;
1059 mpPptEscherEx->PtReplaceOrInsert( EPP_Persist_MainMaster | nPageNum, mpStrm->Tell() );
1060 mpPptEscherEx->OpenContainer( EPP_MainMaster );
1061 mpPptEscherEx->AddAtom( 24, EPP_SlideAtom, 2 );
1062 *mpStrm << (INT32)EPP_LAYOUT_TITLEANDBODYSLIDE // slide layout -> title and body slide
1063 << (sal_uInt8)1 << (sal_uInt8)2 << (sal_uInt8)0 << (sal_uInt8)0 << (sal_uInt8)0 << (sal_uInt8)0 << (sal_uInt8)0 << (sal_uInt8)0 // placeholderID
1064 << (sal_uInt32)0 // master ID ( ist gleich null bei einer masterpage )
1065 << (sal_uInt32)0 // notes ID ( ist gleich null wenn keine notizen vorhanden )
1066 << (sal_uInt16)0 // Bit 1: Follow master objects, Bit 2: Follow master scheme, Bit 3: Follow master background
1067 << (sal_uInt16)0; // padword
1069 mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
1070 *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x99cc00 << (sal_uInt32)0xcc3333 << (sal_uInt32)0xffcccc << (sal_uInt32)0xb2b2b2;
1071 mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
1072 *mpStrm << (sal_uInt32)0xff0000 << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x00ffff << (sal_uInt32)0x0099ff << (sal_uInt32)0xffff00 << (sal_uInt32)0x0000ff << (sal_uInt32)0x969696;
1073 mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
1074 *mpStrm << (sal_uInt32)0xccffff << (sal_uInt32)0x000000 << (sal_uInt32)0x336666 << (sal_uInt32)0x008080 << (sal_uInt32)0x339933 << (sal_uInt32)0x000080 << (sal_uInt32)0xcc3300 << (sal_uInt32)0x66ccff;
1075 mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
1076 *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x333333 << (sal_uInt32)0x000000 << (sal_uInt32)0xdddddd << (sal_uInt32)0x808080 << (sal_uInt32)0x4d4d4d << (sal_uInt32)0xeaeaea;
1077 mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
1078 *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x66ccff << (sal_uInt32)0xff0000 << (sal_uInt32)0xcc00cc << (sal_uInt32)0xc0c0c0;
1079 mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
1080 *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0xc0c0c0 << (sal_uInt32)0xff6600 << (sal_uInt32)0x0000ff << (sal_uInt32)0x009900;
1081 mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 6 );
1082 *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0xff9933 << (sal_uInt32)0xccff99 << (sal_uInt32)0xcc00cc << (sal_uInt32)0xb2b2b2;
1084 for ( int nInstance = EPP_TEXTTYPE_Title; nInstance <= EPP_TEXTTYPE_QuarterBody; nInstance++ )
1086 if ( nInstance == EPP_TEXTTYPE_notUsed )
1087 continue;
1089 // the auto color is dependent to the page background,so we have to set a page that is in the right context
1090 if ( nInstance == EPP_TEXTTYPE_Notes )
1091 ImplGetPageByIndex( 0, NOTICE );
1092 else
1093 ImplGetPageByIndex( 0, MASTER );
1095 mpPptEscherEx->BeginAtom();
1097 sal_Bool bFirst = TRUE;
1098 sal_Bool bSimpleText = FALSE;
1100 *mpStrm << (sal_uInt16)5; // paragraph count
1102 for ( sal_uInt16 nLev = 0; nLev < 5; nLev++ )
1104 if ( nInstance >= EPP_TEXTTYPE_CenterBody )
1106 bFirst = FALSE;
1107 bSimpleText = TRUE;
1108 *mpStrm << nLev;
1110 mpStyleSheet->mpParaSheet[ nInstance ]->Write( *mpStrm, mpPptEscherEx, nLev, bFirst, bSimpleText, mXPagePropSet );
1111 mpStyleSheet->mpCharSheet[ nInstance ]->Write( *mpStrm, mpPptEscherEx, nLev, bFirst, bSimpleText, mXPagePropSet );
1112 bFirst = FALSE;
1114 mpPptEscherEx->EndAtom( EPP_TxMasterStyleAtom, 0, nInstance );
1116 ImplGetPageByIndex( nPageNum, MASTER );
1118 EscherSolverContainer aSolverContainer;
1120 mpPptEscherEx->OpenContainer( EPP_PPDrawing );
1121 mpPptEscherEx->OpenContainer( ESCHER_DgContainer );
1123 mpPptEscherEx->EnterGroup(0,0);
1124 ImplWritePage( pPHLayout[ 0 ], aSolverContainer, MASTER, TRUE ); // Die Shapes der Seite werden im PPT Dok. erzeugt
1125 mpPptEscherEx->LeaveGroup();
1127 ImplWriteBackground( aXBackgroundPropSet );
1129 aSolverContainer.WriteSolver( *mpStrm );
1131 mpPptEscherEx->CloseContainer(); // ESCHER_DgContainer
1132 mpPptEscherEx->CloseContainer(); // EPP_Drawing
1133 mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 1 );
1134 *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x99cc00 << (sal_uInt32)0xcc3333 << (sal_uInt32)0xffcccc << (sal_uInt32)0xb2b2b2;
1136 if ( aBuExMasterStream.Tell() )
1138 ImplProgTagContainer( mpStrm, &aBuExMasterStream );
1140 mpPptEscherEx->CloseContainer(); // EPP_MainMaster
1141 return TRUE;
1144 // ---------------------------------------------------------------------------------------------
1146 sal_Bool PPTWriter::ImplCreateMainNotes()
1148 if ( !ImplGetPageByIndex( 0, NOTICE ) )
1149 return FALSE;
1150 ImplSetCurrentStyleSheet( 0 );
1152 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPageTarget >
1153 aXMasterPageTarget( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
1155 if ( !aXMasterPageTarget.is() )
1156 return FALSE;
1158 mXDrawPage = aXMasterPageTarget->getMasterPage();
1159 if ( !mXDrawPage.is() )
1160 return FALSE;
1162 mXPropSet = ::com::sun::star::uno::Reference<
1163 ::com::sun::star::beans::XPropertySet >
1164 ( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
1165 if ( !mXPropSet.is() )
1166 return FALSE;
1168 mXShapes = ::com::sun::star::uno::Reference<
1169 ::com::sun::star::drawing::XShapes >
1170 ( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
1171 if ( !mXShapes.is() )
1172 return FALSE;
1174 EscherSolverContainer aSolverContainer;
1176 mpPptEscherEx->PtReplaceOrInsert( EPP_Persist_MainNotes, mpStrm->Tell() );
1177 mpPptEscherEx->OpenContainer( EPP_Notes );
1178 mpPptEscherEx->AddAtom( 8, EPP_NotesAtom, 1 );
1179 *mpStrm << (sal_uInt32)0x80000001 // Number that identifies this slide
1180 << (sal_uInt32)0; // follow nothing
1181 mpPptEscherEx->OpenContainer( EPP_PPDrawing );
1182 mpPptEscherEx->OpenContainer( ESCHER_DgContainer );
1183 mpPptEscherEx->EnterGroup(0,0);
1185 ImplWritePage( pPHLayout[ 20 ], aSolverContainer, NOTICE, TRUE );
1187 mpPptEscherEx->LeaveGroup();
1188 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
1189 mpPptEscherEx->AddShape( ESCHER_ShpInst_Rectangle, 0xc00 );
1190 EscherPropertyContainer aPropOpt;
1191 aPropOpt.AddOpt( ESCHER_Prop_fillColor, 0xffffff ); // stock valued fill color
1192 aPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0 );
1193 aPropOpt.AddOpt( ESCHER_Prop_fillRectRight, 0x68bdde );
1194 aPropOpt.AddOpt( ESCHER_Prop_fillRectBottom, 0x8b9f8e );
1195 aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x120012 );
1196 aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0 );
1197 aPropOpt.AddOpt( ESCHER_Prop_bWMode, ESCHER_wDontShow );
1198 aPropOpt.AddOpt( ESCHER_Prop_fBackground, 0x10001 ); // if true, this is the background shape
1199 aPropOpt.Commit( *mpStrm );
1200 mpPptEscherEx->CloseContainer(); // ESCHER_SpContainer
1202 aSolverContainer.WriteSolver( *mpStrm );
1204 mpPptEscherEx->CloseContainer(); // ESCHER_DgContainer
1205 mpPptEscherEx->CloseContainer(); // EPP_Drawing
1206 mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 1 );
1207 *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x99cc00 << (sal_uInt32)0xcc3333 << (sal_uInt32)0xffcccc << (sal_uInt32)0xb2b2b2;
1208 mpPptEscherEx->CloseContainer(); // EPP_Notes
1209 return TRUE;
1212 // ---------------------------------------------------------------------------------------------
1214 static rtl::OUString getInitials( const rtl::OUString& rName )
1216 rtl::OUString sInitials;
1218 const sal_Unicode * pStr = rName.getStr();
1219 sal_Int32 nLength = rName.getLength();
1221 while( nLength )
1223 // skip whitespace
1224 while( nLength && (*pStr <= ' ') )
1226 nLength--; pStr++;
1229 // take letter
1230 if( nLength )
1232 sInitials += rtl::OUString( *pStr );
1233 nLength--; pStr++;
1236 // skip letters until whitespace
1237 while( nLength && (*pStr > ' ') )
1239 nLength--; pStr++;
1243 return sInitials;
1246 void ImplExportComments( uno::Reference< drawing::XDrawPage > xPage, SvMemoryStream& rBinaryTagData10Atom )
1250 uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xPage, uno::UNO_QUERY_THROW );
1251 uno::Reference< office::XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
1253 sal_Int32 nIndex = 1;
1255 while( xAnnotationEnumeration->hasMoreElements() )
1257 EscherExContainer aComment10( rBinaryTagData10Atom, EPP_Comment10 );
1259 uno::Reference< office::XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement() );
1261 geometry::RealPoint2D aRealPoint2D( xAnnotation->getPosition() );
1262 MapMode aMapDest( MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 ) );
1263 Point aPoint( OutputDevice::LogicToLogic( Point( static_cast< sal_Int32 >( aRealPoint2D.X * 100.0 ),
1264 static_cast< sal_Int32 >( aRealPoint2D.Y * 100.0 ) ), MAP_100TH_MM, aMapDest ) );
1266 rtl::OUString sAuthor( xAnnotation->getAuthor() );
1267 uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
1268 rtl::OUString sText( xText->getString() );
1269 rtl::OUString sInitials( getInitials( sAuthor ) );
1270 util::DateTime aDateTime( xAnnotation->getDateTime() );
1271 if ( sAuthor.getLength() )
1272 PPTWriter::WriteCString( rBinaryTagData10Atom, sAuthor, 0 );
1273 if ( sText.getLength() )
1274 PPTWriter::WriteCString( rBinaryTagData10Atom, sText, 1 );
1275 if ( sInitials.getLength() )
1276 PPTWriter::WriteCString( rBinaryTagData10Atom, sInitials, 2 );
1278 sal_Int16 nMilliSeconds = aDateTime.HundredthSeconds * 10;
1279 EscherExAtom aCommentAtom10( rBinaryTagData10Atom, EPP_CommentAtom10 );
1280 rBinaryTagData10Atom << nIndex++
1281 << aDateTime.Year
1282 << aDateTime.Month
1283 << aDateTime.Day // todo: day of week
1284 << aDateTime.Day
1285 << aDateTime.Hours
1286 << aDateTime.Minutes
1287 << aDateTime.Seconds
1288 << nMilliSeconds
1289 << static_cast< sal_Int32 >( aPoint.X() )
1290 << static_cast< sal_Int32 >( aPoint.Y() );
1294 catch ( uno::Exception& )
1299 // ---------------------------------------------------------------------------------------------
1301 sal_Bool PPTWriter::ImplCreateSlide( sal_uInt32 nPageNum )
1303 ::com::sun::star::uno::Any aAny;
1305 if ( !ImplGetPageByIndex( nPageNum, NORMAL ) )
1306 return FALSE;
1307 sal_uInt32 nMasterID = ImplGetMasterIndex( NORMAL );
1308 ImplSetCurrentStyleSheet( nMasterID );
1309 nMasterID |= 0x80000000;
1311 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXBackgroundPropSet;
1312 sal_Bool bHasBackground = GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ) );
1313 if ( bHasBackground )
1314 bHasBackground = ( aAny >>= aXBackgroundPropSet );
1316 sal_uInt16 nMode = 7; // Bit 1: Follow master objects, Bit 2: Follow master scheme, Bit 3: Follow master background
1317 if ( bHasBackground )
1318 nMode &=~4;
1320 /* sj: Don't know what's IsBackgroundVisible for, have to ask cl
1321 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundVisible" ) ) ) )
1323 sal_Bool bBackgroundVisible;
1324 if ( aAny >>= bBackgroundVisible )
1326 if ( bBackgroundVisible )
1327 nMode &= ~4;
1331 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundObjectsVisible" ) ) ) )
1333 sal_Bool bBackgroundObjectsVisible = sal_False;
1334 if ( aAny >>= bBackgroundObjectsVisible )
1336 if ( !bBackgroundObjectsVisible )
1337 nMode &= ~1;
1341 const PHLayout& rLayout = ImplGetLayout( mXPagePropSet );
1342 mpPptEscherEx->PtReplaceOrInsert( EPP_Persist_Slide | nPageNum, mpStrm->Tell() );
1343 mpPptEscherEx->OpenContainer( EPP_Slide );
1344 mpPptEscherEx->AddAtom( 24, EPP_SlideAtom, 2 );
1345 *mpStrm << rLayout.nLayout;
1346 mpStrm->Write( rLayout.nPlaceHolder, 8 ); // placeholderIDs ( 8Stueck )
1347 *mpStrm << (sal_uInt32)nMasterID // master ID ( ist gleich 0x80000000 bei einer masterpage )
1348 << (sal_uInt32)nPageNum + 0x100 // notes ID ( ist gleich null wenn keine notizen vorhanden )
1349 << nMode
1350 << (sal_uInt16)0; // padword
1352 mnDiaMode = 0;
1353 sal_Bool bVisible = sal_True;
1354 ::com::sun::star::presentation::FadeEffect eFe = ::com::sun::star::presentation::FadeEffect_NONE;
1356 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ) ) )
1357 aAny >>= bVisible;
1358 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Change" ) ) ) )
1360 switch ( *(INT32*)aAny.getValue() )
1362 case 1 : // automatisch
1363 mnDiaMode++;
1364 case 2 : // halbautomatisch
1365 mnDiaMode++;
1366 default :
1367 case 0 : // manuell
1368 break;
1371 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Effect" ) ) ) )
1372 aAny >>= eFe;
1374 sal_uInt32 nSoundRef = 0;
1375 sal_Bool bIsSound = sal_False;
1376 sal_Bool bStopSound = sal_False;
1377 sal_Bool bLoopSound = sal_False;
1379 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ) ) )
1381 rtl::OUString aSoundURL;
1382 if ( aAny >>= aSoundURL )
1384 nSoundRef = maSoundCollection.GetId( aSoundURL );
1385 bIsSound = sal_True;
1387 else
1388 aAny >>= bStopSound;
1390 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "LoopSound" ) ) ) )
1391 aAny >>= bLoopSound;
1394 sal_Bool bNeedsSSSlideInfoAtom = ( bVisible == FALSE )
1395 || ( mnDiaMode == 2 )
1396 || ( bIsSound )
1397 || ( bStopSound )
1398 || ( eFe != ::com::sun::star::presentation::FadeEffect_NONE );
1399 if ( bNeedsSSSlideInfoAtom )
1401 sal_uInt8 nDirection = 0;
1402 sal_uInt8 nTransitionType = 0;
1403 sal_uInt16 nBuildFlags = 1; // advange by mouseclick
1404 INT32 nSlideTime = 0; // muss noch !!!
1405 sal_uInt8 nSpeed = 1;
1407 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Speed" ) ) ) )
1409 ::com::sun::star::presentation::AnimationSpeed aAs;
1410 aAny >>= aAs;
1411 nSpeed = (sal_uInt8)aAs;
1413 sal_Int16 nTT = 0, nTST = 0;
1414 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TransitionType" ) ) )
1415 && ( aAny >>= nTT ) )
1417 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TransitionSubtype" ) ) )
1418 && ( aAny >>= nTST ) )
1420 switch( nTT )
1422 case animations::TransitionType::FADE :
1424 if ( nTST == animations::TransitionSubType::CROSSFADE )
1425 nTransitionType = PPT_TRANSITION_TYPE_SMOOTHFADE;
1426 else if ( nTST == animations::TransitionSubType::FADEOVERCOLOR )
1427 nTransitionType = PPT_TRANSITION_TYPE_FADE;
1429 break;
1430 case PPT_TRANSITION_TYPE_COMB :
1432 nTransitionType = PPT_TRANSITION_TYPE_COMB;
1433 if ( nTST == animations::TransitionSubType::COMBVERTICAL )
1434 nDirection++;
1436 break;
1437 case animations::TransitionType::PUSHWIPE :
1439 nTransitionType = PPT_TRANSITION_TYPE_PUSH;
1440 switch( nTST )
1442 case animations::TransitionSubType::FROMRIGHT: nDirection = 0; break;
1443 case animations::TransitionSubType::FROMBOTTOM: nDirection = 1; break;
1444 case animations::TransitionSubType::FROMLEFT: nDirection = 2; break;
1445 case animations::TransitionSubType::FROMTOP: nDirection = 3; break;
1448 break;
1449 case animations::TransitionType::PINWHEELWIPE :
1451 nTransitionType = PPT_TRANSITION_TYPE_WHEEL;
1452 switch( nTST )
1454 case animations::TransitionSubType::ONEBLADE: nDirection = 1; break;
1455 case animations::TransitionSubType::TWOBLADEVERTICAL : nDirection = 2; break;
1456 case animations::TransitionSubType::THREEBLADE : nDirection = 3; break;
1457 case animations::TransitionSubType::FOURBLADE: nDirection = 4; break;
1458 case animations::TransitionSubType::EIGHTBLADE: nDirection = 8; break;
1461 break;
1462 case animations::TransitionType::FANWIPE :
1464 nTransitionType = PPT_TRANSITION_TYPE_WEDGE;
1466 break;
1467 case animations::TransitionType::ELLIPSEWIPE :
1469 nTransitionType = PPT_TRANSITION_TYPE_CIRCLE;
1471 break;
1472 case animations::TransitionType::FOURBOXWIPE :
1474 nTransitionType = PPT_TRANSITION_TYPE_PLUS;
1476 break;
1477 case animations::TransitionType::IRISWIPE :
1479 nTransitionType = PPT_TRANSITION_TYPE_DIAMOND;
1481 break;
1485 if ( !nTransitionType )
1487 switch ( eFe )
1489 default :
1490 case ::com::sun::star::presentation::FadeEffect_RANDOM :
1491 nTransitionType = PPT_TRANSITION_TYPE_RANDOM;
1492 break;
1494 case ::com::sun::star::presentation::FadeEffect_HORIZONTAL_STRIPES :
1495 nDirection++;
1496 case ::com::sun::star::presentation::FadeEffect_VERTICAL_STRIPES :
1497 nTransitionType = PPT_TRANSITION_TYPE_BLINDS;
1498 break;
1500 case ::com::sun::star::presentation::FadeEffect_VERTICAL_CHECKERBOARD :
1501 nDirection++;
1502 case ::com::sun::star::presentation::FadeEffect_HORIZONTAL_CHECKERBOARD :
1503 nTransitionType = PPT_TRANSITION_TYPE_CHECKER;
1504 break;
1506 case ::com::sun::star::presentation::FadeEffect_MOVE_FROM_UPPERLEFT :
1507 nDirection++;
1508 case ::com::sun::star::presentation::FadeEffect_MOVE_FROM_UPPERRIGHT :
1509 nDirection++;
1510 case ::com::sun::star::presentation::FadeEffect_MOVE_FROM_LOWERLEFT :
1511 nDirection++;
1512 case ::com::sun::star::presentation::FadeEffect_MOVE_FROM_LOWERRIGHT :
1513 nDirection++;
1514 case ::com::sun::star::presentation::FadeEffect_MOVE_FROM_TOP :
1515 nDirection++;
1516 case ::com::sun::star::presentation::FadeEffect_MOVE_FROM_LEFT :
1517 nDirection++;
1518 case ::com::sun::star::presentation::FadeEffect_MOVE_FROM_BOTTOM :
1519 nDirection++;
1520 case ::com::sun::star::presentation::FadeEffect_MOVE_FROM_RIGHT :
1521 nTransitionType = PPT_TRANSITION_TYPE_COVER;
1522 break;
1524 case ::com::sun::star::presentation::FadeEffect_DISSOLVE :
1525 nTransitionType = PPT_TRANSITION_TYPE_DISSOLVE;
1526 break;
1528 case ::com::sun::star::presentation::FadeEffect_VERTICAL_LINES :
1529 nDirection++;
1530 case ::com::sun::star::presentation::FadeEffect_HORIZONTAL_LINES :
1531 nTransitionType = PPT_TRANSITION_TYPE_RANDOM_BARS;
1532 break;
1534 case ::com::sun::star::presentation::FadeEffect_CLOSE_HORIZONTAL :
1535 nDirection++;
1536 case ::com::sun::star::presentation::FadeEffect_OPEN_HORIZONTAL :
1537 nDirection++;
1538 case ::com::sun::star::presentation::FadeEffect_CLOSE_VERTICAL :
1539 nDirection++;
1540 case ::com::sun::star::presentation::FadeEffect_OPEN_VERTICAL :
1541 nTransitionType = PPT_TRANSITION_TYPE_SPLIT;
1542 break;
1544 case ::com::sun::star::presentation::FadeEffect_FADE_FROM_UPPERLEFT :
1545 nDirection++;
1546 case ::com::sun::star::presentation::FadeEffect_FADE_FROM_UPPERRIGHT :
1547 nDirection++;
1548 case ::com::sun::star::presentation::FadeEffect_FADE_FROM_LOWERLEFT :
1549 nDirection++;
1550 case ::com::sun::star::presentation::FadeEffect_FADE_FROM_LOWERRIGHT :
1551 nDirection += 4;
1552 nTransitionType = PPT_TRANSITION_TYPE_STRIPS;
1553 break;
1555 case ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_LOWERRIGHT :
1556 nDirection++;
1557 case ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_LOWERLEFT :
1558 nDirection++;
1559 case ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_UPPERRIGHT :
1560 nDirection++;
1561 case ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_UPPERLEFT :
1562 nDirection++;
1563 case ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_BOTTOM :
1564 nDirection++;
1565 case ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_RIGHT :
1566 nDirection++;
1567 case ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_TOP :
1568 nDirection++;
1569 case ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_LEFT :
1570 nTransitionType = PPT_TRANSITION_TYPE_PULL;
1571 break;
1573 case ::com::sun::star::presentation::FadeEffect_FADE_FROM_TOP :
1574 nDirection++;
1575 case ::com::sun::star::presentation::FadeEffect_FADE_FROM_LEFT :
1576 nDirection++;
1577 case ::com::sun::star::presentation::FadeEffect_FADE_FROM_BOTTOM :
1578 nDirection++;
1579 case ::com::sun::star::presentation::FadeEffect_FADE_FROM_RIGHT :
1580 nTransitionType = PPT_TRANSITION_TYPE_WIPE;
1581 break;
1583 case ::com::sun::star::presentation::FadeEffect_ROLL_FROM_TOP :
1584 nDirection++;
1585 case ::com::sun::star::presentation::FadeEffect_ROLL_FROM_LEFT :
1586 nDirection++;
1587 case ::com::sun::star::presentation::FadeEffect_ROLL_FROM_BOTTOM :
1588 nDirection++;
1589 case ::com::sun::star::presentation::FadeEffect_ROLL_FROM_RIGHT :
1590 nTransitionType = PPT_TRANSITION_TYPE_WIPE;
1591 break;
1593 case ::com::sun::star::presentation::FadeEffect_FADE_TO_CENTER :
1594 nDirection++;
1595 case ::com::sun::star::presentation::FadeEffect_FADE_FROM_CENTER :
1596 nTransitionType = PPT_TRANSITION_TYPE_ZOOM;
1597 break;
1599 case ::com::sun::star::presentation::FadeEffect_NONE :
1600 nDirection = 2;
1601 break;
1604 if ( mnDiaMode == 2 ) // automatic ?
1605 nBuildFlags |= 0x400;
1606 if ( bVisible == FALSE )
1607 nBuildFlags |= 4;
1608 if ( bIsSound )
1609 nBuildFlags |= 16;
1610 if ( bLoopSound )
1611 nBuildFlags |= 64;
1612 if ( bStopSound )
1613 nBuildFlags |= 256;
1615 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Duration" ) ) ) )// duration of this slide
1616 nSlideTime = *(INT32*)aAny.getValue() << 10; // in ticks
1619 mpPptEscherEx->AddAtom( 16, EPP_SSSlideInfoAtom );
1620 *mpStrm << nSlideTime // standtime in ticks
1621 << nSoundRef
1622 << nDirection
1623 << nTransitionType
1624 << nBuildFlags
1625 << nSpeed
1626 << (sal_uInt8)0 << (sal_uInt8)0 << (sal_uInt8)0;
1629 ImplCreateHeaderFooters( mXPagePropSet );
1631 EscherSolverContainer aSolverContainer;
1632 mpPptEscherEx->OpenContainer( EPP_PPDrawing );
1633 mpPptEscherEx->OpenContainer( ESCHER_DgContainer );
1634 mpPptEscherEx->EnterGroup(0,0);
1635 ImplWritePage( rLayout, aSolverContainer, NORMAL, FALSE, nPageNum ); // Die Shapes der Seite werden im PPT Dok. erzeugt
1636 mpPptEscherEx->LeaveGroup();
1638 if ( bHasBackground )
1639 ImplWriteBackground( aXBackgroundPropSet );
1640 else
1642 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
1643 mpPptEscherEx->AddShape( ESCHER_ShpInst_Rectangle, 0xc00 ); // Flags: Connector | Background | HasSpt
1644 EscherPropertyContainer aPropOpt;
1645 aPropOpt.AddOpt( ESCHER_Prop_fillRectRight, PPTtoEMU( maDestPageSize.Width ) );
1646 aPropOpt.AddOpt( ESCHER_Prop_fillRectBottom, PPTtoEMU( maDestPageSize.Width ) );
1647 aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x120012 );
1648 aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
1649 aPropOpt.AddOpt( ESCHER_Prop_bWMode, ESCHER_wDontShow );
1650 aPropOpt.AddOpt( ESCHER_Prop_fBackground, 0x10001 ); // if true, this is the background shape
1651 aPropOpt.Commit( *mpStrm );
1652 mpPptEscherEx->CloseContainer(); // ESCHER_SpContainer
1655 aSolverContainer.WriteSolver( *mpStrm );
1657 mpPptEscherEx->CloseContainer(); // ESCHER_DgContainer
1658 mpPptEscherEx->CloseContainer(); // EPP_Drawing
1659 mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 1 );
1660 *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x99cc00 << (sal_uInt32)0xcc3333 << (sal_uInt32)0xffcccc << (sal_uInt32)0xb2b2b2;
1662 SvMemoryStream aBinaryTagData10Atom;
1663 ImplExportComments( mXDrawPage, aBinaryTagData10Atom );
1664 if ( mbUseNewAnimations )
1666 SvMemoryStream amsofbtAnimGroup;
1667 ppt::AnimationExporter aExporter( aSolverContainer, maSoundCollection );
1668 aExporter.doexport( mXDrawPage, amsofbtAnimGroup );
1669 sal_uInt32 nmsofbtAnimGroupSize = amsofbtAnimGroup.Tell();
1670 if ( nmsofbtAnimGroupSize )
1673 EscherExAtom aMagic2( aBinaryTagData10Atom, 0x2eeb );
1674 aBinaryTagData10Atom << (sal_uInt32)0x01c45df9
1675 << (sal_uInt32)0xe1471b30;
1678 EscherExAtom aMagic( aBinaryTagData10Atom, 0x2b00 );
1679 aBinaryTagData10Atom << (sal_uInt32)0;
1681 aBinaryTagData10Atom.Write( amsofbtAnimGroup.GetData(), amsofbtAnimGroup.Tell() );
1683 EscherExContainer aMagic2( aBinaryTagData10Atom, 0x2b02 );
1687 if ( aBinaryTagData10Atom.Tell() )
1689 EscherExContainer aProgTags ( *mpStrm, EPP_ProgTags );
1690 EscherExContainer aProgBinaryTag( *mpStrm, EPP_ProgBinaryTag );
1692 EscherExAtom aCString( *mpStrm, EPP_CString );
1693 *mpStrm << (sal_uInt32)0x5f005f
1694 << (sal_uInt32)0x50005f
1695 << (sal_uInt32)0x540050
1696 << (sal_uInt16)0x31
1697 << (sal_uInt16)0x30;
1700 EscherExAtom aBinaryTagData( *mpStrm, EPP_BinaryTagData );
1701 mpStrm->Write( aBinaryTagData10Atom.GetData(), aBinaryTagData10Atom.Tell() );
1705 if ( mbUseNewAnimations )
1707 SvMemoryStream amsofbtAnimGroup;
1708 ppt::AnimationExporter aExporter( aSolverContainer, maSoundCollection );
1709 aExporter.doexport( mXDrawPage, amsofbtAnimGroup );
1710 sal_uInt32 nmsofbtAnimGroupSize = amsofbtAnimGroup.Tell();
1711 if ( nmsofbtAnimGroupSize )
1713 EscherExContainer aProgTags ( *mpStrm, EPP_ProgTags );
1714 EscherExContainer aProgBinaryTag( *mpStrm, EPP_ProgBinaryTag );
1716 EscherExAtom aCString( *mpStrm, EPP_CString );
1717 *mpStrm << (sal_uInt32)0x5f005f
1718 << (sal_uInt32)0x50005f
1719 << (sal_uInt32)0x540050
1720 << (sal_uInt16)0x31
1721 << (sal_uInt16)0x30;
1724 EscherExAtom aBinaryTagData( *mpStrm, EPP_BinaryTagData );
1727 EscherExAtom aMagic2( *mpStrm, 0x2eeb );
1728 *mpStrm << (sal_uInt32)0x01c45df9
1729 << (sal_uInt32)0xe1471b30;
1732 EscherExAtom aMagic( *mpStrm, 0x2b00 );
1733 *mpStrm << (sal_uInt32)0;
1736 mpStrm->Write( amsofbtAnimGroup.GetData(), amsofbtAnimGroup.Tell() );
1738 EscherExContainer aMagic2( *mpStrm, 0x2b02 );
1744 mpPptEscherEx->CloseContainer(); // EPP_Slide
1745 return TRUE;
1748 // ---------------------------------------------------------------------------------------------
1750 sal_Bool PPTWriter::ImplCreateNotes( sal_uInt32 nPageNum )
1752 if ( !ImplGetPageByIndex( nPageNum, NOTICE ) )
1753 return FALSE;
1754 ImplSetCurrentStyleSheet( ImplGetMasterIndex( NORMAL ) );
1757 mpPptEscherEx->PtReplaceOrInsert( EPP_Persist_Notes | nPageNum, mpStrm->Tell() );
1758 mpPptEscherEx->OpenContainer( EPP_Notes );
1759 mpPptEscherEx->AddAtom( 8, EPP_NotesAtom, 1 );
1760 *mpStrm << (sal_uInt32)nPageNum + 0x100
1761 << (sal_uInt16)3 // follow master ....
1762 << (sal_uInt16)0;
1764 ImplCreateHeaderFooters( mXPagePropSet );
1766 EscherSolverContainer aSolverContainer;
1768 mpPptEscherEx->OpenContainer( EPP_PPDrawing );
1769 mpPptEscherEx->OpenContainer( ESCHER_DgContainer );
1770 mpPptEscherEx->EnterGroup(0,0);
1772 ImplWritePage( pPHLayout[ 20 ], aSolverContainer, NOTICE, FALSE ); // Die Shapes der Seite werden im PPT Dok. erzeugt
1774 mpPptEscherEx->LeaveGroup();
1775 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
1776 mpPptEscherEx->AddShape( ESCHER_ShpInst_Rectangle, 0xc00 ); // Flags: Connector | Background | HasSpt
1777 EscherPropertyContainer aPropOpt;
1778 aPropOpt.AddOpt( ESCHER_Prop_fillColor, 0xffffff ); // stock valued fill color
1779 aPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0 );
1780 aPropOpt.AddOpt( ESCHER_Prop_fillRectRight, 0x8b9f8e );
1781 aPropOpt.AddOpt( ESCHER_Prop_fillRectBottom, 0x68bdde );
1782 aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x120012 );
1783 aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
1784 aPropOpt.AddOpt( ESCHER_Prop_bWMode, ESCHER_wDontShow );
1785 aPropOpt.AddOpt( ESCHER_Prop_fBackground, 0x10001 );
1786 aPropOpt.Commit( *mpStrm );
1787 mpPptEscherEx->CloseContainer(); // ESCHER_SpContainer
1789 aSolverContainer.WriteSolver( *mpStrm );
1791 mpPptEscherEx->CloseContainer(); // ESCHER_DgContainer
1792 mpPptEscherEx->CloseContainer(); // EPP_Drawing
1793 mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 1 );
1794 *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x99cc00 << (sal_uInt32)0xcc3333 << (sal_uInt32)0xffcccc << (sal_uInt32)0xb2b2b2;
1795 mpPptEscherEx->CloseContainer(); // EPP_Notes
1796 return TRUE;
1799 void PPTWriter::ImplWriteBackground( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet )
1801 //************************ ******
1802 //** DEFAULT BACKGROUND SHAPE **
1803 //******************************
1805 sal_uInt32 nFillColor = 0xffffff;
1806 sal_uInt32 nFillBackColor = 0;
1808 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
1809 mpPptEscherEx->AddShape( ESCHER_ShpInst_Rectangle, 0xc00 ); // Flags: Connector | Background | HasSpt
1810 Point aEmptyPoint = Point();
1811 Rectangle aRect( aEmptyPoint, Size( 28000, 21000 ) );
1812 EscherPropertyContainer aPropOpt( (EscherGraphicProvider&)*mpPptEscherEx, mpPicStrm, aRect );
1813 aPropOpt.AddOpt( ESCHER_Prop_fillType, ESCHER_FillSolid );
1814 ::com::sun::star::drawing::FillStyle aFS( ::com::sun::star::drawing::FillStyle_NONE );
1815 if ( ImplGetPropertyValue( rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ) ) ) )
1816 mAny >>= aFS;
1818 switch( aFS )
1820 case ::com::sun::star::drawing::FillStyle_GRADIENT :
1822 aPropOpt.CreateGradientProperties( rXPropSet );
1823 aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x1f001e );
1824 aPropOpt.GetOpt( ESCHER_Prop_fillColor, nFillColor );
1825 aPropOpt.GetOpt( ESCHER_Prop_fillBackColor, nFillBackColor );
1827 break;
1829 case ::com::sun::star::drawing::FillStyle_BITMAP :
1830 aPropOpt.CreateGraphicProperties( rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" ) ), sal_True );
1831 break;
1833 case ::com::sun::star::drawing::FillStyle_HATCH :
1834 aPropOpt.CreateGraphicProperties( rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" ) ), sal_True );
1835 break;
1837 case ::com::sun::star::drawing::FillStyle_SOLID :
1839 if ( ImplGetPropertyValue( rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ) ) )
1841 nFillColor = mpPptEscherEx->GetColor( *((sal_uInt32*)mAny.getValue()) );
1842 nFillBackColor = nFillColor ^ 0xffffff;
1844 } // PASSTHROUGH INTENDED
1845 case ::com::sun::star::drawing::FillStyle_NONE :
1846 default:
1847 aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x120012 );
1848 break;
1850 aPropOpt.AddOpt( ESCHER_Prop_fillColor, nFillColor );
1851 aPropOpt.AddOpt( ESCHER_Prop_fillBackColor, nFillBackColor );
1852 aPropOpt.AddOpt( ESCHER_Prop_fillRectRight, PPTtoEMU( maDestPageSize.Width ) );
1853 aPropOpt.AddOpt( ESCHER_Prop_fillRectBottom, PPTtoEMU( maDestPageSize.Height ) );
1854 aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
1855 aPropOpt.AddOpt( ESCHER_Prop_bWMode, ESCHER_bwWhite );
1856 aPropOpt.AddOpt( ESCHER_Prop_fBackground, 0x10001 );
1857 aPropOpt.Commit( *mpStrm );
1858 mpPptEscherEx->CloseContainer(); // ESCHER_SpContainer
1861 void PPTWriter::ImplWriteVBA( SvMemoryStream* pVBA )
1863 if ( pVBA )
1865 pVBA->Seek( STREAM_SEEK_TO_END );
1866 sal_uInt32 nLen = pVBA->Tell();
1867 if ( nLen > 8 )
1869 nLen -= 8;
1870 mnVBAOleOfs = mpStrm->Tell();
1871 mpPptEscherEx->BeginAtom();
1872 mpStrm->Write( (sal_Int8*)pVBA->GetData() + 8, nLen );
1873 mpPptEscherEx->EndAtom( EPP_ExOleObjStg, 0, 1 );
1878 // ---------------------------------------------------------------------------------------------
1880 void PPTWriter::ImplWriteOLE( sal_uInt32 nCnvrtFlags )
1882 PPTExOleObjEntry* pPtr;
1884 SvxMSExportOLEObjects aOleExport( nCnvrtFlags );
1886 for ( pPtr = (PPTExOleObjEntry*)maExOleObj.First(); pPtr;
1887 pPtr = (PPTExOleObjEntry*)maExOleObj.Next() )
1889 SvMemoryStream* pStrm = NULL;
1890 pPtr->nOfsB = mpStrm->Tell();
1891 switch ( pPtr->eType )
1893 case NORMAL_OLE_OBJECT :
1895 SdrObject* pSdrObj = GetSdrObjectFromXShape( pPtr->xShape );
1896 if ( pSdrObj && pSdrObj->ISA( SdrOle2Obj ) )
1898 ::uno::Reference < embed::XEmbeddedObject > xObj( ( (SdrOle2Obj*) pSdrObj )->GetObjRef() );
1899 if( xObj.is() )
1901 SvStorageRef xTempStorage( new SvStorage( new SvMemoryStream(), TRUE ) );
1902 aOleExport.ExportOLEObject( xObj, *xTempStorage );
1904 //TODO/MBA: testing
1905 String aPersistStream( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( SVEXT_PERSIST_STREAM ) ) );
1906 SvMemoryStream aStream;
1907 SvStorageRef xCleanStorage( new SvStorage( FALSE, aStream ) );
1908 xTempStorage->CopyTo( xCleanStorage );
1909 // SJ: #99809# create a dummy content stream, the dummy content is necessary for ppt, but not for
1910 // doc files, so we can't share code.
1911 SotStorageStreamRef xStm = xCleanStorage->OpenSotStream( aPersistStream, STREAM_STD_READWRITE );
1912 *xStm << (sal_uInt32)0 // no ClipboardId
1913 << (sal_uInt32)4 // no target device
1914 << (sal_uInt32)1 // aspect ratio
1915 << (sal_Int32)-1 // L-Index
1916 << (sal_uInt32)0 // Advanced Flags
1917 << (sal_uInt32)0 // compression
1918 << (sal_uInt32)0 // Size
1919 << (sal_uInt32)0 // "
1920 << (sal_uInt32)0;
1921 pStrm = xCleanStorage->CreateMemoryStream();
1925 break;
1927 case OCX_CONTROL :
1929 if ( pPtr->xControlModel.is() )
1931 String aName;
1932 ::com::sun::star::awt::Size aSize;
1933 SvStorageRef xDest( new SvStorage( new SvMemoryStream(), TRUE ) );
1934 sal_Bool bOk = SvxMSConvertOCXControls::WriteOCXStream( xDest, pPtr->xControlModel, aSize, aName );
1935 if ( bOk )
1936 pStrm = xDest->CreateMemoryStream();
1940 if ( pStrm )
1942 mpPptEscherEx->BeginAtom();
1943 pStrm->Seek( STREAM_SEEK_TO_END );
1944 sal_uInt32 npStrmSize = pStrm->Tell();
1945 *mpStrm << npStrmSize; // uncompressed size
1947 #ifdef DBG_EXTRACTOLEOBJECTS
1948 SvFileStream aOut( String::CreateFromAscii( "D:\\OUT.OLE" ), STREAM_TRUNC | STREAM_WRITE );
1949 pStrm->Seek( 0 );
1950 aOut.Write( pStrm->GetData(), npStrmSize );
1951 #endif
1953 pStrm->Seek( 0 );
1954 ZCodec aZCodec( 0x8000, 0x8000 );
1955 aZCodec.BeginCompression();
1956 aZCodec.Compress( *pStrm, *mpStrm );
1957 aZCodec.EndCompression();
1958 delete pStrm;
1959 mpPptEscherEx->EndAtom( EPP_ExOleObjStg, 0, 1 );
1964 // ---------------------------------------------------------------------------------------------
1965 // PersistantTable und UserEditAtom schreiben
1967 sal_Bool PPTWriter::ImplWriteAtomEnding()
1970 #define EPP_LastViewTypeNone 0
1971 #define EPP_LastViewTypeSlideView 1
1972 #define EPP_LastViewTypeOutlineView 2
1973 #define EPP_LastViewTypeNotes 3
1976 sal_uInt32 i, nPos, nOfs, nPersistOfs = mpStrm->Tell();
1977 sal_uInt32 nPersistEntrys = 0;
1978 *mpStrm << (sal_uInt32)0 << (sal_uInt32)0 << (sal_uInt32)0; // Record Header und ersten Eintrag ueberspringen
1980 // Document pesist schreiben
1981 nPersistEntrys++;
1982 *mpStrm << (sal_uInt32)0;
1983 // MasterPages persists schreiben
1984 for ( i = 0; i < mnMasterPages; i++ )
1986 nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_MainMaster | i );
1987 if ( nOfs )
1989 *mpStrm << nOfs;
1990 mpPptEscherEx->InsertAtPersistOffset( EPP_MAINMASTER_PERSIST_KEY | i, ++nPersistEntrys );
1993 // MainNotesMaster persist schreiben
1994 nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_MainNotes );
1995 if ( nOfs )
1997 *mpStrm << nOfs;
1998 mpPptEscherEx->InsertAtPersistOffset( EPP_MAINNOTESMASTER_PERSIST_KEY, ++nPersistEntrys );
2000 // Slide persists schreiben -> es gilt hier auch den EPP_SlidePersistAtome mit einem gueltigen wert zu beschreiben
2001 for ( i = 0; i < mnPages; i++ )
2003 nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_Slide | i );
2004 if ( nOfs )
2006 *mpStrm << nOfs;
2007 mpPptEscherEx->InsertAtPersistOffset( EPP_MAINSLIDE_PERSIST_KEY | i, ++nPersistEntrys );
2010 // Notes persists schreiben
2011 for ( i = 0; i < mnPages; i++ )
2013 nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_Notes | i );
2014 if ( nOfs )
2016 *mpStrm << nOfs;
2017 mpPptEscherEx->InsertAtPersistOffset( EPP_MAINNOTES_PERSIST_KEY | i, ++nPersistEntrys );
2020 // Ole persists
2021 PPTExOleObjEntry* pPtr;
2022 for ( pPtr = (PPTExOleObjEntry*)maExOleObj.First(); pPtr; pPtr = (PPTExOleObjEntry*)maExOleObj.Next() )
2024 nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_ExObj );
2025 if ( nOfs )
2027 nPersistEntrys++;
2028 *mpStrm << pPtr->nOfsB;
2029 sal_uInt32 nOldPos, nPersOfs = nOfs + pPtr->nOfsA + 16 + 8; // 8 bytes atom header, +16 to the persist entry
2030 nOldPos = mpStrm->Tell();
2031 mpStrm->Seek( nPersOfs );
2032 *mpStrm << nPersistEntrys;
2033 mpStrm->Seek( nOldPos );
2036 // VB persist
2037 if ( mnVBAOleOfs && mpVBA )
2039 nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_VBAInfoAtom );
2040 if ( nOfs )
2042 nPersistEntrys++;
2043 sal_uInt32 n1, n2;
2045 mpVBA->Seek( 0 );
2046 *mpVBA >> n1
2047 >> n2;
2049 *mpStrm << mnVBAOleOfs;
2050 sal_uInt32 nOldPos = mpStrm->Tell();
2051 mpStrm->Seek( nOfs ); // Fill the VBAInfoAtom with the correct index to the persisttable
2052 *mpStrm << nPersistEntrys
2053 << n1
2054 << 2;
2055 mpStrm->Seek( nOldPos );
2059 nPos = mpStrm->Tell();
2060 mpStrm->Seek( nPersistOfs );
2061 mpPptEscherEx->AddAtom( ( nPersistEntrys + 1 ) << 2, EPP_PersistPtrIncrementalBlock ); // Record Header eintragen
2062 *mpStrm << (sal_uInt32)( ( nPersistEntrys << 20 ) | 1 );
2063 mpStrm->Seek( nPos );
2065 *mpCurUserStrm << (sal_uInt32)nPos; // offset to current edit setzen
2066 mpPptEscherEx->AddAtom( 28, EPP_UserEditAtom );
2067 *mpStrm << (INT32)0x100 // last slide ID
2068 << (sal_uInt32)0x03000dbc // minor and major app version that did the save
2069 << (sal_uInt32)0 // offset last save, 0 after a full save
2070 << nPersistOfs // File offset to persist pointers for this save operation
2071 << (sal_uInt32)1 // Persist reference to the document persist object
2072 << (sal_uInt32)nPersistEntrys // max persists written, Seed value for persist object id management
2073 << (sal_Int16)EPP_LastViewTypeSlideView // last view type
2074 << (sal_Int16)0x12; // padword
2076 return TRUE;
2079 // ---------------------------------------------------------------------------------------------
2081 PPTExCharSheet::PPTExCharSheet( int nInstance )
2083 sal_uInt16 nFontHeight = 24;
2085 for ( int nDepth = 0; nDepth < 5; nDepth++ )
2087 PPTExCharLevel& rLev = maCharLevel[ nDepth ];
2088 switch ( nInstance )
2090 case EPP_TEXTTYPE_Title :
2091 case EPP_TEXTTYPE_CenterTitle :
2092 nFontHeight = 44;
2093 break;
2094 case EPP_TEXTTYPE_Body :
2095 case EPP_TEXTTYPE_CenterBody :
2096 case EPP_TEXTTYPE_HalfBody :
2097 case EPP_TEXTTYPE_QuarterBody :
2099 switch ( nDepth )
2101 case 0 : nFontHeight = 32; break;
2102 case 1 : nFontHeight = 28; break;
2103 case 2 : nFontHeight = 24; break;
2104 default :nFontHeight = 20; break;
2107 break;
2108 case EPP_TEXTTYPE_Notes :
2109 nFontHeight = 12;
2110 break;
2111 case EPP_TEXTTYPE_notUsed :
2112 case EPP_TEXTTYPE_Other :
2113 nFontHeight = 24;
2114 break;
2116 rLev.mnFlags = 0;
2117 rLev.mnFont = 0;
2118 rLev.mnAsianOrComplexFont = 0xffff;
2119 rLev.mnFontHeight = nFontHeight;
2120 rLev.mnFontColor = 0;
2121 rLev.mnEscapement = 0;
2126 void PPTExCharSheet::SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
2127 FontCollection& rFontCollection, int nLevel )
2129 PortionObj aPortionObj( rXPropSet, rFontCollection );
2131 PPTExCharLevel& rLev = maCharLevel[ nLevel ];
2133 if ( aPortionObj.meCharColor == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2134 rLev.mnFontColor = aPortionObj.mnCharColor;
2135 if ( aPortionObj.meCharEscapement == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2136 rLev.mnEscapement = aPortionObj.mnCharEscapement;
2137 if ( aPortionObj.meCharHeight == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2138 rLev.mnFontHeight = aPortionObj.mnCharHeight;
2139 if ( aPortionObj.meFontName == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2140 rLev.mnFont = aPortionObj.mnFont;
2141 if ( aPortionObj.meAsianOrComplexFont == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2142 rLev.mnAsianOrComplexFont = aPortionObj.mnAsianOrComplexFont;
2143 rLev.mnFlags = aPortionObj.mnCharAttr;
2146 void PPTExCharSheet::Write( SvStream& rSt, PptEscherEx*, sal_uInt16 nLev, sal_Bool, sal_Bool bSimpleText,
2147 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet )
2149 const PPTExCharLevel& rLev = maCharLevel[ nLev ];
2151 sal_uInt32 nCharFlags = 0xefffff;
2152 if ( bSimpleText )
2153 nCharFlags = 0x7ffff;
2155 rSt << nCharFlags
2156 << rLev.mnFlags
2157 << rLev.mnFont;
2159 sal_uInt32 nFontColor = rLev.mnFontColor;
2160 if ( nFontColor == COL_AUTO )
2162 sal_Bool bIsDark = sal_False;
2163 ::com::sun::star::uno::Any aAny;
2164 if ( PropValue::GetPropertyValue( aAny, rPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundDark" ) ), sal_True ) )
2165 aAny >>= bIsDark;
2166 nFontColor = bIsDark ? 0xffffff : 0x000000;
2168 nFontColor &= 0xffffff;
2169 nFontColor |= 0xfe000000;
2170 if ( bSimpleText )
2172 rSt << rLev.mnFontHeight
2173 << nFontColor;
2175 else
2177 rSt << rLev.mnAsianOrComplexFont
2178 << (sal_uInt16)0xffff // unbekannt
2179 << (sal_uInt16)0xffff // unbekannt
2180 << rLev.mnFontHeight
2181 << nFontColor
2182 << rLev.mnEscapement;
2186 PPTExParaSheet::PPTExParaSheet( int nInstance, sal_uInt16 nDefaultTab, PPTExBulletProvider& rProv ) :
2187 rBuProv ( rProv ),
2188 mnInstance ( nInstance )
2190 sal_Bool bHasBullet = FALSE;
2192 sal_uInt16 nUpperDist = 0;
2193 sal_uInt16 nBulletChar = 0x2022;
2194 sal_uInt16 nBulletOfs = 0;
2195 sal_uInt16 nTextOfs = 0;
2197 for ( int nDepth = 0; nDepth < 5; nDepth++ )
2199 PPTExParaLevel& rLev = maParaLevel[ nDepth ];
2200 switch ( nInstance )
2202 case EPP_TEXTTYPE_Title :
2203 case EPP_TEXTTYPE_CenterTitle :
2204 break;
2205 case EPP_TEXTTYPE_Body :
2206 case EPP_TEXTTYPE_CenterBody :
2207 case EPP_TEXTTYPE_HalfBody :
2208 case EPP_TEXTTYPE_QuarterBody :
2210 bHasBullet = TRUE;
2211 nUpperDist = 0x14;
2213 break;
2214 case EPP_TEXTTYPE_Notes :
2215 nUpperDist = 0x1e;
2216 break;
2218 // default :
2219 // case EPP_TEXTTYPE_notUsed :
2220 // case EPP_TEXTTYPE_Other :
2221 // break;
2223 switch ( nDepth )
2225 case 0 :
2227 nBulletChar = 0x2022;
2228 nBulletOfs = 0;
2229 nTextOfs = ( bHasBullet ) ? 0xd8 : 0;
2231 break;
2232 case 1 :
2234 nBulletChar = 0x2013;
2235 nBulletOfs = 0x120;
2236 nTextOfs = 0x1d4;
2238 break;
2239 case 2 :
2241 nBulletChar = 0x2022;
2242 nBulletOfs = 0x240;
2243 nTextOfs = 0x2d0;
2245 break;
2246 case 3 :
2248 nBulletChar = 0x2013;
2249 nBulletOfs = 0x360;
2250 nTextOfs = 0x3f0;
2252 break;
2253 case 4 :
2255 nBulletChar = 0xbb;
2256 nBulletOfs = 0x480;
2257 nTextOfs = 0x510;
2259 break;
2261 rLev.mbIsBullet = bHasBullet;
2262 rLev.mnBulletChar = nBulletChar;
2263 rLev.mnBulletFont = 0;
2264 rLev.mnBulletHeight = 100;
2265 rLev.mnBulletColor = 0;
2266 rLev.mnAdjust = 0;
2267 rLev.mnLineFeed = 100;
2268 rLev.mnLowerDist = 0;
2269 rLev.mnUpperDist = nUpperDist;
2270 rLev.mnTextOfs = nTextOfs;
2271 rLev.mnBulletOfs = nBulletOfs;
2272 rLev.mnDefaultTab = nDefaultTab;
2273 rLev.mnAsianSettings = 2;
2274 rLev.mnBiDi = 0;
2276 rLev.mbExtendedBulletsUsed = FALSE;
2277 rLev.mnBulletId = 0xffff;
2278 rLev.mnBulletStart = 0;
2279 rLev.mnMappedNumType = 0;
2280 rLev.mnNumberingType = 0;
2284 void PPTExParaSheet::SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
2285 FontCollection& rFontCollection, int nLevel, const PPTExCharLevel& rCharLevel )
2287 ParagraphObj aParagraphObj( rXPropSet, rBuProv );
2288 aParagraphObj.CalculateGraphicBulletSize( rCharLevel.mnFontHeight );
2289 PPTExParaLevel& rLev = maParaLevel[ nLevel ];
2291 if ( aParagraphObj.meTextAdjust == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2292 rLev.mnAdjust = aParagraphObj.mnTextAdjust;
2293 if ( aParagraphObj.meLineSpacing == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2295 sal_Int16 nLineSpacing = aParagraphObj.mnLineSpacing;
2296 if ( nLineSpacing > 0 ) // if nLinespacing is < 0 the linespacing is an absolute spacing
2298 sal_Bool bFixedLineSpacing = sal_False;
2299 uno::Any aAny = rXPropSet->getPropertyValue( ::rtl::OUString(
2300 RTL_CONSTASCII_USTRINGPARAM(
2301 "FontIndependentLineSpacing" ) ) );
2302 if( !(aAny >>= bFixedLineSpacing) || !bFixedLineSpacing )
2304 const FontCollectionEntry* pDesc = rFontCollection.GetById( rCharLevel.mnFont );
2305 if ( pDesc )
2306 nLineSpacing = (sal_Int16)( (double)nLineSpacing * pDesc->Scaling + 0.5 );
2309 else
2311 if ( rCharLevel.mnFontHeight > (sal_uInt16)( ((double)-nLineSpacing) * 0.001 * 72.0 / 2.54 ) ) // 1/100mm to point
2313 const FontCollectionEntry* pDesc = rFontCollection.GetById( rCharLevel.mnFont );
2314 if ( pDesc )
2315 nLineSpacing = (sal_Int16)( (double)100.0 * pDesc->Scaling + 0.5 );
2316 else
2317 nLineSpacing = 100;
2319 else
2320 nLineSpacing = (sal_Int16)( (double)nLineSpacing / 4.40972 );
2322 rLev.mnLineFeed = nLineSpacing;
2324 if ( aParagraphObj.meLineSpacingBottom == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2325 rLev.mnLowerDist = aParagraphObj.mnLineSpacingBottom;
2326 if ( aParagraphObj.meLineSpacingTop == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2327 rLev.mnUpperDist = aParagraphObj.mnLineSpacingTop;
2328 if ( aParagraphObj.meForbiddenRules == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2330 rLev.mnAsianSettings &=~1;
2331 if ( aParagraphObj.mbForbiddenRules )
2332 rLev.mnAsianSettings |= 1;
2334 if ( aParagraphObj.meParagraphPunctation == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2336 rLev.mnAsianSettings &=~4;
2337 if ( aParagraphObj.mbParagraphPunctation )
2338 rLev.mnAsianSettings |= 4;
2341 if ( aParagraphObj.meBiDi == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2342 rLev.mnBiDi = aParagraphObj.mnBiDi;
2344 rLev.mbIsBullet = aParagraphObj.mbIsBullet; //( ( aParagraphObj.nBulletFlags & 1 ) != 0 );
2346 if ( !nLevel )
2348 if ( ( aParagraphObj.meBullet == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2349 && aParagraphObj.bExtendedParameters )
2351 for ( sal_Int16 i = 0; i < 5; i++ )
2353 PPTExParaLevel& rLevel = maParaLevel[ i ];
2354 if ( i )
2355 aParagraphObj.ImplGetNumberingLevel( rBuProv, i, FALSE );
2356 // rLevel.mbIsBullet = ( ( aParagraphObj.nBulletFlags & 1 ) != 0 );
2357 rLevel.mnTextOfs = aParagraphObj.nTextOfs;
2358 rLevel.mnBulletOfs = (sal_uInt16)aParagraphObj.nBulletOfs;
2359 rLevel.mnBulletChar = aParagraphObj.cBulletId;
2360 FontCollectionEntry aFontDescEntry( aParagraphObj.aFontDesc.Name, aParagraphObj.aFontDesc.Family,
2361 aParagraphObj.aFontDesc.Pitch, aParagraphObj.aFontDesc.CharSet );
2362 rLevel.mnBulletFont = (sal_uInt16)rFontCollection.GetId( aFontDescEntry );
2363 rLevel.mnBulletHeight = aParagraphObj.nBulletRealSize;
2364 rLevel.mnBulletColor = aParagraphObj.nBulletColor;
2366 rLevel.mbExtendedBulletsUsed = aParagraphObj.bExtendedBulletsUsed;
2367 rLevel.mnBulletId = aParagraphObj.nBulletId;
2368 rLevel.mnNumberingType = aParagraphObj.nNumberingType;
2369 rLevel.mnBulletStart = aParagraphObj.nStartWith;
2370 rLevel.mnMappedNumType = aParagraphObj.nMappedNumType;
2376 void PPTExParaSheet::Write( SvStream& rSt, PptEscherEx*, sal_uInt16 nLev, sal_Bool, sal_Bool bSimpleText,
2377 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet )
2379 const PPTExParaLevel& rLev = maParaLevel[ nLev ];
2381 if ( maParaLevel[ 0 ].mbExtendedBulletsUsed || maParaLevel[ 1 ].mbExtendedBulletsUsed ||
2382 maParaLevel[ 2 ].mbExtendedBulletsUsed || maParaLevel[ 3 ].mbExtendedBulletsUsed ||
2383 maParaLevel[ 4 ].mbExtendedBulletsUsed )
2385 SvStream& rOut = rBuProv.aBuExMasterStream;
2386 if ( !nLev )
2388 rOut << (sal_uInt32)( ( EPP_PST_ExtendedParagraphMasterAtom << 16 ) | ( mnInstance << 4 ) )
2389 << (sal_uInt32)( 5 * 16 + 2 )
2390 << (sal_uInt16)5; // depth
2392 sal_uInt16 nBulletId = rLev.mnBulletId;
2393 if ( rLev.mnNumberingType != SVX_NUM_BITMAP )
2394 nBulletId = 0xffff;
2395 rOut << (sal_uInt32)0x03800000
2396 << (sal_uInt16)nBulletId
2397 << (sal_uInt32)rLev.mnMappedNumType
2398 << (sal_uInt16)rLev.mnBulletStart
2399 << (sal_uInt32)0;
2402 sal_uInt32 nParaFlags = 0x3ffdff;
2403 sal_uInt16 nBulletFlags = ( rLev.mbIsBullet ) ? 0xf : 0xe;
2405 if ( nLev )
2406 nParaFlags &= 0x207fff;
2407 if ( bSimpleText )
2408 nParaFlags &= 0x7fff;
2409 sal_uInt32 nBulletColor = rLev.mnBulletColor;
2410 if ( nBulletColor == COL_AUTO )
2412 sal_Bool bIsDark = sal_False;
2413 ::com::sun::star::uno::Any aAny;
2414 if ( PropValue::GetPropertyValue( aAny, rPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundDark" ) ), sal_True ) )
2415 aAny >>= bIsDark;
2416 nBulletColor = bIsDark ? 0xffffff : 0x000000;
2418 nBulletColor &= 0xffffff;
2419 nBulletColor |= 0xfe000000;
2420 rSt << nParaFlags
2421 << nBulletFlags
2422 << rLev.mnBulletChar
2423 << rLev.mnBulletFont
2424 << rLev.mnBulletHeight
2425 << nBulletColor
2426 << rLev.mnAdjust
2427 << rLev.mnLineFeed
2428 << rLev.mnUpperDist
2429 << rLev.mnLowerDist
2430 << rLev.mnTextOfs
2431 << rLev.mnBulletOfs;
2433 if ( bSimpleText || nLev )
2435 if ( nParaFlags & 0x200000 )
2436 rSt << rLev.mnBiDi;
2438 else
2440 rSt << rLev.mnDefaultTab
2441 << (sal_uInt16)0
2442 << (sal_uInt16)0
2443 << rLev.mnAsianSettings
2444 << rLev.mnBiDi;
2449 PPTExStyleSheet::PPTExStyleSheet( sal_uInt16 nDefaultTab, PPTExBulletProvider& rBuProv )
2451 for ( int nInstance = EPP_TEXTTYPE_Title; nInstance <= EPP_TEXTTYPE_QuarterBody; nInstance++ )
2453 mpParaSheet[ nInstance ] = ( nInstance == EPP_TEXTTYPE_notUsed ) ? NULL : new PPTExParaSheet( nInstance, nDefaultTab, rBuProv );
2454 mpCharSheet[ nInstance ] = ( nInstance == EPP_TEXTTYPE_notUsed ) ? NULL : new PPTExCharSheet( nInstance );
2458 PPTExStyleSheet::~PPTExStyleSheet()
2460 for ( int nInstance = EPP_TEXTTYPE_Title; nInstance <= EPP_TEXTTYPE_QuarterBody; nInstance++ )
2462 if ( nInstance == EPP_TEXTTYPE_notUsed )
2463 continue;
2465 delete mpParaSheet[ nInstance ];
2466 delete mpCharSheet[ nInstance ];
2470 void PPTExStyleSheet::SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
2471 FontCollection& rFontCollection, int nInstance, int nLevel )
2473 if ( nInstance == EPP_TEXTTYPE_notUsed )
2474 return;
2475 mpCharSheet[ nInstance ]->SetStyleSheet( rXPropSet, rFontCollection, nLevel );
2476 mpParaSheet[ nInstance ]->SetStyleSheet( rXPropSet, rFontCollection, nLevel, mpCharSheet[ nInstance ]->maCharLevel[ nLevel ] );
2479 sal_Bool PPTExStyleSheet::IsHardAttribute( sal_uInt32 nInstance, sal_uInt32 nLevel, PPTExTextAttr eAttr, sal_uInt32 nValue )
2481 const PPTExParaLevel& rPara = mpParaSheet[ nInstance ]->maParaLevel[ nLevel ];
2482 const PPTExCharLevel& rChar = mpCharSheet[ nInstance ]->maCharLevel[ nLevel ];
2484 sal_uInt32 nFlag = 0;
2486 switch ( eAttr )
2488 case ParaAttr_BulletOn : return ( rPara.mbIsBullet ) ? ( nValue ) ? FALSE : TRUE : ( nValue ) ? TRUE : FALSE;
2489 case ParaAttr_BuHardFont :
2490 case ParaAttr_BulletFont : return ( rPara.mnBulletFont != nValue );
2491 case ParaAttr_BuHardColor :
2492 case ParaAttr_BulletColor : return ( rPara.mnBulletColor != nValue );
2493 case ParaAttr_BuHardHeight :
2494 case ParaAttr_BulletHeight : return ( rPara.mnBulletHeight != nValue );
2495 case ParaAttr_BulletChar : return ( rPara.mnBulletChar != nValue );
2496 case ParaAttr_Adjust : return ( rPara.mnAdjust != nValue );
2497 case ParaAttr_LineFeed : return ( rPara.mnLineFeed != nValue );
2498 case ParaAttr_UpperDist : return ( rPara.mnUpperDist != nValue );
2499 case ParaAttr_LowerDist : return ( rPara.mnLowerDist != nValue );
2500 case ParaAttr_TextOfs : return ( rPara.mnTextOfs != nValue );
2501 case ParaAttr_BulletOfs : return ( rPara.mnBulletOfs != nValue );
2502 case ParaAttr_DefaultTab : return ( rPara.mnDefaultTab != nValue );
2503 case ParaAttr_BiDi : return ( rPara.mnBiDi != nValue );
2504 case CharAttr_Bold : nFlag = 1; break;
2505 case CharAttr_Italic : nFlag = 2; break;
2506 case CharAttr_Underline : nFlag = 4; break;
2507 case CharAttr_Shadow : nFlag = 16; break;
2508 case CharAttr_Strikeout : nFlag = 256; break;
2509 case CharAttr_Embossed : nFlag = 512; break;
2510 case CharAttr_Font : return ( rChar.mnFont != nValue );
2511 case CharAttr_AsianOrComplexFont : return ( rChar.mnAsianOrComplexFont != nValue );
2512 case CharAttr_Symbol : return TRUE;
2513 case CharAttr_FontHeight : return ( rChar.mnFontHeight != nValue );
2514 case CharAttr_FontColor : return ( rChar.mnFontColor != nValue );
2515 case CharAttr_Escapement : return ( rChar.mnEscapement != nValue );
2516 default:
2517 break;
2519 if ( nFlag )
2521 if ( rChar.mnFlags & nFlag )
2522 return ( ( nValue & nFlag ) == 0 );
2523 else
2524 return ( ( nValue & nFlag ) != 0 );
2526 return TRUE;
2529 sal_uInt32 PPTExStyleSheet::SizeOfTxCFStyleAtom() const
2531 return 24;
2534 // the TxCFStyleAtom stores the text properties that are used
2535 // when creating new objects in PowerPoint.
2537 void PPTExStyleSheet::WriteTxCFStyleAtom( SvStream& rSt )
2539 const PPTExCharLevel& rCharStyle = mpCharSheet[ EPP_TEXTTYPE_Other ]->maCharLevel[ 0 ];
2541 sal_uInt16 nFlags = 0x60 // ??
2542 | 0x02 // fontsize;
2543 | 0x04; // fontcolor
2545 sal_uInt32 nCharFlags = rCharStyle.mnFlags;
2546 nCharFlags &= CharAttr_Italic | CharAttr_Bold | CharAttr_Underline | CharAttr_Shadow;
2548 rSt << (sal_uInt32)( EPP_TxCFStyleAtom << 16 ) // recordheader
2549 << SizeOfTxCFStyleAtom() - 8
2550 << (sal_uInt16)( 0x80 | nCharFlags )
2551 << (sal_uInt16)nFlags
2552 << (sal_uInt16)nCharFlags
2553 << (sal_Int32)-1 // ?
2554 << rCharStyle.mnFontHeight
2555 << rCharStyle.mnFontColor;
2559 // ---------------------------------------------------------------------------------------------
2561 // ---------------------
2562 // - exported function -
2563 // ---------------------
2565 extern "C" SAL_DLLPUBLIC_EXPORT BOOL __LOADONCALLAPI ExportPPT( SvStorageRef& rSvStorage,
2566 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rXModel,
2567 ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > & rXStatInd,
2568 SvMemoryStream* pVBA, sal_uInt32 nCnvrtFlags )
2570 PPTWriter* pPPTWriter;
2571 BOOL bStatus = FALSE;
2573 pPPTWriter = new PPTWriter( rSvStorage, rXModel, rXStatInd, pVBA, nCnvrtFlags );
2574 if ( pPPTWriter )
2576 bStatus = ( pPPTWriter->IsValid() == TRUE );
2577 delete pPPTWriter;
2580 return bStatus;