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