1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26
27 #include <editeng/numitem.hxx>
28
29 #include <unotools/ucbstreamhelper.hxx>
30 #include <vcl/wrkwin.hxx>
31 #include <svl/urihelper.hxx>
32 #include <svx/svxids.hrc>
33 #include <filter/msfilter/svdfppt.hxx>
34 #include <svx/svditer.hxx>
35 #include <sfx2/docfile.hxx>
36 #include <sfx2/app.hxx>
37 #include <svx/svdograf.hxx>
38 #include <svx/svdlayer.hxx>
39 #include <vcl/msgbox.hxx>
40 #include <svl/style.hxx>
41 #include <svx/xflclit.hxx>
42 #include <editeng/eeitem.hxx>
43 #include <editeng/colritem.hxx>
44 #include <svl/whiter.hxx>
45 #include <svx/xgrad.hxx>
46 #include <svx/xflgrit.hxx>
47 #include <svx/xbtmpit.hxx>
48 #include <svx/xlnclit.hxx>
49 #include <editeng/adjitem.hxx>
50 #include <editeng/editeng.hxx>
51 #include <editeng/bulitem.hxx>
52 #include <editeng/lrspitem.hxx>
53 #include <editeng/lspcitem.hxx>
54 #include <editeng/tstpitem.hxx>
55
56 #include <sfx2/docinf.hxx>
57
58 #include "glob.hrc"
59 #include "pptin.hxx"
60 #include "Outliner.hxx"
61 #include "drawdoc.hxx"
62 #include "sdpage.hxx"
63 #include "sdresid.hxx"
64 #include "pres.hxx"
65 #include "sdresid.hxx"
66 #include "stlpool.hxx"
67 #include "anminfo.hxx"
68 #include <svx/gallery.hxx>
69 #include <tools/urlobj.hxx>
70 #include <editeng/numitem.hxx>
71 #include <svl/itempool.hxx>
72 #include <editeng/fhgtitem.hxx>
73 #include <svx/svdopage.hxx>
74 #include <svx/svdomedia.hxx>
75 #include <svx/svdogrp.hxx>
76 #include "propread.hxx"
77 #include <cusshow.hxx>
78 #include <vcl/bmpacc.hxx>
79
80 #include "../../ui/inc/DrawDocShell.hxx"
81 #include "../../ui/inc/FrameView.hxx"
82 #include "../../ui/inc/optsitem.hxx"
83
84 #include <unotools/fltrcfg.hxx>
85 #include <sfx2/progress.hxx>
86 #include <unotools/localfilehelper.hxx>
87 #include <editeng/editstat.hxx>
88 #include <unotools/pathoptions.hxx>
89 #include <sfx2/docfac.hxx>
90 #define MAX_USER_MOVE 2
91
92 #include "pptinanimations.hxx"
93 #include "ppt97animations.hxx"
94
95 #include <com/sun/star/document/XDocumentProperties.hpp>
96 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
97
98
99 using namespace ::com::sun::star;
100
101
SdPPTImport(SdDrawDocument * pDocument,SvStream & rDocStream,SvStorage & rStorage,SfxMedium & rMedium,MSFilterTracer * pTracer)102 SdPPTImport::SdPPTImport( SdDrawDocument* pDocument, SvStream& rDocStream, SvStorage& rStorage, SfxMedium& rMedium, MSFilterTracer* pTracer )
103 {
104
105 sal_uInt32 nImportFlags = 0;
106
107 #ifdef DBG_UTIL
108 PropRead* pSummaryInformation = new PropRead( rStorage, String( RTL_CONSTASCII_USTRINGPARAM( "\005SummaryInformation" ) ) );
109 if ( pSummaryInformation->IsValid() )
110 {
111 pSummaryInformation->Read();
112 sal_uInt8 aPropSetGUID[ 16 ] =
113 {
114 0xe0, 0x85, 0x9f, 0xf2, 0xf9, 0x4f, 0x68, 0x10, 0xab, 0x91, 0x08, 0x00, 0x2b, 0x27, 0xb3, 0xd9
115 };
116 Section* pSection = (Section*)pSummaryInformation->GetSection( aPropSetGUID );
117 if ( pSection )
118 {
119 PropItem aPropItem;
120 if ( pSection->GetProperty( PID_COMMENTS, aPropItem ) )
121 {
122 String aComment;
123 aPropItem.Read( aComment );
124 if ( aComment.Search( String( RTL_CONSTASCII_USTRINGPARAM( "Applixware" ) ), 0 ) != STRING_NOTFOUND )
125 {
126 nImportFlags |= PPT_IMPORTFLAGS_NO_TEXT_ASSERT;
127 }
128 }
129 }
130 }
131 delete pSummaryInformation;
132 #endif
133
134 PowerPointImportParam aParam( rDocStream, nImportFlags, pTracer );
135 SvStream* pCurrentUserStream = rStorage.OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "Current User" ) ), STREAM_STD_READ );
136 if( pCurrentUserStream )
137 {
138 *pCurrentUserStream >> aParam.aCurrentUserAtom;
139 delete pCurrentUserStream;
140 }
141
142 if( pDocument )
143 {
144 // iterate over all styles
145 SdStyleSheetPool* pStyleSheetPool = pDocument->GetSdStyleSheetPool();
146
147 sal_uInt32 nStyles = pStyleSheetPool ? pStyleSheetPool->GetStyles().size() : 0;
148 for (sal_uInt32 nStyle = 0; nStyle < nStyles; nStyle++)
149 {
150 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( pStyleSheetPool->GetStyles()[nStyle].get() );
151 SfxItemSet& rSet = pSheet->GetItemSet();
152
153 // if autokerning is set in style, override it, ppt has no autokerning
154 if( rSet.GetItemState( EE_CHAR_PAIRKERNING, sal_False ) == SFX_ITEM_SET )
155 rSet.ClearItem( EE_CHAR_PAIRKERNING );
156 }
157 }
158
159 pFilter = new ImplSdPPTImport( pDocument, rStorage, rMedium, aParam );
160 }
161
Import()162 sal_Bool SdPPTImport::Import()
163 {
164 return pFilter->Import();
165 }
166
~SdPPTImport()167 SdPPTImport::~SdPPTImport()
168 {
169 delete pFilter;
170 }
171
ImplSdPPTImport(SdDrawDocument * pDocument,SvStorage & rStorage_,SfxMedium & rMedium,PowerPointImportParam & rParam)172 ImplSdPPTImport::ImplSdPPTImport( SdDrawDocument* pDocument, SvStorage& rStorage_, SfxMedium& rMedium, PowerPointImportParam& rParam )
173 : SdrPowerPointImport ( rParam, rMedium.GetBaseURL() )
174 , mrMed ( rMedium )
175 , mrStorage ( rStorage_ )
176 , mbDocumentFound ( sal_False )
177 , mnFilterOptions ( 0 )
178 {
179 mpDoc = pDocument;
180 if ( bOk )
181 {
182 mbDocumentFound = SeekToDocument( &maDocHd ); // maDocHd = the latest DocumentHeader
183 while ( SeekToRec( rStCtrl, PPT_PST_Document, nStreamLen, &maDocHd ) )
184 mbDocumentFound = sal_True;
185
186 sal_uInt32 nDggContainerOfs = 0;
187
188 if ( mbDocumentFound )
189 {
190 sal_uLong nPosMerk = rStCtrl.Tell();
191
192 pStData = rStorage_.OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "Pictures" ) ), STREAM_STD_READ );
193
194 rStCtrl.Seek( maDocHd.GetRecBegFilePos() + 8 );
195 sal_uLong nDocLen = maDocHd.GetRecEndFilePos();
196 DffRecordHeader aPPDGHd;
197 if ( SeekToRec( rStCtrl, PPT_PST_PPDrawingGroup, nDocLen, &aPPDGHd ) )
198 {
199 sal_uLong nPPDGLen = aPPDGHd.GetRecEndFilePos();
200 if ( SeekToRec( rStCtrl, DFF_msofbtDggContainer, nPPDGLen, NULL ) )
201 nDggContainerOfs = rStCtrl.Tell();
202 }
203 rStCtrl.Seek( nPosMerk );
204 }
205 sal_uInt32 nSvxMSDffOLEConvFlags2 = 0;
206
207 SvtFilterOptions* pBasOpt = SvtFilterOptions::Get();
208 if ( pBasOpt )
209 {
210 if ( pBasOpt->IsLoadPPointBasicCode() )
211 mnFilterOptions |= 1;
212 if ( pBasOpt->IsMathType2Math() )
213 nSvxMSDffOLEConvFlags2 |= OLE_MATHTYPE_2_STARMATH;
214 if ( pBasOpt->IsWinWord2Writer() )
215 nSvxMSDffOLEConvFlags2 |= OLE_WINWORD_2_STARWRITER;
216 if ( pBasOpt->IsExcel2Calc() )
217 nSvxMSDffOLEConvFlags2 |= OLE_EXCEL_2_STARCALC;
218 if ( pBasOpt->IsPowerPoint2Impress() )
219 nSvxMSDffOLEConvFlags2 |= OLE_POWERPOINT_2_STARIMPRESS;
220 }
221
222 InitSvxMSDffManager( nDggContainerOfs, pStData, nSvxMSDffOLEConvFlags2 );
223 SetSvxMSDffSettings( SVXMSDFF_SETTINGS_CROP_BITMAPS
224 | SVXMSDFF_SETTINGS_IMPORT_PPT );
225 SetModel( mpDoc, 576 );
226 }
227 }
228
229 //////////////////////////////////////////////////////////////////////////
230 //
231 // Dtor
232 //
233 //////////////////////////////////////////////////////////////////////////
234
~ImplSdPPTImport()235 ImplSdPPTImport::~ImplSdPPTImport()
236 {
237 for ( void* pPtr = maSlideNameList.First(); pPtr; pPtr = maSlideNameList.Next() )
238 delete (String*)pPtr;
239 delete pStData;
240 }
241
242 //////////////////////////////////////////////////////////////////////////
243 //
244 // Import
245 //
246 //////////////////////////////////////////////////////////////////////////
247
Import()248 sal_Bool ImplSdPPTImport::Import()
249 {
250 if ( !bOk )
251 return sal_False;
252
253 pSdrModel->setLock( sal_True );
254 pSdrModel->EnableUndo(false);
255
256 SdrOutliner& rOutl = mpDoc->GetDrawOutliner();
257 sal_uInt32 nControlWord = rOutl.GetEditEngine().GetControlWord();
258 nControlWord |= EE_CNTRL_ULSPACESUMMATION;
259 nControlWord &=~ EE_CNTRL_ULSPACEFIRSTPARA;
260 ((EditEngine&)rOutl.GetEditEngine()).SetControlWord( nControlWord );
261
262 SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin();
263 mnBackgroundLayerID = rAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRND )), sal_False );
264 mnBackgroundObjectsLayerID = rAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRNDOBJ )), sal_False );
265
266 ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
267 if ( pDocShell )
268 SeekOle( pDocShell, mnFilterOptions );
269
270 // hyperlinks
271 PropRead* pDInfoSec2 = new PropRead( mrStorage, String( RTL_CONSTASCII_USTRINGPARAM( "\005DocumentSummaryInformation" ) ) );
272 if ( pDInfoSec2->IsValid() )
273 {
274 PropItem aPropItem;
275
276 sal_uInt32 nType, nPropSize, nPropCount;
277
278 pDInfoSec2->Read();
279
280 sal_uInt8 aPropSetGUID[ 16 ] =
281 {
282 0x02, 0xd5, 0xcd, 0xd5, 0x9c, 0x2e, 0x1b, 0x10, 0x93, 0x97, 0x08, 0x00, 0x2b, 0x2c, 0xf9, 0xae
283 };
284 Section* pSection = (Section*)pDInfoSec2->GetSection( aPropSetGUID );
285 if ( pSection )
286 {
287 if ( pSection->GetProperty( PID_SLIDECOUNT, aPropItem ) )
288 {
289 aPropItem >> nType;
290 if ( ( nType == VT_I4 ) || ( nType == VT_UI4 ) )
291 {
292 // examine PID_HEADINGPAIR to get the correct entry for PID_DOCPARTS
293 sal_uInt32 nSlideCount, nVecCount;
294 aPropItem >> nSlideCount;
295 if ( nSlideCount && pSection->GetProperty( PID_HEADINGPAIR, aPropItem ) )
296 {
297 sal_uInt32 nSlideTitleIndex = 0, nSlideTitleCount = 0;
298 sal_uInt32 nFontIndex, nFontCount = 0;
299 sal_uInt32 nDesignTemplateIndex, nDesignTemplateCount = 0;
300 sal_uInt32 i, nTemp, nEntryCount = 0;
301
302 String aUString;
303
304 aPropItem >> nType
305 >> nVecCount;
306
307 if ( ( nType == ( VT_VARIANT | VT_VECTOR ) ) && ( nVecCount ^ 1 ) )
308 {
309 nVecCount >>= 1;
310
311 for ( i = 0; i < nVecCount; i++ )
312 {
313 if ( !aPropItem.Read( aUString, VT_EMPTY, sal_False ) )
314 break;
315 aPropItem >> nType;
316 if ( ( nType != VT_I4 ) && ( nType != VT_UI4 ) )
317 break;
318 aPropItem >> nTemp;
319 if ( aUString.EqualsAscii("Slide Titles") || aUString.EqualsAscii("Folientitel") )
320 {
321 nSlideTitleCount = nTemp;
322 nSlideTitleIndex = nEntryCount;
323 }
324 else if ( aUString.EqualsAscii("Fonts Used") )
325 {
326 nFontCount = nTemp;
327 nFontIndex = nEntryCount;
328 }
329 else if ( aUString.EqualsAscii("Design Template") )
330 {
331 nDesignTemplateCount = nTemp;
332 nDesignTemplateIndex = nEntryCount;
333 }
334 nEntryCount += nTemp;
335 }
336 }
337 if ( ( nSlideCount == nSlideTitleCount ) && pSection->GetProperty( PID_DOCPARTS, aPropItem ) )
338 {
339 aPropItem >> nType
340 >> nVecCount;
341
342 if ( ( nVecCount >= ( nSlideTitleIndex + nSlideTitleCount ) )
343 && ( nType == ( VT_LPSTR | VT_VECTOR ) ) )
344 {
345 for ( i = 0; i != nSlideTitleIndex; i++ )
346 {
347 aPropItem >> nTemp;
348 aPropItem.SeekRel( nTemp );
349 }
350 for ( i = 0; i < nSlideTitleCount; i++ )
351 {
352 if ( !aPropItem.Read( aUString, nType, sal_False ) )
353 break;
354 String* pString = new String( aUString );
355 if ( pString->EqualsAscii( "No Slide Title" ))
356 *pString = String();
357 else
358 {
359 void* pPtr;
360 for ( pPtr = maSlideNameList.First(); pPtr; pPtr = maSlideNameList.Next() )
361 {
362 if ( *((String*)pPtr ) == *pString )
363 {
364 *pString = String();
365 break;
366 }
367 }
368 }
369 maSlideNameList.Insert( pString, LIST_APPEND );
370 }
371 }
372 }
373 }
374 }
375 }
376
377 sal_uInt8 aUserPropSetGUID[ 16 ] =
378 {
379 0x05, 0xd5, 0xcd, 0xd5, 0x9c, 0x2e, 0x1b, 0x10, 0x93, 0x97, 0x08, 0x00, 0x2b, 0x2c, 0xf9, 0xae
380 };
381 pSection = (Section*)pDInfoSec2->GetSection( aUserPropSetGUID );
382 if ( pSection )
383 {
384 Dictionary aDict;
385 if ( pSection->GetDictionary( aDict ) )
386 {
387 sal_uInt32 nPropId = aDict.GetProperty( rtl::OUString::createFromAscii("_PID_HLINKS" ));
388 if ( nPropId )
389 {
390 if ( pSection->GetProperty( nPropId, aPropItem ) )
391 {
392 aPropItem.Seek( STREAM_SEEK_TO_BEGIN );
393 aPropItem >> nType;
394 if ( nType == VT_BLOB )
395 {
396 aPropItem >> nPropSize
397 >> nPropCount;
398
399 if ( ! ( nPropCount % 6 ) )
400 {
401 sal_uInt32 i;
402
403 nPropCount /= 6; // 6 propertys a hyperlink
404
405 SdHyperlinkEntry* pHyperlink = 0;
406 for ( i = 0; i < nPropCount; i++ )
407 {
408 pHyperlink = new SdHyperlinkEntry;
409 pHyperlink->nIndex = 0;
410 aPropItem >> nType;
411 if ( nType != VT_I4 )
412 break;
413 aPropItem >> pHyperlink->nPrivate1
414 >> nType;
415 if ( nType != VT_I4 )
416 break;
417 aPropItem >> pHyperlink->nPrivate2
418 >> nType;
419 if ( nType != VT_I4 )
420 break;
421 aPropItem >> pHyperlink->nPrivate3
422 >> nType;
423 if ( nType != VT_I4 )
424 break;
425 aPropItem >> pHyperlink->nInfo;
426 if ( !aPropItem.Read( pHyperlink->aTarget, VT_EMPTY ) )
427 break;
428 if ( !aPropItem.Read( pHyperlink->aSubAdress, VT_EMPTY ) )
429 break;
430 pHyperlink->nStartPos = pHyperlink->nEndPos = -1;
431
432 if ( pHyperlink->aSubAdress.Len() ) // get the converted subadress
433 {
434 sal_uInt32 nPageNumber = 0;
435 String aString( pHyperlink->aSubAdress );
436 ByteString aStringAry[ 3 ];
437 sal_uInt16 nTokenCount = aString.GetTokenCount( ',' );
438 if ( nTokenCount > 3 )
439 nTokenCount = 3;
440 sal_uInt16 nToken;
441 for( nToken = 0; nToken < nTokenCount; nToken++ )
442 aStringAry[ nToken ] = ByteString( aString.GetToken( nToken, (sal_Unicode)',' ), RTL_TEXTENCODING_UTF8 );
443
444 sal_Bool bDocInternalSubAddress = sal_False;
445
446 // first pass, searching for a SlideId
447 for( nToken = 0; nToken < nTokenCount; nToken++ )
448 {
449 if ( aStringAry[ nToken ].IsNumericAscii() )
450 {
451 sal_Int32 nNumber = aStringAry[ nToken ].ToInt32();
452 if ( nNumber & ~0xff )
453 {
454 PptSlidePersistList* pPageList = GetPageList( PPT_SLIDEPAGE );
455 if ( pPageList )
456 {
457 sal_uInt16 nPage = pPageList->FindPage( nNumber );
458 if ( nPage != PPTSLIDEPERSIST_ENTRY_NOTFOUND )
459 {
460 nPageNumber = nPage;
461 bDocInternalSubAddress = sal_True;
462 break;
463 }
464 }
465 }
466 }
467 }
468 if ( !bDocInternalSubAddress )
469 { // second pass, searching for a SlideName
470 for ( nToken = 0; nToken < nTokenCount; nToken++ )
471 {
472 for ( void* pPtr = maSlideNameList.First(); pPtr; pPtr = maSlideNameList.Next() )
473 {
474 if ( ByteString(*(String*)pPtr, RTL_TEXTENCODING_UTF8 ) == aStringAry[ nToken ] )
475 {
476 nPageNumber = maSlideNameList.GetCurPos();
477 bDocInternalSubAddress = sal_True;
478 break;
479 }
480 }
481 }
482 }
483 if ( !bDocInternalSubAddress )
484 { // third pass, searching for a slide number
485 for ( nToken = 0; nToken < nTokenCount; nToken++ )
486 {
487 if ( aStringAry[ nToken ].IsNumericAscii() )
488 {
489 sal_Int32 nNumber = aStringAry[ nToken ].ToInt32();
490 if ( ( nNumber & ~0xff ) == 0 )
491 {
492 nPageNumber = (sal_uInt32)nNumber - 1;
493 bDocInternalSubAddress = sal_True;
494 break;
495 }
496 }
497 }
498 }
499 // if a document internal sub address
500 if ( bDocInternalSubAddress )
501 {
502 if ( nPageNumber < maSlideNameList.Count() )
503 pHyperlink->aConvSubString = *(String*)maSlideNameList.GetObject( nPageNumber );
504 if ( !pHyperlink->aConvSubString.Len() )
505 {
506 pHyperlink->aConvSubString = String( SdResId( STR_PAGE ) );
507 pHyperlink->aConvSubString.Append( sal_Unicode( ' ' ) );
508 pHyperlink->aConvSubString.Append( mpDoc->CreatePageNumValue( (sal_uInt16)nPageNumber + 1 ) );
509 }
510 } else {
511 // if sub address is given but not internal, use it as it is
512 if ( !pHyperlink->aConvSubString.Len() )
513 {
514 pHyperlink->aConvSubString = aString;
515 }
516 }
517 }
518 aHyperList.Insert( pHyperlink, LIST_APPEND );
519 }
520 if ( i != nPropCount )
521 delete pHyperlink;
522 }
523 }
524 }
525 }
526 }
527 }
528 }
529 }
530 delete pDInfoSec2;
531
532 if ( mbDocumentFound )
533 {
534 rStCtrl.Seek( maDocHd.GetRecBegFilePos() + 8 );
535 // HyperList lesen / Indexe der einzelnen Eintraege setzen
536 DffRecordHeader aHyperHd;
537 if ( SeekToRec( rStCtrl, PPT_PST_ExObjList, maDocHd.GetRecEndFilePos(), &aHyperHd ) )
538 {
539 sal_uInt32 nExObjHyperListLen = aHyperHd.GetRecEndFilePos();
540 for ( void* pPtr = aHyperList.First(); pPtr; pPtr = aHyperList.Next() )
541 {
542 DffRecordHeader aHyperE;
543 if ( !SeekToRec( rStCtrl, PPT_PST_ExHyperlink, nExObjHyperListLen, &aHyperE ) )
544 break;
545 if ( !SeekToRec( rStCtrl, PPT_PST_ExHyperlinkAtom, nExObjHyperListLen, NULL, 0 ) )
546 break;
547 rStCtrl.SeekRel( 8 );
548 rStCtrl >> ((SdHyperlinkEntry*)pPtr)->nIndex;
549 aHyperE.SeekToEndOfRecord( rStCtrl );
550 }
551 }
552 }
553
554 Size aVisAreaSize;
555 switch ( aUserEditAtom.eLastViewType )
556 {
557 case 5 : // notes master
558 case 3 : // notes
559 aVisAreaSize = aDocAtom.GetNotesPageSize();
560 break;
561 default :
562 aVisAreaSize = aDocAtom.GetSlidesPageSize();
563 }
564 Scale( aVisAreaSize );
565 pDocShell->SetVisArea( Rectangle( Point(), aVisAreaSize ) );
566
567 ///////////////////////////////////////////////////////////
568 // create master pages:
569 ///////////////////////////////////////////////////////////
570 SfxProgress* pStbMgr = new SfxProgress( pDocShell, String( SdResId( STR_POWERPOINT_IMPORT ) ),
571 pMasterPages->Count() + pSlidePages->Count() + pNotePages->Count() );
572
573 sal_uInt32 nImportedPages = 0;
574 {
575 sal_uInt16 nMasterAnz = GetPageCount( PPT_MASTERPAGE );
576
577 for ( sal_uInt16 nMasterNum = 0; nMasterNum < nMasterAnz; nMasterNum++ )
578 {
579 SetPageNum( nMasterNum, PPT_MASTERPAGE );
580 SdPage* pPage = (SdPage*)MakeBlancPage( sal_True );
581 if ( pPage )
582 {
583 sal_Bool bNotesMaster = (*GetPageList( eAktPageKind ) )[ nAktPageNum ]->bNotesMaster;
584 sal_Bool bStarDrawFiller = (*GetPageList( eAktPageKind ) )[ nAktPageNum ]->bStarDrawFiller;
585
586 PageKind ePgKind = ( bNotesMaster ) ? PK_NOTES : PK_STANDARD;
587 sal_Bool bHandout = (*GetPageList( eAktPageKind ) )[ nAktPageNum ]->bHandoutMaster;
588 if ( bHandout )
589 ePgKind = PK_HANDOUT;
590
591 pPage->SetPageKind( ePgKind );
592 pSdrModel->InsertMasterPage( (SdrPage*)pPage );
593 if ( bNotesMaster && bStarDrawFiller )
594 ((SdPage*)pPage)->SetAutoLayout( AUTOLAYOUT_NOTES, sal_True );
595 if ( nMasterNum )
596 {
597 boost::optional< sal_Int16 > oStartNumbering;
598 SfxStyleSheet* pSheet;
599 if ( nMasterNum == 1 )
600 {
601 ///////////////////
602 // standardsheet //
603 ///////////////////
604 pSheet = (SfxStyleSheet*)mpDoc->GetStyleSheetPool()->Find( String(SdResId( STR_STANDARD_STYLESHEET_NAME )), SD_STYLE_FAMILY_GRAPHICS );
605 if ( pSheet )
606 {
607 SfxItemSet& rItemSet = pSheet->GetItemSet();
608 PPTParagraphObj aParagraph( *pPPTStyleSheet, TSS_TYPE_TEXT_IN_SHAPE, 0 );
609 PPTPortionObj aPortion( *pPPTStyleSheet, TSS_TYPE_TEXT_IN_SHAPE, 0 );
610 aParagraph.AppendPortion( aPortion );
611 aParagraph.ApplyTo( rItemSet, oStartNumbering, (SdrPowerPointImport&)*this, 0xffffffff, NULL );
612 aPortion.ApplyTo( rItemSet, (SdrPowerPointImport&)*this, 0xffffffff );
613 }
614 }
615
616 // PSEUDO
617 pSheet = (SfxStyleSheet*)mpDoc->GetStyleSheetPool()->Find( String(SdResId( STR_PSEUDOSHEET_BACKGROUNDOBJECTS )), SD_STYLE_FAMILY_PSEUDO );
618 if ( pSheet )
619 {
620 SfxItemSet& rItemSet = pSheet->GetItemSet();
621 PPTParagraphObj aParagraph( *pPPTStyleSheet, TSS_TYPE_TEXT_IN_SHAPE, 0 );
622 PPTPortionObj aPortion( *pPPTStyleSheet, TSS_TYPE_TEXT_IN_SHAPE, 0 );
623 aParagraph.AppendPortion( aPortion );
624 aParagraph.ApplyTo( rItemSet, oStartNumbering, (SdrPowerPointImport&)*this, 0xffffffff, NULL );
625 aPortion.ApplyTo( rItemSet, (SdrPowerPointImport&)*this, 0xffffffff );
626 }
627
628 ///////////////////////////////////////////////////////////
629 // create layoutstylesheets, set layoutname and stylesheet
630 // (nur auf Standard- und Notizseiten)
631 ///////////////////////////////////////////////////////////
632 String aLayoutName( SdResId( STR_LAYOUT_DEFAULT_NAME ) );
633 if ( nMasterNum > 2 )
634 {
635 if ( ePgKind == PK_STANDARD )
636 { // Standardseite: Neues Praesentationslayout erzeugen
637 aLayoutName = String( SdResId( STR_LAYOUT_DEFAULT_TITLE_NAME ) );
638 aLayoutName += String::CreateFromInt32( (sal_Int32)( ( nMasterNum + 1 ) / 2 - 1 ) );
639 ( (SdStyleSheetPool*)mpDoc->GetStyleSheetPool() )->CreateLayoutStyleSheets( aLayoutName );
640 }
641 else // Notizseite: Praesentationslayout von der Standardseite verwenden
642 aLayoutName = ( (SdPage*)mpDoc->GetMasterPage( nMasterNum - 1 ) )->GetName();
643 }
644 pPage->SetName( aLayoutName );
645 aLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
646 aLayoutName += String( SdResId( STR_LAYOUT_OUTLINE ) );
647 pPage->SetLayoutName( aLayoutName );
648
649 /////////////////////
650 // set stylesheets //
651 /////////////////////
652 if ( pPage->GetPageKind() == PK_STANDARD )
653 {
654 sal_uInt32 nTitleInstance = TSS_TYPE_PAGETITLE;
655 sal_uInt32 nOutlinerInstance = TSS_TYPE_BODY;
656 const PptSlideLayoutAtom* pSlideLayout = GetSlideLayoutAtom();
657 sal_Bool bSwapStyleSheet = pSlideLayout->eLayout == PPT_LAYOUT_TITLEMASTERSLIDE;
658 if ( bSwapStyleSheet )
659 {
660 nTitleInstance = TSS_TYPE_TITLE;
661 nOutlinerInstance = TSS_TYPE_SUBTITLE;
662 }
663 /////////////////////
664 // titelstylesheet //
665 /////////////////////
666 pSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE );
667 if ( pSheet )
668 {
669 SfxItemSet& rItemSet = pSheet->GetItemSet();
670 PPTParagraphObj aParagraph( *pPPTStyleSheet, nTitleInstance, 0 );
671 PPTPortionObj aPortion( *pPPTStyleSheet, nTitleInstance, 0 );
672 aParagraph.AppendPortion( aPortion );
673 aParagraph.ApplyTo( rItemSet, oStartNumbering, (SdrPowerPointImport&)*this, 0xffffffff, NULL );
674 aPortion.ApplyTo( rItemSet, (SdrPowerPointImport&)*this, 0xffffffff );
675 }
676 ////////////////////////
677 // outlinerstylesheet //
678 ////////////////////////
679 sal_uInt16 nLevel;
680 PPTParagraphObj* pParagraphs[ 9 ];
681 PPTParagraphObj* pPreviousPara = NULL;
682
683 for ( nLevel = 0; nLevel < 9; nLevel++ )
684 {
685 String aName( pPage->GetLayoutName() );
686 aName.Append( (sal_Unicode)( ' ' ) );
687 aName.Append( String::CreateFromInt32( nLevel + 1 ) );
688 SfxStyleSheet* pOutlineSheet = (SfxStyleSheet*)mpDoc->GetStyleSheetPool()->Find( aName, SD_STYLE_FAMILY_MASTERPAGE );
689 DBG_ASSERT( pOutlineSheet, "Vorlage fuer Gliederungsobjekt nicht gefunden" );
690 if ( pOutlineSheet )
691 {
692 pParagraphs[ nLevel ] = new PPTParagraphObj( *pPPTStyleSheet, nOutlinerInstance, nLevel );
693 SfxItemSet& rItemSet = pOutlineSheet->GetItemSet();
694 PPTPortionObj aPortion( *pPPTStyleSheet, nOutlinerInstance, nLevel );
695 pParagraphs[ nLevel ]->AppendPortion( aPortion );
696 pParagraphs[ nLevel ]->ApplyTo( rItemSet, oStartNumbering, (SdrPowerPointImport&)*this, 0xffffffff, pPreviousPara );
697 aPortion.ApplyTo( rItemSet, (SdrPowerPointImport&)*this, 0xffffffff );
698 pPreviousPara = pParagraphs[ nLevel ];
699 }
700 else
701 pParagraphs[ nLevel ] = NULL;
702 }
703 for ( nLevel = 0; nLevel < 9; delete pParagraphs[ nLevel++ ] ) ;
704 /////////////////////////
705 // subtitle stylesheet //
706 /////////////////////////
707 pSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TEXT );
708 if ( pSheet )
709 {
710 SfxItemSet& rItemSet = pSheet->GetItemSet();
711 PPTParagraphObj aParagraph( *pPPTStyleSheet, TSS_TYPE_SUBTITLE, 0 );
712 PPTPortionObj aPortion( *pPPTStyleSheet, TSS_TYPE_SUBTITLE, 0 );
713 aParagraph.AppendPortion( aPortion );
714 aParagraph.ApplyTo( rItemSet, oStartNumbering, (SdrPowerPointImport&)*this, 0xffffffff, NULL );
715 aPortion.ApplyTo( rItemSet, (SdrPowerPointImport&)*this, 0xffffffff );
716 }
717 }
718 else if ( ePgKind == PK_NOTES )
719 {
720 pSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_NOTES );
721 if ( pSheet )
722 {
723 SfxItemSet& rItemSet = pSheet->GetItemSet();
724 PPTParagraphObj aParagraph( *pPPTStyleSheet, TSS_TYPE_NOTES, 0 );
725 PPTPortionObj aPortion( *pPPTStyleSheet, TSS_TYPE_NOTES, 0 );
726 aParagraph.AppendPortion( aPortion );
727 aParagraph.ApplyTo( rItemSet, oStartNumbering, (SdrPowerPointImport&)*this, 0xffffffff, NULL );
728 aPortion.ApplyTo( rItemSet, (SdrPowerPointImport&)*this, 0xffffffff );
729 }
730 }
731 }
732 }
733 }
734 }
735 SdPage* pMPage;
736 sal_uInt16 i;
737 for ( i = 0; i < mpDoc->GetMasterPageCount() && ( (pMPage = (SdPage*)mpDoc->GetMasterPage( i )) != 0 ); i++ )
738 {
739 SetPageNum( i, PPT_MASTERPAGE );
740 /////////////////////////////////////////////
741 // importing master page objects //
742 /////////////////////////////////////////////
743 PptSlidePersistList* pList = GetPageList( eAktPageKind );
744 PptSlidePersistEntry* pPersist = ( pList && ( nAktPageNum < pList->Count() ) )
745 ? (*pList)[ nAktPageNum ] : NULL;
746 if ( pPersist )
747 {
748 if ( pPersist->bStarDrawFiller && pPersist->bNotesMaster && ( nAktPageNum > 2 ) && ( ( nAktPageNum & 1 ) == 0 ) )
749 {
750 pSdrModel->DeleteMasterPage( nAktPageNum );
751 SdrPage* pNotesClone = ((SdPage*)pSdrModel->GetMasterPage( 2 ))->Clone();
752 pSdrModel->InsertMasterPage( pNotesClone, nAktPageNum );
753 if ( pNotesClone )
754 {
755 String aLayoutName( ((SdPage*)pSdrModel->GetMasterPage( nAktPageNum - 1 ))->GetLayoutName() );
756 ((SdPage*)pNotesClone)->SetPresentationLayout( aLayoutName, sal_False, sal_False, sal_False );
757 ((SdPage*)pNotesClone)->SetLayoutName( aLayoutName );
758 }
759 }
760 else if ( pPersist->bStarDrawFiller == sal_False )
761 {
762 PptSlidePersistEntry* pE = pPersist;
763 while( ( pE->aSlideAtom.nFlags & 4 ) && pE->aSlideAtom.nMasterId )
764 {
765 sal_uInt16 nNextMaster = pMasterPages->FindPage( pE->aSlideAtom.nMasterId );
766 if ( nNextMaster == PPTSLIDEPERSIST_ENTRY_NOTFOUND )
767 break;
768 else
769 pE = (*pList)[ nNextMaster ];
770 }
771 SdrObject* pObj = ImportPageBackgroundObject( *pMPage, pE->nBackgroundOffset, sal_True ); // import background
772 if ( pObj )
773 pMPage->NbcInsertObject( pObj );
774
775 sal_Bool bNewAnimationsUsed = sal_False;
776 ProcessData aProcessData( *(*pList)[ nAktPageNum ], (SdPage*)pMPage );
777 sal_uInt32 nFPosMerk = rStCtrl.Tell();
778 DffRecordHeader aPageHd;
779 if ( SeekToAktPage( &aPageHd ) )
780 {
781 if ( mbTracing )
782 mpTracer->AddAttribute( rtl::OUString::createFromAscii( "MasterPage" ), rtl::OUString::valueOf( (sal_Int32) (nAktPageNum + 1) ) );
783
784 while( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPageHd.GetRecEndFilePos() ) )
785 {
786 DffRecordHeader aHd;
787 rStCtrl >> aHd;
788 switch( aHd.nRecType )
789 {
790 case PPT_PST_PPDrawing :
791 {
792 aHd.SeekToBegOfRecord( rStCtrl );
793 DffRecordHeader aPPDrawHd;
794 if ( SeekToRec( rStCtrl, PPT_PST_PPDrawing, aHd.GetRecEndFilePos(), &aPPDrawHd ) )
795 {
796 sal_uInt32 nPPDrawEnd = aPPDrawHd.GetRecEndFilePos();
797 DffRecordHeader aEscherF002Hd;
798 if ( SeekToRec( rStCtrl, DFF_msofbtDgContainer, nPPDrawEnd, &aEscherF002Hd ) )
799 {
800 sal_uInt32 nEscherF002End = aEscherF002Hd.GetRecEndFilePos();
801 DffRecordHeader aEscherObjListHd;
802 if ( SeekToRec( rStCtrl, DFF_msofbtSpgrContainer, nEscherF002End, &aEscherObjListHd ) )
803 {
804 sal_uInt32 nObjCount = 0;
805 while( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aEscherObjListHd.GetRecEndFilePos() ) )
806 {
807 DffRecordHeader aHd2;
808 rStCtrl >> aHd2;
809 if ( ( aHd2.nRecType == DFF_msofbtSpContainer ) || ( aHd2.nRecType == DFF_msofbtSpgrContainer ) )
810 {
811 if ( nObjCount++ ) // skipping the first object
812 {
813 Rectangle aEmpty;
814 aHd2.SeekToBegOfRecord( rStCtrl );
815 SdrObject* pImpObj = ImportObj( rStCtrl, (void*)&aProcessData, aEmpty, aEmpty );
816 if ( pImpObj )
817 {
818 pImpObj->SetLayer( mnBackgroundObjectsLayerID );
819 pMPage->NbcInsertObject( pImpObj );
820 }
821 }
822 }
823 aHd2.SeekToEndOfRecord( rStCtrl );
824 }
825 }
826 }
827 }
828 }
829 break;
830
831 case PPT_PST_ProgTags :
832 {
833 DffRecordHeader aProgTagHd;
834 if ( SeekToContentOfProgTag( 10, rStCtrl, aPageHd, aProgTagHd ) )
835 {
836 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aProgTagHd.GetRecEndFilePos() ) )
837 {
838 DffRecordHeader aProgTagContentHd;
839 rStCtrl >> aProgTagContentHd;
840 switch( aProgTagContentHd.nRecType )
841 {
842 case DFF_msofbtAnimGroup :
843 {
844 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xPage( pMPage->getUnoPage(), ::com::sun::star::uno::UNO_QUERY );
845 ppt::AnimationImporter aImporter( this, rStCtrl );
846 aImporter.import( xPage, aProgTagContentHd );
847 bNewAnimationsUsed = sal_True;
848 }
849 break;
850 }
851 aProgTagContentHd.SeekToEndOfRecord( rStCtrl );
852 }
853 }
854 }
855 break;
856 }
857 aHd.SeekToEndOfRecord( rStCtrl );
858 }
859 if ( mbTracing )
860 mpTracer->RemoveAttribute( rtl::OUString::createFromAscii( "MasterPage" ) );
861 }
862 rStCtrl.Seek( nFPosMerk );
863 ImportPageEffect( (SdPage*)pMPage, bNewAnimationsUsed );
864
865 ///////////////////////
866 // background object //
867 ///////////////////////
868 pObj = pMPage->GetObj( 0 );
869 if ( pObj && pObj->GetObjIdentifier() == OBJ_RECT )
870 {
871 if ( pMPage->GetPageKind() == PK_STANDARD )
872 {
873 // transform data from imported background object to new form
874 // and delete the object. It was used as container to transport
875 // the attributes of the MasterPage background fill
876 SfxStyleSheet* pSheet = pMPage->GetStyleSheetForMasterPageBackground();
877
878 if(pSheet)
879 {
880 // if we have a StyleSheet (for Masterpages), set attributes there and use it
881 pSheet->GetItemSet().ClearItem();
882 pSheet->GetItemSet().Put(pObj->GetMergedItemSet());
883 pMPage->getSdrPageProperties().ClearItem();
884 pMPage->getSdrPageProperties().SetStyleSheet(pSheet);
885 }
886 else
887 {
888 // without StyleSheet, set attributes directly. This
889 // should not be done at all and is an error (will be asserted by SdrPage)
890 pMPage->getSdrPageProperties().ClearItem();
891 pMPage->getSdrPageProperties().PutItemSet(pObj->GetMergedItemSet());
892 }
893
894 pMPage->RemoveObject(pObj->GetOrdNum());
895 SdrObject::Free(pObj);
896 }
897 }
898 }
899 }
900 if( pStbMgr )
901 pStbMgr->SetState( nImportedPages++ );
902 }
903 ////////////////////////////////////
904 // importing slide pages //
905 ////////////////////////////////////
906 {
907 sal_uInt32 nFPosMerk = rStCtrl.Tell();
908 PptPageKind ePageKind = eAktPageKind;
909 sal_uInt16 nPageNum = nAktPageNum;
910
911 SdPage* pHandoutPage = (SdPage*)MakeBlancPage( sal_False );
912 pHandoutPage->SetPageKind( PK_HANDOUT );
913 pSdrModel->InsertPage( pHandoutPage );
914
915 sal_uInt16 nPageAnz = GetPageCount( PPT_SLIDEPAGE );
916 if ( nPageAnz )
917 {
918 for ( sal_uInt16 nPage = 0; nPage < nPageAnz; nPage++ )
919 {
920 sal_Bool bNewAnimationsUsed = sal_False;
921
922 mePresChange = PRESCHANGE_SEMIAUTO;
923 SetPageNum( nPage, PPT_SLIDEPAGE );
924 SdPage* pPage = (SdPage*)MakeBlancPage( sal_False );
925 PptSlidePersistEntry* pMasterPersist = NULL;
926 if ( HasMasterPage( nPage, PPT_SLIDEPAGE ) ) // try to get the LayoutName from the masterpage
927 {
928 sal_uInt16 nMasterNum = GetMasterPageIndex( nAktPageNum, eAktPageKind );
929 pPage->TRG_SetMasterPage(*pSdrModel->GetMasterPage(nMasterNum));
930 PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE );
931 if ( pPageList && nMasterNum < pPageList->Count() )
932 pMasterPersist = (*pPageList)[ nMasterNum ];
933 pPage->SetLayoutName(((SdPage&)pPage->TRG_GetMasterPage()).GetLayoutName());
934 }
935 pPage->SetPageKind( PK_STANDARD );
936 pSdrModel->InsertPage( pPage ); // SJ: #i29625# because of form controls, the
937 ImportPage( pPage, pMasterPersist ); // page must be inserted before importing
938 SetHeaderFooterPageSettings( pPage, pMasterPersist );
939 // CWS preseng01: pPage->SetPageKind( PK_STANDARD );
940
941 DffRecordHeader aPageHd;
942 if ( SeekToAktPage( &aPageHd ) )
943 {
944 aPageHd.SeekToContent( rStCtrl );
945 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPageHd.GetRecEndFilePos() ) )
946 {
947 DffRecordHeader aHd;
948 rStCtrl >> aHd;
949 switch ( aHd.nRecType )
950 {
951 case PPT_PST_ProgTags :
952 {
953 DffRecordHeader aProgTagHd;
954 if ( SeekToContentOfProgTag( 10, rStCtrl, aPageHd, aProgTagHd ) )
955 {
956 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aProgTagHd.GetRecEndFilePos() ) )
957 {
958 DffRecordHeader aProgTagContentHd;
959 rStCtrl >> aProgTagContentHd;
960 switch( aProgTagContentHd.nRecType )
961 {
962 /*
963 case PPT_PST_CommentContainer :
964 {
965
966 }
967 break;
968 */
969 case DFF_msofbtAnimGroup :
970 {
971 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xPage( pPage->getUnoPage(), ::com::sun::star::uno::UNO_QUERY );
972 ppt::AnimationImporter aImporter( this, rStCtrl );
973 aImporter.import( xPage, aProgTagContentHd );
974 bNewAnimationsUsed = sal_True;
975 }
976 break;
977
978 case PPT_PST_NewlyAddedAtomByXP11008 : // ???
979 break;
980
981 case PPT_PST_NewlyAddedAtomByXP12011 : // ??? don't know, this atom is always 8 bytes big
982 break; // and is appearing in nearly every l10 progtag
983 }
984 aProgTagContentHd.SeekToEndOfRecord( rStCtrl );
985 }
986 }
987 }
988 break;
989
990 case PPT_PST_HeadersFooters :
991 case PPT_PST_PPDrawing :
992 default:
993 break;
994 }
995
996 aHd.SeekToEndOfRecord( rStCtrl );
997 }
998 ImportPageEffect( (SdPage*)pPage, bNewAnimationsUsed );
999 }
1000
1001 // creating the corresponding note page
1002 eAktPageKind = PPT_NOTEPAGE;
1003 SdPage* pNotesPage = (SdPage*)MakeBlancPage( sal_False );
1004 sal_uInt16 nNotesMasterNum = GetMasterPageIndex( nPage, PPT_SLIDEPAGE ) + 1;
1005 sal_uInt32 nNotesPageId = GetNotesPageId( nPage );
1006 if ( nNotesPageId )
1007 {
1008 nImportedPages++;
1009 sal_uInt16 nNotesPageIndex = pNotePages->FindPage( nNotesPageId );
1010 if ( nNotesPageIndex == PPTSLIDEPERSIST_ENTRY_NOTFOUND )
1011 nNotesPageIndex = 0;
1012 SetPageNum( nNotesPageIndex, PPT_NOTEPAGE );
1013 PptSlidePersistEntry* pMasterPersist2 = NULL;
1014 if ( HasMasterPage( nNotesPageIndex, PPT_NOTEPAGE ) ) // try to get the LayoutName from the masterpage
1015 {
1016 pNotesPage->TRG_SetMasterPage(*pSdrModel->GetMasterPage(nNotesMasterNum));
1017 PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE );
1018 if ( pPageList && nNotesMasterNum < pPageList->Count() )
1019 pMasterPersist2 = (*pPageList)[ nNotesMasterNum ];
1020 pNotesPage->SetLayoutName( ((SdPage&)pNotesPage->TRG_GetMasterPage()).GetLayoutName() );
1021 }
1022 pNotesPage->SetPageKind( PK_NOTES );
1023 pNotesPage->TRG_SetMasterPage(*pSdrModel->GetMasterPage(nNotesMasterNum));
1024 pSdrModel->InsertPage( pNotesPage ); // SJ: #i29625# because of form controls, the
1025 ImportPage( pNotesPage, pMasterPersist2 ); // page must be inserted before importing
1026 SetHeaderFooterPageSettings( pNotesPage, pMasterPersist2 );
1027 pNotesPage->SetAutoLayout( AUTOLAYOUT_NOTES, sal_False );
1028 }
1029 else
1030 {
1031 pNotesPage->SetPageKind( PK_NOTES );
1032 pNotesPage->TRG_SetMasterPage(*pSdrModel->GetMasterPage(nNotesMasterNum));
1033 pNotesPage->SetAutoLayout( AUTOLAYOUT_NOTES, sal_True );
1034 pSdrModel->InsertPage( pNotesPage );
1035 SdrObject* pPageObj = pNotesPage->GetPresObj( PRESOBJ_PAGE, 1 );
1036 if ( pPageObj )
1037 ((SdrPageObj*)pPageObj)->SetReferencedPage(pSdrModel->GetPage(( nPage << 1 ) + 1));
1038 }
1039
1040 if( pStbMgr )
1041 pStbMgr->SetState( nImportedPages++ );
1042 }
1043 //////////////
1044 }
1045 else
1046 {
1047 // Das kann bei Dokumentvorlagen vorkommen
1048 eAktPageKind = PPT_SLIDEPAGE;
1049 SdrPage* pPage = MakeBlancPage( sal_False );
1050 pSdrModel->InsertPage( pPage );
1051
1052 // #i37397#, trying to set the title master for the first page
1053 sal_uInt16 nMaster, nMasterCount = pSdrModel->GetMasterPageCount();
1054 SdPage* pFoundMaster = NULL;
1055 for ( nMaster = 1; nMaster < nMasterCount; nMaster++ )
1056 {
1057 SdPage* pMaster = static_cast<SdPage*>( pSdrModel->GetMasterPage( nMaster ) );
1058 if ( pMaster->GetPageKind() == PK_STANDARD )
1059 {
1060 SetPageNum( nMaster, PPT_MASTERPAGE );
1061 if ( !pFoundMaster )
1062 pFoundMaster = pMaster;
1063 else if ( GetSlideLayoutAtom()->eLayout == PPT_LAYOUT_TITLEMASTERSLIDE )
1064 pFoundMaster = pMaster;
1065 if ( GetSlideLayoutAtom()->eLayout == PPT_LAYOUT_TITLEMASTERSLIDE )
1066 break;
1067 }
1068 }
1069 if ( pFoundMaster )
1070 {
1071 ((SdPage*)pPage)->TRG_SetMasterPage( *((SdPage*)pFoundMaster) );
1072 ((SdPage*)pPage)->SetLayoutName( ((SdPage*)pFoundMaster)->GetLayoutName() );
1073 }
1074 ((SdPage*)pPage)->SetAutoLayout( AUTOLAYOUT_TITLE, sal_True, sal_True );
1075
1076 eAktPageKind = PPT_NOTEPAGE;
1077 SdrPage* pNPage = MakeBlancPage( sal_False );
1078 pSdrModel->InsertPage( pNPage );
1079 }
1080 SetPageNum( nPageNum, ePageKind );
1081 rStCtrl.Seek( nFPosMerk );
1082 }
1083 ///////////////////////////////////////////////////////////////////
1084 // Handzettel und Notiz-Seiten erzeugen //
1085 ///////////////////////////////////////////////////////////////////
1086 bOk = mpDoc->CreateMissingNotesAndHandoutPages();
1087 if ( bOk )
1088 {
1089 for ( i = 0; i < mpDoc->GetSdPageCount( PK_STANDARD ); i++ )
1090 {
1091 ////////////////////
1092 // set AutoLayout //
1093 ////////////////////
1094 SetPageNum( i, PPT_SLIDEPAGE );
1095 SdPage* pPage = mpDoc->GetSdPage( i, PK_STANDARD );
1096 AutoLayout eAutoLayout = AUTOLAYOUT_NONE;
1097 const PptSlideLayoutAtom* pSlideLayout = GetSlideLayoutAtom();
1098 if ( pSlideLayout )
1099 {
1100 switch ( pSlideLayout->eLayout ) // Praesentationslayouts fuer Standard-Seiten
1101 {
1102 case PPT_LAYOUT_TITLEANDBODYSLIDE :
1103 {
1104 eAutoLayout = AUTOLAYOUT_ENUM;
1105 sal_uInt16 nID1 = pSlideLayout->aPlaceholderId[ 1 ];
1106 switch ( nID1 )
1107 {
1108 case PPT_PLACEHOLDER_BODY :
1109 eAutoLayout = AUTOLAYOUT_ENUM;
1110 break;
1111 case PPT_PLACEHOLDER_TABLE :
1112 eAutoLayout = AUTOLAYOUT_TAB;
1113 break;
1114 case PPT_PLACEHOLDER_ORGANISZATIONCHART :
1115 eAutoLayout = AUTOLAYOUT_ORG;
1116 break;
1117 case PPT_PLACEHOLDER_GRAPH :
1118 eAutoLayout = AUTOLAYOUT_CHART;
1119 break;
1120 case PPT_PLACEHOLDER_OBJECT :
1121 eAutoLayout = AUTOLAYOUT_OBJ;
1122 break;
1123 case PPT_PLACEHOLDER_VERTICALTEXTBODY :
1124 eAutoLayout = AUTOLAYOUT_TITLE_VERTICAL_OUTLINE;
1125 break;
1126 }
1127 }
1128 break;
1129
1130 case PPT_LAYOUT_2COLUMNSANDTITLE :
1131 {
1132 eAutoLayout = AUTOLAYOUT_2TEXT;
1133 sal_uInt16 nID1 = pSlideLayout->aPlaceholderId[ 1 ];
1134 sal_uInt16 nID2 = pSlideLayout->aPlaceholderId[ 2 ];
1135 if ( nID1 == PPT_PLACEHOLDER_BODY && nID2 == PPT_PLACEHOLDER_GRAPH )
1136 eAutoLayout = AUTOLAYOUT_TEXTCHART;
1137 else if ( nID1 == PPT_PLACEHOLDER_GRAPH && nID2 == PPT_PLACEHOLDER_BODY )
1138 eAutoLayout = AUTOLAYOUT_CHARTTEXT;
1139 else if ( nID1 == PPT_PLACEHOLDER_BODY && nID2 == PPT_PLACEHOLDER_CLIPART )
1140 eAutoLayout = AUTOLAYOUT_TEXTCLIP;
1141 else if ( nID1 == PPT_PLACEHOLDER_CLIPART && nID2 == PPT_PLACEHOLDER_BODY )
1142 eAutoLayout = AUTOLAYOUT_CLIPTEXT;
1143 else if ( nID1 == PPT_PLACEHOLDER_CLIPART && nID2 == PPT_PLACEHOLDER_VERTICALTEXTBODY )
1144 eAutoLayout = AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART;
1145 else if ( ( nID1 == PPT_PLACEHOLDER_BODY )
1146 && ( ( nID2 == PPT_PLACEHOLDER_OBJECT ) || ( nID2 == PPT_PLACEHOLDER_MEDIACLIP ) ) )
1147 eAutoLayout = AUTOLAYOUT_TEXTOBJ;
1148 else if ( ( nID2 == PPT_PLACEHOLDER_BODY )
1149 && ( ( nID1 == PPT_PLACEHOLDER_OBJECT ) || ( nID1 == PPT_PLACEHOLDER_MEDIACLIP ) ) )
1150 eAutoLayout = AUTOLAYOUT_OBJTEXT;
1151 else if ( ( nID1 == PPT_PLACEHOLDER_OBJECT ) && ( nID2 == PPT_PLACEHOLDER_OBJECT ) )
1152 eAutoLayout = AUTOLAYOUT_OBJ;
1153 }
1154 break;
1155
1156 case PPT_LAYOUT_2ROWSANDTITLE :
1157 {
1158 eAutoLayout = AUTOLAYOUT_2TEXT;
1159 sal_uInt16 nID1 = pSlideLayout->aPlaceholderId[ 1 ];
1160 sal_uInt16 nID2 = pSlideLayout->aPlaceholderId[ 2 ];
1161 if ( nID1 == PPT_PLACEHOLDER_BODY && nID2 == PPT_PLACEHOLDER_OBJECT )
1162 eAutoLayout = AUTOLAYOUT_TEXTOVEROBJ;
1163 else if ( nID1 == PPT_PLACEHOLDER_OBJECT && nID2 == PPT_PLACEHOLDER_BODY )
1164 eAutoLayout = AUTOLAYOUT_OBJOVERTEXT;
1165 }
1166 break;
1167
1168 case PPT_LAYOUT_TITLESLIDE :
1169 eAutoLayout = AUTOLAYOUT_TITLE;
1170 break;
1171 case PPT_LAYOUT_ONLYTITLE :
1172 eAutoLayout = AUTOLAYOUT_ONLY_TITLE;
1173 break;
1174 case PPT_LAYOUT_RIGHTCOLUMN2ROWS :
1175 eAutoLayout = AUTOLAYOUT_TEXT2OBJ;
1176 break;
1177 case PPT_LAYOUT_LEFTCOLUMN2ROWS :
1178 eAutoLayout = AUTOLAYOUT_2OBJTEXT;
1179 break;
1180 case PPT_LAYOUT_TOPROW2COLUMN :
1181 eAutoLayout = AUTOLAYOUT_2OBJOVERTEXT;
1182 break;
1183 case PPT_LAYOUT_4OBJECTS :
1184 eAutoLayout = AUTOLAYOUT_4OBJ;
1185 break;
1186 case PPT_LAYOUT_BIGOBJECT :
1187 eAutoLayout = AUTOLAYOUT_OBJ;
1188 break;
1189 case PPT_LAYOUT_TITLERIGHTBODYLEFT :
1190 eAutoLayout = AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE; // AUTOLAYOUT_ENUM;
1191 break;
1192 case PPT_LAYOUT_TITLERIGHT2BODIESLEFT :
1193 eAutoLayout = AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART; // AUTOLAYOUT_TEXT2OBJ;
1194 break;
1195
1196 case PPT_LAYOUT_BOTTOMROW2COLUMNS :
1197 case PPT_LAYOUT_BLANCSLIDE :
1198 case PPT_LAYOUT_MASTERSLIDE : // Layout der Standard- und Titel-MasterPage
1199 case PPT_LAYOUT_TITLEMASTERSLIDE :
1200 case PPT_LAYOUT_MASTERNOTES : // Layout der Notizen-MasterPage
1201 case PPT_LAYOUT_NOTESTITLEBODY : // Praesentationslayout fuer Notiz-Seiten
1202 case PPT_LAYOUT_HANDOUTLAYOUT : // Praesentationslayout fuer Handzettelseiten
1203 eAutoLayout = AUTOLAYOUT_NONE;
1204 break;
1205 }
1206 if ( eAutoLayout != AUTOLAYOUT_NONE )
1207 pPage->SetAutoLayout( eAutoLayout, sal_False );
1208 }
1209 }
1210 //////////////////////////////////////////////////////////////
1211 // Handzettel-MasterPage: Autolayout setzen //
1212 //////////////////////////////////////////////////////////////
1213 SdPage* pHandoutMPage = mpDoc->GetMasterSdPage( 0, PK_HANDOUT );
1214 pHandoutMPage->SetAutoLayout( AUTOLAYOUT_HANDOUT6, sal_True, sal_True );
1215 }
1216
1217 sal_uInt32 nSlideCount = GetPageCount();
1218 for ( i = 0; ( i < nSlideCount) && ( i < maSlideNameList.Count() ); i++ )
1219 {
1220 SdPage* pPage = mpDoc->GetSdPage( i, PK_STANDARD );
1221 String* pName = (String*)maSlideNameList.GetObject( i );
1222 if ( pPage && pName )
1223 {
1224 if ( pName->Len() )
1225 pPage->SetName( *pName );
1226 else
1227 *pName = pPage->GetName();
1228 }
1229 }
1230 if ( mbDocumentFound )
1231 {
1232 mpDoc->SetSummationOfParagraphs( sal_True );
1233 if ( pDocShell )
1234 {
1235 ::sd::FrameView* pFrameView = mpDoc->GetFrameView( 0 );
1236 if ( !pFrameView )
1237 {
1238 List* pFrameViewList = mpDoc->GetFrameViewList();
1239 if ( pFrameViewList )
1240 {
1241 pFrameView = new ::sd::FrameView( mpDoc );
1242 if ( pFrameView )
1243 pFrameViewList->Insert( pFrameView );
1244 }
1245 }
1246 if ( pFrameView )
1247 {
1248 sal_uInt16 nSelectedPage = 0;
1249 PageKind ePageKind = PK_STANDARD;
1250 EditMode eEditMode = EM_PAGE;
1251
1252 switch ( aUserEditAtom.eLastViewType )
1253 {
1254 case 7 : // outliner view
1255 {
1256 SfxItemSet* pSet = mrMed.GetItemSet();
1257 if ( pSet )
1258 pSet->Put( SfxUInt16Item( SID_VIEW_ID, 3 ) );
1259 }
1260 break;
1261 case 8 : // slide sorter
1262 {
1263 SfxItemSet* pSet = mrMed.GetItemSet();
1264 if ( pSet )
1265 pSet->Put( SfxUInt16Item( SID_VIEW_ID, 2 ) );
1266 }
1267 break;
1268 case 10 : // titlemaster
1269 nSelectedPage = 1;
1270 case 2 : // master
1271 {
1272 ePageKind = PK_STANDARD;
1273 eEditMode = EM_MASTERPAGE;
1274 }
1275 break;
1276 case 5 : // notes master
1277 eEditMode = EM_MASTERPAGE;
1278 case 3 : // notes
1279 ePageKind = PK_NOTES;
1280 break;
1281 case 4 : // handout
1282 ePageKind = PK_HANDOUT;
1283 break;
1284 default :
1285 case 1 : // normal
1286 break;
1287 }
1288 pFrameView->SetPageKind( ePageKind );
1289 pFrameView->SetSelectedPage( nSelectedPage );
1290 pFrameView->SetViewShEditMode( eEditMode, ePageKind );
1291 }
1292 }
1293 DffRecordHeader aCustomShowHeader;
1294 // custom show einlesen und setzen
1295 rStCtrl.Seek( maDocHd.GetRecBegFilePos() + 8 );
1296 if ( SeekToRec( rStCtrl, PPT_PST_NamedShows, maDocHd.GetRecEndFilePos(), &aCustomShowHeader ) )
1297 {
1298 DffRecordHeader aCuHeader;
1299 while( SeekToRec( rStCtrl, PPT_PST_NamedShow, aCustomShowHeader.GetRecEndFilePos(), &aCuHeader ) )
1300 {
1301 DffRecordHeader aContent;
1302 if ( SeekToRec( rStCtrl, PPT_PST_CString, aCuHeader.GetRecEndFilePos(), &aContent ) )
1303 {
1304 String aCuShow;
1305 aContent.SeekToBegOfRecord( rStCtrl );
1306 if ( ReadString( aCuShow ) )
1307 {
1308 if ( SeekToRec( rStCtrl, PPT_PST_NamedShowSlides, aCuHeader.GetRecEndFilePos(), &aContent ) )
1309 {
1310 PptSlidePersistList* pPageList = GetPageList( PPT_SLIDEPAGE );
1311 sal_uInt32 nSCount = aContent.nRecLen >> 2;
1312 if ( pPageList && nSCount )
1313 {
1314 List* pList = mpDoc->GetCustomShowList( sal_True );
1315 if ( pList )
1316 {
1317 SdCustomShow* pSdCustomShow = new SdCustomShow( mpDoc );
1318 if ( pSdCustomShow )
1319 {
1320 pSdCustomShow->SetName( aCuShow );
1321 sal_uInt32 nFound = 0;
1322 for ( sal_uInt32 nS = 0; nS < nSCount; nS++ )
1323 {
1324 sal_uInt32 nPageNumber;
1325 rStCtrl >> nPageNumber;
1326 sal_uInt16 nPage = pPageList->FindPage( nPageNumber );
1327 if ( nPage != PPTSLIDEPERSIST_ENTRY_NOTFOUND )
1328 {
1329 SdPage* pPage = mpDoc->GetSdPage( nPage, PK_STANDARD );
1330 if ( pPage )
1331 {
1332 pSdCustomShow->Insert( pPage, LIST_APPEND );
1333 nFound++;
1334 }
1335 }
1336 }
1337 if ( nFound )
1338 pList->Insert( pSdCustomShow, LIST_APPEND );
1339 else
1340 delete pSdCustomShow;
1341 }
1342 }
1343 }
1344 }
1345 }
1346 }
1347 }
1348 }
1349 // this is defaulted, maybe there is no SSDocInfoAtom
1350 String aCustomShow;
1351 sal_uInt32 nFlags = 1; // Bit 0: Auto advance
1352 sal_uInt32 nPenColor = 0x1000000;
1353 sal_Int32 nRestartTime = 0x7fffffff;
1354 sal_uInt16 nStartSlide = 0;
1355 sal_Int16 nEndSlide = 0;
1356
1357 // read the pres. configuration
1358 rStCtrl.Seek( maDocHd.GetRecBegFilePos() + 8 );
1359 if ( SeekToRec( rStCtrl, PPT_PST_SSDocInfoAtom, maDocHd.GetRecEndFilePos(), &aCustomShowHeader ) )
1360 {
1361 rStCtrl >> nPenColor
1362 >> nRestartTime
1363 >> nStartSlide
1364 >> nEndSlide;
1365
1366 sal_Unicode nChar;
1367 for ( sal_uInt32 i2 = 0; i2 < 32; i2++ )
1368 {
1369 rStCtrl >> nChar;
1370 if ( nChar )
1371 aCustomShow.Append( nChar );
1372 else
1373 {
1374 rStCtrl.SeekRel( ( 31 - i2 ) << 1 );
1375 break;
1376 }
1377 }
1378 rStCtrl >> nFlags;
1379 }
1380 // set the current custom show
1381 if ( aCustomShow.Len() )
1382 {
1383 void* pPtr;
1384 List* pList = mpDoc->GetCustomShowList( sal_False );
1385 if ( pList )
1386 {
1387 for ( pPtr = pList->First(); pPtr; pPtr = pList->Next() )
1388 {
1389 if ( ((SdCustomShow*)pPtr)->GetName() == aCustomShow )
1390 break;
1391 }
1392 if ( !pPtr )
1393 pList->First();
1394 }
1395 }
1396 sd::PresentationSettings& rPresSettings = mpDoc->getPresentationSettings();
1397
1398 rPresSettings.mbManual = ( nFlags & 1 ) == 0;
1399 rPresSettings.mbAnimationAllowed = ( nFlags & 2 ) == 0;
1400 rPresSettings.mbAll = ( nFlags & 4 ) == 0;
1401 rPresSettings.mbCustomShow = ( nFlags & 8 ) != 0;
1402 rPresSettings.mbEndless = ( nFlags & 0x80 ) != 0;
1403 rPresSettings.mbFullScreen = ( nFlags & 0x10 ) == 0;
1404 // rPresSettings.mnPauseTimeout;
1405 // rPresSettings.mbShowLogo;
1406 if ( nStartSlide && ( nStartSlide <= GetPageCount() ) )
1407 {
1408 SdPage* pPage = mpDoc->GetSdPage( nStartSlide - 1, PK_STANDARD );
1409 if ( pPage )
1410 rPresSettings.maPresPage = pPage->GetName();
1411 }
1412 }
1413
1414 delete pStbMgr;
1415
1416 // read DocumentInfo
1417 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1418 mpDoc->GetObjectShell()->GetModel(), uno::UNO_QUERY_THROW);
1419 uno::Reference<document::XDocumentProperties> xDocProps
1420 = xDPS->getDocumentProperties();
1421 sfx2::LoadOlePropertySet(xDocProps, &mrStorage);
1422 xDocProps->setTemplateName(::rtl::OUString());
1423
1424 pSdrModel->setLock( sal_False );
1425 pSdrModel->EnableUndo(true);
1426 return bOk;
1427 }
1428
SetHeaderFooterPageSettings(SdPage * pPage,const PptSlidePersistEntry * pMasterPersist)1429 void ImplSdPPTImport::SetHeaderFooterPageSettings( SdPage* pPage, const PptSlidePersistEntry* pMasterPersist )
1430 {
1431 sal_uInt32 i;
1432 PptSlidePersistList* pList = GetPageList( eAktPageKind );
1433 if ( ( !pList ) || ( pList->Count() <= nAktPageNum ) )
1434 return;
1435 PptSlidePersistEntry& rSlidePersist = *(*pList)[ nAktPageNum ];
1436 HeaderFooterEntry* pHFE = rSlidePersist.pHeaderFooterEntry;
1437 if ( pHFE )
1438 {
1439 for ( i = 0; i < 4; i++ )
1440 {
1441 bool bVisible = pHFE->IsToDisplay( i );
1442 if ( ( eAktPageKind == PPT_SLIDEPAGE )
1443 && ( rSlidePersist.aSlideAtom.aLayout.eLayout == PPT_LAYOUT_TITLESLIDE )
1444 && ( aDocAtom.bTitlePlaceholdersOmitted == sal_True ) )
1445 {
1446 bVisible = sal_False;
1447 }
1448 if ( bVisible && pMasterPersist )
1449 {
1450 sal_uInt32 nPosition = pHFE->NeedToImportInstance( i, rSlidePersist );
1451 if ( nPosition )
1452 {
1453 Rectangle aEmpty;
1454 bVisible = sal_False;
1455 rStCtrl.Seek( nPosition );
1456 ProcessData aProcessData( rSlidePersist, (SdPage*)pPage );
1457 SdrObject* pObj = ImportObj( rStCtrl, (void*)&aProcessData, aEmpty, aEmpty );
1458 if ( pObj )
1459 pPage->NbcInsertObject( pObj, 0 );
1460 }
1461 }
1462 String aPlaceHolderString;
1463 if ( pHFE->pPlaceholder )
1464 aPlaceHolderString = pHFE->pPlaceholder[ i ];
1465
1466 sd::HeaderFooterSettings rHeaderFooterSettings( pPage->getHeaderFooterSettings() );
1467 switch( i )
1468 {
1469 case 0 :
1470 {
1471 rHeaderFooterSettings.mbDateTimeVisible = bVisible;
1472 rHeaderFooterSettings.mbDateTimeIsFixed = ( pHFE->nAtom & 0x20000 ) == 0;
1473 rHeaderFooterSettings.maDateTimeText = aPlaceHolderString;
1474 SvxDateFormat eDateFormat;
1475 SvxTimeFormat eTimeFormat;
1476 PPTFieldEntry::GetDateTime( pHFE->nAtom & 0xff, eDateFormat, eTimeFormat );
1477 rHeaderFooterSettings.meDateTimeFormat = eDateFormat | ( eTimeFormat << 4 );
1478 }
1479 break;
1480 case 1 :
1481 {
1482 rHeaderFooterSettings.mbHeaderVisible = bVisible;
1483 rHeaderFooterSettings.maHeaderText = aPlaceHolderString;
1484 }
1485 break;
1486 case 2 :
1487 {
1488 rHeaderFooterSettings.mbFooterVisible = bVisible;
1489 rHeaderFooterSettings.maFooterText = aPlaceHolderString;
1490 }
1491 break;
1492 case 3 :
1493 {
1494 rHeaderFooterSettings.mbSlideNumberVisible = bVisible;
1495 }
1496 break;
1497 }
1498 pPage->setHeaderFooterSettings( rHeaderFooterSettings );
1499 }
1500 }
1501 }
1502
1503 //////////////////////////////////////////////////////////////////////////
1504 //
1505 // Import von Seiten
1506 //
1507 //////////////////////////////////////////////////////////////////////////
1508
1509 struct Ppt97AnimationStlSortHelper
1510 {
1511 bool operator()( const std::pair< SdrObject*, Ppt97AnimationPtr >& p1, const std::pair< SdrObject*, Ppt97AnimationPtr >& p2 );
1512 };
1513
operator ()(const std::pair<SdrObject *,Ppt97AnimationPtr> & p1,const std::pair<SdrObject *,Ppt97AnimationPtr> & p2)1514 bool Ppt97AnimationStlSortHelper::operator()( const std::pair< SdrObject*, Ppt97AnimationPtr >& p1, const std::pair< SdrObject*, Ppt97AnimationPtr >& p2 )
1515 {
1516 if( !p1.second.get() || !p2.second.get() )
1517 return true;
1518 if( *p1.second < *p2.second )
1519 return true;
1520 if( *p1.second > *p2.second )
1521 return false;
1522 if( p1.first->GetOrdNum() < p2.first->GetOrdNum() )
1523 return true;
1524 return false;
1525 }
1526
ImportPageEffect(SdPage * pPage,const sal_Bool bNewAnimationsUsed)1527 void ImplSdPPTImport::ImportPageEffect( SdPage* pPage, const sal_Bool bNewAnimationsUsed )
1528 {
1529 sal_uLong nFilePosMerk = rStCtrl.Tell();
1530
1531 // PageKind an der Seite setzen (bisher nur PK_STANDARD oder PK_NOTES)
1532 if ( pPage->GetPageKind() == PK_STANDARD )
1533 {
1534 PptSlidePersistList* pPersistList = GetPageList( eAktPageKind );
1535 PptSlidePersistEntry* pActualSlidePersist = ( pPersistList && ( nAktPageNum < pPersistList->Count() ) )
1536 ? (*pPersistList)[ nAktPageNum ] : NULL;
1537
1538 if ( pActualSlidePersist && ( eAktPageKind == PPT_SLIDEPAGE ) )
1539 {
1540 if ( ! ( pActualSlidePersist->aSlideAtom.nFlags & 1 ) ) // do not follow master objects ?
1541 {
1542 if(pPage->TRG_HasMasterPage())
1543 {
1544 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1545 aVisibleLayers.Set(mnBackgroundObjectsLayerID, sal_False);
1546 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
1547 }
1548 }
1549 }
1550 DffRecordHeader aPageRecHd;
1551 if ( pPage && SeekToAktPage( &aPageRecHd ) )
1552 {
1553 sal_uLong nPageRecEnd = aPageRecHd.GetRecEndFilePos();
1554
1555 sal_Bool bTryTwice = ( eAktPageKind == PPT_SLIDEPAGE );
1556 sal_Bool bSSSlideInfoAtom = sal_False;
1557 while ( sal_True )
1558 {
1559 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < nPageRecEnd ) )
1560 {
1561 DffRecordHeader aHd;
1562 rStCtrl >> aHd;
1563 switch ( aHd.nRecType )
1564 {
1565 case PPT_PST_SSSlideInfoAtom:
1566 {
1567 bSSSlideInfoAtom = sal_True;
1568 if ( eAktPageKind == PPT_MASTERPAGE )
1569 {
1570 if ( pActualSlidePersist )
1571 pActualSlidePersist->aPersistAtom.nReserved = aHd.GetRecBegFilePos();
1572 }
1573 else
1574 {
1575 sal_Int8 nDirection, nTransitionType, nByteDummy, nSpeed;
1576 sal_Int16 nBuildFlags;
1577 sal_Int32 nSlideTime, nSoundRef;
1578 rStCtrl >> nSlideTime // Standzeit (in Ticks)
1579 >> nSoundRef // Index in SoundCollection
1580 >> nDirection // Richtung des Ueberblendeffekts
1581 >> nTransitionType // Ueberblendeffekt
1582 >> nBuildFlags // Buildflags (s.u.)
1583 >> nSpeed // Geschwindigkeit (langsam, mittel, schnell)
1584 >> nByteDummy >> nByteDummy >> nByteDummy;
1585
1586 switch ( nTransitionType )
1587 {
1588 case PPT_TRANSITION_TYPE_BLINDS :
1589 {
1590 if ( nDirection == 0 )
1591 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_VERTICAL_STRIPES );// Vertikal blenden
1592 else if ( nDirection == 1 )
1593 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_HORIZONTAL_STRIPES );// Horizontal blenden
1594 }
1595 break;
1596 case PPT_TRANSITION_TYPE_CHECKER :
1597 {
1598 if ( nDirection == 0 )
1599 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_HORIZONTAL_CHECKERBOARD );// Vertikal versetzt einblenden ??
1600 else if ( nDirection == 1 )
1601 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_VERTICAL_CHECKERBOARD );// Horizontal versetzt einblenden ??
1602 }
1603 break;
1604 case PPT_TRANSITION_TYPE_COVER :
1605 {
1606 if ( nDirection == 0 )
1607 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_MOVE_FROM_RIGHT ); // Von rechts ueberdecken
1608 else if ( nDirection == 1 )
1609 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_MOVE_FROM_BOTTOM ); // Von unten ueberdecken
1610 else if ( nDirection == 2 )
1611 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_MOVE_FROM_LEFT ); // Von links ueberdecken
1612 else if ( nDirection == 3 )
1613 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_MOVE_FROM_TOP ); // Von oben ueberdecken
1614 else if ( nDirection == 4 )
1615 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_MOVE_FROM_LOWERRIGHT );// Von rechts unten ueberdecken ??
1616 else if ( nDirection == 5 )
1617 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_MOVE_FROM_LOWERLEFT ); // Von links unten ueberdecken ??
1618 else if ( nDirection == 6 )
1619 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_MOVE_FROM_UPPERRIGHT );// Von rechts oben ueberdecken
1620 else if ( nDirection == 7 )
1621 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_MOVE_FROM_UPPERLEFT ); // Von links oben ueberdecken ??
1622 }
1623 break;
1624 case PPT_TRANSITION_TYPE_NONE :
1625 {
1626 if ( nBuildFlags )
1627 {
1628 if ( nDirection == 0 )
1629 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_NONE ); // Direkt
1630 else if ( nDirection == 1 )
1631 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_NONE ); // Direkt ueber Schwarz
1632 }
1633 else
1634 pPage->setTransitionType( 0 );
1635 }
1636 break;
1637 case PPT_TRANSITION_TYPE_DISSOLVE :
1638 pPage->SetFadeEffect(::com::sun::star::presentation::FadeEffect_DISSOLVE); // Aufloesen
1639 break;
1640 case PPT_TRANSITION_TYPE_RANDOM_BARS :
1641 {
1642 if ( nDirection == 0 )
1643 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_HORIZONTAL_LINES ); // Horizontale Linien
1644 else if ( nDirection == 1 )
1645 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_VERTICAL_LINES ); // Vertikale Linien
1646 }
1647 break;
1648 case PPT_TRANSITION_TYPE_SPLIT :
1649 {
1650 if ( nDirection == 0 )
1651 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_OPEN_VERTICAL ); // Horizontal oeffnen
1652 else if ( nDirection == 1 )
1653 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_CLOSE_VERTICAL ); // Horizontal schliessen
1654 else if ( nDirection == 2 )
1655 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_OPEN_HORIZONTAL ); // Vertikal oeffnen
1656 else if ( nDirection == 3 )
1657 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_CLOSE_HORIZONTAL );// Vertikal schliessen
1658 }
1659 break;
1660 case PPT_TRANSITION_TYPE_STRIPS :
1661 {
1662 if ( nDirection == 4 )
1663 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_FADE_FROM_LOWERRIGHT );// Diagonal nach links oben
1664 else if ( nDirection == 5 )
1665 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_FADE_FROM_LOWERLEFT ); // Diagonal nach rechts oben
1666 else if ( nDirection == 6 )
1667 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_FADE_FROM_UPPERRIGHT );// Diagonal nach links unten
1668 else if ( nDirection == 7 )
1669 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_FADE_FROM_UPPERLEFT ); // Diagonal nach rechts unten
1670 }
1671 break;
1672 case PPT_TRANSITION_TYPE_PULL :
1673 {
1674 if ( nDirection == 0 )
1675 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_LEFT ); // Nach links aufdecken
1676 else if ( nDirection == 1 )
1677 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_TOP ); // Nach oben aufdecken
1678 else if ( nDirection == 2 )
1679 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_RIGHT ); // Nach rechts aufdecken
1680 else if ( nDirection == 3 )
1681 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_BOTTOM ); // Nach unten aufdecken
1682 else if ( nDirection == 4 )
1683 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_UPPERLEFT );// Nach links oben aufdecken
1684 else if ( nDirection == 5 )
1685 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_UPPERRIGHT );// Nach rechts oben aufdecken
1686 else if ( nDirection == 6 )
1687 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_LOWERLEFT );// Nach links unten aufdecken
1688 else if ( nDirection == 7 )
1689 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_UNCOVER_TO_LOWERRIGHT );// Nach rechts unten aufdecken
1690 }
1691 break;
1692 case PPT_TRANSITION_TYPE_WIPE :
1693 {
1694 if ( nDirection == 0 )
1695 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_FADE_FROM_RIGHT ); // Von rechts rollen
1696 else if ( nDirection == 1 )
1697 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_FADE_FROM_BOTTOM );// Von unten rollen
1698 else if ( nDirection == 2 )
1699 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_FADE_FROM_LEFT ); // Von links rollen
1700 else if ( nDirection == 3 )
1701 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_FADE_FROM_TOP ); // Von oben rollen
1702 }
1703 break;
1704 case PPT_TRANSITION_TYPE_RANDOM :
1705 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_RANDOM ); // Automatisch
1706 break;
1707 case PPT_TRANSITION_TYPE_FADE :
1708 {
1709 pPage->setTransitionType( animations::TransitionType::FADE );
1710 pPage->setTransitionSubtype( animations::TransitionSubType::FADEOVERCOLOR );
1711 pPage->setTransitionFadeColor( 0 );
1712 }
1713 break;
1714 case PPT_TRANSITION_TYPE_ZOOM :
1715 {
1716 if ( nDirection == 0 )
1717 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_FADE_FROM_CENTER );// Von innen einblenden
1718 else if ( nDirection == 1 )
1719 pPage->SetFadeEffect( ::com::sun::star::presentation::FadeEffect_FADE_TO_CENTER ); // Von aussen einblenden
1720 }
1721 break;
1722 case PPT_TRANSITION_TYPE_DIAMOND :
1723 {
1724 pPage->setTransitionType( animations::TransitionType::IRISWIPE );
1725 pPage->setTransitionSubtype( animations::TransitionSubType::DIAMOND );
1726 }
1727 break;
1728 case PPT_TRANSITION_TYPE_PLUS :
1729 {
1730 pPage->setTransitionType( animations::TransitionType::FOURBOXWIPE );
1731 pPage->setTransitionSubtype( animations::TransitionSubType::CORNERSOUT );
1732 }
1733 break;
1734 case PPT_TRANSITION_TYPE_CIRCLE :
1735 {
1736 pPage->setTransitionType( animations::TransitionType::ELLIPSEWIPE );
1737 pPage->setTransitionSubtype( animations::TransitionSubType::CIRCLE );
1738 }
1739 break;
1740 case PPT_TRANSITION_TYPE_WEDGE :
1741 {
1742 pPage->setTransitionType( animations::TransitionType::FANWIPE );
1743 pPage->setTransitionSubtype( animations::TransitionSubType::CENTERTOP );
1744 }
1745 break;
1746 case PPT_TRANSITION_TYPE_WHEEL :
1747 {
1748 pPage->setTransitionType( animations::TransitionType::PINWHEELWIPE );
1749 sal_Int16 nSubType;
1750 switch( nDirection )
1751 {
1752 default:
1753 case 1 : nSubType = animations::TransitionSubType::ONEBLADE; break;
1754 case 2 : nSubType = animations::TransitionSubType::TWOBLADEVERTICAL; break;
1755 case 3 : nSubType = animations::TransitionSubType::THREEBLADE; break;
1756 case 4 : nSubType = animations::TransitionSubType::FOURBLADE; break;
1757 case 8 : nSubType = animations::TransitionSubType::EIGHTBLADE; break;
1758 }
1759 pPage->setTransitionSubtype( nSubType );
1760 }
1761 break;
1762 case PPT_TRANSITION_TYPE_PUSH :
1763 {
1764 pPage->setTransitionType( animations::TransitionType::PUSHWIPE );
1765 sal_Int16 nSubType;
1766 switch( nDirection )
1767 {
1768 default:
1769 case 0 : nSubType = animations::TransitionSubType::FROMRIGHT; break;
1770 case 1 : nSubType = animations::TransitionSubType::FROMBOTTOM; break;
1771 case 2 : nSubType = animations::TransitionSubType::FROMLEFT; break;
1772 case 3 : nSubType = animations::TransitionSubType::FROMTOP; break;
1773 }
1774 pPage->setTransitionSubtype( nSubType );
1775 }
1776 break;
1777 case PPT_TRANSITION_TYPE_COMB :
1778 {
1779 pPage->setTransitionType( animations::TransitionType::PUSHWIPE );
1780 pPage->setTransitionSubtype( nDirection ? animations::TransitionSubType::COMBVERTICAL : animations::TransitionSubType::COMBHORIZONTAL );
1781 }
1782 break;
1783 case PPT_TRANSITION_TYPE_NEWSFLASH :
1784 {
1785 pPage->setTransitionType( animations::TransitionType::FOURBOXWIPE );
1786 pPage->setTransitionSubtype( animations::TransitionSubType::CORNERSOUT );
1787 /*
1788 pPage->setTransitionType( animations::TransitionType::ZOOM );
1789 pPage->setTransitionSubtype( animations::TransitionSubType::ROTATEIN );
1790 */
1791 }
1792 break;
1793 case PPT_TRANSITION_TYPE_SMOOTHFADE :
1794 {
1795 pPage->setTransitionType( animations::TransitionType::FADE );
1796 pPage->setTransitionSubtype( animations::TransitionSubType::CROSSFADE );
1797 }
1798 break;
1799 }
1800
1801 if ( nSpeed == 0 )
1802 pPage->setTransitionDuration( 3.0 ); // langsam
1803 else if ( nSpeed == 1 )
1804 pPage->setTransitionDuration( 2.0 ); // mittel
1805 else if ( nSpeed == 2 )
1806 pPage->setTransitionDuration( 1.0 ); // schnell
1807
1808 if ( nBuildFlags & 0x400 ) // slidechange by time
1809 { // Standzeit (in Ticks)
1810 pPage->SetPresChange( PRESCHANGE_AUTO );
1811 pPage->SetTime( nSlideTime / 1000 );
1812 }
1813 else
1814 pPage->SetPresChange( mePresChange );
1815
1816 // if ( nBuildFlags & 1 ) // slidechange by mouseclick
1817 // pPage->SetPresChange( mePresChange );
1818
1819 if ( nBuildFlags & 4 )
1820 pPage->SetExcluded( sal_True ); // Dia nicht anzeigen
1821 if ( nBuildFlags & 16 )
1822 { // Dia mit Soundeffekt
1823 pPage->SetSound( sal_True );
1824 String aSoundFile( ReadSound( nSoundRef ) );
1825 pPage->SetSoundFile( aSoundFile );
1826 }
1827 if ( nBuildFlags & ( 1 << 6 ) ) // Loop until next sound
1828 pPage->SetLoopSound( sal_True );
1829 if ( nBuildFlags & ( 1 << 8 ) ) // Stop the previous sound
1830 pPage->SetStopSound( sal_True );
1831 break;
1832 }
1833 }
1834 }
1835 aHd.SeekToEndOfRecord( rStCtrl );
1836 }
1837 if ( bTryTwice && ( bSSSlideInfoAtom == sal_False ) )
1838 {
1839 bTryTwice = sal_False;
1840 if ( HasMasterPage( nAktPageNum, eAktPageKind ) )
1841 {
1842 sal_uInt16 nMasterNum = GetMasterPageIndex( nAktPageNum, eAktPageKind );
1843 PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE );
1844 if ( pPageList && ( nMasterNum < pPageList->Count() ) )
1845 {
1846 PptSlidePersistEntry* pE = (*pPageList)[ nMasterNum ];
1847 if ( pE )
1848 {
1849 sal_uInt32 nOfs = pE->aPersistAtom.nReserved;
1850 if ( nOfs )
1851 {
1852 rStCtrl.Seek( nOfs );
1853 nPageRecEnd = nOfs + 16;
1854 continue;
1855 }
1856 }
1857 }
1858
1859 }
1860 }
1861 break;
1862 }
1863 }
1864 }
1865
1866 if ( !bNewAnimationsUsed )
1867 {
1868 tAnimationVector aAnimationsOnThisPage;
1869
1870 // add effects from page in correct order
1871 SdrObjListIter aSdrIter( *pPage, IM_FLAT );
1872 while ( aSdrIter.IsMore() )
1873 {
1874 SdrObject* pObj = aSdrIter.Next();
1875 tAnimationMap::iterator aFound = maAnimations.find( pObj );
1876 if( aFound != maAnimations.end() )
1877 {
1878 std::pair< SdrObject*, Ppt97AnimationPtr > aPair( (*aFound).first, (*aFound).second );
1879 aAnimationsOnThisPage.push_back( aPair );
1880 }
1881 }
1882
1883 Ppt97AnimationStlSortHelper aSortHelper;
1884 std::sort( aAnimationsOnThisPage.begin(), aAnimationsOnThisPage.end(), aSortHelper );
1885
1886 tAnimationVector::iterator aIter( aAnimationsOnThisPage.begin() );
1887 const tAnimationVector::iterator aEnd( aAnimationsOnThisPage.end() );
1888
1889 for( ;aIter != aEnd; aIter++ )
1890 {
1891 Ppt97AnimationPtr pPpt97Animation = (*aIter).second;;
1892 if( pPpt97Animation.get() )
1893 pPpt97Animation->createAndSetCustomAnimationEffect( (*aIter).first );
1894 }
1895 }
1896 rStCtrl.Seek( nFilePosMerk );
1897 }
1898
1899 //////////////////////////////////////////////////////////////////////////
1900 //
1901 // Import von Sounds
1902 //
1903 // Die Sounds werden nicht nur als String importiert sondern auch
1904 // in die Gallery einefuegt, falls dort noch nicht vorhanden.
1905 //
1906 ///////////////////////////////////////////////////////////////////////////
1907
ReadSound(sal_uInt32 nSoundRef) const1908 String ImplSdPPTImport::ReadSound(sal_uInt32 nSoundRef) const
1909 {
1910 String aRetval;
1911 sal_uInt32 nPosMerk = rStCtrl.Tell();
1912 DffRecordHeader aDocHd;
1913 if ( SeekToDocument( &aDocHd ) )
1914 {
1915 sal_uInt32 nSoundLen = aDocHd.GetRecEndFilePos();
1916 DffRecordHeader aSoundBlockRecHd;
1917 if( SeekToRec( rStCtrl, PPT_PST_SoundCollection, nSoundLen, &aSoundBlockRecHd ) )
1918 {
1919 sal_uInt32 nDataLen = aSoundBlockRecHd.GetRecEndFilePos();
1920 DffRecordHeader aSoundRecHd;
1921 sal_Bool bRefStrValid = sal_False;
1922 sal_Bool bDone = sal_False;
1923
1924 while( !bDone && SeekToRec( rStCtrl, PPT_PST_Sound, nDataLen, &aSoundRecHd ) )
1925 {
1926 sal_uInt32 nStrLen = aSoundRecHd.GetRecEndFilePos();
1927 String aRefStr;
1928 sal_uInt32 nPosMerk2 = rStCtrl.Tell();
1929 if ( SeekToRec( rStCtrl, PPT_PST_CString, nStrLen, NULL, 2 ) )
1930 {
1931 if ( ReadString( aRefStr ) )
1932 bRefStrValid = sal_True;
1933 }
1934 if ( bRefStrValid )
1935 {
1936 if ( UniString::CreateFromInt32( nSoundRef ) == aRefStr )
1937 {
1938 rStCtrl.Seek( nPosMerk2 );
1939 if ( SeekToRec( rStCtrl, PPT_PST_CString, nStrLen, NULL, 0 ) )
1940 {
1941 ReadString( aRetval );
1942 bDone = sal_True;
1943 }
1944 }
1945 }
1946 if ( bDone )
1947 {
1948 // ueberpruefen, ob diese Sound-Datei schon
1949 // existiert. Wenn nicht, exportiere diese
1950 // in unser lokales Sound-Verzeichnis.
1951 sal_Bool bSoundExists = sal_False;
1952 List* pSoundList = new List();
1953
1954 GalleryExplorer::FillObjList( GALLERY_THEME_SOUNDS, *pSoundList );
1955 GalleryExplorer::FillObjList( GALLERY_THEME_USERSOUNDS, *pSoundList );
1956
1957 for( sal_uLong n = 0; ( n < pSoundList->Count() ) && !bSoundExists; n++ )
1958 {
1959 INetURLObject aURL( *(String*)pSoundList->GetObject( n ) );
1960 String aSoundName( aURL.GetName() );
1961
1962 if( aSoundName == aRetval )
1963 {
1964 aRetval = *(String*)pSoundList->GetObject( n );
1965 bSoundExists = sal_True;
1966 }
1967 }
1968
1969 for ( void* pPtr = pSoundList->First(); pPtr; pPtr = pSoundList->Next() )
1970 delete (String*)pPtr;
1971
1972 delete pSoundList;
1973
1974 if ( !bSoundExists )
1975 {
1976 rStCtrl.Seek( nPosMerk2 );
1977 DffRecordHeader aSoundDataRecHd;
1978 if ( SeekToRec( rStCtrl, PPT_PST_SoundData, nStrLen, &aSoundDataRecHd, 0 ) )
1979 {
1980 String aGalleryDir( SvtPathOptions().GetGalleryPath() );
1981 INetURLObject aGalleryUserSound( aGalleryDir.GetToken( aGalleryDir.GetTokenCount( ';' ) - 1 ) );
1982
1983 aGalleryUserSound.Append( aRetval );
1984 sal_uInt32 nSoundDataLen = aSoundDataRecHd.nRecLen;
1985 sal_uInt8* pBuf = new sal_uInt8[ nSoundDataLen ];
1986
1987 rStCtrl.Read( pBuf, nSoundDataLen );
1988 SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aGalleryUserSound.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
1989
1990 if( pOStm )
1991 {
1992 pOStm->Write( pBuf, nSoundDataLen );
1993
1994 if( pOStm->GetError() == ERRCODE_NONE )
1995 {
1996 GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aGalleryUserSound.GetMainURL( INetURLObject::NO_DECODE ) );
1997 aRetval = aGalleryUserSound.GetMainURL( INetURLObject::NO_DECODE );
1998 }
1999
2000 delete pOStm;
2001 }
2002
2003 delete[] pBuf;
2004 }
2005 }
2006 }
2007 if ( !bDone )
2008 aSoundRecHd.SeekToEndOfRecord( rStCtrl );
2009 }
2010 }
2011 }
2012 rStCtrl.Seek( nPosMerk );
2013 return aRetval;
2014 }
2015
2016 //////////////////////////////////////////////////////////////////////////
2017 //
2018 // media object import, the return value is the url to the media object
2019 //
2020 //////////////////////////////////////////////////////////////////////////
2021
ReadMedia(sal_uInt32 nMediaRef) const2022 String ImplSdPPTImport::ReadMedia( sal_uInt32 nMediaRef ) const
2023 {
2024 String aRetVal;
2025 DffRecordHeader* pHd( const_cast<ImplSdPPTImport*>(this)->aDocRecManager.GetRecordHeader( PPT_PST_ExObjList, SEEK_FROM_BEGINNING ) );
2026 if ( pHd )
2027 {
2028 pHd->SeekToContent( rStCtrl );
2029 while ( ( rStCtrl.Tell() < pHd->GetRecEndFilePos() ) && !aRetVal.Len() )
2030 {
2031 DffRecordHeader aHdMovie;
2032 rStCtrl >> aHdMovie;
2033 switch( aHdMovie.nRecType )
2034 {
2035 case PPT_PST_ExAviMovie :
2036 case PPT_PST_ExMCIMovie :
2037 {
2038 DffRecordHeader aExVideoHd;
2039 if ( SeekToRec( rStCtrl, PPT_PST_ExVideo, aHdMovie.GetRecEndFilePos(), &aExVideoHd ) )
2040 {
2041 DffRecordHeader aExMediaAtomHd;
2042 if ( SeekToRec( rStCtrl, PPT_PST_ExMediaAtom, aExVideoHd.GetRecEndFilePos(), &aExMediaAtomHd ) )
2043 {
2044 sal_uInt32 nRef;
2045 rStCtrl >> nRef;
2046 if ( nRef == nMediaRef )
2047 {
2048 aExVideoHd.SeekToContent( rStCtrl );
2049 while( rStCtrl.Tell() < aExVideoHd.GetRecEndFilePos() )
2050 {
2051 DffRecordHeader aHd;
2052 rStCtrl >> aHd;
2053 switch( aHd.nRecType )
2054 {
2055 case PPT_PST_CString :
2056 {
2057 aHd.SeekToBegOfRecord( rStCtrl );
2058 String aStr;
2059 if ( ReadString( aStr ) )
2060 {
2061 if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aStr, aRetVal ) )
2062 {
2063 aRetVal = INetURLObject( aRetVal ).GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
2064 }else{
2065 aRetVal = aStr;
2066 }
2067 }
2068 }
2069 break;
2070 }
2071 aHd.SeekToEndOfRecord( rStCtrl );
2072 }
2073 break;
2074 }
2075 }
2076 }
2077 }
2078 break;
2079 }
2080 aHdMovie.SeekToEndOfRecord( rStCtrl );
2081 }
2082 }
2083 return aRetVal;
2084 }
2085
2086 //////////////////////////////////////////////////////////////////////////
2087 //
2088 // Import von Objekten
2089 //
2090 //////////////////////////////////////////////////////////////////////////
2091
FillSdAnimationInfo(SdAnimationInfo * pInfo,PptInteractiveInfoAtom * pIAtom,String aMacroName)2092 void ImplSdPPTImport::FillSdAnimationInfo( SdAnimationInfo* pInfo, PptInteractiveInfoAtom* pIAtom, String aMacroName )
2093 {
2094 // Lokale Informationen in pInfo eintragen
2095 if( pIAtom->nSoundRef )
2096 {
2097 pInfo->SetBookmark( ReadSound( pIAtom->nSoundRef ) ); // Pfad zum Soundfile in MSDOS-Notation
2098 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_SOUND; // RunProgramAction
2099 }
2100 // if ( nFlags & 0x01 ) // koennen wir nicht ( beim Anklicken markieren )
2101 switch ( pIAtom->nAction )
2102 {
2103 // case 0x01 : // MacroAction
2104 // {
2105 // pInfo->meClickAction = ::com::sun::star::presentation::::com::sun::star::presentation::ClickAction_MACRO;
2106 // // aMacro liegt in folgender Form vor:
2107 // // "Macroname.Modulname.Libname.Dokumentname" oder
2108 // // "Macroname.Modulname.Libname.Applikationsname"
2109 // pInfo->maBookmark = aMacroName;
2110 // }
2111 // break;
2112 case 0x02 : // RunProgramAction
2113 {
2114 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_PROGRAM;
2115 pInfo->SetBookmark( aMacroName ); // Programmname in aBookmark
2116 }
2117 break;
2118 case 0x03 : // JumpAction
2119 {
2120 switch( pIAtom->nJump )
2121 {
2122 case 0x01 :
2123 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_NEXTPAGE; // Next slide
2124 break;
2125 case 0x02 :
2126 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_PREVPAGE; // Previous slide
2127 break;
2128 case 0x03 :
2129 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_FIRSTPAGE; // First slide
2130 break;
2131 case 0x04 :
2132 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_LASTPAGE; // last Slide
2133 break;
2134 case 0x05 :
2135 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_PREVPAGE; // Last slide viewed
2136 break;
2137 case 0x06 :
2138 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_STOPPRESENTATION; // End show
2139 break;
2140 default :
2141 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_NONE; // 0x00: no action, else unknown
2142 break;
2143 }
2144 }
2145 break;
2146 case 0x04 :
2147 {
2148 SdHyperlinkEntry* pPtr;
2149 for ( pPtr = (SdHyperlinkEntry*)aHyperList.First(); pPtr; pPtr = (SdHyperlinkEntry*)aHyperList.Next() )
2150 {
2151 if ( pPtr->nIndex == pIAtom->nExHyperlinkId )
2152 break;
2153 }
2154 if ( pPtr )
2155 {
2156 switch( pIAtom->nHyperlinkType )
2157 {
2158 case 9:
2159 case 8: // hyperlink : URL
2160 {
2161 if ( pPtr->aTarget.Len() )
2162 {
2163 ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
2164 if ( pDocShell )
2165 {
2166 String aBaseURL = pDocShell->GetMedium()->GetBaseURL();
2167 String aBookmarkURL( pInfo->GetBookmark() );
2168 INetURLObject aURL( pPtr->aTarget );
2169 if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
2170 utl::LocalFileHelper::ConvertSystemPathToURL( pPtr->aTarget, aBaseURL, aBookmarkURL );
2171 if( !aBookmarkURL.Len() )
2172 aBookmarkURL = URIHelper::SmartRel2Abs( INetURLObject(aBaseURL), pPtr->aTarget, URIHelper::GetMaybeFileHdl(), true );
2173 pInfo->SetBookmark( aBookmarkURL );
2174 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_PROGRAM;
2175 }
2176 }
2177 }
2178 break;
2179
2180 case 10:
2181 break;
2182
2183 case 7: // hyperlink auf eine Seite
2184 {
2185 if ( pPtr->aConvSubString.Len() )
2186 {
2187 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_BOOKMARK;
2188 pInfo->SetBookmark( pPtr->aConvSubString );
2189 }
2190 }
2191 break;
2192 }
2193 }
2194 }
2195 break;
2196 case 0x05 : // OLEAction ( OLEVerb to use, 0==first, 1==secnd, .. )
2197 case 0x06 : // MediaAction
2198 case 0x07 : // CustomShowAction
2199 default : // 0x00: no action, else unknown action
2200 break;
2201 }
2202 }
2203
ApplyTextObj(PPTTextObj * pTextObj,SdrTextObj * pObj,SdPage * pPage,SfxStyleSheet * pSheet,SfxStyleSheet ** ppStyleSheetAry) const2204 SdrObject* ImplSdPPTImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* pObj, SdPage* pPage,
2205 SfxStyleSheet* pSheet, SfxStyleSheet** ppStyleSheetAry ) const
2206 {
2207 SfxStyleSheet* pStyleSheetAry[ 9 ];
2208 SdrTextObj* pText = pObj;
2209 SdrObject* pRet = pText;
2210
2211 ppStyleSheetAry = NULL;
2212
2213 PresObjKind ePresKind = PRESOBJ_NONE;
2214 PptOEPlaceholderAtom* pPlaceHolder = pTextObj->GetOEPlaceHolderAtom();
2215 String aPresentationText;
2216 if ( pPlaceHolder )
2217 {
2218 switch( pPlaceHolder->nPlaceholderId )
2219 {
2220 case PPT_PLACEHOLDER_MASTERNOTESSLIDEIMAGE :
2221 case PPT_PLACEHOLDER_MASTERCENTEREDTITLE :
2222 case PPT_PLACEHOLDER_MASTERTITLE :
2223 {
2224 ePresKind = PRESOBJ_TITLE;
2225 aPresentationText = pPage->GetPresObjText( ePresKind );
2226 }
2227 break;
2228 case PPT_PLACEHOLDER_MASTERBODY :
2229 {
2230 ePresKind = PRESOBJ_OUTLINE;
2231 aPresentationText = pPage->GetPresObjText( ePresKind );
2232 }
2233 break;
2234 case PPT_PLACEHOLDER_MASTERSUBTITLE :
2235 {
2236 ePresKind = PRESOBJ_TEXT;
2237 aPresentationText = pPage->GetPresObjText( ePresKind );
2238 }
2239 break;
2240 case PPT_PLACEHOLDER_MASTERNOTESBODYIMAGE :
2241 {
2242 ePresKind = PRESOBJ_NOTES;
2243 aPresentationText = pPage->GetPresObjText( ePresKind );
2244 }
2245 break;
2246 case PPT_PLACEHOLDER_MASTERDATE : ePresKind = PRESOBJ_DATETIME; break;
2247 case PPT_PLACEHOLDER_MASTERSLIDENUMBER : ePresKind = PRESOBJ_SLIDENUMBER;break;
2248 case PPT_PLACEHOLDER_MASTERFOOTER : ePresKind = PRESOBJ_FOOTER; break;
2249 case PPT_PLACEHOLDER_MASTERHEADER : ePresKind = PRESOBJ_HEADER; break;
2250 }
2251 }
2252 switch ( pTextObj->GetDestinationInstance() )
2253 {
2254 case TSS_TYPE_PAGETITLE :
2255 case TSS_TYPE_TITLE :
2256 {
2257 pSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE );
2258 if ( pSheet )
2259 ((SdrAttrObj*)pText)->SdrAttrObj::NbcSetStyleSheet( pSheet, sal_True );
2260 DBG_ASSERT( pSheet, "ImplSdPPTImport::ApplyTextObj -> could not get stylesheet for titleobject (SJ)" );
2261 }
2262 break;
2263 case TSS_TYPE_SUBTITLE :
2264 {
2265 pSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TEXT );
2266 if ( pSheet )
2267 ((SdrAttrObj*)pText)->SdrAttrObj::NbcSetStyleSheet( pSheet, sal_True );
2268 DBG_ASSERT( pSheet, "ImplSdPPTImport::ApplyTextObj -> could not get stylesheet for subtitleobject (SJ)" );
2269 }
2270 break;
2271 case TSS_TYPE_BODY :
2272 case TSS_TYPE_HALFBODY :
2273 case TSS_TYPE_QUARTERBODY :
2274 {
2275 for ( sal_uInt16 nLevel = 9; nLevel; nLevel-- )
2276 {
2277 String aName( pPage->GetLayoutName() );
2278 aName.Append( (sal_Unicode)( ' ' ) );
2279 aName.Append( String::CreateFromInt32( nLevel ) );
2280 pSheet = (SfxStyleSheet*)mpDoc->GetStyleSheetPool()->Find( aName, SD_STYLE_FAMILY_MASTERPAGE );
2281 if ( pSheet )
2282 pText->StartListening( *pSheet );
2283 pStyleSheetAry[ nLevel - 1 ] = pSheet;
2284 }
2285 DBG_ASSERT( pSheet, "ImplSdPPTImport::ApplyTextObj -> could not get stylesheet for outlinerobject (SJ)" );
2286 if ( pSheet )
2287 ((SdrAttrObj*)pText)->SdrAttrObj::NbcSetStyleSheet( pSheet, sal_True );
2288 ppStyleSheetAry = &pStyleSheetAry[ 0 ];
2289 }
2290 break;
2291 case TSS_TYPE_NOTES :
2292 {
2293 if ( pPlaceHolder && ( ( pPlaceHolder->nPlaceholderId == PPT_PLACEHOLDER_NOTESSLIDEIMAGE )
2294 || ( pPlaceHolder->nPlaceholderId == PPT_PLACEHOLDER_MASTERNOTESSLIDEIMAGE ) ) )
2295 {
2296 pSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE );
2297 if ( pSheet )
2298 ((SdrAttrObj*)pText)->SdrAttrObj::NbcSetStyleSheet( pSheet, sal_True );
2299 DBG_ASSERT( pSheet, "ImplSdPPTImport::ApplyTextObj -> could not get stylesheet for titleobject (SJ)" );
2300 }
2301 else
2302 {
2303 pSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_NOTES );
2304 DBG_ASSERT( pSheet, "ImplSdPPTImport::ApplyTextObj -> could not get stylesheet for notesobj (SJ)" );
2305 if ( pSheet )
2306 ((SdrAttrObj*)pText)->SdrAttrObj::NbcSetStyleSheet( pSheet, sal_True );
2307 }
2308 }
2309 break;
2310 case TSS_TYPE_UNUSED :
2311 case TSS_TYPE_TEXT_IN_SHAPE :
2312 {
2313 switch( ePresKind )
2314 {
2315 case PRESOBJ_DATETIME :
2316 case PRESOBJ_SLIDENUMBER :
2317 case PRESOBJ_FOOTER :
2318 case PRESOBJ_HEADER :
2319 pSheet = (SfxStyleSheet*)mpDoc->GetStyleSheetPool()->Find( String(SdResId( STR_PSEUDOSHEET_BACKGROUNDOBJECTS )), SD_STYLE_FAMILY_PSEUDO );
2320 break;
2321 default :
2322 pSheet = (SfxStyleSheet*)mpDoc->GetStyleSheetPool()->Find( String(SdResId( STR_STANDARD_STYLESHEET_NAME )), SD_STYLE_FAMILY_GRAPHICS );
2323 }
2324 }
2325 break;
2326 }
2327 pText = (SdrTextObj*)SdrPowerPointImport::ApplyTextObj( pTextObj, pText, pPage, pSheet, ppStyleSheetAry );
2328 if ( pPlaceHolder && pPlaceHolder->nPlaceholderId )
2329 {
2330 if ( eAktPageKind == PPT_MASTERPAGE )
2331 {
2332 sal_Bool bCreatePlaceHolder = ( pTextObj->GetInstance() != TSS_TYPE_UNUSED );
2333 sal_Bool bIsHeaderFooter = ( ePresKind == PRESOBJ_HEADER) || (ePresKind == PRESOBJ_FOOTER)
2334 || (ePresKind == PRESOBJ_DATETIME) || (ePresKind == PRESOBJ_SLIDENUMBER);
2335 if ( bCreatePlaceHolder && ( pTextObj->GetInstance() == TSS_TYPE_TEXT_IN_SHAPE ) )
2336 bCreatePlaceHolder = bIsHeaderFooter;
2337 if ( bCreatePlaceHolder )
2338 {
2339 if ( !bIsHeaderFooter )
2340 {
2341 pText->SetNotVisibleAsMaster( sal_True );
2342 pText->SetEmptyPresObj( sal_True );
2343 }
2344 pText->SetUserCall( pPage );
2345 pPage->InsertPresObj( pText, ePresKind );
2346 SdrOutliner* pOutl = NULL;
2347 if ( pTextObj->GetInstance() == TSS_TYPE_NOTES )
2348 pOutl = GetDrawOutliner( pText );
2349 if ( aPresentationText.Len() )
2350 pPage->SetObjText( (SdrTextObj*)pText, pOutl, ePresKind, aPresentationText );
2351
2352 if ( pPage->GetPageKind() != PK_NOTES && pPage->GetPageKind() != PK_HANDOUT)
2353 {
2354 SfxStyleSheet* pSheet2( pPage->GetStyleSheetForPresObj( ePresKind ) );
2355 if ( pSheet2 )
2356 {
2357 SfxItemSet& rItemSet = pSheet2->GetItemSet();
2358 rItemSet.Put( (SdrTextLeftDistItem&)pText->GetMergedItem( SDRATTR_TEXT_LEFTDIST ) );
2359 rItemSet.Put( (SdrTextRightDistItem&)pText->GetMergedItem( SDRATTR_TEXT_RIGHTDIST ) );
2360 rItemSet.Put( (SdrTextUpperDistItem&)pText->GetMergedItem( SDRATTR_TEXT_UPPERDIST ) );
2361 rItemSet.Put( (SdrTextLowerDistItem&)pText->GetMergedItem( SDRATTR_TEXT_LOWERDIST ) );
2362 rItemSet.Put( (SdrTextVertAdjustItem&)pText->GetMergedItem( SDRATTR_TEXT_VERTADJUST ) );
2363 rItemSet.Put( (SdrTextHorzAdjustItem&)pText->GetMergedItem( SDRATTR_TEXT_HORZADJUST ) );
2364 if ( pTextObj->GetInstance() == TSS_TYPE_TITLE
2365 || pTextObj->GetInstance() == TSS_TYPE_SUBTITLE)
2366 {
2367 rItemSet.Put( pText->GetMergedItemSet() );
2368 }
2369 }
2370 pText->NbcSetStyleSheet( pSheet2, sal_False );
2371 }
2372
2373 SfxItemSet aTempAttr( mpDoc->GetPool() );
2374 SdrTextMinFrameHeightItem aMinHeight( pText->GetLogicRect().GetSize().Height() );
2375 aTempAttr.Put( aMinHeight );
2376 SdrTextAutoGrowHeightItem aAutoGrowHeight( sal_False );
2377 aTempAttr.Put( aAutoGrowHeight );
2378 pText->SetMergedItemSet(aTempAttr);
2379 }
2380 else
2381 {
2382 pRet = NULL;
2383 }
2384 }
2385 else
2386 {
2387 const PptSlideLayoutAtom* pSlideLayout = GetSlideLayoutAtom();
2388 if ( pSlideLayout || ( eAktPageKind == PPT_NOTEPAGE ) )
2389 {
2390 sal_Int16 nPlaceholderId = pPlaceHolder->nPlaceholderId;
2391 sal_uInt16 i = 0;
2392 if ( eAktPageKind == PPT_SLIDEPAGE )
2393 {
2394 for ( ; i < 8; i++ )
2395 {
2396 if ( pSlideLayout->aPlaceholderId[ i ] == nPlaceholderId )
2397 break;
2398 }
2399 }
2400 // [Bug 119962] Placeholder in ppt file created by MS 2007 is lost if load in Impress
2401 unsigned int nParaCount = pTextObj->Count();
2402 PPTParagraphObj *pFirstPara = nParaCount == 0 ? NULL : pTextObj->First();
2403 unsigned int nFirstParaTextcount = pFirstPara == NULL ? 0 : pFirstPara->GetTextSize();
2404 if ( i < 8 || ((nParaCount == 1 && nFirstParaTextcount == 0) || nParaCount == 0))
2405 {
2406 PresObjKind ePresObjKind = PRESOBJ_NONE;
2407 sal_Bool bEmptyPresObj = sal_True;
2408 sal_Bool bVertical = sal_False;
2409 if ( ( pTextObj->GetShapeType() == mso_sptRectangle ) || ( pTextObj->GetShapeType() == mso_sptTextBox ) )
2410 {
2411 //if a placeholder with some custom attribute,the pTextObj will keep those attr,whose text size is zero,
2412 //so sdPage should renew a PresObj to process placeholder.
2413 if ( pTextObj->Count() > 1 ||
2414 ( pTextObj->Count() == 1 &&(pTextObj->First()) && pTextObj->First()->GetTextSize()>0 ))
2415 bEmptyPresObj = sal_False;
2416 switch ( nPlaceholderId )
2417 {
2418 case PPT_PLACEHOLDER_NOTESBODY : ePresObjKind = PRESOBJ_NOTES; break;
2419 case PPT_PLACEHOLDER_VERTICALTEXTTITLE :
2420 bVertical = sal_True; // PASSTHROUGH !!!
2421 case PPT_PLACEHOLDER_TITLE : ePresObjKind = PRESOBJ_TITLE; break;
2422 case PPT_PLACEHOLDER_VERTICALTEXTBODY :
2423 bVertical = sal_True; // PASSTHROUGH !!!
2424 case PPT_PLACEHOLDER_BODY : ePresObjKind = PRESOBJ_OUTLINE; break;
2425 case PPT_PLACEHOLDER_CENTEREDTITLE : ePresObjKind = PRESOBJ_TITLE; break;
2426 case PPT_PLACEHOLDER_SUBTITLE : ePresObjKind = PRESOBJ_TEXT; break; // PRESOBJ_OUTLINE
2427
2428 default :
2429 {
2430 if ( !pTextObj->Count() )
2431 {
2432 switch ( nPlaceholderId )
2433 {
2434 case PPT_PLACEHOLDER_MEDIACLIP :
2435 case PPT_PLACEHOLDER_OBJECT : ePresObjKind = PRESOBJ_OBJECT; break;
2436 case PPT_PLACEHOLDER_GRAPH : ePresObjKind = PRESOBJ_CHART; break;
2437 case PPT_PLACEHOLDER_TABLE : ePresObjKind = PRESOBJ_TABLE; break;
2438 case PPT_PLACEHOLDER_CLIPART : ePresObjKind = PRESOBJ_GRAPHIC; break;
2439 case PPT_PLACEHOLDER_ORGANISZATIONCHART : ePresObjKind = PRESOBJ_ORGCHART; break;
2440 }
2441 }
2442 };
2443 }
2444 }
2445 else if ( pTextObj->GetShapeType() == mso_sptPictureFrame )
2446 {
2447 if ( !pTextObj->Count() && pObj->ISA( SdrGrafObj ) )
2448 {
2449 bEmptyPresObj = sal_False;
2450 switch ( nPlaceholderId )
2451 {
2452 case PPT_PLACEHOLDER_MEDIACLIP :
2453 case PPT_PLACEHOLDER_OBJECT : ePresObjKind = PRESOBJ_OBJECT; break;
2454 case PPT_PLACEHOLDER_GRAPH : ePresObjKind = PRESOBJ_CHART; break;
2455 case PPT_PLACEHOLDER_TABLE : ePresObjKind = PRESOBJ_CALC; break;
2456 case PPT_PLACEHOLDER_CLIPART : ePresObjKind = PRESOBJ_GRAPHIC; break;
2457 case PPT_PLACEHOLDER_ORGANISZATIONCHART : ePresObjKind = PRESOBJ_ORGCHART; break;
2458 }
2459 }
2460 }
2461 if ( ePresObjKind != PRESOBJ_NONE )
2462 {
2463 if ( !bEmptyPresObj )
2464 {
2465 pPage->InsertPresObj( pRet, ePresObjKind );
2466 }
2467 else
2468 {
2469 SdrObject* pPresObj = pPage->CreatePresObj( ePresObjKind, bVertical, pText->GetLogicRect(), sal_True );
2470 pPresObj->SetUserCall( pPage );
2471
2472 SfxItemSet aSet( pSdrModel->GetItemPool() );
2473 ApplyAttributes( rStCtrl, aSet );
2474 pPresObj->SetLogicRect(pText->GetLogicRect());
2475 ApplyTextAnchorAttributes( *pTextObj, aSet );
2476 //set custom font attribute of the placeholder
2477 if ( pTextObj->Count() == 1 )
2478 {
2479 PPTParagraphObj* pPara = pTextObj->First();
2480 PPTPortionObj* pPor = NULL;
2481 if ( pPara && pPara->GetTextSize() == 0 && (pPor = pPara->First()))
2482 {
2483 pPor->ApplyTo(aSet, (SdrPowerPointImport&)*this, pTextObj->GetDestinationInstance());
2484 }
2485 }
2486 pPresObj->SetMergedItemSet(aSet);
2487
2488 if ( ( eAktPageKind != PPT_NOTEPAGE ) && ( pSlideLayout->aPlacementId[ i ] != (sal_uLong)-1 ) )
2489 {
2490 SdrObject* pTitleObj;
2491 try {
2492 pTitleObj = ((SdPage&)pPage->TRG_GetMasterPage()).GetPresObj( PRESOBJ_TITLE );
2493 } catch (uno::Exception &) {
2494 pTitleObj = NULL;
2495 }
2496 SdrObject* pOutlineObj;
2497 try {
2498 pOutlineObj = ((SdPage&)pPage->TRG_GetMasterPage()).GetPresObj( PRESOBJ_OUTLINE );
2499 } catch (uno::Exception &) {
2500 pOutlineObj = NULL;
2501 }
2502 Rectangle aTitleRect;
2503 Rectangle aOutlineRect;
2504 Size aOutlineSize;
2505
2506 if ( pTitleObj )
2507 aTitleRect = pTitleObj->GetLogicRect();
2508 if ( pOutlineObj )
2509 {
2510 aOutlineRect = pOutlineObj->GetLogicRect();
2511 aOutlineSize = aOutlineRect.GetSize();
2512 }
2513 Rectangle aLogicRect( pPresObj->GetLogicRect() );
2514 Size aLogicSize( aLogicRect.GetSize() );
2515
2516 switch ( pSlideLayout->aPlacementId[ i ] )
2517 {
2518 case 0 : // Lage im Titelbereich
2519 {
2520 if ( aLogicRect != aTitleRect )
2521 pPresObj->SetUserCall( NULL );
2522 }
2523 break;
2524
2525 case 1:
2526 {
2527 if ( pSlideLayout->eLayout == PPT_LAYOUT_TITLEANDBODYSLIDE )
2528 { // Lage im Outlinebereich
2529 if ( aLogicRect != aOutlineRect )
2530 pPresObj->SetUserCall( NULL );
2531 }
2532 else if ( pSlideLayout->eLayout == PPT_LAYOUT_2COLUMNSANDTITLE )
2533 { // Lage im Outlinebereich links
2534 if (Abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
2535 Abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE ||
2536 Abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE ||
2537 aLogicSize.Width() / aOutlineSize.Width() < 0.48 ||
2538 aLogicSize.Width() / aOutlineSize.Width() > 0.5)
2539 {
2540 pPresObj->SetUserCall(NULL);
2541 }
2542 }
2543 else if ( pSlideLayout->eLayout == PPT_LAYOUT_2ROWSANDTITLE )
2544 { // Lage im Outlinebereich oben
2545 if (Abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
2546 Abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE ||
2547 Abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE)
2548 {
2549 pPresObj->SetUserCall( NULL );
2550 }
2551 }
2552 else if (Abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
2553 Abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE)
2554 { // Lage im Outlinebereich links oben
2555 pPresObj->SetUserCall( NULL );
2556 }
2557 }
2558 break;
2559
2560 case 2:
2561 {
2562 if ( pSlideLayout->eLayout == PPT_LAYOUT_2COLUMNSANDTITLE )
2563 { // Lage im Outlinebereich rechts
2564 if (Abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE ||
2565 Abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE ||
2566 Abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE ||
2567 aLogicSize.Width() / aOutlineSize.Width() < 0.48 ||
2568 aLogicSize.Width() / aOutlineSize.Width() > 0.5)
2569 {
2570 pPresObj->SetUserCall( NULL );
2571 }
2572 }
2573 else if ( pSlideLayout->eLayout == PPT_LAYOUT_2ROWSANDTITLE )
2574 { // Lage im Outlinebereich unten
2575 if (Abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
2576 Abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE ||
2577 Abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE)
2578 {
2579 pPresObj->SetUserCall( NULL );
2580 }
2581 }
2582 else if (Abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE ||
2583 Abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE)
2584 { // Lage im Outlinebereich rechts oben
2585 pPresObj->SetUserCall(NULL);
2586 }
2587 }
2588 break;
2589
2590 case 3:
2591 { // Lage im Outlinebereich links unten
2592 if (Abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
2593 Abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE)
2594 {
2595 pPresObj->SetUserCall( NULL );
2596 }
2597 }
2598 break;
2599
2600 case 4:
2601 { // Lage im Outlinebereich rechts unten
2602 if (Abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE ||
2603 Abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE)
2604 {
2605 pObj->SetUserCall( NULL );
2606 }
2607 }
2608 break;
2609 }
2610 }
2611 pRet = NULL; // return zero cause this obj was already inserted by CreatePresObj
2612 }
2613 }
2614 else if ( !pTextObj->Count() )
2615 pRet = NULL;
2616 }
2617 }
2618 }
2619 }
2620 if ( pRet != pText )
2621 {
2622 SdrObject* pFree( pText );
2623 SdrObject::Free( pFree );
2624 }
2625 return pRet;
2626 }
2627
ProcessObj(SvStream & rSt,DffObjData & rObjData,void * pData,Rectangle & rTextRect,SdrObject * pRet)2628 SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, void* pData, Rectangle& rTextRect, SdrObject* pRet )
2629 {
2630 SdrObject* pObj = SdrPowerPointImport::ProcessObj( rSt, rObjData, pData, rTextRect, pRet );
2631
2632 // Animationseffekte des Objektes lesen
2633 if ( pObj )
2634 {
2635 // further setup placeholder objects
2636 if( pObj->ISA(SdrPageObj) && pData )
2637 {
2638 const ProcessData* pProcessData=(const ProcessData*)pData;
2639 if( pProcessData->pPage )
2640 pProcessData->pPage->InsertPresObj( pObj, PRESOBJ_PAGE );
2641 }
2642
2643 sal_Bool bInhabitanceChecked = sal_False;
2644 sal_Bool bAnimationInfoFound = sal_False;
2645 DffRecordHeader aMasterShapeHd;
2646
2647 if ( maShapeRecords.SeekToContent( rSt, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) )
2648 {
2649 DffRecordHeader& rHdClientData = *maShapeRecords.Current();
2650 while( sal_True )
2651 {
2652 sal_uInt32 nClientDataLen = rHdClientData.GetRecEndFilePos();
2653 DffRecordHeader aHd;
2654 do
2655 {
2656 rSt >> aHd;
2657 sal_uInt32 nHdRecEnd = aHd.GetRecEndFilePos();
2658 switch ( aHd.nRecType )
2659 {
2660 case PPT_PST_AnimationInfo :
2661 {
2662 DffRecordHeader aHdAnimInfoAtom;
2663 if ( SeekToRec( rSt, PPT_PST_AnimationInfoAtom, nHdRecEnd, &aHdAnimInfoAtom ) )
2664 {
2665 // read data from stream
2666 Ppt97AnimationPtr pAnimation( new Ppt97Animation( rSt ) );
2667 // store animation informations
2668 if( pAnimation->HasEffect() )
2669 {
2670 // translate color to RGB
2671 pAnimation->SetDimColor( MSO_CLR_ToColor(pAnimation->GetDimColor()).GetColor() );
2672 // translate sound bits to file url
2673 if( pAnimation->HasSoundEffect() )
2674 pAnimation->SetSoundFileUrl( ReadSound( pAnimation->GetSoundRef() ) );
2675
2676 bool bDontAnimateInvisibleShape = false;
2677 {
2678 SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj);
2679
2680 if( pTextObj && pTextObj->HasText() &&
2681 !pObj->ISA( SdrObjGroup ) &&
2682 pAnimation->HasAnimateAssociatedShape() )
2683 {
2684 const SfxItemSet& rObjItemSet = pObj->GetMergedItemSet();
2685
2686 XFillStyle eFillStyle = ((XFillStyleItem&)(rObjItemSet.Get(XATTR_FILLSTYLE))).GetValue();
2687 XLineStyle eLineStyle = ((XLineStyleItem&)(rObjItemSet.Get(XATTR_LINESTYLE))).GetValue();
2688
2689 if ( ( eFillStyle == XFILL_NONE ) && ( eLineStyle == XLINE_NONE ) )
2690 bDontAnimateInvisibleShape = true;
2691 }
2692 }
2693 if( bDontAnimateInvisibleShape )
2694 pAnimation->SetAnimateAssociatedShape(false);
2695
2696 //maybe some actions necessary to ensure that animations on master pages are played before animations on normal pages
2697 ///mabe todo in future: bool bIsEffectOnMasterPage = !bInhabitanceChecked;?
2698
2699 maAnimations[pObj] = pAnimation;
2700
2701 bAnimationInfoFound = sal_True;
2702 }
2703 }
2704 }
2705 break;
2706 case PPT_PST_InteractiveInfo:
2707 {
2708 sal_uInt32 nFilePosMerk2 = rSt.Tell();
2709 String aMacroName;
2710
2711 if(SeekToRec( rSt, PPT_PST_CString, nHdRecEnd, NULL, 0 ) )
2712 ReadString(aMacroName);
2713
2714 rSt.Seek( nFilePosMerk2 );
2715 DffRecordHeader aHdInteractiveInfoAtom;
2716 if ( SeekToRec( rSt, PPT_PST_InteractiveInfoAtom, nHdRecEnd, &aHdInteractiveInfoAtom ) )
2717 {
2718 PptInteractiveInfoAtom aInteractiveInfoAtom;
2719 rSt >> aInteractiveInfoAtom;
2720
2721 // interactive object
2722 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj, true);
2723
2724 ( (ImplSdPPTImport*) this )->FillSdAnimationInfo( pInfo, &aInteractiveInfoAtom, aMacroName );
2725 if ( aInteractiveInfoAtom.nAction == 6 ) // Sj -> media action
2726 {
2727 rHdClientData.SeekToContent( rStCtrl );
2728 DffRecordHeader aObjRefAtomHd;
2729 if ( SeekToRec( rSt, PPT_PST_ExObjRefAtom, nHdRecEnd, &aObjRefAtomHd ) )
2730 {
2731 sal_uInt32 nRef;
2732 rSt >> nRef;
2733 String aMediaURL( ReadMedia( nRef ) );
2734 if ( !aMediaURL.Len() )
2735 aMediaURL = ReadSound( nRef );
2736 if ( aMediaURL.Len() )
2737 {
2738 SdrMediaObj* pMediaObj = new SdrMediaObj( pObj->GetSnapRect() );
2739 pMediaObj->SetModel( pObj->GetModel() );
2740 pMediaObj->SetMergedItemSet( pObj->GetMergedItemSet() );
2741
2742 //--remove object from maAnimations list and add the new object instead
2743 Ppt97AnimationPtr pAnimation;
2744 {
2745 tAnimationMap::iterator aFound = maAnimations.find( pObj );
2746 if( aFound != maAnimations.end() )
2747 {
2748 pAnimation = (*aFound).second;
2749 maAnimations.erase(aFound);
2750 }
2751 maAnimations[pMediaObj] = pAnimation;
2752 }
2753 //--
2754
2755 SdrObject::Free( pObj ), pObj = pMediaObj; // SJ: hoping that pObj is not inserted in any list
2756 pMediaObj->setURL( aMediaURL );
2757 }
2758 }
2759 }
2760 }
2761 }
2762 break;
2763 }
2764 aHd.SeekToEndOfRecord( rSt );
2765 }
2766 while( ( rSt.GetError() == 0 ) && ( rSt.Tell() < nClientDataLen ) );
2767
2768 if ( bInhabitanceChecked || bAnimationInfoFound )
2769 break;
2770 bInhabitanceChecked = sal_True;
2771 if ( ! ( IsProperty( DFF_Prop_hspMaster ) && SeekToShape( rSt, pData, GetPropertyValue( DFF_Prop_hspMaster ) ) ) )
2772 break;
2773 rSt >> aMasterShapeHd;
2774 if ( !SeekToRec( rSt, DFF_msofbtClientData, aMasterShapeHd.GetRecEndFilePos(), &aMasterShapeHd ) )
2775 break;
2776 aMasterShapeHd.SeekToContent( rSt );
2777 rHdClientData = aMasterShapeHd;
2778 }
2779 }
2780 }
2781 return pObj;
2782 }
2783
2784 // ---------------------
2785 // - exported function -
2786 // ---------------------
2787
ImportPPT(const::rtl::OUString & rConfigPath,uno::Sequence<beans::PropertyValue> * pConfigData,SdDrawDocument * pDocument,SvStream & rDocStream,SvStorage & rStorage,SfxMedium & rMedium)2788 extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL ImportPPT( const ::rtl::OUString& rConfigPath,
2789 uno::Sequence< beans::PropertyValue >* pConfigData,
2790 SdDrawDocument* pDocument, SvStream& rDocStream, SvStorage& rStorage, SfxMedium& rMedium )
2791 {
2792 sal_Bool bRet = sal_False;
2793
2794 MSFilterTracer aTracer( rConfigPath, pConfigData );
2795 aTracer.StartTracing();
2796
2797 SdPPTImport* pImport = new SdPPTImport( pDocument, rDocStream, rStorage, rMedium, &aTracer );
2798 bRet = pImport->Import();
2799
2800 aTracer.EndTracing();
2801 delete pImport;
2802
2803 return bRet;
2804 }
2805