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