Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <osl/endian.h>
21 : #include <vcl/svapp.hxx>
22 : #include <unotools/tempfile.hxx>
23 : #include <math.h>
24 : #include <editeng/eeitem.hxx>
25 : #include <sot/storage.hxx>
26 : #include <sot/storinfo.hxx>
27 : #include <sot/stg.hxx>
28 : #include <com/sun/star/embed/Aspects.hpp>
29 : #include <com/sun/star/office/XAnnotation.hpp>
30 : #include <com/sun/star/office/XAnnotationAccess.hpp>
31 : #include <com/sun/star/text/XText.hpp>
32 : #include <com/sun/star/geometry/RealPoint2D.hpp>
33 : #include <com/sun/star/util/DateTime.hpp>
34 : #include <unotools/streamwrap.hxx>
35 : #include <filter/msfilter/svdfppt.hxx>
36 : #include <svx/xpoly.hxx>
37 : #include <svx/svdtrans.hxx>
38 : #include <svx/svdmodel.hxx>
39 : #include <svx/svdpage.hxx>
40 : #include <svx/svdobj.hxx>
41 : #include <svx/svdogrp.hxx>
42 : #include <svx/svdorect.hxx>
43 : #include <svx/svdopage.hxx>
44 : #include <svx/svdograf.hxx>
45 : #include <svx/svdopath.hxx>
46 : #include <svx/svdocirc.hxx>
47 : #include <svx/svdocapt.hxx>
48 : #include <svx/svdotable.hxx>
49 : #include <editeng/outlobj.hxx>
50 : #include <svx/svdattr.hxx>
51 : #include "svx/xattr.hxx"
52 : #include "svx/svditext.hxx"
53 : #include <svx/svdetc.hxx>
54 : #include <editeng/bulitem.hxx>
55 : #include <svx/polysc3d.hxx>
56 : #include <svx/extrud3d.hxx>
57 : #include <svx/svdoashp.hxx>
58 : #include <editeng/tstpitem.hxx>
59 : #include <editeng/unoprnms.hxx>
60 : #include <editeng/editids.hrc>
61 :
62 : #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
63 : #include <editeng/adjitem.hxx>
64 : #include <editeng/escpitem.hxx>
65 : #include <editeng/colritem.hxx>
66 : #include <editeng/fhgtitem.hxx>
67 : #include <editeng/wghtitem.hxx>
68 : #include <editeng/postitem.hxx>
69 : #include <editeng/udlnitem.hxx>
70 : #include <editeng/crsditem.hxx>
71 : #include <editeng/shdditem.hxx>
72 : #include <editeng/charreliefitem.hxx>
73 : #include <editeng/fontitem.hxx>
74 : #include <svx/svdoutl.hxx>
75 : #include <editeng/editeng.hxx>
76 : #include <editeng/lspcitem.hxx>
77 : #include <editeng/ulspitem.hxx>
78 : #include <editeng/lrspitem.hxx>
79 : #include <vcl/metric.hxx>
80 : #include <vcl/bmpacc.hxx>
81 : #include <svx/svditer.hxx>
82 : #include <svx/svdoedge.hxx>
83 : #include <svx/sxekitm.hxx>
84 : #include <editeng/flditem.hxx>
85 : #include <tools/zcodec.hxx>
86 : #include <filter/msfilter/svxmsbas.hxx>
87 : #include <sfx2/objsh.hxx>
88 : #include <editeng/brshitem.hxx>
89 : #include <editeng/langitem.hxx>
90 : #include <svx/svdoole2.hxx>
91 : #include <svx/unoapi.hxx>
92 : #include <toolkit/unohlp.hxx>
93 : #include <com/sun/star/container/XIndexContainer.hpp>
94 : #include <com/sun/star/drawing/XShapes.hpp>
95 : #include <com/sun/star/drawing/XControlShape.hpp>
96 : #include <com/sun/star/form/XFormComponent.hpp>
97 : #include <com/sun/star/beans/XPropertySet.hpp>
98 : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
99 : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
100 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
101 : #include <com/sun/star/awt/Size.hpp>
102 : #include <com/sun/star/awt/Point.hpp>
103 : #include <com/sun/star/drawing/FillStyle.hpp>
104 : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
105 : #include <editeng/writingmodeitem.hxx>
106 : #include <vcl/print.hxx>
107 : #include <editeng/svxfont.hxx>
108 : #include <editeng/frmdiritem.hxx>
109 : #include <svx/sdtfchim.hxx>
110 : #include <unotools/ucbstreamhelper.hxx>
111 : #include <editeng/scripttypeitem.hxx>
112 : #include "com/sun/star/awt/Gradient.hpp"
113 : #include <com/sun/star/table/XMergeableCellRange.hpp>
114 : #include <com/sun/star/table/BorderLine2.hpp>
115 : #include <com/sun/star/table/BorderLineStyle.hpp>
116 : #include <vcl/virdev.hxx>
117 : #include <algorithm>
118 : #include <set>
119 : #include <rtl/strbuf.hxx>
120 :
121 : // PPT ColorScheme Slots
122 : #define PPT_COLSCHEME (0x08000000)
123 : #define PPT_COLSCHEME_HINTERGRUND (0x08000000)
124 : #define PPT_COLSCHEME_TEXT_UND_ZEILEN (0x08000001)
125 : #define PPT_COLSCHEME_SCHATTEN (0x08000002)
126 : #define PPT_COLSCHEME_TITELTEXT (0x08000003)
127 : #define PPT_COLSCHEME_FUELLBEREICHE (0x08000004)
128 : #define PPT_COLSCHEME_AKZENT (0x08000005)
129 : #define PPT_COLSCHEME_A_UND_HYPERLINK (0x08000006)
130 : #define PPT_COLSCHEME_A_H_GESICHERT (0x08000007)
131 :
132 : #define ANSI_CHARSET 0
133 : #define SYMBOL_CHARSET 2
134 :
135 : /* Font Families */
136 : #define FF_ROMAN 0x10
137 : #define FF_SWISS 0x20
138 : #define FF_MODERN 0x30
139 : #define FF_SCRIPT 0x40
140 : #define FF_DECORATIVE 0x50
141 :
142 : #define DEFAULT_PITCH 0x00
143 : #define FIXED_PITCH 0x01
144 : #define VARIABLE_PITCH 0x02
145 :
146 : using namespace ::com::sun::star ;
147 : using namespace uno ;
148 : using namespace beans ;
149 : using namespace drawing ;
150 : using namespace container ;
151 : using namespace table ;
152 :
153 6 : PowerPointImportParam::PowerPointImportParam( SvStream& rDocStrm, sal_uInt32 nFlags ) :
154 : rDocStream ( rDocStrm ),
155 6 : nImportFlags ( nFlags )
156 : {
157 6 : }
158 :
159 6 : SvStream& operator>>( SvStream& rIn, PptCurrentUserAtom& rAtom )
160 : {
161 6 : DffRecordHeader aHd;
162 6 : rIn >> aHd;
163 6 : if ( aHd.nRecType == PPT_PST_CurrentUserAtom )
164 : {
165 : sal_uInt32 nLen;
166 : sal_uInt16 nUserNameLen, nPad;
167 6 : rIn >> nLen
168 12 : >> rAtom.nMagic
169 12 : >> rAtom.nCurrentUserEdit
170 6 : >> nUserNameLen
171 12 : >> rAtom.nDocFileVersion
172 12 : >> rAtom.nMajorVersion
173 12 : >> rAtom.nMinorVersion
174 6 : >> nPad;
175 6 : rAtom.aCurrentUser = SvxMSDffManager::MSDFFReadZString( rIn, nUserNameLen, sal_True );
176 : }
177 6 : aHd.SeekToEndOfRecord( rIn );
178 6 : return rIn;
179 : }
180 :
181 67 : void PptSlidePersistAtom::Clear()
182 : {
183 67 : nReserved = nPsrReference = nFlags = nNumberTexts = nSlideId = 0;
184 67 : }
185 :
186 57 : SvStream& operator>>( SvStream& rIn, PptSlidePersistAtom& rAtom )
187 : {
188 57 : DffRecordHeader aHd;
189 57 : rIn >> aHd
190 114 : >> rAtom.nPsrReference
191 114 : >> rAtom.nFlags
192 114 : >> rAtom.nNumberTexts
193 114 : >> rAtom.nSlideId;
194 57 : aHd.SeekToEndOfRecord( rIn );
195 57 : return rIn;
196 : }
197 :
198 239 : sal_uInt16 PptSlidePersistList::FindPage(sal_uInt32 nId) const
199 : {
200 594 : for ( sal_uInt16 i=0; i < size(); i++ )
201 : {
202 594 : if (operator[](i)->GetSlideId()==nId) return i;
203 : }
204 0 : return PPTSLIDEPERSIST_ENTRY_NOTFOUND;
205 : }
206 :
207 4 : SvStream& operator>>( SvStream& rIn, PptInteractiveInfoAtom& rAtom )
208 : {
209 4 : rIn >> rAtom.nSoundRef
210 8 : >> rAtom.nExHyperlinkId
211 8 : >> rAtom.nAction
212 8 : >> rAtom.nOleVerb
213 8 : >> rAtom.nJump
214 8 : >> rAtom.nFlags
215 8 : >> rAtom.nHyperlinkType
216 8 : >> rAtom.nUnknown1
217 8 : >> rAtom.nUnknown2
218 8 : >> rAtom.nUnknown3;
219 4 : return rIn;
220 : }
221 :
222 3 : SvStream& operator>>( SvStream& rIn, PptExOleObjAtom& rAtom )
223 : {
224 : sal_uInt32 nDummy1;
225 : sal_uInt32 nDummy2;
226 : sal_uInt32 nDummy4;
227 :
228 3 : rIn >> rAtom.nAspect
229 3 : >> nDummy1
230 6 : >> rAtom.nId
231 3 : >> nDummy2
232 6 : >> rAtom.nPersistPtr
233 3 : >> nDummy4;
234 3 : return rIn;
235 : }
236 :
237 89 : Size PptDocumentAtom::GetPageSize(const Size& rSiz) const
238 : {
239 89 : return rSiz;
240 : }
241 :
242 5 : SvStream& operator>>(SvStream& rIn, PptDocumentAtom& rAtom)
243 : {
244 : // Actual format:
245 : // 00 aSlidePageSizeXY 8
246 : // 08 aNotesPageSizeXY 8
247 : // 16 aZoomRatio (OLE) 8
248 : // 24 nNotesMasterPersist 4
249 : // 28 nHandoutMasterPersist 4
250 : // 32 n1stPageNumber 2
251 : // 34 ePageFormat 2
252 : // 36 bEmbeddedTrueType 1
253 : // 37 bOmitTitlePlace 1
254 : // 38 bRightToLeft 1
255 : // 39 bShowComments 1
256 :
257 5 : DffRecordHeader aHd;
258 : sal_Int32 nSlideX,nSlideY, nNoticeX, nNoticeY, nDummy;
259 : sal_uInt16 nSlidePageFormat;
260 : sal_Int8 nEmbeddedTrueType, nTitlePlaceHoldersOmitted, nRightToLeft, nShowComments;
261 :
262 5 : rIn >> aHd
263 5 : >> nSlideX >> nSlideY
264 5 : >> nNoticeX >> nNoticeY
265 5 : >> nDummy >> nDummy // skip ZoomRation
266 10 : >> rAtom.nNotesMasterPersist
267 10 : >> rAtom.nHandoutMasterPersist
268 10 : >> rAtom.n1stPageNumber
269 5 : >> nSlidePageFormat
270 5 : >> nEmbeddedTrueType
271 5 : >> nTitlePlaceHoldersOmitted
272 5 : >> nRightToLeft
273 5 : >> nShowComments;
274 5 : rAtom.aSlidesPageSize.Width() = nSlideX;
275 5 : rAtom.aSlidesPageSize.Height() = nSlideY;
276 5 : rAtom.aNotesPageSize.Width() = nNoticeX;
277 5 : rAtom.aNotesPageSize.Height() = nNoticeY;
278 5 : rAtom.eSlidesPageFormat = (PptPageFormat)nSlidePageFormat;
279 5 : rAtom.bEmbeddedTrueType = nEmbeddedTrueType;
280 5 : rAtom.bTitlePlaceholdersOmitted = nTitlePlaceHoldersOmitted;
281 5 : rAtom.bRightToLeft = nRightToLeft;
282 5 : rAtom.bShowComments = nShowComments;
283 5 : aHd.SeekToEndOfRecord( rIn );
284 5 : return rIn;
285 : }
286 :
287 67 : void PptSlideLayoutAtom::Clear()
288 : {
289 67 : eLayout = 0;
290 603 : for ( sal_uInt16 i = 0; i < 8; i++ )
291 : {
292 536 : aPlaceholderId[ i ] = 0;
293 536 : aPlacementId[ i ] = 0;
294 : }
295 67 : }
296 :
297 37 : SvStream& operator>>( SvStream& rIn, PptSlideLayoutAtom& rAtom )
298 : {
299 37 : rIn >> rAtom.eLayout;
300 37 : rIn.Read( rAtom.aPlaceholderId, 8 );
301 37 : return rIn;
302 : }
303 :
304 37 : SvStream& operator>>( SvStream& rIn, PptSlideAtom& rAtom )
305 : {
306 37 : DffRecordHeader aHd;
307 37 : rIn >> aHd
308 74 : >> rAtom.aLayout
309 74 : >> rAtom.nMasterId
310 74 : >> rAtom.nNotesId
311 74 : >> rAtom.nFlags;
312 37 : aHd.SeekToEndOfRecord( rIn );
313 37 : return rIn;
314 : }
315 :
316 67 : void PptSlideAtom::Clear()
317 : {
318 67 : nMasterId = nNotesId = 0;
319 67 : nFlags = 0;
320 67 : }
321 :
322 23 : SvStream& operator>>( SvStream& rIn, PptNotesAtom& rAtom )
323 : {
324 23 : DffRecordHeader aHd;
325 23 : rIn >> aHd
326 46 : >> rAtom.nSlideId
327 46 : >> rAtom.nFlags;
328 23 : aHd.SeekToEndOfRecord( rIn );
329 23 : return rIn;
330 : }
331 :
332 67 : void PptNotesAtom::Clear()
333 : {
334 67 : nSlideId = 0;
335 67 : nFlags = 0;
336 67 : }
337 :
338 73 : void PptColorSchemeAtom::Clear()
339 : {
340 73 : memset(&aData[0], 0, 32);
341 73 : }
342 :
343 9470 : Color PptColorSchemeAtom::GetColor( sal_uInt16 nNum ) const
344 : {
345 9470 : Color aRetval;
346 9470 : if ( nNum < 8 )
347 : {
348 9470 : nNum <<= 2;
349 9470 : aRetval.SetRed( aData[ nNum++ ] );
350 9470 : aRetval.SetGreen( aData[ nNum++ ] );
351 9470 : aRetval.SetBlue( aData[ nNum++ ] );
352 : }
353 9470 : return aRetval;
354 : }
355 :
356 61 : SvStream& operator>>( SvStream& rIn, PptColorSchemeAtom& rAtom )
357 : {
358 61 : DffRecordHeader aHd;
359 61 : rIn >> aHd;
360 61 : rIn.Read( rAtom.aData, 32 );
361 61 : aHd.SeekToEndOfRecord( rIn );
362 61 : return rIn;
363 : }
364 :
365 21 : SvStream& operator>>( SvStream& rIn, PptFontEntityAtom& rAtom )
366 : {
367 21 : DffRecordHeader aHd;
368 21 : rIn >> aHd;
369 : sal_Unicode nTemp, cData[ 32 ];
370 21 : rIn.Read( cData, 64 );
371 :
372 : sal_uInt8 lfCharset, lfPitchAndFamily;
373 :
374 21 : rIn >> lfCharset
375 42 : >> rAtom.lfClipPrecision
376 42 : >> rAtom.lfQuality
377 21 : >> lfPitchAndFamily;
378 :
379 21 : switch( lfCharset )
380 : {
381 : case SYMBOL_CHARSET :
382 2 : rAtom.eCharSet = RTL_TEXTENCODING_SYMBOL;
383 2 : break;
384 : case ANSI_CHARSET :
385 17 : rAtom.eCharSet = RTL_TEXTENCODING_MS_1252;
386 17 : break;
387 :
388 : default :
389 2 : rAtom.eCharSet = osl_getThreadTextEncoding();
390 : }
391 21 : switch ( lfPitchAndFamily & 0xf0 )
392 : {
393 : case FF_ROMAN:
394 9 : rAtom.eFamily = FAMILY_ROMAN;
395 9 : break;
396 :
397 : case FF_SWISS:
398 0 : rAtom.eFamily = FAMILY_SWISS;
399 0 : break;
400 :
401 : case FF_MODERN:
402 0 : rAtom.eFamily = FAMILY_MODERN;
403 0 : break;
404 :
405 : case FF_SCRIPT:
406 1 : rAtom.eFamily = FAMILY_SCRIPT;
407 1 : break;
408 :
409 : case FF_DECORATIVE:
410 0 : rAtom.eFamily = FAMILY_DECORATIVE;
411 0 : break;
412 :
413 : default:
414 11 : rAtom.eFamily = FAMILY_DONTKNOW;
415 11 : break;
416 : }
417 :
418 21 : switch ( lfPitchAndFamily & 0x0f )
419 : {
420 : case FIXED_PITCH:
421 0 : rAtom.ePitch = PITCH_FIXED;
422 0 : break;
423 :
424 : case DEFAULT_PITCH:
425 : case VARIABLE_PITCH:
426 : default:
427 21 : rAtom.ePitch = PITCH_VARIABLE;
428 21 : break;
429 : }
430 : sal_uInt16 i;
431 235 : for ( i = 0; i < 32; i++ )
432 : {
433 235 : nTemp = cData[ i ];
434 235 : if ( !nTemp )
435 21 : break;
436 : #ifdef OSL_BIGENDIAN
437 : cData[ i ] = ( nTemp >> 8 ) | ( nTemp << 8 );
438 : #endif
439 : }
440 21 : rAtom.aName = rtl::OUString(cData, i);
441 21 : OutputDevice* pDev = (OutputDevice*)Application::GetDefaultDevice();
442 21 : rAtom.bAvailable = pDev->IsFontAvailable( rAtom.aName );
443 21 : aHd.SeekToEndOfRecord( rIn );
444 21 : return rIn;
445 : }
446 :
447 10 : class PptFontCollection: public boost::ptr_vector<PptFontEntityAtom> {
448 : };
449 :
450 6 : SvStream& operator>>( SvStream& rIn, PptUserEditAtom& rAtom )
451 : {
452 6 : rIn >> rAtom.aHd
453 12 : >> rAtom.nLastSlideID
454 12 : >> rAtom.nVersion
455 12 : >> rAtom.nOffsetLastEdit
456 12 : >> rAtom.nOffsetPersistDirectory
457 12 : >> rAtom.nDocumentRef
458 12 : >> rAtom.nMaxPersistWritten
459 12 : >> rAtom.eLastViewType;
460 6 : rAtom.aHd.SeekToEndOfRecord(rIn);
461 6 : return rIn;
462 : }
463 :
464 1334 : void PptOEPlaceholderAtom::Clear()
465 : {
466 1334 : nPlacementId = 0;
467 1334 : nPlaceholderSize = nPlaceholderId = 0;
468 1334 : }
469 :
470 278 : SvStream& operator>>( SvStream& rIn, PptOEPlaceholderAtom& rAtom )
471 : {
472 278 : rIn >> rAtom.nPlacementId
473 556 : >> rAtom.nPlaceholderId
474 556 : >> rAtom.nPlaceholderSize;
475 278 : return rIn;
476 : }
477 :
478 67 : PptSlidePersistEntry::PptSlidePersistEntry() :
479 : pStyleSheet ( NULL ),
480 : pHeaderFooterEntry ( NULL ),
481 : pSolverContainer ( NULL ),
482 : nSlidePersistStartOffset( 0 ),
483 : nSlidePersistEndOffset ( 0 ),
484 : nBackgroundOffset ( 0 ),
485 : nDrawingDgId ( 0xffffffff ),
486 : pPresentationObjects ( NULL ),
487 : pBObj ( NULL ),
488 : bBObjIsTemporary ( sal_True ),
489 : ePageKind ( PPT_MASTERPAGE ),
490 : bNotesMaster ( sal_False ),
491 : bHandoutMaster ( sal_False ),
492 67 : bStarDrawFiller ( sal_False )
493 : {
494 67 : HeaderFooterOfs[ 0 ] = HeaderFooterOfs[ 1 ] = HeaderFooterOfs[ 2 ] = HeaderFooterOfs[ 3 ] = 0;
495 67 : }
496 :
497 :
498 67 : PptSlidePersistEntry::~PptSlidePersistEntry()
499 : {
500 67 : delete pStyleSheet;
501 67 : delete pSolverContainer;
502 67 : delete[] pPresentationObjects;
503 67 : };
504 :
505 6 : SdrEscherImport::SdrEscherImport( PowerPointImportParam& rParam, const String& rBaseURL ) :
506 : SvxMSDffManager ( rParam.rDocStream, rBaseURL ),
507 : pFonts ( NULL ),
508 : nStreamLen ( 0 ),
509 : nTextStylesIndex ( 0xffff ),
510 6 : eCharSetSystem ( osl_getThreadTextEncoding() ),
511 : bWingdingsChecked ( sal_False ),
512 : bWingdingsAvailable ( sal_False ),
513 : bMonotypeSortsChecked ( sal_False ),
514 : bMonotypeSortsAvailable ( sal_False ),
515 : bTimesNewRomanChecked ( sal_False ),
516 : bTimesNewRomanAvailable ( sal_False ),
517 12 : rImportParam ( rParam )
518 : {
519 6 : }
520 :
521 12 : SdrEscherImport::~SdrEscherImport()
522 : {
523 9 : for ( size_t i = 0, n = aOleObjectList.size(); i < n; ++i )
524 3 : delete aOleObjectList[ i ];
525 6 : aOleObjectList.clear();
526 6 : delete pFonts;
527 6 : }
528 :
529 0 : const PptSlideLayoutAtom* SdrEscherImport::GetSlideLayoutAtom() const
530 : {
531 0 : return NULL;
532 : }
533 :
534 0 : sal_Bool SdrEscherImport::ReadString( rtl::OUString& rStr ) const
535 : {
536 0 : sal_Bool bRet = sal_False;
537 0 : DffRecordHeader aStrHd;
538 0 : rStCtrl >> aStrHd;
539 0 : if (aStrHd.nRecType == PPT_PST_TextBytesAtom
540 : || aStrHd.nRecType == PPT_PST_TextCharsAtom
541 : || aStrHd.nRecType == PPT_PST_CString)
542 : {
543 : sal_Bool bUniCode =
544 : (aStrHd.nRecType == PPT_PST_TextCharsAtom
545 0 : || aStrHd.nRecType == PPT_PST_CString);
546 0 : bRet=sal_True;
547 0 : sal_uLong nBytes = aStrHd.nRecLen;
548 0 : rStr = MSDFFReadZString( rStCtrl, nBytes, bUniCode );
549 0 : aStrHd.SeekToEndOfRecord( rStCtrl );
550 : }
551 : else
552 0 : aStrHd.SeekToBegOfRecord( rStCtrl );
553 0 : return bRet;
554 : }
555 :
556 0 : bool SdrEscherImport::GetColorFromPalette(sal_uInt16 /*nNum*/, Color& /*rColor*/) const
557 : {
558 0 : return sal_False;
559 : }
560 :
561 0 : sal_Bool SdrEscherImport::SeekToShape( SvStream& /*rSt*/, void* /*pClientData*/, sal_uInt32 /*nId*/) const
562 : {
563 0 : return sal_False;
564 : }
565 :
566 3908 : PptFontEntityAtom* SdrEscherImport::GetFontEnityAtom( sal_uInt32 nNum ) const
567 : {
568 3908 : PptFontEntityAtom* pRetValue = NULL;
569 3908 : if ( pFonts && ( nNum < pFonts->size() ) )
570 3908 : pRetValue = &(*pFonts)[ (sal_uInt16)nNum ];
571 3908 : return pRetValue;
572 : }
573 :
574 0 : SdrObject* SdrEscherImport::ReadObjText( PPTTextObj* /*pTextObj*/, SdrObject* pObj, SdPage* /*pPage*/) const
575 : {
576 0 : return pObj;
577 : }
578 :
579 290 : void SdrEscherImport::ProcessClientAnchor2( SvStream& rSt, DffRecordHeader& rHd, void* /*pData*/, DffObjData& rObj )
580 : {
581 : sal_Int32 l, t, r, b;
582 290 : if ( rHd.nRecLen == 16 )
583 : {
584 0 : rSt >> l >> t >> r >> b;
585 : }
586 : else
587 : {
588 : sal_Int16 ls, ts, rs, bs;
589 290 : rSt >> ts >> ls >> rs >> bs; // the order of coordinates is a bit strange...
590 290 : l = ls, t = ts, r = rs, b = bs;
591 : }
592 290 : Scale( l );
593 290 : Scale( t );
594 290 : Scale( r );
595 290 : Scale( b );
596 290 : rObj.aChildAnchor = Rectangle( l, t, r, b );
597 290 : rObj.bChildAnchor = sal_True;
598 290 : return;
599 : };
600 :
601 0 : void SdrEscherImport::RecolorGraphic( SvStream& rSt, sal_uInt32 nRecLen, Graphic& rGraphic )
602 : {
603 0 : if ( rGraphic.GetType() == GRAPHIC_GDIMETAFILE )
604 : {
605 : sal_uInt16 nX, nGlobalColorsCount, nFillColorsCount;
606 :
607 0 : rSt >> nX
608 0 : >> nGlobalColorsCount
609 0 : >> nFillColorsCount
610 0 : >> nX
611 0 : >> nX
612 0 : >> nX;
613 :
614 0 : if ( ( nGlobalColorsCount <= 64 ) && ( nFillColorsCount <= 64 ) )
615 : {
616 0 : if ( (sal_uInt32)( ( nGlobalColorsCount + nFillColorsCount ) * 44 + 12 ) == nRecLen )
617 : {
618 : sal_uInt32 OriginalGlobalColors[ 64 ];
619 : sal_uInt32 NewGlobalColors[ 64 ];
620 : sal_uInt32 OriginalFillColors[ 64 ];
621 : sal_uInt32 NewFillColors[ 64 ];
622 :
623 : sal_uInt32 i, j, nGlobalColorsChanged, nFillColorsChanged;
624 0 : nGlobalColorsChanged = nFillColorsChanged = 0;
625 :
626 0 : sal_uInt32* pCurrentOriginal = OriginalGlobalColors;
627 0 : sal_uInt32* pCurrentNew = NewGlobalColors;
628 0 : sal_uInt32* pCount = &nGlobalColorsChanged;
629 0 : i = nGlobalColorsCount;
630 :
631 0 : for ( j = 0; j < 2; j++ )
632 : {
633 0 : for ( ; i > 0; i-- )
634 : {
635 0 : sal_uInt32 nIndex, nPos = rSt.Tell();
636 : sal_uInt8 nDummy, nRed, nGreen, nBlue;
637 : sal_uInt16 nChanged;
638 0 : rSt >> nChanged;
639 0 : if ( nChanged & 1 )
640 : {
641 0 : sal_uInt32 nColor = 0;
642 0 : rSt >> nDummy
643 0 : >> nRed
644 0 : >> nDummy
645 0 : >> nGreen
646 0 : >> nDummy
647 0 : >> nBlue
648 0 : >> nIndex;
649 :
650 0 : if ( nIndex < 8 )
651 : {
652 0 : Color aColor = MSO_CLR_ToColor( nIndex << 24 );
653 0 : nRed = aColor.GetRed();
654 0 : nGreen = aColor.GetGreen();
655 0 : nBlue = aColor.GetBlue();
656 : }
657 0 : nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 );
658 0 : *pCurrentNew++ = nColor;
659 0 : rSt >> nDummy
660 0 : >> nRed
661 0 : >> nDummy
662 0 : >> nGreen
663 0 : >> nDummy
664 0 : >> nBlue;
665 0 : nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 );
666 0 : *pCurrentOriginal++ = nColor;
667 0 : (*pCount)++;
668 : }
669 0 : rSt.Seek( nPos + 44 );
670 : }
671 0 : pCurrentOriginal = OriginalFillColors;
672 0 : pCurrentNew = NewFillColors;
673 0 : pCount = &nFillColorsChanged;
674 0 : i = nFillColorsCount;
675 : }
676 0 : if ( nGlobalColorsChanged || nFillColorsChanged )
677 : {
678 0 : Color* pSearchColors = new Color[ nGlobalColorsChanged ];
679 0 : Color* pReplaceColors = new Color[ nGlobalColorsChanged ];
680 :
681 0 : for ( j = 0; j < nGlobalColorsChanged; j++ )
682 : {
683 0 : sal_uInt32 nSearch = OriginalGlobalColors[ j ];
684 0 : sal_uInt32 nReplace = NewGlobalColors[ j ];
685 :
686 0 : pSearchColors[ j ].SetRed( (sal_uInt8)nSearch );
687 0 : pSearchColors[ j ].SetGreen( (sal_uInt8)( nSearch >> 8 ) );
688 0 : pSearchColors[ j ].SetBlue( (sal_uInt8)( nSearch >> 16 ) );
689 :
690 0 : pReplaceColors[ j ].SetRed( (sal_uInt8)nReplace );
691 0 : pReplaceColors[ j ].SetGreen( (sal_uInt8)( nReplace >> 8 ) );
692 0 : pReplaceColors[ j ].SetBlue( (sal_uInt8)( nReplace >> 16 ) );
693 : }
694 0 : GDIMetaFile aGdiMetaFile( rGraphic.GetGDIMetaFile() );
695 : aGdiMetaFile.ReplaceColors( pSearchColors, pReplaceColors,
696 0 : nGlobalColorsChanged, NULL );
697 0 : rGraphic = aGdiMetaFile;
698 :
699 0 : delete[] pSearchColors;
700 0 : delete[] pReplaceColors;
701 : }
702 : }
703 : }
704 : }
705 0 : }
706 :
707 : /* ProcessObject is called from ImplSdPPTImport::ProcessObj to hanlde all application specific things,
708 : such as the import of text, animation effects, header footer and placeholder.
709 :
710 : The parameter pOriginalObj is the object as it was imported by our general escher import, it must either
711 : be deleted or it can be returned to be inserted into the sdr page.
712 : */
713 1240 : SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, void* pData, Rectangle& rTextRect, SdrObject* pOriginalObj )
714 : {
715 1240 : if ( pOriginalObj && pOriginalObj->ISA( SdrObjCustomShape ) )
716 687 : pOriginalObj->SetMergedItem( SdrTextFixedCellHeightItem( sal_True ) );
717 :
718 : // we are initializing our return value with the object that was imported by our escher import
719 1240 : SdrObject* pRet = pOriginalObj;
720 :
721 1240 : ProcessData& rData = *((ProcessData*)pData);
722 1240 : PptSlidePersistEntry& rPersistEntry = rData.rPersistEntry;
723 :
724 1240 : if ( ! ( rObjData.nSpFlags & SP_FGROUP ) ) // sj: #114758# ...
725 : {
726 1204 : PptOEPlaceholderAtom aPlaceholderAtom;
727 :
728 1204 : if ( maShapeRecords.SeekToContent( rSt, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) )
729 : {
730 179 : sal_Int16 nHeaderFooterInstance = -1;
731 179 : DffRecordHeader aClientDataHd;
732 542 : while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < maShapeRecords.Current()->GetRecEndFilePos() ) )
733 : {
734 184 : rSt >> aClientDataHd;
735 184 : switch ( aClientDataHd.nRecType )
736 : {
737 : // importing header/footer object from master page
738 : case PPT_PST_OEPlaceholderAtom :
739 : {
740 148 : rSt >> aPlaceholderAtom;
741 148 : if ( nHeaderFooterInstance == -1 )
742 : {
743 148 : switch ( aPlaceholderAtom.nPlaceholderId )
744 : {
745 9 : case PPT_PLACEHOLDER_MASTERSLIDENUMBER : nHeaderFooterInstance++;
746 19 : case PPT_PLACEHOLDER_MASTERFOOTER : nHeaderFooterInstance++;
747 24 : case PPT_PLACEHOLDER_MASTERHEADER : nHeaderFooterInstance++;
748 34 : case PPT_PLACEHOLDER_MASTERDATE : nHeaderFooterInstance++; break;
749 : }
750 148 : if ( ! ( nHeaderFooterInstance & 0xfffc ) ) // is this a valid instance ( 0->3 )
751 34 : rPersistEntry.HeaderFooterOfs[ nHeaderFooterInstance ] = rObjData.rSpHd.GetRecBegFilePos();
752 : }
753 : }
754 148 : break;
755 :
756 : case PPT_PST_RecolorInfoAtom :
757 : {
758 0 : if ( pRet && ( pRet->ISA( SdrGrafObj ) && ((SdrGrafObj*)pRet)->HasGDIMetaFile() ) )
759 : {
760 0 : Graphic aGraphic( ((SdrGrafObj*)pRet)->GetGraphic() );
761 0 : RecolorGraphic( rSt, aClientDataHd.nRecLen, aGraphic );
762 0 : ((SdrGrafObj*)pRet)->SetGraphic( aGraphic );
763 : }
764 : }
765 0 : break;
766 : }
767 184 : aClientDataHd.SeekToEndOfRecord( rSt );
768 : }
769 : }
770 1204 : if ( ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_NOTESSLIDEIMAGE ) && ( rPersistEntry.bNotesMaster == sal_False ) )
771 : {
772 18 : sal_uInt16 nPageNum = pSdrModel->GetPageCount();
773 18 : if ( nPageNum > 0 )
774 18 : nPageNum--;
775 :
776 : // replacing the object which we will return with a SdrPageObj
777 18 : SdrObject::Free( pRet );
778 18 : pRet = new SdrPageObj( rObjData.aBoundRect, pSdrModel->GetPage( nPageNum - 1 ) );
779 : }
780 : else
781 : {
782 : // try to load some ppt text
783 1186 : PPTTextObj aTextObj( rSt, (SdrPowerPointImport&)*this, rPersistEntry, &rObjData );
784 1186 : if ( ( aTextObj.Count() || aTextObj.GetOEPlaceHolderAtom() ) )
785 : {
786 604 : sal_Bool bVerticalText = sal_False;
787 : // and if the text object is not empty, it must be applied to pRet, the object we
788 : // initially got from our escher import
789 604 : sal_Int32 nTextRotationAngle = 0;
790 604 : if ( IsProperty( DFF_Prop_txflTextFlow ) )
791 : {
792 3 : MSO_TextFlow eTextFlow = (MSO_TextFlow)( GetPropertyValue( DFF_Prop_txflTextFlow ) & 0xFFFF );
793 3 : switch( eTextFlow )
794 : {
795 : case mso_txflBtoT : // Bottom to Top non-@, unten -> oben
796 0 : nTextRotationAngle += 9000;
797 0 : break;
798 : case mso_txflTtoBA : /* #68110# */ // Top to Bottom @-font, oben -> unten
799 : case mso_txflTtoBN : // Top to Bottom non-@, oben -> unten
800 : case mso_txflVertN : // Vertical, non-@, oben -> unten
801 0 : bVerticalText = !bVerticalText; // nTextRotationAngle += 27000;
802 0 : break;
803 : // case mso_txflHorzN : // Horizontal non-@, normal
804 : // case mso_txflHorzA : // Horizontal @-font, normal
805 3 : default: break;
806 : }
807 : }
808 604 : sal_Int32 nFontDirection = GetPropertyValue( DFF_Prop_cdirFont, mso_cdir0 );
809 604 : nTextRotationAngle -= nFontDirection * 9000;
810 604 : if ( ( nFontDirection == 1 ) || ( nFontDirection == 3 ) ) // #104546#
811 : {
812 0 : bVerticalText = !bVerticalText;
813 : }
814 604 : aTextObj.SetVertical( bVerticalText );
815 604 : if ( pRet )
816 : {
817 604 : sal_Bool bDeleteSource = aTextObj.GetOEPlaceHolderAtom() != 0;
818 858 : if ( bDeleteSource && ( pRet->ISA( SdrGrafObj ) == sal_False ) // we are not allowed to get
819 127 : && ( pRet->ISA( SdrObjGroup ) == sal_False ) // grouped placeholder objects
820 127 : && ( pRet->ISA( SdrOle2Obj ) == sal_False ) )
821 127 : SdrObject::Free( pRet );
822 : }
823 604 : sal_uInt32 nTextFlags = aTextObj.GetTextFlags();
824 604 : sal_Int32 nTextLeft = GetPropertyValue( DFF_Prop_dxTextLeft, 25 * 3600 ); // 0.25 cm (emu)
825 604 : sal_Int32 nTextRight = GetPropertyValue( DFF_Prop_dxTextRight, 25 * 3600 ); // 0.25 cm (emu)
826 604 : sal_Int32 nTextTop = GetPropertyValue( DFF_Prop_dyTextTop, 13 * 3600 ); // 0.13 cm (emu)
827 604 : sal_Int32 nTextBottom = GetPropertyValue( DFF_Prop_dyTextBottom, 13 * 3600 );
828 604 : ScaleEmu( nTextLeft );
829 604 : ScaleEmu( nTextRight );
830 604 : ScaleEmu( nTextTop );
831 604 : ScaleEmu( nTextBottom );
832 :
833 604 : sal_Int32 nMinFrameWidth = 0;
834 604 : sal_Int32 nMinFrameHeight = 0;
835 : sal_Bool bAutoGrowWidth, bAutoGrowHeight;
836 :
837 : SdrTextVertAdjust eTVA;
838 : SdrTextHorzAdjust eTHA;
839 :
840 : nTextFlags &= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT
841 604 : | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK;
842 :
843 604 : if ( bVerticalText )
844 : {
845 0 : eTVA = SDRTEXTVERTADJUST_BLOCK;
846 0 : eTHA = SDRTEXTHORZADJUST_CENTER;
847 :
848 : // read text anchor
849 0 : MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
850 :
851 0 : switch( eTextAnchor )
852 : {
853 : case mso_anchorTop:
854 : case mso_anchorTopCentered:
855 : case mso_anchorTopBaseline:
856 : case mso_anchorTopCenteredBaseline:
857 0 : eTHA = SDRTEXTHORZADJUST_RIGHT;
858 0 : break;
859 :
860 : case mso_anchorMiddle :
861 : case mso_anchorMiddleCentered:
862 0 : eTHA = SDRTEXTHORZADJUST_CENTER;
863 0 : break;
864 :
865 : case mso_anchorBottom:
866 : case mso_anchorBottomCentered:
867 : case mso_anchorBottomBaseline:
868 : case mso_anchorBottomCenteredBaseline:
869 0 : eTHA = SDRTEXTHORZADJUST_LEFT;
870 0 : break;
871 : }
872 : // if there is a 100% use of following attributes, the textbox can been aligned also in vertical direction
873 0 : switch ( eTextAnchor )
874 : {
875 : case mso_anchorTopCentered :
876 : case mso_anchorMiddleCentered :
877 : case mso_anchorBottomCentered :
878 : case mso_anchorTopCenteredBaseline:
879 : case mso_anchorBottomCenteredBaseline:
880 : {
881 : // check if it is sensible to use the centered alignment
882 0 : sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT;
883 0 : if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs
884 0 : eTVA = SDRTEXTVERTADJUST_CENTER; // the text has to be displayed using the full width;
885 : }
886 0 : break;
887 :
888 : default :
889 : {
890 0 : if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT )
891 0 : eTVA = SDRTEXTVERTADJUST_TOP;
892 0 : else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT )
893 0 : eTVA = SDRTEXTVERTADJUST_BOTTOM;
894 : }
895 0 : break;
896 : }
897 0 : nMinFrameWidth = rTextRect.GetWidth() - ( nTextLeft + nTextRight );
898 : }
899 : else
900 : {
901 604 : eTVA = SDRTEXTVERTADJUST_CENTER;
902 604 : eTHA = SDRTEXTHORZADJUST_BLOCK;
903 :
904 : // read text anchor
905 604 : MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
906 :
907 604 : switch( eTextAnchor )
908 : {
909 : case mso_anchorTop:
910 : case mso_anchorTopCentered:
911 : case mso_anchorTopBaseline:
912 : case mso_anchorTopCenteredBaseline:
913 538 : eTVA = SDRTEXTVERTADJUST_TOP;
914 538 : break;
915 :
916 : case mso_anchorMiddle :
917 : case mso_anchorMiddleCentered:
918 57 : eTVA = SDRTEXTVERTADJUST_CENTER;
919 57 : break;
920 :
921 : case mso_anchorBottom:
922 : case mso_anchorBottomCentered:
923 : case mso_anchorBottomBaseline:
924 : case mso_anchorBottomCenteredBaseline:
925 9 : eTVA = SDRTEXTVERTADJUST_BOTTOM;
926 9 : break;
927 : }
928 : // if there is a 100% usage of following attributes, the textbox can be aligned also in horizontal direction
929 604 : switch ( eTextAnchor )
930 : {
931 : case mso_anchorTopCentered :
932 : case mso_anchorMiddleCentered :
933 : case mso_anchorBottomCentered :
934 : case mso_anchorTopCenteredBaseline:
935 : case mso_anchorBottomCenteredBaseline:
936 : {
937 : // check if it is sensible to use the centered alignment
938 0 : sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT;
939 0 : if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs
940 0 : eTHA = SDRTEXTHORZADJUST_CENTER; // the text has to be displayed using the full width;
941 : }
942 0 : break;
943 :
944 : default :
945 604 : break;
946 : }
947 604 : nMinFrameHeight = rTextRect.GetHeight() - ( nTextTop + nTextBottom );
948 : }
949 :
950 604 : SdrObjKind eTextKind = OBJ_RECT;
951 604 : if ( ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_NOTESSLIDEIMAGE )
952 : || ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_MASTERNOTESSLIDEIMAGE ) )
953 : {
954 4 : aTextObj.SetInstance( 2 );
955 4 : eTextKind = OBJ_TITLETEXT;
956 : }
957 600 : else if ( ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_MASTERNOTESBODYIMAGE )
958 : || ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_NOTESBODY ) )
959 : {
960 23 : aTextObj.SetInstance( 2 );
961 23 : eTextKind = OBJ_TEXT;
962 : }
963 :
964 604 : sal_uInt32 nDestinationInstance = aTextObj.GetInstance();
965 604 : if ( rPersistEntry.ePageKind == PPT_MASTERPAGE )
966 : {
967 48 : if ( !rPersistEntry.pPresentationObjects )
968 : {
969 9 : rPersistEntry.pPresentationObjects = new sal_uInt32[ PPT_STYLESHEETENTRYS ];
970 9 : memset( rPersistEntry.pPresentationObjects, 0, PPT_STYLESHEETENTRYS * 4 );
971 : }
972 48 : if ( !rPersistEntry.pPresentationObjects[ nDestinationInstance ] )
973 23 : rPersistEntry.pPresentationObjects[ nDestinationInstance ] = rObjData.rSpHd.GetRecBegFilePos();
974 : }
975 604 : switch ( nDestinationInstance )
976 : {
977 : case TSS_TYPE_PAGETITLE :
978 : case TSS_TYPE_TITLE :
979 : {
980 40 : if ( GetSlideLayoutAtom()->eLayout == PPT_LAYOUT_TITLEMASTERSLIDE )
981 0 : nDestinationInstance = TSS_TYPE_TITLE;
982 : else
983 40 : nDestinationInstance = TSS_TYPE_PAGETITLE;
984 : }
985 40 : break;
986 : case TSS_TYPE_BODY :
987 : case TSS_TYPE_HALFBODY :
988 : case TSS_TYPE_QUARTERBODY :
989 428 : nDestinationInstance = TSS_TYPE_BODY;
990 428 : break;
991 : }
992 604 : aTextObj.SetDestinationInstance( (sal_uInt16)nDestinationInstance );
993 :
994 604 : bool bAutoFit = false; // auto-scale text into shape box
995 604 : switch ( aTextObj.GetInstance() )
996 : {
997 : case TSS_TYPE_PAGETITLE :
998 40 : case TSS_TYPE_TITLE : eTextKind = OBJ_TITLETEXT; break;
999 2 : case TSS_TYPE_SUBTITLE : eTextKind = OBJ_TEXT; break;
1000 : case TSS_TYPE_BODY :
1001 : case TSS_TYPE_HALFBODY :
1002 428 : case TSS_TYPE_QUARTERBODY : eTextKind = OBJ_OUTLINETEXT; bAutoFit = true; break;
1003 : }
1004 604 : if ( aTextObj.GetDestinationInstance() != TSS_TYPE_TEXT_IN_SHAPE )
1005 : {
1006 497 : if ( !aTextObj.GetOEPlaceHolderAtom() || !aTextObj.GetOEPlaceHolderAtom()->nPlaceholderId )
1007 : {
1008 404 : aTextObj.SetDestinationInstance( TSS_TYPE_TEXT_IN_SHAPE );
1009 404 : eTextKind = OBJ_RECT;
1010 : }
1011 : }
1012 604 : SdrObject* pTObj = NULL;
1013 604 : sal_Bool bWordWrap = (MSO_WrapMode)GetPropertyValue( DFF_Prop_WrapText, mso_wrapSquare ) != mso_wrapNone;
1014 604 : sal_Bool bFitShapeToText = ( GetPropertyValue( DFF_Prop_FitTextToShape ) & 2 ) != 0;
1015 :
1016 604 : if ( pRet && pRet->ISA( SdrObjCustomShape ) && ( eTextKind == OBJ_RECT ) )
1017 : {
1018 474 : bAutoGrowHeight = bFitShapeToText;
1019 474 : if ( bWordWrap )
1020 422 : bAutoGrowWidth = sal_False;
1021 : else
1022 52 : bAutoGrowWidth = sal_True;
1023 474 : pTObj = pRet;
1024 474 : pRet = NULL;
1025 : }
1026 : else
1027 : {
1028 130 : if ( pRet && pRet->ISA( SdrObjCustomShape ) )
1029 : {
1030 0 : SdrObject::Free( pRet );
1031 0 : pRet = NULL;
1032 : }
1033 130 : pTObj = new SdrRectObj( eTextKind != OBJ_RECT ? eTextKind : OBJ_TEXT );
1034 130 : pTObj->SetModel( pSdrModel );
1035 130 : SfxItemSet aSet( pSdrModel->GetItemPool() );
1036 130 : if ( !pRet )
1037 127 : ((SdrEscherImport*)this)->ApplyAttributes( rSt, aSet, rObjData );
1038 130 : pTObj->SetMergedItemSet( aSet );
1039 130 : if ( pRet )
1040 : {
1041 3 : pTObj->SetMergedItem( XLineStyleItem( XLINE_NONE ) );
1042 3 : pTObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) );
1043 : }
1044 130 : if ( bVerticalText )
1045 : {
1046 0 : bAutoGrowWidth = bFitShapeToText; // bFitShapeToText; can't be used, because we cut the text if it is too height,
1047 0 : bAutoGrowHeight = sal_False;
1048 : }
1049 : else
1050 : {
1051 130 : bAutoGrowWidth = sal_False;
1052 130 : bAutoGrowHeight = sal_True; // bFitShapeToText; can't be used, because we cut the text if it is too height,
1053 130 : }
1054 : }
1055 604 : pTObj->SetMergedItem( SvxFrameDirectionItem( bVerticalText ? FRMDIR_VERT_TOP_RIGHT : FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
1056 :
1057 : //Autofit text only if there is no auto grow height and width
1058 : //See fdo#41245
1059 604 : if (bAutoFit && !bAutoGrowHeight && !bAutoGrowWidth)
1060 : {
1061 401 : pTObj->SetMergedItem( SdrTextFitToSizeTypeItem(SDRTEXTFIT_AUTOFIT) );
1062 : }
1063 :
1064 604 : if ( !pTObj->ISA( SdrObjCustomShape ) )
1065 : {
1066 130 : pTObj->SetMergedItem( SdrTextAutoGrowWidthItem( bAutoGrowWidth ) );
1067 130 : pTObj->SetMergedItem( SdrTextAutoGrowHeightItem( bAutoGrowHeight ) );
1068 : }
1069 : else
1070 : {
1071 474 : pTObj->SetMergedItem( SdrTextWordWrapItem( bWordWrap ) );
1072 474 : pTObj->SetMergedItem( SdrTextAutoGrowHeightItem( bFitShapeToText ) );
1073 : }
1074 :
1075 604 : pTObj->SetMergedItem( SdrTextVertAdjustItem( eTVA ) );
1076 604 : pTObj->SetMergedItem( SdrTextHorzAdjustItem( eTHA ) );
1077 :
1078 604 : if ( nMinFrameHeight < 0 )
1079 23 : nMinFrameHeight = 0;
1080 604 : if ( !pTObj->ISA( SdrObjCustomShape ) )
1081 130 : pTObj->SetMergedItem( SdrTextMinFrameHeightItem( nMinFrameHeight ) );
1082 :
1083 604 : if ( nMinFrameWidth < 0 )
1084 0 : nMinFrameWidth = 0;
1085 604 : if ( !pTObj->ISA( SdrObjCustomShape ) )
1086 130 : pTObj->SetMergedItem( SdrTextMinFrameWidthItem( nMinFrameWidth ) );
1087 :
1088 : // set margins at the borders of the textbox
1089 604 : pTObj->SetMergedItem( SdrTextLeftDistItem( nTextLeft ) );
1090 604 : pTObj->SetMergedItem( SdrTextRightDistItem( nTextRight ) );
1091 604 : pTObj->SetMergedItem( SdrTextUpperDistItem( nTextTop ) );
1092 604 : pTObj->SetMergedItem( SdrTextLowerDistItem( nTextBottom ) );
1093 604 : pTObj->SetMergedItem( SdrTextFixedCellHeightItem( sal_True ) );
1094 :
1095 604 : if ( !pTObj->ISA( SdrObjCustomShape ) )
1096 130 : pTObj->SetSnapRect( rTextRect );
1097 604 : pTObj = ReadObjText( &aTextObj, pTObj, rData.pPage );
1098 604 : if ( pTObj )
1099 : {
1100 : /* check if our new snaprect makes trouble,
1101 : because we do not display the ADJUST_BLOCK
1102 : properly if the textsize is bigger than the
1103 : snaprect of the object. Then we will use
1104 : ADJUST_CENTER instead of ADJUST_BLOCK.
1105 : */
1106 594 : if ( !pTObj->ISA( SdrObjCustomShape ) && !bFitShapeToText && !bWordWrap )
1107 : {
1108 0 : SdrTextObj* pText = PTR_CAST( SdrTextObj, pTObj );
1109 0 : if ( pText )
1110 : {
1111 0 : if ( bVerticalText )
1112 : {
1113 0 : if ( eTVA == SDRTEXTVERTADJUST_BLOCK )
1114 : {
1115 0 : Size aTextSize( pText->GetTextSize() );
1116 0 : aTextSize.Width() += nTextLeft + nTextRight;
1117 0 : aTextSize.Height() += nTextTop + nTextBottom;
1118 0 : if ( rTextRect.GetHeight() < aTextSize.Height() )
1119 0 : pTObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
1120 : }
1121 : }
1122 : else
1123 : {
1124 0 : if ( eTHA == SDRTEXTHORZADJUST_BLOCK )
1125 : {
1126 0 : Size aTextSize( pText->GetTextSize() );
1127 0 : aTextSize.Width() += nTextLeft + nTextRight;
1128 0 : aTextSize.Height() += nTextTop + nTextBottom;
1129 0 : if ( rTextRect.GetWidth() < aTextSize.Width() )
1130 0 : pTObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_CENTER ) );
1131 : }
1132 : }
1133 : }
1134 : }
1135 : // rotate text with shape?
1136 594 : sal_Int32 nAngle = ( rObjData.nSpFlags & SP_FFLIPV ) ? -mnFix16Angle : mnFix16Angle; // #72116# vertical flip -> rotate by using the other way
1137 594 : nAngle += nTextRotationAngle;
1138 :
1139 594 : if ( !pTObj->ISA( SdrObjCustomShape ) )
1140 : {
1141 120 : if ( rObjData.nSpFlags & SP_FFLIPV )
1142 : {
1143 0 : double a = 18000 * nPi180;
1144 0 : pTObj->Rotate( rTextRect.Center(), 18000, sin( a ), cos( a ) );
1145 : }
1146 120 : if ( rObjData.nSpFlags & SP_FFLIPH )
1147 0 : nAngle = 36000 - nAngle;
1148 120 : if ( nAngle )
1149 : {
1150 0 : double a = nAngle * nPi180;
1151 0 : pTObj->NbcRotate( rObjData.aBoundRect.Center(), nAngle, sin( a ), cos( a ) );
1152 : }
1153 : }
1154 594 : if ( pRet )
1155 : {
1156 0 : SdrObject* pGroup = new SdrObjGroup;
1157 0 : pGroup->GetSubList()->NbcInsertObject( pRet );
1158 0 : pGroup->GetSubList()->NbcInsertObject( pTObj );
1159 0 : pRet = pGroup;
1160 : }
1161 : else
1162 594 : pRet = pTObj;
1163 : }
1164 1186 : }
1165 : }
1166 : }
1167 : else
1168 : {
1169 36 : if ( maShapeRecords.SeekToContent( rSt, DFF_msofbtUDefProp, SEEK_FROM_CURRENT_AND_RESTART ) )
1170 : {
1171 34 : maShapeRecords.Current()->SeekToBegOfRecord( rSt );
1172 34 : DffPropertyReader aSecPropSet( *this );
1173 34 : aSecPropSet.ReadPropSet( rSt, (ProcessData*)pData );
1174 34 : sal_Int32 nTableProperties = aSecPropSet.GetPropertyValue( DFF_Prop_tableProperties, 0 );
1175 34 : if ( nTableProperties & 3 )
1176 : {
1177 33 : if ( aSecPropSet.SeekToContent( DFF_Prop_tableRowProperties, rSt ) )
1178 : {
1179 33 : sal_Int16 i, nRowCount = 0;
1180 33 : rSt >> nRowCount >> i >> i;
1181 33 : if ( nRowCount )
1182 : {
1183 33 : sal_uInt32* pTableArry = new sal_uInt32[ nRowCount + 2 ];
1184 33 : pTableArry[ 0 ] = nTableProperties;
1185 33 : pTableArry[ 1 ] = nRowCount;
1186 108 : for ( i = 0; i < nRowCount; i++ )
1187 75 : rSt >> pTableArry[ i + 2 ];
1188 33 : rData.pTableRowProperties = pTableArry;
1189 : }
1190 : }
1191 34 : }
1192 : }
1193 : }
1194 1240 : if ( pRet ) // sj: #i38501#, and and taking care of connections to group objects
1195 : {
1196 1233 : if ( rObjData.nSpFlags & SP_FBACKGROUND )
1197 : {
1198 51 : pRet->NbcSetSnapRect( Rectangle( Point(), ((SdrPage*)rData.pPage)->GetSize() ) ); // set size
1199 : }
1200 1233 : if ( rPersistEntry.pSolverContainer )
1201 : {
1202 218 : for ( size_t i = 0; i < rPersistEntry.pSolverContainer->aCList.size(); ++i )
1203 : {
1204 40 : SvxMSDffConnectorRule* pPtr = rPersistEntry.pSolverContainer->aCList[ i ];
1205 40 : if ( rObjData.nShapeId == pPtr->nShapeC )
1206 2 : pPtr->pCObj = pRet;
1207 : else
1208 : {
1209 38 : SdrObject* pConnectObj = pRet;
1210 38 : if ( pOriginalObj && pRet->ISA( SdrObjGroup ) )
1211 : { /* check if the original object from the escherimport is part of the group object,
1212 : if this is the case, we will use the original object to connect to */
1213 4 : SdrObjListIter aIter( *pRet, IM_DEEPWITHGROUPS );
1214 8 : while( aIter.IsMore() )
1215 : {
1216 0 : SdrObject* pPartObj = aIter.Next();
1217 0 : if ( pPartObj == pOriginalObj )
1218 : {
1219 0 : pConnectObj = pPartObj;
1220 0 : break;
1221 : }
1222 4 : }
1223 : }
1224 38 : if ( rObjData.nShapeId == pPtr->nShapeA )
1225 : {
1226 2 : pPtr->pAObj = pConnectObj;
1227 2 : pPtr->nSpFlagsA = rObjData.nSpFlags;
1228 : }
1229 38 : if ( rObjData.nShapeId == pPtr->nShapeB )
1230 : {
1231 2 : pPtr->pBObj = pConnectObj;
1232 2 : pPtr->nSpFlagsB = rObjData.nSpFlags;
1233 : }
1234 : }
1235 : }
1236 : }
1237 1233 : if ( rPersistEntry.ePageKind == PPT_MASTERPAGE )
1238 : { // maybe the escher clusterlist is not correct, but we have to got the right page by using the
1239 : // spMaster property, so we are patching the table
1240 53 : if ( rPersistEntry.nDrawingDgId != 0xffffffff )
1241 : {
1242 53 : sal_uInt32 nSec = ( rObjData.nShapeId >> 10 ) - 1;
1243 53 : if ( !maFidcls.empty() && ( nSec < mnIdClusters ) )
1244 53 : maFidcls[ nSec ].dgid = rPersistEntry.nDrawingDgId; // insert the correct drawing id;
1245 : }
1246 : }
1247 1233 : if ( GetPropertyValue( DFF_Prop_fNoFillHitTest ) & 0x10 )
1248 : {
1249 265 : if ( (MSO_FillType)GetPropertyValue( DFF_Prop_fillType, mso_fillSolid ) == mso_fillBackground )
1250 : {
1251 0 : rData.aBackgroundColoredObjects.push_back( pRet );
1252 : }
1253 : }
1254 : }
1255 1240 : return pRet;
1256 : }
1257 :
1258 6 : SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const String& rBaseURL ) :
1259 : SdrEscherImport ( rParam, rBaseURL ),
1260 6 : bOk ( rStCtrl.GetErrorCode() == SVSTREAM_OK ),
1261 : pPersistPtr ( NULL ),
1262 : nPersistPtrAnz ( 0 ),
1263 : pDefaultSheet ( NULL ),
1264 : pMasterPages ( NULL ),
1265 : pSlidePages ( NULL ),
1266 : pNotePages ( NULL ),
1267 : nAktPageNum ( 0 ),
1268 : nDocStreamPos ( 0 ),
1269 : nPageColorsNum ( 0xFFFF ),
1270 : ePageColorsKind ( PPT_MASTERPAGE ),
1271 12 : eAktPageKind ( PPT_MASTERPAGE )
1272 : {
1273 : DffRecordHeader* pHd;
1274 6 : if ( bOk )
1275 : {
1276 6 : rStCtrl.Seek( STREAM_SEEK_TO_END );
1277 6 : nStreamLen = rStCtrl.Tell();
1278 :
1279 : // try to allocate the UserEditAtom via CurrentUserAtom
1280 6 : sal_uInt32 nCurrentUserEdit = rParam.aCurrentUserAtom.nCurrentUserEdit;
1281 6 : if ( nCurrentUserEdit )
1282 : {
1283 6 : rStCtrl.Seek( nCurrentUserEdit );
1284 6 : rStCtrl >> aUserEditAtom;
1285 : }
1286 6 : if ( !aUserEditAtom.nOffsetPersistDirectory )
1287 : { // if there is no UserEditAtom try to search the last one
1288 :
1289 0 : rStCtrl.Seek( 0 );
1290 0 : DffRecordManager aPptRecManager; // contains all first level container and atoms
1291 0 : aPptRecManager.Consume( rStCtrl, sal_False, nStreamLen );
1292 0 : for ( pHd = aPptRecManager.Last(); pHd; pHd = aPptRecManager.Prev() )
1293 : {
1294 0 : if ( pHd->nRecType == PPT_PST_UserEditAtom )
1295 : {
1296 0 : pHd->SeekToBegOfRecord( rStCtrl );
1297 0 : rStCtrl >> aUserEditAtom;
1298 0 : break;
1299 : }
1300 : }
1301 0 : if ( !pHd )
1302 0 : bOk = sal_False;
1303 : }
1304 : }
1305 6 : if ( rStCtrl.GetError() != 0 )
1306 0 : bOk = sal_False;
1307 :
1308 6 : if ( bOk )
1309 : {
1310 6 : nPersistPtrAnz = aUserEditAtom.nMaxPersistWritten + 1;
1311 6 : if ( ( nPersistPtrAnz >> 2 ) > nStreamLen ) // sj: at least nPersistPtrAnz is not allowed to be greater than filesize
1312 0 : bOk = sal_False; // (it should not be greater than the PPT_PST_PersistPtrIncrementalBlock, but
1313 : // we are reading this block later, so we do not have access yet)
1314 :
1315 6 : if ( bOk && ( nPersistPtrAnz < ( SAL_MAX_UINT32 / sizeof( sal_uInt32 ) ) ) )
1316 6 : pPersistPtr = new (std::nothrow) sal_uInt32[ nPersistPtrAnz ];
1317 6 : if ( !pPersistPtr )
1318 0 : bOk = sal_False;
1319 6 : if ( bOk )
1320 : {
1321 6 : memset( pPersistPtr, 0x00, nPersistPtrAnz * 4 );
1322 :
1323 : // SJ: new search mechanism from bottom to top (Issue 21122)
1324 6 : PptUserEditAtom aCurrentEditAtom( aUserEditAtom );
1325 6 : sal_uInt32 nCurrentEditAtomStrmPos = aCurrentEditAtom.aHd.GetRecEndFilePos();
1326 18 : while( nCurrentEditAtomStrmPos )
1327 : {
1328 6 : sal_uInt32 nPersistIncPos = aCurrentEditAtom.nOffsetPersistDirectory;
1329 6 : if ( nPersistIncPos )
1330 : {
1331 6 : rStCtrl.Seek( nPersistIncPos );
1332 6 : DffRecordHeader aPersistHd;
1333 6 : rStCtrl >> aPersistHd;
1334 6 : if ( aPersistHd.nRecType == PPT_PST_PersistPtrIncrementalBlock )
1335 : {
1336 6 : sal_uLong nPibLen = aPersistHd.GetRecEndFilePos();
1337 39 : while ( bOk && ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < nPibLen ) )
1338 : {
1339 : sal_uInt32 nOfs, nAnz;
1340 27 : rStCtrl >> nOfs;
1341 27 : nAnz = nOfs;
1342 27 : nOfs &= 0x000FFFFF;
1343 27 : nAnz >>= 20;
1344 126 : while ( bOk && ( rStCtrl.GetError() == 0 ) && ( nAnz > 0 ) && ( nOfs <= nPersistPtrAnz ) )
1345 : {
1346 : sal_uInt32 nPt;
1347 72 : rStCtrl >> nPt;
1348 72 : if ( !pPersistPtr[ nOfs ] )
1349 : {
1350 72 : pPersistPtr[ nOfs ] = nPt;
1351 72 : if ( pPersistPtr[ nOfs ] > nStreamLen )
1352 : {
1353 0 : bOk = sal_False;
1354 : OSL_FAIL("SdrPowerPointImport::Ctor(): Ungueltiger Eintrag im Persist-Directory!");
1355 : }
1356 : }
1357 72 : nAnz--;
1358 72 : nOfs++;
1359 : }
1360 27 : if ( bOk && nAnz > 0 )
1361 : {
1362 : OSL_FAIL("SdrPowerPointImport::Ctor(): Nicht alle Persist-Directory Entraege gelesen!");
1363 0 : bOk = sal_False;
1364 : }
1365 : }
1366 : }
1367 : }
1368 6 : nCurrentEditAtomStrmPos = aCurrentEditAtom.nOffsetLastEdit < nCurrentEditAtomStrmPos ? aCurrentEditAtom.nOffsetLastEdit : 0;
1369 6 : if ( nCurrentEditAtomStrmPos )
1370 : {
1371 0 : rStCtrl.Seek( nCurrentEditAtomStrmPos );
1372 0 : rStCtrl >> aCurrentEditAtom;
1373 : }
1374 : }
1375 : }
1376 : }
1377 6 : if ( rStCtrl.GetError() != 0 )
1378 0 : bOk = sal_False;
1379 6 : if ( bOk )
1380 : { // check Document PersistEntry
1381 6 : nDocStreamPos = aUserEditAtom.nDocumentRef;
1382 6 : if ( nDocStreamPos > nPersistPtrAnz )
1383 : {
1384 : OSL_FAIL("SdrPowerPointImport::Ctor(): aUserEditAtom.nDocumentRef ungueltig!");
1385 0 : bOk = sal_False;
1386 : }
1387 : }
1388 6 : if ( bOk )
1389 : { // check Document FilePos
1390 6 : nDocStreamPos = pPersistPtr[ nDocStreamPos ];
1391 6 : if ( nDocStreamPos >= nStreamLen )
1392 : {
1393 : OSL_FAIL("SdrPowerPointImport::Ctor(): nDocStreamPos >= nStreamLen!");
1394 0 : bOk = sal_False;
1395 : }
1396 : }
1397 6 : if ( bOk )
1398 : {
1399 6 : rStCtrl.Seek( nDocStreamPos );
1400 6 : aDocRecManager.Consume( rStCtrl );
1401 :
1402 6 : DffRecordHeader aDocHd;
1403 6 : rStCtrl >> aDocHd;
1404 : // read DocumentAtom
1405 6 : DffRecordHeader aDocAtomHd;
1406 6 : rStCtrl >> aDocAtomHd;
1407 6 : if ( aDocHd.nRecType == PPT_PST_Document && aDocAtomHd.nRecType == PPT_PST_DocumentAtom )
1408 : {
1409 5 : aDocAtomHd.SeekToBegOfRecord( rStCtrl );
1410 5 : rStCtrl >> aDocAtom;
1411 : }
1412 : else
1413 1 : bOk = sal_False;
1414 :
1415 6 : if ( bOk )
1416 : {
1417 5 : if ( !pFonts )
1418 5 : ReadFontCollection();
1419 :
1420 : // reading TxPF, TxSI
1421 5 : PPTTextCharacterStyleAtomInterpreter aTxCFStyle; // SJ: TODO, this atom needs to be interpreted, it contains character default styles for standard objects (instance4)
1422 5 : PPTTextParagraphStyleAtomInterpreter aTxPFStyle;
1423 5 : PPTTextSpecInfoAtomInterpreter aTxSIStyle; // styles (default language setting ... )
1424 :
1425 5 : DffRecordHeader* pEnvHd = aDocRecManager.GetRecordHeader( PPT_PST_Environment );
1426 5 : if ( pEnvHd )
1427 : {
1428 5 : pEnvHd->SeekToContent( rStCtrl );
1429 5 : DffRecordHeader aTxPFStyleRecHd;
1430 5 : if ( SeekToRec( rStCtrl, PPT_PST_TxPFStyleAtom, pEnvHd->GetRecEndFilePos(), &aTxPFStyleRecHd ) )
1431 2 : aTxPFStyle.Read( rStCtrl, aTxPFStyleRecHd );
1432 :
1433 5 : pEnvHd->SeekToContent( rStCtrl );
1434 5 : DffRecordHeader aTxSIStyleRecHd;
1435 5 : if ( SeekToRec( rStCtrl, PPT_PST_TxSIStyleAtom, pEnvHd->GetRecEndFilePos(), &aTxSIStyleRecHd ) )
1436 : {
1437 5 : aTxSIStyle.Read( rStCtrl, aTxSIStyleRecHd, PPT_PST_TxSIStyleAtom );
1438 : #ifdef DBG_UTIL
1439 : if ( !aTxSIStyle.bValid )
1440 : {
1441 : if (!(rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT ))
1442 : {
1443 : OSL_FAIL( "SdrTextSpecInfoAtomInterpreter::Ctor(): parsing error, this document needs to be analysed (SJ)" );
1444 : }
1445 : }
1446 : #endif
1447 : }
1448 : }
1449 :
1450 : // TODO:: PPT_PST_TxPFStyleAtom
1451 :
1452 : // read SlidePersists
1453 5 : pMasterPages=new PptSlidePersistList;
1454 5 : pSlidePages =new PptSlidePersistList;
1455 5 : pNotePages =new PptSlidePersistList;
1456 :
1457 : // now always creating the handout page, it will be the first in our masterpage list
1458 5 : PptSlidePersistEntry* pE = new PptSlidePersistEntry;
1459 5 : pE->aPersistAtom.nPsrReference = aDocAtom.nHandoutMasterPersist;
1460 5 : pE->bHandoutMaster = sal_True;
1461 5 : if ( !aDocAtom.nHandoutMasterPersist )
1462 4 : pE->bStarDrawFiller = sal_True; // this is a dummy master page
1463 5 : pMasterPages->insert( pMasterPages->begin(), pE );
1464 :
1465 5 : sal_uInt16 nPageListNum = 0;
1466 5 : DffRecordHeader* pSlideListWithTextHd = aDocRecManager.GetRecordHeader( PPT_PST_SlideListWithText );
1467 5 : PptSlidePersistEntry* pPreviousPersist = NULL;
1468 24 : while ( pSlideListWithTextHd && ( nPageListNum < 3 ) )
1469 : {
1470 14 : pSlideListWithTextHd->SeekToContent( rStCtrl );
1471 14 : PptSlidePersistList* pPageList = GetPageList( PptPageKind( nPageListNum ) );
1472 14 : sal_uInt32 nSlideListWithTextHdEndOffset = pSlideListWithTextHd->GetRecEndFilePos();
1473 85 : while ( SeekToRec( rStCtrl, PPT_PST_SlidePersistAtom, nSlideListWithTextHdEndOffset ) )
1474 : {
1475 57 : if ( pPreviousPersist )
1476 52 : pPreviousPersist->nSlidePersistEndOffset = rStCtrl.Tell();
1477 57 : PptSlidePersistEntry* pE2 = new PptSlidePersistEntry;
1478 57 : rStCtrl >> pE2->aPersistAtom;
1479 57 : pE2->nSlidePersistStartOffset = rStCtrl.Tell();
1480 57 : pE2->ePageKind = PptPageKind( nPageListNum );
1481 57 : pPageList->push_back( pE2 );
1482 57 : pPreviousPersist = pE2;
1483 : }
1484 14 : if ( pPreviousPersist )
1485 14 : pPreviousPersist->nSlidePersistEndOffset = nSlideListWithTextHdEndOffset;
1486 14 : pSlideListWithTextHd = aDocRecManager.GetRecordHeader( PPT_PST_SlideListWithText, SEEK_FROM_CURRENT );
1487 14 : nPageListNum++;
1488 : }
1489 :
1490 : // we will ensure that there is at least one master page
1491 5 : if ( pMasterPages->size() == 1 ) // -> there is only a handout page available
1492 : {
1493 0 : PptSlidePersistEntry* pE2 = new PptSlidePersistEntry;
1494 0 : pE2->bStarDrawFiller = sal_True; // this is a dummy master page
1495 0 : pMasterPages->insert( pMasterPages->begin() + 1, pE2 );
1496 : }
1497 :
1498 : // now we will insert at least one notes master for each master page
1499 : sal_uInt16 nMasterPage;
1500 5 : sal_uInt16 nMasterPages = pMasterPages->size() - 1;
1501 10 : for ( nMasterPage = 0; nMasterPage < nMasterPages; nMasterPage++ )
1502 : {
1503 5 : PptSlidePersistEntry* pE2 = new PptSlidePersistEntry;
1504 5 : pE2->bNotesMaster = sal_True;
1505 5 : pE2->bStarDrawFiller = sal_True; // this is a dummy master page
1506 5 : if ( !nMasterPage && aDocAtom.nNotesMasterPersist )
1507 : { // special treatment for the first notes master
1508 4 : pE2->aPersistAtom.nPsrReference = aDocAtom.nNotesMasterPersist;
1509 4 : pE2->bStarDrawFiller = sal_False; // this is a dummy master page
1510 : }
1511 5 : pMasterPages->insert( pMasterPages->begin() + (( nMasterPage + 1 ) << 1), pE2 );
1512 : }
1513 :
1514 : // read for each page the SlideAtom respectively the NotesAtom if it exists
1515 5 : nPageListNum = 0;
1516 20 : for ( nPageListNum = 0; nPageListNum < 3; nPageListNum++ )
1517 : {
1518 15 : PptSlidePersistList* pPageList = GetPageList( PptPageKind( nPageListNum ) );
1519 82 : for ( sal_uInt16 nPageNum = 0; nPageNum < pPageList->size(); nPageNum++ )
1520 : {
1521 67 : PptSlidePersistEntry* pE2 = (*pPageList)[ nPageNum ];
1522 67 : sal_uLong nPersist = pE2->aPersistAtom.nPsrReference;
1523 67 : if ( ( nPersist > 0 ) && ( nPersist < nPersistPtrAnz ) )
1524 : {
1525 62 : sal_uLong nFPos = pPersistPtr[ nPersist ];
1526 62 : if ( nFPos < nStreamLen )
1527 : {
1528 62 : rStCtrl.Seek( nFPos );
1529 62 : DffRecordHeader aSlideHd;
1530 62 : rStCtrl >> aSlideHd;
1531 62 : if ( SeekToRec( rStCtrl, PPT_PST_SlideAtom, aSlideHd.GetRecEndFilePos() ) )
1532 37 : rStCtrl >> pE2->aSlideAtom;
1533 25 : else if ( SeekToRec( rStCtrl, PPT_PST_NotesAtom, aSlideHd.GetRecEndFilePos() ) )
1534 23 : rStCtrl >> pE2->aNotesAtom;
1535 62 : aSlideHd.SeekToContent( rStCtrl );
1536 :
1537 62 : DffRecordHeader aPPTDrawingHd;
1538 62 : if ( SeekToRec( rStCtrl, PPT_PST_PPDrawing, aSlideHd.GetRecEndFilePos(), &aPPTDrawingHd ) )
1539 : {
1540 61 : DffRecordHeader aPPTDgContainer;
1541 61 : if ( SeekToRec( rStCtrl, DFF_msofbtDgContainer, aPPTDrawingHd.GetRecEndFilePos(), &aPPTDgContainer ) )
1542 : {
1543 61 : if ( SeekToRec( rStCtrl, DFF_msofbtDg, aPPTDrawingHd.GetRecEndFilePos() ) )
1544 : {
1545 61 : DffRecordHeader aDgRecordHeader;
1546 61 : rStCtrl >> aDgRecordHeader;
1547 61 : pE2->nDrawingDgId = aDgRecordHeader.nRecInstance;
1548 61 : aDgRecordHeader.SeekToEndOfRecord( rStCtrl );
1549 : }
1550 61 : if ( SeekToRec( rStCtrl, DFF_msofbtSolverContainer, aPPTDgContainer.GetRecEndFilePos() ) )
1551 : {
1552 5 : pE2->pSolverContainer = new SvxMSDffSolverContainer;
1553 5 : rStCtrl >> *( pE2->pSolverContainer );
1554 : }
1555 61 : aPPTDgContainer.SeekToBegOfRecord( rStCtrl );
1556 61 : SetDgContainer( rStCtrl ); // set this, so that the escherimport is knowing of our drawings
1557 : }
1558 : }
1559 : // office xp is supporting more than one stylesheet
1560 62 : if ( ( pE2->ePageKind == PPT_MASTERPAGE ) && ( pE2->aSlideAtom.nMasterId == 0 ) && ( pE2->bNotesMaster == 0 ) )
1561 : {
1562 6 : PPTTextSpecInfo aTxSI( 0 );
1563 6 : if ( aTxSIStyle.bValid && !aTxSIStyle.aList.empty() )
1564 6 : aTxSI = *( aTxSIStyle.aList[ 0 ] );
1565 :
1566 6 : pE2->pStyleSheet = new PPTStyleSheet( aSlideHd, rStCtrl, *this, aTxCFStyle, aTxPFStyle, aTxSI );
1567 6 : pDefaultSheet = pE2->pStyleSheet;
1568 : }
1569 62 : if ( SeekToRec( rStCtrl, PPT_PST_ColorSchemeAtom, aSlideHd.GetRecEndFilePos() ) )
1570 61 : rStCtrl >> pE2->aColorScheme;
1571 : else
1572 : {
1573 : OSL_FAIL( "SdrPowerPointImport::Ctor(): could not get SlideColorScheme! (SJ)" );
1574 : }
1575 : }
1576 : else
1577 : {
1578 : OSL_FAIL("SdrPowerPointImport::Ctor(): Persist-Eintrag fehlerhaft! (SJ)");
1579 : }
1580 : }
1581 : }
1582 : }
1583 5 : DffRecordHeader* pHeadersFootersHd = aDocRecManager.GetRecordHeader( PPT_PST_HeadersFooters, SEEK_FROM_BEGINNING );
1584 5 : if ( pHeadersFootersHd )
1585 : {
1586 5 : HeaderFooterEntry aNormalMaster, aNotesMaster;
1587 14 : for ( ; pHeadersFootersHd; pHeadersFootersHd = aDocRecManager.GetRecordHeader( PPT_PST_HeadersFooters, SEEK_FROM_CURRENT ) )
1588 : {
1589 9 : if ( pHeadersFootersHd->nRecInstance == 3 ) // normal master
1590 5 : ImportHeaderFooterContainer( *pHeadersFootersHd, aNormalMaster );
1591 4 : else if ( pHeadersFootersHd->nRecInstance == 4 ) // notes master
1592 4 : ImportHeaderFooterContainer( *pHeadersFootersHd, aNotesMaster );
1593 : }
1594 20 : for ( sal_uInt16 i = 0; i < pMasterPages->size(); i++ )
1595 : {
1596 15 : if ( (*pMasterPages)[ i ]->bNotesMaster )
1597 5 : (*pMasterPages)[ i ]->pHeaderFooterEntry = new HeaderFooterEntry( aNotesMaster );
1598 : else
1599 10 : (*pMasterPages)[ i ]->pHeaderFooterEntry = new HeaderFooterEntry( aNormalMaster );
1600 5 : }
1601 5 : }
1602 : }
1603 : }
1604 6 : if ( ( rStCtrl.GetError() != 0 ) || ( pDefaultSheet == NULL ) )
1605 1 : bOk = sal_False;
1606 6 : pPPTStyleSheet = pDefaultSheet;
1607 6 : rStCtrl.Seek( 0 );
1608 6 : }
1609 :
1610 12 : SdrPowerPointImport::~SdrPowerPointImport()
1611 : {
1612 6 : for ( size_t i = 0, n = aHyperList.size(); i < n; ++i ) {
1613 0 : delete aHyperList[ i ];
1614 : }
1615 6 : aHyperList.clear();
1616 6 : delete pMasterPages;
1617 6 : delete pSlidePages;
1618 6 : delete pNotePages;
1619 6 : delete[] pPersistPtr;
1620 6 : }
1621 :
1622 0 : sal_Bool PPTConvertOCXControls::ReadOCXStream( SotStorageRef& rSrc,
1623 : com::sun::star::uno::Reference<
1624 : com::sun::star::drawing::XShape > *pShapeRef,
1625 : sal_Bool bFloatingCtrl )
1626 : {
1627 0 : bool bRes = false;
1628 0 : uno::Reference< form::XFormComponent > xFComp;
1629 0 : if ( mpPPTImporter && mpPPTImporter->ReadFormControl( rSrc, xFComp ) )
1630 : {
1631 0 : if ( xFComp.is() )
1632 : {
1633 0 : com::sun::star::awt::Size aSz; // not used in import
1634 0 : bRes = InsertControl( xFComp, aSz,pShapeRef,bFloatingCtrl);
1635 : }
1636 : }
1637 0 : return bRes;
1638 : }
1639 :
1640 0 : sal_Bool PPTConvertOCXControls::InsertControl(
1641 : const com::sun::star::uno::Reference<
1642 : com::sun::star::form::XFormComponent > &rFComp,
1643 : const com::sun::star::awt::Size& rSize,
1644 : com::sun::star::uno::Reference<
1645 : com::sun::star::drawing::XShape > *pShape,
1646 : sal_Bool /*bFloatingCtrl*/)
1647 : {
1648 0 : sal_Bool bRetValue = sal_False;
1649 : try
1650 : {
1651 0 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape;
1652 :
1653 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > & rFormComps =
1654 0 : GetFormComps();
1655 :
1656 : ::com::sun::star::uno::Any aTmp( &rFComp, ::getCppuType((const ::com::sun::star::uno::Reference<
1657 0 : com::sun::star::form::XFormComponent >*)0) );
1658 :
1659 0 : rFormComps->insertByIndex( rFormComps->getCount(), aTmp );
1660 :
1661 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceFactory =
1662 0 : GetServiceFactory();
1663 0 : if( rServiceFactory.is() )
1664 : {
1665 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xCreate = rServiceFactory
1666 0 : ->createInstance(String( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ControlShape" ) ) );
1667 0 : if( xCreate.is() )
1668 : {
1669 0 : xShape = ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >(xCreate, ::com::sun::star::uno::UNO_QUERY);
1670 0 : if ( xShape.is() )
1671 : {
1672 0 : xShape->setSize(rSize);
1673 : // set the Control-Model at the Control-Shape
1674 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XControlShape > xControlShape( xShape,
1675 0 : ::com::sun::star::uno::UNO_QUERY );
1676 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > xControlModel( rFComp,
1677 0 : ::com::sun::star::uno::UNO_QUERY );
1678 0 : if ( xControlShape.is() && xControlModel.is() )
1679 : {
1680 0 : xControlShape->setControl( xControlModel );
1681 0 : if (pShape)
1682 0 : *pShape = xShape;
1683 0 : bRetValue = sal_True;
1684 0 : }
1685 : }
1686 0 : }
1687 0 : }
1688 : }
1689 0 : catch( ... )
1690 : {
1691 0 : bRetValue = sal_False;
1692 : }
1693 0 : return bRetValue;
1694 : };
1695 0 : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& PPTConvertOCXControls::GetDrawPage()
1696 : {
1697 0 : if( !xDrawPage.is() && mxModel.is() )
1698 : {
1699 0 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPages > xDrawPages;
1700 0 : switch( ePageKind )
1701 : {
1702 : case PPT_SLIDEPAGE :
1703 : case PPT_NOTEPAGE :
1704 : {
1705 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPagesSupplier >
1706 0 : xDrawPagesSupplier( mxModel, ::com::sun::star::uno::UNO_QUERY);
1707 0 : if ( xDrawPagesSupplier.is() )
1708 0 : xDrawPages = xDrawPagesSupplier->getDrawPages();
1709 : }
1710 0 : break;
1711 :
1712 : case PPT_MASTERPAGE :
1713 : {
1714 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPagesSupplier >
1715 0 : xMasterPagesSupplier( mxModel, ::com::sun::star::uno::UNO_QUERY);
1716 0 : if ( xMasterPagesSupplier.is() )
1717 0 : xDrawPages = xMasterPagesSupplier->getMasterPages();
1718 : }
1719 0 : break;
1720 : }
1721 0 : if ( xDrawPages.is() && xDrawPages->getCount() )
1722 : {
1723 0 : xDrawPages->getCount();
1724 0 : ::com::sun::star::uno::Any aAny( xDrawPages->getByIndex( xDrawPages->getCount() - 1 ) );
1725 0 : aAny >>= xDrawPage;
1726 0 : }
1727 : }
1728 0 : return xDrawPage;
1729 : }
1730 :
1731 3 : sal_Bool SdrPowerPointOLEDecompress( SvStream& rOutput, SvStream& rInput, sal_uInt32 nInputSize )
1732 : {
1733 3 : sal_uInt32 nOldPos = rInput.Tell();
1734 3 : char* pBuf = new char[ nInputSize ];
1735 3 : rInput.Read( pBuf, nInputSize );
1736 3 : ZCodec aZCodec( 0x8000, 0x8000 );
1737 3 : aZCodec.BeginCompression();
1738 3 : SvMemoryStream aSource( pBuf, nInputSize, STREAM_READ );
1739 3 : aZCodec.Decompress( aSource, rOutput );
1740 3 : const sal_Bool bSuccess(0L != aZCodec.EndCompression());
1741 3 : delete[] pBuf;
1742 3 : rInput.Seek( nOldPos );
1743 3 : return bSuccess;
1744 : }
1745 :
1746 : // #i32596# - add new parameter <_nCalledByGroup>
1747 3 : SdrObject* SdrPowerPointImport::ImportOLE( long nOLEId,
1748 : const Graphic& rGraf,
1749 : const Rectangle& rBoundRect,
1750 : const Rectangle& rVisArea,
1751 : const int /*_nCalledByGroup*/,
1752 : sal_Int64 /*nAspect*/ ) const
1753 : {
1754 3 : SdrObject* pRet = NULL;
1755 :
1756 3 : sal_uInt32 nOldPos = rStCtrl.Tell();
1757 :
1758 3 : Graphic aGraphic( rGraf );
1759 :
1760 3 : if ( ((SdrPowerPointImport*)this)->maShapeRecords.SeekToContent( rStCtrl, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) )
1761 : {
1762 3 : DffRecordHeader aPlaceHd;
1763 15 : while ( ( rStCtrl.GetError() == 0 )
1764 6 : && ( rStCtrl.Tell() < ((SdrPowerPointImport*)this)->maShapeRecords.Current()->GetRecEndFilePos() ) )
1765 : {
1766 3 : rStCtrl >> aPlaceHd;
1767 3 : if ( aPlaceHd.nRecType == PPT_PST_RecolorInfoAtom )
1768 : {
1769 0 : ((SdrPowerPointImport*)this)->RecolorGraphic( rStCtrl, aPlaceHd.nRecLen, aGraphic );
1770 0 : break;
1771 : }
1772 : else
1773 3 : aPlaceHd.SeekToEndOfRecord( rStCtrl );
1774 : }
1775 : }
1776 :
1777 : PPTOleEntry* pOe;
1778 6 : for ( size_t i = 0; i < ((SdrPowerPointImport*)this)->aOleObjectList.size(); ++i )
1779 : {
1780 3 : pOe = ((SdrPowerPointImport*)this)->aOleObjectList[ i ];
1781 3 : if ( pOe->nId != (sal_uInt32)nOLEId )
1782 0 : continue;
1783 :
1784 3 : rStCtrl.Seek( pOe->nRecHdOfs );
1785 :
1786 3 : DffRecordHeader aHd;
1787 3 : rStCtrl >> aHd;
1788 :
1789 3 : sal_uInt32 nLen = aHd.nRecLen - 4;
1790 3 : if ( (sal_Int32)nLen > 0 )
1791 : {
1792 3 : sal_Bool bSuccess = sal_False;
1793 :
1794 3 : rStCtrl.SeekRel( 4 );
1795 :
1796 3 : ::utl::TempFile aTmpFile;
1797 3 : aTmpFile.EnableKillingFile( sal_True );
1798 :
1799 3 : if ( aTmpFile.IsValid() )
1800 : {
1801 3 : SvStream* pDest = ::utl::UcbStreamHelper::CreateStream( aTmpFile.GetURL(), STREAM_TRUNC | STREAM_WRITE );
1802 3 : if ( pDest )
1803 3 : bSuccess = SdrPowerPointOLEDecompress( *pDest, rStCtrl, nLen );
1804 3 : delete pDest;
1805 : }
1806 3 : if ( bSuccess )
1807 : {
1808 3 : SvStream* pDest = ::utl::UcbStreamHelper::CreateStream( aTmpFile.GetURL(), STREAM_READ );
1809 3 : Storage* pObjStor = pDest ? new Storage( *pDest, sal_True ) : NULL;
1810 3 : if ( pObjStor )
1811 : {
1812 3 : SotStorageRef xObjStor( new SotStorage( pObjStor ) );
1813 3 : if ( xObjStor.Is() && !xObjStor->GetError() )
1814 : {
1815 3 : if ( xObjStor->GetClassName() == SvGlobalName() )
1816 : {
1817 0 : ClsId aId( pObjStor->GetClassId() );
1818 0 : xObjStor->SetClass( SvGlobalName( aId.n1, aId.n2, aId.n3, aId.n4, aId.n5, aId.n6, aId.n7, aId.n8, aId.n9, aId.n10, aId.n11 ),
1819 0 : pObjStor->GetFormat(), pObjStor->GetUserName() );
1820 : }
1821 3 : SotStorageStreamRef xSrcTst = xObjStor->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "\1Ole" ) ) );
1822 3 : if ( xSrcTst.Is() )
1823 : {
1824 : sal_uInt8 aTestA[ 10 ];
1825 3 : sal_Bool bGetItAsOle = ( sizeof( aTestA ) == xSrcTst->Read( aTestA, sizeof( aTestA ) ) );
1826 3 : if ( !bGetItAsOle )
1827 : { // maybe there is a contentsstream in here
1828 0 : xSrcTst = xObjStor->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "Contents" ) ), STREAM_READWRITE | STREAM_NOCREATE );
1829 0 : bGetItAsOle = ( xSrcTst.Is() && sizeof( aTestA ) == xSrcTst->Read( aTestA, sizeof( aTestA ) ) );
1830 : }
1831 3 : if ( bGetItAsOle )
1832 : {
1833 3 : ::rtl::OUString aNm;
1834 : // if ( nSvxMSDffOLEConvFlags )
1835 : {
1836 3 : uno::Reference < embed::XStorage > xDestStorage( pOe->pShell->GetStorage() );
1837 : uno::Reference < embed::XEmbeddedObject > xObj =
1838 3 : CheckForConvertToSOObj( nSvxMSDffOLEConvFlags, *xObjStor, xDestStorage, rGraf, rVisArea );
1839 3 : if( xObj.is() )
1840 : {
1841 0 : pOe->pShell->getEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aNm );
1842 :
1843 0 : svt::EmbeddedObjectRef aObj( xObj, pOe->nAspect );
1844 :
1845 : // TODO/LATER: need MediaType for Graphic
1846 0 : aObj.SetGraphic( rGraf, ::rtl::OUString() );
1847 0 : pRet = new SdrOle2Obj( aObj, aNm, rBoundRect, sal_False );
1848 3 : }
1849 : }
1850 3 : if ( !pRet && ( pOe->nType == PPT_PST_ExControl ) )
1851 : {
1852 0 : uno::Reference< io::XInputStream > xIStrm = new utl::OSeekableInputStreamWrapper(*pDest );
1853 0 : uno::Reference< frame::XModel > xModel( pOe->pShell ? pOe->pShell->GetModel() : NULL );
1854 0 : PPTConvertOCXControls aPPTConvertOCXControls( this, xIStrm, xModel, eAktPageKind );
1855 0 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape;
1856 0 : if ( aPPTConvertOCXControls.ReadOCXStream( xObjStor, &xShape, sal_False ) )
1857 0 : pRet = GetSdrObjectFromXShape( xShape );
1858 :
1859 : }
1860 3 : if ( !pRet )
1861 : {
1862 3 : aNm = pOe->pShell->getEmbeddedObjectContainer().CreateUniqueObjectName();
1863 :
1864 : // object is not an own object
1865 3 : SotStorageRef xTarget = SotStorage::OpenOLEStorage( pOe->pShell->GetStorage(), aNm, STREAM_READWRITE );
1866 3 : if ( xObjStor.Is() && xTarget.Is() )
1867 : {
1868 3 : xObjStor->CopyTo( xTarget );
1869 3 : if( !xTarget->GetError() )
1870 3 : xTarget->Commit();
1871 : }
1872 3 : xTarget.Clear();
1873 :
1874 : uno::Reference < embed::XEmbeddedObject > xObj =
1875 3 : pOe->pShell->getEmbeddedObjectContainer().GetEmbeddedObject( aNm );
1876 3 : if ( xObj.is() )
1877 : {
1878 3 : if ( pOe->nAspect != embed::Aspects::MSOLE_ICON )
1879 : {
1880 : //TODO/LATER: keep on hacking?!
1881 : // we don't want to be modified
1882 : //xInplaceObj->EnableSetModified( sal_False );
1883 3 : if ( rVisArea.IsEmpty() )
1884 : {
1885 0 : MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( pOe->nAspect ) );
1886 : Size aSize( OutputDevice::LogicToLogic( aGraphic.GetPrefSize(),
1887 0 : aGraphic.GetPrefMapMode(), MapMode( aMapUnit ) ) );
1888 :
1889 0 : awt::Size aSz;
1890 0 : aSz.Width = aSize.Width();
1891 0 : aSz.Height = aSize.Height();
1892 0 : xObj->setVisualAreaSize( pOe->nAspect, aSz );
1893 : }
1894 : else
1895 : {
1896 3 : awt::Size aSize( rVisArea.GetSize().Width(), rVisArea.GetSize().Height() );
1897 3 : xObj->setVisualAreaSize( pOe->nAspect, aSize );
1898 : }
1899 : //xInplaceObj->EnableSetModified( sal_True );
1900 : }
1901 :
1902 3 : svt::EmbeddedObjectRef aObj( xObj, pOe->nAspect );
1903 :
1904 : // TODO/LATER: need MediaType for Graphic
1905 3 : aObj.SetGraphic( aGraphic, ::rtl::OUString() );
1906 :
1907 3 : pRet = new SdrOle2Obj( aObj, aNm, rBoundRect, sal_False );
1908 3 : }
1909 3 : }
1910 : }
1911 3 : }
1912 3 : }
1913 : }
1914 3 : delete pDest;
1915 3 : }
1916 : }
1917 : }
1918 3 : rStCtrl.Seek( nOldPos );
1919 :
1920 3 : return pRet;
1921 : }
1922 :
1923 4 : SvMemoryStream* SdrPowerPointImport::ImportExOleObjStg( sal_uInt32 nPersistPtr, sal_uInt32& nOleId ) const
1924 : {
1925 4 : SvMemoryStream* pRet = NULL;
1926 4 : if ( nPersistPtr && ( nPersistPtr < nPersistPtrAnz ) )
1927 : {
1928 0 : sal_uInt32 nOldPos, nOfs = pPersistPtr[ nPersistPtr ];
1929 0 : nOldPos = rStCtrl.Tell();
1930 0 : rStCtrl.Seek( nOfs );
1931 0 : DffRecordHeader aHd;
1932 0 : rStCtrl >> aHd;
1933 0 : if ( aHd.nRecType == DFF_PST_ExOleObjStg )
1934 : {
1935 0 : sal_uInt32 nLen = aHd.nRecLen - 4;
1936 0 : if ( (sal_Int32)nLen > 0 )
1937 : {
1938 0 : rStCtrl >> nOleId;
1939 0 : pRet = new SvMemoryStream;
1940 0 : ZCodec aZCodec( 0x8000, 0x8000 );
1941 0 : aZCodec.BeginCompression();
1942 0 : aZCodec.Decompress( rStCtrl, *pRet );
1943 0 : if ( !aZCodec.EndCompression() )
1944 0 : delete pRet, pRet = NULL;
1945 : }
1946 : }
1947 0 : rStCtrl.Seek( nOldPos );
1948 : }
1949 4 : return pRet;
1950 : }
1951 :
1952 5 : void SdrPowerPointImport::SeekOle( SfxObjectShell* pShell, sal_uInt32 nFilterOptions )
1953 : {
1954 5 : if ( pShell )
1955 : {
1956 : DffRecordHeader* pHd;
1957 :
1958 5 : sal_uInt32 nOldPos = rStCtrl.Tell();
1959 5 : if ( nFilterOptions & 1 )
1960 : {
1961 5 : pHd = aDocRecManager.GetRecordHeader( PPT_PST_List, SEEK_FROM_BEGINNING );
1962 5 : if ( pHd )
1963 : {
1964 : // we try to locate the basic atom
1965 5 : pHd->SeekToContent( rStCtrl );
1966 5 : if ( SeekToRec( rStCtrl, PPT_PST_VBAInfo, pHd->GetRecEndFilePos(), pHd ) )
1967 : {
1968 4 : if ( SeekToRec( rStCtrl, PPT_PST_VBAInfoAtom, pHd->GetRecEndFilePos(), pHd ) )
1969 : {
1970 : sal_uInt32 nPersistPtr, nIDoNotKnow1, nIDoNotKnow2;
1971 4 : rStCtrl >> nPersistPtr
1972 4 : >> nIDoNotKnow1
1973 4 : >> nIDoNotKnow2;
1974 :
1975 : sal_uInt32 nOleId;
1976 4 : SvMemoryStream* pBas = ImportExOleObjStg( nPersistPtr, nOleId );
1977 4 : if ( pBas )
1978 : {
1979 0 : SotStorageRef xSource( new SotStorage( pBas, sal_True ) );
1980 0 : SotStorageRef xDest( new SotStorage( new SvMemoryStream(), sal_True ) );
1981 0 : if ( xSource.Is() && xDest.Is() )
1982 : {
1983 : // is this a visual basic storage ?
1984 : SotStorageRef xSubStorage = xSource->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "VBA" ) ),
1985 0 : STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYALL );
1986 0 : if( xSubStorage.Is() && ( SVSTREAM_OK == xSubStorage->GetError() ) )
1987 : {
1988 0 : SotStorageRef xMacros = xDest->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "MACROS" ) ) );
1989 0 : if ( xMacros.Is() )
1990 : {
1991 0 : SvStorageInfoList aList;
1992 0 : xSource->FillInfoList( &aList );
1993 : sal_uInt32 i;
1994 :
1995 0 : sal_Bool bCopied = sal_True;
1996 0 : for ( i = 0; i < aList.size(); i++ ) // copy all entries
1997 : {
1998 0 : const SvStorageInfo& rInfo = aList[ i ];
1999 0 : if ( !xSource->CopyTo( rInfo.GetName(), xMacros, rInfo.GetName() ) )
2000 0 : bCopied = sal_False;
2001 : }
2002 0 : if ( i && bCopied )
2003 : {
2004 0 : SvxImportMSVBasic aMSVBas( *pShell, *xDest );
2005 :
2006 0 : uno::Reference < embed::XStorage > xDoc( pShell->GetStorage() );
2007 0 : if ( xDoc.is() )
2008 : {
2009 0 : SotStorageRef xVBA = SotStorage::OpenOLEStorage( xDoc, String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Macros" ) ) );
2010 0 : if ( xVBA.Is() && ( xVBA->GetError() == SVSTREAM_OK ) )
2011 : {
2012 0 : SotStorageRef xSubVBA = xVBA->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Overhead" ) ) );
2013 0 : if ( xSubVBA.Is() && ( xSubVBA->GetError() == SVSTREAM_OK ) )
2014 : {
2015 0 : SotStorageStreamRef xOriginal = xSubVBA->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Overhead2" ) ) );
2016 0 : if ( xOriginal.Is() && ( xOriginal->GetError() == SVSTREAM_OK ) )
2017 : {
2018 0 : if ( nPersistPtr && ( nPersistPtr < nPersistPtrAnz ) )
2019 : {
2020 0 : rStCtrl.Seek( pPersistPtr[ nPersistPtr ] );
2021 0 : rStCtrl >> *pHd;
2022 :
2023 0 : *xOriginal << nIDoNotKnow1
2024 0 : << nIDoNotKnow2;
2025 :
2026 : sal_uInt32 nToCopy, nBufSize;
2027 0 : nToCopy = pHd->nRecLen;
2028 0 : sal_uInt8* pBuf = new sal_uInt8[ 0x40000 ]; // 256KB Buffer
2029 0 : if ( pBuf )
2030 : {
2031 0 : while ( nToCopy )
2032 : {
2033 0 : nBufSize = ( nToCopy >= 0x40000 ) ? 0x40000 : nToCopy;
2034 0 : rStCtrl.Read( pBuf, nBufSize );
2035 0 : xOriginal->Write( pBuf, nBufSize );
2036 0 : nToCopy -= nBufSize;
2037 : }
2038 0 : delete[] pBuf;
2039 : }
2040 : }
2041 0 : }
2042 0 : }
2043 0 : }
2044 0 : }
2045 0 : }
2046 0 : }
2047 0 : }
2048 0 : }
2049 : }
2050 : }
2051 : }
2052 : }
2053 : }
2054 5 : pHd = aDocRecManager.GetRecordHeader( PPT_PST_ExObjList, SEEK_FROM_BEGINNING );
2055 5 : if ( pHd )
2056 : {
2057 3 : DffRecordManager* pExObjListManager = NULL;
2058 3 : DffRecordHeader* pExEmbed = NULL;
2059 :
2060 3 : pHd->SeekToBegOfRecord( rStCtrl );
2061 3 : pExObjListManager = new DffRecordManager( rStCtrl );
2062 3 : sal_uInt16 i, nRecType(PPT_PST_ExEmbed);
2063 :
2064 9 : for ( i = 0; i < 2; i++ )
2065 : {
2066 6 : switch ( i )
2067 : {
2068 3 : case 0 : nRecType = PPT_PST_ExEmbed; break;
2069 3 : case 1 : nRecType = PPT_PST_ExControl; break;
2070 : }
2071 9 : for ( pExEmbed = pExObjListManager->GetRecordHeader( nRecType, SEEK_FROM_BEGINNING );
2072 3 : pExEmbed; pExEmbed = pExObjListManager->GetRecordHeader( nRecType, SEEK_FROM_CURRENT ) )
2073 : {
2074 3 : pExEmbed->SeekToContent( rStCtrl );
2075 :
2076 3 : DffRecordHeader aExOleAtHd;
2077 3 : if ( SeekToRec( rStCtrl, PPT_PST_ExOleObjAtom, pExEmbed->GetRecEndFilePos(), &aExOleAtHd ) )
2078 : {
2079 : PptExOleObjAtom aAt;
2080 3 : rStCtrl >> aAt;
2081 :
2082 3 : if ( aAt.nPersistPtr && ( aAt.nPersistPtr < nPersistPtrAnz ) )
2083 : {
2084 : sal_uInt32 nId;
2085 3 : rStCtrl.Seek( pPersistPtr[ aAt.nPersistPtr ] );
2086 3 : DffRecordHeader aHd;
2087 3 : rStCtrl >> aHd;
2088 3 : if ( aHd.nRecType == DFF_PST_ExOleObjStg )
2089 : {
2090 3 : rStCtrl >> nId;
2091 : aOleObjectList.push_back(
2092 3 : new PPTOleEntry( aAt.nId, aHd.nFilePos, pShell, nRecType, aAt.nAspect ) );
2093 : }
2094 : }
2095 : }
2096 : }
2097 : }
2098 3 : delete pExObjListManager;
2099 : }
2100 5 : rStCtrl.Seek( nOldPos );
2101 : }
2102 5 : }
2103 :
2104 5 : sal_Bool SdrPowerPointImport::ReadFontCollection()
2105 : {
2106 5 : sal_Bool bRet = sal_False;
2107 5 : DffRecordHeader* pEnvHd = aDocRecManager.GetRecordHeader( PPT_PST_Environment );
2108 5 : if ( pEnvHd )
2109 : {
2110 5 : sal_uLong nFPosMerk = rStCtrl.Tell(); // remember FilePos for restoring it later
2111 5 : pEnvHd->SeekToContent( rStCtrl );
2112 5 : DffRecordHeader aListHd;
2113 5 : if ( SeekToRec( rStCtrl, PPT_PST_FontCollection, pEnvHd->GetRecEndFilePos(), &aListHd ) )
2114 : {
2115 5 : sal_uInt16 nCount2 = 0;
2116 5 : VirtualDevice* pVDev = NULL;
2117 31 : while ( SeekToRec( rStCtrl, PPT_PST_FontEntityAtom, aListHd.GetRecEndFilePos() ) )
2118 : {
2119 21 : bRet = sal_True;
2120 21 : if ( !pFonts )
2121 5 : pFonts = new PptFontCollection;
2122 21 : PptFontEntityAtom* pFont = new PptFontEntityAtom;
2123 21 : rStCtrl >> *pFont;
2124 :
2125 21 : Font aFont;
2126 21 : aFont.SetCharSet( pFont->eCharSet );
2127 21 : aFont.SetName( pFont->aName );
2128 21 : aFont.SetFamily( pFont->eFamily );
2129 21 : aFont.SetPitch( pFont->ePitch );
2130 21 : aFont.SetHeight( 100 );
2131 :
2132 : // following block is necessary, because our old PowerPoint export did not set the
2133 : // correct charset
2134 181 : if ( pFont->aName.EqualsIgnoreCaseAscii( "Wingdings" ) ||
2135 20 : pFont->aName.EqualsIgnoreCaseAscii( "Wingdings 2" ) ||
2136 20 : pFont->aName.EqualsIgnoreCaseAscii( "Wingdings 3" ) ||
2137 20 : pFont->aName.EqualsIgnoreCaseAscii( "Monotype Sorts" ) ||
2138 20 : pFont->aName.EqualsIgnoreCaseAscii( "Monotype Sorts 2" ) ||
2139 20 : pFont->aName.EqualsIgnoreCaseAscii( "Webdings" ) ||
2140 20 : pFont->aName.EqualsIgnoreCaseAscii( "StarBats" ) ||
2141 20 : pFont->aName.EqualsIgnoreCaseAscii( "StarMath" ) ||
2142 20 : pFont->aName.EqualsIgnoreCaseAscii( "ZapfDingbats" ) )
2143 : {
2144 1 : pFont->eCharSet = RTL_TEXTENCODING_SYMBOL;
2145 : };
2146 21 : pFonts->insert( pFonts->begin() + nCount2++, pFont );
2147 21 : }
2148 5 : delete pVDev;
2149 : }
2150 5 : rStCtrl.Seek( nFPosMerk ); // restore FilePos
2151 : }
2152 5 : return bRet;
2153 : }
2154 :
2155 1393 : PptSlidePersistList* SdrPowerPointImport::GetPageList(PptPageKind ePageKind) const
2156 : {
2157 1393 : if ( ePageKind == PPT_MASTERPAGE )
2158 363 : return pMasterPages;
2159 1030 : if ( ePageKind == PPT_SLIDEPAGE )
2160 920 : return pSlidePages;
2161 110 : if ( ePageKind == PPT_NOTEPAGE )
2162 110 : return pNotePages;
2163 0 : return NULL;
2164 : }
2165 :
2166 8 : SdrOutliner* SdrPowerPointImport::GetDrawOutliner( SdrTextObj* pSdrText ) const
2167 : {
2168 8 : if ( !pSdrText )
2169 0 : return NULL;
2170 : else
2171 8 : return &pSdrText->ImpGetDrawOutliner();
2172 : }
2173 :
2174 :
2175 604 : SdrObject* SdrPowerPointImport::ReadObjText( PPTTextObj* pTextObj, SdrObject* pSdrObj, SdPage* pPage ) const
2176 : {
2177 604 : SdrTextObj* pText = PTR_CAST( SdrTextObj, pSdrObj );
2178 604 : if ( pText )
2179 : {
2180 604 : if ( !ApplyTextObj( pTextObj, pText, pPage, NULL, NULL ) )
2181 10 : pSdrObj = NULL;
2182 : }
2183 604 : return pSdrObj;
2184 : }
2185 :
2186 :
2187 604 : SdrObject* SdrPowerPointImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* pSdrText, SdPage* /*pPage*/,
2188 : SfxStyleSheet* pSheet, SfxStyleSheet** ppStyleSheetAry ) const
2189 : {
2190 604 : SdrTextObj* pText = pSdrText;
2191 604 : if ( pTextObj->Count() )
2192 : {
2193 587 : sal_uInt32 nDestinationInstance = pTextObj->GetDestinationInstance() ;
2194 587 : SdrOutliner& rOutliner = pText->ImpGetDrawOutliner();
2195 587 : if ( ( pText->GetObjInventor() == SdrInventor ) && ( pText->GetObjIdentifier() == OBJ_TITLETEXT ) ) // Outliner-Style for Title-Text object?!? (->of DL)
2196 33 : rOutliner.Init( OUTLINERMODE_TITLEOBJECT ); // Outliner reset
2197 :
2198 587 : sal_Bool bOldUpdateMode = rOutliner.GetUpdateMode();
2199 587 : rOutliner.SetUpdateMode( sal_False );
2200 587 : if ( pSheet )
2201 : {
2202 587 : if ( rOutliner.GetStyleSheet( 0 ) != pSheet )
2203 587 : rOutliner.SetStyleSheet( 0, pSheet );
2204 : }
2205 587 : rOutliner.SetVertical( pTextObj->GetVertical() );
2206 587 : sal_Int16 nLastStartNumbering = -1;
2207 587 : const PPTParagraphObj* pPreviousParagraph = NULL;
2208 1361 : for ( PPTParagraphObj* pPara = pTextObj->First(); pPara; pPara = pTextObj->Next() )
2209 : {
2210 774 : sal_uInt32 nTextSize = pPara->GetTextSize();
2211 774 : if ( ! ( nTextSize & 0xffff0000 ) )
2212 : {
2213 : PPTPortionObj* pPortion;
2214 774 : sal_Unicode* pParaText = new sal_Unicode[ nTextSize ];
2215 774 : sal_Int32 nCurrentIndex = 0;
2216 1961 : for ( pPortion = pPara->First(); pPortion; pPortion = pPara->Next() )
2217 : {
2218 1187 : if ( pPortion->mpFieldItem )
2219 34 : pParaText[ nCurrentIndex++ ] = ' ';
2220 : else
2221 : {
2222 1153 : sal_Int32 nCharacters = pPortion->Count();
2223 1153 : const sal_Unicode* pSource = pPortion->maString.GetBuffer();
2224 1153 : sal_Unicode* pDest = pParaText + nCurrentIndex;
2225 :
2226 : sal_uInt32 nFont;
2227 1153 : pPortion->GetAttrib( PPT_CharAttr_Font, nFont, pTextObj->GetInstance() );
2228 1153 : PptFontEntityAtom* pFontEnityAtom = GetFontEnityAtom( nFont );
2229 1153 : if ( pFontEnityAtom && ( pFontEnityAtom->eCharSet == RTL_TEXTENCODING_SYMBOL ) )
2230 : {
2231 : sal_Unicode nUnicode;
2232 70 : for (sal_Int32 i = 0; i < nCharacters; i++ )
2233 : {
2234 35 : nUnicode = pSource[ i ];
2235 35 : if ( ! ( nUnicode & 0xff00 ) )
2236 0 : nUnicode |= 0xf000;
2237 35 : pDest[ i ] = nUnicode;
2238 35 : }
2239 : }
2240 : else
2241 1118 : memcpy( pDest, pSource, nCharacters << 1 );
2242 1153 : nCurrentIndex += nCharacters;
2243 : }
2244 : }
2245 774 : sal_uInt16 nParaIndex = (sal_uInt16)pTextObj->GetCurrentIndex();
2246 774 : SfxStyleSheet* pS = ( ppStyleSheetAry ) ? ppStyleSheetAry[ pPara->pParaSet->mnDepth ] : pSheet;
2247 :
2248 774 : ESelection aSelection( nParaIndex, 0, nParaIndex, 0 );
2249 774 : rOutliner.Insert( String(), nParaIndex, pPara->pParaSet->mnDepth );
2250 774 : rOutliner.QuickInsertText( rtl::OUString(pParaText, nCurrentIndex), aSelection );
2251 774 : rOutliner.SetParaAttribs( nParaIndex, rOutliner.GetEmptyItemSet() );
2252 774 : if ( pS )
2253 774 : rOutliner.SetStyleSheet( nParaIndex, pS );
2254 :
2255 1961 : for ( pPortion = pPara->First(); pPortion; pPortion = pPara->Next() )
2256 : {
2257 1187 : SfxItemSet aPortionAttribs( rOutliner.GetEmptyItemSet() );
2258 1187 : SvxFieldItem* pFieldItem = pPortion->GetTextField();
2259 1187 : if ( pFieldItem )
2260 : {
2261 34 : rOutliner.QuickInsertField( *pFieldItem, ESelection( nParaIndex, aSelection.nEndPos, nParaIndex, aSelection.nEndPos + 1 ) );
2262 34 : aSelection.nEndPos++;
2263 34 : delete pFieldItem;
2264 : }
2265 : else
2266 : {
2267 1153 : const sal_Unicode *pF, *pPtr = pPortion->maString.GetBuffer();
2268 1153 : const sal_Unicode *pMax = pPtr + pPortion->maString.Len();
2269 : sal_Int32 nLen;
2270 13415 : for ( pF = pPtr; pPtr < pMax; pPtr++ )
2271 : {
2272 12262 : if ( *pPtr == 0xb )
2273 : {
2274 1 : nLen = pPtr - pF;
2275 1 : if ( nLen )
2276 : aSelection.nEndPos =
2277 : sal::static_int_cast< sal_uInt16 >(
2278 0 : aSelection.nEndPos + nLen );
2279 1 : pF = pPtr + 1;
2280 1 : rOutliner.QuickInsertLineBreak( ESelection( nParaIndex, aSelection.nEndPos, nParaIndex, aSelection.nEndPos + 1 ) );
2281 1 : aSelection.nEndPos++;
2282 : }
2283 : }
2284 1153 : nLen = pPtr - pF;
2285 1153 : if ( nLen )
2286 : aSelection.nEndPos = sal::static_int_cast< sal_uInt16 >(
2287 1086 : aSelection.nEndPos + nLen );
2288 : }
2289 1187 : pPortion->ApplyTo( aPortionAttribs, (SdrPowerPointImport&)*this, nDestinationInstance, pTextObj );
2290 1187 : rOutliner.QuickSetAttribs( aPortionAttribs, aSelection );
2291 1187 : aSelection.nStartPos = aSelection.nEndPos;
2292 1187 : }
2293 774 : boost::optional< sal_Int16 > oStartNumbering;
2294 774 : SfxItemSet aParagraphAttribs( rOutliner.GetEmptyItemSet() );
2295 774 : pPara->ApplyTo( aParagraphAttribs, oStartNumbering, (SdrPowerPointImport&)*this, nDestinationInstance, pPreviousParagraph );
2296 :
2297 774 : sal_uInt32 nIsBullet2 = 0; //, nInstance = nDestinationInstance != 0xffffffff ? nDestinationInstance : pTextObj->GetInstance();
2298 774 : pPara->GetAttrib( PPT_ParaAttr_BulletOn, nIsBullet2, nDestinationInstance );
2299 774 : if ( !nIsBullet2 )
2300 604 : aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, sal_False ) );
2301 :
2302 774 : if ( oStartNumbering )
2303 : {
2304 0 : if ( *oStartNumbering != nLastStartNumbering )
2305 0 : rOutliner.SetNumberingStartValue( nParaIndex, *oStartNumbering );
2306 : else
2307 0 : rOutliner.SetNumberingStartValue( nParaIndex, -1 );
2308 0 : nLastStartNumbering = *oStartNumbering;
2309 : }
2310 : else
2311 : {
2312 774 : nLastStartNumbering = -1;
2313 774 : rOutliner.SetNumberingStartValue( nParaIndex, nLastStartNumbering );
2314 : }
2315 :
2316 774 : pPreviousParagraph = pPara;
2317 774 : if ( !aSelection.nStartPos ) // in PPT empty paragraphs never gets a bullet
2318 : {
2319 66 : aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, sal_False ) );
2320 : }
2321 774 : aSelection.nStartPos = 0;
2322 774 : rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection );
2323 774 : delete[] pParaText;
2324 : }
2325 : }
2326 587 : OutlinerParaObject* pNewText = rOutliner.CreateParaObject();
2327 587 : rOutliner.Clear();
2328 587 : rOutliner.SetUpdateMode( bOldUpdateMode );
2329 587 : pText->SetOutlinerParaObject( pNewText );
2330 : }
2331 604 : return pText;
2332 : }
2333 :
2334 8 : sal_Bool SdrPowerPointImport::SeekToDocument( DffRecordHeader* pRecHd ) const
2335 : {
2336 : sal_Bool bRet;
2337 8 : sal_uLong nFPosMerk = rStCtrl.Tell(); // remember FilePos for restoring it should the situation arise
2338 8 : rStCtrl.Seek( nDocStreamPos );
2339 8 : DffRecordHeader aDocHd;
2340 8 : rStCtrl >> aDocHd;
2341 8 : bRet = aDocHd.nRecType == PPT_PST_Document;
2342 8 : if ( bRet )
2343 : {
2344 8 : if ( pRecHd )
2345 8 : *pRecHd = aDocHd;
2346 : else
2347 0 : aDocHd.SeekToBegOfRecord( rStCtrl );
2348 : }
2349 8 : if ( !bRet )
2350 0 : rStCtrl.Seek( nFPosMerk ); // restore FilePos
2351 8 : return bRet;
2352 : }
2353 :
2354 255 : sal_Bool SdrPowerPointImport::SeekToContentOfProgTag( sal_Int32 nVersion, SvStream& rSt,
2355 : const DffRecordHeader& rSourceHd, DffRecordHeader& rContentHd )
2356 : {
2357 255 : sal_Bool bRetValue = sal_False;
2358 255 : sal_uInt32 nOldPos = rSt.Tell();
2359 :
2360 255 : DffRecordHeader aProgTagsHd, aProgTagBinaryDataHd;
2361 255 : rSourceHd.SeekToContent( rSt );
2362 255 : sal_Bool bFound = rSourceHd.nRecType == PPT_PST_ProgTags;
2363 255 : if ( !bFound )
2364 207 : bFound = SeekToRec( rSt, PPT_PST_ProgTags, rSourceHd.GetRecEndFilePos(), &aProgTagsHd );
2365 255 : if ( bFound )
2366 : {
2367 180 : while( SeekToRec( rSt, PPT_PST_ProgBinaryTag, aProgTagsHd.GetRecEndFilePos(), &aProgTagBinaryDataHd ) )
2368 : {
2369 91 : rSt >> rContentHd;
2370 91 : if ( rContentHd.nRecType == PPT_PST_CString )
2371 : {
2372 91 : sal_uInt16 n = 6;
2373 91 : sal_uInt32 i = rContentHd.nRecLen >> 1;
2374 91 : if ( i > n )
2375 : {
2376 91 : String aPre = read_uInt16s_ToOUString(rSt, n);
2377 91 : n = (sal_uInt16)( i - 6 );
2378 91 : String aSuf = read_uInt16s_ToOUString(rSt, n);
2379 91 : sal_Int32 nV = aSuf.ToInt32();
2380 91 : if ( ( nV == nVersion ) && ( aPre == String( RTL_CONSTASCII_USTRINGPARAM( "___PPT" ) ) ) )
2381 : {
2382 85 : rContentHd.SeekToEndOfRecord( rSt );
2383 85 : rSt >> rContentHd;
2384 85 : if ( rContentHd.nRecType == PPT_PST_BinaryTagData )
2385 : {
2386 85 : bRetValue = sal_True;
2387 : break;
2388 : }
2389 91 : }
2390 : }
2391 : }
2392 6 : aProgTagBinaryDataHd.SeekToEndOfRecord( rSt );
2393 : }
2394 : }
2395 255 : if ( !bRetValue )
2396 170 : rSt.Seek( nOldPos );
2397 255 : return bRetValue;
2398 : }
2399 :
2400 56 : sal_uInt32 SdrPowerPointImport::GetAktPageId()
2401 : {
2402 56 : PptSlidePersistList* pList = GetPageList( eAktPageKind );
2403 56 : if ( pList && nAktPageNum < pList->size() )
2404 56 : return (*pList)[ (sal_uInt16)nAktPageNum ]->aPersistAtom.nSlideId;
2405 0 : return 0;
2406 : }
2407 :
2408 139 : sal_Bool SdrPowerPointImport::SeekToAktPage( DffRecordHeader* pRecHd ) const
2409 : {
2410 139 : sal_Bool bRet = sal_False;
2411 139 : PptSlidePersistList* pList = GetPageList( eAktPageKind );
2412 139 : if ( pList && ( nAktPageNum < pList->size() ) )
2413 : {
2414 139 : sal_uLong nPersist = (*pList)[ (sal_uInt16)nAktPageNum ]->aPersistAtom.nPsrReference;
2415 139 : if ( nPersist > 0 && nPersist < nPersistPtrAnz )
2416 : {
2417 139 : sal_uLong nFPos = 0;
2418 139 : nFPos = pPersistPtr[ nPersist ];
2419 139 : if ( nFPos < nStreamLen )
2420 : {
2421 139 : rStCtrl.Seek( nFPos );
2422 139 : if ( pRecHd )
2423 139 : rStCtrl >> *pRecHd;
2424 139 : bRet = sal_True;
2425 : }
2426 : }
2427 : }
2428 139 : return bRet;
2429 : }
2430 :
2431 15 : sal_uInt16 SdrPowerPointImport::GetPageCount( PptPageKind ePageKind ) const
2432 : {
2433 15 : PptSlidePersistList* pList = GetPageList( ePageKind );
2434 15 : if ( pList )
2435 15 : return pList->size();
2436 0 : return 0;
2437 : }
2438 :
2439 114 : void SdrPowerPointImport::SetPageNum( sal_uInt16 nPageNum, PptPageKind eKind )
2440 : {
2441 114 : eAktPageKind = eKind;
2442 114 : nAktPageNum = nPageNum;
2443 :
2444 114 : pPPTStyleSheet = NULL;
2445 :
2446 114 : sal_Bool bHasMasterPage = sal_True;
2447 114 : sal_uInt16 nMasterIndex = 0;
2448 :
2449 114 : if ( eKind == PPT_MASTERPAGE )
2450 30 : nMasterIndex = nPageNum;
2451 : else
2452 : {
2453 84 : if ( HasMasterPage( nPageNum, eKind ) )
2454 84 : nMasterIndex = GetMasterPageIndex( nPageNum, eKind );
2455 : else
2456 0 : bHasMasterPage = sal_False;
2457 : }
2458 114 : if ( bHasMasterPage )
2459 : {
2460 114 : PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE );
2461 114 : if ( pPageList && nMasterIndex < pPageList->size() )
2462 : {
2463 114 : PptSlidePersistEntry* pMasterPersist = (*pPageList)[ nMasterIndex ];
2464 114 : if ( ( pMasterPersist->pStyleSheet == NULL ) && pMasterPersist->aSlideAtom.nMasterId )
2465 : {
2466 0 : nMasterIndex = pMasterPages->FindPage( pMasterPersist->aSlideAtom.nMasterId );
2467 0 : if ( nMasterIndex != PPTSLIDEPERSIST_ENTRY_NOTFOUND )
2468 0 : pMasterPersist = (*pPageList)[ nMasterIndex ];
2469 : }
2470 114 : pPPTStyleSheet = pMasterPersist->pStyleSheet;
2471 : }
2472 : }
2473 114 : if ( !pPPTStyleSheet )
2474 39 : pPPTStyleSheet = pDefaultSheet;
2475 114 : }
2476 :
2477 84 : Size SdrPowerPointImport::GetPageSize() const
2478 : {
2479 84 : Size aRet( IsNoteOrHandout( nAktPageNum, eAktPageKind ) ? aDocAtom.GetNotesPageSize() : aDocAtom.GetSlidesPageSize() );
2480 84 : Scale( aRet );
2481 : // PPT arbeitet nur mit Einheiten zu 576DPI. Um Ungenauigkeiten zu
2482 : // vermeiden runde ich die letzte Nachkommastelle metrisch weg.
2483 84 : if ( nMapMul > 2 * nMapDiv )
2484 : {
2485 84 : MapUnit eMap = pSdrModel->GetScaleUnit();
2486 84 : bool bInch = IsInch( eMap );
2487 84 : long nInchMul = 1, nInchDiv = 1;
2488 84 : if ( bInch )
2489 : { // temporarily convert size (for rounding it) from inch to metric units
2490 0 : Fraction aFact(GetMapFactor(eMap,MAP_100TH_MM).X());
2491 0 : nInchMul = aFact.GetNumerator();
2492 0 : nInchDiv = aFact.GetDenominator();
2493 0 : aRet.Width() = BigMulDiv( aRet.Width(), nInchMul, nInchDiv );
2494 0 : aRet.Height() = BigMulDiv( aRet.Height(), nInchMul, nInchDiv );
2495 : }
2496 84 : aRet.Width() += 5; aRet.Width() /= 10; aRet.Width()*=10;
2497 84 : aRet.Height() += 5; aRet.Height() /= 10; aRet.Height()*=10;
2498 84 : if ( bInch )
2499 : {
2500 0 : aRet.Width() = BigMulDiv( aRet.Width(), nInchDiv, nInchMul );
2501 0 : aRet.Height() = BigMulDiv( aRet.Height(), nInchDiv, nInchMul );
2502 : }
2503 : }
2504 84 : return aRet;
2505 : }
2506 :
2507 9470 : bool SdrPowerPointImport::GetColorFromPalette( sal_uInt16 nNum, Color& rColor ) const
2508 : {
2509 9470 : if ( nPageColorsNum != nAktPageNum || ePageColorsKind != eAktPageKind )
2510 : {
2511 68 : sal_uInt16 nSlideFlags = 0;
2512 68 : PptSlidePersistList* pPageList = GetPageList( eAktPageKind );
2513 68 : if ( pPageList && ( nAktPageNum < pPageList->size() ) )
2514 : {
2515 68 : PptSlidePersistEntry* pE = (*pPageList)[ nAktPageNum ];
2516 68 : if ( pE )
2517 68 : nSlideFlags = pE->aSlideAtom.nFlags;
2518 68 : if ( ! ( nSlideFlags & 2 ) )
2519 36 : ((SdrPowerPointImport*)this)->aPageColors = pE->aColorScheme;
2520 : }
2521 68 : if ( nSlideFlags & 2 ) // follow master colorscheme?
2522 : {
2523 32 : PptSlidePersistList* pPageList2 = GetPageList( PPT_MASTERPAGE );
2524 32 : if ( pPageList2 )
2525 : {
2526 32 : PptSlidePersistEntry* pMasterPersist = NULL;
2527 32 : if ( eAktPageKind == PPT_MASTERPAGE )
2528 0 : pMasterPersist = (*pPageList2)[ nAktPageNum ];
2529 : else
2530 : {
2531 32 : if ( HasMasterPage( nAktPageNum, eAktPageKind ) )
2532 : {
2533 32 : sal_uInt16 nMasterNum = GetMasterPageIndex( nAktPageNum, eAktPageKind );
2534 32 : if ( nMasterNum < pPageList2->size() )
2535 32 : pMasterPersist = (*pPageList2)[ nMasterNum ];
2536 : }
2537 : }
2538 32 : if ( pMasterPersist )
2539 : {
2540 64 : while( ( pMasterPersist && pMasterPersist->aSlideAtom.nFlags & 2 ) // it is possible that a masterpage
2541 : && pMasterPersist->aSlideAtom.nMasterId ) // itself is following a master colorscheme
2542 : {
2543 0 : sal_uInt16 nNextMaster = pMasterPages->FindPage( pMasterPersist->aSlideAtom.nMasterId );
2544 0 : if ( nNextMaster == PPTSLIDEPERSIST_ENTRY_NOTFOUND )
2545 0 : break;
2546 : else
2547 0 : pMasterPersist = (*pPageList2)[ nNextMaster ];
2548 : }
2549 32 : ((SdrPowerPointImport*)this)->aPageColors = pMasterPersist->aColorScheme;
2550 : }
2551 : }
2552 : }
2553 : // resgister current color scheme
2554 68 : ((SdrPowerPointImport*)this)->nPageColorsNum = nAktPageNum;
2555 68 : ((SdrPowerPointImport*)this)->ePageColorsKind = eAktPageKind;
2556 : }
2557 9470 : rColor = aPageColors.GetColor( nNum );
2558 9470 : return sal_True;
2559 : }
2560 :
2561 176 : sal_Bool SdrPowerPointImport::SeekToShape( SvStream& rSt, void* pClientData, sal_uInt32 nId ) const
2562 : {
2563 176 : sal_Bool bRet = SvxMSDffManager::SeekToShape( rSt, pClientData, nId );
2564 176 : if ( !bRet )
2565 : {
2566 0 : ProcessData& rData = *( (ProcessData*)pClientData );
2567 0 : PptSlidePersistEntry& rPersistEntry = rData.rPersistEntry;
2568 0 : if ( rPersistEntry.ePageKind == PPT_SLIDEPAGE )
2569 : {
2570 0 : if ( HasMasterPage( nAktPageNum, eAktPageKind ) )
2571 : {
2572 0 : sal_uInt16 nMasterNum = GetMasterPageIndex( nAktPageNum, eAktPageKind );
2573 0 : PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE );
2574 0 : if ( pPageList && ( nMasterNum < pPageList->size() ) )
2575 : {
2576 0 : PptSlidePersistEntry* pPersist = (*pPageList)[ nMasterNum ]; // get the masterpage's persistentry
2577 0 : if ( pPersist && pPersist->pPresentationObjects )
2578 : {
2579 0 : sal_uInt32 nCurrent(0L);
2580 0 : DffRecordList* pCList = maShapeRecords.pCList; // we got a backup of the current position
2581 0 : if ( pCList )
2582 0 : nCurrent = pCList->nCurrent;
2583 0 : if ( ((SdrEscherImport*)this )->maShapeRecords.SeekToContent( rSt, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) )
2584 : {
2585 0 : sal_uInt32 nStreamPos = rSt.Tell();
2586 0 : PPTTextObj aTextObj( rSt, (SdrPowerPointImport&)*this, rPersistEntry, NULL );
2587 0 : if ( aTextObj.Count() || aTextObj.GetOEPlaceHolderAtom() )
2588 : {
2589 0 : sal_uInt32 nShapePos = 0;
2590 0 : switch ( aTextObj.GetInstance() )
2591 : {
2592 : case TSS_TYPE_TITLE :
2593 0 : nShapePos = pPersist->pPresentationObjects[ TSS_TYPE_PAGETITLE ];
2594 0 : break;
2595 : case TSS_TYPE_PAGETITLE :
2596 0 : nShapePos = pPersist->pPresentationObjects[ TSS_TYPE_PAGETITLE ];
2597 0 : break;
2598 : case TSS_TYPE_SUBTITLE :
2599 : case TSS_TYPE_HALFBODY :
2600 : case TSS_TYPE_QUARTERBODY :
2601 : case TSS_TYPE_BODY :
2602 0 : nShapePos = pPersist->pPresentationObjects[ TSS_TYPE_BODY ];
2603 0 : break;
2604 : }
2605 0 : if ( nShapePos )
2606 : {
2607 0 : rSt.Seek( nShapePos );
2608 0 : bRet = sal_True;
2609 : }
2610 : }
2611 0 : if ( !bRet )
2612 0 : rSt.Seek( nStreamPos );
2613 : }
2614 0 : if ( pCList ) // restoring
2615 0 : pCList->nCurrent = nCurrent;
2616 0 : ((SdrEscherImport*)this )->maShapeRecords.pCList = pCList;
2617 : }
2618 : }
2619 : }
2620 : }
2621 : }
2622 176 : return bRet;
2623 : }
2624 :
2625 84 : SdrPage* SdrPowerPointImport::MakeBlancPage( sal_Bool bMaster ) const
2626 : {
2627 84 : SdrPage* pRet = pSdrModel->AllocPage( bMaster );
2628 84 : pRet->SetSize( GetPageSize() );
2629 :
2630 84 : return pRet;
2631 : }
2632 :
2633 0 : void ImportComment10( SvxMSDffManager& rMan, SvStream& rStCtrl, SdrPage* pPage, DffRecordHeader& rComment10Hd )
2634 : {
2635 0 : rtl::OUString sAuthor;
2636 0 : rtl::OUString sText;
2637 0 : rtl::OUString sInitials;
2638 :
2639 0 : sal_Int32 nIndex = 0;
2640 0 : util::DateTime aDateTime;
2641 0 : sal_Int32 nPosX = 0;
2642 0 : sal_Int32 nPosY = 0;
2643 :
2644 0 : while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < rComment10Hd.GetRecEndFilePos() ) )
2645 : {
2646 0 : DffRecordHeader aCommentHd;
2647 0 : rStCtrl >> aCommentHd;
2648 0 : switch( aCommentHd.nRecType )
2649 : {
2650 : case PPT_PST_CString :
2651 : {
2652 : rtl::OUString aString = SvxMSDffManager::MSDFFReadZString( rStCtrl,
2653 0 : aCommentHd.nRecLen, sal_True );
2654 0 : switch ( aCommentHd.nRecInstance )
2655 : {
2656 0 : case 0 : sAuthor = aString; break;
2657 0 : case 1 : sText = aString; break;
2658 0 : case 2 : sInitials = aString; break;
2659 0 : }
2660 : }
2661 0 : break;
2662 :
2663 : case PPT_PST_CommentAtom10 :
2664 : {
2665 0 : rStCtrl >> nIndex
2666 0 : >> aDateTime.Year
2667 0 : >> aDateTime.Month
2668 0 : >> aDateTime.Day // DayOfWeek
2669 0 : >> aDateTime.Day
2670 0 : >> aDateTime.Hours
2671 0 : >> aDateTime.Minutes
2672 0 : >> aDateTime.Seconds
2673 0 : >> aDateTime.HundredthSeconds
2674 0 : >> nPosX
2675 0 : >> nPosY;
2676 :
2677 0 : aDateTime.HundredthSeconds /= 10;
2678 : }
2679 0 : break;
2680 : }
2681 0 : aCommentHd.SeekToEndOfRecord( rStCtrl );
2682 : }
2683 0 : Point aPosition( nPosX, nPosY );
2684 0 : rMan.Scale( aPosition );
2685 :
2686 : try
2687 : {
2688 0 : uno::Reference< office::XAnnotationAccess > xAnnotationAccess( pPage->getUnoPage(), UNO_QUERY_THROW );
2689 0 : uno::Reference< office::XAnnotation > xAnnotation( xAnnotationAccess->createAndInsertAnnotation() );
2690 0 : xAnnotation->setPosition( geometry::RealPoint2D( aPosition.X() / 100.0, aPosition.Y() / 100.0 ) );
2691 0 : xAnnotation->setAuthor( sAuthor );
2692 0 : xAnnotation->setDateTime( aDateTime );
2693 0 : uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
2694 0 : xText->setString( sText );
2695 : }
2696 0 : catch( const uno::Exception& )
2697 : {
2698 :
2699 0 : }
2700 0 : }
2701 :
2702 :
2703 : // be sure not to import masterpages with this method
2704 52 : void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry* pMasterPersist )
2705 : {
2706 52 : sal_uInt32 nMerk = rStCtrl.Tell();
2707 52 : PptSlidePersistList* pList = GetPageList( eAktPageKind );
2708 52 : if ( ( !pList ) || ( pList->size() <= nAktPageNum ) )
2709 : return;
2710 52 : PptSlidePersistEntry& rSlidePersist = *(*pList)[ nAktPageNum ];
2711 52 : if ( rSlidePersist.bStarDrawFiller )
2712 : return;
2713 :
2714 52 : DffRecordHeader aPageHd;
2715 52 : if ( SeekToAktPage( &aPageHd ) )
2716 : {
2717 52 : rSlidePersist.pHeaderFooterEntry = new HeaderFooterEntry( pMasterPersist );
2718 52 : ProcessData aProcessData( rSlidePersist, (SdPage*)pRet );
2719 315 : while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPageHd.GetRecEndFilePos() ) )
2720 : {
2721 211 : DffRecordHeader aHd;
2722 211 : rStCtrl >> aHd;
2723 211 : switch ( aHd.nRecType )
2724 : {
2725 : case PPT_PST_HeadersFooters :
2726 : {
2727 5 : ImportHeaderFooterContainer( aHd, *rSlidePersist.pHeaderFooterEntry );
2728 : }
2729 5 : break;
2730 :
2731 : case PPT_PST_ProgTags :
2732 : {
2733 48 : DffRecordHeader aContentDataHd;
2734 48 : if ( SeekToContentOfProgTag( 10, rStCtrl, aHd, aContentDataHd ) )
2735 : {
2736 48 : DffRecordHeader aComment10Hd;
2737 96 : while( ( rStCtrl.GetError() == 0 ) && SeekToRec( rStCtrl, PPT_PST_Comment10, aContentDataHd.GetRecEndFilePos(), &aComment10Hd ) )
2738 : {
2739 0 : ImportComment10( *this, rStCtrl, pRet, aComment10Hd );
2740 0 : aComment10Hd.SeekToEndOfRecord( rStCtrl );
2741 : }
2742 : }
2743 : }
2744 48 : break;
2745 :
2746 : case PPT_PST_PPDrawing :
2747 : {
2748 51 : DffRecordHeader aPPDrawHd;
2749 51 : if ( SeekToRec( rStCtrl, DFF_msofbtDgContainer, aHd.GetRecEndFilePos(), &aPPDrawHd ) )
2750 : {
2751 51 : sal_uInt32 nPPDrawOfs = rStCtrl.Tell();
2752 :
2753 : // importing the background object before importing the page
2754 51 : while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPPDrawHd.GetRecEndFilePos() ) )
2755 : {
2756 155 : DffRecordHeader aEscherObjListHd;
2757 155 : rStCtrl >> aEscherObjListHd;
2758 155 : switch ( aEscherObjListHd.nRecType )
2759 : {
2760 : case DFF_msofbtSpContainer :
2761 : {
2762 51 : Rectangle aPageSize( Point(), pRet->GetSize() );
2763 51 : if ( rSlidePersist.aSlideAtom.nFlags & 4 ) // follow master background?
2764 : {
2765 32 : if ( HasMasterPage( nAktPageNum, eAktPageKind ) )
2766 : {
2767 32 : sal_uInt16 nMasterNum = GetMasterPageIndex( nAktPageNum, eAktPageKind );
2768 32 : PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE );
2769 32 : PptSlidePersistEntry* pE = (*pPageList)[ nMasterNum ];
2770 64 : while( ( pE->aSlideAtom.nFlags & 4 ) && pE->aSlideAtom.nMasterId )
2771 : {
2772 0 : sal_uInt16 nNextMaster = pMasterPages->FindPage( pE->aSlideAtom.nMasterId );
2773 0 : if ( nNextMaster == PPTSLIDEPERSIST_ENTRY_NOTFOUND )
2774 0 : break;
2775 : else
2776 0 : pE = (*pPageList)[ nNextMaster ];
2777 : }
2778 32 : if ( pE->nBackgroundOffset )
2779 : {
2780 : // do not follow master colorscheme?
2781 32 : sal_Bool bTemporary = ( rSlidePersist.aSlideAtom.nFlags & 2 ) != 0;
2782 32 : sal_uInt32 nPos = rStCtrl.Tell();
2783 32 : rStCtrl.Seek( pE->nBackgroundOffset );
2784 32 : rSlidePersist.pBObj = ImportObj( rStCtrl, (void*)&aProcessData, aPageSize, aPageSize );
2785 32 : rSlidePersist.bBObjIsTemporary = bTemporary;
2786 32 : rStCtrl.Seek( nPos );
2787 : }
2788 : }
2789 : }
2790 : else
2791 : {
2792 19 : DffRecordHeader aShapeHd;
2793 19 : rStCtrl >> aShapeHd;
2794 19 : if ( aShapeHd.nRecType == DFF_msofbtSp )
2795 : {
2796 : sal_uInt32 nSpFlags;
2797 19 : rStCtrl >> nSpFlags >> nSpFlags;
2798 19 : if ( nSpFlags & SP_FBACKGROUND )
2799 : {
2800 19 : aEscherObjListHd.SeekToBegOfRecord( rStCtrl );
2801 19 : rSlidePersist.pBObj = ImportObj( rStCtrl, (void*)&aProcessData, aPageSize, aPageSize );
2802 19 : rSlidePersist.bBObjIsTemporary = sal_False;
2803 : }
2804 : }
2805 : }
2806 : }
2807 51 : break;
2808 : }
2809 155 : if ( aEscherObjListHd.nRecType == DFF_msofbtSpContainer )
2810 : break;
2811 104 : aEscherObjListHd.SeekToEndOfRecord( rStCtrl );
2812 : }
2813 :
2814 : // now importing page
2815 51 : rStCtrl.Seek( nPPDrawOfs );
2816 155 : while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPPDrawHd.GetRecEndFilePos() ) )
2817 : {
2818 104 : DffRecordHeader aEscherObjListHd;
2819 104 : rStCtrl >> aEscherObjListHd;
2820 104 : switch ( aEscherObjListHd.nRecType )
2821 : {
2822 : case DFF_msofbtSpgrContainer :
2823 : {
2824 51 : DffRecordHeader aShapeHd;
2825 51 : if ( SeekToRec( rStCtrl, DFF_msofbtSpContainer, aEscherObjListHd.GetRecEndFilePos(), &aShapeHd ) )
2826 : {
2827 51 : aShapeHd.SeekToEndOfRecord( rStCtrl );
2828 352 : while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aEscherObjListHd.GetRecEndFilePos() ) )
2829 : {
2830 250 : rStCtrl >> aShapeHd;
2831 250 : if ( ( aShapeHd.nRecType == DFF_msofbtSpContainer ) || ( aShapeHd.nRecType == DFF_msofbtSpgrContainer ) )
2832 : {
2833 236 : Rectangle aEmpty;
2834 236 : aShapeHd.SeekToBegOfRecord( rStCtrl );
2835 : sal_Int32 nShapeId;
2836 236 : aProcessData.pTableRowProperties = NULL;
2837 236 : SdrObject* pObj = ImportObj( rStCtrl, (void*)&aProcessData, aEmpty, aEmpty, 0, &nShapeId );
2838 236 : if ( pObj )
2839 : {
2840 229 : if ( aProcessData.pTableRowProperties )
2841 33 : pObj = CreateTable( pObj, aProcessData.pTableRowProperties, aProcessData.rPersistEntry.pSolverContainer );
2842 :
2843 229 : pRet->NbcInsertObject( pObj );
2844 :
2845 229 : if( nShapeId )
2846 229 : insertShapeId( nShapeId, pObj );
2847 : }
2848 : }
2849 250 : aShapeHd.SeekToEndOfRecord( rStCtrl );
2850 : }
2851 : }
2852 : }
2853 51 : break;
2854 : }
2855 104 : if ( aEscherObjListHd.nRecType == DFF_msofbtSpgrContainer )
2856 : break;
2857 53 : aEscherObjListHd.SeekToEndOfRecord( rStCtrl );
2858 : }
2859 :
2860 : /* There are a lot of Shapes which are dependent to
2861 : the current background color */
2862 51 : if ( rSlidePersist.ePageKind == PPT_SLIDEPAGE )
2863 : {
2864 32 : if ( !aProcessData.aBackgroundColoredObjects.empty() )
2865 : {
2866 0 : if ( rSlidePersist.pBObj )
2867 : {
2868 0 : const SfxPoolItem* pPoolItem = NULL;
2869 0 : const SfxItemSet& rObjectItemSet = rSlidePersist.pBObj->GetMergedItemSet();
2870 :
2871 : //SfxItemState eState = rObjectItemSet.GetItemState( XATTR_FILLCOLOR, sal_False, &pPoolItem );
2872 0 : if ( pPoolItem )
2873 : {
2874 0 : SfxItemSet aNewSet(*rObjectItemSet.GetPool());
2875 0 : aNewSet.Put(*pPoolItem);
2876 0 : aNewSet.Put(XFillStyleItem( XFILL_SOLID ));
2877 :
2878 0 : for (
2879 0 : size_t i = 0, n = aProcessData.aBackgroundColoredObjects.size();
2880 : i < n;
2881 : ++i
2882 : ) {
2883 0 : aProcessData.aBackgroundColoredObjects[ i ]->SetMergedItemSet(aNewSet);
2884 0 : }
2885 : }
2886 : }
2887 : }
2888 : }
2889 51 : if ( rSlidePersist.pBObj )
2890 : {
2891 : // #i99386# transfer the attributes from the temporary BackgroundObject
2892 : // to the Page and delete it. Maybe rSlidePersist.bBObjIsTemporary is
2893 : // obsolete here, too.
2894 51 : pRet->getSdrPageProperties().ClearItem();
2895 51 : pRet->getSdrPageProperties().PutItemSet(rSlidePersist.pBObj->GetMergedItemSet());
2896 51 : SdrObject::Free( rSlidePersist.pBObj );
2897 : }
2898 : }
2899 : }
2900 51 : break;
2901 : }
2902 211 : aHd.SeekToEndOfRecord( rStCtrl );
2903 : }
2904 52 : if ( rSlidePersist.pSolverContainer )
2905 5 : SolveSolver( *rSlidePersist.pSolverContainer );
2906 : }
2907 52 : rStCtrl.Seek( nMerk );
2908 : }
2909 :
2910 154 : const PptSlideLayoutAtom* SdrPowerPointImport::GetSlideLayoutAtom() const
2911 : {
2912 154 : PptSlidePersistList* pPageList = GetPageList( eAktPageKind );
2913 154 : if ( pPageList && nAktPageNum < pPageList->size() )
2914 : {
2915 154 : PptSlidePersistEntry* pE = (*pPageList)[ nAktPageNum ];
2916 154 : if ( pE )
2917 154 : return &pE->aSlideAtom.aLayout;
2918 : }
2919 0 : return NULL;
2920 : }
2921 :
2922 84 : sal_Bool SdrPowerPointImport::IsNoteOrHandout( sal_uInt16 nPageNum, PptPageKind /*ePageKind*/) const
2923 : {
2924 84 : sal_Bool bNote = eAktPageKind == PPT_NOTEPAGE;
2925 84 : if ( eAktPageKind == PPT_MASTERPAGE )
2926 20 : bNote = ( nPageNum & 1 ) == 0;
2927 84 : return bNote;
2928 : }
2929 :
2930 406 : sal_uInt32 SdrPowerPointImport::GetMasterPageId( sal_uInt16 nPageNum, PptPageKind ePageKind ) const
2931 : {
2932 406 : PptSlidePersistList* pPageList = GetPageList( ePageKind );
2933 406 : if ( pPageList && nPageNum < pPageList->size() )
2934 406 : return (*pPageList)[ nPageNum ]->aSlideAtom.nMasterId;
2935 0 : return 0;
2936 : }
2937 :
2938 32 : sal_uInt32 SdrPowerPointImport::GetNotesPageId( sal_uInt16 nPageNum ) const
2939 : {
2940 32 : PptSlidePersistList* pPageList=GetPageList( PPT_SLIDEPAGE );
2941 32 : if ( pPageList && nPageNum < pPageList->size() )
2942 32 : return (*pPageList)[ nPageNum ]->aSlideAtom.nNotesId;
2943 0 : return 0;
2944 : }
2945 :
2946 227 : sal_Bool SdrPowerPointImport::HasMasterPage( sal_uInt16 nPageNum, PptPageKind ePageKind ) const
2947 : {
2948 227 : if ( ePageKind == PPT_NOTEPAGE )
2949 40 : return aDocAtom.nNotesMasterPersist != 0;
2950 187 : if ( ePageKind == PPT_MASTERPAGE )
2951 0 : return sal_False;
2952 187 : return GetMasterPageId( nPageNum, ePageKind ) != 0;
2953 : }
2954 :
2955 239 : sal_uInt16 SdrPowerPointImport::GetMasterPageIndex( sal_uInt16 nPageNum, PptPageKind ePageKind ) const
2956 : {
2957 239 : sal_uInt16 nIdx = 0;
2958 239 : if ( ePageKind == PPT_NOTEPAGE )
2959 20 : return 2;
2960 219 : sal_uInt32 nId = GetMasterPageId( nPageNum, ePageKind );
2961 219 : if ( nId && pMasterPages )
2962 : {
2963 219 : nIdx = pMasterPages->FindPage( nId );
2964 219 : if ( nIdx == PPTSLIDEPERSIST_ENTRY_NOTFOUND )
2965 0 : nIdx = 0;
2966 : }
2967 219 : return nIdx;
2968 : }
2969 :
2970 9 : SdrObject* SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage, sal_uInt32& nBgFileOffset, sal_Bool bForce )
2971 : {
2972 9 : SdrObject* pRet = NULL;
2973 9 : sal_Bool bCreateObj = bForce;
2974 9 : SfxItemSet* pSet = NULL;
2975 9 : sal_uLong nFPosMerk = rStCtrl.Tell(); // remember FilePos for restoring it later
2976 9 : DffRecordHeader aPageHd;
2977 9 : if ( SeekToAktPage( &aPageHd ) )
2978 : { // and now search for the background attributes of the Page
2979 9 : sal_uLong nPageRecEnd = aPageHd.GetRecEndFilePos();
2980 9 : DffRecordHeader aPPDrawHd;
2981 9 : if ( SeekToRec( rStCtrl, PPT_PST_PPDrawing, nPageRecEnd, &aPPDrawHd ) )
2982 : {
2983 9 : sal_uLong nPPDrawEnd = aPPDrawHd.GetRecEndFilePos();
2984 9 : DffRecordHeader aEscherF002Hd;
2985 9 : if ( SeekToRec( rStCtrl, DFF_msofbtDgContainer, nPPDrawEnd, &aEscherF002Hd ) )
2986 : {
2987 9 : sal_uLong nEscherF002End = aEscherF002Hd.GetRecEndFilePos();
2988 9 : DffRecordHeader aEscherObjectHd;
2989 9 : if ( SeekToRec( rStCtrl, DFF_msofbtSpContainer, nEscherF002End, &aEscherObjectHd ) )
2990 : {
2991 9 : nBgFileOffset = aEscherObjectHd.GetRecBegFilePos();
2992 : //sal_uLong nEscherObjectEnd = aEscherObjectHd.GetRecEndFilePos();
2993 : //DffRecordHeader aEscherPropertiesHd;
2994 9 : if ( SeekToRec( rStCtrl, DFF_msofbtOPT,nEscherF002End ) )
2995 : {
2996 9 : rStCtrl >> (DffPropertyReader&)*this;
2997 9 : mnFix16Angle = Fix16ToAngle( GetPropertyValue( DFF_Prop_Rotation, 0 ) );
2998 9 : sal_uInt32 nColor = GetPropertyValue( DFF_Prop_fillColor, 0xffffff );
2999 9 : pSet = new SfxItemSet( pSdrModel->GetItemPool() );
3000 9 : DffObjData aObjData( aEscherObjectHd, Rectangle( 0, 0, 28000, 21000 ), 0 );
3001 9 : ApplyAttributes( rStCtrl, *pSet, aObjData );
3002 9 : Color aColor( MSO_CLR_ToColor( nColor ) );
3003 9 : pSet->Put( XFillColorItem( String(), aColor ) );
3004 : }
3005 : }
3006 : }
3007 : }
3008 : }
3009 9 : rStCtrl.Seek( nFPosMerk ); // restore FilePos
3010 9 : if ( bCreateObj )
3011 : {
3012 9 : if ( !pSet )
3013 : {
3014 0 : pSet = new SfxItemSet( pSdrModel->GetItemPool() );
3015 0 : pSet->Put( XFillStyleItem( XFILL_NONE ) );
3016 : }
3017 9 : pSet->Put( XLineStyleItem( XLINE_NONE ) );
3018 9 : Rectangle aRect( rPage.GetLftBorder(), rPage.GetUppBorder(), rPage.GetWdt()-rPage.GetRgtBorder(), rPage.GetHgt()-rPage.GetLwrBorder() );
3019 9 : pRet = new SdrRectObj( aRect );
3020 9 : pRet->SetModel( pSdrModel );
3021 :
3022 9 : pRet->SetMergedItemSet(*pSet);
3023 :
3024 9 : pRet->SetMarkProtect( sal_True );
3025 9 : pRet->SetMoveProtect( sal_True );
3026 9 : pRet->SetResizeProtect( sal_True );
3027 : }
3028 9 : delete pSet;
3029 9 : return pRet;
3030 : }
3031 :
3032 62 : HeaderFooterEntry::HeaderFooterEntry( const PptSlidePersistEntry* pMPE ) :
3033 : pMasterPersist ( pMPE ),
3034 62 : nAtom ( 0 )
3035 : {
3036 62 : if ( pMPE )
3037 : {
3038 52 : HeaderFooterEntry* pMHFE = pMPE->pHeaderFooterEntry;
3039 52 : if ( pMHFE )
3040 : {
3041 52 : nAtom = pMPE->pHeaderFooterEntry->nAtom;
3042 52 : pPlaceholder[ 0 ] = pMHFE->pPlaceholder[ 0 ];
3043 52 : pPlaceholder[ 1 ] = pMHFE->pPlaceholder[ 1 ];
3044 52 : pPlaceholder[ 2 ] = pMHFE->pPlaceholder[ 2 ];
3045 52 : pPlaceholder[ 3 ] = pMHFE->pPlaceholder[ 3 ];
3046 : }
3047 : }
3048 62 : }
3049 :
3050 50 : HeaderFooterEntry::~HeaderFooterEntry()
3051 : {
3052 50 : }
3053 :
3054 0 : sal_uInt32 HeaderFooterEntry::GetMaskForInstance( sal_uInt32 nInstance )
3055 : {
3056 0 : sal_uInt32 nRet = 0;
3057 0 : switch ( nInstance )
3058 : {
3059 0 : case 0 : nRet = 0x07ffff; break;
3060 0 : case 1 : nRet = 0x100000; break;
3061 0 : case 2 : nRet = 0x200000; break;
3062 0 : case 3 : nRet = 0x080000; break;
3063 : }
3064 0 : return nRet;
3065 : }
3066 :
3067 208 : sal_uInt32 HeaderFooterEntry::IsToDisplay( sal_uInt32 nInstance )
3068 : {
3069 208 : sal_uInt32 nMask = 0;
3070 208 : switch ( nInstance )
3071 : {
3072 52 : case 0 : nMask = 0x010000; break;
3073 52 : case 1 : nMask = 0x100000; break;
3074 52 : case 2 : nMask = 0x200000; break;
3075 52 : case 3 : nMask = 0x080000; break;
3076 : }
3077 208 : return ( nAtom & nMask );
3078 : }
3079 :
3080 : // The following method checks if the slide is using a different colorscheme than
3081 : // its master, if this is the fact, then the HeaderFooter must probably be
3082 : // imported as real sdrobject. In this case, the return value is the offset to the
3083 : // master header footer object, so it can be re-loaded with a different color set
3084 170 : sal_uInt32 HeaderFooterEntry::NeedToImportInstance( const sal_uInt32 nInstance, const PptSlidePersistEntry& rSlidePersist )
3085 : {
3086 170 : sal_uInt32 nRet = 0;
3087 170 : if ( pMasterPersist )
3088 : {
3089 170 : if ( !( rSlidePersist.aSlideAtom.nFlags & 2 ) )
3090 : { // not following the master persist, so we have to check if the colors are changed
3091 78 : if ( memcmp( &rSlidePersist.aColorScheme, &pMasterPersist->aColorScheme, 32 ) )
3092 : {
3093 4 : nRet = pMasterPersist->HeaderFooterOfs[ nInstance ];
3094 : }
3095 : }
3096 : }
3097 170 : return nRet;
3098 : }
3099 :
3100 14 : void SdrEscherImport::ImportHeaderFooterContainer( DffRecordHeader& rHd, HeaderFooterEntry& rE )
3101 : {
3102 14 : rHd.SeekToContent( rStCtrl );
3103 42 : while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < rHd.GetRecEndFilePos() ) )
3104 : {
3105 14 : DffRecordHeader aHd;
3106 14 : rStCtrl >> aHd;
3107 14 : switch ( aHd.nRecType )
3108 : {
3109 : case PPT_PST_HeadersFootersAtom :
3110 14 : rStCtrl >> rE.nAtom;
3111 14 : break;
3112 :
3113 : case PPT_PST_CString :
3114 : {
3115 0 : if ( aHd.nRecInstance < 4 )
3116 : {
3117 0 : rE.pPlaceholder[ aHd.nRecInstance ] = MSDFFReadZString( rStCtrl,
3118 0 : aHd.nRecLen, sal_True );
3119 : }
3120 : }
3121 0 : break;
3122 : }
3123 14 : aHd.SeekToEndOfRecord( rStCtrl );
3124 : }
3125 14 : }
3126 :
3127 : // no longer needed
3128 0 : sal_Unicode SdrPowerPointImport::PPTSubstitute( sal_uInt16 /*nFont*/, sal_Unicode /*nChar*/,
3129 : sal_uInt32& /*nMappedFontId*/, Font& /*rFont*/, char /*nDefault*/) const
3130 : {
3131 0 : return 0;
3132 : }
3133 :
3134 0 : PPTBuGraEntry::PPTBuGraEntry( Graphic& rGraphic, sal_uInt32 nInst ) :
3135 : nInstance ( nInst ),
3136 0 : aBuGra ( rGraphic ) {}
3137 :
3138 270 : PPTExtParaLevel::PPTExtParaLevel()
3139 : : mnExtParagraphMask( 0 )
3140 : , mnBuBlip( 0xffff )
3141 : , mnHasAnm( 0 )
3142 : , mnAnmScheme( 0 )
3143 : , mpfPP10Ext( 0 )
3144 : , mnExtCharacterMask( 0 )
3145 : , mcfPP10Ext( 0 )
3146 270 : , mbSet( sal_False )
3147 270 : {}
3148 :
3149 0 : SvStream& operator>>( SvStream& rIn, PPTExtParaLevel& rLevel )
3150 : {
3151 0 : rLevel.mbSet = sal_True;
3152 0 : rIn >> rLevel.mnExtParagraphMask;
3153 0 : if ( rLevel.mnExtParagraphMask & 0x00800000 )
3154 0 : rIn >> rLevel.mnBuBlip;
3155 0 : if ( rLevel.mnExtParagraphMask & 0x02000000 )
3156 0 : rIn >> rLevel.mnHasAnm;
3157 0 : if ( rLevel.mnExtParagraphMask & 0x01000000 )
3158 0 : rIn >> rLevel.mnAnmScheme;
3159 0 : if ( rLevel.mnExtParagraphMask & 0x04000000 )
3160 0 : rIn >> rLevel.mpfPP10Ext;
3161 0 : rIn >> rLevel.mnExtCharacterMask;
3162 0 : if ( rLevel.mnExtCharacterMask & 0x100000 )
3163 0 : rIn >> rLevel.mcfPP10Ext;
3164 0 : return rIn;
3165 : }
3166 :
3167 0 : sal_Bool PPTExtParaProv::GetGraphic( sal_uInt32 nInstance, Graphic& rGraph ) const
3168 : {
3169 0 : sal_Bool bRetValue = sal_False;
3170 0 : PPTBuGraEntry* pPtr = NULL;
3171 0 : if ( nInstance < aBuGraList.size() )
3172 : {
3173 0 : pPtr = aBuGraList[ nInstance ];
3174 0 : if ( pPtr->nInstance == nInstance )
3175 0 : bRetValue = sal_True;
3176 : }
3177 0 : if ( !bRetValue )
3178 : {
3179 0 : for (size_t i = 0; i < aBuGraList.size(); i++ )
3180 : {
3181 0 : pPtr = aBuGraList[ i ];
3182 0 : if ( pPtr->nInstance == nInstance )
3183 : {
3184 0 : bRetValue = sal_True;
3185 0 : break;
3186 : }
3187 : }
3188 : }
3189 0 : if ( bRetValue )
3190 0 : rGraph = pPtr->aBuGra;
3191 0 : return bRetValue;
3192 : }
3193 :
3194 6 : PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const DffRecordHeader* pHd ) :
3195 : bStyles ( sal_False ),
3196 6 : bGraphics ( sal_False )
3197 : {
3198 6 : sal_uInt32 nOldPos = rSt.Tell();
3199 :
3200 : // here we have to get the graphical bullets...
3201 :
3202 6 : DffRecordHeader aHd;
3203 6 : DffRecordHeader aContentDataHd;
3204 :
3205 6 : const DffRecordHeader* pListHd = rMan.aDocRecManager.GetRecordHeader( PPT_PST_List, SEEK_FROM_BEGINNING );
3206 6 : while( pListHd )
3207 : {
3208 6 : pListHd->SeekToContent( rSt );
3209 6 : if ( !rMan.SeekToContentOfProgTag( 9, rSt, *pListHd, aContentDataHd ) )
3210 3 : break;
3211 9 : while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aContentDataHd.GetRecEndFilePos() ) )
3212 : {
3213 3 : rSt >> aHd;
3214 3 : switch ( aHd.nRecType )
3215 : {
3216 : case PPT_PST_ExtendedBuGraContainer :
3217 : {
3218 0 : while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aHd.GetRecEndFilePos() ) )
3219 : {
3220 : sal_uInt16 nType;
3221 0 : DffRecordHeader aBuGraAtomHd;
3222 0 : rSt >> aBuGraAtomHd;
3223 0 : if ( aBuGraAtomHd.nRecType == PPT_PST_ExtendedBuGraAtom )
3224 : {
3225 0 : rSt >> nType;
3226 0 : Graphic aGraphic;
3227 0 : if ( rMan.GetBLIPDirect( rSt, aGraphic, NULL ) )
3228 : {
3229 0 : sal_uInt32 nInstance = aBuGraAtomHd.nRecInstance;
3230 0 : PPTBuGraEntry* pBuGra = new PPTBuGraEntry( aGraphic, nInstance );
3231 0 : size_t n = 0;
3232 0 : size_t nBuGraCount = aBuGraList.size();
3233 0 : if ( nBuGraCount )
3234 : {
3235 0 : if ( aBuGraList[ nBuGraCount - 1 ]->nInstance < nInstance )
3236 0 : n = nBuGraCount;
3237 : else
3238 : { // maybe the instances are not sorted, we sort it
3239 0 : for ( n = 0; n < nBuGraCount; n++ )
3240 : { // sorting fields ( hi >> lo )
3241 0 : if ( aBuGraList[ n ]->nInstance < nInstance )
3242 0 : break;
3243 : }
3244 : }
3245 : }
3246 0 : if ( n < nBuGraCount ) {
3247 0 : aBuGraList.insert( aBuGraList.begin() + n, pBuGra );
3248 : } else {
3249 0 : aBuGraList.push_back( pBuGra );
3250 : }
3251 0 : }
3252 : #ifdef DBG_UTIL
3253 : else OSL_FAIL( "PPTExParaProv::PPTExParaProv - bullet graphic is not valid (SJ)" );
3254 : #endif
3255 : }
3256 : #ifdef DBG_UTIL
3257 : else OSL_FAIL( "PPTExParaProv::PPTExParaProv - unknown atom interpreting the PPT_PST_ExtendedBuGraContainer (SJ)" );
3258 : #endif
3259 0 : aBuGraAtomHd.SeekToEndOfRecord( rSt );
3260 : }
3261 0 : if ( !aBuGraList.empty() )
3262 0 : bGraphics = sal_True;
3263 : }
3264 0 : break;
3265 :
3266 : case PPT_PST_ExtendedPresRuleContainer :
3267 3 : aExtendedPresRules.Consume( rSt, sal_False, aHd.GetRecEndFilePos() );
3268 3 : break;
3269 : #ifdef DBG_UTIL
3270 : default :
3271 : OSL_FAIL( "PPTExParaProv::PPTExParaProv - unknown atom reading ppt2000 num rules (SJ)" );
3272 : case PPT_PST_MasterText : // first seen in: ms-tt02.ppt
3273 : case PPT_PST_SrKinsoku :
3274 : case PPT_PST_NewlyAddedAtom4016 :
3275 : case PPT_PST_NewlyAddedAtomByPPT2000_6010 :
3276 : case PPT_PST_NewlyAddedAtomByPPT2000_6011 :
3277 : case PPT_PST_NewlyAddedAtomByXP1037 :
3278 : case PPT_PST_NewlyAddedAtomByXP12004 :
3279 : case PPT_PST_NewlyAddedAtomByXP14001 :
3280 : break;
3281 : #endif
3282 : }
3283 3 : aHd.SeekToEndOfRecord( rSt );
3284 : }
3285 3 : break;
3286 : }
3287 :
3288 6 : while( pHd )
3289 : { // get the extended paragraph styles on mainmaster ( graphical bullets, num ruling ... )
3290 6 : if ( !rMan.SeekToContentOfProgTag( 9, rSt, *pHd, aContentDataHd ) )
3291 6 : break;
3292 0 : while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aContentDataHd.GetRecEndFilePos() ) )
3293 : {
3294 0 : rSt >> aHd;
3295 0 : switch ( aHd.nRecType )
3296 : {
3297 : case PPT_PST_ExtendedParagraphMasterAtom :
3298 : {
3299 0 : if ( aHd.nRecInstance < PPT_STYLESHEETENTRYS )
3300 : {
3301 0 : sal_uInt16 nDepth, i = 0;
3302 0 : rSt >> nDepth;
3303 0 : if ( i <= 5 )
3304 : {
3305 :
3306 0 : while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aHd.GetRecEndFilePos() ) && ( i < nDepth ) )
3307 : {
3308 0 : bStyles = sal_True;
3309 0 : rSt >> aExtParaSheet[ aHd.nRecInstance ].aExtParaLevel[ i++ ];
3310 : }
3311 : #ifdef DBG_UTIL
3312 : if ( rSt.Tell() != aHd.GetRecEndFilePos() )
3313 : OSL_FAIL( "PPTExParaProv::PPTExParaProv - error reading PPT_PST_ExtendedParagraphMasterAtom (SJ)" );
3314 : #endif
3315 : }
3316 : #ifdef DBG_UTIL
3317 : else OSL_FAIL( "PPTExParaProv::PPTExParaProv - depth is greater than 5 (SJ)" );
3318 : #endif
3319 : }
3320 : #ifdef DBG_UTIL
3321 : else OSL_FAIL( "PPTExParaProv::PPTExParaProv - instance out of range (SJ)" );
3322 : #endif
3323 : }
3324 0 : break;
3325 : default :
3326 : OSL_FAIL( "PPTExParaProv::PPTExParaProv - unknown atom, assuming PPT_PST_ExtendedParagraphMasterAtom (SJ)" );
3327 : case PPT_PST_NewlyAddedAtomByXP11008 :
3328 : case PPT_PST_NewlyAddedAtomByXP11010 :
3329 : case PPT_PST_NewlyAddedAtomByXP12010 :
3330 : case PPT_PST_NewlyAddedAtomByXP12011 :
3331 : case 0xf144 :
3332 0 : break;
3333 : }
3334 0 : aHd.SeekToEndOfRecord( rSt );
3335 : }
3336 0 : break;
3337 : }
3338 6 : rSt.Seek( nOldPos );
3339 6 : }
3340 :
3341 12 : PPTExtParaProv::~PPTExtParaProv()
3342 : {
3343 6 : for ( size_t i = 0, n = aBuGraList.size(); i < n; ++i )
3344 0 : delete aBuGraList[ i ];
3345 6 : aBuGraList.clear();
3346 6 : }
3347 :
3348 855 : PPTNumberFormatCreator::PPTNumberFormatCreator( PPTExtParaProv* pParaProv ) :
3349 855 : pExtParaProv ( pParaProv )
3350 : {
3351 855 : }
3352 :
3353 855 : PPTNumberFormatCreator::~PPTNumberFormatCreator()
3354 : {
3355 855 : delete pExtParaProv;
3356 855 : }
3357 :
3358 402 : sal_Bool PPTNumberFormatCreator::ImplGetExtNumberFormat( SdrPowerPointImport& rManager,
3359 : SvxNumberFormat& rNumberFormat, sal_uInt32 nLevel, sal_uInt32 nInstance, sal_uInt32 nDestinationInstance,
3360 : boost::optional< sal_Int16 >& rStartNumbering, sal_uInt32 nFontHeight, PPTParagraphObj* pPara )
3361 : {
3362 402 : sal_Bool bHardAttribute = ( nDestinationInstance == 0xffffffff );
3363 :
3364 402 : sal_uInt32 nBuFlags = 0;
3365 402 : sal_uInt16 nHasAnm = 0;
3366 402 : sal_uInt32 nAnmScheme = 0xFFFF0003;
3367 402 : sal_uInt16 nBuBlip = 0xffff;
3368 :
3369 402 : const PPTExtParaProv* pParaProv = pExtParaProv;
3370 402 : if ( !pExtParaProv )
3371 : pParaProv = ( pPara ) ? pPara->mrStyleSheet.pExtParaProv
3372 180 : : rManager.pPPTStyleSheet->pExtParaProv;
3373 402 : if ( pPara )
3374 : {
3375 180 : nBuFlags = pPara->pParaSet->mnExtParagraphMask;
3376 180 : if ( nBuFlags )
3377 : {
3378 0 : if ( nBuFlags & 0x00800000 )
3379 0 : nBuBlip = pPara->pParaSet->mnBuBlip;
3380 0 : if ( nBuFlags & 0x01000000 )
3381 0 : nAnmScheme = pPara->pParaSet->mnAnmScheme;
3382 0 : if ( nBuFlags & 0x02000000 )
3383 0 : nHasAnm = pPara->pParaSet->mnHasAnm;
3384 0 : bHardAttribute = sal_True;
3385 : }
3386 : }
3387 :
3388 402 : if ( ( nBuFlags & 0x03800000 ) != 0x03800000 ) // merge style sheet
3389 : { // we have to read the master attributes
3390 402 : if ( pParaProv && ( nLevel < 5 ) )
3391 : {
3392 402 : if ( pParaProv->bStyles )
3393 : {
3394 0 : const PPTExtParaLevel& rLev = pParaProv->aExtParaSheet[ nInstance ].aExtParaLevel[ nLevel ];
3395 0 : if ( rLev.mbSet )
3396 : {
3397 0 : sal_uInt32 nMaBuFlags = rLev.mnExtParagraphMask;
3398 :
3399 0 : if ( (!( nBuFlags & 0x00800000)) && ( nMaBuFlags & 0x00800000 ) )
3400 : {
3401 0 : if (!( nBuFlags & 0x02000000)) // if there is a BuStart without BuInstance,
3402 0 : nBuBlip = rLev.mnBuBlip; // then there is no graphical Bullet possible
3403 : }
3404 0 : if ( (!( nBuFlags & 0x01000000)) && ( nMaBuFlags & 0x01000000 ) )
3405 0 : nAnmScheme = rLev.mnAnmScheme;
3406 0 : if ( (!( nBuFlags & 0x02000000)) && ( nMaBuFlags & 0x02000000 ) )
3407 0 : nHasAnm = rLev.mnHasAnm;
3408 0 : nBuFlags |= nMaBuFlags;
3409 : }
3410 : }
3411 : }
3412 : }
3413 402 : if ( nBuBlip != 0xffff ) // set graphical bullet
3414 : {
3415 0 : Graphic aGraphic;
3416 0 : if ( pParaProv->GetGraphic( nBuBlip, aGraphic ) )
3417 : {
3418 0 : SvxBrushItem aBrush( aGraphic, GPOS_MM, SID_ATTR_BRUSH );
3419 0 : rNumberFormat.SetGraphicBrush( &aBrush );
3420 0 : sal_uInt32 nHeight = (sal_uInt32)( (double)nFontHeight * 0.2540 * nBulletHeight + 0.5 );
3421 0 : Size aPrefSize( aGraphic.GetPrefSize() );
3422 0 : sal_uInt32 nWidth = ( nHeight * aPrefSize.Width() ) / aPrefSize.Height();
3423 0 : rNumberFormat.SetGraphicSize( Size( nWidth, nHeight ) );
3424 0 : rNumberFormat.SetNumberingType ( SVX_NUM_BITMAP );
3425 0 : }
3426 : }
3427 402 : else if ( nHasAnm )
3428 : {
3429 0 : switch( static_cast< sal_uInt16 >( nAnmScheme ) )
3430 : {
3431 : default :
3432 : case 0 :
3433 : {
3434 0 : rNumberFormat.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER );
3435 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3436 : }
3437 0 : break;
3438 : case 1 :
3439 : {
3440 0 : rNumberFormat.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER );
3441 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3442 : }
3443 0 : break;
3444 : case 2 :
3445 : {
3446 0 : rNumberFormat.SetNumberingType( SVX_NUM_ARABIC );
3447 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3448 : }
3449 0 : break;
3450 : case 3 :
3451 : {
3452 0 : rNumberFormat.SetNumberingType( SVX_NUM_ARABIC );
3453 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3454 : }
3455 0 : break;
3456 : case 4 :
3457 : {
3458 0 : rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_LOWER );
3459 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3460 0 : rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3461 : }
3462 0 : break;
3463 : case 5 :
3464 : {
3465 0 : rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_LOWER );
3466 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3467 : }
3468 0 : break;
3469 : case 6 :
3470 : {
3471 0 : rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_LOWER );
3472 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3473 : }
3474 0 : break;
3475 : case 7 :
3476 : {
3477 0 : rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_UPPER );
3478 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3479 : }
3480 0 : break;
3481 : case 8 :
3482 : {
3483 0 : rNumberFormat.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER );
3484 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3485 0 : rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3486 : }
3487 0 : break;
3488 : case 9 :
3489 : {
3490 0 : rNumberFormat.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER );
3491 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3492 : }
3493 0 : break;
3494 : case 10 :
3495 : {
3496 0 : rNumberFormat.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER );
3497 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3498 0 : rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3499 : }
3500 0 : break;
3501 : case 11 :
3502 : {
3503 0 : rNumberFormat.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER );
3504 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3505 : }
3506 0 : break;
3507 : case 12 :
3508 : {
3509 0 : rNumberFormat.SetNumberingType( SVX_NUM_ARABIC );
3510 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3511 0 : rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3512 : }
3513 0 : break;
3514 : case 13 :
3515 : {
3516 0 : rNumberFormat.SetNumberingType( SVX_NUM_ARABIC );
3517 : }
3518 0 : break;
3519 : case 14 :
3520 : {
3521 0 : rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_UPPER );
3522 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3523 0 : rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3524 : }
3525 0 : break;
3526 : case 15 :
3527 : {
3528 0 : rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_UPPER );
3529 0 : rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3530 : }
3531 0 : break;
3532 : }
3533 0 : rStartNumbering = boost::optional< sal_Int16 >( nAnmScheme >> 16 );
3534 : }
3535 402 : return bHardAttribute;
3536 : }
3537 :
3538 222 : void PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport& rManager, SvxNumberFormat& rNumberFormat, sal_uInt32 nLevel, const PPTParaLevel& rParaLevel, const PPTCharLevel& rCharLevel, sal_uInt32 nInstance )
3539 : {
3540 222 : nIsBullet = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BulletOn ) ) != 0 ? 1 : 0;
3541 222 : nBulletChar = rParaLevel.mnBulletChar;
3542 :
3543 : sal_Bool bBuHardFont;
3544 222 : bBuHardFont = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardFont ) ) != 0;
3545 222 : if ( bBuHardFont )
3546 104 : nBulletFont = rParaLevel.mnBulletFont;
3547 : else
3548 118 : nBulletFont = rCharLevel.mnFont;
3549 222 : nBulletHeight = rParaLevel.mnBulletHeight;
3550 222 : nBulletColor = rParaLevel.mnBulletColor;
3551 222 : nTextOfs = rParaLevel.mnTextOfs;
3552 222 : nBulletOfs = rParaLevel.mnBulletOfs;
3553 :
3554 222 : boost::optional< sal_Int16 > oStartNumbering;
3555 222 : ImplGetExtNumberFormat( rManager, rNumberFormat, nLevel, nInstance, 0xffffffff, oStartNumbering, rCharLevel.mnFontHeight, NULL );
3556 222 : if ( ( rNumberFormat.GetNumberingType() != SVX_NUM_BITMAP ) && ( nBulletHeight > 0x7fff ) )
3557 0 : nBulletHeight = rCharLevel.mnFontHeight ? ((-((sal_Int16)nBulletHeight)) * 100 ) / rCharLevel.mnFontHeight : 100;
3558 222 : ImplGetNumberFormat( rManager, rNumberFormat, nLevel );
3559 222 : switch ( rNumberFormat.GetNumberingType() )
3560 : {
3561 : case SVX_NUM_CHARS_UPPER_LETTER :
3562 : case SVX_NUM_CHARS_LOWER_LETTER :
3563 : case SVX_NUM_ROMAN_UPPER :
3564 : case SVX_NUM_ROMAN_LOWER :
3565 : case SVX_NUM_ARABIC :
3566 : case SVX_NUM_CHARS_UPPER_LETTER_N :
3567 : case SVX_NUM_CHARS_LOWER_LETTER_N :
3568 : {
3569 0 : sal_uInt32 nFont = rCharLevel.mnFont;
3570 0 : PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nFont );
3571 0 : if ( pFontEnityAtom )
3572 : {
3573 0 : Font aFont;
3574 0 : aFont.SetCharSet( pFontEnityAtom->eCharSet );
3575 0 : aFont.SetName( pFontEnityAtom->aName );
3576 0 : aFont.SetFamily( pFontEnityAtom->eFamily );
3577 0 : aFont.SetPitch( pFontEnityAtom->ePitch );
3578 0 : rNumberFormat.SetBulletFont( &aFont );
3579 : }
3580 : }
3581 0 : break;
3582 222 : }
3583 222 : }
3584 :
3585 814 : sal_Bool PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport& rManager, SvxNumberFormat& rNumberFormat, PPTParagraphObj* pParaObj,
3586 : sal_uInt32 nDestinationInstance, boost::optional< sal_Int16 >& rStartNumbering )
3587 : {
3588 814 : sal_uInt32 nHardCount = 0;
3589 814 : nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletOn, nIsBullet, nDestinationInstance );
3590 814 : nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletChar, nBulletChar, nDestinationInstance );
3591 814 : nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletFont, nBulletFont, nDestinationInstance );
3592 814 : nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletHeight, nBulletHeight, nDestinationInstance );
3593 814 : nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletColor, nBulletColor, nDestinationInstance );
3594 814 : nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_TextOfs, nTextOfs, nDestinationInstance );
3595 814 : nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletOfs, nBulletOfs, nDestinationInstance );
3596 :
3597 814 : if ( nIsBullet )
3598 180 : rNumberFormat.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
3599 :
3600 814 : sal_uInt32 nFontHeight = 24;
3601 814 : PPTPortionObj* pPtr = pParaObj->First();
3602 814 : if ( pPtr )
3603 814 : pPtr->GetAttrib( PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance );
3604 814 : if ( nIsBullet )
3605 : nHardCount += ImplGetExtNumberFormat( rManager, rNumberFormat, pParaObj->pParaSet->mnDepth,
3606 180 : pParaObj->mnInstance, nDestinationInstance, rStartNumbering, nFontHeight, pParaObj );
3607 :
3608 814 : if ( rNumberFormat.GetNumberingType() != SVX_NUM_BITMAP )
3609 814 : pParaObj->UpdateBulletRelSize( nBulletHeight );
3610 814 : if ( nHardCount )
3611 616 : ImplGetNumberFormat( rManager, rNumberFormat, pParaObj->pParaSet->mnDepth );
3612 :
3613 814 : if ( nHardCount )
3614 : {
3615 616 : switch ( rNumberFormat.GetNumberingType() )
3616 : {
3617 : case SVX_NUM_CHARS_UPPER_LETTER :
3618 : case SVX_NUM_CHARS_LOWER_LETTER :
3619 : case SVX_NUM_ROMAN_UPPER :
3620 : case SVX_NUM_ROMAN_LOWER :
3621 : case SVX_NUM_ARABIC :
3622 : case SVX_NUM_CHARS_UPPER_LETTER_N :
3623 : case SVX_NUM_CHARS_LOWER_LETTER_N :
3624 : {
3625 0 : if ( pPtr )
3626 : {
3627 : sal_uInt32 nFont;
3628 0 : pPtr->GetAttrib( PPT_CharAttr_Font, nFont, nDestinationInstance );
3629 0 : PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nFont );
3630 0 : if ( pFontEnityAtom )
3631 : {
3632 0 : Font aFont;
3633 0 : aFont.SetCharSet( pFontEnityAtom->eCharSet );
3634 0 : aFont.SetName( pFontEnityAtom->aName );
3635 0 : aFont.SetFamily( pFontEnityAtom->eFamily );
3636 0 : aFont.SetPitch( pFontEnityAtom->ePitch );
3637 0 : rNumberFormat.SetBulletFont( &aFont );
3638 : }
3639 : }
3640 : }
3641 0 : break;
3642 : }
3643 : }
3644 814 : return ( nHardCount ) ? sal_True : sal_False;
3645 : }
3646 :
3647 838 : void PPTNumberFormatCreator::ImplGetNumberFormat( SdrPowerPointImport& rManager, SvxNumberFormat& rNumberFormat, sal_uInt32 /*nLevel*/)
3648 : {
3649 838 : Font aFont;
3650 838 : PptFontEntityAtom* pAtom = rManager.GetFontEnityAtom( nBulletFont );
3651 838 : if ( pAtom )
3652 : {
3653 838 : CharSet eCharSet( pAtom->eCharSet );
3654 838 : aFont.SetName( pAtom->aName );
3655 838 : aFont.SetCharSet( eCharSet );
3656 838 : aFont.SetFamily( pAtom->eFamily );
3657 838 : aFont.SetPitch( pAtom->ePitch );
3658 : }
3659 838 : Color aCol( rManager.MSO_TEXT_CLR_ToColor( nBulletColor ) );
3660 838 : aFont.SetColor( aCol );
3661 :
3662 838 : sal_uInt16 nBuChar = (sal_uInt16)nBulletChar;
3663 838 : if ( aFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL )
3664 : {
3665 486 : nBuChar &= 0x00ff;
3666 486 : nBuChar |= 0xf000;
3667 : }
3668 838 : rNumberFormat.SetBulletFont( &aFont );
3669 838 : rNumberFormat.SetBulletChar( nBuChar );
3670 838 : rNumberFormat.SetBulletRelSize( (sal_uInt16)nBulletHeight );
3671 838 : rNumberFormat.SetBulletColor( aCol );
3672 838 : sal_uInt16 nAbsLSpace = (sal_uInt16)( ( (sal_uInt32)nTextOfs * 2540 ) / 576 );
3673 838 : sal_uInt16 nFirstLineOffset = nAbsLSpace - (sal_uInt16)( ( (sal_uInt32)nBulletOfs * 2540 ) / 576 );
3674 838 : rNumberFormat.SetAbsLSpace( nAbsLSpace );
3675 838 : rNumberFormat.SetFirstLineOffset( -nFirstLineOffset );
3676 838 : }
3677 :
3678 30 : PPTCharSheet::PPTCharSheet( sal_uInt32 nInstance )
3679 : {
3680 30 : sal_uInt32 nColor = PPT_COLSCHEME_TEXT_UND_ZEILEN;
3681 30 : sal_uInt16 nFontHeight(0);
3682 30 : switch ( nInstance )
3683 : {
3684 : case TSS_TYPE_PAGETITLE :
3685 : case TSS_TYPE_TITLE :
3686 : {
3687 6 : nColor = PPT_COLSCHEME_TITELTEXT;
3688 6 : nFontHeight = 44;
3689 : }
3690 6 : break;
3691 : case TSS_TYPE_BODY :
3692 : case TSS_TYPE_SUBTITLE :
3693 : case TSS_TYPE_HALFBODY :
3694 : case TSS_TYPE_QUARTERBODY :
3695 6 : nFontHeight = 32;
3696 6 : break;
3697 : case TSS_TYPE_NOTES :
3698 6 : nFontHeight = 12;
3699 6 : break;
3700 : case TSS_TYPE_UNUSED :
3701 : case TSS_TYPE_TEXT_IN_SHAPE :
3702 12 : nFontHeight = 24;
3703 12 : break;
3704 : }
3705 180 : for ( sal_uInt32 nDepth = 0; nDepth < 5; nDepth++ )
3706 : {
3707 150 : maCharLevel[ nDepth ].mnFlags = 0;
3708 150 : maCharLevel[ nDepth ].mnFont = 0;
3709 150 : maCharLevel[ nDepth ].mnAsianOrComplexFont = 0xffff;
3710 150 : maCharLevel[ nDepth ].mnFontHeight = nFontHeight;
3711 150 : maCharLevel[ nDepth ].mnFontColor = nColor;
3712 150 : maCharLevel[ nDepth ].mnFontColorInStyleSheet = Color( (sal_uInt8)nColor, (sal_uInt8)( nColor >> 8 ), (sal_uInt8)( nColor >> 16 ) );
3713 150 : maCharLevel[ nDepth ].mnEscapement = 0;
3714 : }
3715 30 : }
3716 :
3717 24 : PPTCharSheet::PPTCharSheet( const PPTCharSheet& rAttr )
3718 : {
3719 24 : *this = rAttr;
3720 24 : }
3721 :
3722 189 : void PPTCharSheet::Read( SvStream& rIn, sal_Bool /*bMasterStyle*/, sal_uInt32 nLevel, sal_Bool /*bFirst*/)
3723 : {
3724 : // Zeichenattribute
3725 : sal_uInt32 nCMask;
3726 : sal_uInt16 nVal16;
3727 189 : rIn >> nCMask;
3728 :
3729 189 : if ( nCMask & 0x0000FFFF )
3730 : {
3731 : sal_uInt16 nBitAttr;
3732 129 : maCharLevel[ nLevel ].mnFlags &= ~( (sal_uInt16)nCMask );
3733 129 : rIn >> nBitAttr; // Bit attributes (bold, underlined, ...)
3734 129 : maCharLevel[ nLevel ].mnFlags |= nBitAttr;
3735 : }
3736 189 : if ( nCMask & ( 1 << PPT_CharAttr_Font ) ) // 0x00010000
3737 129 : rIn >> maCharLevel[ nLevel ].mnFont;
3738 189 : if ( nCMask & ( 1 << PPT_CharAttr_AsianOrComplexFont ) ) // 0x00200000
3739 69 : rIn >> maCharLevel[ nLevel ].mnAsianOrComplexFont;
3740 189 : if ( nCMask & ( 1 << PPT_CharAttr_ANSITypeface ) ) // 0x00400000
3741 69 : rIn >> nVal16;
3742 189 : if ( nCMask & ( 1 << PPT_CharAttr_Symbol ) ) // 0x00800000
3743 69 : rIn >> nVal16;
3744 189 : if ( nCMask & ( 1 << PPT_CharAttr_FontHeight ) ) // 0x00020000
3745 152 : rIn >> maCharLevel[ nLevel ].mnFontHeight;
3746 189 : if ( nCMask & ( 1 << PPT_CharAttr_FontColor ) ) // 0x00040000
3747 : {
3748 129 : rIn >> maCharLevel[ nLevel ].mnFontColor;
3749 129 : if( ! (maCharLevel[ nLevel ].mnFontColor & 0xff000000 ) )
3750 0 : maCharLevel[ nLevel ].mnFontColor = PPT_COLSCHEME_HINTERGRUND;
3751 : }
3752 189 : if ( nCMask & ( 1 << PPT_CharAttr_Escapement ) ) // 0x00080000
3753 69 : rIn >> maCharLevel[ nLevel ].mnEscapement;
3754 189 : if ( nCMask & 0x00100000 ) // 0x00100000
3755 0 : rIn >> nVal16;
3756 :
3757 189 : nCMask >>= 24;
3758 378 : while( nCMask )
3759 : {
3760 0 : if ( nCMask & 1 )
3761 : {
3762 : OSL_FAIL( "PPTCharSheet::Read - unknown attribute, send me this document (SJ)" );
3763 0 : rIn >> nVal16;
3764 : }
3765 0 : nCMask >>= 1;
3766 : }
3767 189 : }
3768 :
3769 30 : PPTParaSheet::PPTParaSheet( sal_uInt32 nInstance )
3770 : {
3771 30 : sal_uInt16 nBuFlags = 0;
3772 30 : sal_uInt32 nBulletColor = 0x8000000;
3773 30 : sal_uInt16 nUpperDist = 0;
3774 :
3775 30 : switch ( nInstance )
3776 : {
3777 : case TSS_TYPE_PAGETITLE :
3778 : case TSS_TYPE_TITLE :
3779 6 : nBulletColor = PPT_COLSCHEME_TITELTEXT;
3780 6 : break;
3781 : case TSS_TYPE_BODY :
3782 : case TSS_TYPE_SUBTITLE :
3783 : case TSS_TYPE_HALFBODY :
3784 : case TSS_TYPE_QUARTERBODY :
3785 : {
3786 6 : nBuFlags = 1;
3787 6 : nUpperDist = 0x14;
3788 : }
3789 6 : break;
3790 : case TSS_TYPE_NOTES :
3791 6 : nUpperDist = 0x1e;
3792 6 : break;
3793 : }
3794 180 : for ( sal_uInt32 i = 0; i < 5; i++ )
3795 : {
3796 150 : maParaLevel[ i ].mnBuFlags = nBuFlags;
3797 150 : maParaLevel[ i ].mnBulletChar = 0x2022;
3798 150 : maParaLevel[ i ].mnBulletFont = 0;
3799 150 : maParaLevel[ i ].mnBulletHeight = 100;
3800 150 : maParaLevel[ i ].mnBulletColor = nBulletColor;
3801 150 : maParaLevel[ i ].mnAdjust = 0;
3802 150 : maParaLevel[ i ].mnLineFeed = 100;
3803 150 : maParaLevel[ i ].mnLowerDist = 0;
3804 150 : maParaLevel[ i ].mnUpperDist = nUpperDist;
3805 150 : maParaLevel[ i ].mnTextOfs = 0;
3806 150 : maParaLevel[ i ].mnBulletOfs = 0;
3807 150 : maParaLevel[ i ].mnDefaultTab = 0x240;
3808 150 : maParaLevel[ i ].mnAsianLineBreak = 0;
3809 150 : maParaLevel[ i ].mnBiDi = 0;
3810 : }
3811 30 : }
3812 :
3813 24 : PPTParaSheet::PPTParaSheet( const PPTParaSheet& rSheet )
3814 : {
3815 24 : *this = rSheet;
3816 24 : }
3817 :
3818 189 : void PPTParaSheet::Read( SdrPowerPointImport&
3819 : #ifdef DBG_UTIL
3820 : rManager
3821 : #endif
3822 : , SvStream& rIn, sal_Bool /*bMasterStyle*/,
3823 : sal_uInt32 nLevel, sal_Bool bFirst )
3824 : {
3825 : // Absatzattribute
3826 : sal_uInt16 nVal16, i, nMask16;
3827 : sal_uInt32 nVal32, nPMask;
3828 189 : rIn >> nPMask;
3829 :
3830 189 : nMask16 = (sal_uInt16)nPMask & 0xf;
3831 189 : if ( nMask16 )
3832 : {
3833 141 : rIn >> nVal16;
3834 141 : maParaLevel[ nLevel ].mnBuFlags &=~ nMask16;
3835 141 : nVal16 &= nMask16;
3836 141 : maParaLevel[ nLevel ].mnBuFlags |= nVal16;
3837 : }
3838 189 : if ( nPMask & 0x0080 )
3839 137 : rIn >> maParaLevel[ nLevel ].mnBulletChar;
3840 189 : if ( nPMask & 0x0010 )
3841 130 : rIn >> maParaLevel[ nLevel ].mnBulletFont;
3842 189 : if ( nPMask & 0x0040 )
3843 : {
3844 130 : rIn >> nVal16;
3845 130 : maParaLevel[ nLevel ].mnBulletHeight = nVal16;
3846 : }
3847 189 : if ( nPMask & 0x0020 )
3848 : {
3849 129 : rIn >> nVal32;
3850 129 : maParaLevel[ nLevel ].mnBulletColor = nVal32;
3851 : }
3852 189 : if ( bFirst )
3853 : {
3854 21 : if ( nPMask & 0xF00 )
3855 : { // AbsJust!
3856 21 : rIn >> nVal16;
3857 21 : maParaLevel[ nLevel ].mnAdjust = nVal16 & 3;
3858 : }
3859 21 : if ( nPMask & 0x1000 )
3860 21 : rIn >> maParaLevel[ nLevel ].mnLineFeed;
3861 21 : if ( nPMask & 0x2000 )
3862 21 : rIn >> maParaLevel[ nLevel ].mnUpperDist;
3863 21 : if ( nPMask & 0x4000 )
3864 21 : rIn >> maParaLevel[ nLevel ].mnLowerDist;
3865 21 : if ( nPMask & 0x8000 )
3866 21 : rIn >> maParaLevel[ nLevel ].mnTextOfs;
3867 21 : if ( nPMask & 0x10000 )
3868 21 : rIn >> maParaLevel[ nLevel ].mnBulletOfs;
3869 21 : if ( nPMask & 0x20000 )
3870 21 : rIn >> maParaLevel[ nLevel ].mnDefaultTab;
3871 21 : if ( nPMask & 0x200000 )
3872 : {
3873 : // number of tabulators
3874 21 : rIn >> nVal16;
3875 21 : for ( i = 0; i < nVal16; i++ )
3876 0 : rIn >> nVal32; // reading the tabulators
3877 : }
3878 21 : if ( nPMask & 0x40000 )
3879 21 : rIn >> nVal16;
3880 21 : if ( nPMask & 0x80000 )
3881 21 : rIn >> maParaLevel[ nLevel ].mnAsianLineBreak;
3882 21 : if ( nPMask & 0x100000 )
3883 21 : rIn >> maParaLevel[ nLevel ].mnBiDi;
3884 : }
3885 : else
3886 : {
3887 168 : if ( nPMask & 0x800 )
3888 : {
3889 118 : rIn >> nVal16;
3890 118 : maParaLevel[ nLevel ].mnAdjust = nVal16 & 3;
3891 : }
3892 168 : if ( nPMask & 0x1000 )
3893 108 : rIn >> maParaLevel[ nLevel ].mnLineFeed;
3894 168 : if ( nPMask & 0x2000 )
3895 108 : rIn >> maParaLevel[ nLevel ].mnUpperDist;
3896 168 : if ( nPMask & 0x4000 )
3897 108 : rIn >> maParaLevel[ nLevel ].mnLowerDist;
3898 168 : if ( nPMask & 0x8000 )
3899 0 : rIn >> nVal16;
3900 168 : if ( nPMask & 0x100 )
3901 146 : rIn >> maParaLevel[ nLevel ].mnTextOfs;
3902 168 : if ( nPMask & 0x200 )
3903 0 : rIn >> nVal16;
3904 168 : if ( nPMask & 0x400 )
3905 136 : rIn >> maParaLevel[ nLevel ].mnBulletOfs;
3906 168 : if ( nPMask & 0x10000 )
3907 0 : rIn >> nVal16;
3908 168 : if ( nPMask & 0xe0000 )
3909 : {
3910 0 : sal_uInt16 nFlagsToModifyMask = (sal_uInt16)( ( nPMask >> 17 ) & 7 );
3911 0 : rIn >> nVal16;
3912 : // bits that are not involved to zero
3913 0 : nVal16 &= nFlagsToModifyMask;
3914 : // bits that are to change to zero
3915 0 : maParaLevel[ nLevel ].mnAsianLineBreak &=~nFlagsToModifyMask;
3916 : // now set the corresponding bits
3917 0 : maParaLevel[ nLevel ].mnAsianLineBreak |= nVal16;
3918 : }
3919 168 : if ( nPMask & 0x100000 )
3920 : {
3921 : // number of tabulators
3922 0 : rIn >> nVal16;
3923 0 : for ( i = 0; i < nVal16; i++ )
3924 0 : rIn >> nVal32; // reading the tabulators
3925 : }
3926 168 : if ( nPMask & 0x200000 )
3927 48 : rIn >> maParaLevel[ nLevel ].mnBiDi; // #88602#
3928 : }
3929 :
3930 189 : nPMask >>= 22;
3931 378 : while( nPMask )
3932 : {
3933 0 : if ( nPMask & 1 )
3934 : {
3935 : #ifdef DBG_UTIL
3936 : if (!(rManager.rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT))
3937 : {
3938 : OSL_FAIL( "PPTParaSheet::Read - unknown attribute, send me this document (SJ)" );
3939 : }
3940 : #endif
3941 0 : rIn >> nVal16;
3942 : }
3943 0 : nPMask >>= 1;
3944 : }
3945 189 : }
3946 :
3947 6 : PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, SdrPowerPointImport& rManager,
3948 : const PPTTextCharacterStyleAtomInterpreter& /*rTxCFStyle*/, const PPTTextParagraphStyleAtomInterpreter& rTxPFStyle,
3949 : const PPTTextSpecInfo& rTextSpecInfo ) :
3950 :
3951 6 : PPTNumberFormatCreator ( new PPTExtParaProv( rManager, rIn, &rSlideHd ) ),
3952 12 : maTxSI ( rTextSpecInfo )
3953 : {
3954 : sal_uInt32 i;
3955 6 : sal_uInt32 nOldFilePos = rIn.Tell();
3956 :
3957 : // default stylesheets
3958 6 : mpCharSheet[ TSS_TYPE_PAGETITLE ] = new PPTCharSheet( TSS_TYPE_PAGETITLE );
3959 6 : mpCharSheet[ TSS_TYPE_BODY ] = new PPTCharSheet( TSS_TYPE_BODY );
3960 6 : mpCharSheet[ TSS_TYPE_NOTES ] = new PPTCharSheet( TSS_TYPE_NOTES );
3961 6 : mpCharSheet[ TSS_TYPE_UNUSED ] = new PPTCharSheet( TSS_TYPE_UNUSED ); // this entry is not used by ppt
3962 6 : mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ] = new PPTCharSheet( TSS_TYPE_TEXT_IN_SHAPE );
3963 6 : mpParaSheet[ TSS_TYPE_PAGETITLE ] = new PPTParaSheet( TSS_TYPE_PAGETITLE );
3964 6 : mpParaSheet[ TSS_TYPE_BODY ] = new PPTParaSheet( TSS_TYPE_BODY );
3965 6 : mpParaSheet[ TSS_TYPE_NOTES ] = new PPTParaSheet( TSS_TYPE_NOTES );
3966 6 : mpParaSheet[ TSS_TYPE_UNUSED ] = new PPTParaSheet( TSS_TYPE_UNUSED );
3967 6 : mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ] = new PPTParaSheet( TSS_TYPE_TEXT_IN_SHAPE );
3968 6 : mpCharSheet[ TSS_TYPE_QUARTERBODY ] = mpCharSheet[ TSS_TYPE_HALFBODY ] = mpCharSheet[ TSS_TYPE_TITLE ] = mpCharSheet[ TSS_TYPE_SUBTITLE ] = NULL;
3969 6 : mpParaSheet[ TSS_TYPE_QUARTERBODY ] = mpParaSheet[ TSS_TYPE_HALFBODY ] = mpParaSheet[ TSS_TYPE_TITLE ] = mpParaSheet[ TSS_TYPE_SUBTITLE ] = NULL;
3970 :
3971 : /* SJ: try to locate the txMasterStyleAtom in the Environment
3972 :
3973 : it seems that the environment TextStyle is having a higher priority
3974 : than the TextStyle that can be found within the master page
3975 : */
3976 6 : sal_Bool bFoundTxMasterStyleAtom04 = sal_False;
3977 6 : DffRecordHeader* pEnvHeader = rManager.aDocRecManager.GetRecordHeader( PPT_PST_Environment );
3978 6 : if ( pEnvHeader )
3979 : {
3980 6 : pEnvHeader->SeekToContent( rIn );
3981 6 : DffRecordHeader aTxMasterStyleHd;
3982 39 : while ( rIn.Tell() < pEnvHeader->GetRecEndFilePos() )
3983 : {
3984 33 : rIn >> aTxMasterStyleHd;
3985 33 : if ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom )
3986 : {
3987 : sal_uInt16 nLevelAnz;
3988 6 : rIn >> nLevelAnz;
3989 :
3990 6 : sal_uInt16 nLev = 0;
3991 6 : sal_Bool bFirst = sal_True;
3992 6 : bFoundTxMasterStyleAtom04 = sal_True;
3993 42 : while ( rIn.GetError() == 0 && rIn.Tell() < aTxMasterStyleHd.GetRecEndFilePos() && nLev < nLevelAnz )
3994 : {
3995 30 : if ( nLev )
3996 : {
3997 24 : mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev ] = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev - 1 ];
3998 24 : mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev ] = mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev - 1 ];
3999 : }
4000 30 : mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rManager, rIn, sal_True, nLev, bFirst );
4001 30 : if ( !nLev )
4002 : {
4003 : // set paragraph defaults for instance 4 (TSS_TYPE_TEXT_IN_SHAPE)
4004 6 : if ( rTxPFStyle.bValid )
4005 : {
4006 3 : PPTParaLevel& rParaLevel = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ 0 ];
4007 3 : rParaLevel.mnAsianLineBreak = 0;
4008 3 : if ( rTxPFStyle.bForbiddenRules )
4009 1 : rParaLevel.mnAsianLineBreak |= 1;
4010 3 : if ( !rTxPFStyle.bLatinTextWrap )
4011 3 : rParaLevel.mnAsianLineBreak |= 2;
4012 3 : if ( rTxPFStyle.bHangingPunctuation )
4013 1 : rParaLevel.mnAsianLineBreak |= 4;
4014 : }
4015 : }
4016 30 : mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rIn, sal_True, nLev, bFirst );
4017 30 : bFirst = sal_False;
4018 30 : nLev++;
4019 : }
4020 : break;
4021 : }
4022 : else
4023 27 : aTxMasterStyleHd.SeekToEndOfRecord( rIn );
4024 : }
4025 : }
4026 :
4027 6 : rSlideHd.SeekToContent( rIn );
4028 6 : DffRecordHeader aTxMasterStyleHd;
4029 57 : while ( rIn.Tell() < rSlideHd.GetRecEndFilePos() )
4030 : {
4031 50 : rIn >> aTxMasterStyleHd;
4032 50 : if ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom )
4033 5 : break;
4034 : else
4035 45 : aTxMasterStyleHd.SeekToEndOfRecord( rIn );
4036 : }
4037 50 : while ( ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom ) && ( rIn.Tell() < rSlideHd.GetRecEndFilePos() ) ) //TODO: aTxMasterStyleHd may be used without having been properly initialized
4038 : {
4039 38 : sal_uInt32 nInstance = aTxMasterStyleHd.nRecInstance;
4040 38 : if ( ( nInstance < PPT_STYLESHEETENTRYS ) &&
4041 : ( ( nInstance != TSS_TYPE_TEXT_IN_SHAPE ) || ( bFoundTxMasterStyleAtom04 == sal_False ) ) )
4042 : {
4043 35 : if ( nInstance > 4 )
4044 : {
4045 20 : delete mpCharSheet[ nInstance ]; // be sure to delete the old one if this instance comes twice
4046 20 : delete mpParaSheet[ nInstance ];
4047 :
4048 20 : switch ( nInstance )
4049 : {
4050 : case TSS_TYPE_SUBTITLE :
4051 : {
4052 5 : mpCharSheet[ TSS_TYPE_SUBTITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4053 5 : mpParaSheet[ TSS_TYPE_SUBTITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4054 : }
4055 5 : break;
4056 : case TSS_TYPE_TITLE :
4057 : {
4058 5 : mpCharSheet[ TSS_TYPE_TITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_PAGETITLE ] ) );
4059 5 : mpParaSheet[ TSS_TYPE_TITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_PAGETITLE ] ) );
4060 : }
4061 5 : break;
4062 : case TSS_TYPE_HALFBODY :
4063 : {
4064 5 : mpCharSheet[ TSS_TYPE_HALFBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4065 5 : mpParaSheet[ TSS_TYPE_HALFBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4066 : }
4067 5 : break;
4068 :
4069 : case TSS_TYPE_QUARTERBODY :
4070 : {
4071 5 : mpCharSheet[ TSS_TYPE_QUARTERBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4072 5 : mpParaSheet[ TSS_TYPE_QUARTERBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4073 : }
4074 5 : break;
4075 : }
4076 : }
4077 : sal_uInt16 nLevelAnz;
4078 35 : rIn >> nLevelAnz;
4079 35 : if ( nLevelAnz > 5 )
4080 : {
4081 : OSL_FAIL( "PPTStyleSheet::Ppt-TextStylesheet hat mehr als 5 Ebenen! (SJ)" );
4082 0 : nLevelAnz = 5;
4083 : }
4084 35 : sal_uInt16 nLev = 0;
4085 35 : sal_Bool bFirst = sal_True;
4086 :
4087 229 : while ( rIn.GetError() == 0 && rIn.Tell() < aTxMasterStyleHd.GetRecEndFilePos() && nLev < nLevelAnz )
4088 : {
4089 159 : if ( nLev && ( nInstance < 5 ) )
4090 : {
4091 52 : mpParaSheet[ nInstance ]->maParaLevel[ nLev ] = mpParaSheet[ nInstance ]->maParaLevel[ nLev - 1 ];
4092 52 : mpCharSheet[ nInstance ]->maCharLevel[ nLev ] = mpCharSheet[ nInstance ]->maCharLevel[ nLev - 1 ];
4093 : }
4094 :
4095 : // Exception: Template 5, 6 (MasterTitle Title und SubTitle)
4096 159 : if ( nInstance >= TSS_TYPE_SUBTITLE )
4097 : {
4098 92 : bFirst = sal_False;
4099 :
4100 : sal_uInt16 nDontKnow;
4101 92 : rIn >> nDontKnow;
4102 : }
4103 159 : mpParaSheet[ nInstance ]->Read( rManager, rIn, sal_True, nLev, bFirst );
4104 159 : mpCharSheet[ nInstance ]->Read( rIn, sal_True, nLev, bFirst );
4105 159 : bFirst = sal_False;
4106 159 : nLev++;
4107 : }
4108 : #ifdef DBG_UTIL
4109 : if (!(rManager.rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT))
4110 : {
4111 : if ( rIn.GetError() == 0 )
4112 : {
4113 : rtl::OStringBuffer aMsg;
4114 : if ( rIn.Tell() > aTxMasterStyleHd.GetRecEndFilePos() )
4115 : {
4116 : aMsg.append(RTL_CONSTASCII_STRINGPARAM("\n "));
4117 : aMsg.append(RTL_CONSTASCII_STRINGPARAM("reading too many bytes:"));
4118 : aMsg.append(static_cast<sal_Int32>(rIn.Tell() - aTxMasterStyleHd.GetRecEndFilePos()));
4119 : }
4120 : if ( rIn.Tell() < aTxMasterStyleHd.GetRecEndFilePos() )
4121 : {
4122 : aMsg.append(RTL_CONSTASCII_STRINGPARAM("\n "));
4123 : aMsg.append(RTL_CONSTASCII_STRINGPARAM("reading too few bytes:"));
4124 : aMsg.append(static_cast<sal_Int32>(aTxMasterStyleHd.GetRecEndFilePos() - rIn.Tell()));
4125 : }
4126 : if (aMsg.getLength())
4127 : {
4128 : aMsg.insert(0, RTL_CONSTASCII_STRINGPARAM("]:"));
4129 : aMsg.insert(0, RTL_CONSTASCII_STRINGPARAM(
4130 : "PptStyleSheet::operator>>["));
4131 : OSL_FAIL(aMsg.getStr());
4132 : }
4133 : }
4134 : if ( rIn.Tell() != aTxMasterStyleHd.GetRecEndFilePos() )
4135 : DBG_ASSERT(0, "SJ: Falsche Anzahl von Bytes gelesen beim Import der PPT-Formatvorlagen");
4136 : }
4137 : #endif
4138 : }
4139 38 : aTxMasterStyleHd.SeekToEndOfRecord( rIn );
4140 38 : rIn >> aTxMasterStyleHd;
4141 : }
4142 6 : if ( !mpCharSheet[ TSS_TYPE_SUBTITLE ] )
4143 : {
4144 1 : mpCharSheet[ TSS_TYPE_SUBTITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4145 1 : mpParaSheet[ TSS_TYPE_SUBTITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4146 : }
4147 6 : if ( !mpCharSheet[ TSS_TYPE_TITLE ] )
4148 : {
4149 1 : mpCharSheet[ TSS_TYPE_TITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_PAGETITLE ] ) );
4150 1 : mpParaSheet[ TSS_TYPE_TITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_PAGETITLE ] ) );
4151 : }
4152 6 : if ( !mpCharSheet[ TSS_TYPE_HALFBODY ] )
4153 : {
4154 1 : mpCharSheet[ TSS_TYPE_HALFBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4155 1 : mpParaSheet[ TSS_TYPE_HALFBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4156 : }
4157 6 : if ( !mpCharSheet[ TSS_TYPE_QUARTERBODY ] )
4158 : {
4159 1 : mpCharSheet[ TSS_TYPE_QUARTERBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4160 1 : mpParaSheet[ TSS_TYPE_QUARTERBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4161 : }
4162 6 : if ( !bFoundTxMasterStyleAtom04 )
4163 : { // try to locate the txMasterStyleAtom in the Environment
4164 0 : DffRecordHeader* pEnvHeader2 = rManager.aDocRecManager.GetRecordHeader( PPT_PST_Environment );
4165 0 : if ( pEnvHeader2 )
4166 : {
4167 0 : pEnvHeader2->SeekToContent( rIn );
4168 0 : DffRecordHeader aTxMasterStyleHd2;
4169 0 : while ( rIn.Tell() < pEnvHeader2->GetRecEndFilePos() )
4170 : {
4171 0 : rIn >> aTxMasterStyleHd2;
4172 0 : if ( aTxMasterStyleHd2.nRecType == PPT_PST_TxMasterStyleAtom )
4173 : {
4174 : sal_uInt16 nLevelAnz;
4175 0 : rIn >> nLevelAnz;
4176 :
4177 0 : sal_uInt16 nLev = 0;
4178 0 : sal_Bool bFirst = sal_True;
4179 0 : while ( rIn.GetError() == 0 && rIn.Tell() < aTxMasterStyleHd2.GetRecEndFilePos() && nLev < nLevelAnz )
4180 : {
4181 0 : if ( nLev )
4182 : {
4183 0 : mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev ] = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev - 1 ];
4184 0 : mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev ] = mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev - 1 ];
4185 : }
4186 0 : mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rManager, rIn, sal_True, nLev, bFirst );
4187 0 : if ( !nLev )
4188 : {
4189 : // set paragraph defaults for instance 4 (TSS_TYPE_TEXT_IN_SHAPE)
4190 0 : if ( rTxPFStyle.bValid )
4191 : {
4192 0 : PPTParaLevel& rParaLevel = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ 0 ];
4193 0 : rParaLevel.mnAsianLineBreak = 0;
4194 0 : if ( rTxPFStyle.bForbiddenRules )
4195 0 : rParaLevel.mnAsianLineBreak |= 1;
4196 0 : if ( !rTxPFStyle.bLatinTextWrap )
4197 0 : rParaLevel.mnAsianLineBreak |= 2;
4198 0 : if ( rTxPFStyle.bHangingPunctuation )
4199 0 : rParaLevel.mnAsianLineBreak |= 4;
4200 : }
4201 : }
4202 0 : mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rIn, sal_True, nLev, bFirst );
4203 0 : bFirst = sal_False;
4204 0 : nLev++;
4205 : }
4206 : break;
4207 : }
4208 : else
4209 0 : aTxMasterStyleHd2.SeekToEndOfRecord( rIn );
4210 : }
4211 : }
4212 : }
4213 6 : rIn.Seek( nOldFilePos );
4214 :
4215 : // will will create the default numbulletitem for each instance
4216 60 : for ( i = 0; i < PPT_STYLESHEETENTRYS; i++ )
4217 : {
4218 54 : sal_uInt16 nLevels, nDepth = 0;
4219 : SvxNumRuleType eNumRuleType;
4220 :
4221 54 : switch ( i )
4222 : {
4223 : case TSS_TYPE_PAGETITLE :
4224 : case TSS_TYPE_TITLE :
4225 12 : nLevels = 1;
4226 12 : eNumRuleType = SVX_RULETYPE_NUMBERING;
4227 12 : break;
4228 : case TSS_TYPE_SUBTITLE :
4229 6 : nLevels = 10;
4230 6 : eNumRuleType = SVX_RULETYPE_NUMBERING;
4231 6 : break;
4232 : case TSS_TYPE_BODY :
4233 : case TSS_TYPE_HALFBODY :
4234 : case TSS_TYPE_QUARTERBODY :
4235 18 : nLevels = 10;
4236 18 : eNumRuleType = SVX_RULETYPE_PRESENTATION_NUMBERING;
4237 18 : break;
4238 : default :
4239 : case TSS_TYPE_NOTES :
4240 : case TSS_TYPE_UNUSED :
4241 : case TSS_TYPE_TEXT_IN_SHAPE :
4242 18 : nLevels = 10;
4243 18 : eNumRuleType = SVX_RULETYPE_NUMBERING;
4244 18 : break;
4245 : }
4246 : SvxNumRule aRule( NUM_BULLET_REL_SIZE | NUM_BULLET_COLOR |
4247 : NUM_CHAR_TEXT_DISTANCE | NUM_SYMBOL_ALIGNMENT,
4248 54 : nLevels, sal_False, eNumRuleType );
4249 276 : for ( sal_uInt16 nCount = 0; nDepth < nLevels; nCount++ )
4250 : {
4251 222 : const PPTParaLevel& rParaLevel = mpParaSheet[ i ]->maParaLevel[ nCount ];
4252 222 : const PPTCharLevel& rCharLevel = mpCharSheet[ i ]->maCharLevel[ nCount ];
4253 222 : SvxNumberFormat aNumberFormat( SVX_NUM_CHAR_SPECIAL );
4254 222 : aNumberFormat.SetBulletChar( ' ' );
4255 222 : GetNumberFormat( rManager, aNumberFormat, nCount, rParaLevel, rCharLevel, i );
4256 222 : aRule.SetLevel( nDepth++, aNumberFormat );
4257 222 : if ( nCount >= 4 )
4258 : {
4259 252 : for ( ;nDepth < nLevels; nDepth++ )
4260 210 : aRule.SetLevel( nDepth, aNumberFormat );
4261 42 : if ( eNumRuleType == SVX_RULETYPE_PRESENTATION_NUMBERING )
4262 18 : aRule.SetLevel( 0, aNumberFormat );
4263 : }
4264 222 : }
4265 54 : mpNumBulletItem[ i ] = new SvxNumBulletItem( aRule, EE_PARA_NUMBULLET );
4266 54 : }
4267 6 : }
4268 :
4269 12 : PPTStyleSheet::~PPTStyleSheet()
4270 : {
4271 60 : for ( sal_uInt32 i = 0; i < PPT_STYLESHEETENTRYS; i++ )
4272 : {
4273 54 : delete mpCharSheet[ i ];
4274 54 : delete mpParaSheet[ i ];
4275 54 : delete mpNumBulletItem[ i ];
4276 : }
4277 6 : }
4278 :
4279 731 : PPTParaPropSet::PPTParaPropSet() :
4280 731 : pParaSet( new ImplPPTParaPropSet )
4281 : {
4282 731 : pParaSet->mnHasAnm = 1;
4283 731 : }
4284 :
4285 1548 : PPTParaPropSet::PPTParaPropSet( PPTParaPropSet& rParaPropSet )
4286 : {
4287 1548 : pParaSet = rParaPropSet.pParaSet;
4288 1548 : pParaSet->mnRefCount++;
4289 :
4290 1548 : mnOriginalTextPos = rParaPropSet.mnOriginalTextPos;
4291 1548 : }
4292 :
4293 2279 : PPTParaPropSet::~PPTParaPropSet()
4294 : {
4295 2279 : if ( ! ( --pParaSet->mnRefCount ) )
4296 731 : delete pParaSet;
4297 2279 : }
4298 :
4299 0 : PPTParaPropSet& PPTParaPropSet::operator=( PPTParaPropSet& rParaPropSet )
4300 : {
4301 0 : if ( this != &rParaPropSet )
4302 : {
4303 0 : if ( ! ( --pParaSet->mnRefCount ) )
4304 0 : delete pParaSet;
4305 0 : pParaSet = rParaPropSet.pParaSet;
4306 0 : pParaSet->mnRefCount++;
4307 :
4308 0 : mnOriginalTextPos = rParaPropSet.mnOriginalTextPos;
4309 : }
4310 0 : return *this;
4311 : }
4312 :
4313 1110 : PPTCharPropSet::PPTCharPropSet( sal_uInt32 nParagraph ) :
4314 : mnParagraph ( nParagraph ),
4315 : mpFieldItem ( NULL ),
4316 1110 : pCharSet ( new ImplPPTCharPropSet )
4317 : {
4318 1110 : mnLanguage[ 0 ] = mnLanguage[ 1 ] = mnLanguage[ 2 ] = 0;
4319 1110 : }
4320 :
4321 1306 : PPTCharPropSet::PPTCharPropSet( const PPTCharPropSet& rCharPropSet )
4322 : {
4323 1306 : pCharSet = rCharPropSet.pCharSet;
4324 1306 : pCharSet->mnRefCount++;
4325 :
4326 1306 : mnParagraph = rCharPropSet.mnParagraph;
4327 1306 : mnOriginalTextPos = rCharPropSet.mnOriginalTextPos;
4328 1306 : maString = rCharPropSet.maString;
4329 1306 : mpFieldItem = ( rCharPropSet.mpFieldItem ) ? new SvxFieldItem( *rCharPropSet.mpFieldItem ) : NULL;
4330 1306 : mnLanguage[ 0 ] = rCharPropSet.mnLanguage[ 0 ];
4331 1306 : mnLanguage[ 1 ] = rCharPropSet.mnLanguage[ 1 ];
4332 1306 : mnLanguage[ 2 ] = rCharPropSet.mnLanguage[ 2 ];
4333 1306 : }
4334 :
4335 1143 : PPTCharPropSet::PPTCharPropSet( const PPTCharPropSet& rCharPropSet, sal_uInt32 nParagraph )
4336 : {
4337 1143 : pCharSet = rCharPropSet.pCharSet;
4338 1143 : pCharSet->mnRefCount++;
4339 :
4340 1143 : mnParagraph = nParagraph;
4341 1143 : mnOriginalTextPos = rCharPropSet.mnOriginalTextPos;
4342 1143 : maString = rCharPropSet.maString;
4343 1143 : mpFieldItem = ( rCharPropSet.mpFieldItem ) ? new SvxFieldItem( *rCharPropSet.mpFieldItem ) : NULL;
4344 1143 : mnLanguage[ 0 ] = mnLanguage[ 1 ] = mnLanguage[ 2 ] = 0;
4345 1143 : }
4346 :
4347 7118 : PPTCharPropSet::~PPTCharPropSet()
4348 : {
4349 3559 : if ( ! ( --pCharSet->mnRefCount ) )
4350 1145 : delete pCharSet;
4351 3559 : delete mpFieldItem;
4352 3559 : }
4353 :
4354 0 : PPTCharPropSet& PPTCharPropSet::operator=( const PPTCharPropSet& rCharPropSet )
4355 : {
4356 0 : if ( this != &rCharPropSet )
4357 : {
4358 0 : if ( ! ( --pCharSet->mnRefCount ) )
4359 0 : delete pCharSet;
4360 0 : pCharSet = rCharPropSet.pCharSet;
4361 0 : pCharSet->mnRefCount++;
4362 :
4363 0 : mnOriginalTextPos = rCharPropSet.mnOriginalTextPos;
4364 0 : mnParagraph = rCharPropSet.mnParagraph;
4365 0 : maString = rCharPropSet.maString;
4366 0 : mpFieldItem = ( rCharPropSet.mpFieldItem ) ? new SvxFieldItem( *rCharPropSet.mpFieldItem ) : NULL;
4367 : }
4368 0 : return *this;
4369 : }
4370 :
4371 35 : void PPTCharPropSet::ImplMakeUnique()
4372 : {
4373 35 : if ( pCharSet->mnRefCount > 1 )
4374 : {
4375 35 : ImplPPTCharPropSet& rOld = *pCharSet;
4376 35 : rOld.mnRefCount--;
4377 35 : pCharSet = new ImplPPTCharPropSet( rOld );
4378 35 : pCharSet->mnRefCount = 1;
4379 : }
4380 35 : }
4381 :
4382 35 : void PPTCharPropSet::SetFont( sal_uInt16 nFont )
4383 : {
4384 35 : sal_uInt32 nMask = 1 << PPT_CharAttr_Font;
4385 35 : sal_uInt32 bDoNotMake = pCharSet->mnAttrSet & nMask;
4386 :
4387 35 : if ( bDoNotMake )
4388 1 : bDoNotMake = nFont == pCharSet->mnFont;
4389 :
4390 35 : if ( !bDoNotMake )
4391 : {
4392 35 : ImplMakeUnique();
4393 35 : pCharSet->mnFont = nFont;
4394 35 : pCharSet->mnAttrSet |= nMask;
4395 : }
4396 35 : }
4397 :
4398 0 : void PPTCharPropSet::SetColor( sal_uInt32 nColor )
4399 : {
4400 0 : ImplMakeUnique();
4401 0 : pCharSet->mnColor = nColor;
4402 0 : pCharSet->mnAttrSet |= 1 << PPT_CharAttr_FontColor;
4403 0 : }
4404 :
4405 662 : PPTRuler::PPTRuler()
4406 : : nRefCount(1)
4407 : , nFlags(0)
4408 : , nDefaultTab(0x240)
4409 : , pTab(NULL)
4410 662 : , nTabCount(0)
4411 : {
4412 662 : memset(nTextOfs, 0, sizeof(nTextOfs));
4413 662 : memset(nBulletOfs, 0, sizeof(nBulletOfs));
4414 662 : }
4415 :
4416 662 : PPTRuler::~PPTRuler()
4417 : {
4418 662 : delete[] pTab;
4419 662 : };
4420 :
4421 :
4422 75 : PPTTextRulerInterpreter::PPTTextRulerInterpreter() :
4423 75 : mpImplRuler ( new PPTRuler() )
4424 : {
4425 75 : }
4426 :
4427 774 : PPTTextRulerInterpreter::PPTTextRulerInterpreter( PPTTextRulerInterpreter& rRuler )
4428 : {
4429 774 : mpImplRuler = rRuler.mpImplRuler;
4430 774 : mpImplRuler->nRefCount++;
4431 774 : }
4432 :
4433 587 : PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, SdrPowerPointImport& rMan, DffRecordHeader& rHeader, SvStream& rIn ) :
4434 587 : mpImplRuler ( new PPTRuler() )
4435 : {
4436 587 : if ( nFileOfs != 0xffffffff )
4437 : {
4438 554 : sal_uInt32 nOldPos = rIn.Tell();
4439 554 : DffRecordHeader rHd;
4440 554 : if ( nFileOfs )
4441 : {
4442 18 : rIn.Seek( nFileOfs );
4443 18 : rIn >> rHd;
4444 : }
4445 : else
4446 : {
4447 536 : rHeader.SeekToContent( rIn );
4448 536 : if ( rMan.SeekToRec( rIn, PPT_PST_TextRulerAtom, rHeader.GetRecEndFilePos(), &rHd ) )
4449 433 : nFileOfs++;
4450 : }
4451 554 : if ( nFileOfs )
4452 : {
4453 : sal_Int16 nTCount;
4454 : sal_Int32 i;
4455 451 : rIn >> mpImplRuler->nFlags;
4456 :
4457 : // number of indent levels, unused now
4458 451 : if ( mpImplRuler->nFlags & 2 )
4459 0 : rIn >> nTCount;
4460 451 : if ( mpImplRuler->nFlags & 1 )
4461 31 : rIn >> mpImplRuler->nDefaultTab;
4462 451 : if ( mpImplRuler->nFlags & 4 )
4463 : {
4464 24 : rIn >> nTCount;
4465 24 : if ( nTCount )
4466 : {
4467 24 : mpImplRuler->nTabCount = (sal_uInt16)nTCount;
4468 24 : mpImplRuler->pTab = new PPTTabEntry[ mpImplRuler->nTabCount ];
4469 114 : for ( i = 0; i < nTCount; i++ )
4470 : {
4471 90 : rIn >> mpImplRuler->pTab[ i ].nOffset
4472 180 : >> mpImplRuler->pTab[ i ].nStyle;
4473 : }
4474 : }
4475 : }
4476 2706 : for ( i = 0; i < 5; i++ )
4477 : {
4478 2255 : if ( mpImplRuler->nFlags & ( 8 << i ) )
4479 2053 : rIn >> mpImplRuler->nTextOfs[ i ];
4480 2255 : if ( mpImplRuler->nFlags & ( 256 << i ) )
4481 64 : rIn >> mpImplRuler->nBulletOfs[ i ];
4482 2255 : if( mpImplRuler->nBulletOfs[ i ] > 0x7fff)
4483 : {
4484 : // workaround
4485 : // when bullet offset is > 0x7fff, the paragraph should look like
4486 : // * first line text
4487 : // second line text
4488 : //
4489 : // we add to bullet para indent 0xffff - bullet offset. it looks like
4490 : // best we can do for now
4491 0 : mpImplRuler->nTextOfs[ i ] += 0xffff - mpImplRuler->nBulletOfs[ i ];
4492 0 : mpImplRuler->nBulletOfs[ i ] = 0;
4493 : }
4494 : }
4495 : }
4496 554 : rIn.Seek( nOldPos );
4497 : }
4498 587 : }
4499 :
4500 656 : sal_Bool PPTTextRulerInterpreter::GetDefaultTab( sal_uInt32 /*nLevel*/, sal_uInt16& nValue ) const
4501 : {
4502 656 : if ( ! ( mpImplRuler->nFlags & 1 ) )
4503 610 : return sal_False;
4504 46 : nValue = mpImplRuler->nDefaultTab;
4505 46 : return sal_True;
4506 : }
4507 :
4508 656 : sal_Bool PPTTextRulerInterpreter::GetTextOfs( sal_uInt32 nLevel, sal_uInt16& nValue ) const
4509 : {
4510 656 : if ( ! ( ( nLevel < 5 ) && ( mpImplRuler->nFlags & ( 8 << nLevel ) ) ) )
4511 236 : return sal_False;
4512 420 : nValue = mpImplRuler->nTextOfs[ nLevel ];
4513 420 : return sal_True;
4514 : }
4515 :
4516 656 : sal_Bool PPTTextRulerInterpreter::GetBulletOfs( sal_uInt32 nLevel, sal_uInt16& nValue ) const
4517 : {
4518 656 : if ( ! ( ( nLevel < 5 ) && ( mpImplRuler->nFlags & ( 256 << nLevel ) ) ) )
4519 648 : return sal_False;
4520 8 : nValue = mpImplRuler->nBulletOfs[ nLevel ];
4521 8 : return sal_True;
4522 : }
4523 :
4524 0 : PPTTextRulerInterpreter& PPTTextRulerInterpreter::operator=( PPTTextRulerInterpreter& rRuler )
4525 : {
4526 0 : if ( this != &rRuler )
4527 : {
4528 0 : if ( ! ( --mpImplRuler->nRefCount ) )
4529 0 : delete mpImplRuler;
4530 0 : mpImplRuler = rRuler.mpImplRuler;
4531 0 : mpImplRuler->nRefCount++;
4532 : }
4533 0 : return *this;
4534 : }
4535 :
4536 1436 : PPTTextRulerInterpreter::~PPTTextRulerInterpreter()
4537 : {
4538 1436 : if ( ! ( --mpImplRuler->nRefCount ) )
4539 662 : delete mpImplRuler;
4540 1436 : }
4541 :
4542 5 : PPTTextCharacterStyleAtomInterpreter::PPTTextCharacterStyleAtomInterpreter() :
4543 : nFlags1 ( 0 ),
4544 : nFlags2 ( 0 ),
4545 5 : nFlags3 ( 0 )
4546 : {
4547 5 : }
4548 :
4549 0 : sal_Bool PPTTextCharacterStyleAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader& rRecHd )
4550 : {
4551 0 : rRecHd.SeekToContent( rIn );
4552 :
4553 0 : rIn >> nFlags1
4554 0 : >> nFlags2
4555 0 : >> nFlags3
4556 0 : >> n1
4557 0 : >> nFontHeight
4558 0 : >> nFontColor;
4559 :
4560 0 : return sal_True;
4561 : }
4562 :
4563 5 : PPTTextCharacterStyleAtomInterpreter::~PPTTextCharacterStyleAtomInterpreter()
4564 : {
4565 5 : }
4566 :
4567 5 : PPTTextParagraphStyleAtomInterpreter::PPTTextParagraphStyleAtomInterpreter() :
4568 : bValid ( sal_False ),
4569 : bForbiddenRules ( sal_False ),
4570 : bHangingPunctuation ( sal_False ),
4571 5 : bLatinTextWrap ( sal_False )
4572 : {
4573 5 : }
4574 :
4575 2 : sal_Bool PPTTextParagraphStyleAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader& rRecHd )
4576 : {
4577 2 : bValid = sal_False;
4578 2 : rRecHd.SeekToContent( rIn );
4579 2 : sal_uInt32 nDummy32, nFlags, nRecEndPos = rRecHd.GetRecEndFilePos();
4580 : sal_uInt16 nDummy16;
4581 :
4582 2 : rIn >> nDummy16
4583 2 : >> nFlags;
4584 :
4585 2 : if ( nFlags & 0xf && ( rIn.Tell() < nRecEndPos ) )
4586 0 : rIn >> nDummy16; // BuFlags
4587 2 : if ( nFlags & 0x80 && ( rIn.Tell() < nRecEndPos ) )
4588 0 : rIn >> nDummy16; // BuChar
4589 2 : if ( nFlags & 0x10 && ( rIn.Tell() < nRecEndPos ) )
4590 0 : rIn >> nDummy16; // nBuFont;
4591 2 : if ( nFlags & 0x40 && ( rIn.Tell() < nRecEndPos ) )
4592 0 : rIn >> nDummy16; // nBuHeight;
4593 2 : if ( nFlags & 0x0020 && ( rIn.Tell() < nRecEndPos ) )
4594 0 : rIn >> nDummy32; // nBuColor;
4595 2 : if ( nFlags & 0x800 && ( rIn.Tell() < nRecEndPos ) )
4596 2 : rIn >> nDummy16; // AbsJust!
4597 2 : if ( nFlags & 0x400 && ( rIn.Tell() < nRecEndPos ) )
4598 0 : rIn >> nDummy16;
4599 2 : if ( nFlags & 0x200 && ( rIn.Tell() < nRecEndPos ) )
4600 0 : rIn >> nDummy16;
4601 2 : if ( nFlags & 0x100 && ( rIn.Tell() < nRecEndPos ) )
4602 0 : rIn >> nDummy16;
4603 2 : if ( nFlags & 0x1000 && ( rIn.Tell() < nRecEndPos ) )
4604 0 : rIn >> nDummy16; // LineFeed
4605 2 : if ( nFlags & 0x2000 && ( rIn.Tell() < nRecEndPos ) )
4606 0 : rIn >> nDummy16; // nUpperDist
4607 2 : if ( nFlags & 0x4000 && ( rIn.Tell() < nRecEndPos ) )
4608 0 : rIn >> nDummy16; // nLowerDist
4609 2 : if ( nFlags & 0x8000 && ( rIn.Tell() < nRecEndPos ) )
4610 0 : rIn >> nDummy16;
4611 2 : if ( nFlags & 0x10000 && ( rIn.Tell() < nRecEndPos ) )
4612 0 : rIn >> nDummy16;
4613 2 : if ( nFlags & 0xe0000 && ( rIn.Tell() < nRecEndPos ) )
4614 : {
4615 2 : rIn >> nDummy16;
4616 2 : if ( nFlags & 0x20000 )
4617 2 : bForbiddenRules = ( nDummy16 & 1 ) == 1;
4618 2 : if ( nFlags & 0x40000 )
4619 2 : bLatinTextWrap = ( nDummy16 & 2 ) == 0;
4620 2 : if ( nFlags & 0x80000 )
4621 2 : bHangingPunctuation = ( nDummy16 & 4 ) == 4;
4622 : }
4623 2 : nFlags &=~ 0xfffff;
4624 2 : sal_uInt32 nMask = 0x100000;
4625 8 : while ( nFlags && nMask && ( rIn.Tell() < nRecEndPos ) )
4626 : {
4627 4 : if ( nFlags & nMask )
4628 : {
4629 2 : rIn >> nDummy16;
4630 2 : nFlags ^= nMask;
4631 : }
4632 4 : nMask <<= 1;
4633 : }
4634 2 : bValid = rIn.Tell() == nRecEndPos;
4635 2 : return bValid;
4636 : }
4637 :
4638 5 : PPTTextParagraphStyleAtomInterpreter::~PPTTextParagraphStyleAtomInterpreter()
4639 : {
4640 :
4641 5 : }
4642 :
4643 759 : PPTTextSpecInfo::PPTTextSpecInfo( sal_uInt32 _nCharIdx ) :
4644 : nCharIdx ( _nCharIdx ),
4645 759 : nDontKnow ( 1 )
4646 : {
4647 759 : nLanguage[ 0 ] = 0x400;
4648 759 : nLanguage[ 1 ] = 0;
4649 759 : nLanguage[ 2 ] = 0;
4650 759 : }
4651 :
4652 765 : PPTTextSpecInfo::~PPTTextSpecInfo()
4653 : {
4654 765 : }
4655 :
4656 592 : PPTTextSpecInfoAtomInterpreter::PPTTextSpecInfoAtomInterpreter() :
4657 592 : bValid ( sal_False )
4658 : {
4659 592 : }
4660 :
4661 592 : sal_Bool PPTTextSpecInfoAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader& rRecHd,
4662 : sal_uInt16 nRecordType, const PPTTextSpecInfo* pTextSpecDefault )
4663 : {
4664 592 : bValid = sal_False;
4665 592 : sal_uInt32 nCharIdx = 0;
4666 592 : rRecHd.SeekToContent( rIn );
4667 :
4668 1937 : while ( rIn.Tell() < rRecHd.GetRecEndFilePos() )
4669 : {
4670 : sal_uInt32 nCharCount,
4671 : nFlags, i;
4672 :
4673 753 : if ( nRecordType == PPT_PST_TextSpecInfoAtom )
4674 : {
4675 748 : rIn >> nCharCount;
4676 748 : nCharIdx += nCharCount;
4677 : }
4678 753 : rIn >> nFlags;
4679 :
4680 753 : PPTTextSpecInfo* pEntry = new PPTTextSpecInfo( nCharIdx );
4681 753 : if ( pTextSpecDefault )
4682 : {
4683 748 : pEntry->nDontKnow = pTextSpecDefault->nDontKnow;
4684 748 : pEntry->nLanguage[ 0 ] = pTextSpecDefault->nLanguage[ 0 ];
4685 748 : pEntry->nLanguage[ 1 ] = pTextSpecDefault->nLanguage[ 1 ];
4686 748 : pEntry->nLanguage[ 2 ] = pTextSpecDefault->nLanguage[ 2 ];
4687 : }
4688 2957 : for ( i = 1; nFlags && i ; i <<= 1 )
4689 : {
4690 2204 : sal_uInt16 nLang = 0;
4691 2204 : switch( nFlags & i )
4692 : {
4693 580 : case 0 : break;
4694 170 : case 1 : rIn >> pEntry->nDontKnow; break;
4695 739 : case 2 : rIn >> nLang; break;
4696 715 : case 4 : rIn >> nLang; break;
4697 : default :
4698 : {
4699 0 : rIn.SeekRel( 2 );
4700 : }
4701 : }
4702 2204 : if ( nLang )
4703 : {
4704 1450 : sal_uInt16 nScriptType = GetI18NScriptTypeOfLanguage( nLang );
4705 1450 : if ( nScriptType & SCRIPTTYPE_LATIN )
4706 743 : pEntry->nLanguage[ 0 ] = nLang;
4707 1450 : if ( nScriptType & SCRIPTTYPE_ASIAN )
4708 707 : pEntry->nLanguage[ 1 ] = nLang;
4709 1450 : if ( nScriptType & SCRIPTTYPE_COMPLEX )
4710 0 : pEntry->nLanguage[ 2 ] = nLang;
4711 : }
4712 2204 : nFlags &= ~i;
4713 : }
4714 753 : aList.push_back( pEntry );
4715 : }
4716 592 : bValid = rIn.Tell() == rRecHd.GetRecEndFilePos();
4717 592 : return bValid;
4718 : }
4719 :
4720 1184 : PPTTextSpecInfoAtomInterpreter::~PPTTextSpecInfoAtomInterpreter()
4721 : {
4722 1345 : for ( size_t i = 0, n = aList.size(); i < n; ++i ) {
4723 753 : delete aList[ i ];
4724 : }
4725 592 : aList.clear();
4726 592 : }
4727 :
4728 1 : void StyleTextProp9::Read( SvStream& rIn )
4729 : {
4730 1 : rIn >> mnExtParagraphMask;
4731 1 : if ( mnExtParagraphMask & 0x800000 )
4732 0 : rIn >> mnBuBlip;
4733 1 : if ( mnExtParagraphMask & 0x2000000 )
4734 0 : rIn >> mnHasAnm;
4735 1 : if ( mnExtParagraphMask & 0x1000000 )
4736 0 : rIn >> mnAnmScheme;
4737 1 : if ( mnExtParagraphMask & 0x4000000 )
4738 0 : rIn >> mpfPP10Ext;
4739 1 : rIn >> mnExtCharacterMask;
4740 1 : if ( mnExtCharacterMask & 0x100000 )
4741 1 : rIn >> mncfPP10Ext;
4742 1 : rIn >> mnSpecialInfoMask;
4743 1 : if ( mnSpecialInfoMask & 0x20 )
4744 0 : rIn >> mnPP10Ext;
4745 1 : if ( mnSpecialInfoMask & 0x40 )
4746 0 : rIn >> mfBidi;
4747 1 : }
4748 :
4749 587 : PPTStyleTextPropReader::PPTStyleTextPropReader( SvStream& rIn, SdrPowerPointImport& rMan, const DffRecordHeader& rTextHeader,
4750 587 : PPTTextRulerInterpreter& rRuler, const DffRecordHeader& rExtParaHd, sal_uInt32 nInstance )
4751 : {
4752 587 : Init(rIn, rMan, rTextHeader, rRuler, rExtParaHd, nInstance);
4753 587 : }
4754 :
4755 587 : void PPTStyleTextPropReader::ReadParaProps( SvStream& rIn, SdrPowerPointImport& rMan, const DffRecordHeader& rTextHeader,
4756 : const String& aString, PPTTextRulerInterpreter& rRuler,
4757 : sal_uInt32& nCharCount, sal_Bool& bTextPropAtom )
4758 : {
4759 587 : sal_uInt32 nMask = 0; //TODO: nMask initialized here to suppress warning for now, see corresponding TODO below
4760 587 : sal_uInt32 nCharAnzRead = 0;
4761 : sal_uInt16 nDummy16;
4762 :
4763 587 : sal_uInt16 nStringLen = aString.Len();
4764 :
4765 587 : DffRecordHeader aTextHd2;
4766 587 : rTextHeader.SeekToContent( rIn );
4767 587 : if ( rMan.SeekToRec( rIn, PPT_PST_StyleTextPropAtom, rTextHeader.GetRecEndFilePos(), &aTextHd2 ) )
4768 576 : bTextPropAtom = sal_True;
4769 1830 : while ( nCharAnzRead <= nStringLen )
4770 : {
4771 656 : PPTParaPropSet aParaPropSet;
4772 656 : ImplPPTParaPropSet& aSet = *aParaPropSet.pParaSet;
4773 656 : if ( bTextPropAtom )
4774 : {
4775 645 : rIn >> nCharCount
4776 1290 : >> aParaPropSet.pParaSet->mnDepth; // indent depth
4777 :
4778 : aParaPropSet.pParaSet->mnDepth = // taking care of about using not more than 9 outliner levels
4779 : std::min(sal_uInt16(8),
4780 645 : aParaPropSet.pParaSet->mnDepth);
4781 :
4782 645 : nCharCount--;
4783 :
4784 645 : rIn >> nMask;
4785 645 : aSet.mnAttrSet = nMask & 0x207df7;
4786 645 : sal_uInt16 nBulFlg = 0;
4787 645 : if ( nMask & 0xF )
4788 455 : rIn >> nBulFlg; // Bullet-HardAttr-Flags
4789 645 : aSet.mpArry[ PPT_ParaAttr_BulletOn ] = ( nBulFlg & 1 ) ? 1 : 0;
4790 645 : aSet.mpArry[ PPT_ParaAttr_BuHardFont ] = ( nBulFlg & 2 ) ? 1 : 0;
4791 645 : aSet.mpArry[ PPT_ParaAttr_BuHardColor ] = ( nBulFlg & 4 ) ? 1 : 0;
4792 :
4793 645 : if ( nMask & 0x0080 ) // buChar
4794 37 : rIn >> aSet.mpArry[ PPT_ParaAttr_BulletChar ];
4795 645 : if ( nMask & 0x0010 ) // buTypeface
4796 41 : rIn >> aSet.mpArry[ PPT_ParaAttr_BulletFont ];
4797 645 : if ( nMask & 0x0040 ) // buSize
4798 : {
4799 28 : rIn >> aSet.mpArry[ PPT_ParaAttr_BulletHeight ];
4800 28 : if ( ! ( ( nMask & ( 1 << PPT_ParaAttr_BuHardHeight ) )
4801 56 : && ( nBulFlg & ( 1 << PPT_ParaAttr_BuHardHeight ) ) ) )
4802 1 : aSet.mnAttrSet ^= 0x40;
4803 : }
4804 645 : if ( nMask & 0x0020 ) // buColor
4805 : {
4806 : sal_uInt32 nVal32, nHiByte;
4807 41 : rIn >> nVal32;
4808 41 : nHiByte = nVal32 >> 24;
4809 41 : if ( nHiByte <= 8 )
4810 16 : nVal32 = nHiByte | PPT_COLSCHEME;
4811 41 : aSet.mnBulletColor = nVal32;
4812 : }
4813 645 : if ( nMask & 0x0800 ) // pfAlignment
4814 : {
4815 439 : rIn >> nDummy16;
4816 439 : aSet.mpArry[ PPT_ParaAttr_Adjust ] = nDummy16 & 3;
4817 : }
4818 645 : if ( nMask & 0x1000 ) // pfLineSpacing
4819 79 : rIn >> aSet.mpArry[ PPT_ParaAttr_LineFeed ];
4820 645 : if ( nMask & 0x2000 ) // pfSpaceBefore
4821 28 : rIn >> aSet.mpArry[ PPT_ParaAttr_UpperDist ];
4822 645 : if ( nMask & 0x4000 ) // pfSpaceAfter
4823 1 : rIn >> aSet.mpArry[ PPT_ParaAttr_LowerDist ];
4824 645 : if ( nMask & 0x100 ) // pfLeftMargin
4825 0 : rIn >> nDummy16;
4826 645 : if ( nMask & 0x400 ) // pfIndent
4827 0 : rIn >> nDummy16;
4828 645 : if ( nMask & 0x8000 ) // pfDefaultTabSize
4829 0 : rIn >> nDummy16;
4830 645 : if ( nMask & 0x100000 ) // pfTabStops
4831 : {
4832 0 : sal_uInt16 i, nDistance, nAlignment, nNumberOfTabStops = 0;
4833 0 : rIn >> nNumberOfTabStops;
4834 0 : for ( i = 0; i < nNumberOfTabStops; i++ )
4835 : {
4836 0 : rIn >> nDistance
4837 0 : >> nAlignment;
4838 : }
4839 : }
4840 645 : if ( nMask & 0x10000 ) // pfBaseLine
4841 0 : rIn >> nDummy16;
4842 645 : if ( nMask & 0xe0000 ) // pfCharWrap, pfWordWrap, pfOverflow
4843 : {
4844 99 : rIn >> nDummy16;
4845 99 : if ( nMask & 0x20000 )
4846 99 : aSet.mpArry[ PPT_ParaAttr_AsianLB_1 ] = nDummy16 & 1;
4847 99 : if ( nMask & 0x40000 )
4848 0 : aSet.mpArry[ PPT_ParaAttr_AsianLB_2 ] = ( nDummy16 >> 1 ) & 1;
4849 99 : if ( nMask & 0x80000 )
4850 75 : aSet.mpArry[ PPT_ParaAttr_AsianLB_3 ] = ( nDummy16 >> 2 ) & 1;
4851 99 : aSet.mnAttrSet |= ( ( nMask >> 17 ) & 7 ) << PPT_ParaAttr_AsianLB_1;
4852 : }
4853 645 : if ( nMask & 0x200000 ) // pfTextDirection
4854 0 : rIn >> aSet.mpArry[ PPT_ParaAttr_BiDi ];
4855 : }
4856 : else
4857 11 : nCharCount = nStringLen;
4858 :
4859 656 : if ( rRuler.GetTextOfs( aParaPropSet.pParaSet->mnDepth, aSet.mpArry[ PPT_ParaAttr_TextOfs ] ) )
4860 420 : aSet.mnAttrSet |= 1 << PPT_ParaAttr_TextOfs;
4861 656 : if ( rRuler.GetBulletOfs( aParaPropSet.pParaSet->mnDepth, aSet.mpArry[ PPT_ParaAttr_BulletOfs ] ) )
4862 8 : aSet.mnAttrSet |= 1 << PPT_ParaAttr_BulletOfs;
4863 656 : if ( rRuler.GetDefaultTab( aParaPropSet.pParaSet->mnDepth, aSet.mpArry[ PPT_ParaAttr_DefaultTab ] ) )
4864 46 : aSet.mnAttrSet |= 1 << PPT_ParaAttr_DefaultTab;
4865 :
4866 656 : if ( ( nCharCount > nStringLen ) || ( nStringLen < nCharAnzRead + nCharCount ) )
4867 : {
4868 0 : bTextPropAtom = sal_False;
4869 0 : nCharCount = nStringLen - nCharAnzRead;
4870 : // please fix the right hand side of
4871 : // PPTParaPropSet& PPTParaPropSet::operator=(PPTParaPropSet&),
4872 : // it should be a const reference
4873 0 : PPTParaPropSet aTmpPPTParaPropSet;
4874 0 : aParaPropSet = aTmpPPTParaPropSet;
4875 0 : OSL_FAIL( "SJ:PPTStyleTextPropReader::could not get this PPT_PST_StyleTextPropAtom by reading the paragraph attributes" );
4876 : }
4877 656 : PPTParaPropSet* pPara = new PPTParaPropSet( aParaPropSet );
4878 656 : pPara->mnOriginalTextPos = nCharAnzRead;
4879 656 : aParaPropList.push_back( pPara );
4880 656 : if ( nCharCount )
4881 : {
4882 : sal_uInt32 nCount;
4883 604 : const sal_Unicode* pDat = aString.GetBuffer() + nCharAnzRead;
4884 13018 : for ( nCount = 0; nCount < nCharCount; nCount++ )
4885 : {
4886 12414 : if ( pDat[ nCount ] == 0xd )
4887 : {
4888 118 : pPara = new PPTParaPropSet( aParaPropSet );
4889 118 : pPara->mnOriginalTextPos = nCharAnzRead + nCount + 1;
4890 118 : aParaPropList.push_back( pPara );
4891 : }
4892 : }
4893 : }
4894 656 : nCharAnzRead += nCharCount + 1;
4895 656 : }
4896 587 : }
4897 :
4898 1024 : void PPTStyleTextPropReader::ReadCharProps( SvStream& rIn, PPTCharPropSet& aCharPropSet, const String& aString,
4899 : sal_uInt32& nCharCount, sal_uInt32 nCharAnzRead,
4900 : sal_Bool& bTextPropAtom, sal_uInt32 nExtParaPos,
4901 : const std::vector< StyleTextProp9 >& aStyleTextProp9,
4902 : sal_uInt32& nExtParaFlags, sal_uInt16& nBuBlip,
4903 : sal_uInt16& nHasAnm, sal_uInt32& nAnmScheme )
4904 : {
4905 1024 : sal_uInt32 nMask = 0; //TODO: nMask initialized here to suppress warning for now, see corresponding TODO below
4906 : sal_uInt16 nDummy16;
4907 : sal_Int32 nCharsToRead;
4908 1024 : sal_uInt16 nStringLen = aString.Len();
4909 :
4910 1024 : rIn >> nDummy16;
4911 1024 : nCharCount = nDummy16;
4912 1024 : rIn >> nDummy16;
4913 1024 : nCharsToRead = nStringLen - ( nCharAnzRead + nCharCount );
4914 1024 : if ( nCharsToRead < 0 )
4915 : {
4916 560 : nCharCount = nStringLen - nCharAnzRead;
4917 560 : if ( nCharsToRead < -1 )
4918 : {
4919 1 : bTextPropAtom = sal_False;
4920 : OSL_FAIL( "SJ:PPTStyleTextPropReader::could not get this PPT_PST_StyleTextPropAtom by reading the character attributes" );
4921 : }
4922 : }
4923 1024 : ImplPPTCharPropSet& aSet = *aCharPropSet.pCharSet;
4924 :
4925 : // character attributes
4926 1024 : rIn >> nMask;
4927 1024 : if ( (sal_uInt16)nMask )
4928 : {
4929 811 : aSet.mnAttrSet |= (sal_uInt16)nMask;
4930 811 : rIn >> aSet.mnFlags;
4931 : }
4932 1024 : if ( nMask & 0x10000 ) // cfTypeface
4933 : {
4934 167 : rIn >> aSet.mnFont;
4935 167 : aSet.mnAttrSet |= 1 << PPT_CharAttr_Font;
4936 : }
4937 1024 : if ( nMask & 0x200000 ) // cfFEOldTypeface
4938 : {
4939 964 : rIn >> aSet.mnAsianOrComplexFont;
4940 964 : aSet.mnAttrSet |= 1 << PPT_CharAttr_AsianOrComplexFont;
4941 : }
4942 1024 : if ( nMask & 0x400000 ) // cfANSITypeface
4943 : {
4944 965 : rIn >> aSet.mnANSITypeface;
4945 965 : aSet.mnAttrSet |= 1 << PPT_CharAttr_ANSITypeface;
4946 : }
4947 1024 : if ( nMask & 0x800000 ) // cfSymbolTypeface
4948 : {
4949 141 : rIn >> aSet.mnSymbolFont;
4950 141 : aSet.mnAttrSet |= 1 << PPT_CharAttr_Symbol;
4951 : }
4952 1024 : if ( nMask & 0x20000 ) // cfSize
4953 : {
4954 685 : rIn >> aSet.mnFontHeight;
4955 685 : aSet.mnAttrSet |= 1 << PPT_CharAttr_FontHeight;
4956 : }
4957 1024 : if ( nMask & 0x40000 ) // cfColor
4958 : {
4959 : sal_uInt32 nVal;
4960 601 : rIn >> nVal;
4961 601 : if ( !( nVal & 0xff000000 ) )
4962 0 : nVal = PPT_COLSCHEME_HINTERGRUND;
4963 601 : aSet.mnColor = nVal;
4964 601 : aSet.mnAttrSet |= 1 << PPT_CharAttr_FontColor;
4965 : }
4966 1024 : if ( nMask & 0x80000 ) // cfPosition
4967 : {
4968 26 : rIn >> aSet.mnEscapement;
4969 26 : aSet.mnAttrSet |= 1 << PPT_CharAttr_Escapement;
4970 : }
4971 1024 : if ( nExtParaPos )
4972 : {
4973 1 : sal_uInt32 nExtBuInd = nMask & 0x3c00;
4974 1 : sal_uInt32 nExtParaNibble = 0;
4975 1 : if ( nExtBuInd )
4976 0 : nExtBuInd = ( aSet.mnFlags & 0x3c00 ) >> 10;
4977 1 : if ( nExtBuInd < aStyleTextProp9.size() )
4978 : {
4979 1 : if ( nExtParaNibble && ( ( nExtBuInd + nExtParaNibble ) < aStyleTextProp9.size() ) )
4980 0 : nExtBuInd += nExtParaNibble;
4981 :
4982 1 : nExtParaFlags = aStyleTextProp9[ nExtBuInd ].mnExtParagraphMask;
4983 1 : nBuBlip = aStyleTextProp9[ nExtBuInd ].mnBuBlip;
4984 1 : nHasAnm = aStyleTextProp9[ nExtBuInd ].mnHasAnm;
4985 1 : nAnmScheme = aStyleTextProp9[ nExtBuInd ].mnAnmScheme;
4986 : }
4987 1 : if ( ( nExtBuInd & 0xf ) == 0xf )
4988 0 : nExtParaNibble += 16;
4989 : }
4990 1024 : }
4991 :
4992 587 : void PPTStyleTextPropReader::Init( SvStream& rIn, SdrPowerPointImport& rMan, const DffRecordHeader& rTextHeader,
4993 : PPTTextRulerInterpreter& rRuler, const DffRecordHeader& rExtParaHd, sal_uInt32 nInstance )
4994 : {
4995 587 : sal_uInt32 nMerk = rIn.Tell();
4996 587 : sal_uInt32 nExtParaPos = ( rExtParaHd.nRecType == PPT_PST_ExtendedParagraphAtom ) ? rExtParaHd.nFilePos + 8 : 0;
4997 :
4998 587 : std::vector< StyleTextProp9 > aStyleTextProp9;
4999 587 : if ( rExtParaHd.nRecType == PPT_PST_ExtendedParagraphAtom )
5000 : {
5001 1 : rIn.Seek( rExtParaHd.nFilePos + 8 );
5002 3 : while( ( rIn.GetError() == 0 ) && ( rIn.Tell() < rExtParaHd.GetRecEndFilePos() ) )
5003 : {
5004 1 : aStyleTextProp9.resize( aStyleTextProp9.size() + 1 );
5005 1 : aStyleTextProp9.back().Read( rIn );
5006 : }
5007 1 : rIn.Seek( nMerk );
5008 : }
5009 :
5010 587 : String aString;
5011 587 : DffRecordHeader aTextHd;
5012 587 : rIn >> aTextHd;
5013 587 : sal_uInt32 nMaxLen = aTextHd.nRecLen;
5014 587 : if ( nMaxLen >= 0xFFFF )
5015 0 : nMaxLen = 0xFFFE;
5016 :
5017 587 : if( aTextHd.nRecType == PPT_PST_TextCharsAtom )
5018 : {
5019 : sal_uInt32 i;
5020 83 : sal_Unicode nChar,*pBuf = new sal_Unicode[ ( nMaxLen >> 1 ) + 1 ];
5021 83 : rIn.Read( pBuf, nMaxLen );
5022 83 : nMaxLen >>= 1;
5023 83 : pBuf[ nMaxLen ] = 0;
5024 83 : sal_Unicode* pPtr = pBuf;
5025 : #ifdef OSL_BIGENDIAN
5026 : sal_Unicode nTemp;
5027 : for ( i = 0; i < nMaxLen; i++ )
5028 : {
5029 : nTemp = *pPtr;
5030 : *pPtr++ = ( nTemp << 8 ) | ( nTemp >> 8 );
5031 : }
5032 : pPtr = pBuf;
5033 : #endif
5034 :
5035 5062 : for ( i = 0; i < nMaxLen; pPtr++, i++ )
5036 : {
5037 4979 : nChar = *pPtr;
5038 4979 : if ( !nChar )
5039 0 : break;
5040 4979 : if ( ( nChar & 0xff00 ) == 0xf000 ) // in this special case we got a symbol
5041 35 : aSpecMarkerList.push_back( (sal_uInt32)( i | PPT_SPEC_SYMBOL ) );
5042 4944 : else if ( nChar == 0xd )
5043 : {
5044 111 : if ( nInstance == TSS_TYPE_PAGETITLE )
5045 0 : *pPtr = 0xb;
5046 : else
5047 111 : aSpecMarkerList.push_back( (sal_uInt32)( i | PPT_SPEC_NEWLINE ) );
5048 : }
5049 : }
5050 83 : if ( i )
5051 83 : aString = rtl::OUString(pBuf, i);
5052 83 : delete[] pBuf;
5053 : }
5054 504 : else if( aTextHd.nRecType == PPT_PST_TextBytesAtom )
5055 : {
5056 453 : sal_Char *pBuf = new sal_Char[ nMaxLen + 1 ];
5057 453 : pBuf[ nMaxLen ] = 0;
5058 453 : rIn.Read( pBuf, nMaxLen );
5059 453 : sal_Char* pPtr = pBuf;
5060 7504 : for (;;)
5061 : {
5062 7957 : sal_Char cLo = *pPtr;
5063 7957 : if ( cLo == 0 )
5064 453 : break;
5065 7504 : if ( cLo == 0xd )
5066 : {
5067 76 : if ( nInstance == TSS_TYPE_PAGETITLE )
5068 0 : *pPtr = 0xb;
5069 : else
5070 76 : aSpecMarkerList.push_back( (sal_uInt32)( (pPtr - pBuf) | PPT_SPEC_NEWLINE ) );
5071 : }
5072 7504 : pPtr++;
5073 : }
5074 453 : xub_StrLen nLen = sal::static_int_cast< xub_StrLen >( pPtr - pBuf );
5075 453 : if ( nLen )
5076 453 : aString = String( pBuf, nLen, RTL_TEXTENCODING_MS_1252 );
5077 453 : delete[] pBuf;
5078 : }
5079 : else
5080 : {
5081 : // no chars, but potentially char/para props?
5082 : sal_uInt32 nCharCount;
5083 51 : sal_Bool bTextPropAtom = sal_False;
5084 51 : ReadParaProps( rIn, rMan, rTextHeader, aString, rRuler, nCharCount, bTextPropAtom );
5085 :
5086 51 : if ( bTextPropAtom )
5087 : {
5088 : // yeah, StyleTextProp is there, read it all & push to
5089 : // aParaPropList
5090 51 : PPTCharPropSet aCharPropSet(0);
5091 51 : aCharPropSet.mnOriginalTextPos = 0;
5092 :
5093 51 : sal_uInt32 nCharAnzRead = 0;
5094 51 : sal_uInt32 nExtParaFlags = 0, nAnmScheme = 0;
5095 51 : sal_uInt16 nBuBlip = 0xffff, nHasAnm = 0;
5096 : ReadCharProps( rIn, aCharPropSet, aString, nCharCount, nCharAnzRead,
5097 : bTextPropAtom, nExtParaPos, aStyleTextProp9, nExtParaFlags,
5098 51 : nBuBlip, nHasAnm, nAnmScheme );
5099 :
5100 51 : aCharPropList.push_back( new PPTCharPropSet( aCharPropSet, 0 ) );
5101 : }
5102 : }
5103 :
5104 587 : if ( aString.Len() )
5105 : {
5106 : sal_uInt32 nCharCount;
5107 536 : sal_Bool bTextPropAtom = sal_False;
5108 :
5109 536 : ReadParaProps( rIn, rMan, rTextHeader, aString, rRuler, nCharCount, bTextPropAtom );
5110 :
5111 536 : sal_Bool bEmptyParaPossible = sal_True;
5112 536 : sal_uInt32 nCharAnzRead = 0;
5113 536 : sal_uInt32 nCurrentPara = 0;
5114 536 : size_t i = 1; // points to the next element to process
5115 536 : sal_uInt32 nCurrentSpecMarker = aSpecMarkerList.empty() ? 0 : aSpecMarkerList[0];
5116 536 : sal_uInt32 nStringLen = aString.Len();
5117 :
5118 2054 : while ( nCharAnzRead < nStringLen )
5119 : {
5120 982 : sal_uInt32 nExtParaFlags = 0, nLatestParaUpdate = 0xffffffff, nAnmScheme = 0;
5121 982 : sal_uInt16 nBuBlip = 0xffff, nHasAnm = 0;
5122 :
5123 982 : PPTCharPropSet aCharPropSet( nCurrentPara );
5124 982 : if ( bTextPropAtom )
5125 : {
5126 971 : if( nCharAnzRead == ( nStringLen - 1 ) && aString.GetChar( nCharAnzRead ) == '\r' )
5127 : {
5128 : /* n#782833: Seems like the new line character at end of the para
5129 : * has two char properties and we would need to use the next one.
5130 : */
5131 2 : PPTCharPropSet aDummyCharPropSet( nCurrentPara );
5132 : ReadCharProps( rIn, aDummyCharPropSet, aString, nCharCount, nCharAnzRead,
5133 : bTextPropAtom, nExtParaPos, aStyleTextProp9, nExtParaFlags,
5134 2 : nBuBlip, nHasAnm, nAnmScheme );
5135 2 : bEmptyParaPossible = true;
5136 : }
5137 : ReadCharProps( rIn, aCharPropSet, aString, nCharCount, nCharAnzRead,
5138 : bTextPropAtom, nExtParaPos, aStyleTextProp9, nExtParaFlags,
5139 971 : nBuBlip, nHasAnm, nAnmScheme );
5140 : }
5141 : else
5142 : {
5143 11 : nCharCount = nStringLen;
5144 : }
5145 :
5146 : sal_uInt32 nLen;
5147 2186 : while( nCharCount )
5148 : {
5149 1089 : if ( nExtParaPos && ( nLatestParaUpdate != nCurrentPara ) && ( nCurrentPara < aParaPropList.size() ) )
5150 : {
5151 1 : PPTParaPropSet* pPropSet = aParaPropList[ nCurrentPara ];
5152 1 : pPropSet->pParaSet->mnExtParagraphMask = nExtParaFlags;
5153 1 : if ( nExtParaFlags & 0x800000 )
5154 0 : pPropSet->pParaSet->mnBuBlip = nBuBlip;
5155 1 : if ( nExtParaFlags & 0x01000000 )
5156 0 : pPropSet->pParaSet->mnAnmScheme = nAnmScheme;
5157 1 : if ( nExtParaFlags & 0x02000000 )
5158 0 : pPropSet->pParaSet->mnHasAnm = nHasAnm;
5159 1 : nLatestParaUpdate = nCurrentPara;
5160 : }
5161 1089 : aCharPropSet.mnOriginalTextPos = nCharAnzRead;
5162 1089 : if ( nCurrentSpecMarker && ( ( nCurrentSpecMarker & 0xffff ) < ( nCharAnzRead + nCharCount ) ) )
5163 : {
5164 222 : if ( nCurrentSpecMarker & PPT_SPEC_NEWLINE )
5165 : {
5166 187 : nLen = ( nCurrentSpecMarker & 0xffff ) - nCharAnzRead;
5167 187 : if ( nLen )
5168 167 : aCharPropSet.maString = String( aString, (sal_uInt16)nCharAnzRead, (sal_uInt16)nLen );
5169 20 : else if ( bEmptyParaPossible )
5170 8 : aCharPropSet.maString = String();
5171 187 : if ( nLen || bEmptyParaPossible )
5172 175 : aCharPropList.push_back( new PPTCharPropSet( aCharPropSet, nCurrentPara ) );
5173 187 : nCurrentPara++;
5174 187 : nLen++;
5175 187 : nCharAnzRead += nLen;
5176 187 : nCharCount -= nLen;
5177 187 : bEmptyParaPossible = sal_True;
5178 : }
5179 35 : else if ( nCurrentSpecMarker & PPT_SPEC_SYMBOL )
5180 : {
5181 35 : if ( ( nCurrentSpecMarker & 0xffff ) != nCharAnzRead )
5182 : {
5183 8 : nLen = ( nCurrentSpecMarker & 0xffff ) - nCharAnzRead;
5184 8 : aCharPropSet.maString = String( aString, (sal_uInt16)nCharAnzRead, (sal_uInt16)nLen );
5185 8 : aCharPropList.push_back( new PPTCharPropSet( aCharPropSet, nCurrentPara ) );
5186 8 : nCharCount -= nLen;
5187 8 : nCharAnzRead += nLen;
5188 : }
5189 35 : PPTCharPropSet* pCPropSet = new PPTCharPropSet( aCharPropSet, nCurrentPara );
5190 35 : pCPropSet->maString = aString.GetChar( (sal_uInt16)nCharAnzRead );
5191 35 : if ( aCharPropSet.pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_Symbol ) )
5192 35 : pCPropSet->SetFont( aCharPropSet.pCharSet->mnSymbolFont );
5193 35 : aCharPropList.push_back( pCPropSet );
5194 35 : nCharCount--;
5195 35 : nCharAnzRead++;
5196 35 : bEmptyParaPossible = sal_False;
5197 : }
5198 222 : nCurrentSpecMarker = ( i < aSpecMarkerList.size() ) ? aSpecMarkerList[ i++ ] : 0;
5199 : }
5200 : else
5201 : {
5202 867 : aCharPropSet.maString = String( aString, (sal_uInt16)nCharAnzRead, (sal_uInt16)nCharCount );
5203 867 : aCharPropList.push_back( new PPTCharPropSet( aCharPropSet, nCurrentPara ) );
5204 867 : nCharAnzRead += nCharCount;
5205 867 : bEmptyParaPossible = sal_False;
5206 867 : break;
5207 : }
5208 : }
5209 982 : }
5210 536 : if ( !aCharPropList.empty() && ( aCharPropList.back()->mnParagraph != nCurrentPara ) )
5211 : {
5212 7 : PPTCharPropSet* pCharPropSet = new PPTCharPropSet( *aCharPropList.back(), nCurrentPara );
5213 7 : pCharPropSet->maString = String();
5214 7 : pCharPropSet->mnOriginalTextPos = nStringLen - 1;
5215 7 : aCharPropList.push_back( pCharPropSet );
5216 : }
5217 : }
5218 587 : rIn.Seek( nMerk );
5219 587 : }
5220 :
5221 1174 : PPTStyleTextPropReader::~PPTStyleTextPropReader()
5222 : {
5223 1361 : for ( PPTParaPropSetList::const_iterator it = aParaPropList.begin(); it != aParaPropList.end(); ++it )
5224 774 : delete *it;
5225 1774 : for ( PPTCharPropSetList::const_iterator it = aCharPropList.begin(); it != aCharPropList.end(); ++it )
5226 1187 : delete *it;
5227 587 : }
5228 :
5229 : struct FieldEntry
5230 : {
5231 : sal_uInt32 nFieldType;
5232 : sal_uInt32 nFieldStartPos;
5233 : sal_uInt32 nFieldEndPos;
5234 : String aFieldUrl;
5235 :
5236 : FieldEntry( sal_uInt32 nType, sal_uInt32 nStart, sal_uInt32 nEnd )
5237 : {
5238 : nFieldType = nType;
5239 : nFieldStartPos = nStart;
5240 : nFieldEndPos = nEnd;
5241 : }
5242 : FieldEntry( FieldEntry& rFieldEntry )
5243 : {
5244 : nFieldType = rFieldEntry.nFieldType;
5245 : nFieldStartPos = rFieldEntry.nFieldStartPos;
5246 : nFieldEndPos = rFieldEntry.nFieldEndPos;
5247 : aFieldUrl = rFieldEntry.aFieldUrl;
5248 : }
5249 : };
5250 :
5251 :
5252 75 : PPTPortionObj::PPTPortionObj( const PPTStyleSheet& rStyleSheet, sal_uInt32 nInstance, sal_uInt32 nDepth ) :
5253 : PPTCharPropSet ( 0 ),
5254 : mrStyleSheet ( rStyleSheet ),
5255 : mnInstance ( nInstance ),
5256 75 : mnDepth ( ( nDepth > 4 ) ? 4 : nDepth )
5257 : {
5258 75 : }
5259 :
5260 1187 : PPTPortionObj::PPTPortionObj( const PPTCharPropSet& rCharPropSet, const PPTStyleSheet& rStyleSheet, sal_uInt32 nInstance, sal_uInt32 nDepth ) :
5261 : PPTCharPropSet ( rCharPropSet ),
5262 : mrStyleSheet ( rStyleSheet ),
5263 : mnInstance ( nInstance ),
5264 1187 : mnDepth ( nDepth )
5265 : {
5266 1187 : }
5267 :
5268 75 : PPTPortionObj::PPTPortionObj( const PPTPortionObj& rPortionObj ) :
5269 : PPTCharPropSet ( rPortionObj ),
5270 : mrStyleSheet ( rPortionObj.mrStyleSheet ),
5271 : mnInstance ( rPortionObj.mnInstance ),
5272 75 : mnDepth ( rPortionObj.mnDepth )
5273 : {
5274 75 : }
5275 :
5276 1337 : PPTPortionObj::~PPTPortionObj()
5277 : {
5278 1337 : }
5279 :
5280 1180 : sal_Bool PPTPortionObj::HasTabulator()
5281 : {
5282 1180 : sal_Bool bRetValue = sal_False;
5283 : sal_Int32 nCount;
5284 1180 : const sal_Unicode* pPtr = maString.GetBuffer();
5285 13316 : for ( nCount = 0; nCount < maString.Len(); nCount++ )
5286 : {
5287 12145 : if ( pPtr[ nCount ] == 0x9 )
5288 : {
5289 9 : bRetValue = sal_True;
5290 9 : break;
5291 : }
5292 :
5293 : }
5294 1180 : return bRetValue;
5295 : }
5296 :
5297 17699 : sal_Bool PPTPortionObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& nRetValue, sal_uInt32 nDestinationInstance ) const
5298 : {
5299 17699 : sal_uInt32 nMask = 1 << nAttr;
5300 17699 : nRetValue = 0;
5301 :
5302 17699 : sal_uInt32 bIsHardAttribute = ( ( pCharSet->mnAttrSet & nMask ) != 0 ) ? 1 : 0;
5303 :
5304 17699 : if ( bIsHardAttribute )
5305 : {
5306 4595 : switch ( nAttr )
5307 : {
5308 : case PPT_CharAttr_Bold :
5309 : case PPT_CharAttr_Italic :
5310 : case PPT_CharAttr_Underline :
5311 : case PPT_CharAttr_Shadow :
5312 : case PPT_CharAttr_Strikeout :
5313 : case PPT_CharAttr_Embossed :
5314 629 : nRetValue = ( pCharSet->mnFlags & nMask ) ? 1 : 0;
5315 629 : break;
5316 : case PPT_CharAttr_Font :
5317 575 : nRetValue = pCharSet->mnFont;
5318 575 : break;
5319 : case PPT_CharAttr_AsianOrComplexFont :
5320 1082 : nRetValue = pCharSet->mnAsianOrComplexFont;
5321 1082 : break;
5322 : case PPT_CharAttr_FontHeight :
5323 1613 : nRetValue = pCharSet->mnFontHeight;
5324 1613 : break;
5325 : case PPT_CharAttr_FontColor :
5326 671 : nRetValue = pCharSet->mnColor;
5327 671 : break;
5328 : case PPT_CharAttr_Escapement :
5329 25 : nRetValue = pCharSet->mnEscapement;
5330 25 : break;
5331 : default :
5332 : OSL_FAIL( "SJ:PPTPortionObj::GetAttrib ( hard attribute does not exist )" );
5333 : }
5334 : }
5335 : else
5336 : {
5337 13104 : const PPTCharLevel& rCharLevel = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ mnDepth ];
5338 13104 : PPTCharLevel* pCharLevel = NULL;
5339 13104 : if ( ( nDestinationInstance == 0xffffffff )
5340 : || ( mnDepth && ( ( mnInstance == TSS_TYPE_SUBTITLE ) || ( mnInstance == TSS_TYPE_TEXT_IN_SHAPE ) ) ) )
5341 1063 : bIsHardAttribute = 1;
5342 12041 : else if ( nDestinationInstance != mnInstance )
5343 5450 : pCharLevel = &mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ mnDepth ];
5344 13104 : switch( nAttr )
5345 : {
5346 : case PPT_CharAttr_Bold :
5347 : case PPT_CharAttr_Italic :
5348 : case PPT_CharAttr_Underline :
5349 : case PPT_CharAttr_Shadow :
5350 : case PPT_CharAttr_Strikeout :
5351 : case PPT_CharAttr_Embossed :
5352 : {
5353 6943 : nRetValue = ( rCharLevel.mnFlags & nMask ) ? 1 : 0;
5354 6943 : if ( pCharLevel )
5355 : {
5356 3233 : sal_uInt32 nTmp = ( pCharLevel->mnFlags & nMask ) ? 1 : 0;
5357 3233 : if ( nRetValue != nTmp )
5358 3 : bIsHardAttribute = 1;
5359 : }
5360 : }
5361 6943 : break;
5362 : case PPT_CharAttr_Font :
5363 : {
5364 2853 : nRetValue = rCharLevel.mnFont;
5365 2853 : if ( pCharLevel && ( nRetValue != pCharLevel->mnFont ) )
5366 913 : bIsHardAttribute = 1;
5367 : }
5368 2853 : break;
5369 : case PPT_CharAttr_AsianOrComplexFont :
5370 : {
5371 180 : nRetValue = rCharLevel.mnAsianOrComplexFont;
5372 180 : if ( pCharLevel && ( nRetValue != pCharLevel->mnAsianOrComplexFont ) )
5373 0 : bIsHardAttribute = 1;
5374 : }
5375 180 : break;
5376 : case PPT_CharAttr_FontHeight :
5377 : {
5378 1143 : nRetValue = rCharLevel.mnFontHeight;
5379 1143 : if ( pCharLevel && ( nRetValue != pCharLevel->mnFontHeight ) )
5380 368 : bIsHardAttribute = 1;
5381 : }
5382 1143 : break;
5383 : case PPT_CharAttr_FontColor :
5384 : {
5385 748 : nRetValue = rCharLevel.mnFontColor;
5386 748 : if ( pCharLevel && ( nRetValue != pCharLevel->mnFontColor ) )
5387 6 : bIsHardAttribute = 1;
5388 : }
5389 748 : break;
5390 : case PPT_CharAttr_Escapement :
5391 : {
5392 1237 : nRetValue = rCharLevel.mnEscapement;
5393 1237 : if ( pCharLevel && ( nRetValue != pCharLevel->mnEscapement ) )
5394 0 : bIsHardAttribute = 1;
5395 : }
5396 1237 : break;
5397 : default :
5398 : OSL_FAIL( "SJ:PPTPortionObj::GetAttrib ( attribute does not exist )" );
5399 : }
5400 : }
5401 17699 : return (sal_Bool)bIsHardAttribute;
5402 : }
5403 :
5404 75 : void PPTPortionObj::ApplyTo( SfxItemSet& rSet, SdrPowerPointImport& rManager, sal_uInt32 nDestinationInstance )
5405 : {
5406 75 : ApplyTo( rSet, rManager, nDestinationInstance, NULL );
5407 75 : }
5408 :
5409 1262 : void PPTPortionObj::ApplyTo( SfxItemSet& rSet, SdrPowerPointImport& rManager, sal_uInt32 nDestinationInstance, const PPTTextObj* pTextObj )
5410 : {
5411 : sal_uInt32 nVal;
5412 1262 : if ( GetAttrib( PPT_CharAttr_Bold, nVal, nDestinationInstance ) )
5413 : {
5414 703 : rSet.Put( SvxWeightItem( nVal != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
5415 703 : rSet.Put( SvxWeightItem( nVal != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
5416 703 : rSet.Put( SvxWeightItem( nVal != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
5417 : }
5418 1262 : if ( GetAttrib( PPT_CharAttr_Italic, nVal, nDestinationInstance ) )
5419 : {
5420 89 : rSet.Put( SvxPostureItem( nVal != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC ) );
5421 89 : rSet.Put( SvxPostureItem( nVal != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
5422 89 : rSet.Put( SvxPostureItem( nVal != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
5423 : }
5424 1262 : if ( GetAttrib( PPT_CharAttr_Underline, nVal, nDestinationInstance ) )
5425 83 : rSet.Put( SvxUnderlineItem( nVal != 0 ? UNDERLINE_SINGLE : UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
5426 :
5427 1262 : if ( GetAttrib( PPT_CharAttr_Shadow, nVal, nDestinationInstance ) )
5428 81 : rSet.Put( SvxShadowedItem( nVal != 0, EE_CHAR_SHADOW ) );
5429 :
5430 1262 : if ( GetAttrib( PPT_CharAttr_Strikeout, nVal, nDestinationInstance ) )
5431 81 : rSet.Put( SvxCrossedOutItem( nVal != 0 ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) );
5432 :
5433 1262 : sal_uInt32 nAsianFontId = 0xffff;
5434 1262 : if ( GetAttrib( PPT_CharAttr_AsianOrComplexFont, nAsianFontId, nDestinationInstance ) )
5435 : {
5436 1157 : if ( nAsianFontId != 0xffff )
5437 : {
5438 1139 : PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nAsianFontId );
5439 1139 : if ( pFontEnityAtom )
5440 : {
5441 : rSet.Put( SvxFontItem( pFontEnityAtom->eFamily, pFontEnityAtom->aName,
5442 1139 : String(), pFontEnityAtom->ePitch, pFontEnityAtom->eCharSet, EE_CHAR_FONTINFO_CJK ) );
5443 : rSet.Put( SvxFontItem( pFontEnityAtom->eFamily, pFontEnityAtom->aName,
5444 1139 : String(), pFontEnityAtom->ePitch, pFontEnityAtom->eCharSet, EE_CHAR_FONTINFO_CTL ) );
5445 : }
5446 : }
5447 : }
5448 1262 : if ( GetAttrib( PPT_CharAttr_Font, nVal, nDestinationInstance ) )
5449 : {
5450 778 : PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nVal );
5451 778 : if ( pFontEnityAtom )
5452 778 : rSet.Put( SvxFontItem( pFontEnityAtom->eFamily, pFontEnityAtom->aName, String(), pFontEnityAtom->ePitch, pFontEnityAtom->eCharSet, EE_CHAR_FONTINFO ) );
5453 : }
5454 1262 : if ( GetAttrib( PPT_CharAttr_FontHeight, nVal, nDestinationInstance ) ) // Schriftgrad in Point
5455 : {
5456 959 : sal_uInt32 nHeight = rManager.ScalePoint( nVal );
5457 959 : rSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
5458 959 : rSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
5459 959 : rSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
5460 : }
5461 :
5462 1262 : if ( GetAttrib( PPT_CharAttr_Embossed, nVal, nDestinationInstance ) )
5463 81 : rSet.Put( SvxCharReliefItem( nVal != 0 ? RELIEF_EMBOSSED : RELIEF_NONE, EE_CHAR_RELIEF ) );
5464 1262 : if ( nVal ) /* if Embossed is set, the font color depends to the fillstyle/color of the object,
5465 : if the object has no fillstyle, the font color depends to fillstyle of the background */
5466 : {
5467 0 : Color aDefColor( COL_BLACK );
5468 0 : MSO_FillType eFillType = mso_fillSolid;
5469 0 : if ( rManager.GetPropertyValue( DFF_Prop_fNoFillHitTest ) & 0x10 )
5470 0 : eFillType = (MSO_FillType)rManager.GetPropertyValue( DFF_Prop_fillType, mso_fillSolid );
5471 : else
5472 0 : eFillType = mso_fillBackground;
5473 0 : switch( eFillType )
5474 : {
5475 : case mso_fillShade :
5476 : case mso_fillShadeCenter :
5477 : case mso_fillShadeShape :
5478 : case mso_fillShadeScale :
5479 : case mso_fillShadeTitle :
5480 : case mso_fillSolid :
5481 0 : aDefColor = rManager.MSO_CLR_ToColor( rManager.GetPropertyValue( DFF_Prop_fillColor ) );
5482 0 : break;
5483 : case mso_fillPattern :
5484 0 : aDefColor = rManager.MSO_CLR_ToColor( rManager.GetPropertyValue( DFF_Prop_fillBackColor ) );
5485 0 : break;
5486 : case mso_fillTexture :
5487 : {
5488 0 : Graphic aGraf;
5489 0 : if ( rManager.GetBLIP( rManager.GetPropertyValue( DFF_Prop_fillBlip ), aGraf, NULL ) )
5490 : {
5491 0 : Bitmap aBmp( aGraf.GetBitmap() );
5492 0 : Size aSize( aBmp.GetSizePixel() );
5493 0 : if ( aSize.Width() && aSize.Height() )
5494 : {
5495 0 : if ( aSize.Width () > 64 )
5496 0 : aSize.Width () = 64;
5497 0 : if ( aSize.Height() > 64 )
5498 0 : aSize.Height() = 64;
5499 :
5500 0 : BitmapReadAccess* pAcc = aBmp.AcquireReadAccess();
5501 0 : if( pAcc )
5502 : {
5503 0 : sal_uLong nRt = 0, nGn = 0, nBl = 0;
5504 0 : const long nWidth = aSize.Width();
5505 0 : const long nHeight = aSize.Height();
5506 :
5507 0 : if( pAcc->HasPalette() )
5508 : {
5509 0 : for( long nY = 0L; nY < nHeight; nY++ )
5510 : {
5511 0 : for( long nX = 0L; nX < nWidth; nX++ )
5512 : {
5513 0 : const BitmapColor& rCol = pAcc->GetPaletteColor( (sal_uInt8) pAcc->GetPixel( nY, nX ) );
5514 0 : nRt+=rCol.GetRed(); nGn+=rCol.GetGreen(); nBl+=rCol.GetBlue();
5515 : }
5516 : }
5517 : }
5518 : else
5519 : {
5520 0 : for( long nY = 0L; nY < nHeight; nY++ )
5521 : {
5522 0 : for( long nX = 0L; nX < nWidth; nX++ )
5523 : {
5524 0 : const BitmapColor aCol( pAcc->GetPixel( nY, nX ) );
5525 0 : nRt+=aCol.GetRed(); nGn+=aCol.GetGreen(); nBl+=aCol.GetBlue();
5526 0 : }
5527 : }
5528 : }
5529 0 : aBmp.ReleaseAccess( pAcc );
5530 0 : sal_uInt32 nC = ( aSize.Width() * aSize.Height() );
5531 0 : nRt /= nC;
5532 0 : nGn /= nC;
5533 0 : nBl /= nC;
5534 0 : aDefColor = Color(sal_uInt8( nRt ), sal_uInt8( nGn ),sal_uInt8( nBl ) );
5535 : }
5536 0 : }
5537 0 : }
5538 : }
5539 0 : break;
5540 : case mso_fillBackground :
5541 : {
5542 0 : if ( pTextObj ) // the textobject is needed
5543 : {
5544 0 : const SfxItemSet* pItemSet = pTextObj->GetBackground();
5545 0 : if ( pItemSet )
5546 : {
5547 0 : const SfxPoolItem* pFillStyleItem = NULL;
5548 0 : pItemSet->GetItemState( XATTR_FILLSTYLE, sal_False, &pFillStyleItem );
5549 0 : if ( pFillStyleItem )
5550 : {
5551 0 : XFillStyle eFillStyle = ((XFillStyleItem*)pFillStyleItem)->GetValue();
5552 0 : switch( eFillStyle )
5553 : {
5554 : case XFILL_SOLID :
5555 : {
5556 0 : const SfxPoolItem* pFillColorItem = NULL;
5557 0 : pItemSet->GetItemState( XATTR_FILLCOLOR, sal_False, &pFillColorItem );
5558 0 : if ( pFillColorItem )
5559 0 : aDefColor = ((XColorItem*)pFillColorItem)->GetColorValue();
5560 : }
5561 0 : break;
5562 : case XFILL_GRADIENT :
5563 : {
5564 0 : const SfxPoolItem* pGradientItem = NULL;
5565 0 : pItemSet->GetItemState( XATTR_FILLGRADIENT, sal_False, &pGradientItem );
5566 0 : if ( pGradientItem )
5567 0 : aDefColor = ((XFillGradientItem*)pGradientItem)->GetGradientValue().GetStartColor();
5568 : }
5569 0 : break;
5570 : case XFILL_HATCH :
5571 : case XFILL_BITMAP :
5572 0 : aDefColor = Color( COL_WHITE );
5573 0 : break;
5574 0 : default: break;
5575 : }
5576 : }
5577 : }
5578 : }
5579 : }
5580 0 : break;
5581 0 : default: break;
5582 : }
5583 0 : rSet.Put( SvxColorItem( aDefColor, EE_CHAR_COLOR ) );
5584 : }
5585 : else
5586 : {
5587 1262 : if ( GetAttrib( PPT_CharAttr_FontColor, nVal, nDestinationInstance ) ) // Textfarbe (4Byte-Arg)
5588 : {
5589 695 : Color aCol( rManager.MSO_TEXT_CLR_ToColor( nVal ) );
5590 695 : rSet.Put( SvxColorItem( aCol, EE_CHAR_COLOR ) );
5591 695 : if ( nDestinationInstance == 0xffffffff )
5592 75 : mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ mnDepth ].mnFontColorInStyleSheet = aCol;
5593 : }
5594 567 : else if ( nVal & 0x0f000000 ) // this is not a hard attribute, but maybe the page has a different colerscheme,
5595 : { // so that in this case we must use a hard color attribute
5596 567 : Color aCol( rManager.MSO_TEXT_CLR_ToColor( nVal ) );
5597 567 : Color& aColorInSheet = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ mnDepth ].mnFontColorInStyleSheet;
5598 567 : if ( aColorInSheet != aCol )
5599 195 : rSet.Put( SvxColorItem( aCol, EE_CHAR_COLOR ) );
5600 : }
5601 : }
5602 :
5603 1262 : if ( GetAttrib( PPT_CharAttr_Escapement, nVal, nDestinationInstance ) ) // Hoch/Tiefstellung in %
5604 : {
5605 106 : sal_uInt16 nEsc = 0;
5606 106 : sal_uInt8 nProp = 100;
5607 :
5608 106 : if ( nVal )
5609 : {
5610 25 : nEsc = (sal_Int16)nVal;
5611 25 : nProp = DFLT_ESC_PROP;
5612 : }
5613 106 : SvxEscapementItem aItem( nEsc, nProp, EE_CHAR_ESCAPEMENT );
5614 106 : rSet.Put( aItem );
5615 : }
5616 1262 : if ( mnLanguage[ 0 ] )
5617 1187 : rSet.Put( SvxLanguageItem( mnLanguage[ 0 ], EE_CHAR_LANGUAGE ) );
5618 1262 : if ( mnLanguage[ 1 ] )
5619 1129 : rSet.Put( SvxLanguageItem( mnLanguage[ 1 ], EE_CHAR_LANGUAGE_CJK ) );
5620 1262 : if ( mnLanguage[ 2 ] )
5621 0 : rSet.Put( SvxLanguageItem( mnLanguage[ 2 ], EE_CHAR_LANGUAGE_CTL ) );
5622 1262 : }
5623 :
5624 1187 : SvxFieldItem* PPTPortionObj::GetTextField()
5625 : {
5626 1187 : if ( mpFieldItem )
5627 34 : return new SvxFieldItem( *mpFieldItem );
5628 1153 : return NULL;
5629 : }
5630 :
5631 75 : PPTParagraphObj::PPTParagraphObj( const PPTStyleSheet& rStyleSheet, sal_uInt32 nInstance, sal_uInt16 nDepth ) :
5632 : PPTNumberFormatCreator ( NULL ),
5633 : mrStyleSheet ( rStyleSheet ),
5634 : mnInstance ( nInstance ),
5635 75 : mbTab ( sal_True ) // style sheets always have to get the right tabulator setting
5636 : {
5637 75 : if ( nDepth > 4 )
5638 20 : nDepth = 4;
5639 75 : pParaSet->mnDepth = nDepth;
5640 75 : }
5641 :
5642 774 : PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader,
5643 : size_t const nCurParaPos, size_t& rnCurCharPos,
5644 : const PPTStyleSheet& rStyleSheet,
5645 : sal_uInt32 nInstance, PPTTextRulerInterpreter& rRuler ) :
5646 774 : PPTParaPropSet ( *rPropReader.aParaPropList[nCurParaPos] ),
5647 : PPTNumberFormatCreator ( NULL ),
5648 : PPTTextRulerInterpreter ( rRuler ),
5649 : mrStyleSheet ( rStyleSheet ),
5650 : mnInstance ( nInstance ),
5651 : mbTab ( sal_False ),
5652 774 : mnCurrentObject ( 0 )
5653 : {
5654 774 : if (rnCurCharPos < rPropReader.aCharPropList.size())
5655 : {
5656 : sal_uInt32 const nCurrentParagraph =
5657 774 : rPropReader.aCharPropList[rnCurCharPos]->mnParagraph;
5658 3335 : for (; rnCurCharPos < rPropReader.aCharPropList.size() &&
5659 1374 : rPropReader.aCharPropList[rnCurCharPos]->mnParagraph == nCurrentParagraph;
5660 : ++rnCurCharPos)
5661 : {
5662 : PPTCharPropSet *const pCharPropSet =
5663 1187 : rPropReader.aCharPropList[rnCurCharPos];
5664 : PPTPortionObj* pPPTPortion = new PPTPortionObj( *pCharPropSet,
5665 1187 : rStyleSheet, nInstance, pParaSet->mnDepth );
5666 1187 : m_PortionList.push_back(pPPTPortion);
5667 1187 : if (!mbTab)
5668 : {
5669 1180 : mbTab = pPPTPortion->HasTabulator();
5670 : }
5671 : }
5672 : }
5673 774 : }
5674 :
5675 1698 : PPTParagraphObj::~PPTParagraphObj()
5676 : {
5677 849 : ImplClear();
5678 849 : }
5679 :
5680 75 : void PPTParagraphObj::AppendPortion( PPTPortionObj& rPPTPortion )
5681 : {
5682 75 : m_PortionList.push_back(new PPTPortionObj(rPPTPortion));
5683 75 : if ( !mbTab )
5684 : {
5685 0 : mbTab = m_PortionList.back().HasTabulator();
5686 : }
5687 75 : }
5688 :
5689 814 : void PPTParagraphObj::UpdateBulletRelSize( sal_uInt32& nBulletRelSize ) const
5690 : {
5691 814 : if ( nBulletRelSize > 0x7fff ) // a negative value is the absolute bullet height
5692 : {
5693 0 : sal_uInt16 nFontHeight = 0;
5694 0 : if (!m_PortionList.empty())
5695 : {
5696 0 : PPTPortionObj const& rPortion = m_PortionList.front();
5697 0 : if (rPortion.pCharSet->mnAttrSet & (1 << PPT_CharAttr_FontHeight))
5698 : {
5699 0 : nFontHeight = rPortion.pCharSet->mnFontHeight;
5700 : }
5701 : }
5702 : // if we do not have a hard attributed fontheight, the fontheight is taken from the style
5703 0 : if ( !nFontHeight )
5704 0 : nFontHeight = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontHeight;
5705 0 : nBulletRelSize = nFontHeight ? ((-((sal_Int16)nBulletRelSize)) * 100 ) / nFontHeight : 100;
5706 : }
5707 814 : }
5708 :
5709 16072 : sal_Bool PPTParagraphObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& nRetValue, sal_uInt32 nDestinationInstance )
5710 : {
5711 16072 : sal_uInt32 nMask = 1 << nAttr;
5712 16072 : nRetValue = 0;
5713 :
5714 16072 : if ( nAttr > 21 )
5715 : {
5716 : OSL_FAIL( "SJ:PPTParagraphObj::GetAttrib - attribute does not exist" );
5717 0 : return sal_False;
5718 : }
5719 :
5720 16072 : sal_uInt32 bIsHardAttribute = ( ( pParaSet->mnAttrSet & nMask ) != 0 ) ? 1 : 0;
5721 :
5722 16072 : if ( bIsHardAttribute )
5723 : {
5724 3695 : if ( nAttr == PPT_ParaAttr_BulletColor )
5725 : {
5726 : sal_Bool bHardBulletColor;
5727 49 : if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardColor ) )
5728 37 : bHardBulletColor = pParaSet->mpArry[ PPT_ParaAttr_BuHardColor ] != 0;
5729 : else
5730 12 : bHardBulletColor = ( mrStyleSheet.mpParaSheet[ mnInstance ]->maParaLevel[ pParaSet->mnDepth ].mnBuFlags
5731 24 : & ( 1 << PPT_ParaAttr_BuHardColor ) ) != 0;
5732 49 : if ( bHardBulletColor )
5733 33 : nRetValue = pParaSet->mnBulletColor;
5734 : else
5735 : {
5736 16 : nRetValue = PPT_COLSCHEME_TEXT_UND_ZEILEN;
5737 16 : if ((nDestinationInstance != 0xffffffff) && !m_PortionList.empty())
5738 : {
5739 16 : PPTPortionObj const& rPortion = m_PortionList.front();
5740 16 : if (rPortion.pCharSet->mnAttrSet & (1 << PPT_CharAttr_FontColor))
5741 : {
5742 9 : nRetValue = rPortion.pCharSet->mnColor;
5743 : }
5744 : else
5745 : {
5746 7 : nRetValue = mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontColor;
5747 : }
5748 : }
5749 : }
5750 : }
5751 3646 : else if ( nAttr == PPT_ParaAttr_BulletFont )
5752 : {
5753 : sal_Bool bHardBuFont;
5754 49 : if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardFont ) )
5755 45 : bHardBuFont = pParaSet->mpArry[ PPT_ParaAttr_BuHardFont ] != 0;
5756 : else
5757 4 : bHardBuFont = ( mrStyleSheet.mpParaSheet[ mnInstance ]->maParaLevel[ pParaSet->mnDepth ].mnBuFlags
5758 8 : & ( 1 << PPT_ParaAttr_BuHardFont ) ) != 0;
5759 49 : if ( bHardBuFont )
5760 45 : nRetValue = pParaSet->mpArry[ PPT_ParaAttr_BulletFont ];
5761 : else
5762 : {
5763 : // it is the font used which assigned to the first character of the following text
5764 4 : nRetValue = 0;
5765 4 : if ((nDestinationInstance != 0xffffffff) && !m_PortionList.empty())
5766 : {
5767 4 : PPTPortionObj const& rPortion = m_PortionList.front();
5768 4 : if (rPortion.pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_Font ) )
5769 : {
5770 4 : nRetValue = rPortion.pCharSet->mnFont;
5771 : }
5772 : else
5773 : {
5774 0 : nRetValue = mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFont;
5775 : }
5776 : }
5777 : }
5778 : }
5779 : else
5780 3597 : nRetValue = pParaSet->mpArry[ nAttr ];
5781 : }
5782 : else
5783 : {
5784 12377 : const PPTParaLevel& rParaLevel = mrStyleSheet.mpParaSheet[ mnInstance ]->maParaLevel[ pParaSet->mnDepth ];
5785 :
5786 12377 : PPTParaLevel* pParaLevel = NULL;
5787 12377 : if ( ( nDestinationInstance == 0xffffffff )
5788 : || ( pParaSet->mnDepth && ( ( mnInstance == TSS_TYPE_SUBTITLE ) || ( mnInstance == TSS_TYPE_TEXT_IN_SHAPE ) ) ) )
5789 1364 : bIsHardAttribute = 1;
5790 11013 : else if ( nDestinationInstance != mnInstance )
5791 5403 : pParaLevel = &mrStyleSheet.mpParaSheet[ nDestinationInstance ]->maParaLevel[ pParaSet->mnDepth ];
5792 12377 : switch ( nAttr )
5793 : {
5794 : case PPT_ParaAttr_BulletOn :
5795 : {
5796 1165 : nRetValue = rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BulletOn );
5797 1165 : if ( pParaLevel )
5798 : {
5799 97 : if ( nRetValue != ( (sal_uInt32)pParaLevel->mnBuFlags & ( 1 << PPT_ParaAttr_BulletOn ) ) )
5800 30 : bIsHardAttribute = 1;
5801 : }
5802 : }
5803 1165 : break;
5804 : case PPT_ParaAttr_BuHardFont :
5805 : case PPT_ParaAttr_BuHardColor :
5806 : case PPT_ParaAttr_BuHardHeight :
5807 : OSL_FAIL( "SJ:PPTParagraphObj::GetAttrib - this attribute does not make sense" );
5808 0 : break;
5809 : case PPT_ParaAttr_BulletChar :
5810 : {
5811 769 : nRetValue = rParaLevel.mnBulletChar;
5812 769 : if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletChar ) )
5813 411 : bIsHardAttribute = 1;
5814 : }
5815 769 : break;
5816 : case PPT_ParaAttr_BulletFont :
5817 : {
5818 : sal_Bool bHardBuFont;
5819 765 : if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardFont ) )
5820 0 : bHardBuFont = pParaSet->mpArry[ PPT_ParaAttr_BuHardFont ] != 0;
5821 : else
5822 765 : bHardBuFont = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardFont ) ) != 0;
5823 765 : if ( bHardBuFont )
5824 : {
5825 601 : nRetValue = rParaLevel.mnBulletFont;
5826 601 : if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletFont ) )
5827 411 : bIsHardAttribute = 1;
5828 : }
5829 : else
5830 : {
5831 164 : if (!m_PortionList.empty())
5832 : {
5833 164 : PPTPortionObj const& rPortion = m_PortionList.front();
5834 : bIsHardAttribute = rPortion.GetAttrib(
5835 164 : PPT_CharAttr_Font, nRetValue, nDestinationInstance);
5836 : }
5837 : else
5838 : {
5839 0 : nRetValue = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFont;
5840 0 : bIsHardAttribute = 1;
5841 : }
5842 : }
5843 : }
5844 765 : break;
5845 : case PPT_ParaAttr_BulletHeight :
5846 : {
5847 785 : nRetValue = rParaLevel.mnBulletHeight;
5848 785 : if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletHeight ) )
5849 405 : bIsHardAttribute = 1;
5850 : }
5851 785 : break;
5852 : case PPT_ParaAttr_BulletColor :
5853 : {
5854 : sal_Bool bHardBulletColor;
5855 765 : if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardColor ) )
5856 0 : bHardBulletColor = pParaSet->mpArry[ PPT_ParaAttr_BuHardColor ] != 0;
5857 : else
5858 765 : bHardBulletColor = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardColor ) ) != 0;
5859 765 : if ( bHardBulletColor )
5860 : {
5861 608 : nRetValue = rParaLevel.mnBulletColor;
5862 608 : if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletColor ) )
5863 407 : bIsHardAttribute = 1;
5864 : }
5865 : else
5866 : {
5867 157 : if (!m_PortionList.empty())
5868 : {
5869 157 : PPTPortionObj const& rPortion = m_PortionList.front();
5870 : bIsHardAttribute = rPortion.GetAttrib(
5871 157 : PPT_CharAttr_FontColor, nRetValue, nDestinationInstance);
5872 : }
5873 : else
5874 : {
5875 0 : nRetValue = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontColor;
5876 0 : bIsHardAttribute = 1;
5877 : }
5878 : }
5879 : }
5880 765 : break;
5881 : case PPT_ParaAttr_Adjust :
5882 : {
5883 731 : nRetValue = rParaLevel.mnAdjust;
5884 731 : if ( pParaLevel && ( nRetValue != pParaLevel->mnAdjust ) )
5885 0 : bIsHardAttribute = 1;
5886 : }
5887 731 : break;
5888 : case PPT_ParaAttr_LineFeed :
5889 : {
5890 730 : nRetValue = rParaLevel.mnLineFeed;
5891 730 : if ( pParaLevel && ( nRetValue != pParaLevel->mnLineFeed ) )
5892 407 : bIsHardAttribute = 1;
5893 : }
5894 730 : break;
5895 : case PPT_ParaAttr_UpperDist :
5896 : {
5897 804 : nRetValue = rParaLevel.mnUpperDist;
5898 804 : if ( pParaLevel && ( nRetValue != pParaLevel->mnUpperDist ) )
5899 407 : bIsHardAttribute = 1;
5900 : }
5901 804 : break;
5902 : case PPT_ParaAttr_LowerDist :
5903 : {
5904 846 : nRetValue = rParaLevel.mnLowerDist;
5905 846 : if ( pParaLevel && ( nRetValue != pParaLevel->mnLowerDist ) )
5906 0 : bIsHardAttribute = 1;
5907 : }
5908 846 : break;
5909 : case PPT_ParaAttr_TextOfs :
5910 : {
5911 879 : nRetValue = rParaLevel.mnTextOfs;
5912 879 : if ( pParaLevel && ( nRetValue != pParaLevel->mnTextOfs ) )
5913 20 : bIsHardAttribute = 1;
5914 : }
5915 879 : break;
5916 : case PPT_ParaAttr_BulletOfs :
5917 : {
5918 1717 : nRetValue = rParaLevel.mnBulletOfs;
5919 1717 : if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletOfs ) )
5920 8 : bIsHardAttribute = 1;
5921 : }
5922 1717 : break;
5923 : case PPT_ParaAttr_DefaultTab :
5924 : {
5925 80 : nRetValue = rParaLevel.mnDefaultTab;
5926 80 : if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletOfs ) )
5927 0 : bIsHardAttribute = 1;
5928 : }
5929 80 : break;
5930 : case PPT_ParaAttr_AsianLB_1 :
5931 : {
5932 734 : nRetValue = rParaLevel.mnAsianLineBreak & 1;
5933 734 : if ( pParaLevel && ( nRetValue != ( (sal_uInt32)pParaLevel->mnAsianLineBreak & 1 ) ) )
5934 0 : bIsHardAttribute = 1;
5935 : }
5936 734 : break;
5937 : case PPT_ParaAttr_AsianLB_2 :
5938 : {
5939 0 : nRetValue = ( rParaLevel.mnAsianLineBreak >> 1 ) & 1;
5940 0 : if ( pParaLevel && ( nRetValue != ( ( (sal_uInt32)pParaLevel->mnAsianLineBreak >> 1 ) & 1 ) ) )
5941 0 : bIsHardAttribute = 1;
5942 : }
5943 0 : break;
5944 : case PPT_ParaAttr_AsianLB_3 :
5945 : {
5946 758 : nRetValue = ( rParaLevel.mnAsianLineBreak >> 2 ) & 1;
5947 758 : if ( pParaLevel && ( nRetValue != ( ( (sal_uInt32)pParaLevel->mnAsianLineBreak >> 2 ) & 1 ) ) )
5948 0 : bIsHardAttribute = 1;
5949 : }
5950 758 : break;
5951 : case PPT_ParaAttr_BiDi :
5952 : {
5953 849 : nRetValue = rParaLevel.mnBiDi;
5954 849 : if ( pParaLevel && ( nRetValue != pParaLevel->mnBiDi ) )
5955 0 : bIsHardAttribute = 1;
5956 : }
5957 849 : break;
5958 : }
5959 : }
5960 16072 : return (sal_Bool)bIsHardAttribute;
5961 : }
5962 :
5963 849 : void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, boost::optional< sal_Int16 >& rStartNumbering, SdrPowerPointImport& rManager, sal_uInt32 nDestinationInstance, const PPTParagraphObj* /*pPrev*/)
5964 : {
5965 : sal_Int16 nVal2;
5966 : sal_uInt32 nVal, nUpperDist, nLowerDist;
5967 849 : sal_uInt32 nInstance = nDestinationInstance != 0xffffffff ? nDestinationInstance : mnInstance;
5968 :
5969 849 : if ( ( nDestinationInstance != 0xffffffff ) || ( pParaSet->mnDepth <= 1 ) )
5970 : {
5971 814 : SvxNumBulletItem* pNumBulletItem = mrStyleSheet.mpNumBulletItem[ nInstance ];
5972 814 : if ( pNumBulletItem )
5973 : {
5974 814 : SvxNumberFormat aNumberFormat( SVX_NUM_NUMBER_NONE );
5975 814 : if ( GetNumberFormat( rManager, aNumberFormat, this, nDestinationInstance, rStartNumbering ) )
5976 : {
5977 616 : if ( aNumberFormat.GetNumberingType() == SVX_NUM_NUMBER_NONE )
5978 : {
5979 567 : aNumberFormat.SetLSpace( 0 );
5980 567 : aNumberFormat.SetAbsLSpace( 0 );
5981 567 : aNumberFormat.SetFirstLineOffset( 0 );
5982 567 : aNumberFormat.SetCharTextDistance( 0 );
5983 567 : aNumberFormat.SetFirstLineIndent( 0 );
5984 567 : aNumberFormat.SetIndentAt( 0 );
5985 : }
5986 616 : SvxNumBulletItem aNewNumBulletItem( *pNumBulletItem );
5987 616 : SvxNumRule* pRule = aNewNumBulletItem.GetNumRule();
5988 616 : if ( pRule )
5989 : {
5990 616 : pRule->SetLevel( pParaSet->mnDepth, aNumberFormat );
5991 : sal_uInt16 i, n;
5992 6722 : for ( i = 0; i < pRule->GetLevelCount(); i++ )
5993 : {
5994 6106 : if ( i != pParaSet->mnDepth )
5995 : {
5996 5490 : n = i > 4 ? 4 : i;
5997 :
5998 5490 : SvxNumberFormat aNumberFormat2( pRule->GetLevel( i ) );
5999 5490 : const PPTParaLevel& rParaLevel = mrStyleSheet.mpParaSheet[ nInstance ]->maParaLevel[ n ];
6000 5490 : const PPTCharLevel& rCharLevel = mrStyleSheet.mpCharSheet[ nInstance ]->maCharLevel[ n ];
6001 : sal_uInt32 nColor;
6002 5490 : if ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardColor ) )
6003 810 : nColor = rParaLevel.mnBulletColor;
6004 : else
6005 4680 : nColor = rCharLevel.mnFontColor;
6006 5490 : aNumberFormat2.SetBulletColor( rManager.MSO_TEXT_CLR_ToColor( nColor ) );
6007 5490 : pRule->SetLevel( i, aNumberFormat2 );
6008 : }
6009 : }
6010 616 : rSet.Put( aNewNumBulletItem );
6011 616 : }
6012 814 : }
6013 : }
6014 : }
6015 :
6016 849 : sal_uInt32 nIsBullet2, _nTextOfs, _nBulletOfs, nHardAttribute = 0;
6017 849 : GetAttrib( PPT_ParaAttr_BulletOn, nIsBullet2, nDestinationInstance );
6018 849 : nHardAttribute += GetAttrib( PPT_ParaAttr_TextOfs, _nTextOfs, nDestinationInstance );
6019 849 : nHardAttribute += GetAttrib( PPT_ParaAttr_BulletOfs, _nBulletOfs, nDestinationInstance );
6020 849 : if ( !nIsBullet2 )
6021 : {
6022 634 : SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE );
6023 634 : sal_uInt16 nAbsLSpace = (sal_uInt16)( ( (sal_uInt32)_nTextOfs * 2540 ) / 576 );
6024 634 : sal_uInt16 nFirstLineOffset = nAbsLSpace - (sal_uInt16)( ( (sal_uInt32)_nBulletOfs * 2540 ) / 576 );
6025 634 : aLRSpaceItem.SetLeft( nAbsLSpace );
6026 634 : aLRSpaceItem.SetTxtFirstLineOfstValue( -nFirstLineOffset );
6027 634 : rSet.Put( aLRSpaceItem );
6028 : }
6029 : else
6030 : {
6031 215 : SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE );
6032 215 : aLRSpaceItem.SetLeft( 0 );
6033 215 : aLRSpaceItem.SetTxtFirstLineOfstValue( 0 );
6034 215 : rSet.Put( aLRSpaceItem );
6035 : }
6036 849 : if ( GetAttrib( PPT_ParaAttr_Adjust, nVal, nDestinationInstance ) )
6037 : {
6038 525 : if ( nVal <= 3 )
6039 : { // Absatzausrichtung
6040 : static SvxAdjust const aAdj[ 4 ] = { SVX_ADJUST_LEFT, SVX_ADJUST_CENTER, SVX_ADJUST_RIGHT, SVX_ADJUST_BLOCK };
6041 525 : rSet.Put( SvxAdjustItem( aAdj[ nVal ], EE_PARA_JUST ) );
6042 : }
6043 : }
6044 :
6045 849 : if ( GetAttrib( PPT_ParaAttr_AsianLB_1, nVal, nDestinationInstance ) )
6046 190 : rSet.Put( SfxBoolItem( EE_PARA_FORBIDDENRULES, nVal != 0 ) );
6047 849 : if ( GetAttrib( PPT_ParaAttr_AsianLB_3, nVal, nDestinationInstance ) )
6048 166 : rSet.Put( SfxBoolItem( EE_PARA_HANGINGPUNCTUATION, nVal != 0 ) );
6049 :
6050 849 : if ( GetAttrib( PPT_ParaAttr_BiDi, nVal, nDestinationInstance ) )
6051 79 : rSet.Put( SvxFrameDirectionItem( nVal == 1 ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
6052 :
6053 : // LineSpacing
6054 849 : PPTPortionObj* pPortion = First();
6055 849 : sal_Bool bIsHardAttribute = GetAttrib( PPT_ParaAttr_LineFeed, nVal, nDestinationInstance );
6056 849 : nVal2 = (sal_Int16)nVal;
6057 849 : sal_uInt32 nFont = sal_uInt32();
6058 849 : if ( pPortion && pPortion->GetAttrib( PPT_CharAttr_Font, nFont, nDestinationInstance ) )
6059 611 : bIsHardAttribute = sal_True;
6060 :
6061 849 : if ( bIsHardAttribute )
6062 : {
6063 689 : if ( pPortion && ( nVal2 > 200 ) )
6064 : {
6065 : sal_uInt32 nFontHeight;
6066 0 : pPortion->GetAttrib( PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance );
6067 0 : nVal2 = -(sal_Int16)( ( nFontHeight * nVal * 8 ) / 100 );
6068 : }
6069 689 : rSet.Put( SdrTextFixedCellHeightItem( sal_True ), SDRATTR_TEXT_USEFIXEDCELLHEIGHT );
6070 689 : SvxLineSpacingItem aItem( 200, EE_PARA_SBL );
6071 689 : if ( nVal2 <= 0 ) {
6072 0 : aItem.SetLineHeight( (sal_uInt16)( rManager.ScalePoint( -nVal2 ) / 8 ) );
6073 0 : aItem.GetLineSpaceRule() = SVX_LINE_SPACE_FIX;
6074 0 : aItem.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
6075 : } else
6076 : {
6077 689 : sal_uInt8 nPropLineSpace = (sal_uInt8)nVal2;
6078 689 : aItem.SetPropLineSpace( nPropLineSpace );
6079 689 : aItem.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
6080 : }
6081 689 : rSet.Put( aItem );
6082 : }
6083 :
6084 : // Paragraph Spacing
6085 849 : bIsHardAttribute = ( (sal_uInt32)GetAttrib( PPT_ParaAttr_UpperDist, nUpperDist, nDestinationInstance ) +
6086 849 : (sal_uInt32)GetAttrib( PPT_ParaAttr_LowerDist, nLowerDist, nDestinationInstance ) ) != 0;
6087 849 : if ( ( nUpperDist > 0 ) || ( nLowerDist > 0 ) )
6088 : {
6089 680 : if (!m_PortionList.empty())
6090 : {
6091 680 : sal_uInt32 nFontHeight = 0;
6092 680 : m_PortionList.back().GetAttrib(
6093 680 : PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance);
6094 680 : if ( ((sal_Int16)nUpperDist) > 0 )
6095 626 : nUpperDist = - (sal_Int16)( ( nFontHeight * nUpperDist * 100 ) / 1000 );
6096 680 : if ( ((sal_Int16)nLowerDist) > 0 )
6097 3 : nLowerDist = - (sal_Int16)( ( nFontHeight * nLowerDist * 100 ) / 1000 );
6098 : }
6099 680 : bIsHardAttribute = sal_True;
6100 : }
6101 849 : if ( bIsHardAttribute )
6102 : {
6103 710 : SvxULSpaceItem aULSpaceItem( EE_PARA_ULSPACE );
6104 710 : nVal2 = (sal_Int16)nUpperDist;
6105 710 : if ( nVal2 <= 0 )
6106 710 : aULSpaceItem.SetUpper( (sal_uInt16)(((sal_uInt32) - nVal2 * 2540 ) / ( 72 * 8 ) ) );
6107 : else
6108 : {
6109 0 : aULSpaceItem.SetUpperValue( 0 );
6110 0 : aULSpaceItem.SetPropUpper( (sal_uInt16)nUpperDist == 100 ? 101 : (sal_uInt16)nUpperDist );
6111 : }
6112 710 : nVal2 = (sal_Int16)nLowerDist;
6113 710 : if ( nVal2 <= 0 )
6114 710 : aULSpaceItem.SetLower( (sal_uInt16)(((sal_uInt32) - nVal2 * 2540 ) / ( 72 * 8 ) ) );
6115 : else
6116 : {
6117 0 : aULSpaceItem.SetLowerValue( 0 );
6118 0 : aULSpaceItem.SetPropLower( (sal_uInt16)nLowerDist == 100 ? 101 : (sal_uInt16)nLowerDist );
6119 : }
6120 710 : rSet.Put( aULSpaceItem );
6121 : }
6122 :
6123 849 : if ( mbTab ) // makes it sense to apply tabsettings
6124 : {
6125 84 : sal_uInt32 i, nDefaultTab, nTab, nTextOfs2 = 0;
6126 84 : sal_uInt32 nLatestManTab = 0;
6127 84 : GetAttrib( PPT_ParaAttr_TextOfs, nTextOfs2, nDestinationInstance );
6128 84 : GetAttrib( PPT_ParaAttr_BulletOfs, nTab, nDestinationInstance );
6129 84 : GetAttrib( PPT_ParaAttr_BulletOn, i, nDestinationInstance );
6130 84 : GetAttrib( PPT_ParaAttr_DefaultTab, nDefaultTab, nDestinationInstance );
6131 84 : SvxTabStopItem aTabItem( 0, 0, SVX_TAB_ADJUST_DEFAULT, EE_PARA_TABS );
6132 84 : if ( GetTabCount() )
6133 : {
6134 0 : for ( i = 0; i < GetTabCount(); i++ )
6135 : {
6136 : SvxTabAdjust eTabAdjust;
6137 0 : nTab = GetTabOffsetByIndex( (sal_uInt16)i );
6138 0 : switch( GetTabStyleByIndex( (sal_uInt16)i ) )
6139 : {
6140 0 : case 1 : eTabAdjust = SVX_TAB_ADJUST_CENTER; break;
6141 0 : case 2 : eTabAdjust = SVX_TAB_ADJUST_RIGHT; break;
6142 0 : case 3 : eTabAdjust = SVX_TAB_ADJUST_DECIMAL; break;
6143 0 : default : eTabAdjust = SVX_TAB_ADJUST_LEFT;
6144 : }
6145 0 : if ( nTab > nTextOfs2 )
6146 0 : aTabItem.Insert( SvxTabStop( (sal_uInt16)( ( ( nTab - nTextOfs2 ) * 2540 ) / 576 ), eTabAdjust ) );
6147 : }
6148 0 : nLatestManTab = nTab;
6149 : }
6150 84 : if ( nIsBullet2 == 0 )
6151 32 : aTabItem.Insert( SvxTabStop( (sal_uInt16)0 ) );
6152 84 : if ( nDefaultTab )
6153 : {
6154 84 : nTab = ( nTextOfs2 > nLatestManTab ) ? nTextOfs2 : nLatestManTab;
6155 84 : nTab /= nDefaultTab;
6156 84 : nTab = nDefaultTab * ( 1 + nTab );
6157 1372 : for ( i = 0; ( i < 20 ) && ( nTab < 0x1b00 ); i++ )
6158 : {
6159 1288 : aTabItem.Insert( SvxTabStop( (sal_uInt16)( ( ( nTab - nTextOfs2 ) * 2540 ) / 576 ) ) );
6160 1288 : nTab += nDefaultTab;
6161 : }
6162 : }
6163 84 : rSet.Put( aTabItem );
6164 : }
6165 849 : }
6166 :
6167 774 : sal_uInt32 PPTParagraphObj::GetTextSize()
6168 : {
6169 774 : sal_uInt32 nCount, nRetValue = 0;
6170 1961 : for (size_t i = 0; i < m_PortionList.size(); i++)
6171 : {
6172 1187 : PPTPortionObj const& rPortionObj = m_PortionList[i];
6173 1187 : nCount = rPortionObj.Count();
6174 1187 : if ((!nCount) && rPortionObj.mpFieldItem)
6175 0 : nCount++;
6176 1187 : nRetValue += nCount;
6177 : }
6178 774 : return nRetValue;
6179 : }
6180 :
6181 3211 : PPTPortionObj* PPTParagraphObj::First()
6182 : {
6183 3211 : mnCurrentObject = 0;
6184 3211 : if (m_PortionList.empty())
6185 0 : return NULL;
6186 3211 : return &m_PortionList.front();
6187 : }
6188 :
6189 2374 : PPTPortionObj* PPTParagraphObj::Next()
6190 : {
6191 2374 : sal_uInt32 i = mnCurrentObject + 1;
6192 2374 : if (i >= m_PortionList.size())
6193 1548 : return NULL;
6194 826 : mnCurrentObject++;
6195 826 : return &m_PortionList[i];
6196 : }
6197 :
6198 849 : void PPTParagraphObj::ImplClear()
6199 : {
6200 849 : }
6201 :
6202 34 : PPTFieldEntry::~PPTFieldEntry()
6203 : {
6204 34 : delete pField1;
6205 34 : delete pField2;
6206 34 : delete pString;
6207 34 : };
6208 :
6209 52 : void PPTFieldEntry::GetDateTime( const sal_uInt32 nVal, SvxDateFormat& eDateFormat, SvxTimeFormat& eTimeFormat )
6210 : {
6211 52 : eDateFormat = SVXDATEFORMAT_APPDEFAULT;
6212 52 : eTimeFormat = SVXTIMEFORMAT_APPDEFAULT;
6213 : // ID auswerten
6214 52 : switch( nVal )
6215 : {
6216 : case 0:
6217 : case 6:
6218 33 : eDateFormat = SVXDATEFORMAT_A;
6219 33 : break;
6220 : case 1:
6221 0 : eDateFormat = SVXDATEFORMAT_F;
6222 0 : break;
6223 : case 2:
6224 : case 3:
6225 0 : eDateFormat = SVXDATEFORMAT_D;
6226 0 : break;
6227 : case 4:
6228 : case 5:
6229 0 : eDateFormat = SVXDATEFORMAT_C;
6230 0 : break;
6231 : case 7:
6232 0 : eDateFormat = SVXDATEFORMAT_A;
6233 : case 9:
6234 0 : eTimeFormat = SVXTIMEFORMAT_24_HM;
6235 0 : break;
6236 : case 8:
6237 0 : eDateFormat = SVXDATEFORMAT_A;
6238 : case 11:
6239 0 : eTimeFormat = SVXTIMEFORMAT_12_HM;
6240 0 : break;
6241 : case 10:
6242 0 : eTimeFormat = SVXTIMEFORMAT_24_HMS;
6243 0 : break;
6244 : case 12:
6245 0 : eTimeFormat = SVXTIMEFORMAT_12_HMS;
6246 0 : break;
6247 : }
6248 52 : }
6249 :
6250 0 : void PPTFieldEntry::SetDateTime( sal_uInt32 nVal )
6251 : {
6252 : SvxDateFormat eDateFormat;
6253 : SvxTimeFormat eTimeFormat;
6254 0 : GetDateTime( nVal, eDateFormat, eTimeFormat );
6255 0 : if ( eDateFormat != SVXDATEFORMAT_APPDEFAULT )
6256 0 : pField1 = new SvxFieldItem( SvxDateField( Date( Date::SYSTEM ), SVXDATETYPE_VAR, eDateFormat ), EE_FEATURE_FIELD );
6257 0 : if ( eTimeFormat != SVXTIMEFORMAT_APPDEFAULT )
6258 : {
6259 0 : SvxFieldItem* pFieldItem = new SvxFieldItem( SvxExtTimeField( Time( Time::SYSTEM ), SVXTIMETYPE_VAR, eTimeFormat ), EE_FEATURE_FIELD );
6260 0 : if ( pField1 )
6261 0 : pField2 = pFieldItem;
6262 : else
6263 0 : pField1 = pFieldItem;
6264 : }
6265 0 : }
6266 :
6267 1186 : PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport, PptSlidePersistEntry& rPersistEntry, DffObjData* pObjData ) :
6268 1186 : mpImplTextObj ( new ImplPPTTextObj( rPersistEntry ) )
6269 : {
6270 1186 : mpImplTextObj->mnRefCount = 1;
6271 1186 : mpImplTextObj->mnShapeId = 0;
6272 1186 : mpImplTextObj->mnShapeMaster = 0;
6273 1186 : mpImplTextObj->mpPlaceHolderAtom = NULL;
6274 1186 : mpImplTextObj->mnDestinationInstance = mpImplTextObj->mnInstance = 4;
6275 1186 : mpImplTextObj->mnCurrentObject = 0;
6276 1186 : mpImplTextObj->mnParagraphCount = 0;
6277 1186 : mpImplTextObj->mpParagraphList = NULL;
6278 1186 : mpImplTextObj->mnTextFlags = 0;
6279 1186 : mpImplTextObj->meShapeType = ( pObjData && pObjData->bShapeType ) ? pObjData->eShapeType : mso_sptMin;
6280 :
6281 1186 : DffRecordHeader aExtParaHd;
6282 1186 : aExtParaHd.nRecType = 0; // set empty
6283 :
6284 1186 : sal_uInt32 bStatus = sal_True;
6285 :
6286 1186 : DffRecordHeader aShapeContainerHd;
6287 1186 : rIn >> aShapeContainerHd;
6288 :
6289 1186 : if ( ( pObjData == NULL ) || ( pObjData->bShapeType ) )
6290 : {
6291 1186 : PPTExtParaProv* pExtParaProv = rSdrPowerPointImport.pPPTStyleSheet->pExtParaProv;
6292 1186 : if ( pObjData )
6293 : {
6294 1186 : mpImplTextObj->mnShapeId = pObjData->nShapeId;
6295 1186 : if ( pObjData->nSpFlags & SP_FHAVEMASTER )
6296 76 : mpImplTextObj->mnShapeMaster = rSdrPowerPointImport.GetPropertyValue( DFF_Prop_hspMaster, 0 );
6297 : }
6298 : // ClientData
6299 1186 : if ( rSdrPowerPointImport.maShapeRecords.SeekToContent( rIn, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) )
6300 : {
6301 161 : sal_uInt32 nOldPos = rIn.Tell();
6302 161 : DffRecordHeader& aClientDataContainerHd = *rSdrPowerPointImport.maShapeRecords.Current();
6303 161 : DffRecordHeader aPlaceHolderAtomHd;
6304 161 : if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_OEPlaceholderAtom, aClientDataContainerHd.GetRecEndFilePos(), &aPlaceHolderAtomHd ) )
6305 : {
6306 130 : mpImplTextObj->mpPlaceHolderAtom = new PptOEPlaceholderAtom;
6307 130 : rIn >> *( mpImplTextObj->mpPlaceHolderAtom );
6308 : }
6309 161 : rIn.Seek( nOldPos );
6310 161 : DffRecordHeader aProgTagHd;
6311 161 : if ( rSdrPowerPointImport.SeekToContentOfProgTag( 9, rIn, aClientDataContainerHd, aProgTagHd ) )
6312 : {
6313 0 : rIn >> aExtParaHd;
6314 : }
6315 : }
6316 :
6317 : // ClientTextBox
6318 1186 : if ( rSdrPowerPointImport.maShapeRecords.SeekToContent( rIn, DFF_msofbtClientTextbox, SEEK_FROM_CURRENT_AND_RESTART ) )
6319 : {
6320 600 : DffRecordHeader aClientTextBoxHd( *rSdrPowerPointImport.maShapeRecords.Current() );
6321 600 : sal_uInt32 nTextRulerAtomOfs = 0; // case of zero -> this atom may be found in aClientDataContainerHd;
6322 : // case of -1 -> ther is no atom of this kind
6323 : // else -> this is the fileofs where we can get it
6324 :
6325 : // checkout if this is a referenced
6326 : // textobj, if so the we will patch
6327 : // the ClientTextBoxHd for a
6328 : // equivalent one
6329 600 : DffRecordHeader aTextHd;
6330 600 : if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_OutlineTextRefAtom, aClientTextBoxHd.GetRecEndFilePos(), &aTextHd ) )
6331 : {
6332 : sal_uInt32 nRefNum;
6333 56 : rIn >> nRefNum;
6334 :
6335 56 : if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_TextRulerAtom, aClientTextBoxHd.GetRecEndFilePos() ) )
6336 18 : nTextRulerAtomOfs = rIn.Tell();
6337 : else
6338 38 : nTextRulerAtomOfs = 0xffffffff;
6339 :
6340 56 : sal_uInt32 nInstance = 0;
6341 56 : switch( rSdrPowerPointImport.eAktPageKind )
6342 : {
6343 : case PPT_NOTEPAGE :
6344 0 : nInstance++;
6345 : case PPT_MASTERPAGE :
6346 0 : nInstance++;
6347 : case PPT_SLIDEPAGE :
6348 56 : break;
6349 : default :
6350 0 : bStatus = sal_False;
6351 : }
6352 56 : if ( bStatus )
6353 : {
6354 56 : sal_uInt32 nSlideId = rSdrPowerPointImport.GetAktPageId();
6355 56 : if ( !nSlideId )
6356 0 : bStatus = sal_False;
6357 : else
6358 : {
6359 56 : if ( !aExtParaHd.nRecType )
6360 : {
6361 56 : sal_uInt32 nOldPos = rIn.Tell();
6362 : // try to locate the referenced ExtendedParaHd
6363 : DffRecordHeader* pHd = pExtParaProv->
6364 : aExtendedPresRules.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom,
6365 56 : SEEK_FROM_CURRENT_AND_RESTART );
6366 56 : DffRecordHeader aPresRuleHd;
6367 56 : DffRecordHeader* pFirst = pHd;
6368 :
6369 : sal_uInt32 nTmpSlideId, nTmpRef;
6370 113 : while ( pHd )
6371 : {
6372 54 : pHd->SeekToContent( rIn );
6373 54 : rIn >> nTmpSlideId
6374 54 : >> nTmpRef; // this seems to be the instance
6375 :
6376 54 : if ( ( nTmpSlideId == nSlideId ) && ( pHd->nRecInstance == nRefNum ) )
6377 : {
6378 3 : pHd->SeekToEndOfRecord( rIn );
6379 3 : rIn >> aPresRuleHd;
6380 3 : if ( aPresRuleHd.nRecType == PPT_PST_ExtendedParagraphAtom )
6381 : {
6382 3 : aExtParaHd = aPresRuleHd;
6383 3 : break;
6384 : }
6385 : }
6386 : pHd = pExtParaProv->
6387 : aExtendedPresRules.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom,
6388 51 : SEEK_FROM_CURRENT_AND_RESTART );
6389 51 : if ( pHd == pFirst )
6390 50 : break;
6391 : }
6392 56 : rIn.Seek( nOldPos );
6393 : }
6394 : // now pHd points to the right SlideListWithText Container
6395 56 : PptSlidePersistList* pPageList = rSdrPowerPointImport.GetPageList( rSdrPowerPointImport.eAktPageKind );
6396 56 : PptSlidePersistEntry* pE = NULL;
6397 56 : if ( pPageList && ( rSdrPowerPointImport.nAktPageNum < pPageList->size() ) )
6398 56 : pE = (*pPageList)[ rSdrPowerPointImport.nAktPageNum ];
6399 56 : if ( (!pE) || (!pE->nSlidePersistStartOffset) || ( pE->aPersistAtom.nSlideId != nSlideId ) )
6400 0 : bStatus = sal_False;
6401 : else
6402 : {
6403 56 : rIn.Seek( pE->nSlidePersistStartOffset );
6404 : // now we got the right page and are searching for the right
6405 : // TextHeaderAtom
6406 206 : while ( rIn.Tell() < pE->nSlidePersistEndOffset )
6407 : {
6408 150 : rIn >> aClientTextBoxHd;
6409 150 : if ( aClientTextBoxHd.nRecType == PPT_PST_TextHeaderAtom )
6410 : {
6411 80 : if ( aClientTextBoxHd.nRecInstance == nRefNum )
6412 : {
6413 56 : aClientTextBoxHd.SeekToEndOfRecord( rIn );
6414 56 : break;
6415 : }
6416 : }
6417 94 : aClientTextBoxHd.SeekToEndOfRecord( rIn );
6418 : }
6419 56 : if ( rIn.Tell() > pE->nSlidePersistEndOffset )
6420 0 : bStatus = sal_False;
6421 : else
6422 : { // patching the RecordHeader
6423 56 : aClientTextBoxHd.nFilePos -= DFF_COMMON_RECORD_HEADER_SIZE;
6424 56 : aClientTextBoxHd.nRecLen += DFF_COMMON_RECORD_HEADER_SIZE;
6425 56 : aClientTextBoxHd.nRecType = DFF_msofbtClientTextbox;
6426 56 : aClientTextBoxHd.nRecVer = DFF_PSFLAG_CONTAINER;
6427 :
6428 : // we have to calculate the correct record len
6429 56 : DffRecordHeader aTmpHd;
6430 279 : while ( rIn.Tell() < pE->nSlidePersistEndOffset )
6431 : {
6432 193 : rIn >> aTmpHd;
6433 193 : if ( ( aTmpHd.nRecType == PPT_PST_SlidePersistAtom ) || ( aTmpHd.nRecType == PPT_PST_TextHeaderAtom ) )
6434 26 : break;
6435 167 : aTmpHd.SeekToEndOfRecord( rIn );
6436 167 : aClientTextBoxHd.nRecLen += aTmpHd.nRecLen + DFF_COMMON_RECORD_HEADER_SIZE;
6437 : }
6438 56 : aClientTextBoxHd.SeekToContent( rIn );
6439 : }
6440 : }
6441 : }
6442 : }
6443 : }
6444 :
6445 600 : if ( bStatus )
6446 : {
6447 600 : if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_TextHeaderAtom, aClientTextBoxHd.GetRecEndFilePos(), &aTextHd ) )
6448 : {
6449 : // TextHeaderAtom is always the first Atom
6450 : sal_uInt16 nInstance;
6451 600 : rIn >> nInstance; // this number tells us the TxMasterStyleAtom Instance
6452 600 : if ( nInstance > 8 )
6453 0 : nInstance = 4;
6454 600 : aTextHd.SeekToEndOfRecord( rIn );
6455 600 : mpImplTextObj->mnInstance = nInstance;
6456 :
6457 600 : sal_uInt32 nFilePos = rIn.Tell();
6458 664 : if ( rSdrPowerPointImport.SeekToRec2( PPT_PST_TextBytesAtom,
6459 : PPT_PST_TextCharsAtom,
6460 600 : aClientTextBoxHd.GetRecEndFilePos() )
6461 : || rSdrPowerPointImport.SeekToRec( rIn,
6462 : PPT_PST_StyleTextPropAtom,
6463 64 : aClientTextBoxHd.GetRecEndFilePos() ) )
6464 : {
6465 : PPTTextRulerInterpreter aTextRulerInterpreter( nTextRulerAtomOfs, rSdrPowerPointImport,
6466 587 : aClientTextBoxHd, rIn );
6467 :
6468 : PPTStyleTextPropReader aStyleTextPropReader( rIn, rSdrPowerPointImport, aClientTextBoxHd,
6469 587 : aTextRulerInterpreter, aExtParaHd, nInstance );
6470 587 : sal_uInt32 nParagraphs = mpImplTextObj->mnParagraphCount = aStyleTextPropReader.aParaPropList.size();
6471 587 : if ( nParagraphs )
6472 : {
6473 : // the language settings will be merged into the list of PPTCharPropSet
6474 587 : DffRecordHeader aTextSpecInfoHd;
6475 587 : PPTTextSpecInfoAtomInterpreter aTextSpecInfoAtomInterpreter;
6476 587 : if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_TextSpecInfoAtom,
6477 587 : aClientTextBoxHd.GetRecEndFilePos(), &aTextSpecInfoHd ) )
6478 : {
6479 587 : if ( aTextSpecInfoAtomInterpreter.Read( rIn, aTextSpecInfoHd, PPT_PST_TextSpecInfoAtom,
6480 587 : &(rSdrPowerPointImport.pPPTStyleSheet->maTxSI) ) )
6481 : {
6482 587 : sal_uInt32 nI = 0;
6483 : PPTTextSpecInfo* pSpecInfo;
6484 1335 : for ( size_t i = 0; i < aTextSpecInfoAtomInterpreter.aList.size(); ++i)
6485 : {
6486 748 : pSpecInfo = aTextSpecInfoAtomInterpreter.aList[ i ];
6487 748 : sal_uInt32 nCharIdx = pSpecInfo->nCharIdx;
6488 :
6489 : // portions and text have to been splitted in some cases
6490 2683 : for ( ; nI < aStyleTextPropReader.aCharPropList.size(); )
6491 : {
6492 1299 : PPTCharPropSet* pSet = aStyleTextPropReader.aCharPropList[ nI ];
6493 1299 : if ( pSet->mnOriginalTextPos < nCharIdx )
6494 : {
6495 1187 : pSet->mnLanguage[ 0 ] = pSpecInfo->nLanguage[ 0 ];
6496 1187 : pSet->mnLanguage[ 1 ] = pSpecInfo->nLanguage[ 1 ];
6497 1187 : pSet->mnLanguage[ 2 ] = pSpecInfo->nLanguage[ 2 ];
6498 : // test if the current portion needs to be splitted
6499 1187 : if ( pSet->maString.Len() > 1 )
6500 : {
6501 841 : sal_Int32 nIndexOfNextPortion = pSet->maString.Len() + pSet->mnOriginalTextPos;
6502 841 : sal_Int32 nNewLen = nIndexOfNextPortion - nCharIdx;
6503 841 : sal_Int32 nOldLen = pSet->maString.Len() - nNewLen;
6504 :
6505 841 : if ( ( nNewLen > 0 ) && ( nOldLen > 0 ) )
6506 : {
6507 44 : String aString( pSet->maString );
6508 44 : PPTCharPropSet* pNew = new PPTCharPropSet( *pSet );
6509 44 : pSet->maString = String( aString, 0, (sal_uInt16)nOldLen );
6510 44 : pNew->maString = String( aString, (sal_uInt16)nOldLen, (sal_uInt16)nNewLen );
6511 44 : pNew->mnOriginalTextPos += nOldLen;
6512 44 : aStyleTextPropReader.aCharPropList.insert( aStyleTextPropReader.aCharPropList.begin() + nI + 1, pNew );
6513 : }
6514 : }
6515 : }
6516 : else
6517 112 : break;
6518 1187 : nI++;
6519 : }
6520 : }
6521 : }
6522 : #ifdef DBG_UTIL
6523 : else
6524 : {
6525 : if (!(rSdrPowerPointImport.rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT))
6526 : {
6527 : OSL_FAIL( "SdrTextSpecInfoAtomInterpreter::Ctor(): parsing error, this document needs to be analysed (SJ)" );
6528 : }
6529 : }
6530 : #endif
6531 : }
6532 : // now will search for possible textextensions such as date/time fields
6533 : // or ParaTabStops and append them on this textobj
6534 587 : rIn.Seek( nFilePos );
6535 587 : ::std::vector< PPTFieldEntry* > FieldList;
6536 3360 : while ( rIn.Tell() < aClientTextBoxHd.GetRecEndFilePos() )
6537 : {
6538 2186 : rIn >> aTextHd;
6539 2186 : sal_uInt16 nVal = 0;
6540 2186 : PPTFieldEntry* pEntry = NULL;
6541 2186 : switch ( aTextHd.nRecType )
6542 : {
6543 : case PPT_PST_DateTimeMCAtom :
6544 : {
6545 0 : pEntry = new PPTFieldEntry;
6546 0 : rIn >> pEntry->nPos
6547 0 : >> nVal
6548 0 : >> nVal;
6549 0 : pEntry->SetDateTime( nVal & 0xff );
6550 : }
6551 0 : break;
6552 :
6553 : case PPT_PST_FooterMCAtom :
6554 : {
6555 10 : pEntry = new PPTFieldEntry;
6556 10 : rIn >> pEntry->nPos;
6557 10 : pEntry->pField1 = new SvxFieldItem( SvxFooterField(), EE_FEATURE_FIELD );
6558 : }
6559 10 : break;
6560 :
6561 : case PPT_PST_HeaderMCAtom :
6562 : {
6563 5 : pEntry = new PPTFieldEntry;
6564 5 : rIn >> pEntry->nPos;
6565 5 : pEntry->pField1 = new SvxFieldItem( SvxHeaderField(), EE_FEATURE_FIELD );
6566 : }
6567 5 : break;
6568 :
6569 : case PPT_PST_GenericDateMCAtom :
6570 : {
6571 10 : pEntry = new PPTFieldEntry;
6572 10 : rIn >> pEntry->nPos;
6573 10 : pEntry->pField1 = new SvxFieldItem( SvxDateTimeField(), EE_FEATURE_FIELD );
6574 10 : if ( rPersistEntry.pHeaderFooterEntry ) // sj: #i34111# on master pages it is possible
6575 : { // that there is no HeaderFooterEntry available
6576 10 : if ( rPersistEntry.pHeaderFooterEntry->nAtom & 0x20000 ) // auto date time
6577 0 : pEntry->SetDateTime( rPersistEntry.pHeaderFooterEntry->nAtom & 0xff );
6578 : else
6579 10 : pEntry->pString = new String( rPersistEntry.pHeaderFooterEntry->pPlaceholder[ nVal ] );
6580 : }
6581 : }
6582 10 : break;
6583 :
6584 : case PPT_PST_SlideNumberMCAtom :
6585 : case PPT_PST_RTFDateTimeMCAtom :
6586 : {
6587 9 : pEntry = new PPTFieldEntry;
6588 9 : if ( aTextHd.nRecLen >= 4 )
6589 : {
6590 9 : rIn >> pEntry->nPos
6591 9 : >> nVal;
6592 :
6593 : // evaluate ID
6594 : //SvxFieldItem* pFieldItem = NULL;
6595 9 : switch( aTextHd.nRecType )
6596 : {
6597 : case PPT_PST_SlideNumberMCAtom:
6598 9 : pEntry->pField1 = new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD );
6599 9 : break;
6600 :
6601 : case PPT_PST_RTFDateTimeMCAtom:
6602 : {
6603 : // Rude workaround for one special case reported
6604 : // by a customer. (#i75203#)
6605 :
6606 : // Don't even attempt to handle the general use
6607 : // case for PPT_PST_RTFDateTimeMCAtom (a generic
6608 : // MS style date/time format string). Just handle
6609 : // the special case where the format string
6610 : // contains only one or several possibly empty
6611 : // quoted strings. I.e. something that doesn't
6612 : // expand to any date or time at all, but to a
6613 : // fixed string. How on earth somebody manages to
6614 : // produce such things in PPT slides I have no
6615 : // idea.
6616 0 : if (nVal == 0)
6617 : {
6618 : sal_Unicode n;
6619 : xub_StrLen nLen;
6620 0 : String aStr;
6621 0 : bool inquote = sal_False;
6622 0 : for (nLen = 0, n = 0; nLen < 64; nLen++)
6623 : {
6624 0 : rIn >> n;
6625 :
6626 : // Collect quoted characters into aStr
6627 0 : if ( n == '\'')
6628 0 : inquote = !inquote;
6629 0 : else if (!n)
6630 : {
6631 : // End of format string
6632 0 : pEntry->pString = new String( aStr );
6633 0 : break;
6634 : }
6635 0 : else if (!inquote)
6636 : {
6637 : // Non-quoted character, i.e. a real
6638 : // format specifier. We don't handle
6639 : // those. Sorry.
6640 0 : break;
6641 : }
6642 : else
6643 : {
6644 0 : aStr += n;
6645 : }
6646 0 : }
6647 : }
6648 0 : if ( pEntry->pString == NULL )
6649 : {
6650 : // Handle as previously
6651 0 : pEntry->pField1 = new SvxFieldItem( SvxDateField( Date( Date::SYSTEM ), SVXDATETYPE_FIX ), EE_FEATURE_FIELD );
6652 : }
6653 : }
6654 : }
6655 : }
6656 : }
6657 9 : break;
6658 :
6659 : case PPT_PST_InteractiveInfo :
6660 : {
6661 4 : DffRecordHeader aHdInteractiveInfoAtom;
6662 4 : if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_InteractiveInfoAtom, aTextHd.GetRecEndFilePos(), &aHdInteractiveInfoAtom ) )
6663 : {
6664 : PptInteractiveInfoAtom aInteractiveInfoAtom;
6665 4 : rIn >> aInteractiveInfoAtom;
6666 4 : for ( size_t i = 0; i < rSdrPowerPointImport.aHyperList.size(); ++i )
6667 : {
6668 0 : SdHyperlinkEntry* pHyperlink = rSdrPowerPointImport.aHyperList[ i ];
6669 0 : if ( pHyperlink->nIndex == aInteractiveInfoAtom.nExHyperlinkId )
6670 : {
6671 0 : aTextHd.SeekToEndOfRecord( rIn );
6672 0 : rIn >> aTextHd;
6673 0 : if ( aTextHd.nRecType != PPT_PST_TxInteractiveInfoAtom )
6674 : {
6675 0 : aTextHd.SeekToBegOfRecord( rIn );
6676 0 : continue;
6677 : }
6678 : else
6679 : {
6680 : sal_uInt32 nStartPos, nEndPos;
6681 0 : rIn >> nStartPos
6682 0 : >> nEndPos;
6683 0 : if ( nEndPos )
6684 : {
6685 0 : pEntry = new PPTFieldEntry;
6686 0 : pEntry->nPos = (sal_uInt16)nStartPos;
6687 0 : pEntry->nTextRangeEnd = (sal_uInt16)nEndPos;
6688 0 : String aTarget( pHyperlink->aTarget );
6689 0 : if ( pHyperlink->aConvSubString.Len() )
6690 : {
6691 0 : aTarget.Append( (sal_Unicode)'#' );
6692 0 : aTarget.Append( pHyperlink->aConvSubString );
6693 : }
6694 0 : pEntry->pField1 = new SvxFieldItem( SvxURLField( aTarget, String(), SVXURLFORMAT_REPR ), EE_FEATURE_FIELD );
6695 : }
6696 : }
6697 0 : break;
6698 : }
6699 : }
6700 : }
6701 : }
6702 4 : break;
6703 : }
6704 2186 : aTextHd.SeekToEndOfRecord( rIn );
6705 2186 : if ( pEntry )
6706 : {
6707 : // sorting fields ( hi >> lo )
6708 34 : ::std::vector< PPTFieldEntry* >::iterator it = FieldList.begin();
6709 34 : for( ; it != FieldList.end(); ++it ) {
6710 0 : if ( (*it)->nPos < pEntry->nPos ) {
6711 0 : break;
6712 : }
6713 : }
6714 34 : if ( it != FieldList.end() ) {
6715 0 : FieldList.insert( it, pEntry );
6716 : } else {
6717 34 : FieldList.push_back( pEntry );
6718 : }
6719 : }
6720 : }
6721 587 : if ( !FieldList.empty() )
6722 : {
6723 34 : ::std::vector< PPTFieldEntry* >::iterator FE = FieldList.begin();
6724 34 : PPTCharPropSetList& aCharPropList = aStyleTextPropReader.aCharPropList;
6725 :
6726 34 : sal_Int32 i = nParagraphs - 1;
6727 34 : sal_Int32 n = aCharPropList.size() - 1;
6728 :
6729 : // at this point we just have a list of textportions(aCharPropList)
6730 : // the next while loop tries to resolve the list of fields(pFieldList)
6731 103 : while( ( FE < FieldList.end() ) && ( n >= 0 ) && ( i >= 0 ) )
6732 : {
6733 35 : PPTCharPropSet* pSet = aCharPropList[n];
6734 35 : String aString( pSet->maString );
6735 35 : sal_uInt32 nCount = aString.Len();
6736 35 : sal_uInt32 nPos = pSet->mnOriginalTextPos + nCount;
6737 70 : while ( ( FE < FieldList.end() ) && nCount-- )
6738 : {
6739 35 : nPos--;
6740 71 : while ( ( FE < FieldList.end() ) && ( (*FE)->nPos > nPos ) )
6741 1 : ++FE;
6742 35 : if ( !(FE < FieldList.end()) )
6743 1 : break;
6744 :
6745 34 : if ( (*FE)->nPos == nPos )
6746 : {
6747 34 : if ( aString.GetChar( (sal_uInt16)nCount ) == 0x2a )
6748 : {
6749 34 : sal_uInt32 nBehind = aString.Len() - ( nCount + 1 );
6750 34 : pSet->maString = String();
6751 34 : if ( nBehind )
6752 : {
6753 0 : PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet );
6754 0 : pNewCPS->maString = String( aString, (sal_uInt16)nCount + 1, (sal_uInt16)nBehind );
6755 0 : aCharPropList.insert( aCharPropList.begin() + n + 1, pNewCPS );
6756 : }
6757 34 : if ( (*FE)->pField2 )
6758 : {
6759 0 : PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet );
6760 0 : pNewCPS->mpFieldItem = (*FE)->pField2, (*FE)->pField2 = NULL;
6761 0 : aCharPropList.insert( aCharPropList.begin() + n + 1, pNewCPS );
6762 :
6763 0 : pNewCPS = new PPTCharPropSet( *pSet );
6764 0 : pNewCPS->maString = String( String( RTL_CONSTASCII_USTRINGPARAM( " " ) ) );
6765 0 : aCharPropList.insert( aCharPropList.begin() + n + 1, pNewCPS );
6766 : }
6767 34 : if ( nCount )
6768 : {
6769 0 : PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet );
6770 0 : pNewCPS->maString = String( aString, (sal_uInt16)0, (sal_uInt16)nCount );
6771 0 : aCharPropList.insert( aCharPropList.begin() + n++, pNewCPS );
6772 : }
6773 34 : if ( (*FE)->pField1 )
6774 : {
6775 34 : pSet->mpFieldItem = (*FE)->pField1, (*FE)->pField1 = NULL;
6776 : }
6777 0 : else if ( (*FE)->pString )
6778 0 : pSet->maString = *(*FE)->pString;
6779 : }
6780 : else
6781 : {
6782 0 : if ( (*FE)->nTextRangeEnd ) // text range hyperlink
6783 : {
6784 0 : sal_uInt32 nHyperLen = (*FE)->nTextRangeEnd - nPos;
6785 0 : if ( nHyperLen )
6786 : {
6787 0 : PPTCharPropSet* pBefCPS = NULL;
6788 0 : if ( nCount )
6789 : {
6790 0 : pBefCPS = new PPTCharPropSet( *pSet );
6791 0 : pSet->maString = String( pSet->maString, (sal_uInt16)nCount, (sal_uInt16)( pSet->maString.Len() - nCount ) );
6792 : }
6793 0 : sal_uInt32 nIdx = n;
6794 0 : sal_Int32 nHyperLenLeft = nHyperLen;
6795 :
6796 0 : while ( ( aCharPropList.size() > nIdx ) && nHyperLenLeft )
6797 : {
6798 : // the textrange hyperlink can take more than 1 paragraph
6799 : // the solution here is to clone the hyperlink...
6800 :
6801 0 : PPTCharPropSet* pCurrent = aCharPropList[ nIdx ];
6802 0 : sal_Int32 nNextStringLen = pCurrent->maString.Len();
6803 :
6804 : DBG_ASSERT( (*FE)->pField1, "missing field!" );
6805 0 : if (!(*FE)->pField1)
6806 0 : break;
6807 :
6808 0 : const SvxURLField* pField = (const SvxURLField*)(*FE)->pField1->GetField();
6809 :
6810 0 : if ( pCurrent->mpFieldItem )
6811 : {
6812 0 : pCurrent->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK );
6813 0 : if ( pCurrent->mpFieldItem->GetField()->ISA( SvxURLField ) )
6814 0 : break;
6815 0 : nHyperLenLeft--;
6816 : }
6817 0 : else if ( nNextStringLen )
6818 : {
6819 0 : if ( nNextStringLen <= nHyperLenLeft )
6820 : {
6821 0 : pCurrent->mpFieldItem = new SvxFieldItem( SvxURLField( pField->GetURL(), pCurrent->maString, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD );
6822 0 : nHyperLenLeft -= nNextStringLen;
6823 :
6824 0 : if ( nHyperLenLeft )
6825 : {
6826 : // if the next portion is in a higher paragraph,
6827 : // the textrange is to decrease (because of the LineBreak character)
6828 0 : if ( aCharPropList.size() > ( nIdx + 1 ) )
6829 : {
6830 0 : PPTCharPropSet* pNext = aCharPropList[ nIdx + 1 ];
6831 0 : if ( pNext->mnParagraph > pCurrent->mnParagraph )
6832 0 : nHyperLenLeft--;
6833 : }
6834 : }
6835 : }
6836 : else
6837 : {
6838 0 : PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pCurrent );
6839 0 : pNewCPS->maString = String( pCurrent->maString, (sal_uInt16)nHyperLenLeft, (sal_uInt16)( nNextStringLen - nHyperLenLeft ) );
6840 0 : aCharPropList.insert( aCharPropList.begin() + nIdx + 1, pNewCPS );
6841 0 : String aRepresentation( pCurrent->maString, 0, (sal_uInt16)nHyperLenLeft );
6842 0 : pCurrent->mpFieldItem = new SvxFieldItem( SvxURLField( pField->GetURL(), aRepresentation, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD );
6843 0 : nHyperLenLeft = 0;
6844 : }
6845 0 : pCurrent->maString = String();
6846 0 : pCurrent->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK );
6847 : }
6848 0 : nIdx++;
6849 : }
6850 0 : delete (*FE)->pField1, (*FE)->pField1 = NULL;
6851 :
6852 0 : if ( pBefCPS )
6853 : {
6854 0 : pBefCPS->maString = String( aString, (sal_uInt16)0, (sal_uInt16)nCount );
6855 0 : aCharPropList.insert( aCharPropList.begin() + n, pBefCPS );
6856 0 : n++;
6857 : }
6858 : }
6859 : }
6860 : }
6861 34 : break;
6862 : }
6863 : }
6864 35 : n--;
6865 35 : }
6866 68 : for( size_t j = 0, n2 = FieldList.size(); j < n2; ++j ) {
6867 34 : delete FieldList[ j ];
6868 : }
6869 : }
6870 587 : mpImplTextObj->mpParagraphList = new PPTParagraphObj*[ nParagraphs ];
6871 2722 : for (size_t nCurCharPos = 0, nCurPos = 0;
6872 1361 : nCurPos < aStyleTextPropReader.aParaPropList.size();
6873 : ++nCurPos)
6874 : {
6875 : PPTParagraphObj* pPara = new PPTParagraphObj(
6876 : aStyleTextPropReader, nCurPos, nCurCharPos,
6877 : *rSdrPowerPointImport.pPPTStyleSheet,
6878 774 : nInstance, aTextRulerInterpreter );
6879 774 : mpImplTextObj->mpParagraphList[ nCurPos ] = pPara;
6880 :
6881 774 : sal_uInt32 nParaAdjust, nFlags = 0;
6882 774 : pPara->GetAttrib( PPT_ParaAttr_Adjust, nParaAdjust, GetInstance() );
6883 :
6884 774 : switch ( nParaAdjust )
6885 : {
6886 327 : case 0 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT; break;
6887 433 : case 1 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER; break;
6888 14 : case 2 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT; break;
6889 0 : case 3 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK; break;
6890 : }
6891 774 : mpImplTextObj->mnTextFlags |= nFlags;
6892 587 : }
6893 587 : }
6894 : }
6895 : }
6896 : }
6897 : }
6898 : }
6899 1186 : }
6900 :
6901 0 : PPTTextObj::PPTTextObj( PPTTextObj& rTextObj )
6902 : {
6903 0 : mpImplTextObj = rTextObj.mpImplTextObj;
6904 0 : mpImplTextObj->mnRefCount++;
6905 0 : }
6906 :
6907 1186 : PPTTextObj::~PPTTextObj()
6908 : {
6909 1186 : ImplClear();
6910 1186 : }
6911 :
6912 1773 : PPTParagraphObj* PPTTextObj::First()
6913 : {
6914 1773 : mpImplTextObj->mnCurrentObject = 0;
6915 1773 : if ( !mpImplTextObj->mnParagraphCount )
6916 599 : return NULL;
6917 1174 : return mpImplTextObj->mpParagraphList[ 0 ];
6918 : }
6919 :
6920 1548 : PPTParagraphObj* PPTTextObj::Next()
6921 : {
6922 1548 : sal_uInt32 i = mpImplTextObj->mnCurrentObject + 1;
6923 1548 : if ( i >= mpImplTextObj->mnParagraphCount )
6924 1174 : return NULL;
6925 374 : mpImplTextObj->mnCurrentObject++;
6926 374 : return mpImplTextObj->mpParagraphList[ i ];
6927 : }
6928 :
6929 0 : const SfxItemSet* PPTTextObj::GetBackground() const
6930 : {
6931 0 : if ( mpImplTextObj->mrPersistEntry.pBObj )
6932 0 : return &mpImplTextObj->mrPersistEntry.pBObj->GetMergedItemSet();
6933 : else
6934 0 : return NULL;
6935 : }
6936 :
6937 1186 : void PPTTextObj::ImplClear()
6938 : {
6939 1186 : if ( ! ( --mpImplTextObj->mnRefCount ) )
6940 : {
6941 1960 : for ( PPTParagraphObj* pPtr = First(); pPtr; pPtr = Next() )
6942 774 : delete pPtr;
6943 1186 : delete[] mpImplTextObj->mpParagraphList;
6944 1186 : delete mpImplTextObj->mpPlaceHolderAtom;
6945 1186 : delete mpImplTextObj;
6946 : }
6947 1186 : }
6948 :
6949 0 : PPTTextObj& PPTTextObj::operator=( PPTTextObj& rTextObj )
6950 : {
6951 0 : if ( this != &rTextObj )
6952 : {
6953 0 : ImplClear();
6954 0 : mpImplTextObj = rTextObj.mpImplTextObj;
6955 0 : mpImplTextObj->mnRefCount++;
6956 : }
6957 0 : return *this;
6958 : }
6959 :
6960 2643 : sal_Bool IsLine( const SdrObject* pObj )
6961 : {
6962 2643 : return pObj->ISA( SdrPathObj ) && ((SdrPathObj*)pObj)->IsLine() && (((SdrPathObj*)pObj)->GetPointCount() == 2 );
6963 : }
6964 :
6965 396 : sal_Bool GetCellPosition( const SdrObject* pObj, const std::set< sal_Int32 >& rRows, const std::set< sal_Int32 >& rColumns,
6966 : sal_Int32& nTableIndex, sal_Int32& nRow, sal_Int32& nRowCount, sal_Int32& nColumn, sal_Int32& nColumnCount )
6967 : {
6968 396 : Rectangle aSnapRect( pObj->GetSnapRect() );
6969 396 : sal_Bool bCellObject = ( aSnapRect.GetWidth() > 1 ) && ( aSnapRect.GetHeight() > 1 );
6970 396 : if ( bCellObject )
6971 : {
6972 396 : std::set< sal_Int32 >::const_iterator aRowIter( rRows.find( aSnapRect.Top() ) );
6973 396 : std::set< sal_Int32 >::const_iterator aColumnIter( rColumns.find( aSnapRect.Left() ) );
6974 396 : if ( ( aRowIter == rRows.end() ) || ( aColumnIter == rColumns.end() ) )
6975 0 : bCellObject = sal_False;
6976 : else
6977 : {
6978 396 : nRowCount = 1;
6979 396 : nRow = std::distance( rRows.begin(), aRowIter );
6980 803 : while( ++aRowIter != rRows.end() )
6981 : {
6982 216 : if ( *aRowIter >= aSnapRect.Bottom() )
6983 205 : break;
6984 11 : nRowCount++;
6985 : }
6986 396 : nColumnCount = 1;
6987 396 : nColumn = std::distance( rColumns.begin(), aColumnIter );
6988 792 : while( ++aColumnIter != rColumns.end() )
6989 : {
6990 321 : if ( *aColumnIter >= aSnapRect.Right() )
6991 321 : break;
6992 0 : nColumnCount++;
6993 : }
6994 396 : nTableIndex = nRow * rColumns.size() + nColumn;
6995 : }
6996 : }
6997 396 : return bCellObject;
6998 : }
6999 :
7000 : #define LinePositionLeft 0x01000000
7001 : #define LinePositionTop 0x02000000
7002 : #define LinePositionRight 0x04000000
7003 : #define LinePositionBottom 0x08000000
7004 : #define LinePositionTLBR 0x10000000
7005 : #define LinePositionBLTR 0x20000000
7006 :
7007 :
7008 249 : void GetRowPositions( const Rectangle& rSnapRect, const std::set< sal_Int32 >& rRows,
7009 : const std::set< sal_Int32 >& rColumns, std::vector< sal_Int32 >& rPositions, sal_Int32 nColumn, sal_Int32 nFlags )
7010 : {
7011 249 : std::set< sal_Int32 >::const_iterator aRow( rRows.find( rSnapRect.Top() ) );
7012 249 : if ( aRow != rRows.end() )
7013 : {
7014 249 : sal_Int32 nRow = std::distance( rRows.begin(), aRow );
7015 945 : while( ( aRow != rRows.end() ) && ((*aRow) < rSnapRect.Bottom() ) )
7016 : {
7017 447 : if ( nFlags & LinePositionLeft )
7018 375 : rPositions.push_back( ( ( nRow * rColumns.size() ) + nColumn ) | LinePositionLeft );
7019 447 : if ( nFlags & LinePositionRight )
7020 375 : rPositions.push_back( ( ( nRow * rColumns.size() ) + ( nColumn - 1 ) ) | LinePositionRight );
7021 :
7022 447 : ++nRow;
7023 447 : ++aRow;
7024 : }
7025 : }
7026 249 : }
7027 :
7028 :
7029 236 : void GetColumnPositions( const Rectangle& rSnapRect, const std::set< sal_Int32 >& /* rRows */,
7030 : const std::set< sal_Int32 >& rColumns, std::vector< sal_Int32 >& rPositions, sal_Int32 nRow, sal_Int32 nFlags )
7031 : {
7032 236 : std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( rSnapRect.Left() ) );
7033 236 : if ( aColumn != rColumns.end() )
7034 : {
7035 236 : sal_Int32 nColumn = std::distance( rColumns.begin(), aColumn );
7036 1031 : while( ( aColumn != rColumns.end() ) && ((*aColumn) < rSnapRect.Right() ) )
7037 : {
7038 559 : if ( nFlags & LinePositionTop )
7039 392 : rPositions.push_back( ( ( nRow * rColumns.size() ) + nColumn ) | LinePositionTop );
7040 559 : if ( nFlags & LinePositionBottom )
7041 362 : rPositions.push_back( ( ( ( nRow - 1 ) * rColumns.size() ) + nColumn ) | LinePositionBottom );
7042 :
7043 559 : ++nColumn;
7044 559 : ++aColumn;
7045 : }
7046 : }
7047 236 : }
7048 :
7049 485 : void GetLinePositions( const SdrObject* pObj, const std::set< sal_Int32 >& rRows, const std::set< sal_Int32 >& rColumns,
7050 : std::vector< sal_Int32 >& rPositions, const Rectangle& rGroupSnap )
7051 : {
7052 485 : Rectangle aSnapRect( pObj->GetSnapRect() );
7053 485 : if ( aSnapRect.Left() == aSnapRect.Right() )
7054 : {
7055 249 : std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( aSnapRect.Left() ) );
7056 249 : if ( ( aColumn != rColumns.end() ) || ( aSnapRect.Left() == rGroupSnap.Right() ) )
7057 : {
7058 : sal_Int32 nColumn, nFlags;
7059 249 : if ( aColumn != rColumns.end() )
7060 : {
7061 200 : nColumn = std::distance( rColumns.begin(), aColumn );
7062 200 : nFlags = LinePositionLeft;
7063 200 : if ( aColumn != rColumns.begin() )
7064 144 : nFlags |= LinePositionRight;
7065 : }
7066 : else
7067 : {
7068 49 : nColumn = rColumns.size();
7069 49 : nFlags = LinePositionRight;
7070 : }
7071 249 : GetRowPositions( aSnapRect, rRows, rColumns, rPositions, nColumn, nFlags );
7072 : }
7073 : }
7074 236 : else if ( aSnapRect.Top() == aSnapRect.Bottom() )
7075 : {
7076 236 : std::set< sal_Int32 >::const_iterator aRow( rRows.find( aSnapRect.Top() ) );
7077 236 : if ( ( aRow != rRows.end() ) || ( aSnapRect.Top() == rGroupSnap.Bottom() ) )
7078 : {
7079 : sal_Int32 nRow, nFlags;
7080 236 : if ( aRow != rRows.end() )
7081 : {
7082 155 : nRow = std::distance( rRows.begin(), aRow );
7083 155 : nFlags = LinePositionTop;
7084 155 : if ( aRow != rRows.begin() )
7085 61 : nFlags |= LinePositionBottom;
7086 : }
7087 : else
7088 : {
7089 81 : nRow = rRows.size();
7090 81 : nFlags = LinePositionBottom;
7091 : }
7092 236 : GetColumnPositions( aSnapRect, rRows, rColumns, rPositions, nRow, nFlags );
7093 : }
7094 : }
7095 : else
7096 : {
7097 0 : sal_uInt32 nPosition = 0;
7098 0 : Point aPt1( ((SdrPathObj*)pObj)->GetPoint( 0 ) );
7099 0 : Point aPt2( ((SdrPathObj*)pObj)->GetPoint( 1 ) );
7100 0 : if ( aPt1.X() < aPt2.X() )
7101 0 : nPosition |= aPt1.Y() < aPt2.Y() ? LinePositionTLBR : LinePositionBLTR;
7102 : else
7103 0 : nPosition |= aPt1.Y() < aPt2.Y() ? LinePositionBLTR : LinePositionTLBR;
7104 :
7105 0 : std::set< sal_Int32 >::const_iterator aRow( rRows.find( aPt1.Y() < aPt2.Y() ? aPt1.Y() : aPt2.Y() ) );
7106 0 : std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( aPt1.X() < aPt2.X() ? aPt1.X() : aPt2.X() ) );
7107 0 : if ( ( aRow != rRows.end() ) && ( aColumn != rColumns.end() ) )
7108 : {
7109 0 : nPosition |= ( std::distance( rRows.begin(), aRow ) * rColumns.size() ) + std::distance( rColumns.begin(), aColumn );
7110 0 : rPositions.push_back( nPosition );
7111 : }
7112 : }
7113 485 : }
7114 :
7115 33 : void CreateTableRows( Reference< XTableRows > xTableRows, const std::set< sal_Int32 >& rRows, sal_Int32 nTableBottom )
7116 : {
7117 33 : if ( rRows.size() > 1 )
7118 23 : xTableRows->insertByIndex( 0, rRows.size() - 1 );
7119 :
7120 33 : std::set< sal_Int32 >::const_iterator aIter( rRows.begin() );
7121 33 : sal_Int32 nLastPosition( *aIter );
7122 33 : Reference< XIndexAccess > xIndexAccess( xTableRows, UNO_QUERY_THROW );
7123 106 : for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ )
7124 : {
7125 : sal_Int32 nHeight;
7126 73 : if ( ++aIter != rRows.end() )
7127 : {
7128 40 : nHeight = *aIter - nLastPosition;
7129 40 : nLastPosition = *aIter;
7130 : }
7131 : else
7132 33 : nHeight = nTableBottom - nLastPosition;
7133 :
7134 73 : static const rtl::OUString sWidth( RTL_CONSTASCII_USTRINGPARAM ( "Height" ) );
7135 73 : Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW );
7136 73 : xPropSet->setPropertyValue( sWidth, Any( nHeight ) );
7137 106 : }
7138 33 : }
7139 :
7140 33 : void CreateTableColumns( Reference< XTableColumns > xTableColumns, const std::set< sal_Int32 >& rColumns, sal_Int32 nTableRight )
7141 : {
7142 33 : if ( rColumns.size() > 1 )
7143 33 : xTableColumns->insertByIndex( 0, rColumns.size() - 1 );
7144 :
7145 33 : std::set< sal_Int32 >::const_iterator aIter( rColumns.begin() );
7146 33 : sal_Int32 nLastPosition( *aIter );
7147 33 : Reference< XIndexAccess > xIndexAccess( xTableColumns, UNO_QUERY_THROW );
7148 208 : for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ )
7149 : {
7150 : sal_Int32 nWidth;
7151 175 : if ( ++aIter != rColumns.end() )
7152 : {
7153 142 : nWidth = *aIter - nLastPosition;
7154 142 : nLastPosition = *aIter;
7155 : }
7156 : else
7157 33 : nWidth = nTableRight - nLastPosition;
7158 :
7159 175 : static const rtl::OUString sWidth( RTL_CONSTASCII_USTRINGPARAM ( "Width" ) );
7160 175 : Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW );
7161 175 : xPropSet->setPropertyValue( sWidth, Any( nWidth ) );
7162 208 : }
7163 33 : }
7164 :
7165 8 : void MergeCells( const Reference< XTable >& xTable, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan )
7166 : {
7167 : DBG_ASSERT( (nColSpan > 1) || (nRowSpan > 1), "nonsense parameter!!" );
7168 : DBG_ASSERT( (nCol >= 0) && (nCol < xTable->getColumnCount()) && (nRow >= 0) && (nRow < xTable->getRowCount()), "die celle gibts nicht!!" );
7169 : DBG_ASSERT( (nColSpan >= 1) && ((nCol + nColSpan - 1) < xTable->getColumnCount()), "nColSpan murks!" );
7170 : DBG_ASSERT( (nRowSpan >= 1) && ((nRow + nRowSpan - 1) < xTable->getRowCount()), "nRowSpan murks!" );
7171 :
7172 8 : if( xTable.is() ) try
7173 : {
7174 8 : Reference< XMergeableCellRange > xRange( xTable->createCursorByRange( xTable->getCellRangeByPosition( nCol, nRow,nCol + nColSpan - 1, nRow + nRowSpan - 1 ) ), UNO_QUERY_THROW );
7175 8 : if( xRange->isMergeable() )
7176 8 : xRange->merge();
7177 : }
7178 0 : catch( const Exception& )
7179 : {
7180 : DBG_ASSERT( false, "exception caught!" );
7181 : }
7182 8 : }
7183 :
7184 396 : void ApplyCellAttributes( const SdrObject* pObj, Reference< XCell >& xCell )
7185 : {
7186 : try
7187 : {
7188 396 : Reference< XPropertySet > xPropSet( xCell, UNO_QUERY_THROW );
7189 :
7190 396 : const sal_Int32 nLeftDist(((const SdrTextLeftDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_LEFTDIST)).GetValue());
7191 396 : const sal_Int32 nRightDist(((const SdrTextRightDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_RIGHTDIST)).GetValue());
7192 396 : const sal_Int32 nUpperDist(((const SdrTextUpperDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST)).GetValue());
7193 396 : const sal_Int32 nLowerDist(((const SdrTextLowerDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST)).GetValue());
7194 396 : static const rtl::OUString sTopBorder( RTL_CONSTASCII_USTRINGPARAM( "TextUpperDistance" ) );
7195 396 : static const rtl::OUString sBottomBorder( RTL_CONSTASCII_USTRINGPARAM( "TextLowerDistance" ) );
7196 396 : static const rtl::OUString sLeftBorder( RTL_CONSTASCII_USTRINGPARAM( "TextLeftDistance" ) );
7197 396 : static const rtl::OUString sRightBorder( RTL_CONSTASCII_USTRINGPARAM( "TextRightDistance" ) );
7198 396 : xPropSet->setPropertyValue( sTopBorder, Any( nUpperDist ) );
7199 396 : xPropSet->setPropertyValue( sRightBorder, Any( nRightDist ) );
7200 396 : xPropSet->setPropertyValue( sLeftBorder, Any( nLeftDist ) );
7201 396 : xPropSet->setPropertyValue( sBottomBorder, Any( nLowerDist ) );
7202 :
7203 396 : static const rtl::OUString sTextVerticalAdjust( RTL_CONSTASCII_USTRINGPARAM( "TextVerticalAdjust" ) );
7204 396 : const SdrTextVertAdjust eTextVertAdjust(((const SdrTextVertAdjustItem&)pObj->GetMergedItem(SDRATTR_TEXT_VERTADJUST)).GetValue());
7205 396 : drawing::TextVerticalAdjust eVA( drawing::TextVerticalAdjust_TOP );
7206 396 : if ( eTextVertAdjust == SDRTEXTVERTADJUST_CENTER )
7207 0 : eVA = drawing::TextVerticalAdjust_CENTER;
7208 396 : else if ( eTextVertAdjust == SDRTEXTVERTADJUST_BOTTOM )
7209 0 : eVA = drawing::TextVerticalAdjust_BOTTOM;
7210 396 : xPropSet->setPropertyValue( sTextVerticalAdjust, Any( eVA ) );
7211 :
7212 396 : SfxItemSet aSet( pObj->GetMergedItemSet() );
7213 396 : XFillStyle eFillStyle(((XFillStyleItem&)pObj->GetMergedItem( XATTR_FILLSTYLE )).GetValue());
7214 396 : ::com::sun::star::drawing::FillStyle eFS( com::sun::star::drawing::FillStyle_NONE );
7215 396 : switch( eFillStyle )
7216 : {
7217 : case XFILL_SOLID :
7218 : {
7219 130 : static const rtl::OUString sFillColor( String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ) );
7220 130 : eFS = com::sun::star::drawing::FillStyle_SOLID;
7221 130 : Color aFillColor( ((XFillColorItem&)pObj->GetMergedItem( XATTR_FILLCOLOR )).GetColorValue() );
7222 130 : sal_Int32 nFillColor( aFillColor.GetColor() );
7223 130 : xPropSet->setPropertyValue( sFillColor, Any( nFillColor ) );
7224 : }
7225 130 : break;
7226 : case XFILL_GRADIENT :
7227 : {
7228 0 : eFS = com::sun::star::drawing::FillStyle_GRADIENT;
7229 0 : XGradient aXGradient(((const XFillGradientItem&)pObj->GetMergedItem(XATTR_FILLGRADIENT)).GetGradientValue());
7230 :
7231 0 : com::sun::star::awt::Gradient aGradient;
7232 0 : aGradient.Style = (awt::GradientStyle) aXGradient.GetGradientStyle();
7233 0 : aGradient.StartColor = (sal_Int32)aXGradient.GetStartColor().GetColor();
7234 0 : aGradient.EndColor = (sal_Int32)aXGradient.GetEndColor().GetColor();
7235 0 : aGradient.Angle = (short)aXGradient.GetAngle();
7236 0 : aGradient.Border = aXGradient.GetBorder();
7237 0 : aGradient.XOffset = aXGradient.GetXOffset();
7238 0 : aGradient.YOffset = aXGradient.GetYOffset();
7239 0 : aGradient.StartIntensity = aXGradient.GetStartIntens();
7240 0 : aGradient.EndIntensity = aXGradient.GetEndIntens();
7241 0 : aGradient.StepCount = aXGradient.GetSteps();
7242 :
7243 0 : static const rtl::OUString sFillGradient( String( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ) ) );
7244 0 : xPropSet->setPropertyValue( sFillGradient, Any( aGradient ) );
7245 : }
7246 0 : break;
7247 : case XFILL_HATCH :
7248 0 : eFS = com::sun::star::drawing::FillStyle_HATCH;
7249 0 : break;
7250 : case XFILL_BITMAP :
7251 : {
7252 0 : eFS = com::sun::star::drawing::FillStyle_BITMAP;
7253 :
7254 0 : XFillBitmapItem aXFillBitmapItem((const XFillBitmapItem&)pObj->GetMergedItem( XATTR_FILLBITMAP ));
7255 0 : XOBitmap aLocalXOBitmap( aXFillBitmapItem.GetBitmapValue() );
7256 0 : rtl::OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
7257 : aURL += rtl::OStringToOUString(
7258 0 : aLocalXOBitmap.GetGraphicObject().GetUniqueID(),
7259 0 : RTL_TEXTENCODING_ASCII_US);
7260 :
7261 0 : static const rtl::OUString sFillBitmapURL( String( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" ) ) );
7262 0 : xPropSet->setPropertyValue( sFillBitmapURL, Any( aURL ) );
7263 : }
7264 0 : break;
7265 : case XFILL_NONE :
7266 266 : eFS = com::sun::star::drawing::FillStyle_NONE;
7267 266 : break;
7268 :
7269 : }
7270 396 : static const rtl::OUString sFillStyle( String( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ) ) );
7271 396 : xPropSet->setPropertyValue( sFillStyle, Any( eFS ) );
7272 396 : if ( eFillStyle != XFILL_NONE )
7273 : {
7274 130 : sal_Int16 nFillTransparence( ( (const XFillTransparenceItem&)pObj->GetMergedItem( XATTR_FILLTRANSPARENCE ) ).GetValue() );
7275 130 : if ( nFillTransparence != 100 )
7276 : {
7277 130 : nFillTransparence *= 100;
7278 130 : static const rtl::OUString sFillTransparence( String( RTL_CONSTASCII_USTRINGPARAM( "FillTransparence" ) ) );
7279 130 : xPropSet->setPropertyValue( sFillTransparence, Any( nFillTransparence ) );
7280 : }
7281 396 : }
7282 : }
7283 0 : catch( const Exception& )
7284 : {
7285 : }
7286 396 : }
7287 :
7288 485 : void ApplyCellLineAttributes( const SdrObject* pLine, Reference< XTable >& xTable, const std::vector< sal_Int32 >& vPositions, sal_Int32 nColumns )
7289 : {
7290 : try
7291 : {
7292 485 : SfxItemSet aSet( pLine->GetMergedItemSet() );
7293 485 : XLineStyle eLineStyle(((XLineStyleItem&)pLine->GetMergedItem( XATTR_LINESTYLE )).GetValue());
7294 485 : com::sun::star::table::BorderLine2 aBorderLine;
7295 485 : switch( eLineStyle )
7296 : {
7297 : case XLINE_DASH :
7298 : case XLINE_SOLID :
7299 : {
7300 440 : Color aLineColor( ((XLineColorItem&)pLine->GetMergedItem( XATTR_LINECOLOR )).GetColorValue() );
7301 440 : aBorderLine.Color = aLineColor.GetColor();
7302 440 : aBorderLine.LineWidth = static_cast< sal_Int16 >( ((const XLineWidthItem&)(pLine->GetMergedItem(XATTR_LINEWIDTH))).GetValue() / 4 );
7303 440 : aBorderLine.LineStyle = eLineStyle == XLINE_SOLID ? table::BorderLineStyle::SOLID : table::BorderLineStyle::DASHED;
7304 : }
7305 440 : break;
7306 : case XLINE_NONE :
7307 : {
7308 45 : aBorderLine.LineWidth = 0;
7309 45 : aBorderLine.LineStyle = table::BorderLineStyle::NONE;
7310 : }
7311 45 : break;
7312 : }
7313 485 : Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
7314 485 : std::vector< sal_Int32 >::const_iterator aIter( vPositions.begin() );
7315 2474 : while( aIter != vPositions.end() )
7316 : {
7317 1504 : static const rtl::OUString sTopBorder( String( RTL_CONSTASCII_USTRINGPARAM( "TopBorder" ) ) );
7318 1504 : static const rtl::OUString sBottomBorder( String( RTL_CONSTASCII_USTRINGPARAM( "BottomBorder" ) ) );
7319 1504 : static const rtl::OUString sLeftBorder( String( RTL_CONSTASCII_USTRINGPARAM( "LeftBorder" ) ) );
7320 1504 : static const rtl::OUString sRightBorder( String( RTL_CONSTASCII_USTRINGPARAM( "RightBorder" ) ) );
7321 1504 : static const rtl::OUString sDiagonalTLBR( RTL_CONSTASCII_USTRINGPARAM ( "DiagonalTLBR" ) );
7322 1504 : static const rtl::OUString sDiagonalBLTR( RTL_CONSTASCII_USTRINGPARAM ( "DiagonalBLTR" ) );
7323 :
7324 1504 : sal_Int32 nPosition = *aIter & 0xffffff;
7325 1504 : sal_Int32 nFlags = *aIter &~0xffffff;
7326 1504 : sal_Int32 nRow = nPosition / nColumns;
7327 1504 : sal_Int32 nColumn = nPosition - ( nRow * nColumns );
7328 1504 : Reference< XCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ) );
7329 1504 : Reference< XPropertySet > xPropSet( xCell, UNO_QUERY_THROW );
7330 :
7331 1504 : if ( nFlags & LinePositionLeft )
7332 375 : xPropSet->setPropertyValue( sLeftBorder, Any( aBorderLine ) );
7333 1504 : if ( nFlags & LinePositionTop )
7334 392 : xPropSet->setPropertyValue( sTopBorder, Any( aBorderLine ) );
7335 1504 : if ( nFlags & LinePositionRight )
7336 375 : xPropSet->setPropertyValue( sRightBorder, Any( aBorderLine ) );
7337 1504 : if ( nFlags & LinePositionBottom )
7338 362 : xPropSet->setPropertyValue( sBottomBorder, Any( aBorderLine ) );
7339 1504 : if ( nFlags & LinePositionTLBR )
7340 0 : xPropSet->setPropertyValue( sDiagonalTLBR, Any( sal_True ) );
7341 1504 : if ( nFlags & LinePositionBLTR )
7342 0 : xPropSet->setPropertyValue( sDiagonalBLTR, Any( sal_True ) );
7343 1504 : ++aIter;
7344 1989 : }
7345 : }
7346 0 : catch( const Exception& )
7347 : {
7348 : }
7349 485 : }
7350 :
7351 33 : SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, sal_uInt32* pTableArry, SvxMSDffSolverContainer* pSolverContainer )
7352 : {
7353 33 : SdrObject* pRet = pGroup;
7354 33 : sal_uInt32 nRows = pTableArry[ 1 ];
7355 33 : if ( nRows && pGroup->ISA( SdrObjGroup ) )
7356 : {
7357 33 : SdrObjList* pSubList(((SdrObjGroup*)pGroup)->GetSubList());
7358 33 : if ( pSubList )
7359 : {
7360 33 : std::set< sal_Int32 > aRows;
7361 33 : std::set< sal_Int32 > aColumns;
7362 :
7363 33 : SdrObjListIter aGroupIter( *pSubList, IM_DEEPNOGROUPS, sal_False );
7364 947 : while( aGroupIter.IsMore() )
7365 : {
7366 881 : const SdrObject* pObj( aGroupIter.Next() );
7367 881 : if ( !IsLine( pObj ) )
7368 : {
7369 396 : Rectangle aSnapRect( pObj->GetSnapRect() );
7370 396 : aRows.insert( aSnapRect.Top() );
7371 396 : aColumns.insert( aSnapRect.Left() );
7372 : }
7373 : }
7374 33 : ::sdr::table::SdrTableObj* pTable = new ::sdr::table::SdrTableObj( pSdrModel );
7375 33 : pTable->uno_lock();
7376 33 : Reference< XTable > xTable( pTable->getTable() );
7377 : try
7378 : {
7379 33 : Reference< XColumnRowRange > xColumnRowRange( xTable, UNO_QUERY_THROW );
7380 :
7381 33 : CreateTableRows( xColumnRowRange->getRows(), aRows, pGroup->GetSnapRect().Bottom() );
7382 33 : CreateTableColumns( xColumnRowRange->getColumns(), aColumns, pGroup->GetSnapRect().Right() );
7383 :
7384 33 : sal_Int32 nCellCount = aRows.size() * aColumns.size();
7385 33 : sal_Int32 *pMergedCellIndexTable = new sal_Int32[ nCellCount ];
7386 424 : for ( sal_Int32 i = 0; i < nCellCount; i++ )
7387 391 : pMergedCellIndexTable[ i ] = i;
7388 :
7389 33 : aGroupIter.Reset();
7390 947 : while( aGroupIter.IsMore() )
7391 : {
7392 881 : SdrObject* pObj( aGroupIter.Next() );
7393 881 : if ( !IsLine( pObj ) )
7394 : {
7395 396 : sal_Int32 nTableIndex = 0;
7396 396 : sal_Int32 nRow = 0;
7397 396 : sal_Int32 nRowCount = 0;
7398 396 : sal_Int32 nColumn = 0;
7399 396 : sal_Int32 nColumnCount = 0;
7400 396 : if ( GetCellPosition( pObj, aRows, aColumns, nTableIndex, nRow, nRowCount, nColumn, nColumnCount ) )
7401 : {
7402 396 : Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
7403 396 : Reference< XCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ) );
7404 :
7405 396 : ApplyCellAttributes( pObj, xCell );
7406 :
7407 396 : if ( ( nRowCount > 1 ) || ( nColumnCount > 1 ) ) // cell merging
7408 : {
7409 8 : MergeCells( xTable, nColumn, nRow, nColumnCount, nRowCount );
7410 27 : for ( sal_Int32 nRowIter = 0; nRowIter < nRowCount; nRowIter++ )
7411 : {
7412 38 : for ( sal_Int32 nColumnIter = 0; nColumnIter < nColumnCount; nColumnIter++ )
7413 : { // now set the correct index for the merged cell
7414 19 : pMergedCellIndexTable[ ( ( nRow + nRowIter ) * aColumns.size() ) + nColumn + nColumnIter ] = nTableIndex;
7415 : }
7416 : }
7417 : }
7418 :
7419 : // applying text
7420 396 : OutlinerParaObject* pParaObject = pObj->GetOutlinerParaObject();
7421 396 : if ( pParaObject )
7422 : {
7423 396 : SdrText* pSdrText = pTable->getText( nTableIndex );
7424 396 : if ( pSdrText )
7425 396 : pSdrText->SetOutlinerParaObject(new OutlinerParaObject(*pParaObject) );
7426 396 : }
7427 : }
7428 : }
7429 : }
7430 33 : aGroupIter.Reset();
7431 947 : while( aGroupIter.IsMore() )
7432 : {
7433 881 : SdrObject* pObj( aGroupIter.Next() );
7434 881 : if ( IsLine( pObj ) )
7435 : {
7436 485 : std::vector< sal_Int32 > vPositions; // containing cell indexes + cell position
7437 485 : GetLinePositions( pObj, aRows, aColumns, vPositions, pGroup->GetSnapRect() );
7438 :
7439 : // correcting merged cell position
7440 485 : std::vector< sal_Int32 >::iterator aIter( vPositions.begin() );
7441 2474 : while( aIter != vPositions.end() )
7442 : {
7443 1504 : sal_Int32 nOldPosition = *aIter & 0xffff;
7444 1504 : sal_Int32 nOldFlags = *aIter & 0xffff0000;
7445 1504 : sal_Int32 nNewPosition = pMergedCellIndexTable[ nOldPosition ] | nOldFlags;
7446 1504 : *aIter++ = nNewPosition;
7447 : }
7448 485 : ApplyCellLineAttributes( pObj, xTable, vPositions, aColumns.size() );
7449 : }
7450 : }
7451 33 : delete[] pMergedCellIndexTable;
7452 :
7453 : // we are replacing the whole group object by a single table object, so
7454 : // possibly connections to the group object have to be removed.
7455 33 : if ( pSolverContainer )
7456 : {
7457 5 : for ( size_t i = 0; i < pSolverContainer->aCList.size(); ++i )
7458 : {
7459 0 : SvxMSDffConnectorRule* pPtr = pSolverContainer->aCList[ i ];
7460 :
7461 : // check connections to the group object
7462 0 : if ( pPtr->pAObj == pGroup )
7463 0 : pPtr->pAObj = NULL;
7464 0 : if ( pPtr->pBObj == pGroup )
7465 0 : pPtr->pBObj = NULL;
7466 :
7467 : // check connections to all its subobjects
7468 0 : SdrObjListIter aIter( *pGroup, IM_DEEPWITHGROUPS );
7469 0 : while( aIter.IsMore() )
7470 : {
7471 0 : SdrObject* pPartObj = aIter.Next();
7472 0 : if ( pPtr->pAObj == pPartObj )
7473 0 : pPtr->pAObj = NULL;
7474 0 : if ( pPtr->pBObj == pPartObj )
7475 0 : pPtr->pBObj = NULL;
7476 : }
7477 0 : }
7478 : }
7479 33 : pTable->uno_unlock();
7480 33 : pTable->SetSnapRect( pGroup->GetSnapRect() );
7481 33 : pRet = pTable;
7482 :
7483 : //Remove Objects from shape map
7484 33 : SdrObjListIter aIter( *pGroup, IM_DEEPWITHGROUPS );
7485 947 : while( aIter.IsMore() )
7486 : {
7487 881 : SdrObject* pPartObj = aIter.Next();
7488 881 : removeShapeId( pPartObj );
7489 : }
7490 :
7491 33 : SdrObject::Free( pGroup );
7492 : }
7493 0 : catch( const Exception& )
7494 : {
7495 0 : pTable->uno_unlock();
7496 0 : SdrObject* pObj = pTable;
7497 0 : SdrObject::Free( pObj );
7498 33 : }
7499 : }
7500 : }
7501 33 : return pRet;
7502 : }
7503 :
7504 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|