Update ooo320-m1
[ooovba.git] / svx / source / svdraw / svdfppt.cxx
blob5493b86d080d657014fc6d013afcf4bfad3bd3ea
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdfppt.cxx,v $
10 * $Revision: 1.163.6.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <osl/endian.h>
34 #include <vcl/svapp.hxx>
35 #include <unotools/tempfile.hxx>
36 #include <math.h>
37 #include <svx/eeitem.hxx>
38 #include <sot/storage.hxx>
39 #include <sot/storinfo.hxx>
40 #include <sot/stg.hxx>
41 #include <com/sun/star/embed/Aspects.hpp>
42 #include <com/sun/star/office/XAnnotation.hpp>
43 #include <com/sun/star/office/XAnnotationAccess.hpp>
44 #include <com/sun/star/text/XText.hpp>
45 #include <com/sun/star/geometry/RealPoint2D.hpp>
46 #include <com/sun/star/util/DateTime.hpp>
48 #include <unotools/streamwrap.hxx>
50 #include <svx/svdfppt.hxx>
51 #include <svx/xpoly.hxx>
52 #include <svx/svdtrans.hxx>
53 #include <svx/svdmodel.hxx>
54 #include <svx/svdpage.hxx>
55 #include <svx/svdobj.hxx>
56 #include <svx/svdogrp.hxx>
57 #include <svx/svdorect.hxx>
58 #include <svx/svdopage.hxx>
59 #include <svx/svdograf.hxx>
60 #include <svx/svdopath.hxx>
61 #include <svx/svdocirc.hxx>
62 #include <svx/svdocapt.hxx>
63 #include <svx/svdotable.hxx>
64 #include <svx/outlobj.hxx>
65 #include <svx/svdattr.hxx>
66 #include "xattr.hxx"
67 #include "svditext.hxx"
68 #include <svx/svdetc.hxx>
69 #include <bulitem.hxx>
70 #include <svx/polysc3d.hxx>
71 #include <svx/extrud3d.hxx>
72 #include <svx/svdoashp.hxx>
73 #include <svx/tstpitem.hxx>
74 #include <svx/unoprnms.hxx>
76 #if defined(JOEENV) && defined(JOEDEBUG)
77 #include "impinccv.h" // etwas Testkram
78 #endif
80 #if defined(DBG_EXTRACTOLEOBJECTS) || defined(DBG_EXTRACTFONTMETRICS)
81 #include <tools/urlobj.hxx>
82 #include <unotools/localfilehelper.hxx>
83 #endif
85 #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
86 #include <svx/adjitem.hxx>
87 #include <svx/escpitem.hxx>
88 #include <svx/colritem.hxx>
89 #include <svx/fhgtitem.hxx>
90 #include <svx/wghtitem.hxx>
91 #include <svx/postitem.hxx>
92 #include <svx/udlnitem.hxx>
93 #include <svx/crsditem.hxx>
94 #include <svx/shdditem.hxx>
95 #include <svx/charreliefitem.hxx>
96 #include <fontitem.hxx>
97 #include <svx/svdoutl.hxx>
98 #include <svx/editeng.hxx>
99 #include <svx/lspcitem.hxx>
100 #include <svx/ulspitem.hxx>
101 #include <svx/lrspitem.hxx>
102 #include <vcl/metric.hxx>
103 #include <vcl/bmpacc.hxx>
104 #include <svditer.hxx>
105 #include <svx/svdoedge.hxx>
106 #include <svx/sxekitm.hxx>
107 #include <svx/flditem.hxx>
108 #include <svtools/sychconv.hxx>
109 #include <tools/zcodec.hxx>
110 #include <svxmsbas.hxx>
111 #include <sfx2/objsh.hxx>
112 #include <svx/brshitem.hxx>
113 #include <svx/langitem.hxx>
114 #include <svx/svdoole2.hxx>
115 #include <unoapi.hxx>
116 #include <toolkit/unohlp.hxx>
117 #include <com/sun/star/container/XIndexContainer.hpp>
118 #include <com/sun/star/drawing/XShapes.hpp>
119 #include <com/sun/star/drawing/XControlShape.hpp>
120 #include <com/sun/star/form/XFormComponent.hpp>
121 #include <com/sun/star/beans/XPropertySet.hpp>
122 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
123 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
124 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
125 #include <com/sun/star/awt/Size.hpp>
126 #include <com/sun/star/awt/Point.hpp>
127 #include <com/sun/star/drawing/FillStyle.hpp>
128 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
129 #include <svx/writingmodeitem.hxx>
130 #include <vcl/print.hxx>
131 #include <svx/svxfont.hxx>
132 #include <svx/frmdiritem.hxx>
133 #include <svx/sdtfchim.hxx>
134 #include <unotools/ucbstreamhelper.hxx>
135 #include <svx/scripttypeitem.hxx>
136 #include "com/sun/star/awt/Gradient.hpp"
137 #include <com/sun/star/table/XMergeableCellRange.hpp>
138 #include <com/sun/star/table/BorderLine.hpp>
139 #include <vcl/virdev.hxx>
140 #include <algorithm>
141 #include <set>
143 ////////////////////////////////////////////////////////////////////////////////////////////////////
145 // PPT ColorScheme Slots
146 #define PPT_COLSCHEME (0x08000000)
147 #define PPT_COLSCHEME_HINTERGRUND (0x08000000)
148 #define PPT_COLSCHEME_TEXT_UND_ZEILEN (0x08000001)
149 #define PPT_COLSCHEME_SCHATTEN (0x08000002)
150 #define PPT_COLSCHEME_TITELTEXT (0x08000003)
151 #define PPT_COLSCHEME_FUELLBEREICHE (0x08000004)
152 #define PPT_COLSCHEME_AKZENT (0x08000005)
153 #define PPT_COLSCHEME_A_UND_HYPERLINK (0x08000006)
154 #define PPT_COLSCHEME_A_H_GESICHERT (0x08000007)
156 ////////////////////////////////////////////////////////////////////////////////////////////////////
158 #define ANSI_CHARSET 0
159 #define DEFAULT_CHARSET 1
160 #define SYMBOL_CHARSET 2
161 #define SHIFTJIS_CHARSET 128
162 #define HANGEUL_CHARSET 129
163 #define CHINESEBIG5_CHARSET 136
164 #define OEM_CHARSET 255
166 ////////////////////////////////////////////////////////////////////////////////////////////////////
168 /* Font Families */
169 #define FF_DONTCARE 0x00
170 #define FF_ROMAN 0x10
171 #define FF_SWISS 0x20
172 #define FF_MODERN 0x30
173 #define FF_SCRIPT 0x40
174 #define FF_DECORATIVE 0x50
176 ////////////////////////////////////////////////////////////////////////////////////////////////////
178 #define DEFAULT_PITCH 0x00
179 #define FIXED_PITCH 0x01
180 #define VARIABLE_PITCH 0x02
182 using namespace ::com::sun::star ;
183 using namespace uno ;
184 using namespace beans ;
185 using namespace drawing ;
186 using namespace container ;
187 using namespace table ;
189 ////////////////////////////////////////////////////////////////////////////////////////////////////
191 PowerPointImportParam::PowerPointImportParam( SvStream& rDocStrm, sal_uInt32 nFlags, MSFilterTracer* pT ) :
192 rDocStream ( rDocStrm ),
193 nImportFlags ( nFlags ),
194 pTracer ( pT )
198 ////////////////////////////////////////////////////////////////////////////////////////////////////
200 SvStream& operator>>( SvStream& rIn, PptCurrentUserAtom& rAtom )
202 DffRecordHeader aHd;
203 rIn >> aHd;
204 if ( aHd.nRecType == PPT_PST_CurrentUserAtom )
206 sal_uInt32 nLen;
207 sal_uInt16 nUserNameLen, nPad;
208 rIn >> nLen
209 >> rAtom.nMagic
210 >> rAtom.nCurrentUserEdit
211 >> nUserNameLen
212 >> rAtom.nDocFileVersion
213 >> rAtom.nMajorVersion
214 >> rAtom.nMinorVersion
215 >> nPad;
216 SvxMSDffManager::MSDFFReadZString( rIn, rAtom.aCurrentUser, nUserNameLen, sal_True );
218 aHd.SeekToEndOfRecord( rIn );
219 return rIn;
222 void PptSlidePersistAtom::Clear()
224 nReserved = nPsrReference = nFlags = nNumberTexts = nSlideId = 0;
227 SvStream& operator>>( SvStream& rIn, PptSlidePersistAtom& rAtom )
229 DffRecordHeader aHd;
230 rIn >> aHd
231 >> rAtom.nPsrReference
232 >> rAtom.nFlags
233 >> rAtom.nNumberTexts
234 >> rAtom.nSlideId;
235 // >> rAtom.nReserved;
236 aHd.SeekToEndOfRecord( rIn );
237 return rIn;
240 SV_IMPL_PTRARR(_PptSlidePersistList,PptSlidePersistEntry*);
242 USHORT PptSlidePersistList::FindPage(UINT32 nId) const
244 for ( USHORT i=0; i < Count(); i++ )
246 if (operator[](i)->GetSlideId()==nId) return i;
248 return PPTSLIDEPERSIST_ENTRY_NOTFOUND;
251 ////////////////////////////////////////////////////////////////////////////////////////////////////
253 SvStream& operator>>( SvStream& rIn, PptInteractiveInfoAtom& rAtom )
255 rIn >> rAtom.nSoundRef
256 >> rAtom.nExHyperlinkId
257 >> rAtom.nAction
258 >> rAtom.nOleVerb
259 >> rAtom.nJump
260 >> rAtom.nFlags
261 >> rAtom.nHyperlinkType
262 >> rAtom.nUnknown1
263 >> rAtom.nUnknown2
264 >> rAtom.nUnknown3;
265 return rIn;
268 SvStream& operator>>( SvStream& rIn, PptExOleObjAtom& rAtom )
270 rIn >> rAtom.nAspect
271 >> rAtom.nDummy1
272 >> rAtom.nId
273 >> rAtom.nDummy2
274 >> rAtom.nPersistPtr
275 >> rAtom.nDummy4;
276 return rIn;
279 Size PptDocumentAtom::GetPageSize(const Size& rSiz) const
281 return rSiz;
283 Size aRet;
284 switch ( eSlidesPageFormat )
286 // Wenn man in Powerpoint als Seitenformat "Bildschirmgroesse"
287 // einstellt, dann zeigt dieser Dialog zwar 24x18cm an, die
288 // angezeigte Seite ist aber anders. Das sieht man, wenn man
289 // ein Rechteck seitenfuellend aufzieht und sich dessen Groesse
290 // ansieht. Die importierten Abmessungen sind auf jeden Fall
291 // die, die auch im Ppt-File stehen. Ich denke, das es sich
292 // hier eher um ein Bug in PowerPoint handelt, das im
293 // Seitenformat-Dialog bei "Bildschirmgroesse" falsche Masse
294 // angezeigt werden (vielleicht ja auch bildschirmabhaengig?).
295 // case PPTPF_SCREEN : aRet.Width()=4082; aRet.Height()=5443; break;
296 case PPTPF_USLETTER: aRet.Width()=4896; aRet.Height()=6336; break;
297 case PPTPF_A4 : aRet.Width()=4762; aRet.Height()=6735; break;
298 // case PPTPF_35MMDIA : aRet.Width()=4082; aRet.Height()=6123; break;
299 // case PPTPF_OVERHEAD: aRet.Width()=4082; aRet.Height()=5443; break;
301 if ( aRet.Width() )
303 if ( rSiz.Width() > rSiz.Height() )
304 { // Querformat
305 long nMerk = aRet.Width();
306 aRet.Width() = aRet.Height();
307 aRet.Height() = nMerk;
310 else // CustomFormat oder Unbekannt oder Screen,Dia,Overhead
311 aRet = rSiz;
312 return aRet;
316 SvStream& operator>>(SvStream& rIn, PptDocumentAtom& rAtom)
318 // Tatsaechliches Format:
319 // 00 aSlidePageSizeXY 8
320 // 08 aNotesPageSizeXY 8
321 // 16 aZoomRatio (OLE) 8
322 // 24 nNotesMasterPersist 4
323 // 28 nHandoutMasterPersist 4
324 // 32 n1stPageNumber 2
325 // 34 ePageFormat 2
326 // 36 bEmbeddedTrueType 1
327 // 37 bOmitTitlePlace 1
328 // 38 bRightToLeft 1
329 // 39 bShowComments 1
331 DffRecordHeader aHd;
332 INT32 nSlideX,nSlideY, nNoticeX, nNoticeY, nDummy;
333 UINT16 nSlidePageFormat;
334 INT8 nEmbeddedTrueType, nTitlePlaceHoldersOmitted, nRightToLeft, nShowComments;
336 rIn >> aHd
337 >> nSlideX >> nSlideY
338 >> nNoticeX >> nNoticeY
339 >> nDummy >> nDummy // ZoomRation ueberspringen
340 >> rAtom.nNotesMasterPersist
341 >> rAtom.nHandoutMasterPersist
342 >> rAtom.n1stPageNumber
343 >> nSlidePageFormat
344 >> nEmbeddedTrueType
345 >> nTitlePlaceHoldersOmitted
346 >> nRightToLeft
347 >> nShowComments;
348 rAtom.aSlidesPageSize.Width() = nSlideX;
349 rAtom.aSlidesPageSize.Height() = nSlideY;
350 rAtom.aNotesPageSize.Width() = nNoticeX;
351 rAtom.aNotesPageSize.Height() = nNoticeY;
352 rAtom.eSlidesPageFormat = (PptPageFormat)nSlidePageFormat;
353 rAtom.bEmbeddedTrueType = nEmbeddedTrueType;
354 rAtom.bTitlePlaceholdersOmitted = nTitlePlaceHoldersOmitted;
355 rAtom.bRightToLeft = nRightToLeft;
356 rAtom.bShowComments = nShowComments;
357 aHd.SeekToEndOfRecord( rIn );
358 return rIn;
361 ////////////////////////////////////////////////////////////////////////////////////////////////////
363 void PptSlideLayoutAtom::Clear()
365 eLayout = 0;
366 for ( USHORT i = 0; i < 8; i++ )
368 aPlaceholderId[ i ] = 0;
369 aPlacementId[ i ] = 0;
373 SvStream& operator>>( SvStream& rIn, PptSlideLayoutAtom& rAtom )
375 rIn >> rAtom.eLayout;
376 rIn.Read( rAtom.aPlaceholderId, 8 );
377 return rIn;
380 ////////////////////////////////////////////////////////////////////////////////////////////////////
382 SvStream& operator>>( SvStream& rIn, PptSlideAtom& rAtom )
384 DffRecordHeader aHd;
385 rIn >> aHd
386 >> rAtom.aLayout
387 >> rAtom.nMasterId
388 >> rAtom.nNotesId
389 >> rAtom.nFlags;
390 aHd.SeekToEndOfRecord( rIn );
391 return rIn;
394 void PptSlideAtom::Clear()
396 nMasterId = nNotesId = 0;
397 nFlags = 0;
400 ////////////////////////////////////////////////////////////////////////////////////////////////////
402 SvStream& operator>>( SvStream& rIn, PptNotesAtom& rAtom )
404 DffRecordHeader aHd;
405 rIn >> aHd
406 >> rAtom.nSlideId
407 >> rAtom.nFlags;
408 aHd.SeekToEndOfRecord( rIn );
409 return rIn;
412 void PptNotesAtom::Clear()
414 nSlideId = 0;
415 nFlags = 0;
418 ////////////////////////////////////////////////////////////////////////////////////////////////////
420 void PptColorSchemeAtom::Clear()
422 memset(&aData[0], 0, 32);
425 Color PptColorSchemeAtom::GetColor( USHORT nNum ) const
427 Color aRetval;
428 if ( nNum < 8 )
430 nNum <<= 2;
431 aRetval.SetRed( aData[ nNum++ ] );
432 aRetval.SetGreen( aData[ nNum++ ] );
433 aRetval.SetBlue( aData[ nNum++ ] );
435 return aRetval;
438 SvStream& operator>>( SvStream& rIn, PptColorSchemeAtom& rAtom )
440 DffRecordHeader aHd;
441 rIn >> aHd;
442 rIn.Read( rAtom.aData, 32 );
443 aHd.SeekToEndOfRecord( rIn );
444 return rIn;
447 ////////////////////////////////////////////////////////////////////////////////////////////////////
449 SvStream& operator>>( SvStream& rIn, PptFontEntityAtom& rAtom )
451 DffRecordHeader aHd;
452 rIn >> aHd;
453 sal_Unicode nTemp, cData[ 32 ];
454 rIn.Read( cData, 64 );
456 sal_uInt8 lfCharset, lfPitchAndFamily;
458 rIn >> lfCharset
459 >> rAtom.lfClipPrecision
460 >> rAtom.lfQuality
461 >> lfPitchAndFamily;
463 switch( lfCharset )
465 case SYMBOL_CHARSET :
466 rAtom.eCharSet = RTL_TEXTENCODING_SYMBOL;
467 break;
468 case ANSI_CHARSET :
469 rAtom.eCharSet = RTL_TEXTENCODING_MS_1252;
470 break;
472 // case DEFAULT_CHARSET :
473 // case SHIFTJIS_CHARSET :
474 // case HANGEUL_CHARSET :
475 // case CHINESEBIG5_CHARSET :
476 // case OEM_CHARSET :
477 default :
478 rAtom.eCharSet = gsl_getSystemTextEncoding();
480 switch ( lfPitchAndFamily & 0xf0 )
482 case FF_ROMAN:
483 rAtom.eFamily = FAMILY_ROMAN;
484 break;
486 case FF_SWISS:
487 rAtom.eFamily = FAMILY_SWISS;
488 break;
490 case FF_MODERN:
491 rAtom.eFamily = FAMILY_MODERN;
492 break;
494 case FF_SCRIPT:
495 rAtom.eFamily = FAMILY_SCRIPT;
496 break;
498 case FF_DECORATIVE:
499 rAtom.eFamily = FAMILY_DECORATIVE;
500 break;
502 default:
503 rAtom.eFamily = FAMILY_DONTKNOW;
504 break;
507 switch ( lfPitchAndFamily & 0x0f )
509 case FIXED_PITCH:
510 rAtom.ePitch = PITCH_FIXED;
511 break;
513 case DEFAULT_PITCH:
514 case VARIABLE_PITCH:
515 default:
516 rAtom.ePitch = PITCH_VARIABLE;
517 break;
519 sal_uInt16 i;
520 for ( i = 0; i < 32; i++ )
522 nTemp = cData[ i ];
523 if ( !nTemp )
524 break;
525 #ifdef OSL_BIGENDIAN
526 cData[ i ] = ( nTemp >> 8 ) | ( nTemp << 8 );
527 #endif
529 rAtom.aName = String( cData, i );
530 OutputDevice* pDev = (OutputDevice*)Application::GetDefaultDevice();
531 rAtom.bAvailable = pDev->IsFontAvailable( rAtom.aName );
532 aHd.SeekToEndOfRecord( rIn );
533 return rIn;
536 SV_DECL_PTRARR_DEL( PptFontEntityAtomList, PptFontEntityAtom*, 16, 16 )
537 SV_IMPL_PTRARR( PptFontEntityAtomList, PptFontEntityAtom* );
539 class PptFontCollection: public PptFontEntityAtomList {
542 ////////////////////////////////////////////////////////////////////////////////////////////////////
544 SvStream& operator>>( SvStream& rIn, PptUserEditAtom& rAtom )
546 rIn >> rAtom.aHd
547 >> rAtom.nLastSlideID
548 >> rAtom.nVersion
549 >> rAtom.nOffsetLastEdit
550 >> rAtom.nOffsetPersistDirectory
551 >> rAtom.nDocumentRef
552 >> rAtom.nMaxPersistWritten
553 >> rAtom.eLastViewType;
554 rAtom.aHd.SeekToEndOfRecord(rIn);
555 return rIn;
558 ////////////////////////////////////////////////////////////////////////////////////////////////////
560 void PptOEPlaceholderAtom::Clear()
562 nPlacementId = 0;
563 nPlaceholderSize = nPlaceholderId = 0;
566 SvStream& operator>>( SvStream& rIn, PptOEPlaceholderAtom& rAtom )
568 rIn >> rAtom.nPlacementId
569 >> rAtom.nPlaceholderId
570 >> rAtom.nPlaceholderSize;
571 return rIn;
574 ////////////////////////////////////////////////////////////////////////////////////////////////////
576 PptSlidePersistEntry::PptSlidePersistEntry() :
577 pStyleSheet ( NULL ),
578 pHeaderFooterEntry ( NULL ),
579 pSolverContainer ( NULL ),
580 nSlidePersistStartOffset( 0 ),
581 nSlidePersistEndOffset ( 0 ),
582 nBackgroundOffset ( 0 ),
583 nDrawingDgId ( 0xffffffff ),
584 pPresentationObjects ( NULL ),
585 pBObj ( NULL ),
586 bBObjIsTemporary ( sal_True ),
587 ePageKind ( PPT_MASTERPAGE ),
588 bNotesMaster ( FALSE ),
589 bHandoutMaster ( FALSE ),
590 bStarDrawFiller ( FALSE )
592 HeaderFooterOfs[ 0 ] = HeaderFooterOfs[ 1 ] = HeaderFooterOfs[ 2 ] = HeaderFooterOfs[ 3 ] = 0;
596 PptSlidePersistEntry::~PptSlidePersistEntry()
598 delete pStyleSheet;
599 delete pSolverContainer;
600 delete[] pPresentationObjects;
603 ////////////////////////////////////////////////////////////////////////////////////////////////////
604 ////////////////////////////////////////////////////////////////////////////////////////////////////
605 ////////////////////////////////////////////////////////////////////////////////////////////////////
607 SdrEscherImport::SdrEscherImport( PowerPointImportParam& rParam, const String& rBaseURL ) :
608 SvxMSDffManager ( rParam.rDocStream, rBaseURL, rParam.pTracer ),
609 pFonts ( NULL ),
610 nStreamLen ( 0 ),
611 nTextStylesIndex ( 0xffff ),
612 eCharSetSystem ( gsl_getSystemTextEncoding() ),
613 bWingdingsChecked ( FALSE ),
614 bWingdingsAvailable ( FALSE ),
615 bMonotypeSortsChecked ( FALSE ),
616 bMonotypeSortsAvailable ( FALSE ),
617 bTimesNewRomanChecked ( FALSE ),
618 bTimesNewRomanAvailable ( FALSE ),
619 rImportParam ( rParam )
623 SdrEscherImport::~SdrEscherImport()
625 void* pPtr;
626 for ( pPtr = aOleObjectList.First(); pPtr; pPtr = aOleObjectList.Next() )
627 delete (PPTOleEntry*)pPtr;
628 delete pFonts;
631 const PptSlideLayoutAtom* SdrEscherImport::GetSlideLayoutAtom() const
633 return NULL;
636 sal_Bool SdrEscherImport::ReadString( String& rStr ) const
638 sal_Bool bRet = FALSE;
639 DffRecordHeader aStrHd;
640 rStCtrl >> aStrHd;
641 if (aStrHd.nRecType == PPT_PST_TextBytesAtom
642 || aStrHd.nRecType == PPT_PST_TextCharsAtom
643 || aStrHd.nRecType == PPT_PST_CString)
645 sal_Bool bUniCode =
646 (aStrHd.nRecType == PPT_PST_TextCharsAtom
647 || aStrHd.nRecType == PPT_PST_CString);
648 bRet=TRUE;
649 ULONG nBytes = aStrHd.nRecLen;
650 MSDFFReadZString( rStCtrl, rStr, nBytes, bUniCode );
651 aStrHd.SeekToEndOfRecord( rStCtrl );
653 else
654 aStrHd.SeekToBegOfRecord( rStCtrl );
655 return bRet;
658 FASTBOOL SdrEscherImport::GetColorFromPalette(USHORT /*nNum*/, Color& /*rColor*/) const
660 return FALSE;
663 BOOL SdrEscherImport::SeekToShape( SvStream& /*rSt*/, void* /*pClientData*/, UINT32 /*nId*/) const
665 return FALSE;
668 PptFontEntityAtom* SdrEscherImport::GetFontEnityAtom( UINT32 nNum ) const
670 PptFontEntityAtom* pRetValue = NULL;
671 if ( pFonts && ( nNum < pFonts->Count() ) )
672 pRetValue = (*pFonts)[ (USHORT)nNum ];
673 return pRetValue;
676 CharSet SdrEscherImport::GetCharSet( UINT32 nNum ) const
678 CharSet eRetValue( eCharSetSystem );
679 if ( pFonts && ( nNum < pFonts->Count() ) )
680 eRetValue = (*pFonts)[ (USHORT)nNum ]->eCharSet;
681 return eRetValue;
684 BOOL SdrEscherImport::IsFontAvailable( UINT32 nNum ) const
686 BOOL bRetValue = FALSE;
687 if ( pFonts && ( nNum < pFonts->Count() ) )
688 bRetValue = (*pFonts)[ (USHORT)nNum ]->bAvailable;
689 return bRetValue;
692 SdrObject* SdrEscherImport::ReadObjText( PPTTextObj* /*pTextObj*/, SdrObject* pObj, SdPage* /*pPage*/) const
694 return pObj;
697 void SdrEscherImport::ProcessClientAnchor2( SvStream& rSt, DffRecordHeader& rHd, void* /*pData*/, DffObjData& rObj )
699 sal_Int32 l, t, r, b;
700 if ( rHd.nRecLen == 16 )
702 rSt >> l >> t >> r >> b;
704 else
706 INT16 ls, ts, rs, bs;
707 rSt >> ts >> ls >> rs >> bs; // etwas seltsame Koordinatenreihenfolge ...
708 l = ls, t = ts, r = rs, b = bs;
710 Scale( l );
711 Scale( t );
712 Scale( r );
713 Scale( b );
714 rObj.aChildAnchor = Rectangle( l, t, r, b );
715 rObj.bChildAnchor = TRUE;
716 return;
719 void SdrEscherImport::RecolorGraphic( SvStream& rSt, sal_uInt32 nRecLen, Graphic& rGraphic )
721 if ( rGraphic.GetType() == GRAPHIC_GDIMETAFILE )
723 sal_uInt16 nX, nGlobalColorsCount, nFillColorsCount;
725 rSt >> nX
726 >> nGlobalColorsCount
727 >> nFillColorsCount
728 >> nX
729 >> nX
730 >> nX;
732 if ( ( nGlobalColorsCount <= 64 ) && ( nFillColorsCount <= 64 ) )
734 if ( (sal_uInt32)( ( nGlobalColorsCount + nFillColorsCount ) * 44 + 12 ) == nRecLen )
736 sal_uInt32 OriginalGlobalColors[ 64 ];
737 sal_uInt32 NewGlobalColors[ 64 ];
738 sal_uInt32 OriginalFillColors[ 64 ];
739 sal_uInt32 NewFillColors[ 64 ];
741 sal_uInt32 i, j, nGlobalColorsChanged, nFillColorsChanged;
742 nGlobalColorsChanged = nFillColorsChanged = 0;
744 sal_uInt32* pCurrentOriginal = OriginalGlobalColors;
745 sal_uInt32* pCurrentNew = NewGlobalColors;
746 sal_uInt32* pCount = &nGlobalColorsChanged;
747 i = nGlobalColorsCount;
749 for ( j = 0; j < 2; j++ )
751 for ( ; i > 0; i-- )
753 sal_uInt32 nIndex, nPos = rSt.Tell();
754 sal_uInt8 nDummy, nRed, nGreen, nBlue;
755 sal_uInt16 nChanged;
756 rSt >> nChanged;
757 if ( nChanged & 1 )
759 sal_uInt32 nColor = 0;
760 rSt >> nDummy
761 >> nRed
762 >> nDummy
763 >> nGreen
764 >> nDummy
765 >> nBlue
766 >> nIndex;
768 if ( nIndex < 8 )
770 Color aColor = MSO_CLR_ToColor( nIndex << 24 );
771 nRed = aColor.GetRed();
772 nGreen = aColor.GetGreen();
773 nBlue = aColor.GetBlue();
775 nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 );
776 *pCurrentNew++ = nColor;
777 rSt >> nDummy
778 >> nRed
779 >> nDummy
780 >> nGreen
781 >> nDummy
782 >> nBlue;
783 nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 );
784 *pCurrentOriginal++ = nColor;
785 (*pCount)++;
787 rSt.Seek( nPos + 44 );
789 pCurrentOriginal = OriginalFillColors;
790 pCurrentNew = NewFillColors;
791 pCount = &nFillColorsChanged;
792 i = nFillColorsCount;
794 if ( nGlobalColorsChanged || nFillColorsChanged )
796 Color* pSearchColors = new Color[ nGlobalColorsChanged ];
797 Color* pReplaceColors = new Color[ nGlobalColorsChanged ];
799 for ( j = 0; j < nGlobalColorsChanged; j++ )
801 sal_uInt32 nSearch = OriginalGlobalColors[ j ];
802 sal_uInt32 nReplace = NewGlobalColors[ j ];
804 pSearchColors[ j ].SetRed( (BYTE)nSearch );
805 pSearchColors[ j ].SetGreen( (BYTE)( nSearch >> 8 ) );
806 pSearchColors[ j ].SetBlue( (BYTE)( nSearch >> 16 ) );
808 pReplaceColors[ j ].SetRed( (BYTE)nReplace );
809 pReplaceColors[ j ].SetGreen( (BYTE)( nReplace >> 8 ) );
810 pReplaceColors[ j ].SetBlue( (BYTE)( nReplace >> 16 ) );
812 GDIMetaFile aGdiMetaFile( rGraphic.GetGDIMetaFile() );
813 aGdiMetaFile.ReplaceColors( pSearchColors, pReplaceColors,
814 nGlobalColorsChanged, NULL );
815 rGraphic = aGdiMetaFile;
817 delete[] pSearchColors;
818 delete[] pReplaceColors;
825 /* ProcessObject is called from ImplSdPPTImport::ProcessObj to hanlde all application specific things,
826 such as the import of text, animation effects, header footer and placeholder.
828 The parameter pOriginalObj is the object as it was imported by our general escher import, it must either
829 be deleted or it can be returned to be inserted into the sdr page.
831 SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, void* pData, Rectangle& rTextRect, SdrObject* pOriginalObj )
833 if ( pOriginalObj && pOriginalObj->ISA( SdrObjCustomShape ) )
834 pOriginalObj->SetMergedItem( SdrTextFixedCellHeightItem( TRUE ) );
836 // we are initializing our return value with the object that was imported by our escher import
837 SdrObject* pRet = pOriginalObj;
839 ProcessData& rData = *((ProcessData*)pData);
840 PptSlidePersistEntry& rPersistEntry = rData.rPersistEntry;
842 if ( ! ( rObjData.nSpFlags & SP_FGROUP ) ) // sj: #114758# ...
844 PptOEPlaceholderAtom aPlaceholderAtom;
845 INT16 nHeaderFooterInstance = -1;
847 if ( maShapeRecords.SeekToContent( rSt, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) )
849 DffRecordHeader aClientDataHd;
850 while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < maShapeRecords.Current()->GetRecEndFilePos() ) )
852 rSt >> aClientDataHd;
853 switch ( aClientDataHd.nRecType )
855 // importing header/footer object from master page
856 case PPT_PST_OEPlaceholderAtom :
858 rSt >> aPlaceholderAtom;
859 if ( nHeaderFooterInstance == -1 )
861 switch ( aPlaceholderAtom.nPlaceholderId )
863 case PPT_PLACEHOLDER_MASTERSLIDENUMBER : nHeaderFooterInstance++;
864 case PPT_PLACEHOLDER_MASTERFOOTER : nHeaderFooterInstance++;
865 case PPT_PLACEHOLDER_MASTERHEADER : nHeaderFooterInstance++;
866 case PPT_PLACEHOLDER_MASTERDATE : nHeaderFooterInstance++; break;
868 if ( ! ( nHeaderFooterInstance & 0xfffc ) ) // is this a valid instance ( 0->3 )
869 rPersistEntry.HeaderFooterOfs[ nHeaderFooterInstance ] = rObjData.rSpHd.GetRecBegFilePos();
872 break;
874 case PPT_PST_RecolorInfoAtom :
876 if ( pRet && ( pRet->ISA( SdrGrafObj ) && ((SdrGrafObj*)pRet)->HasGDIMetaFile() ) )
878 Graphic aGraphic( ((SdrGrafObj*)pRet)->GetGraphic() );
879 RecolorGraphic( rSt, aClientDataHd.nRecLen, aGraphic );
880 ((SdrGrafObj*)pRet)->SetGraphic( aGraphic );
883 break;
885 aClientDataHd.SeekToEndOfRecord( rSt );
888 if ( ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_NOTESSLIDEIMAGE ) && ( rPersistEntry.bNotesMaster == FALSE ) )
890 USHORT nPageNum = pSdrModel->GetPageCount();
891 if ( nPageNum > 0 )
892 nPageNum--;
894 // replacing the object which we will return with a SdrPageObj
895 SdrObject::Free( pRet );
896 pRet = new SdrPageObj( rObjData.aBoundRect, pSdrModel->GetPage( nPageNum - 1 ) );
898 else
900 // try to load some ppt text
901 PPTTextObj aTextObj( rSt, (SdrPowerPointImport&)*this, rPersistEntry, &rObjData );
902 if ( ( aTextObj.Count() || aTextObj.GetOEPlaceHolderAtom() ) )
904 sal_Bool bVerticalText = sal_False;
905 // and if the text object is not empty, it must be applied to pRet, the object we
906 // initially got from our escher import
907 INT32 nTextRotationAngle = 0;
908 if ( IsProperty( DFF_Prop_txflTextFlow ) )
910 MSO_TextFlow eTextFlow = (MSO_TextFlow)( GetPropertyValue( DFF_Prop_txflTextFlow ) & 0xFFFF );
911 switch( eTextFlow )
913 case mso_txflBtoT : // Bottom to Top non-@, unten -> oben
914 nTextRotationAngle += 9000;
915 break;
916 case mso_txflTtoBA : /* #68110# */ // Top to Bottom @-font, oben -> unten
917 case mso_txflTtoBN : // Top to Bottom non-@, oben -> unten
918 case mso_txflVertN : // Vertical, non-@, oben -> unten
919 bVerticalText = !bVerticalText; // nTextRotationAngle += 27000;
920 break;
921 // case mso_txflHorzN : // Horizontal non-@, normal
922 // case mso_txflHorzA : // Horizontal @-font, normal
923 default: break;
926 sal_Int32 nFontDirection = GetPropertyValue( DFF_Prop_cdirFont, mso_cdir0 );
927 nTextRotationAngle -= nFontDirection * 9000;
928 if ( ( nFontDirection == 1 ) || ( nFontDirection == 3 ) ) // #104546#
930 bVerticalText = !bVerticalText;
932 sal_Int32 nHalfWidth = ( rTextRect.GetWidth() + 1 ) >> 1;
933 sal_Int32 nHalfHeight = ( rTextRect.GetHeight() + 1 ) >> 1;
934 Point aTopLeft( rTextRect.Left() + nHalfWidth - nHalfHeight,
935 rTextRect.Top() + nHalfHeight - nHalfWidth );
936 Size aNewSize( rTextRect.GetHeight(), rTextRect.GetWidth() );
937 Rectangle aNewRect( aTopLeft, aNewSize );
938 rTextRect = aNewRect;
941 aTextObj.SetVertical( bVerticalText );
942 if ( pRet )
944 BOOL bDeleteSource = aTextObj.GetOEPlaceHolderAtom() != 0;
945 if ( bDeleteSource && ( pRet->ISA( SdrGrafObj ) == FALSE ) // we are not allowed to get
946 && ( pRet->ISA( SdrObjGroup ) == FALSE ) // grouped placeholder objects
947 && ( pRet->ISA( SdrOle2Obj ) == FALSE ) )
948 SdrObject::Free( pRet );
950 sal_uInt32 nTextFlags = aTextObj.GetTextFlags();
951 sal_Int32 nTextLeft = GetPropertyValue( DFF_Prop_dxTextLeft, 25 * 3600 ); // 0.25 cm (emu)
952 sal_Int32 nTextRight = GetPropertyValue( DFF_Prop_dxTextRight, 25 * 3600 ); // 0.25 cm (emu)
953 sal_Int32 nTextTop = GetPropertyValue( DFF_Prop_dyTextTop, 13 * 3600 ); // 0.13 cm (emu)
954 sal_Int32 nTextBottom = GetPropertyValue( DFF_Prop_dyTextBottom, 13 * 3600 );
955 ScaleEmu( nTextLeft );
956 ScaleEmu( nTextRight );
957 ScaleEmu( nTextTop );
958 ScaleEmu( nTextBottom );
960 sal_Int32 nMinFrameWidth = 0;
961 sal_Int32 nMinFrameHeight = 0;
962 sal_Bool bAutoGrowWidth, bAutoGrowHeight;
964 SdrTextVertAdjust eTVA;
965 SdrTextHorzAdjust eTHA;
967 nTextFlags &= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT
968 | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK;
970 if ( bVerticalText )
972 eTVA = SDRTEXTVERTADJUST_BLOCK;
973 eTHA = SDRTEXTHORZADJUST_CENTER;
975 // Textverankerung lesen
976 MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
978 switch( eTextAnchor )
980 case mso_anchorTop:
981 case mso_anchorTopCentered:
982 case mso_anchorTopBaseline:
983 case mso_anchorTopCenteredBaseline:
984 eTHA = SDRTEXTHORZADJUST_RIGHT;
985 break;
987 case mso_anchorMiddle :
988 case mso_anchorMiddleCentered:
989 eTHA = SDRTEXTHORZADJUST_CENTER;
990 break;
992 case mso_anchorBottom:
993 case mso_anchorBottomCentered:
994 case mso_anchorBottomBaseline:
995 case mso_anchorBottomCenteredBaseline:
996 eTHA = SDRTEXTHORZADJUST_LEFT;
997 break;
999 // if there is a 100% use of following attributes, the textbox can been aligned also in vertical direction
1000 switch ( eTextAnchor )
1002 case mso_anchorTopCentered :
1003 case mso_anchorMiddleCentered :
1004 case mso_anchorBottomCentered :
1005 case mso_anchorTopCenteredBaseline:
1006 case mso_anchorBottomCenteredBaseline:
1008 // check if it is sensible to use the centered alignment
1009 sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT;
1010 if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs
1011 eTVA = SDRTEXTVERTADJUST_CENTER; // the text has to be displayed using the full width;
1013 break;
1015 default :
1017 if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT )
1018 eTVA = SDRTEXTVERTADJUST_TOP;
1019 else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT )
1020 eTVA = SDRTEXTVERTADJUST_BOTTOM;
1022 break;
1024 nMinFrameWidth = rTextRect.GetWidth() - ( nTextLeft + nTextRight );
1026 else
1028 eTVA = SDRTEXTVERTADJUST_CENTER;
1029 eTHA = SDRTEXTHORZADJUST_BLOCK;
1031 // Textverankerung lesen
1032 MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
1034 switch( eTextAnchor )
1036 case mso_anchorTop:
1037 case mso_anchorTopCentered:
1038 case mso_anchorTopBaseline:
1039 case mso_anchorTopCenteredBaseline:
1040 eTVA = SDRTEXTVERTADJUST_TOP;
1041 break;
1043 case mso_anchorMiddle :
1044 case mso_anchorMiddleCentered:
1045 eTVA = SDRTEXTVERTADJUST_CENTER;
1046 break;
1048 case mso_anchorBottom:
1049 case mso_anchorBottomCentered:
1050 case mso_anchorBottomBaseline:
1051 case mso_anchorBottomCenteredBaseline:
1052 eTVA = SDRTEXTVERTADJUST_BOTTOM;
1053 break;
1055 // if there is a 100% usage of following attributes, the textbox can be aligned also in horizontal direction
1056 switch ( eTextAnchor )
1058 case mso_anchorTopCentered :
1059 case mso_anchorMiddleCentered :
1060 case mso_anchorBottomCentered :
1061 case mso_anchorTopCenteredBaseline:
1062 case mso_anchorBottomCenteredBaseline:
1064 // check if it is sensible to use the centered alignment
1065 sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT;
1066 if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs
1067 eTHA = SDRTEXTHORZADJUST_CENTER; // the text has to be displayed using the full width;
1069 break;
1071 default :
1072 break;
1074 nMinFrameHeight = rTextRect.GetHeight() - ( nTextTop + nTextBottom );
1077 SdrObjKind eTextKind = OBJ_RECT;
1078 if ( ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_NOTESSLIDEIMAGE )
1079 || ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_MASTERNOTESSLIDEIMAGE ) )
1081 aTextObj.SetInstance( 2 );
1082 eTextKind = OBJ_TITLETEXT;
1084 else if ( ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_MASTERNOTESBODYIMAGE )
1085 || ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_NOTESBODY ) )
1087 aTextObj.SetInstance( 2 );
1088 eTextKind = OBJ_TEXT;
1091 sal_uInt32 nDestinationInstance = aTextObj.GetInstance();
1092 if ( ( rPersistEntry.ePageKind == PPT_MASTERPAGE ) )
1094 if ( !rPersistEntry.pPresentationObjects )
1096 rPersistEntry.pPresentationObjects = new UINT32[ PPT_STYLESHEETENTRYS ];
1097 memset( rPersistEntry.pPresentationObjects, 0, PPT_STYLESHEETENTRYS * 4 );
1099 if ( !rPersistEntry.pPresentationObjects[ nDestinationInstance ] )
1100 rPersistEntry.pPresentationObjects[ nDestinationInstance ] = rObjData.rSpHd.GetRecBegFilePos();
1102 switch ( nDestinationInstance )
1104 case TSS_TYPE_PAGETITLE :
1105 case TSS_TYPE_TITLE :
1107 if ( GetSlideLayoutAtom()->eLayout == PPT_LAYOUT_TITLEMASTERSLIDE )
1108 nDestinationInstance = TSS_TYPE_TITLE;
1109 else
1110 nDestinationInstance = TSS_TYPE_PAGETITLE;
1112 break;
1113 case TSS_TYPE_BODY :
1114 // case TSS_TYPE_SUBTITLE :
1115 case TSS_TYPE_HALFBODY :
1116 case TSS_TYPE_QUARTERBODY :
1117 nDestinationInstance = TSS_TYPE_BODY;
1118 break;
1120 aTextObj.SetDestinationInstance( (sal_uInt16)nDestinationInstance );
1122 bool bAutoFit = false; // auto-scale text into shape box
1123 switch ( aTextObj.GetInstance() )
1125 case TSS_TYPE_PAGETITLE :
1126 case TSS_TYPE_TITLE : eTextKind = OBJ_TITLETEXT; break;
1127 case TSS_TYPE_SUBTITLE : eTextKind = OBJ_TEXT; break;
1128 case TSS_TYPE_BODY :
1129 case TSS_TYPE_HALFBODY :
1130 case TSS_TYPE_QUARTERBODY : eTextKind = OBJ_OUTLINETEXT; bAutoFit = true; break;
1132 if ( aTextObj.GetDestinationInstance() != TSS_TYPE_TEXT_IN_SHAPE )
1134 if ( !aTextObj.GetOEPlaceHolderAtom() || !aTextObj.GetOEPlaceHolderAtom()->nPlaceholderId )
1136 aTextObj.SetDestinationInstance( TSS_TYPE_TEXT_IN_SHAPE );
1137 eTextKind = OBJ_RECT;
1140 SdrObject* pTObj = NULL;
1141 sal_Bool bWordWrap = (MSO_WrapMode)GetPropertyValue( DFF_Prop_WrapText, mso_wrapSquare ) != mso_wrapNone;
1142 sal_Bool bFitShapeToText = ( GetPropertyValue( DFF_Prop_FitTextToShape ) & 2 ) != 0;
1144 if ( pRet && pRet->ISA( SdrObjCustomShape ) && ( eTextKind == OBJ_RECT ) )
1146 bAutoGrowHeight = bFitShapeToText;
1147 if ( bWordWrap )
1148 bAutoGrowWidth = sal_False;
1149 else
1150 bAutoGrowWidth = sal_True;
1151 pTObj = pRet;
1152 pRet = NULL;
1154 else
1156 if ( pRet && pRet->ISA( SdrObjCustomShape ) )
1158 SdrObject::Free( pRet );
1159 pRet = NULL;
1161 pTObj = new SdrRectObj( eTextKind != OBJ_RECT ? eTextKind : OBJ_TEXT );
1162 pTObj->SetModel( pSdrModel );
1163 SfxItemSet aSet( pSdrModel->GetItemPool() );
1164 if ( !pRet )
1165 ((SdrEscherImport*)this)->ApplyAttributes( rSt, aSet, rObjData );
1166 pTObj->SetMergedItemSet( aSet );
1167 if ( pRet )
1169 pTObj->SetMergedItem( XLineStyleItem( XLINE_NONE ) );
1170 pTObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) );
1172 if ( bVerticalText )
1174 bAutoGrowWidth = bFitShapeToText; // bFitShapeToText; can't be used, because we cut the text if it is too height,
1175 bAutoGrowHeight = sal_False;
1177 else
1179 bAutoGrowWidth = sal_False;
1180 bAutoGrowHeight = sal_True; // bFitShapeToText; can't be used, because we cut the text if it is too height,
1183 pTObj->SetMergedItem( SvxFrameDirectionItem( bVerticalText ? FRMDIR_VERT_TOP_RIGHT : FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
1185 if (bAutoFit)
1187 // disable both, defeats purpose of autofit
1188 // otherwise
1189 bAutoGrowHeight = sal_False;
1190 bAutoGrowWidth = sal_False;
1191 pTObj->SetMergedItem( SdrTextFitToSizeTypeItem(SDRTEXTFIT_AUTOFIT) );
1194 if ( !pTObj->ISA( SdrObjCustomShape ) )
1196 pTObj->SetMergedItem( SdrTextAutoGrowWidthItem( bAutoGrowWidth ) );
1197 pTObj->SetMergedItem( SdrTextAutoGrowHeightItem( bAutoGrowHeight ) );
1199 else
1201 pTObj->SetMergedItem( SdrTextWordWrapItem( bWordWrap ) );
1202 pTObj->SetMergedItem( SdrTextAutoGrowHeightItem( bFitShapeToText ) );
1205 pTObj->SetMergedItem( SdrTextVertAdjustItem( eTVA ) );
1206 pTObj->SetMergedItem( SdrTextHorzAdjustItem( eTHA ) );
1208 if ( nMinFrameHeight < 0 )
1209 nMinFrameHeight = 0;
1210 if ( !pTObj->ISA( SdrObjCustomShape ) )
1211 pTObj->SetMergedItem( SdrTextMinFrameHeightItem( nMinFrameHeight ) );
1213 if ( nMinFrameWidth < 0 )
1214 nMinFrameWidth = 0;
1215 if ( !pTObj->ISA( SdrObjCustomShape ) )
1216 pTObj->SetMergedItem( SdrTextMinFrameWidthItem( nMinFrameWidth ) );
1218 // Abstaende an den Raendern der Textbox setzen
1219 pTObj->SetMergedItem( SdrTextLeftDistItem( nTextLeft ) );
1220 pTObj->SetMergedItem( SdrTextRightDistItem( nTextRight ) );
1221 pTObj->SetMergedItem( SdrTextUpperDistItem( nTextTop ) );
1222 pTObj->SetMergedItem( SdrTextLowerDistItem( nTextBottom ) );
1223 pTObj->SetMergedItem( SdrTextFixedCellHeightItem( TRUE ) );
1225 if ( !pTObj->ISA( SdrObjCustomShape ) )
1226 pTObj->SetSnapRect( rTextRect );
1227 pTObj = ReadObjText( &aTextObj, pTObj, rData.pPage );
1228 if ( pTObj )
1230 /* check if our new snaprect makes trouble,
1231 because we do not display the ADJUST_BLOCK
1232 properly if the textsize is bigger than the
1233 snaprect of the object. Then we will use
1234 ADJUST_CENTER instead of ADJUST_BLOCK.
1236 if ( !pTObj->ISA( SdrObjCustomShape ) && !bFitShapeToText && !bWordWrap )
1238 SdrTextObj* pText = PTR_CAST( SdrTextObj, pTObj );
1239 if ( pText )
1241 if ( bVerticalText )
1243 if ( eTVA == SDRTEXTVERTADJUST_BLOCK )
1245 Size aTextSize( pText->GetTextSize() );
1246 aTextSize.Width() += nTextLeft + nTextRight;
1247 aTextSize.Height() += nTextTop + nTextBottom;
1248 if ( rTextRect.GetHeight() < aTextSize.Height() )
1249 pTObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
1252 else
1254 if ( eTHA == SDRTEXTHORZADJUST_BLOCK )
1256 Size aTextSize( pText->GetTextSize() );
1257 aTextSize.Width() += nTextLeft + nTextRight;
1258 aTextSize.Height() += nTextTop + nTextBottom;
1259 if ( rTextRect.GetWidth() < aTextSize.Width() )
1260 pTObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_CENTER ) );
1265 // rotate text with shape ?
1266 sal_Int32 nAngle = ( rObjData.nSpFlags & SP_FFLIPV ) ? -mnFix16Angle : mnFix16Angle; // #72116# vertical flip -> rotate by using the other way
1267 nAngle += nTextRotationAngle;
1269 if ( pTObj->ISA( SdrObjCustomShape ) )
1272 if ( nTextRotationAngle )
1274 double fTextRotateAngle = (double)nTextRotationAngle / 100.0;
1275 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)((SdrObjCustomShape*)pTObj)->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
1276 const rtl::OUString sTextRotateAngle( RTL_CONSTASCII_USTRINGPARAM ( "TextRotateAngle" ) );
1277 PropertyValue aPropValue;
1278 aPropValue.Name = sTextRotateAngle;
1279 aPropValue.Value <<= fTextRotateAngle;
1280 aGeometryItem.SetPropertyValue( aPropValue );
1281 ((SdrObjCustomShape*)pTObj)->SetMergedItem( aGeometryItem );
1285 else
1287 if ( rObjData.nSpFlags & SP_FFLIPV )
1289 double a = 18000 * nPi180;
1290 pTObj->Rotate( rTextRect.Center(), 18000, sin( a ), cos( a ) );
1292 if ( rObjData.nSpFlags & SP_FFLIPH )
1293 nAngle = 36000 - nAngle;
1294 if ( nAngle )
1296 double a = nAngle * nPi180;
1297 pTObj->NbcRotate( rObjData.aBoundRect.Center(), nAngle, sin( a ), cos( a ) );
1300 if ( pRet )
1302 SdrObject* pGroup = new SdrObjGroup;
1303 pGroup->GetSubList()->NbcInsertObject( pRet );
1304 pGroup->GetSubList()->NbcInsertObject( pTObj );
1305 pRet = pGroup;
1307 else
1308 pRet = pTObj;
1313 else
1315 if ( maShapeRecords.SeekToContent( rSt, DFF_msofbtUDefProp, SEEK_FROM_CURRENT_AND_RESTART ) )
1317 maShapeRecords.Current()->SeekToBegOfRecord( rSt );
1318 DffPropertyReader aSecPropSet( *this );
1319 aSecPropSet.ReadPropSet( rSt, (ProcessData*)pData );
1320 sal_Int32 nTableProperties = aSecPropSet.GetPropertyValue( DFF_Prop_tableProperties, 0 );
1321 if ( nTableProperties & 3 )
1323 if ( aSecPropSet.SeekToContent( DFF_Prop_tableRowProperties, rSt ) )
1325 sal_Int16 i, nRowCount = 0;
1326 rSt >> nRowCount >> i >> i;
1327 if ( nRowCount )
1329 sal_uInt32* pTableArry = new sal_uInt32[ nRowCount + 2 ];
1330 pTableArry[ 0 ] = nTableProperties;
1331 pTableArry[ 1 ] = nRowCount;
1332 for ( i = 0; i < nRowCount; i++ )
1333 rSt >> pTableArry[ i + 2 ];
1334 rData.pTableRowProperties = pTableArry;
1340 if ( pRet ) // sj: #i38501#, and and taking care of connections to group objects
1342 if ( rObjData.nSpFlags & SP_FBACKGROUND )
1344 pRet->NbcSetSnapRect( Rectangle( Point(), ((SdrPage*)rData.pPage)->GetSize() ) ); // Groesse setzen
1346 if ( rPersistEntry.pSolverContainer )
1348 for ( SvxMSDffConnectorRule* pPtr = (SvxMSDffConnectorRule*)rPersistEntry.pSolverContainer->aCList.First();
1349 pPtr; pPtr = (SvxMSDffConnectorRule*)rPersistEntry.pSolverContainer->aCList.Next() )
1351 if ( rObjData.nShapeId == pPtr->nShapeC )
1352 pPtr->pCObj = pRet;
1353 else
1355 SdrObject* pConnectObj = pRet;
1356 if ( pOriginalObj && pRet->ISA( SdrObjGroup ) )
1357 { /* check if the original object from the escherimport is part of the group object,
1358 if this is the case, we will use the original object to connect to */
1359 SdrObjListIter aIter( *pRet, IM_DEEPWITHGROUPS );
1360 while( aIter.IsMore() )
1362 SdrObject* pPartObj = aIter.Next();
1363 if ( pPartObj == pOriginalObj )
1365 pConnectObj = pPartObj;
1366 break;
1370 if ( rObjData.nShapeId == pPtr->nShapeA )
1372 pPtr->pAObj = pConnectObj;
1373 pPtr->nSpFlagsA = rObjData.nSpFlags;
1375 if ( rObjData.nShapeId == pPtr->nShapeB )
1377 pPtr->pBObj = pConnectObj;
1378 pPtr->nSpFlagsB = rObjData.nSpFlags;
1383 if ( rPersistEntry.ePageKind == PPT_MASTERPAGE )
1384 { // maybe the escher clusterlist is not correct, but we have to got the right page by using the
1385 // spMaster property, so we are patching the table
1386 if ( rPersistEntry.nDrawingDgId != 0xffffffff )
1388 UINT32 nSec = ( rObjData.nShapeId >> 10 ) - 1;
1389 if ( mpFidcls && ( nSec < mnIdClusters ) )
1390 mpFidcls[ nSec ].dgid = rPersistEntry.nDrawingDgId; // insert the correct drawing id;
1393 if ( GetPropertyValue( DFF_Prop_fNoFillHitTest ) & 0x10 )
1395 if ( (MSO_FillType)GetPropertyValue( DFF_Prop_fillType, mso_fillSolid ) == mso_fillBackground )
1397 if ( !rData.pBackgroundColoredObjects )
1398 rData.pBackgroundColoredObjects = new List;
1399 rData.pBackgroundColoredObjects->Insert( pRet, LIST_APPEND );
1403 return pRet;
1406 ////////////////////////////////////////////////////////////////////////////////////////////////////
1408 void SdrEscherImport::CheckWingdings() const
1410 OutputDevice* pDev = (OutputDevice*)Application::GetDefaultDevice();
1411 ((SdrEscherImport*)this)->bWingdingsAvailable = pDev->IsFontAvailable( String( RTL_CONSTASCII_USTRINGPARAM( "WINGDINGS" ) ) );
1412 ((SdrEscherImport*)this)->bWingdingsChecked = TRUE;
1415 void SdrEscherImport::CheckMonotypeSorts() const
1417 OutputDevice* pDev = (OutputDevice*)Application::GetDefaultDevice();
1418 ((SdrEscherImport*)this)->bMonotypeSortsAvailable = pDev->IsFontAvailable( String( RTL_CONSTASCII_USTRINGPARAM( "MONOTYPE SORTS" ) ) );
1419 ((SdrEscherImport*)this)->bMonotypeSortsChecked = TRUE;
1422 void SdrEscherImport::CheckTimesNewRoman() const
1424 OutputDevice* pDev = (OutputDevice*)Application::GetDefaultDevice();
1425 ((SdrEscherImport*)this)->bTimesNewRomanAvailable = pDev->IsFontAvailable( String( RTL_CONSTASCII_USTRINGPARAM( "TIMES NEW ROMAN" ) ) );
1426 ((SdrEscherImport*)this)->bTimesNewRomanChecked = TRUE;
1429 ////////////////////////////////////////////////////////////////////////////////////////////////////
1430 ////////////////////////////////////////////////////////////////////////////////////////////////////
1431 ////////////////////////////////////////////////////////////////////////////////////////////////////
1433 SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const String& rBaseURL ) :
1434 SdrEscherImport ( rParam, rBaseURL ),
1435 bOk ( rStCtrl.GetErrorCode() == SVSTREAM_OK ),
1436 pPersistPtr ( NULL ),
1437 nPersistPtrAnz ( 0 ),
1438 pDefaultSheet ( NULL ),
1439 pMasterPages ( NULL ),
1440 pSlidePages ( NULL ),
1441 pNotePages ( NULL ),
1442 nAktPageNum ( 0 ),
1443 nDocStreamPos ( 0 ),
1444 nPageColorsNum ( 0xFFFF ),
1445 ePageColorsKind ( PPT_MASTERPAGE ),
1446 eAktPageKind ( PPT_MASTERPAGE )
1448 DffRecordHeader* pHd;
1449 if ( bOk )
1451 rStCtrl.Seek( STREAM_SEEK_TO_END );
1452 nStreamLen = rStCtrl.Tell();
1454 // try to allocate the UserEditAtom via CurrentUserAtom
1455 sal_uInt32 nCurrentUserEdit = rParam.aCurrentUserAtom.nCurrentUserEdit;
1456 if ( nCurrentUserEdit )
1458 rStCtrl.Seek( nCurrentUserEdit );
1459 rStCtrl >> aUserEditAtom;
1461 if ( !aUserEditAtom.nOffsetPersistDirectory )
1462 { // if there is no UserEditAtom try to search the last one
1464 rStCtrl.Seek( 0 );
1465 DffRecordManager aPptRecManager; // contains all first level container and atoms
1466 aPptRecManager.Consume( rStCtrl, FALSE, nStreamLen );
1467 for ( pHd = aPptRecManager.Last(); pHd; pHd = aPptRecManager.Prev() )
1469 if ( pHd->nRecType == PPT_PST_UserEditAtom )
1471 pHd->SeekToBegOfRecord( rStCtrl );
1472 rStCtrl >> aUserEditAtom;
1473 break;
1476 if ( !pHd )
1477 bOk = FALSE;
1480 if ( rStCtrl.GetError() != 0 )
1481 bOk = FALSE;
1483 if ( bOk )
1485 // PersistPtrs lesen (alle)
1486 nPersistPtrAnz = aUserEditAtom.nMaxPersistWritten + 1; // 1 mehr, damit ich immer direkt indizieren kann
1487 pPersistPtr = new UINT32[ nPersistPtrAnz ]; // (die fangen naemlich eigentlich bei 1 an)
1488 if ( !pPersistPtr )
1489 bOk = FALSE;
1490 else
1492 memset( pPersistPtr, 0x00, nPersistPtrAnz * 4 );
1494 // SJ: new search mechanism from bottom to top (Issue 21122)
1495 PptUserEditAtom aCurrentEditAtom( aUserEditAtom );
1496 sal_uInt32 nCurrentEditAtomStrmPos = aCurrentEditAtom.aHd.GetRecEndFilePos();
1497 while( nCurrentEditAtomStrmPos )
1499 sal_uInt32 nPersistIncPos = aCurrentEditAtom.nOffsetPersistDirectory;
1500 if ( nPersistIncPos )
1502 rStCtrl.Seek( nPersistIncPos );
1503 DffRecordHeader aPersistHd;
1504 rStCtrl >> aPersistHd;
1505 if ( aPersistHd.nRecType == PPT_PST_PersistPtrIncrementalBlock )
1507 ULONG nPibLen = aPersistHd.GetRecEndFilePos();
1508 while ( bOk && ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < nPibLen ) )
1510 sal_uInt32 nOfs, nAnz;
1511 rStCtrl >> nOfs;
1512 nAnz = nOfs;
1513 nOfs &= 0x000FFFFF;
1514 nAnz >>= 20;
1515 while ( bOk && ( rStCtrl.GetError() == 0 ) && ( nAnz > 0 ) && ( nOfs <= nPersistPtrAnz ) )
1517 sal_uInt32 nPt;
1518 rStCtrl >> nPt;
1519 if ( !pPersistPtr[ nOfs ] )
1521 pPersistPtr[ nOfs ] = nPt;
1522 if ( pPersistPtr[ nOfs ] > nStreamLen )
1524 bOk = FALSE;
1525 DBG_ERROR("SdrPowerPointImport::Ctor(): Ungueltiger Eintrag im Persist-Directory!");
1528 nAnz--;
1529 nOfs++;
1531 if ( bOk && nAnz > 0 )
1533 DBG_ERROR("SdrPowerPointImport::Ctor(): Nicht alle Persist-Directory Entraege gelesen!");
1534 bOk = FALSE;
1539 nCurrentEditAtomStrmPos = aCurrentEditAtom.nOffsetLastEdit < nCurrentEditAtomStrmPos ? aCurrentEditAtom.nOffsetLastEdit : 0;
1540 if ( nCurrentEditAtomStrmPos )
1542 rStCtrl.Seek( nCurrentEditAtomStrmPos );
1543 rStCtrl >> aCurrentEditAtom;
1548 if ( rStCtrl.GetError() != 0 )
1549 bOk = FALSE;
1550 if ( bOk )
1551 { // Document PersistEntry checken
1552 nDocStreamPos = aUserEditAtom.nDocumentRef;
1553 if ( nDocStreamPos > nPersistPtrAnz )
1555 DBG_ERROR("SdrPowerPointImport::Ctor(): aUserEditAtom.nDocumentRef ungueltig!");
1556 bOk = FALSE;
1559 if ( bOk )
1560 { // Document FilePos checken
1561 nDocStreamPos = pPersistPtr[ nDocStreamPos ];
1562 if ( nDocStreamPos >= nStreamLen )
1564 DBG_ERROR("SdrPowerPointImport::Ctor(): nDocStreamPos >= nStreamLen!");
1565 bOk = FALSE;
1568 if ( bOk )
1570 rStCtrl.Seek( nDocStreamPos );
1571 aDocRecManager.Consume( rStCtrl );
1573 DffRecordHeader aDocHd;
1574 rStCtrl >> aDocHd;
1575 // DocumentAtom lesen
1576 DffRecordHeader aDocAtomHd;
1577 rStCtrl >> aDocAtomHd;
1578 if ( aDocHd.nRecType == PPT_PST_Document && aDocAtomHd.nRecType == PPT_PST_DocumentAtom )
1580 aDocAtomHd.SeekToBegOfRecord( rStCtrl );
1581 rStCtrl >> aDocAtom;
1583 else
1584 bOk = FALSE;
1586 if ( bOk )
1588 if ( !pFonts )
1589 ReadFontCollection();
1591 // reading TxPF, TxSI
1592 PPTTextCharacterStyleAtomInterpreter aTxCFStyle; // SJ: ToDo, this atom needs to be interpreted, it contains character default styles for standard objects (instance4)
1593 PPTTextParagraphStyleAtomInterpreter aTxPFStyle;
1594 PPTTextSpecInfoAtomInterpreter aTxSIStyle; // styles (default language setting ... )
1596 DffRecordHeader* pEnvHd = aDocRecManager.GetRecordHeader( PPT_PST_Environment );
1597 if ( pEnvHd )
1599 pEnvHd->SeekToContent( rStCtrl );
1600 DffRecordHeader aTxPFStyleRecHd;
1601 if ( SeekToRec( rStCtrl, PPT_PST_TxPFStyleAtom, pEnvHd->GetRecEndFilePos(), &aTxPFStyleRecHd ) )
1602 aTxPFStyle.Read( rStCtrl, aTxPFStyleRecHd );
1604 pEnvHd->SeekToContent( rStCtrl );
1605 DffRecordHeader aTxSIStyleRecHd;
1606 if ( SeekToRec( rStCtrl, PPT_PST_TxSIStyleAtom, pEnvHd->GetRecEndFilePos(), &aTxSIStyleRecHd ) )
1608 aTxSIStyle.Read( rStCtrl, aTxSIStyleRecHd, PPT_PST_TxSIStyleAtom );
1609 #ifdef DBG_UTIL
1610 if ( !aTxSIStyle.bValid )
1612 if (!(rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT ))
1614 DBG_ERROR( "SdrTextSpecInfoAtomInterpreter::Ctor(): parsing error, this document needs to be analysed (SJ)" );
1617 #endif
1621 // todo:: PPT_PST_TxPFStyleAtom
1623 // SlidePersists Lesen
1624 pMasterPages=new PptSlidePersistList;
1625 pSlidePages =new PptSlidePersistList;
1626 pNotePages =new PptSlidePersistList;
1628 // now always creating the handout page, it will be the first in our masterpage list
1629 PptSlidePersistEntry* pE = new PptSlidePersistEntry;
1630 pE->aPersistAtom.nPsrReference = aDocAtom.nHandoutMasterPersist;
1631 pE->bHandoutMaster = sal_True;
1632 if ( !aDocAtom.nHandoutMasterPersist )
1633 pE->bStarDrawFiller = sal_True; // this is a dummy master page
1634 pMasterPages->C40_INSERT( PptSlidePersistEntry, pE, 0 );
1636 USHORT nPageListNum = 0;
1637 DffRecordHeader* pSlideListWithTextHd = aDocRecManager.GetRecordHeader( PPT_PST_SlideListWithText );
1638 PptSlidePersistEntry* pPreviousPersist = NULL;
1639 while ( pSlideListWithTextHd && ( nPageListNum < 3 ) )
1641 pSlideListWithTextHd->SeekToContent( rStCtrl );
1642 PptSlidePersistList* pPageList = GetPageList( PptPageKind( nPageListNum ) );
1643 sal_uInt32 nSlideListWithTextHdEndOffset = pSlideListWithTextHd->GetRecEndFilePos();
1644 while ( SeekToRec( rStCtrl, PPT_PST_SlidePersistAtom, nSlideListWithTextHdEndOffset ) )
1646 if ( pPreviousPersist )
1647 pPreviousPersist->nSlidePersistEndOffset = rStCtrl.Tell();
1648 PptSlidePersistEntry* pE2 = new PptSlidePersistEntry;
1649 rStCtrl >> pE2->aPersistAtom;
1650 pE2->nSlidePersistStartOffset = rStCtrl.Tell();
1651 pE2->ePageKind = PptPageKind( nPageListNum );
1652 pPageList->C40_INSERT( PptSlidePersistEntry, pE2, pPageList->Count() );
1653 pPreviousPersist = pE2;
1655 if ( pPreviousPersist )
1656 pPreviousPersist->nSlidePersistEndOffset = nSlideListWithTextHdEndOffset;
1657 pSlideListWithTextHd = aDocRecManager.GetRecordHeader( PPT_PST_SlideListWithText, SEEK_FROM_CURRENT );
1658 nPageListNum++;
1661 // we will ensure that there is at least one master page
1662 if ( pMasterPages->Count() == 1 ) // -> there is only a handout page available
1664 PptSlidePersistEntry* pE2 = new PptSlidePersistEntry;
1665 pE2->bStarDrawFiller = sal_True; // this is a dummy master page
1666 pMasterPages->C40_INSERT( PptSlidePersistEntry, pE2, 1 );
1669 // now we will insert at least one notes master for each master page
1670 sal_uInt16 nMasterPage;
1671 sal_uInt16 nMasterPages = pMasterPages->Count() - 1;
1672 for ( nMasterPage = 0; nMasterPage < nMasterPages; nMasterPage++ )
1674 PptSlidePersistEntry* pE2 = new PptSlidePersistEntry;
1675 pE2->bNotesMaster = sal_True;
1676 pE2->bStarDrawFiller = sal_True; // this is a dummy master page
1677 if ( !nMasterPage && aDocAtom.nNotesMasterPersist )
1678 { // special treatment for the first notes master
1679 pE2->aPersistAtom.nPsrReference = aDocAtom.nNotesMasterPersist;
1680 pE2->bStarDrawFiller = sal_False; // this is a dummy master page
1682 pMasterPages->C40_INSERT( PptSlidePersistEntry, pE2, ( nMasterPage + 1 ) << 1 );
1685 // Zu jeder Page noch das SlideAtom bzw. NotesAtom lesen, soweit vorhanden
1686 nPageListNum = 0;
1687 for ( nPageListNum = 0; nPageListNum < 3; nPageListNum++ )
1689 PptSlidePersistList* pPageList = GetPageList( PptPageKind( nPageListNum ) );
1690 for ( USHORT nPageNum = 0; nPageNum < pPageList->Count(); nPageNum++ )
1692 PptSlidePersistEntry* pE2 = (*pPageList)[ nPageNum ];
1693 ULONG nPersist = pE2->aPersistAtom.nPsrReference;
1694 if ( ( nPersist > 0 ) && ( nPersist < nPersistPtrAnz ) )
1696 ULONG nFPos = pPersistPtr[ nPersist ];
1697 if ( nFPos < nStreamLen )
1699 rStCtrl.Seek( nFPos );
1700 DffRecordHeader aSlideHd;
1701 rStCtrl >> aSlideHd;
1702 if ( SeekToRec( rStCtrl, PPT_PST_SlideAtom, aSlideHd.GetRecEndFilePos() ) )
1703 rStCtrl >> pE2->aSlideAtom;
1704 else if ( SeekToRec( rStCtrl, PPT_PST_NotesAtom, aSlideHd.GetRecEndFilePos() ) )
1705 rStCtrl >> pE2->aNotesAtom;
1706 aSlideHd.SeekToContent( rStCtrl );
1708 DffRecordHeader aPPTDrawingHd;
1709 if ( SeekToRec( rStCtrl, PPT_PST_PPDrawing, aSlideHd.GetRecEndFilePos(), &aPPTDrawingHd ) )
1711 DffRecordHeader aPPTDgContainer;
1712 if ( SeekToRec( rStCtrl, DFF_msofbtDgContainer, aPPTDrawingHd.GetRecEndFilePos(), &aPPTDgContainer ) )
1714 if ( SeekToRec( rStCtrl, DFF_msofbtDg, aPPTDrawingHd.GetRecEndFilePos() ) )
1716 DffRecordHeader aDgRecordHeader;
1717 rStCtrl >> aDgRecordHeader;
1718 pE2->nDrawingDgId = aDgRecordHeader.nRecInstance;
1719 aDgRecordHeader.SeekToEndOfRecord( rStCtrl );
1721 if ( SeekToRec( rStCtrl, DFF_msofbtSolverContainer, aPPTDgContainer.GetRecEndFilePos() ) )
1723 pE2->pSolverContainer = new SvxMSDffSolverContainer;
1724 rStCtrl >> *( pE2->pSolverContainer );
1726 aPPTDgContainer.SeekToBegOfRecord( rStCtrl );
1727 SetDgContainer( rStCtrl ); // set this, so that the escherimport is knowing of our drawings
1730 // office xp is supporting more than one stylesheet
1731 if ( ( pE2->ePageKind == PPT_MASTERPAGE ) && ( pE2->aSlideAtom.nMasterId == 0 ) && ( pE2->bNotesMaster == 0 ) )
1733 PPTTextSpecInfo aTxSI( 0 );
1734 if ( aTxSIStyle.bValid && aTxSIStyle.aList.Count() )
1735 aTxSI = *( ( (PPTTextSpecInfo*)aTxSIStyle.aList.GetObject( 0 ) ) );
1737 pE2->pStyleSheet = new PPTStyleSheet( aSlideHd, rStCtrl, *this, aTxCFStyle, aTxPFStyle, aTxSI );
1738 pDefaultSheet = pE2->pStyleSheet;
1740 if ( SeekToRec( rStCtrl, PPT_PST_ColorSchemeAtom, aSlideHd.GetRecEndFilePos() ) )
1741 rStCtrl >> pE2->aColorScheme;
1742 else
1744 DBG_ERROR( "SdrPowerPointImport::Ctor(): could not get SlideColorScheme! (SJ)" );
1747 else
1749 DBG_ERROR("SdrPowerPointImport::Ctor(): Persist-Eintrag fehlerhaft! (SJ)");
1754 DffRecordHeader* pHeadersFootersHd = aDocRecManager.GetRecordHeader( PPT_PST_HeadersFooters, SEEK_FROM_BEGINNING );
1755 if ( pHeadersFootersHd )
1757 HeaderFooterEntry aNormalMaster, aNotesMaster;
1758 for ( ; pHeadersFootersHd; pHeadersFootersHd = aDocRecManager.GetRecordHeader( PPT_PST_HeadersFooters, SEEK_FROM_CURRENT ) )
1760 if ( pHeadersFootersHd->nRecInstance == 3 ) // normal master
1761 ImportHeaderFooterContainer( *pHeadersFootersHd, aNormalMaster );
1762 else if ( pHeadersFootersHd->nRecInstance == 4 ) // notes master
1763 ImportHeaderFooterContainer( *pHeadersFootersHd, aNotesMaster );
1765 for ( USHORT i = 0; i < pMasterPages->Count(); i++ )
1767 if ( (*pMasterPages)[ i ]->bNotesMaster )
1768 (*pMasterPages)[ i ]->pHeaderFooterEntry = new HeaderFooterEntry( aNotesMaster );
1769 else
1770 (*pMasterPages)[ i ]->pHeaderFooterEntry = new HeaderFooterEntry( aNormalMaster );
1775 if ( ( rStCtrl.GetError() != 0 ) || ( pDefaultSheet == NULL ) )
1776 bOk = FALSE;
1777 pPPTStyleSheet = pDefaultSheet;
1778 rStCtrl.Seek( 0 );
1781 SdrPowerPointImport::~SdrPowerPointImport()
1783 for ( void* pPtr = aHyperList.First(); pPtr; pPtr = aHyperList.Next() )
1784 delete (SdHyperlinkEntry*)pPtr;
1785 delete pMasterPages;
1786 delete pSlidePages;
1787 delete pNotePages;
1788 delete[] pPersistPtr;
1791 sal_Bool PPTConvertOCXControls::InsertControl(
1792 const com::sun::star::uno::Reference<
1793 com::sun::star::form::XFormComponent > &rFComp,
1794 const com::sun::star::awt::Size& rSize,
1795 com::sun::star::uno::Reference<
1796 com::sun::star::drawing::XShape > *pShape,
1797 BOOL /*bFloatingCtrl*/)
1799 sal_Bool bRetValue = FALSE;
1802 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape;
1804 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > & rFormComps =
1805 GetFormComps();
1807 ::com::sun::star::uno::Any aTmp( &rFComp, ::getCppuType((const ::com::sun::star::uno::Reference<
1808 com::sun::star::form::XFormComponent >*)0) );
1810 rFormComps->insertByIndex( rFormComps->getCount(), aTmp );
1812 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceFactory =
1813 GetServiceFactory();
1814 if( rServiceFactory.is() )
1816 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xCreate = rServiceFactory
1817 ->createInstance(String( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.ControlShape" ) ) );
1818 if( xCreate.is() )
1820 xShape = ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >(xCreate, ::com::sun::star::uno::UNO_QUERY);
1821 if ( xShape.is() )
1823 xShape->setSize(rSize);
1824 // GetShapes()->add( xShape );
1825 // Das Control-Model am Control-Shape setzen
1826 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XControlShape > xControlShape( xShape,
1827 ::com::sun::star::uno::UNO_QUERY );
1828 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > xControlModel( rFComp,
1829 ::com::sun::star::uno::UNO_QUERY );
1830 if ( xControlShape.is() && xControlModel.is() )
1832 xControlShape->setControl( xControlModel );
1833 if (pShape)
1834 *pShape = xShape;
1835 bRetValue = TRUE;
1841 catch( ... )
1843 bRetValue = FALSE;
1845 return bRetValue;
1848 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& PPTConvertOCXControls::GetDrawPage()
1850 if( !xDrawPage.is() && pDocSh )
1852 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel( pDocSh->GetModel() );
1853 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPages > xDrawPages;
1854 switch( ePageKind )
1856 case PPT_SLIDEPAGE :
1857 case PPT_NOTEPAGE :
1859 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPagesSupplier >
1860 xDrawPagesSupplier( xModel, ::com::sun::star::uno::UNO_QUERY);
1861 if ( xDrawPagesSupplier.is() )
1862 xDrawPages = xDrawPagesSupplier->getDrawPages();
1864 break;
1866 case PPT_MASTERPAGE :
1868 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPagesSupplier >
1869 xMasterPagesSupplier( xModel, ::com::sun::star::uno::UNO_QUERY);
1870 if ( xMasterPagesSupplier.is() )
1871 xDrawPages = xMasterPagesSupplier->getMasterPages();
1873 break;
1875 if ( xDrawPages.is() && xDrawPages->getCount() )
1877 xDrawPages->getCount();
1878 ::com::sun::star::uno::Any aAny( xDrawPages->getByIndex( xDrawPages->getCount() - 1 ) );
1879 aAny >>= xDrawPage;
1882 return xDrawPage;
1885 sal_Bool SdrPowerPointOLEDecompress( SvStream& rOutput, SvStream& rInput, sal_uInt32 nInputSize )
1887 sal_uInt32 nOldPos = rInput.Tell();
1888 char* pBuf = new char[ nInputSize ];
1889 rInput.Read( pBuf, nInputSize );
1890 ZCodec aZCodec( 0x8000, 0x8000 );
1891 aZCodec.BeginCompression();
1892 SvMemoryStream aSource( pBuf, nInputSize, STREAM_READ );
1893 aZCodec.Decompress( aSource, rOutput );
1894 const sal_Bool bSuccess(0L != aZCodec.EndCompression());
1895 delete[] pBuf;
1896 rInput.Seek( nOldPos );
1897 return bSuccess;
1900 // --> OD 2004-12-14 #i32596# - add new parameter <_nCalledByGroup>
1901 SdrObject* SdrPowerPointImport::ImportOLE( long nOLEId,
1902 const Graphic& rGraf,
1903 const Rectangle& rBoundRect,
1904 const Rectangle& rVisArea,
1905 const int /*_nCalledByGroup*/,
1906 sal_Int64 /*nAspect*/ ) const
1907 // <--
1909 SdrObject* pRet = NULL;
1911 UINT32 nOldPos = rStCtrl.Tell();
1913 Graphic aGraphic( rGraf );
1915 if ( ((SdrPowerPointImport*)this)->maShapeRecords.SeekToContent( rStCtrl, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) )
1917 DffRecordHeader aPlaceHd;
1918 while ( ( rStCtrl.GetError() == 0 )
1919 && ( rStCtrl.Tell() < ((SdrPowerPointImport*)this)->maShapeRecords.Current()->GetRecEndFilePos() ) )
1921 rStCtrl >> aPlaceHd;
1922 if ( aPlaceHd.nRecType == PPT_PST_RecolorInfoAtom )
1924 ((SdrPowerPointImport*)this)->RecolorGraphic( rStCtrl, aPlaceHd.nRecLen, aGraphic );
1925 break;
1927 else
1928 aPlaceHd.SeekToEndOfRecord( rStCtrl );
1932 PPTOleEntry* pOe;
1933 for ( pOe = (PPTOleEntry*)((SdrPowerPointImport*)this)->aOleObjectList.First(); pOe;
1934 pOe = (PPTOleEntry*)((SdrPowerPointImport*)this)->aOleObjectList.Next() )
1936 if ( pOe->nId != (sal_uInt32)nOLEId )
1937 continue;
1939 rStCtrl.Seek( pOe->nRecHdOfs );
1941 DffRecordHeader aHd;
1942 rStCtrl >> aHd;
1944 sal_uInt32 nLen = aHd.nRecLen - 4;
1945 if ( (INT32)nLen > 0 )
1947 sal_Bool bSuccess = sal_False;
1949 rStCtrl.SeekRel( 4 );
1951 ::utl::TempFile aTmpFile;
1952 aTmpFile.EnableKillingFile( sal_True );
1954 if ( aTmpFile.IsValid() )
1956 SvStream* pDest = ::utl::UcbStreamHelper::CreateStream( aTmpFile.GetURL(), STREAM_TRUNC | STREAM_WRITE );
1957 if ( pDest )
1958 bSuccess = SdrPowerPointOLEDecompress( *pDest, rStCtrl, nLen );
1959 delete pDest;
1961 if ( bSuccess )
1963 SvStream* pDest = ::utl::UcbStreamHelper::CreateStream( aTmpFile.GetURL(), STREAM_READ );
1964 Storage* pObjStor = pDest ? new Storage( *pDest, TRUE ) : NULL;
1965 if ( pObjStor )
1967 SotStorageRef xObjStor( new SotStorage( pObjStor ) );
1968 if ( xObjStor.Is() && !xObjStor->GetError() )
1970 if ( xObjStor->GetClassName() == SvGlobalName() )
1972 ClsId aId( pObjStor->GetClassId() );
1973 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 ),
1974 pObjStor->GetFormat(), pObjStor->GetUserName() );
1976 SotStorageStreamRef xSrcTst = xObjStor->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "\1Ole" ) ) );
1977 if ( xSrcTst.Is() )
1979 BYTE aTestA[ 10 ];
1980 BOOL bGetItAsOle = ( sizeof( aTestA ) == xSrcTst->Read( aTestA, sizeof( aTestA ) ) );
1981 if ( !bGetItAsOle )
1982 { // maybe there is a contentsstream in here
1983 xSrcTst = xObjStor->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "Contents" ) ), STREAM_READWRITE | STREAM_NOCREATE );
1984 bGetItAsOle = ( xSrcTst.Is() && sizeof( aTestA ) == xSrcTst->Read( aTestA, sizeof( aTestA ) ) );
1986 if ( bGetItAsOle )
1988 ::rtl::OUString aNm;
1989 // if ( nSvxMSDffOLEConvFlags )
1991 uno::Reference < embed::XStorage > xDestStorage( pOe->pShell->GetStorage() );
1992 uno::Reference < embed::XEmbeddedObject > xObj =
1993 CheckForConvertToSOObj( nSvxMSDffOLEConvFlags, *xObjStor, xDestStorage, rGraf, rVisArea );
1994 if( xObj.is() )
1996 pOe->pShell->getEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aNm );
1998 svt::EmbeddedObjectRef aObj( xObj, pOe->nAspect );
2000 // TODO/LATER: need MediaType for Graphic
2001 aObj.SetGraphic( rGraf, ::rtl::OUString() );
2002 pRet = new SdrOle2Obj( aObj, aNm, rBoundRect, FALSE );
2005 if ( !pRet && ( pOe->nType == PPT_PST_ExControl ) )
2007 PPTConvertOCXControls aPPTConvertOCXControls( pOe->pShell, eAktPageKind );
2008 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape;
2009 if ( aPPTConvertOCXControls.ReadOCXStream( xObjStor, &xShape, FALSE ) )
2010 pRet = GetSdrObjectFromXShape( xShape );
2012 if ( !pRet )
2014 aNm = pOe->pShell->getEmbeddedObjectContainer().CreateUniqueObjectName();
2015 ErrCode aErrCode = 0;
2017 // object is not an own object
2018 SotStorageRef xTarget = SotStorage::OpenOLEStorage( pOe->pShell->GetStorage(), aNm, STREAM_READWRITE );
2019 if ( xObjStor.Is() && xTarget.Is() )
2021 xObjStor->CopyTo( xTarget );
2022 if( !xTarget->GetError() )
2023 xTarget->Commit();
2024 if( xTarget->GetError() )
2025 aErrCode = xTarget->GetError();
2027 xTarget.Clear();
2029 uno::Reference < embed::XEmbeddedObject > xObj =
2030 pOe->pShell->getEmbeddedObjectContainer().GetEmbeddedObject( aNm );
2031 if ( xObj.is() )
2033 if ( pOe->nAspect != embed::Aspects::MSOLE_ICON )
2035 //TODO/LATER: keep on hacking?!
2036 // modifiziert wollen wir nicht werden
2037 //xInplaceObj->EnableSetModified( FALSE );
2038 if ( rVisArea.IsEmpty() )
2040 MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( pOe->nAspect ) );
2041 Size aSize( OutputDevice::LogicToLogic( aGraphic.GetPrefSize(),
2042 aGraphic.GetPrefMapMode(), MapMode( aMapUnit ) ) );
2044 awt::Size aSz;
2045 aSz.Width = aSize.Width();
2046 aSz.Height = aSize.Height();
2047 xObj->setVisualAreaSize( pOe->nAspect, aSz );
2049 else
2051 awt::Size aSize( rVisArea.GetSize().Width(), rVisArea.GetSize().Height() );
2052 xObj->setVisualAreaSize( pOe->nAspect, aSize );
2054 //xInplaceObj->EnableSetModified( TRUE );
2057 svt::EmbeddedObjectRef aObj( xObj, pOe->nAspect );
2059 // TODO/LATER: need MediaType for Graphic
2060 aObj.SetGraphic( aGraphic, ::rtl::OUString() );
2062 pRet = new SdrOle2Obj( aObj, aNm, rBoundRect, FALSE );
2069 delete pDest;
2073 rStCtrl.Seek( nOldPos );
2075 return pRet;
2078 SvMemoryStream* SdrPowerPointImport::ImportExOleObjStg( UINT32 nPersistPtr, UINT32& nOleId ) const
2080 SvMemoryStream* pRet = NULL;
2081 if ( nPersistPtr && ( nPersistPtr < nPersistPtrAnz ) )
2083 UINT32 nOldPos, nOfs = pPersistPtr[ nPersistPtr ];
2084 nOldPos = rStCtrl.Tell();
2085 rStCtrl.Seek( nOfs );
2086 DffRecordHeader aHd;
2087 rStCtrl >> aHd;
2088 if ( aHd.nRecType == DFF_PST_ExOleObjStg )
2090 UINT32 nLen = aHd.nRecLen - 4;
2091 if ( (INT32)nLen > 0 )
2093 rStCtrl >> nOleId;
2094 pRet = new SvMemoryStream;
2095 ZCodec aZCodec( 0x8000, 0x8000 );
2096 aZCodec.BeginCompression();
2097 aZCodec.Decompress( rStCtrl, *pRet );
2098 if ( !aZCodec.EndCompression() )
2099 delete pRet, pRet = NULL;
2102 rStCtrl.Seek( nOldPos );
2104 return pRet;
2107 void SdrPowerPointImport::SeekOle( SfxObjectShell* pShell, sal_uInt32 nFilterOptions )
2109 if ( pShell )
2111 DffRecordHeader* pHd;
2113 UINT32 nOldPos = rStCtrl.Tell();
2114 if ( nFilterOptions & 1 )
2116 pHd = aDocRecManager.GetRecordHeader( PPT_PST_List, SEEK_FROM_BEGINNING );
2117 if ( pHd )
2119 // we try to locate the basic atom
2120 pHd->SeekToContent( rStCtrl );
2121 if ( SeekToRec( rStCtrl, PPT_PST_VBAInfo, pHd->GetRecEndFilePos(), pHd ) )
2123 if ( SeekToRec( rStCtrl, PPT_PST_VBAInfoAtom, pHd->GetRecEndFilePos(), pHd ) )
2125 UINT32 nPersistPtr, nIDoNotKnow1, nIDoNotKnow2;
2126 rStCtrl >> nPersistPtr
2127 >> nIDoNotKnow1
2128 >> nIDoNotKnow2;
2130 UINT32 nOleId;
2131 SvMemoryStream* pBas = ImportExOleObjStg( nPersistPtr, nOleId );
2132 if ( pBas )
2134 SotStorageRef xSource( new SotStorage( pBas, TRUE ) );
2135 SotStorageRef xDest( new SotStorage( new SvMemoryStream(), TRUE ) );
2136 if ( xSource.Is() && xDest.Is() )
2138 // is this a visual basic storage ?
2139 SotStorageRef xSubStorage = xSource->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "VBA" ) ),
2140 STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYALL );
2141 if( xSubStorage.Is() && ( SVSTREAM_OK == xSubStorage->GetError() ) )
2143 SotStorageRef xMacros = xDest->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "MACROS" ) ) );
2144 if ( xMacros.Is() )
2146 SvStorageInfoList aList;
2147 xSource->FillInfoList( &aList );
2148 UINT32 i;
2150 BOOL bCopied = TRUE;
2151 for ( i = 0; i < aList.Count(); i++ ) // copy all entrys
2153 const SvStorageInfo& rInfo = aList[ i ];
2154 if ( !xSource->CopyTo( rInfo.GetName(), xMacros, rInfo.GetName() ) )
2155 bCopied = FALSE;
2157 if ( i && bCopied )
2159 SvxImportMSVBasic aMSVBas( *pShell, *xDest, TRUE, FALSE );
2160 //int nSuccess = aMSVBas.Import( String( RTL_CONSTASCII_USTRINGPARAM( "MACROS" ) ),
2161 // String( RTL_CONSTASCII_USTRINGPARAM( "VBA" ) ), TRUE, FALSE );
2163 uno::Reference < embed::XStorage > xDoc( pShell->GetStorage() );
2164 if ( xDoc.is() )
2166 SotStorageRef xVBA = SotStorage::OpenOLEStorage( xDoc, String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Macros" ) ) );
2167 if ( xVBA.Is() && ( xVBA->GetError() == SVSTREAM_OK ) )
2169 SotStorageRef xSubVBA = xVBA->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Overhead" ) ) );
2170 if ( xSubVBA.Is() && ( xSubVBA->GetError() == SVSTREAM_OK ) )
2172 SotStorageStreamRef xOriginal = xSubVBA->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Overhead2" ) ) );
2173 if ( xOriginal.Is() && ( xOriginal->GetError() == SVSTREAM_OK ) )
2175 if ( nPersistPtr && ( nPersistPtr < nPersistPtrAnz ) )
2177 rStCtrl.Seek( pPersistPtr[ nPersistPtr ] );
2178 rStCtrl >> *pHd;
2180 *xOriginal << nIDoNotKnow1
2181 << nIDoNotKnow2;
2183 UINT32 nSource, nToCopy, nBufSize;
2184 nSource = rStCtrl.Tell();
2185 nToCopy = pHd->nRecLen;
2186 BYTE* pBuf = new BYTE[ 0x40000 ]; // 256KB Buffer
2187 if ( pBuf )
2189 while ( nToCopy )
2191 nBufSize = ( nToCopy >= 0x40000 ) ? 0x40000 : nToCopy;
2192 rStCtrl.Read( pBuf, nBufSize );
2193 xOriginal->Write( pBuf, nBufSize );
2194 nToCopy -= nBufSize;
2196 delete[] pBuf;
2212 pHd = aDocRecManager.GetRecordHeader( PPT_PST_ExObjList, SEEK_FROM_BEGINNING );
2213 if ( pHd )
2215 DffRecordManager* pExObjListManager = NULL;
2216 DffRecordHeader* pExEmbed = NULL;
2218 pHd->SeekToBegOfRecord( rStCtrl );
2219 pExObjListManager = new DffRecordManager( rStCtrl );
2220 sal_uInt16 i, nRecType(PPT_PST_ExEmbed);
2222 for ( i = 0; i < 2; i++ )
2224 switch ( i )
2226 case 0 : nRecType = PPT_PST_ExEmbed; break;
2227 case 1 : nRecType = PPT_PST_ExControl; break;
2229 for ( pExEmbed = pExObjListManager->GetRecordHeader( nRecType, SEEK_FROM_BEGINNING );
2230 pExEmbed; pExEmbed = pExObjListManager->GetRecordHeader( nRecType, SEEK_FROM_CURRENT ) )
2232 pExEmbed->SeekToContent( rStCtrl );
2234 DffRecordHeader aExOleAtHd;
2235 if ( SeekToRec( rStCtrl, PPT_PST_ExOleObjAtom, pExEmbed->GetRecEndFilePos(), &aExOleAtHd ) )
2237 PptExOleObjAtom aAt;
2238 rStCtrl >> aAt;
2240 if ( aAt.nPersistPtr && ( aAt.nPersistPtr < nPersistPtrAnz ) )
2242 UINT32 nId;
2243 rStCtrl.Seek( pPersistPtr[ aAt.nPersistPtr ] );
2244 DffRecordHeader aHd;
2245 rStCtrl >> aHd;
2246 if ( aHd.nRecType == DFF_PST_ExOleObjStg )
2248 rStCtrl >> nId;
2249 aOleObjectList.Insert(
2250 new PPTOleEntry( aAt.nId, aHd.nFilePos, pShell, nRecType, aAt.nAspect ) );
2256 delete pExObjListManager;
2258 rStCtrl.Seek( nOldPos );
2262 sal_Bool SdrPowerPointImport::ReadFontCollection()
2264 sal_Bool bRet = FALSE;
2265 DffRecordHeader* pEnvHd = aDocRecManager.GetRecordHeader( PPT_PST_Environment );
2266 if ( pEnvHd )
2268 ULONG nFPosMerk = rStCtrl.Tell(); // FilePos merken fuer spaetere Restauration
2269 pEnvHd->SeekToContent( rStCtrl );
2270 DffRecordHeader aListHd;
2271 if ( SeekToRec( rStCtrl, PPT_PST_FontCollection, pEnvHd->GetRecEndFilePos(), &aListHd ) )
2273 sal_uInt16 nCount2 = 0;
2274 VirtualDevice* pVDev = NULL;
2275 while ( SeekToRec( rStCtrl, PPT_PST_FontEntityAtom, aListHd.GetRecEndFilePos() ) )
2277 bRet = TRUE;
2278 if ( !pFonts )
2279 pFonts = new PptFontCollection;
2280 PptFontEntityAtom* pFont = new PptFontEntityAtom;
2281 rStCtrl >> *pFont;
2283 Font aFont;
2284 aFont.SetCharSet( pFont->eCharSet );
2285 aFont.SetName( pFont->aName );
2286 aFont.SetFamily( pFont->eFamily );
2287 aFont.SetPitch( pFont->ePitch );
2288 aFont.SetHeight( 100 );
2290 if ( mbTracing && !pFont->bAvailable )
2291 mpTracer->Trace( rtl::OUString::createFromAscii( "sd1000" ), pFont->aName );
2293 #ifdef DBG_EXTRACTFONTMETRICS
2295 SvxFont aTmpFont( aFont );
2297 if ( !pVDev )
2298 pVDev = new VirtualDevice;
2299 aTmpFont.SetPhysFont( pVDev );
2300 FontMetric aMetric( pVDev->GetFontMetric() );
2301 sal_uInt16 nTxtHeight = (sal_uInt16)aMetric.GetAscent() + (sal_uInt16)aMetric.GetDescent();
2303 String aFileURLStr;
2304 if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( Application::GetAppFileName(), aFileURLStr ) )
2306 INetURLObject aURL( aFileURLStr );
2307 aURL.SetName( String( RTL_CONSTASCII_STRINGPARAM( "dbgfontmetrics.txt" ) ) );
2309 SvStream* pDbgOut = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE );
2310 if( pDbgOut )
2312 pDbgOut->Seek( STREAM_SEEK_TO_END );
2314 Printer* pPrinter = NULL;
2315 if ( pSdrModel->GetRefDevice() && pSdrModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER )
2316 pPrinter = (Printer*)pSdrModel->GetRefDevice();
2317 if ( pPrinter )
2319 Font aOldFont( pPrinter->GetFont() );
2320 aFont.SetKerning( TRUE );
2321 pPrinter->SetFont( aFont );
2322 aMetric = pPrinter->GetFontMetric();
2323 pPrinter->SetFont( aOldFont );
2326 if ( ( pPrinter == NULL ) || ( aMetric.GetIntLeading() == 0 ) )
2328 VirtualDevice aVirDev( 1 );
2329 aVirDev.SetFont( aFont );
2330 aMetric = aVirDev.GetFontMetric();
2332 ByteString aFontName( aFont.GetName(), RTL_TEXTENCODING_UTF8 );
2333 ByteString aHeight( ByteString::CreateFromInt32( aMetric.GetLineHeight() ) );
2334 ByteString aAscent( ByteString::CreateFromInt32( aMetric.GetAscent() ) );
2335 ByteString aDescent( ByteString::CreateFromInt32( aMetric.GetDescent() ) );
2336 ByteString aLeading( ByteString::CreateFromInt32( aMetric.GetIntLeading() ) );
2337 ByteString aPhysHeight( ByteString::CreateFromInt32( nTxtHeight ) );
2339 *pDbgOut << (sal_uInt8)0xa
2340 << "FontName : " << aFontName.GetBuffer() << (sal_uInt8)0xa
2341 << " Height: " << aHeight.GetBuffer() << (sal_uInt8)0xa
2342 << " Ascent: " << aAscent.GetBuffer() << (sal_uInt8)0xa
2343 << " Descent:" << aDescent.GetBuffer() << (sal_uInt8)0xa
2344 << " Leading:" << aLeading.GetBuffer() << (sal_uInt8)0xa
2345 << "PhysHeight :" << aPhysHeight.GetBuffer()<< (sal_uInt8)0xa;
2347 delete pDbgOut;
2349 #endif
2350 // following block is necessary, because our old PowerPoint export did not set the
2351 // correct charset
2352 if ( pFont->aName.EqualsIgnoreCaseAscii( "Wingdings" ) ||
2353 pFont->aName.EqualsIgnoreCaseAscii( "Wingdings 2" ) ||
2354 pFont->aName.EqualsIgnoreCaseAscii( "Wingdings 3" ) ||
2355 pFont->aName.EqualsIgnoreCaseAscii( "Monotype Sorts" ) ||
2356 pFont->aName.EqualsIgnoreCaseAscii( "Monotype Sorts 2" ) ||
2357 pFont->aName.EqualsIgnoreCaseAscii( "Webdings" ) ||
2358 pFont->aName.EqualsIgnoreCaseAscii( "StarBats" ) ||
2359 pFont->aName.EqualsIgnoreCaseAscii( "StarMath" ) ||
2360 pFont->aName.EqualsIgnoreCaseAscii( "ZapfDingbats" ) )
2362 pFont->eCharSet = RTL_TEXTENCODING_SYMBOL;
2364 pFonts->C40_INSERT( PptFontEntityAtom, pFont, nCount2++ );
2366 delete pVDev;
2368 rStCtrl.Seek( nFPosMerk ); // FilePos restaurieren
2370 return bRet;
2373 PptSlidePersistList* SdrPowerPointImport::GetPageList(PptPageKind ePageKind) const
2375 if ( ePageKind == PPT_MASTERPAGE )
2376 return pMasterPages;
2377 if ( ePageKind == PPT_SLIDEPAGE )
2378 return pSlidePages;
2379 if ( ePageKind == PPT_NOTEPAGE )
2380 return pNotePages;
2381 return NULL;
2384 SdrOutliner* SdrPowerPointImport::GetDrawOutliner( SdrTextObj* pSdrText ) const
2386 if ( !pSdrText )
2387 return NULL;
2388 else
2389 return &pSdrText->ImpGetDrawOutliner();
2393 SdrObject* SdrPowerPointImport::ReadObjText( PPTTextObj* pTextObj, SdrObject* pSdrObj, SdPage* pPage ) const
2395 SdrTextObj* pText = PTR_CAST( SdrTextObj, pSdrObj );
2396 if ( pText )
2398 if ( !ApplyTextObj( pTextObj, pText, pPage, NULL, NULL ) )
2399 pSdrObj = NULL;
2401 return pSdrObj;
2405 SdrObject* SdrPowerPointImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* pSdrText, SdPage* /*pPage*/,
2406 SfxStyleSheet* pSheet, SfxStyleSheet** ppStyleSheetAry ) const
2408 SdrTextObj* pText = pSdrText;
2409 if ( pTextObj->Count() )
2411 UINT32 nDestinationInstance = pTextObj->GetDestinationInstance() ;
2412 SdrOutliner& rOutliner = pText->ImpGetDrawOutliner();
2413 if ( ( pText->GetObjInventor() == SdrInventor ) && ( pText->GetObjIdentifier() == OBJ_TITLETEXT ) ) // Outliner-Style fuer Titel-Textobjekt?!? (->von DL)
2414 rOutliner.Init( OUTLINERMODE_TITLEOBJECT ); // Outliner reset
2416 BOOL bOldUpdateMode = rOutliner.GetUpdateMode();
2417 rOutliner.SetUpdateMode( FALSE );
2418 if ( pSheet )
2420 if ( rOutliner.GetStyleSheet( 0 ) != pSheet )
2421 rOutliner.SetStyleSheet( 0, pSheet );
2423 rOutliner.SetVertical( pTextObj->GetVertical() );
2424 sal_Int16 nLastStartNumbering = -1;
2425 const PPTParagraphObj* pPreviousParagraph = NULL;
2426 for ( PPTParagraphObj* pPara = pTextObj->First(); pPara; pPara = pTextObj->Next() )
2428 UINT32 nTextSize = pPara->GetTextSize();
2429 if ( ! ( nTextSize & 0xffff0000 ) )
2431 PPTPortionObj* pPortion;
2432 sal_Unicode* pParaText = new sal_Unicode[ nTextSize ];
2433 UINT32 nCurrentIndex = 0;
2434 for ( pPortion = pPara->First(); pPortion; pPortion = pPara->Next() )
2436 if ( pPortion->mpFieldItem )
2437 pParaText[ nCurrentIndex++ ] = ' ';
2438 else
2440 sal_uInt32 nCharacters = pPortion->Count();
2441 const sal_Unicode* pSource = pPortion->maString.GetBuffer();
2442 sal_Unicode* pDest = pParaText + nCurrentIndex;
2444 sal_uInt32 nFont;
2445 pPortion->GetAttrib( PPT_CharAttr_Font, nFont, pTextObj->GetInstance() );
2446 PptFontEntityAtom* pFontEnityAtom = GetFontEnityAtom( nFont );
2447 if ( pFontEnityAtom && ( pFontEnityAtom->eCharSet == RTL_TEXTENCODING_SYMBOL ) )
2449 sal_uInt32 i;
2450 sal_Unicode nUnicode;
2451 for ( i = 0; i < nCharacters; i++ )
2453 nUnicode = pSource[ i ];
2454 if ( ! ( nUnicode & 0xff00 ) )
2455 nUnicode |= 0xf000;
2456 pDest[ i ] = nUnicode;
2459 else
2460 memcpy( pDest, pSource, nCharacters << 1 );
2461 nCurrentIndex += nCharacters;
2464 sal_uInt16 nParaIndex = (UINT16)pTextObj->GetCurrentIndex();
2465 SfxStyleSheet* pS = ( ppStyleSheetAry ) ? ppStyleSheetAry[ pPara->pParaSet->mnDepth ] : pSheet;
2467 ESelection aSelection( nParaIndex, 0, nParaIndex, 0 );
2468 rOutliner.Insert( String(), nParaIndex, pPara->pParaSet->mnDepth );
2469 rOutliner.QuickInsertText( String( pParaText, (UINT16)nCurrentIndex ), aSelection );
2470 rOutliner.SetParaAttribs( nParaIndex, rOutliner.GetEmptyItemSet() );
2471 if ( pS )
2472 rOutliner.SetStyleSheet( nParaIndex, pS );
2474 for ( pPortion = pPara->First(); pPortion; pPortion = pPara->Next() )
2476 SfxItemSet aPortionAttribs( rOutliner.GetEmptyItemSet() );
2477 SvxFieldItem* pFieldItem = pPortion->GetTextField();
2478 if ( pFieldItem )
2480 rOutliner.QuickInsertField( *pFieldItem, ESelection( nParaIndex, aSelection.nEndPos, nParaIndex, aSelection.nEndPos + 1 ) );
2481 aSelection.nEndPos++;
2482 delete pFieldItem;
2484 else
2486 const sal_Unicode *pF, *pPtr = pPortion->maString.GetBuffer();
2487 const sal_Unicode *pMax = pPtr + pPortion->maString.Len();
2488 sal_Int32 nLen;
2489 for ( pF = pPtr; pPtr < pMax; pPtr++ )
2491 if ( *pPtr == 0xb )
2493 nLen = pPtr - pF;
2494 if ( nLen )
2495 aSelection.nEndPos =
2496 sal::static_int_cast< USHORT >(
2497 aSelection.nEndPos + nLen );
2498 pF = pPtr + 1;
2499 rOutliner.QuickInsertLineBreak( ESelection( nParaIndex, aSelection.nEndPos, nParaIndex, aSelection.nEndPos + 1 ) );
2500 aSelection.nEndPos++;
2503 nLen = pPtr - pF;
2504 if ( nLen )
2505 aSelection.nEndPos = sal::static_int_cast< USHORT >(
2506 aSelection.nEndPos + nLen );
2508 pPortion->ApplyTo( aPortionAttribs, (SdrPowerPointImport&)*this, nDestinationInstance, pTextObj );
2509 rOutliner.QuickSetAttribs( aPortionAttribs, aSelection );
2510 aSelection.nStartPos = aSelection.nEndPos;
2512 boost::optional< sal_Int16 > oStartNumbering;
2513 SfxItemSet aParagraphAttribs( rOutliner.GetEmptyItemSet() );
2514 pPara->ApplyTo( aParagraphAttribs, oStartNumbering, (SdrPowerPointImport&)*this, nDestinationInstance, pPreviousParagraph );
2516 UINT32 nIsBullet2 = 0; //, nInstance = nDestinationInstance != 0xffffffff ? nDestinationInstance : pTextObj->GetInstance();
2517 pPara->GetAttrib( PPT_ParaAttr_BulletOn, nIsBullet2, nDestinationInstance );
2518 if ( !nIsBullet2 )
2519 aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, FALSE ) );
2521 if ( oStartNumbering )
2523 if ( *oStartNumbering != nLastStartNumbering )
2524 rOutliner.SetNumberingStartValue( nParaIndex, *oStartNumbering );
2525 else
2526 rOutliner.SetNumberingStartValue( nParaIndex, -1 );
2527 nLastStartNumbering = *oStartNumbering;
2529 else
2531 nLastStartNumbering = -1;
2532 rOutliner.SetNumberingStartValue( nParaIndex, nLastStartNumbering );
2535 pPreviousParagraph = pPara;
2536 if ( !aSelection.nStartPos ) // in PPT empty paragraphs never gets a bullet
2538 aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, FALSE ) );
2539 // rOutliner.SetDepth( rOutliner.GetParagraph( nParaIndex ), -1 );
2541 aSelection.nStartPos = 0;
2542 rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection );
2543 delete[] pParaText;
2546 OutlinerParaObject* pNewText = rOutliner.CreateParaObject();
2547 rOutliner.Clear();
2548 rOutliner.SetUpdateMode( bOldUpdateMode );
2549 pText->SetOutlinerParaObject( pNewText );
2551 return pText;
2554 sal_Bool SdrPowerPointImport::SeekToDocument( DffRecordHeader* pRecHd ) const
2556 sal_Bool bRet;
2557 ULONG nFPosMerk = rStCtrl.Tell(); // FilePos merken fuer ggf. spaetere Restauration
2558 rStCtrl.Seek( nDocStreamPos );
2559 DffRecordHeader aDocHd;
2560 rStCtrl >> aDocHd;
2561 bRet = aDocHd.nRecType == PPT_PST_Document;
2562 if ( bRet )
2564 if ( pRecHd )
2565 *pRecHd = aDocHd;
2566 else
2567 aDocHd.SeekToBegOfRecord( rStCtrl );
2569 if ( !bRet )
2570 rStCtrl.Seek( nFPosMerk ); // FilePos restaurieren
2571 return bRet;
2574 sal_Bool SdrPowerPointImport::SeekToContentOfProgTag( sal_Int32 nVersion, SvStream& rSt,
2575 const DffRecordHeader& rSourceHd, DffRecordHeader& rContentHd )
2577 sal_Bool bRetValue = sal_False;
2578 sal_uInt32 nOldPos = rSt.Tell();
2580 DffRecordHeader aProgTagsHd, aProgTagBinaryDataHd;
2581 rSourceHd.SeekToContent( rSt );
2582 sal_Bool bFound = rSourceHd.nRecType == PPT_PST_ProgTags;
2583 if ( !bFound )
2584 bFound = SeekToRec( rSt, PPT_PST_ProgTags, rSourceHd.GetRecEndFilePos(), &aProgTagsHd );
2585 if ( bFound )
2587 while( SeekToRec( rSt, PPT_PST_ProgBinaryTag, aProgTagsHd.GetRecEndFilePos(), &aProgTagBinaryDataHd ) )
2589 rSt >> rContentHd;
2590 if ( rContentHd.nRecType == PPT_PST_CString )
2592 sal_uInt16 n = 6;
2593 sal_uInt32 i = rContentHd.nRecLen >> 1;
2594 if ( i > n )
2596 String aPre, aSuf;
2597 sal_Unicode *pTmp = aPre.AllocBuffer( n );
2598 while ( n-- )
2599 rSt >> *pTmp++;
2600 n = (sal_uInt16)( i - 6 );
2601 pTmp = aSuf.AllocBuffer( n );
2602 while ( n-- )
2603 rSt >> *pTmp++;
2604 sal_Int32 nV = aSuf.ToInt32();
2605 if ( ( nV == nVersion ) && ( aPre == String( RTL_CONSTASCII_USTRINGPARAM( "___PPT" ) ) ) )
2607 rContentHd.SeekToEndOfRecord( rSt );
2608 rSt >> rContentHd;
2609 if ( rContentHd.nRecType == PPT_PST_BinaryTagData )
2611 bRetValue = sal_True;
2612 break;
2617 aProgTagBinaryDataHd.SeekToEndOfRecord( rSt );
2620 if ( !bRetValue )
2621 rSt.Seek( nOldPos );
2622 return bRetValue;
2625 UINT32 SdrPowerPointImport::GetAktPageId()
2627 PptSlidePersistList* pList = GetPageList( eAktPageKind );
2628 if ( pList && nAktPageNum < pList->Count() )
2629 return (*pList)[ (USHORT)nAktPageNum ]->aPersistAtom.nSlideId;
2630 return 0;
2633 sal_Bool SdrPowerPointImport::SeekToAktPage( DffRecordHeader* pRecHd ) const
2635 sal_Bool bRet = FALSE;
2636 PptSlidePersistList* pList = GetPageList( eAktPageKind );
2637 if ( pList && ( nAktPageNum < pList->Count() ) )
2639 ULONG nPersist = (*pList)[ (USHORT)nAktPageNum ]->aPersistAtom.nPsrReference;
2640 if ( nPersist > 0 && nPersist < nPersistPtrAnz )
2642 ULONG nFPos = 0;
2643 nFPos = pPersistPtr[ nPersist ];
2644 if ( nFPos < nStreamLen )
2646 rStCtrl.Seek( nFPos );
2647 if ( pRecHd )
2648 rStCtrl >> *pRecHd;
2649 bRet = TRUE;
2653 return bRet;
2656 USHORT SdrPowerPointImport::GetPageCount( PptPageKind ePageKind ) const
2658 PptSlidePersistList* pList = GetPageList( ePageKind );
2659 if ( pList )
2660 return pList->Count();
2661 return 0;
2664 void SdrPowerPointImport::SetPageNum( sal_uInt16 nPageNum, PptPageKind eKind )
2666 eAktPageKind = eKind;
2667 nAktPageNum = nPageNum;
2669 pPPTStyleSheet = NULL;
2671 sal_Bool bHasMasterPage = sal_True;
2672 sal_uInt16 nMasterIndex = 0;
2674 if ( eKind == PPT_MASTERPAGE )
2675 nMasterIndex = nPageNum;
2676 else
2678 if ( HasMasterPage( nPageNum, eKind ) )
2679 nMasterIndex = GetMasterPageIndex( nPageNum, eKind );
2680 else
2681 bHasMasterPage = sal_False;
2683 if ( bHasMasterPage )
2685 PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE );
2686 if ( pPageList && nMasterIndex < pPageList->Count() )
2688 PptSlidePersistEntry* pMasterPersist = (*pPageList)[ nMasterIndex ];
2689 if ( ( pMasterPersist->pStyleSheet == NULL ) && pMasterPersist->aSlideAtom.nMasterId )
2691 nMasterIndex = pMasterPages->FindPage( pMasterPersist->aSlideAtom.nMasterId );
2692 if ( nMasterIndex != PPTSLIDEPERSIST_ENTRY_NOTFOUND )
2693 pMasterPersist = (*pPageList)[ nMasterIndex ];
2695 pPPTStyleSheet = pMasterPersist->pStyleSheet;
2698 if ( !pPPTStyleSheet )
2699 pPPTStyleSheet = pDefaultSheet;
2702 Size SdrPowerPointImport::GetPageSize() const
2704 Size aRet( IsNoteOrHandout( nAktPageNum, eAktPageKind ) ? aDocAtom.GetNotesPageSize() : aDocAtom.GetSlidesPageSize() );
2705 Scale( aRet );
2706 // PPT arbeitet nur mit Einheiten zu 576DPI. Um Ungenauigkeiten zu
2707 // vermeiden runde ich die letzte Nachkommastelle metrisch weg.
2708 if ( nMapMul > 2 * nMapDiv )
2710 MapUnit eMap = pSdrModel->GetScaleUnit();
2711 bool bInch = IsInch( eMap );
2712 long nInchMul = 1, nInchDiv = 1;
2713 if ( bInch )
2714 { // Size temporaer (zum runden) in nach metric konvertieren
2715 Fraction aFact(GetMapFactor(eMap,MAP_100TH_MM).X());
2716 nInchMul = aFact.GetNumerator();
2717 nInchDiv = aFact.GetDenominator();
2718 aRet.Width() = BigMulDiv( aRet.Width(), nInchMul, nInchDiv );
2719 aRet.Height() = BigMulDiv( aRet.Height(), nInchMul, nInchDiv );
2721 aRet.Width() += 5; aRet.Width() /= 10; aRet.Width()*=10;
2722 aRet.Height() += 5; aRet.Height() /= 10; aRet.Height()*=10;
2723 if ( bInch )
2725 aRet.Width() = BigMulDiv( aRet.Width(), nInchDiv, nInchMul );
2726 aRet.Height() = BigMulDiv( aRet.Height(), nInchDiv, nInchMul );
2729 return aRet;
2732 FASTBOOL SdrPowerPointImport::GetColorFromPalette( USHORT nNum, Color& rColor ) const
2734 if ( nPageColorsNum != nAktPageNum || ePageColorsKind != eAktPageKind )
2736 UINT16 nSlideFlags = 0;
2737 PptSlidePersistList* pPageList = GetPageList( eAktPageKind );
2738 if ( pPageList && ( nAktPageNum < pPageList->Count() ) )
2740 PptSlidePersistEntry* pE = (*pPageList)[ nAktPageNum ];
2741 if ( pE )
2742 nSlideFlags = pE->aSlideAtom.nFlags;
2743 if ( ! ( nSlideFlags & 2 ) )
2744 ((SdrPowerPointImport*)this)->aPageColors = pE->aColorScheme;
2746 if ( nSlideFlags & 2 ) // follow master colorscheme ?
2748 PptSlidePersistList* pPageList2 = GetPageList( PPT_MASTERPAGE );
2749 if ( pPageList2 )
2751 PptSlidePersistEntry* pMasterPersist = NULL;
2752 if ( eAktPageKind == PPT_MASTERPAGE )
2753 pMasterPersist = (*pPageList2)[ nAktPageNum ];
2754 else
2756 if ( HasMasterPage( nAktPageNum, eAktPageKind ) )
2758 sal_uInt16 nMasterNum = GetMasterPageIndex( nAktPageNum, eAktPageKind );
2759 if ( nMasterNum < pPageList2->Count() )
2760 pMasterPersist = (*pPageList2)[ nMasterNum ];
2763 if ( pMasterPersist )
2765 while( ( pMasterPersist && pMasterPersist->aSlideAtom.nFlags & 2 ) // it is possible that a masterpage
2766 && pMasterPersist->aSlideAtom.nMasterId ) // itself is following a master colorscheme
2768 sal_uInt16 nNextMaster = pMasterPages->FindPage( pMasterPersist->aSlideAtom.nMasterId );
2769 if ( nNextMaster == PPTSLIDEPERSIST_ENTRY_NOTFOUND )
2770 break;
2771 else
2772 pMasterPersist = (*pPageList2)[ nNextMaster ];
2774 ((SdrPowerPointImport*)this)->aPageColors = pMasterPersist->aColorScheme;
2778 // momentanes Farbschema eintragen
2779 ((SdrPowerPointImport*)this)->nPageColorsNum = nAktPageNum;
2780 ((SdrPowerPointImport*)this)->ePageColorsKind = eAktPageKind;
2782 rColor = aPageColors.GetColor( nNum );
2783 return TRUE;
2786 BOOL SdrPowerPointImport::SeekToShape( SvStream& rSt, void* pClientData, UINT32 nId ) const
2788 BOOL bRet = SvxMSDffManager::SeekToShape( rSt, pClientData, nId );
2789 if ( !bRet )
2791 ProcessData& rData = *( (ProcessData*)pClientData );
2792 PptSlidePersistEntry& rPersistEntry = rData.rPersistEntry;
2793 if ( rPersistEntry.ePageKind == PPT_SLIDEPAGE )
2795 if ( HasMasterPage( nAktPageNum, eAktPageKind ) )
2797 USHORT nMasterNum = GetMasterPageIndex( nAktPageNum, eAktPageKind );
2798 PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE );
2799 if ( pPageList && ( nMasterNum < pPageList->Count() ) )
2801 PptSlidePersistEntry* pPersist = (*pPageList)[ nMasterNum ]; // get the masterpage's persistentry
2802 if ( pPersist && pPersist->pPresentationObjects )
2804 UINT32 nCurrent(0L);
2805 DffRecordList* pCList = maShapeRecords.pCList; // we got a backup of the current position
2806 if ( pCList )
2807 nCurrent = pCList->nCurrent;
2808 if ( ((SdrEscherImport*)this )->maShapeRecords.SeekToContent( rSt, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) )
2810 UINT32 nStreamPos = rSt.Tell();
2811 PPTTextObj aTextObj( rSt, (SdrPowerPointImport&)*this, rPersistEntry, NULL );
2812 if ( aTextObj.Count() || aTextObj.GetOEPlaceHolderAtom() )
2814 UINT32 nShapePos = 0;
2815 switch ( aTextObj.GetInstance() )
2817 case TSS_TYPE_TITLE :
2818 nShapePos = pPersist->pPresentationObjects[ TSS_TYPE_PAGETITLE ];
2819 break;
2820 case TSS_TYPE_PAGETITLE :
2821 nShapePos = pPersist->pPresentationObjects[ TSS_TYPE_PAGETITLE ];
2822 break;
2823 case TSS_TYPE_SUBTITLE :
2824 case TSS_TYPE_HALFBODY :
2825 case TSS_TYPE_QUARTERBODY :
2826 case TSS_TYPE_BODY :
2827 nShapePos = pPersist->pPresentationObjects[ TSS_TYPE_BODY ];
2828 break;
2829 // case TSS_TYPE_NOTES :
2830 // case TSS_TYPE_UNUSED :
2831 // case TSS_TYPE_TEXT_IN_SHAPE :
2833 if ( nShapePos )
2835 rSt.Seek( nShapePos );
2836 bRet = TRUE;
2839 if ( !bRet )
2840 rSt.Seek( nStreamPos );
2842 if ( pCList ) // restoring
2843 pCList->nCurrent = nCurrent;
2844 ((SdrEscherImport*)this )->maShapeRecords.pCList = pCList;
2850 return bRet;
2853 SdrPage* SdrPowerPointImport::MakeBlancPage( sal_Bool bMaster ) const
2855 SdrPage* pRet = pSdrModel->AllocPage( bMaster );
2856 pRet->SetSize( GetPageSize() );
2859 SJ (21.08.00) : since bug #77576# i decided not to set a border size.
2861 Size aPageSize( aDocAtom.GetSlidesPageSize() ); // PageSize in 576DPI-Units
2862 long nHMarg = aPageSize.Width() - aDocAtom.aSlidesPageSize.Width();
2863 long nVMarg = aPageSize.Height() - aDocAtom.aSlidesPageSize.Height();
2864 if ( nHMarg > 0 )
2866 Scale( nHMarg );
2867 pRet->SetLftBorder( nHMarg / 2 );
2868 pRet->SetRgtBorder( nHMarg - nHMarg / 2 );
2870 if ( nVMarg > 0 )
2872 Scale( nVMarg );
2873 pRet->SetUppBorder( nVMarg / 2 );
2874 pRet->SetLwrBorder( nVMarg - nVMarg / 2 );
2877 return pRet;
2880 void ImportComment10( SvxMSDffManager& rMan, SvStream& rStCtrl, SdrPage* pPage, DffRecordHeader& rComment10Hd )
2882 rtl::OUString sAuthor;
2883 rtl::OUString sText;
2884 rtl::OUString sInitials;
2886 sal_Int32 nIndex = 0;
2887 util::DateTime aDateTime;
2888 sal_Int32 nPosX = 0;
2889 sal_Int32 nPosY = 0;
2891 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < rComment10Hd.GetRecEndFilePos() ) )
2893 DffRecordHeader aCommentHd;
2894 rStCtrl >> aCommentHd;
2895 switch( aCommentHd.nRecType )
2897 case PPT_PST_CString :
2899 String aString;
2900 SvxMSDffManager::MSDFFReadZString( rStCtrl, aString, aCommentHd.nRecLen, TRUE );
2901 switch ( aCommentHd.nRecInstance )
2903 case 0 : sAuthor = aString; break;
2904 case 1 : sText = aString; break;
2905 case 2 : sInitials = aString; break;
2908 break;
2910 case PPT_PST_CommentAtom10 :
2912 rStCtrl >> nIndex
2913 >> aDateTime.Year
2914 >> aDateTime.Month
2915 >> aDateTime.Day // DayOfWeek
2916 >> aDateTime.Day
2917 >> aDateTime.Hours
2918 >> aDateTime.Minutes
2919 >> aDateTime.Seconds
2920 >> aDateTime.HundredthSeconds
2921 >> nPosX
2922 >> nPosY;
2924 aDateTime.HundredthSeconds /= 10;
2926 break;
2928 aCommentHd.SeekToEndOfRecord( rStCtrl );
2930 Point aPosition( nPosX, nPosY );
2931 rMan.Scale( aPosition );
2935 uno::Reference< office::XAnnotationAccess > xAnnotationAccess( pPage->getUnoPage(), UNO_QUERY_THROW );
2936 uno::Reference< office::XAnnotation > xAnnotation( xAnnotationAccess->createAndInsertAnnotation() );
2937 xAnnotation->setPosition( geometry::RealPoint2D( aPosition.X() / 100.0, aPosition.Y() / 100.0 ) );
2938 xAnnotation->setAuthor( sAuthor );
2939 xAnnotation->setDateTime( aDateTime );
2940 uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
2941 xText->setString( sText );
2943 catch( uno::Exception& )
2950 // be sure not to import masterpages with this method
2951 // be sure not to import masterpages with this method
2952 void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry* pMasterPersist )
2954 UINT32 nMerk = rStCtrl.Tell();
2955 PptSlidePersistList* pList = GetPageList( eAktPageKind );
2956 if ( ( !pList ) || ( pList->Count() <= nAktPageNum ) )
2957 return;
2958 PptSlidePersistEntry& rSlidePersist = *(*pList)[ nAktPageNum ];
2959 if ( rSlidePersist.bStarDrawFiller )
2960 return;
2962 DffRecordHeader aPageHd;
2963 if ( SeekToAktPage( &aPageHd ) )
2965 if ( mbTracing )
2966 mpTracer->AddAttribute( eAktPageKind == PPT_SLIDEPAGE
2967 ? rtl::OUString::createFromAscii( "Page" )
2968 : rtl::OUString::createFromAscii( "NotesPage" ),
2969 rtl::OUString::valueOf( (sal_Int32)nAktPageNum + 1 ) );
2971 rSlidePersist.pHeaderFooterEntry = new HeaderFooterEntry( pMasterPersist );
2972 ProcessData aProcessData( rSlidePersist, (SdPage*)pRet );
2973 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPageHd.GetRecEndFilePos() ) )
2975 DffRecordHeader aHd;
2976 rStCtrl >> aHd;
2977 switch ( aHd.nRecType )
2979 case PPT_PST_HeadersFooters :
2981 ImportHeaderFooterContainer( aHd, *rSlidePersist.pHeaderFooterEntry );
2983 break;
2985 case PPT_PST_ProgTags :
2987 DffRecordHeader aContentDataHd;
2988 if ( SeekToContentOfProgTag( 10, rStCtrl, aHd, aContentDataHd ) )
2990 DffRecordHeader aComment10Hd;
2991 while( ( rStCtrl.GetError() == 0 ) && SeekToRec( rStCtrl, PPT_PST_Comment10, aContentDataHd.GetRecEndFilePos(), &aComment10Hd ) )
2993 ImportComment10( *this, rStCtrl, pRet, aComment10Hd );
2994 aComment10Hd.SeekToEndOfRecord( rStCtrl );
2998 break;
3000 case PPT_PST_PPDrawing :
3002 DffRecordHeader aPPDrawHd;
3003 if ( SeekToRec( rStCtrl, DFF_msofbtDgContainer, aHd.GetRecEndFilePos(), &aPPDrawHd ) )
3005 sal_uInt32 nPPDrawOfs = rStCtrl.Tell();
3007 // importing the background object before importing the page
3008 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPPDrawHd.GetRecEndFilePos() ) )
3010 DffRecordHeader aEscherObjListHd;
3011 rStCtrl >> aEscherObjListHd;
3012 switch ( aEscherObjListHd.nRecType )
3014 case DFF_msofbtSpContainer :
3016 Rectangle aPageSize( Point(), pRet->GetSize() );
3017 if ( rSlidePersist.aSlideAtom.nFlags & 4 ) // follow master background ?
3019 if ( HasMasterPage( nAktPageNum, eAktPageKind ) )
3021 sal_uInt16 nMasterNum = GetMasterPageIndex( nAktPageNum, eAktPageKind );
3022 PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE );
3023 PptSlidePersistEntry* pE = (*pPageList)[ nMasterNum ];
3024 while( ( pE->aSlideAtom.nFlags & 4 ) && pE->aSlideAtom.nMasterId )
3026 sal_uInt16 nNextMaster = pMasterPages->FindPage( pE->aSlideAtom.nMasterId );
3027 if ( nNextMaster == PPTSLIDEPERSIST_ENTRY_NOTFOUND )
3028 break;
3029 else
3030 pE = (*pPageList)[ nNextMaster ];
3032 if ( pE->nBackgroundOffset )
3034 // do not follow master colorscheme ?
3035 sal_Bool bTemporary = ( rSlidePersist.aSlideAtom.nFlags & 2 ) != 0;
3036 sal_uInt32 nPos = rStCtrl.Tell();
3037 rStCtrl.Seek( pE->nBackgroundOffset );
3038 rSlidePersist.pBObj = ImportObj( rStCtrl, (void*)&aProcessData, aPageSize, aPageSize );
3039 rSlidePersist.bBObjIsTemporary = bTemporary;
3040 rStCtrl.Seek( nPos );
3044 else
3046 DffRecordHeader aShapeHd;
3047 rStCtrl >> aShapeHd;
3048 if ( aShapeHd.nRecType == DFF_msofbtSp )
3050 UINT32 nSpFlags;
3051 rStCtrl >> nSpFlags >> nSpFlags;
3052 if ( nSpFlags & SP_FBACKGROUND )
3054 aEscherObjListHd.SeekToBegOfRecord( rStCtrl );
3055 rSlidePersist.pBObj = ImportObj( rStCtrl, (void*)&aProcessData, aPageSize, aPageSize );
3056 rSlidePersist.bBObjIsTemporary = sal_False;
3061 break;
3063 if ( aEscherObjListHd.nRecType == DFF_msofbtSpContainer )
3064 break;
3065 aEscherObjListHd.SeekToEndOfRecord( rStCtrl );
3068 // now importing page
3069 rStCtrl.Seek( nPPDrawOfs );
3070 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPPDrawHd.GetRecEndFilePos() ) )
3072 DffRecordHeader aEscherObjListHd;
3073 rStCtrl >> aEscherObjListHd;
3074 switch ( aEscherObjListHd.nRecType )
3076 case DFF_msofbtSpgrContainer :
3078 DffRecordHeader aShapeHd;
3079 if ( SeekToRec( rStCtrl, DFF_msofbtSpContainer, aEscherObjListHd.GetRecEndFilePos(), &aShapeHd ) )
3081 aShapeHd.SeekToEndOfRecord( rStCtrl );
3082 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aEscherObjListHd.GetRecEndFilePos() ) )
3084 rStCtrl >> aShapeHd;
3085 if ( ( aShapeHd.nRecType == DFF_msofbtSpContainer ) || ( aShapeHd.nRecType == DFF_msofbtSpgrContainer ) )
3087 Rectangle aEmpty;
3088 aShapeHd.SeekToBegOfRecord( rStCtrl );
3089 sal_Int32 nShapeId;
3090 aProcessData.pTableRowProperties = NULL;
3091 SdrObject* pObj = ImportObj( rStCtrl, (void*)&aProcessData, aEmpty, aEmpty, 0, &nShapeId );
3092 if ( pObj )
3094 if ( aProcessData.pTableRowProperties )
3095 pObj = CreateTable( pObj, aProcessData.pTableRowProperties, aProcessData.rPersistEntry.pSolverContainer );
3097 pRet->NbcInsertObject( pObj );
3099 if( nShapeId )
3100 insertShapeId( nShapeId, pObj );
3103 aShapeHd.SeekToEndOfRecord( rStCtrl );
3107 break;
3109 if ( aEscherObjListHd.nRecType == DFF_msofbtSpgrContainer )
3110 break;
3111 aEscherObjListHd.SeekToEndOfRecord( rStCtrl );
3114 /* There are a lot of Shapes who are dependent to
3115 the current background color */
3116 if ( rSlidePersist.ePageKind == PPT_SLIDEPAGE )
3118 List* pList2 = aProcessData.pBackgroundColoredObjects;
3119 if ( pList2 )
3121 if ( rSlidePersist.pBObj )
3123 void* pPtr;
3124 const SfxPoolItem* pPoolItem = NULL;
3125 const SfxItemSet& rObjectItemSet = rSlidePersist.pBObj->GetMergedItemSet();
3127 //SfxItemState eState = rObjectItemSet.GetItemState( XATTR_FILLCOLOR, FALSE, &pPoolItem );
3128 if ( pPoolItem )
3130 SfxItemSet aNewSet(*rObjectItemSet.GetPool());
3131 aNewSet.Put(*pPoolItem);
3132 aNewSet.Put(XFillStyleItem( XFILL_SOLID ));
3134 for ( pPtr = pList2->First(); pPtr; pPtr = pList2->Next() )
3136 ((SdrObject*)pPtr)->SetMergedItemSet(aNewSet);
3142 if ( rSlidePersist.pBObj )
3144 if ( rSlidePersist.bBObjIsTemporary )
3145 SdrObject::Free( rSlidePersist.pBObj );
3146 else
3147 pRet->SetBackgroundObj( rSlidePersist.pBObj );
3151 break;
3153 aHd.SeekToEndOfRecord( rStCtrl );
3155 if ( rSlidePersist.pSolverContainer )
3156 SolveSolver( *rSlidePersist.pSolverContainer );
3157 if ( mbTracing )
3158 mpTracer->RemoveAttribute( eAktPageKind == PPT_SLIDEPAGE
3159 ? rtl::OUString::createFromAscii( "Page" )
3160 : rtl::OUString::createFromAscii( "NotesPage" ) );
3162 rStCtrl.Seek( nMerk );
3165 const PptSlideLayoutAtom* SdrPowerPointImport::GetSlideLayoutAtom() const
3167 PptSlidePersistList* pPageList = GetPageList( eAktPageKind );
3168 if ( pPageList && nAktPageNum < pPageList->Count() )
3170 PptSlidePersistEntry* pE = (*pPageList)[ nAktPageNum ];
3171 if ( pE )
3172 return &pE->aSlideAtom.aLayout;
3174 return NULL;
3177 sal_Bool SdrPowerPointImport::IsNoteOrHandout( USHORT nPageNum, PptPageKind /*ePageKind*/) const
3179 sal_Bool bNote = eAktPageKind == PPT_NOTEPAGE;
3180 if ( eAktPageKind == PPT_MASTERPAGE )
3181 bNote = ( nPageNum & 1 ) == 0;
3182 return bNote;
3185 UINT32 SdrPowerPointImport::GetMasterPageId( USHORT nPageNum, PptPageKind ePageKind ) const
3187 PptSlidePersistList* pPageList = GetPageList( ePageKind );
3188 if ( pPageList && nPageNum < pPageList->Count() )
3189 return (*pPageList)[ nPageNum ]->aSlideAtom.nMasterId;
3190 return 0;
3193 UINT32 SdrPowerPointImport::GetNotesPageId( USHORT nPageNum ) const
3195 PptSlidePersistList* pPageList=GetPageList( PPT_SLIDEPAGE );
3196 if ( pPageList && nPageNum < pPageList->Count() )
3197 return (*pPageList)[ nPageNum ]->aSlideAtom.nNotesId;
3198 return 0;
3201 sal_Bool SdrPowerPointImport::HasMasterPage( USHORT nPageNum, PptPageKind ePageKind ) const
3203 if ( ePageKind == PPT_NOTEPAGE )
3204 return aDocAtom.nNotesMasterPersist != 0;
3205 if ( ePageKind == PPT_MASTERPAGE )
3206 return FALSE;
3207 return GetMasterPageId( nPageNum, ePageKind ) != 0;
3210 USHORT SdrPowerPointImport::GetMasterPageIndex( USHORT nPageNum, PptPageKind ePageKind ) const
3212 USHORT nIdx = 0;
3213 if ( ePageKind == PPT_NOTEPAGE )
3214 return 2;
3215 UINT32 nId = GetMasterPageId( nPageNum, ePageKind );
3216 if ( nId && pMasterPages )
3218 nIdx = pMasterPages->FindPage( nId );
3219 if ( nIdx == PPTSLIDEPERSIST_ENTRY_NOTFOUND )
3220 nIdx = 0;
3222 return nIdx;
3225 SdrObject* SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage, sal_uInt32& nBgFileOffset, sal_Bool bForce )
3227 SdrObject* pRet = NULL;
3228 sal_Bool bCreateObj = bForce;
3229 SfxItemSet* pSet = NULL;
3230 ULONG nFPosMerk = rStCtrl.Tell(); // FilePos merken fuer spaetere Restauration
3231 DffRecordHeader aPageHd;
3232 if ( SeekToAktPage( &aPageHd ) )
3233 { // und nun die Hintergrundattribute der Page suchen
3234 ULONG nPageRecEnd = aPageHd.GetRecEndFilePos();
3235 DffRecordHeader aPPDrawHd;
3236 if ( SeekToRec( rStCtrl, PPT_PST_PPDrawing, nPageRecEnd, &aPPDrawHd ) )
3238 ULONG nPPDrawEnd = aPPDrawHd.GetRecEndFilePos();
3239 DffRecordHeader aEscherF002Hd;
3240 if ( SeekToRec( rStCtrl, DFF_msofbtDgContainer, nPPDrawEnd, &aEscherF002Hd ) )
3242 ULONG nEscherF002End = aEscherF002Hd.GetRecEndFilePos();
3243 DffRecordHeader aEscherObjectHd;
3244 if ( SeekToRec( rStCtrl, DFF_msofbtSpContainer, nEscherF002End, &aEscherObjectHd ) )
3246 nBgFileOffset = aEscherObjectHd.GetRecBegFilePos();
3247 //ULONG nEscherObjectEnd = aEscherObjectHd.GetRecEndFilePos();
3248 //DffRecordHeader aEscherPropertiesHd;
3249 if ( SeekToRec( rStCtrl, DFF_msofbtOPT,nEscherF002End ) )
3251 rStCtrl >> (DffPropertyReader&)*this;
3252 mnFix16Angle = Fix16ToAngle( GetPropertyValue( DFF_Prop_Rotation, 0 ) );
3253 UINT32 nColor = GetPropertyValue( DFF_Prop_fillColor, 0xffffff );
3254 pSet = new SfxItemSet( pSdrModel->GetItemPool() );
3255 DffObjData aObjData( aEscherObjectHd, Rectangle( 0, 0, 28000, 21000 ), 0 );
3256 ApplyAttributes( rStCtrl, *pSet, aObjData );
3257 Color aColor( MSO_CLR_ToColor( nColor ) );
3258 pSet->Put( XFillColorItem( String(), aColor ) );
3264 rStCtrl.Seek( nFPosMerk ); // FilePos restaurieren
3265 if ( bCreateObj )
3267 if ( !pSet )
3269 pSet = new SfxItemSet( pSdrModel->GetItemPool() );
3270 pSet->Put( XFillStyleItem( XFILL_NONE ) );
3272 pSet->Put( XLineStyleItem( XLINE_NONE ) );
3273 Rectangle aRect( rPage.GetLftBorder(), rPage.GetUppBorder(), rPage.GetWdt()-rPage.GetRgtBorder(), rPage.GetHgt()-rPage.GetLwrBorder() );
3274 pRet = new SdrRectObj( aRect );
3275 pRet->SetModel( pSdrModel );
3277 pRet->SetMergedItemSet(*pSet);
3279 pRet->SetMarkProtect( TRUE );
3280 pRet->SetMoveProtect( TRUE );
3281 pRet->SetResizeProtect( TRUE );
3283 delete pSet;
3284 return pRet;
3287 ////////////////////////////////////////////////////////////////////////////////////////////////////
3289 HeaderFooterEntry::HeaderFooterEntry( const PptSlidePersistEntry* pMPE ) :
3290 pMasterPersist ( pMPE ),
3291 nAtom ( 0 )
3293 if ( pMPE )
3295 HeaderFooterEntry* pMHFE = pMPE->pHeaderFooterEntry;
3296 if ( pMHFE )
3298 nAtom = pMPE->pHeaderFooterEntry->nAtom;
3299 pPlaceholder[ 0 ] = pMHFE->pPlaceholder[ 0 ];
3300 pPlaceholder[ 1 ] = pMHFE->pPlaceholder[ 1 ];
3301 pPlaceholder[ 2 ] = pMHFE->pPlaceholder[ 2 ];
3302 pPlaceholder[ 3 ] = pMHFE->pPlaceholder[ 3 ];
3307 HeaderFooterEntry::~HeaderFooterEntry()
3311 UINT32 HeaderFooterEntry::GetMaskForInstance( UINT32 nInstance )
3313 UINT32 nRet = 0;
3314 switch ( nInstance )
3316 case 0 : nRet = 0x07ffff; break;
3317 case 1 : nRet = 0x100000; break;
3318 case 2 : nRet = 0x200000; break;
3319 case 3 : nRet = 0x080000; break;
3321 return nRet;
3324 UINT32 HeaderFooterEntry::IsToDisplay( UINT32 nInstance )
3326 UINT32 nMask = 0;
3327 switch ( nInstance )
3329 case 0 : nMask = 0x010000; break;
3330 case 1 : nMask = 0x100000; break;
3331 case 2 : nMask = 0x200000; break;
3332 case 3 : nMask = 0x080000; break;
3334 return ( nAtom & nMask );
3337 // The following method checks if the slide is using a different colorscheme than
3338 // its master, if this is the fact, then the HeaderFooter must probably be
3339 // imported as real sdrobject. In this case, the return value is the offset to the
3340 // master header footer object, so it can be re-loaded with a different color set
3341 sal_uInt32 HeaderFooterEntry::NeedToImportInstance( const sal_uInt32 nInstance, const PptSlidePersistEntry& rSlidePersist )
3343 sal_uInt32 nRet = 0;
3344 if ( pMasterPersist )
3346 if ( !( rSlidePersist.aSlideAtom.nFlags & 2 ) )
3347 { // not following the master persist, so we have to check if the colors are changed
3348 if ( memcmp( &rSlidePersist.aColorScheme, &pMasterPersist->aColorScheme, 32 ) )
3350 nRet = pMasterPersist->HeaderFooterOfs[ nInstance ];
3354 return nRet;
3357 void SdrEscherImport::ImportHeaderFooterContainer( DffRecordHeader& rHd, HeaderFooterEntry& rE )
3359 rHd.SeekToContent( rStCtrl );
3360 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < rHd.GetRecEndFilePos() ) )
3362 DffRecordHeader aHd;
3363 rStCtrl >> aHd;
3364 switch ( aHd.nRecType )
3366 case PPT_PST_HeadersFootersAtom :
3367 rStCtrl >> rE.nAtom;
3368 break;
3370 case PPT_PST_CString :
3372 if ( aHd.nRecInstance < 4 )
3373 MSDFFReadZString( rStCtrl, rE.pPlaceholder[ aHd.nRecInstance ], aHd.nRecLen, TRUE );
3375 break;
3377 aHd.SeekToEndOfRecord( rStCtrl );
3381 //static sal_Unicode PPTExportMapper( sal_Unicode nUni, BOOL& bNeedsStarBats )
3383 // bNeedsStarBats = FALSE;
3385 // sal_Unicode cLo, cReplace;
3386 // cLo = cReplace = 0;
3387 // switch ( nUni )
3388 // {
3389 // case 132 : cLo = 175; break;
3390 // case 147 : cLo = 174; break;
3391 // // Currency
3392 // case 0x00A2: cReplace = 224; break;
3393 // case 0x00A4: cReplace = 225; break;
3394 // case 0x00A5: cReplace = 226; break;
3395 // case 0x20A1: cReplace = 228; break;
3396 // case 0x20A2: cReplace = 229; break;
3397 // case 0x20A3: cReplace = 230; break;
3398 // case 0x20A4: cReplace = 231; break;
3399 // case 0x20A7: cReplace = 227; break;
3400 // case 0x20A8: cReplace = 234; break;
3401 // case 0x20A9: cReplace = 232; break;
3402 // case 0x20AB: cReplace = 233; break;
3403 // case 0x20AC: cReplace = 128; break;
3404 // // Punctuation and other
3405 // case 0x201A: cReplace = 130; break; // SINGLE LOW-9 QUOTATION MARK
3406 // case 0x0192: cReplace = 131; break; // LATIN SMALL LETTER F WITH HOOK
3407 // case 0x201E: // DOUBLE LOW-9 QUOTATION MARK
3408 // case 0x301F: // LOW DOUBLE PRIME QUOTATION MARK
3409 // cReplace = 132; break;
3410 // case 0x2026: cReplace = 133; break; // HORIZONTAL ELLIPSES
3411 // case 0x2020: cReplace = 134; break; // DAGGER
3412 // case 0x2021: cReplace = 135; break; // DOUBLE DAGGER
3413 // case 0x02C6: cReplace = 136; break; // MODIFIER LETTER CIRCUMFLEX ACCENT
3414 // case 0x2030: cReplace = 137; break; // PER MILLE SIGN
3415 // case 0x0160: cReplace = 138; break; // LATIN CAPITAL LETTER S WITH CARON
3416 // case 0x2039: cReplace = 139; break; // SINGLE LEFT-POINTING ANGLE QUOTATION MARK
3417 // case 0x0152: cReplace = 140; break; // LATIN CAPITAL LIGATURE OE
3418 // case 0x017D: cReplace = 142; break; // LATIN CAPITAL LETTER Z WITH CARON
3419 // case 0x2018: // LEFT SINGLE QUOTATION MARK
3420 // case 0x02BB: // MODIFIER LETTER TURNED COMMA
3421 // cReplace = 145; break;
3422 // case 0x2019: // RIGHT SINGLE QUOTATION MARK
3423 // case 0x02BC: // MODIFIER LETTER APOSTROPHE
3424 // cReplace = 146; break;
3425 // case 0x201C: // LEFT DOUBLE QUOTATION MARK
3426 // case 0x301D: // REVERSED DOUBLE PRIME QUOTATION MARK
3427 // cReplace = 147; break;
3428 // case 0x201D: // RIGHT DOUBLE QUOTATION MARK
3429 // case 0x301E: // REVERSED DOUBLE PRIME QUOTATION MARK
3430 // cReplace = 148; break;
3431 // case 0x2022: cReplace = 149; break; // BULLET
3432 // case 0x2013: cReplace = 150; break; // EN DASH
3433 // case 0x2014: cReplace = 151; break; // EM DASH
3434 // case 0x02DC: cReplace = 152; break; // SMALL TILDE
3435 // case 0x2122: cReplace = 153; break; // TRADE MARK SIGN
3436 // case 0x0161: cReplace = 154; break; // LATIN SMALL LETTER S WITH CARON
3437 // case 0x203A: cReplace = 155; break; // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
3438 // case 0x0153: cReplace = 156; break; // LATIN SMALL LIGATURE OE
3439 // case 0x017E: cReplace = 158; break; // LATIN SMALL LETTER Z WITH CARON
3440 // case 0x0178: cReplace = 159; break; // LATIN CAPITAL LETTER Y WITH DIAERESIS
3441 // case 0x00B6: cReplace = 222; break; // PILCROW SIGN / PARAGRAPH SIGN
3442 // }
3443 // if ( cReplace )
3444 // {
3445 // bNeedsStarBats = TRUE;
3446 // return cReplace;
3447 // }
3448 // else
3449 // return cLo;
3452 // no longer needed
3453 sal_Unicode SdrPowerPointImport::PPTSubstitute( UINT16 /*nFont*/, sal_Unicode /*nChar*/,
3454 UINT32& /*nMappedFontId*/, Font& /*rFont*/, char /*nDefault*/) const
3456 return 0;
3459 ////////////////////////////////////////////////////////////////////////////////////////////////////
3461 PPTBuGraEntry::PPTBuGraEntry( Graphic& rGraphic, UINT32 nInst ) :
3462 nInstance ( nInst ),
3463 aBuGra ( rGraphic ) {}
3465 PPTExtParaLevel::PPTExtParaLevel()
3466 : mnExtParagraphMask( 0 )
3467 , mnBuBlip( 0xffff )
3468 , mnHasAnm( 0 )
3469 , mnAnmScheme( 0 )
3470 , mpfPP10Ext( 0 )
3471 , mnExtCharacterMask( 0 )
3472 , mcfPP10Ext( 0 )
3473 , mbSet( sal_False )
3476 SvStream& operator>>( SvStream& rIn, PPTExtParaLevel& rLevel )
3478 rLevel.mbSet = TRUE;
3479 rIn >> rLevel.mnExtParagraphMask;
3480 if ( rLevel.mnExtParagraphMask & 0x00800000 )
3481 rIn >> rLevel.mnBuBlip;
3482 if ( rLevel.mnExtParagraphMask & 0x02000000 )
3483 rIn >> rLevel.mnHasAnm;
3484 if ( rLevel.mnExtParagraphMask & 0x01000000 )
3485 rIn >> rLevel.mnAnmScheme;
3486 if ( rLevel.mnExtParagraphMask & 0x04000000 )
3487 rIn >> rLevel.mpfPP10Ext;
3488 rIn >> rLevel.mnExtCharacterMask;
3489 if ( rLevel.mnExtCharacterMask & 0x100000 )
3490 rIn >> rLevel.mcfPP10Ext;
3491 return rIn;
3494 BOOL PPTExtParaProv::GetGraphic( UINT32 nInstance, Graphic& rGraph ) const
3496 BOOL bRetValue = FALSE;
3497 PPTBuGraEntry* pPtr = NULL;
3498 if ( nInstance < aBuGraList.Count() )
3500 pPtr = (PPTBuGraEntry*)aBuGraList.GetObject( nInstance );
3501 if ( pPtr->nInstance == nInstance )
3502 bRetValue = TRUE;
3504 if ( !bRetValue )
3506 sal_uInt32 i;
3507 for ( i = 0; i < aBuGraList.Count(); i++ )
3509 pPtr = (PPTBuGraEntry*)aBuGraList.GetObject( i );
3510 if ( pPtr->nInstance == nInstance )
3512 bRetValue = TRUE;
3513 break;
3517 if ( bRetValue )
3518 rGraph = pPtr->aBuGra;
3519 return bRetValue;
3522 PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const DffRecordHeader* pHd ) :
3523 bStyles ( FALSE ),
3524 bGraphics ( FALSE )
3526 UINT32 nOldPos = rSt.Tell();
3528 // here we have to get the graphical bullets...
3530 DffRecordHeader aHd;
3531 DffRecordHeader aContentDataHd;
3533 const DffRecordHeader* pListHd = rMan.aDocRecManager.GetRecordHeader( PPT_PST_List, SEEK_FROM_BEGINNING );
3534 while( pListHd )
3536 pListHd->SeekToContent( rSt );
3537 if ( !rMan.SeekToContentOfProgTag( 9, rSt, *pListHd, aContentDataHd ) )
3538 break;
3539 while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aContentDataHd.GetRecEndFilePos() ) )
3541 rSt >> aHd;
3542 switch ( aHd.nRecType )
3544 case PPT_PST_ExtendedBuGraContainer :
3546 while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aHd.GetRecEndFilePos() ) )
3548 UINT16 nType;
3549 DffRecordHeader aBuGraAtomHd;
3550 rSt >> aBuGraAtomHd;
3551 if ( aBuGraAtomHd.nRecType == PPT_PST_ExtendedBuGraAtom )
3553 rSt >> nType;
3554 Graphic aGraphic;
3555 if ( rMan.GetBLIPDirect( rSt, aGraphic, NULL ) )
3557 UINT32 nInstance = aBuGraAtomHd.nRecInstance;
3558 PPTBuGraEntry* pBuGra = new PPTBuGraEntry( aGraphic, nInstance );
3559 UINT32 n = 0;
3560 UINT32 nBuGraCount = aBuGraList.Count();
3561 if ( nBuGraCount )
3563 if ( ( (PPTBuGraEntry*)aBuGraList.GetObject( nBuGraCount - 1 ) )->nInstance < nInstance )
3564 n = nBuGraCount;
3565 else
3566 { // maybe the instances are not sorted, we sort it
3567 for ( n = 0; n < nBuGraCount; n++ )
3568 { // sorting fields ( hi >> lo )
3569 if ( ( (PPTBuGraEntry*)aBuGraList.GetObject( n ) )->nInstance < nInstance )
3570 break;
3574 aBuGraList.Insert( pBuGra, (UINT32)n );
3576 #ifdef DBG_UTIL
3577 else DBG_ERROR( "PPTExParaProv::PPTExParaProv - bullet graphic is not valid (SJ)" );
3578 #endif
3580 #ifdef DBG_UTIL
3581 else DBG_ERROR( "PPTExParaProv::PPTExParaProv - unknown atom interpreting the PPT_PST_ExtendedBuGraContainer (SJ)" );
3582 #endif
3583 aBuGraAtomHd.SeekToEndOfRecord( rSt );
3585 if ( aBuGraList.Count() )
3586 bGraphics = TRUE;
3588 break;
3590 case PPT_PST_ExtendedPresRuleContainer :
3591 aExtendedPresRules.Consume( rSt, FALSE, aHd.GetRecEndFilePos() );
3592 break;
3593 #ifdef DBG_UTIL
3594 default :
3595 DBG_ERROR( "PPTExParaProv::PPTExParaProv - unknown atom reading ppt2000 num rules (SJ)" );
3596 case PPT_PST_MasterText : // first seen in: ms-tt02.ppt
3597 case PPT_PST_SrKinsoku :
3598 case PPT_PST_NewlyAddedAtom4016 :
3599 case PPT_PST_NewlyAddedAtomByPPT2000_6010 :
3600 case PPT_PST_NewlyAddedAtomByPPT2000_6011 :
3601 case PPT_PST_NewlyAddedAtomByXP1037 :
3602 case PPT_PST_NewlyAddedAtomByXP12004 :
3603 case PPT_PST_NewlyAddedAtomByXP14001 :
3604 break;
3605 #endif
3607 aHd.SeekToEndOfRecord( rSt );
3609 break;
3612 while( pHd )
3613 { // get the extended paragraph styles on mainmaster ( graphical bullets, num ruling ... )
3614 if ( !rMan.SeekToContentOfProgTag( 9, rSt, *pHd, aContentDataHd ) )
3615 break;
3616 while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aContentDataHd.GetRecEndFilePos() ) )
3618 rSt >> aHd;
3619 switch ( aHd.nRecType )
3621 case PPT_PST_ExtendedParagraphMasterAtom :
3623 if ( aHd.nRecInstance < PPT_STYLESHEETENTRYS )
3625 UINT16 nDepth, i = 0;
3626 rSt >> nDepth;
3627 if ( i <= 5 )
3630 while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aHd.GetRecEndFilePos() ) && ( i < nDepth ) )
3632 bStyles = TRUE;
3633 rSt >> aExtParaSheet[ aHd.nRecInstance ].aExtParaLevel[ i++ ];
3635 #ifdef DBG_UTIL
3636 if ( rSt.Tell() != aHd.GetRecEndFilePos() )
3637 DBG_ERROR( "PPTExParaProv::PPTExParaProv - error reading PPT_PST_ExtendedParagraphMasterAtom (SJ)" );
3638 #endif
3640 #ifdef DBG_UTIL
3641 else DBG_ERROR( "PPTExParaProv::PPTExParaProv - depth is greater than 5 (SJ)" );
3642 #endif
3644 #ifdef DBG_UTIL
3645 else DBG_ERROR( "PPTExParaProv::PPTExParaProv - instance out of range (SJ)" );
3646 #endif
3648 break;
3649 default :
3650 DBG_ERROR( "PPTExParaProv::PPTExParaProv - unknown atom, assuming PPT_PST_ExtendedParagraphMasterAtom (SJ)" );
3651 case PPT_PST_NewlyAddedAtomByXP11008 :
3652 case PPT_PST_NewlyAddedAtomByXP11010 :
3653 case PPT_PST_NewlyAddedAtomByXP12010 :
3654 case PPT_PST_NewlyAddedAtomByXP12011 :
3655 case 0xf144 :
3656 break;
3658 aHd.SeekToEndOfRecord( rSt );
3660 break;
3662 rSt.Seek( nOldPos );
3665 PPTExtParaProv::~PPTExtParaProv()
3667 void* pPtr;
3668 for ( pPtr = aBuGraList.First(); pPtr; pPtr = aBuGraList.Next() )
3669 delete (PPTBuGraEntry*)pPtr;
3672 ////////////////////////////////////////////////////////////////////////////////////////////////////
3674 PPTNumberFormatCreator::PPTNumberFormatCreator( PPTExtParaProv* pParaProv ) :
3675 pExtParaProv ( pParaProv )
3679 PPTNumberFormatCreator::~PPTNumberFormatCreator()
3681 delete pExtParaProv;
3684 BOOL PPTNumberFormatCreator::ImplGetExtNumberFormat( SdrPowerPointImport& rManager,
3685 SvxNumberFormat& rNumberFormat, UINT32 nLevel, UINT32 nInstance, UINT32 nDestinationInstance,
3686 boost::optional< sal_Int16 >& rStartNumbering, UINT32 nFontHeight, PPTParagraphObj* pPara )
3688 BOOL bHardAttribute = ( nDestinationInstance == 0xffffffff );
3690 UINT32 nBuFlags = 0;
3691 UINT16 nHasAnm = 0;
3692 UINT32 nAnmScheme = 0x10003;
3693 UINT16 nBuBlip = 0xffff;
3695 const PPTExtParaProv* pParaProv = pExtParaProv;
3696 if ( !pExtParaProv )
3697 pParaProv = ( pPara ) ? pPara->mrStyleSheet.pExtParaProv
3698 : rManager.pPPTStyleSheet->pExtParaProv;
3699 if ( pPara )
3701 nBuFlags = pPara->pParaSet->mnExtParagraphMask;
3702 if ( nBuFlags )
3704 if ( nBuFlags & 0x00800000 )
3705 nBuBlip = pPara->pParaSet->mnBuBlip;
3706 if ( nBuFlags & 0x01000000 )
3707 nAnmScheme = pPara->pParaSet->mnAnmScheme;
3708 if ( nBuFlags & 0x02000000 )
3709 nHasAnm = pPara->pParaSet->mnHasAnm;
3710 bHardAttribute = TRUE;
3714 if ( ( nBuFlags & 0x03800000 ) != 0x03800000 ) // merge style sheet
3715 { // we have to read the master attributes
3716 if ( pParaProv && ( nLevel < 5 ) )
3718 if ( pParaProv->bStyles )
3720 const PPTExtParaLevel& rLev = pParaProv->aExtParaSheet[ nInstance ].aExtParaLevel[ nLevel ];
3721 if ( rLev.mbSet )
3723 UINT32 nMaBuFlags = rLev.mnExtParagraphMask;
3725 if ( (!( nBuFlags & 0x00800000)) && ( nMaBuFlags & 0x00800000 ) )
3727 if (!( nBuFlags & 0x02000000)) // if there is a BuStart without BuInstance,
3728 nBuBlip = rLev.mnBuBlip; // then there is no graphical Bullet possible
3730 if ( (!( nBuFlags & 0x01000000)) && ( nMaBuFlags & 0x01000000 ) )
3731 nAnmScheme = rLev.mnAnmScheme;
3732 if ( (!( nBuFlags & 0x02000000)) && ( nMaBuFlags & 0x02000000 ) )
3733 nHasAnm = rLev.mnHasAnm;
3734 nBuFlags |= nMaBuFlags;
3739 if ( nBuBlip != 0xffff ) // set graphical bullet
3741 Graphic aGraphic;
3742 if ( pParaProv->GetGraphic( nBuBlip, aGraphic ) )
3744 SvxBrushItem aBrush( aGraphic, GPOS_MM, SID_ATTR_BRUSH );
3745 rNumberFormat.SetGraphicBrush( &aBrush );
3746 sal_uInt32 nHeight = (sal_uInt32)( (double)nFontHeight * 0.2540 * nBulletHeight + 0.5 );
3747 Size aPrefSize( aGraphic.GetPrefSize() );
3748 UINT32 nWidth = ( nHeight * aPrefSize.Width() ) / aPrefSize.Height();
3749 rNumberFormat.SetGraphicSize( Size( nWidth, nHeight ) );
3750 rNumberFormat.SetNumberingType ( SVX_NUM_BITMAP );
3753 else if ( nHasAnm )
3755 switch( static_cast< sal_uInt16 >( nAnmScheme ) )
3757 default :
3758 case 0 :
3760 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER );
3761 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3763 break;
3764 case 1 :
3766 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER );
3767 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3769 break;
3770 case 2 :
3772 rNumberFormat.SetNumberingType( SVX_NUM_ARABIC );
3773 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3775 break;
3776 case 3 :
3778 rNumberFormat.SetNumberingType( SVX_NUM_ARABIC );
3779 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3781 break;
3782 case 4 :
3784 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_LOWER );
3785 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3786 rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3788 break;
3789 case 5 :
3791 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_LOWER );
3792 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3794 break;
3795 case 6 :
3797 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_LOWER );
3798 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3800 break;
3801 case 7 :
3803 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_UPPER );
3804 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3806 break;
3807 case 8 :
3809 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER );
3810 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3811 rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3813 break;
3814 case 9 :
3816 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER );
3817 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3819 break;
3820 case 10 :
3822 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER );
3823 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3824 rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3826 break;
3827 case 11 :
3829 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER );
3830 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3832 break;
3833 case 12 :
3835 rNumberFormat.SetNumberingType( SVX_NUM_ARABIC );
3836 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3837 rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3839 break;
3840 case 13 :
3842 rNumberFormat.SetNumberingType( SVX_NUM_ARABIC );
3844 break;
3845 case 14 :
3847 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_UPPER );
3848 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3849 rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3851 break;
3852 case 15 :
3854 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_UPPER );
3855 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3857 break;
3859 rStartNumbering = boost::optional< sal_Int16 >( nAnmScheme >> 16 );
3861 return bHardAttribute;
3864 void PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport& rManager, SvxNumberFormat& rNumberFormat, UINT32 nLevel, const PPTParaLevel& rParaLevel, const PPTCharLevel& rCharLevel, UINT32 nInstance )
3866 nIsBullet = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BulletOn ) ) != 0 ? 1 : 0;
3867 nBulletChar = rParaLevel.mnBulletChar;
3869 sal_Bool bBuHardFont;
3870 bBuHardFont = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardFont ) ) != 0;
3871 if ( bBuHardFont )
3872 nBulletFont = rParaLevel.mnBulletFont;
3873 else
3874 nBulletFont = rCharLevel.mnFont;
3875 nBulletHeight = rParaLevel.mnBulletHeight;
3876 nBulletColor = rParaLevel.mnBulletColor;
3877 nTextOfs = rParaLevel.mnTextOfs;
3878 nBulletOfs = rParaLevel.mnBulletOfs;
3880 boost::optional< sal_Int16 > oStartNumbering;
3881 ImplGetExtNumberFormat( rManager, rNumberFormat, nLevel, nInstance, 0xffffffff, oStartNumbering, rCharLevel.mnFontHeight, NULL );
3882 if ( ( rNumberFormat.GetNumberingType() != SVX_NUM_BITMAP ) && ( nBulletHeight > 0x7fff ) )
3883 nBulletHeight = rCharLevel.mnFontHeight ? ((-((sal_Int16)nBulletHeight)) * 100 ) / rCharLevel.mnFontHeight : 100;
3884 ImplGetNumberFormat( rManager, rNumberFormat, nLevel );
3885 switch ( rNumberFormat.GetNumberingType() )
3887 case SVX_NUM_CHARS_UPPER_LETTER :
3888 case SVX_NUM_CHARS_LOWER_LETTER :
3889 case SVX_NUM_ROMAN_UPPER :
3890 case SVX_NUM_ROMAN_LOWER :
3891 case SVX_NUM_ARABIC :
3892 case SVX_NUM_CHARS_UPPER_LETTER_N :
3893 case SVX_NUM_CHARS_LOWER_LETTER_N :
3895 sal_uInt32 nFont = rCharLevel.mnFont;
3896 PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nFont );
3897 if ( pFontEnityAtom )
3899 Font aFont;
3900 aFont.SetCharSet( pFontEnityAtom->eCharSet );
3901 aFont.SetName( pFontEnityAtom->aName );
3902 aFont.SetFamily( pFontEnityAtom->eFamily );
3903 aFont.SetPitch( pFontEnityAtom->ePitch );
3904 rNumberFormat.SetBulletFont( &aFont );
3907 break;
3911 BOOL PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport& rManager, SvxNumberFormat& rNumberFormat, PPTParagraphObj* pParaObj,
3912 UINT32 nDestinationInstance, boost::optional< sal_Int16 >& rStartNumbering )
3914 UINT32 nHardCount = 0;
3915 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletOn, nIsBullet, nDestinationInstance );
3916 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletChar, nBulletChar, nDestinationInstance );
3917 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletFont, nBulletFont, nDestinationInstance );
3918 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletHeight, nBulletHeight, nDestinationInstance );
3919 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletColor, nBulletColor, nDestinationInstance );
3920 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_TextOfs, nTextOfs, nDestinationInstance );
3921 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletOfs, nBulletOfs, nDestinationInstance );
3923 if ( nIsBullet )
3924 rNumberFormat.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
3926 UINT32 nFontHeight = 24;
3927 PPTPortionObj* pPtr = pParaObj->First();
3928 if ( pPtr )
3929 pPtr->GetAttrib( PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance );
3930 if ( nIsBullet )
3931 nHardCount += ImplGetExtNumberFormat( rManager, rNumberFormat, pParaObj->pParaSet->mnDepth,
3932 pParaObj->mnInstance, nDestinationInstance, rStartNumbering, nFontHeight, pParaObj );
3934 if ( rNumberFormat.GetNumberingType() != SVX_NUM_BITMAP )
3935 pParaObj->UpdateBulletRelSize( nBulletHeight );
3936 if ( nHardCount )
3937 ImplGetNumberFormat( rManager, rNumberFormat, pParaObj->pParaSet->mnDepth );
3939 if ( nHardCount )
3941 switch ( rNumberFormat.GetNumberingType() )
3943 case SVX_NUM_CHARS_UPPER_LETTER :
3944 case SVX_NUM_CHARS_LOWER_LETTER :
3945 case SVX_NUM_ROMAN_UPPER :
3946 case SVX_NUM_ROMAN_LOWER :
3947 case SVX_NUM_ARABIC :
3948 case SVX_NUM_CHARS_UPPER_LETTER_N :
3949 case SVX_NUM_CHARS_LOWER_LETTER_N :
3951 if ( pPtr )
3953 sal_uInt32 nFont;
3954 pPtr->GetAttrib( PPT_CharAttr_Font, nFont, nDestinationInstance );
3955 PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nFont );
3956 if ( pFontEnityAtom )
3958 Font aFont;
3959 aFont.SetCharSet( pFontEnityAtom->eCharSet );
3960 aFont.SetName( pFontEnityAtom->aName );
3961 aFont.SetFamily( pFontEnityAtom->eFamily );
3962 aFont.SetPitch( pFontEnityAtom->ePitch );
3963 rNumberFormat.SetBulletFont( &aFont );
3967 break;
3970 return ( nHardCount ) ? TRUE : FALSE;
3973 void PPTNumberFormatCreator::ImplGetNumberFormat( SdrPowerPointImport& rManager, SvxNumberFormat& rNumberFormat, UINT32 /*nLevel*/)
3975 Font aFont;
3976 PptFontEntityAtom* pAtom = rManager.GetFontEnityAtom( nBulletFont );
3977 if ( pAtom )
3979 CharSet eCharSet( pAtom->eCharSet );
3980 aFont.SetName( pAtom->aName );
3981 aFont.SetCharSet( eCharSet );
3982 aFont.SetFamily( pAtom->eFamily );
3983 aFont.SetPitch( pAtom->ePitch );
3985 Color aCol( rManager.MSO_CLR_ToColor( nBulletColor ) );
3986 aFont.SetColor( aCol );
3988 sal_uInt16 nBuChar = (sal_uInt16)nBulletChar;
3989 if ( aFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL )
3991 nBuChar &= 0x00ff;
3992 nBuChar |= 0xf000;
3994 rNumberFormat.SetBulletFont( &aFont );
3995 rNumberFormat.SetBulletChar( nBuChar );
3996 rNumberFormat.SetBulletRelSize( (UINT16)nBulletHeight );
3997 rNumberFormat.SetBulletColor( aCol );
3998 UINT16 nAbsLSpace = (UINT16)( ( (UINT32)nTextOfs * 2540 ) / 576 );
3999 UINT16 nFirstLineOffset = nAbsLSpace - (UINT16)( ( (UINT32)nBulletOfs * 2540 ) / 576 );
4000 rNumberFormat.SetAbsLSpace( nAbsLSpace );
4001 rNumberFormat.SetFirstLineOffset( -nFirstLineOffset );
4004 ////////////////////////////////////////////////////////////////////////////////////////////////////
4006 PPTCharSheet::PPTCharSheet( UINT32 nInstance )
4008 UINT32 nColor = PPT_COLSCHEME_TEXT_UND_ZEILEN;
4009 UINT16 nFontHeight(0);
4010 switch ( nInstance )
4012 case TSS_TYPE_PAGETITLE :
4013 case TSS_TYPE_TITLE :
4015 nColor = PPT_COLSCHEME_TITELTEXT;
4016 nFontHeight = 44;
4018 break;
4019 case TSS_TYPE_BODY :
4020 case TSS_TYPE_SUBTITLE :
4021 case TSS_TYPE_HALFBODY :
4022 case TSS_TYPE_QUARTERBODY :
4023 nFontHeight = 32;
4024 break;
4025 case TSS_TYPE_NOTES :
4026 nFontHeight = 12;
4027 break;
4028 case TSS_TYPE_UNUSED :
4029 case TSS_TYPE_TEXT_IN_SHAPE :
4030 nFontHeight = 24;
4031 break;
4033 for ( UINT32 nDepth = 0; nDepth < 5; nDepth++ )
4035 maCharLevel[ nDepth ].mnFlags = 0;
4036 maCharLevel[ nDepth ].mnFont = 0;
4037 maCharLevel[ nDepth ].mnAsianOrComplexFont = 0xffff;
4038 maCharLevel[ nDepth ].mnFontHeight = nFontHeight;
4039 maCharLevel[ nDepth ].mnFontColor = nColor;
4040 maCharLevel[ nDepth ].mnFontColorInStyleSheet = Color( (BYTE)nColor, (BYTE)( nColor >> 8 ), (BYTE)( nColor >> 16 ) );
4041 maCharLevel[ nDepth ].mnEscapement = 0;
4045 PPTCharSheet::PPTCharSheet( const PPTCharSheet& rAttr )
4047 *this = rAttr;
4050 void PPTCharSheet::Read( SvStream& rIn, sal_Bool /*bMasterStyle*/, sal_uInt32 nLevel, sal_Bool /*bFirst*/)
4052 // Zeichenattribute
4053 sal_uInt32 nCMask;
4054 sal_uInt16 nVal16;
4055 rIn >> nCMask;
4057 if ( nCMask & 0x0000FFFF )
4059 sal_uInt16 nBitAttr;
4060 maCharLevel[ nLevel ].mnFlags &= ~( (sal_uInt16)nCMask );
4061 rIn >> nBitAttr; // Bit-Attribute (Fett, Unterstrichen, ...)
4062 maCharLevel[ nLevel ].mnFlags |= nBitAttr;
4064 if ( nCMask & ( 1 << PPT_CharAttr_Font ) ) // 0x00010000
4065 rIn >> maCharLevel[ nLevel ].mnFont;
4066 if ( nCMask & ( 1 << PPT_CharAttr_AsianOrComplexFont ) ) // 0x00200000
4067 rIn >> maCharLevel[ nLevel ].mnAsianOrComplexFont;
4068 if ( nCMask & ( 1 << PPT_CharAttr_ANSITypeface ) ) // 0x00400000
4069 rIn >> nVal16;
4070 if ( nCMask & ( 1 << PPT_CharAttr_Symbol ) ) // 0x00800000
4071 rIn >> nVal16;
4072 if ( nCMask & ( 1 << PPT_CharAttr_FontHeight ) ) // 0x00020000
4073 rIn >> maCharLevel[ nLevel ].mnFontHeight;
4074 if ( nCMask & ( 1 << PPT_CharAttr_FontColor ) ) // 0x00040000
4076 rIn >> maCharLevel[ nLevel ].mnFontColor;
4077 if( ! (maCharLevel[ nLevel ].mnFontColor & 0xff000000 ) )
4078 maCharLevel[ nLevel ].mnFontColor = PPT_COLSCHEME_HINTERGRUND;
4080 if ( nCMask & ( 1 << PPT_CharAttr_Escapement ) ) // 0x00080000
4081 rIn >> maCharLevel[ nLevel ].mnEscapement;
4082 if ( nCMask & 0x00100000 ) // 0x00100000
4083 rIn >> nVal16;
4085 nCMask >>= 24;
4086 while( nCMask )
4088 if ( nCMask & 1 )
4090 DBG_ERROR( "PPTCharSheet::Read - unknown attribute, send me this document (SJ)" );
4091 rIn >> nVal16;
4093 nCMask >>= 1;
4097 PPTParaSheet::PPTParaSheet( UINT32 nInstance )
4099 sal_uInt16 nBuFlags = 0;
4100 sal_uInt32 nBulletColor = 0x8000000;
4101 sal_uInt16 nUpperDist = 0;
4103 switch ( nInstance )
4105 case TSS_TYPE_PAGETITLE :
4106 case TSS_TYPE_TITLE :
4107 nBulletColor = PPT_COLSCHEME_TITELTEXT;
4108 break;
4109 case TSS_TYPE_BODY :
4110 case TSS_TYPE_SUBTITLE :
4111 case TSS_TYPE_HALFBODY :
4112 case TSS_TYPE_QUARTERBODY :
4114 nBuFlags = 1;
4115 nUpperDist = 0x14;
4117 break;
4118 case TSS_TYPE_NOTES :
4119 nUpperDist = 0x1e;
4120 break;
4122 default :
4123 case TSS_TYPE_UNUSED :
4124 case TSS_TYPE_TEXT_IN_SHAPE :
4125 break;
4128 for ( UINT32 i = 0; i < 5; i++ )
4130 maParaLevel[ i ].mnBuFlags = nBuFlags;
4131 maParaLevel[ i ].mnBulletChar = 0x2022;
4132 maParaLevel[ i ].mnBulletFont = 0;
4133 maParaLevel[ i ].mnBulletHeight = 100;
4134 maParaLevel[ i ].mnBulletColor = nBulletColor;
4135 maParaLevel[ i ].mnAdjust = 0;
4136 maParaLevel[ i ].mnLineFeed = 100;
4137 maParaLevel[ i ].mnLowerDist = 0;
4138 maParaLevel[ i ].mnUpperDist = nUpperDist;
4139 maParaLevel[ i ].mnTextOfs = 0;
4140 maParaLevel[ i ].mnBulletOfs = 0;
4141 maParaLevel[ i ].mnDefaultTab = 0x240;
4142 maParaLevel[ i ].mnAsianLineBreak = 0;
4143 maParaLevel[ i ].mnBiDi = 0;
4147 PPTParaSheet::PPTParaSheet( const PPTParaSheet& rSheet )
4149 *this = rSheet;
4152 void PPTParaSheet::Read( SdrPowerPointImport&
4153 #ifdef DBG_UTIL
4154 rManager
4155 #endif
4156 , SvStream& rIn, sal_Bool /*bMasterStyle*/,
4157 sal_uInt32 nLevel, sal_Bool bFirst )
4159 // Absatzattribute
4160 sal_uInt16 nVal16, i, nMask16;
4161 sal_uInt32 nVal32, nPMask;
4162 rIn >> nPMask;
4164 nMask16 = (sal_uInt16)nPMask & 0xf;
4165 if ( nMask16 )
4167 rIn >> nVal16;
4168 maParaLevel[ nLevel ].mnBuFlags &=~ nMask16;
4169 nVal16 &= nMask16;
4170 maParaLevel[ nLevel ].mnBuFlags |= nVal16;
4172 if ( nPMask & 0x0080 )
4173 rIn >> maParaLevel[ nLevel ].mnBulletChar;
4174 if ( nPMask & 0x0010 )
4175 rIn >> maParaLevel[ nLevel ].mnBulletFont;
4176 if ( nPMask & 0x0040 )
4178 rIn >> nVal16;
4179 maParaLevel[ nLevel ].mnBulletHeight = nVal16;
4181 if ( nPMask & 0x0020 )
4183 rIn >> nVal32;
4184 maParaLevel[ nLevel ].mnBulletColor = nVal32;
4186 if ( bFirst )
4188 if ( nPMask & 0xF00 )
4189 { // AbsJust!
4190 rIn >> nVal16;
4191 maParaLevel[ nLevel ].mnAdjust = nVal16 & 3;
4193 if ( nPMask & 0x1000 )
4194 rIn >> maParaLevel[ nLevel ].mnLineFeed;
4195 if ( nPMask & 0x2000 )
4196 rIn >> maParaLevel[ nLevel ].mnUpperDist;
4197 if ( nPMask & 0x4000 )
4198 rIn >> maParaLevel[ nLevel ].mnLowerDist;
4199 if ( nPMask & 0x8000 )
4200 rIn >> maParaLevel[ nLevel ].mnTextOfs;
4201 if ( nPMask & 0x10000 )
4202 rIn >> maParaLevel[ nLevel ].mnBulletOfs;
4203 if ( nPMask & 0x20000 )
4204 rIn >> maParaLevel[ nLevel ].mnDefaultTab;
4205 if ( nPMask & 0x200000 )
4207 // number of tabulators
4208 rIn >> nVal16;
4209 for ( i = 0; i < nVal16; i++ )
4210 rIn >> nVal32; // reading the tabulators
4212 if ( nPMask & 0x40000 )
4213 rIn >> nVal16;
4214 if ( nPMask & 0x80000 )
4215 rIn >> maParaLevel[ nLevel ].mnAsianLineBreak;
4216 if ( nPMask & 0x100000 )
4217 rIn >> maParaLevel[ nLevel ].mnBiDi;
4219 else
4221 if ( nPMask & 0x800 )
4223 rIn >> nVal16;
4224 maParaLevel[ nLevel ].mnAdjust = nVal16 & 3;
4226 if ( nPMask & 0x1000 )
4227 rIn >> maParaLevel[ nLevel ].mnLineFeed;
4228 if ( nPMask & 0x2000 )
4229 rIn >> maParaLevel[ nLevel ].mnUpperDist;
4230 if ( nPMask & 0x4000 )
4231 rIn >> maParaLevel[ nLevel ].mnLowerDist;
4232 if ( nPMask & 0x8000 )
4233 rIn >> nVal16;
4234 if ( nPMask & 0x100 )
4235 rIn >> maParaLevel[ nLevel ].mnTextOfs;
4236 if ( nPMask & 0x200 )
4237 rIn >> nVal16;
4238 if ( nPMask & 0x400 )
4239 rIn >> maParaLevel[ nLevel ].mnBulletOfs;
4240 if ( nPMask & 0x10000 )
4241 rIn >> nVal16;
4242 if ( nPMask & 0xe0000 )
4244 sal_uInt16 nFlagsToModifyMask = (sal_uInt16)( ( nPMask >> 17 ) & 7 );
4245 rIn >> nVal16;
4246 // bits that are not involved to zero
4247 nVal16 &= nFlagsToModifyMask;
4248 // bits that are to change to zero
4249 maParaLevel[ nLevel ].mnAsianLineBreak &=~nFlagsToModifyMask;
4250 // now set the corresponding bits
4251 maParaLevel[ nLevel ].mnAsianLineBreak |= nVal16;
4253 if ( nPMask & 0x100000 )
4255 // number of tabulators
4256 rIn >> nVal16;
4257 for ( i = 0; i < nVal16; i++ )
4258 rIn >> nVal32; // reading the tabulators
4260 if ( nPMask & 0x200000 )
4261 rIn >> maParaLevel[ nLevel ].mnBiDi; // #88602#
4264 nPMask >>= 22;
4265 while( nPMask )
4267 if ( nPMask & 1 )
4269 #ifdef DBG_UTIL
4270 if (!(rManager.rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT))
4272 DBG_ERROR( "PPTParaSheet::Read - unknown attribute, send me this document (SJ)" );
4274 #endif
4275 rIn >> nVal16;
4277 nPMask >>= 1;
4281 PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, SdrPowerPointImport& rManager,
4282 const PPTTextCharacterStyleAtomInterpreter& /*rTxCFStyle*/, const PPTTextParagraphStyleAtomInterpreter& rTxPFStyle,
4283 const PPTTextSpecInfo& rTextSpecInfo ) :
4285 PPTNumberFormatCreator ( new PPTExtParaProv( rManager, rIn, &rSlideHd ) ),
4286 maTxSI ( rTextSpecInfo )
4288 UINT32 i;
4289 UINT32 nOldFilePos = rIn.Tell();
4291 // default stylesheets
4292 mpCharSheet[ TSS_TYPE_PAGETITLE ] = new PPTCharSheet( TSS_TYPE_PAGETITLE );
4293 mpCharSheet[ TSS_TYPE_BODY ] = new PPTCharSheet( TSS_TYPE_BODY );
4294 mpCharSheet[ TSS_TYPE_NOTES ] = new PPTCharSheet( TSS_TYPE_NOTES );
4295 mpCharSheet[ TSS_TYPE_UNUSED ] = new PPTCharSheet( TSS_TYPE_UNUSED ); // this entry is not used by ppt
4296 mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ] = new PPTCharSheet( TSS_TYPE_TEXT_IN_SHAPE );
4297 mpParaSheet[ TSS_TYPE_PAGETITLE ] = new PPTParaSheet( TSS_TYPE_PAGETITLE );
4298 mpParaSheet[ TSS_TYPE_BODY ] = new PPTParaSheet( TSS_TYPE_BODY );
4299 mpParaSheet[ TSS_TYPE_NOTES ] = new PPTParaSheet( TSS_TYPE_NOTES );
4300 mpParaSheet[ TSS_TYPE_UNUSED ] = new PPTParaSheet( TSS_TYPE_UNUSED );
4301 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ] = new PPTParaSheet( TSS_TYPE_TEXT_IN_SHAPE );
4302 mpCharSheet[ TSS_TYPE_QUARTERBODY ] = mpCharSheet[ TSS_TYPE_HALFBODY ] = mpCharSheet[ TSS_TYPE_TITLE ] = mpCharSheet[ TSS_TYPE_SUBTITLE ] = NULL;
4303 mpParaSheet[ TSS_TYPE_QUARTERBODY ] = mpParaSheet[ TSS_TYPE_HALFBODY ] = mpParaSheet[ TSS_TYPE_TITLE ] = mpParaSheet[ TSS_TYPE_SUBTITLE ] = NULL;
4305 /* SJ: try to locate the txMasterStyleAtom in the Environment
4307 it seems that the environment TextStyle is having a higher priority
4308 than the TextStyle that can be found within the master page
4310 sal_Bool bFoundTxMasterStyleAtom04 = sal_False;
4311 DffRecordHeader* pEnvHeader = rManager.aDocRecManager.GetRecordHeader( PPT_PST_Environment );
4312 if ( pEnvHeader )
4314 pEnvHeader->SeekToContent( rIn );
4315 DffRecordHeader aTxMasterStyleHd;
4316 while ( rIn.Tell() < pEnvHeader->GetRecEndFilePos() )
4318 rIn >> aTxMasterStyleHd;
4319 if ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom )
4321 sal_uInt16 nLevelAnz;
4322 rIn >> nLevelAnz;
4324 sal_uInt16 nLev = 0;
4325 sal_Bool bFirst = sal_True;
4326 bFoundTxMasterStyleAtom04 = sal_True;
4327 while ( rIn.GetError() == 0 && rIn.Tell() < aTxMasterStyleHd.GetRecEndFilePos() && nLev < nLevelAnz )
4329 if ( nLev )
4331 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev ] = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev - 1 ];
4332 mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev ] = mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev - 1 ];
4334 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rManager, rIn, sal_True, nLev, bFirst );
4335 if ( !nLev )
4337 // set paragraph defaults for instance 4 (TSS_TYPE_TEXT_IN_SHAPE)
4338 if ( rTxPFStyle.bValid )
4340 PPTParaLevel& rParaLevel = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ 0 ];
4341 rParaLevel.mnAsianLineBreak = 0;
4342 if ( rTxPFStyle.bForbiddenRules )
4343 rParaLevel.mnAsianLineBreak |= 1;
4344 if ( !rTxPFStyle.bLatinTextWrap )
4345 rParaLevel.mnAsianLineBreak |= 2;
4346 if ( rTxPFStyle.bHangingPunctuation )
4347 rParaLevel.mnAsianLineBreak |= 4;
4350 mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rIn, sal_True, nLev, bFirst );
4351 bFirst = sal_False;
4352 nLev++;
4354 break;
4356 else
4357 aTxMasterStyleHd.SeekToEndOfRecord( rIn );
4361 rSlideHd.SeekToContent( rIn );
4362 DffRecordHeader aTxMasterStyleHd;
4363 while ( rIn.Tell() < rSlideHd.GetRecEndFilePos() )
4365 rIn >> aTxMasterStyleHd;
4366 if ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom )
4367 break;
4368 else
4369 aTxMasterStyleHd.SeekToEndOfRecord( rIn );
4371 while ( ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom ) && ( rIn.Tell() < rSlideHd.GetRecEndFilePos() ) ) //TODO: aTxMasterStyleHd may be used without having been properly initialized
4373 sal_uInt32 nInstance = aTxMasterStyleHd.nRecInstance;
4374 if ( ( nInstance < PPT_STYLESHEETENTRYS ) &&
4375 ( ( nInstance != TSS_TYPE_TEXT_IN_SHAPE ) || ( bFoundTxMasterStyleAtom04 == sal_False ) ) )
4377 if ( nInstance > 4 )
4379 delete mpCharSheet[ nInstance ]; // be sure to delete the old one if this instance comes twice
4380 delete mpParaSheet[ nInstance ];
4382 switch ( nInstance )
4384 case TSS_TYPE_SUBTITLE :
4386 mpCharSheet[ TSS_TYPE_SUBTITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4387 mpParaSheet[ TSS_TYPE_SUBTITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4389 break;
4390 case TSS_TYPE_TITLE :
4392 mpCharSheet[ TSS_TYPE_TITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_PAGETITLE ] ) );
4393 mpParaSheet[ TSS_TYPE_TITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_PAGETITLE ] ) );
4395 break;
4396 case TSS_TYPE_HALFBODY :
4398 mpCharSheet[ TSS_TYPE_HALFBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4399 mpParaSheet[ TSS_TYPE_HALFBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4401 break;
4403 case TSS_TYPE_QUARTERBODY :
4405 mpCharSheet[ TSS_TYPE_QUARTERBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4406 mpParaSheet[ TSS_TYPE_QUARTERBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4408 break;
4411 sal_uInt16 nLevelAnz;
4412 rIn >> nLevelAnz;
4413 if ( nLevelAnz > 5 )
4415 DBG_ERROR( "PPTStyleSheet::Ppt-TextStylesheet hat mehr als 5 Ebenen! (SJ)" );
4416 nLevelAnz = 5;
4418 sal_uInt16 nLev = 0;
4419 sal_Bool bFirst = sal_True;
4421 while ( rIn.GetError() == 0 && rIn.Tell() < aTxMasterStyleHd.GetRecEndFilePos() && nLev < nLevelAnz )
4423 if ( nLev && ( nInstance < 5 ) )
4425 mpParaSheet[ nInstance ]->maParaLevel[ nLev ] = mpParaSheet[ nInstance ]->maParaLevel[ nLev - 1 ];
4426 mpCharSheet[ nInstance ]->maCharLevel[ nLev ] = mpCharSheet[ nInstance ]->maCharLevel[ nLev - 1 ];
4429 // Ausnahme: Vorlage 5, 6 (MasterTitle Titel und SubTitel)
4430 if ( nInstance >= TSS_TYPE_SUBTITLE )
4432 bFirst = sal_False;
4434 sal_uInt16 nDontKnow;
4435 rIn >> nDontKnow;
4437 mpParaSheet[ nInstance ]->Read( rManager, rIn, sal_True, nLev, bFirst );
4438 mpCharSheet[ nInstance ]->Read( rIn, sal_True, nLev, bFirst );
4439 bFirst = sal_False;
4440 nLev++;
4442 #ifdef DBG_UTIL
4443 if (!(rManager.rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT))
4445 if ( rIn.GetError() == 0 )
4447 ByteString aMsg;
4448 if ( rIn.Tell() > aTxMasterStyleHd.GetRecEndFilePos() )
4450 aMsg += "\n ";
4451 aMsg += "reading too many bytes:";
4452 aMsg += ByteString::CreateFromInt32( rIn.Tell() - aTxMasterStyleHd.GetRecEndFilePos() );
4454 if ( rIn.Tell() < aTxMasterStyleHd.GetRecEndFilePos() )
4456 aMsg += "\n ";
4457 aMsg += "reading too less bytes:";
4458 aMsg += ByteString::CreateFromInt32( aTxMasterStyleHd.GetRecEndFilePos() - rIn.Tell() );
4460 if ( aMsg.Len() != 0 )
4462 aMsg.Insert( "]:", 0 );
4463 aMsg.Insert( "PptStyleSheet::operator>>[", 0 );
4464 DBG_ERROR(aMsg.GetBuffer());
4467 if ( rIn.Tell() != aTxMasterStyleHd.GetRecEndFilePos() )
4468 DBG_ASSERT(0, "SJ: Falsche Anzahl von Bytes gelesen beim Import der PPT-Formatvorlagen");
4470 #endif
4472 aTxMasterStyleHd.SeekToEndOfRecord( rIn );
4473 rIn >> aTxMasterStyleHd;
4475 if ( !mpCharSheet[ TSS_TYPE_SUBTITLE ] )
4477 mpCharSheet[ TSS_TYPE_SUBTITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4478 mpParaSheet[ TSS_TYPE_SUBTITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4480 if ( !mpCharSheet[ TSS_TYPE_TITLE ] )
4482 mpCharSheet[ TSS_TYPE_TITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_PAGETITLE ] ) );
4483 mpParaSheet[ TSS_TYPE_TITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_PAGETITLE ] ) );
4485 if ( !mpCharSheet[ TSS_TYPE_HALFBODY ] )
4487 mpCharSheet[ TSS_TYPE_HALFBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4488 mpParaSheet[ TSS_TYPE_HALFBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4490 if ( !mpCharSheet[ TSS_TYPE_QUARTERBODY ] )
4492 mpCharSheet[ TSS_TYPE_QUARTERBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) );
4493 mpParaSheet[ TSS_TYPE_QUARTERBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) );
4495 if ( !bFoundTxMasterStyleAtom04 )
4496 { // try to locate the txMasterStyleAtom in the Environment
4497 DffRecordHeader* pEnvHeader2 = rManager.aDocRecManager.GetRecordHeader( PPT_PST_Environment );
4498 if ( pEnvHeader2 )
4500 pEnvHeader2->SeekToContent( rIn );
4501 DffRecordHeader aTxMasterStyleHd2;
4502 while ( rIn.Tell() < pEnvHeader2->GetRecEndFilePos() )
4504 rIn >> aTxMasterStyleHd2;
4505 if ( aTxMasterStyleHd2.nRecType == PPT_PST_TxMasterStyleAtom )
4507 sal_uInt16 nLevelAnz;
4508 rIn >> nLevelAnz;
4510 sal_uInt16 nLev = 0;
4511 sal_Bool bFirst = sal_True;
4512 while ( rIn.GetError() == 0 && rIn.Tell() < aTxMasterStyleHd2.GetRecEndFilePos() && nLev < nLevelAnz )
4514 if ( nLev )
4516 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev ] = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev - 1 ];
4517 mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev ] = mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev - 1 ];
4519 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rManager, rIn, sal_True, nLev, bFirst );
4520 if ( !nLev )
4522 // set paragraph defaults for instance 4 (TSS_TYPE_TEXT_IN_SHAPE)
4523 if ( rTxPFStyle.bValid )
4525 PPTParaLevel& rParaLevel = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ 0 ];
4526 rParaLevel.mnAsianLineBreak = 0;
4527 if ( rTxPFStyle.bForbiddenRules )
4528 rParaLevel.mnAsianLineBreak |= 1;
4529 if ( !rTxPFStyle.bLatinTextWrap )
4530 rParaLevel.mnAsianLineBreak |= 2;
4531 if ( rTxPFStyle.bHangingPunctuation )
4532 rParaLevel.mnAsianLineBreak |= 4;
4535 mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rIn, sal_True, nLev, bFirst );
4536 bFirst = sal_False;
4537 nLev++;
4539 break;
4541 else
4542 aTxMasterStyleHd2.SeekToEndOfRecord( rIn );
4546 rIn.Seek( nOldFilePos );
4548 // will will create the default numbulletitem for each instance
4549 for ( i = 0; i < PPT_STYLESHEETENTRYS; i++ )
4551 UINT16 nLevels, nDepth = 0;
4552 SvxNumRuleType eNumRuleType;
4554 switch ( i )
4556 case TSS_TYPE_PAGETITLE :
4557 case TSS_TYPE_TITLE :
4558 nLevels = 1;
4559 eNumRuleType = SVX_RULETYPE_NUMBERING;
4560 break;
4561 case TSS_TYPE_SUBTITLE :
4562 nLevels = 10;
4563 eNumRuleType = SVX_RULETYPE_NUMBERING;
4564 break;
4565 case TSS_TYPE_BODY :
4566 case TSS_TYPE_HALFBODY :
4567 case TSS_TYPE_QUARTERBODY :
4568 nLevels = 10;
4569 eNumRuleType = SVX_RULETYPE_PRESENTATION_NUMBERING;
4570 break;
4571 default :
4572 case TSS_TYPE_NOTES :
4573 case TSS_TYPE_UNUSED :
4574 case TSS_TYPE_TEXT_IN_SHAPE :
4575 nLevels = 10;
4576 eNumRuleType = SVX_RULETYPE_NUMBERING;
4577 break;
4579 SvxNumRule aRule( NUM_BULLET_REL_SIZE | NUM_BULLET_COLOR |
4580 NUM_CHAR_TEXT_DISTANCE | NUM_SYMBOL_ALIGNMENT,
4581 nLevels, FALSE, eNumRuleType );
4582 for ( UINT16 nCount = 0; nDepth < nLevels; nCount++ )
4584 const PPTParaLevel& rParaLevel = mpParaSheet[ i ]->maParaLevel[ nCount ];
4585 const PPTCharLevel& rCharLevel = mpCharSheet[ i ]->maCharLevel[ nCount ];
4586 SvxNumberFormat aNumberFormat( SVX_NUM_CHAR_SPECIAL );
4587 aNumberFormat.SetBulletChar( ' ' );
4588 GetNumberFormat( rManager, aNumberFormat, nCount, rParaLevel, rCharLevel, i );
4589 aRule.SetLevel( nDepth++, aNumberFormat );
4590 if ( nCount >= 4 )
4592 for ( ;nDepth < nLevels; nDepth++ )
4593 aRule.SetLevel( nDepth, aNumberFormat );
4594 if ( eNumRuleType == SVX_RULETYPE_PRESENTATION_NUMBERING )
4595 aRule.SetLevel( 0, aNumberFormat );
4598 mpNumBulletItem[ i ] = new SvxNumBulletItem( aRule, EE_PARA_NUMBULLET );
4602 PPTStyleSheet::~PPTStyleSheet()
4604 for ( UINT32 i = 0; i < PPT_STYLESHEETENTRYS; i++ )
4606 delete mpCharSheet[ i ];
4607 delete mpParaSheet[ i ];
4608 delete mpNumBulletItem[ i ];
4612 ////////////////////////////////////////////////////////////////////////////////////////////////////
4614 PPTParaPropSet::PPTParaPropSet() :
4615 pParaSet( new ImplPPTParaPropSet )
4617 pParaSet->mnHasAnm = 1;
4620 PPTParaPropSet::PPTParaPropSet( PPTParaPropSet& rParaPropSet )
4622 pParaSet = rParaPropSet.pParaSet;
4623 pParaSet->mnRefCount++;
4625 mnOriginalTextPos = rParaPropSet.mnOriginalTextPos;
4628 PPTParaPropSet::~PPTParaPropSet()
4630 if ( ! ( --pParaSet->mnRefCount ) )
4631 delete pParaSet;
4634 PPTParaPropSet& PPTParaPropSet::operator=( PPTParaPropSet& rParaPropSet )
4636 if ( this != &rParaPropSet )
4638 if ( ! ( --pParaSet->mnRefCount ) )
4639 delete pParaSet;
4640 pParaSet = rParaPropSet.pParaSet;
4641 pParaSet->mnRefCount++;
4643 mnOriginalTextPos = rParaPropSet.mnOriginalTextPos;
4645 return *this;
4648 PPTCharPropSet::PPTCharPropSet( sal_uInt32 nParagraph ) :
4649 mnParagraph ( nParagraph ),
4650 mpFieldItem ( NULL ),
4651 pCharSet ( new ImplPPTCharPropSet )
4653 mnLanguage[ 0 ] = mnLanguage[ 1 ] = mnLanguage[ 2 ] = 0;
4656 PPTCharPropSet::PPTCharPropSet( PPTCharPropSet& rCharPropSet )
4658 pCharSet = rCharPropSet.pCharSet;
4659 pCharSet->mnRefCount++;
4661 mnParagraph = rCharPropSet.mnParagraph;
4662 mnOriginalTextPos = rCharPropSet.mnOriginalTextPos;
4663 maString = rCharPropSet.maString;
4664 mpFieldItem = ( rCharPropSet.mpFieldItem ) ? new SvxFieldItem( *rCharPropSet.mpFieldItem ) : NULL;
4665 mnLanguage[ 0 ] = rCharPropSet.mnLanguage[ 0 ];
4666 mnLanguage[ 1 ] = rCharPropSet.mnLanguage[ 1 ];
4667 mnLanguage[ 2 ] = rCharPropSet.mnLanguage[ 2 ];
4670 PPTCharPropSet::PPTCharPropSet( PPTCharPropSet& rCharPropSet, sal_uInt32 nParagraph )
4672 pCharSet = rCharPropSet.pCharSet;
4673 pCharSet->mnRefCount++;
4675 mnParagraph = nParagraph;
4676 mnOriginalTextPos = rCharPropSet.mnOriginalTextPos;
4677 maString = rCharPropSet.maString;
4678 mpFieldItem = ( rCharPropSet.mpFieldItem ) ? new SvxFieldItem( *rCharPropSet.mpFieldItem ) : NULL;
4679 mnLanguage[ 0 ] = mnLanguage[ 1 ] = mnLanguage[ 2 ] = 0;
4682 PPTCharPropSet::~PPTCharPropSet()
4684 if ( ! ( --pCharSet->mnRefCount ) )
4685 delete pCharSet;
4686 delete mpFieldItem;
4689 PPTCharPropSet& PPTCharPropSet::operator=( PPTCharPropSet& rCharPropSet )
4691 if ( this != &rCharPropSet )
4693 if ( ! ( --pCharSet->mnRefCount ) )
4694 delete pCharSet;
4695 pCharSet = rCharPropSet.pCharSet;
4696 pCharSet->mnRefCount++;
4698 mnOriginalTextPos = rCharPropSet.mnOriginalTextPos;
4699 mnParagraph = rCharPropSet.mnParagraph;
4700 maString = rCharPropSet.maString;
4701 mpFieldItem = ( rCharPropSet.mpFieldItem ) ? new SvxFieldItem( *rCharPropSet.mpFieldItem ) : NULL;
4703 return *this;
4706 void PPTCharPropSet::ImplMakeUnique()
4708 if ( pCharSet->mnRefCount > 1 )
4710 ImplPPTCharPropSet& rOld = *pCharSet;
4711 rOld.mnRefCount--;
4712 pCharSet = new ImplPPTCharPropSet( rOld );
4713 pCharSet->mnRefCount = 1;
4717 void PPTCharPropSet::SetFont( UINT16 nFont )
4719 UINT32 nMask = 1 << PPT_CharAttr_Font;
4720 UINT32 bDoNotMake = pCharSet->mnAttrSet & nMask;
4722 if ( bDoNotMake )
4723 bDoNotMake = nFont == pCharSet->mnFont;
4725 if ( !bDoNotMake )
4727 ImplMakeUnique();
4728 pCharSet->mnFont = nFont;
4729 pCharSet->mnAttrSet |= nMask;
4733 void PPTCharPropSet::SetColor( sal_uInt32 nColor )
4735 ImplMakeUnique();
4736 pCharSet->mnColor = nColor;
4737 pCharSet->mnAttrSet |= 1 << PPT_CharAttr_FontColor;
4740 ////////////////////////////////////////////////////////////////////////////////////////////////////
4742 PPTRuler::PPTRuler() :
4743 nRefCount ( 1 ),
4744 nFlags ( 0 ),
4745 pTab ( NULL ),
4746 nTabCount ( 0 )
4750 PPTRuler::~PPTRuler()
4752 delete[] pTab;
4756 PPTTextRulerInterpreter::PPTTextRulerInterpreter() :
4757 mpImplRuler ( new PPTRuler() )
4761 PPTTextRulerInterpreter::PPTTextRulerInterpreter( PPTTextRulerInterpreter& rRuler )
4763 mpImplRuler = rRuler.mpImplRuler;
4764 mpImplRuler->nRefCount++;
4767 PPTTextRulerInterpreter::PPTTextRulerInterpreter( UINT32 nFileOfs, SdrPowerPointImport& rMan, DffRecordHeader& rHeader, SvStream& rIn ) :
4768 mpImplRuler ( new PPTRuler() )
4770 if ( nFileOfs != 0xffffffff )
4772 UINT32 nOldPos = rIn.Tell();
4773 DffRecordHeader rHd;
4774 if ( nFileOfs )
4776 rIn.Seek( nFileOfs );
4777 rIn >> rHd;
4779 else
4781 rHeader.SeekToContent( rIn );
4782 if ( rMan.SeekToRec( rIn, PPT_PST_TextRulerAtom, rHeader.GetRecEndFilePos(), &rHd ) )
4783 nFileOfs++;
4785 if ( nFileOfs )
4787 sal_Int16 nTCount;
4788 sal_Int32 i;
4789 rIn >> mpImplRuler->nFlags;
4790 if ( mpImplRuler->nFlags & 1 )
4791 rIn >> mpImplRuler->nDefaultTab;
4792 if ( mpImplRuler->nFlags & 4 )
4794 rIn >> nTCount;
4795 if ( nTCount )
4797 mpImplRuler->nTabCount = (UINT16)nTCount;
4798 mpImplRuler->pTab = new PPTTabEntry[ mpImplRuler->nTabCount ];
4799 for ( i = 0; i < nTCount; i++ )
4801 rIn >> mpImplRuler->pTab[ i ].nOffset
4802 >> mpImplRuler->pTab[ i ].nStyle;
4806 for ( i = 0; i < 5; i++ )
4808 if ( mpImplRuler->nFlags & ( 8 << i ) )
4809 rIn >> mpImplRuler->nTextOfs[ i ];
4810 if ( mpImplRuler->nFlags & ( 256 << i ) )
4811 rIn >> mpImplRuler->nBulletOfs[ i ];
4814 rIn.Seek( nOldPos );
4818 BOOL PPTTextRulerInterpreter::GetDefaultTab( UINT32 /*nLevel*/, UINT16& nValue ) const
4820 if ( ! ( mpImplRuler->nFlags & 1 ) )
4821 return FALSE;
4822 nValue = mpImplRuler->nDefaultTab;
4823 return TRUE;
4826 BOOL PPTTextRulerInterpreter::GetTextOfs( UINT32 nLevel, UINT16& nValue ) const
4828 if ( ! ( ( nLevel < 5 ) && ( mpImplRuler->nFlags & ( 8 << nLevel ) ) ) )
4829 return FALSE;
4830 nValue = mpImplRuler->nTextOfs[ nLevel ];
4831 return TRUE;
4834 BOOL PPTTextRulerInterpreter::GetBulletOfs( UINT32 nLevel, UINT16& nValue ) const
4836 if ( ! ( ( nLevel < 5 ) && ( mpImplRuler->nFlags & ( 256 << nLevel ) ) ) )
4837 return FALSE;
4838 nValue = mpImplRuler->nBulletOfs[ nLevel ];
4839 return TRUE;
4842 PPTTextRulerInterpreter& PPTTextRulerInterpreter::operator=( PPTTextRulerInterpreter& rRuler )
4844 if ( this != &rRuler )
4846 if ( ! ( --mpImplRuler->nRefCount ) )
4847 delete mpImplRuler;
4848 mpImplRuler = rRuler.mpImplRuler;
4849 mpImplRuler->nRefCount++;
4851 return *this;
4854 PPTTextRulerInterpreter::~PPTTextRulerInterpreter()
4856 if ( ! ( --mpImplRuler->nRefCount ) )
4857 delete mpImplRuler;
4860 ////////////////////////////////////////////////////////////////////////////////////////////////////
4862 PPTTextCharacterStyleAtomInterpreter::PPTTextCharacterStyleAtomInterpreter() :
4863 nFlags1 ( 0 ),
4864 nFlags2 ( 0 ),
4865 nFlags3 ( 0 )
4869 sal_Bool PPTTextCharacterStyleAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader& rRecHd )
4871 rRecHd.SeekToContent( rIn );
4873 rIn >> nFlags1
4874 >> nFlags2
4875 >> nFlags3
4876 >> n1
4877 >> nFontHeight
4878 >> nFontColor;
4880 return sal_True;
4883 PPTTextCharacterStyleAtomInterpreter::~PPTTextCharacterStyleAtomInterpreter()
4887 ////////////////////////////////////////////////////////////////////////////////////////////////////
4888 PPTTextParagraphStyleAtomInterpreter::PPTTextParagraphStyleAtomInterpreter() :
4889 bValid ( sal_False ),
4890 bForbiddenRules ( sal_False ),
4891 bHangingPunctuation ( sal_False ),
4892 bLatinTextWrap ( sal_False )
4896 sal_Bool PPTTextParagraphStyleAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader& rRecHd )
4898 bValid = sal_False;
4899 rRecHd.SeekToContent( rIn );
4900 sal_uInt32 nDummy32, nFlags, nRecEndPos = rRecHd.GetRecEndFilePos();
4901 sal_uInt16 nDummy16;
4903 rIn >> nDummy16
4904 >> nFlags;
4906 if ( nFlags & 0xf && ( rIn.Tell() < nRecEndPos ) )
4907 rIn >> nDummy16; // BuFlags
4908 if ( nFlags & 0x80 && ( rIn.Tell() < nRecEndPos ) )
4909 rIn >> nDummy16; // BuChar
4910 if ( nFlags & 0x10 && ( rIn.Tell() < nRecEndPos ) )
4911 rIn >> nDummy16; // nBuFont;
4912 if ( nFlags & 0x40 && ( rIn.Tell() < nRecEndPos ) )
4913 rIn >> nDummy16; // nBuHeight;
4914 if ( nFlags & 0x0020 && ( rIn.Tell() < nRecEndPos ) )
4915 rIn >> nDummy32; // nBuColor;
4916 if ( nFlags & 0x800 && ( rIn.Tell() < nRecEndPos ) )
4917 rIn >> nDummy16; // AbsJust!
4918 if ( nFlags & 0x400 && ( rIn.Tell() < nRecEndPos ) )
4919 rIn >> nDummy16;
4920 if ( nFlags & 0x200 && ( rIn.Tell() < nRecEndPos ) )
4921 rIn >> nDummy16;
4922 if ( nFlags & 0x100 && ( rIn.Tell() < nRecEndPos ) )
4923 rIn >> nDummy16;
4924 if ( nFlags & 0x1000 && ( rIn.Tell() < nRecEndPos ) )
4925 rIn >> nDummy16; // LineFeed
4926 if ( nFlags & 0x2000 && ( rIn.Tell() < nRecEndPos ) )
4927 rIn >> nDummy16; // nUpperDist
4928 if ( nFlags & 0x4000 && ( rIn.Tell() < nRecEndPos ) )
4929 rIn >> nDummy16; // nLowerDist
4930 if ( nFlags & 0x8000 && ( rIn.Tell() < nRecEndPos ) )
4931 rIn >> nDummy16;
4932 if ( nFlags & 0x10000 && ( rIn.Tell() < nRecEndPos ) )
4933 rIn >> nDummy16;
4934 if ( nFlags & 0xe0000 && ( rIn.Tell() < nRecEndPos ) )
4936 rIn >> nDummy16;
4937 if ( nFlags & 0x20000 )
4938 bForbiddenRules = ( nDummy16 & 1 ) == 1;
4939 if ( nFlags & 0x40000 )
4940 bLatinTextWrap = ( nDummy16 & 2 ) == 0;
4941 if ( nFlags & 0x80000 )
4942 bHangingPunctuation = ( nDummy16 & 4 ) == 4;
4944 nFlags &=~ 0xfffff;
4945 sal_uInt32 nMask = 0x100000;
4946 while ( nFlags && nMask && ( rIn.Tell() < nRecEndPos ) )
4948 if ( nFlags & nMask )
4950 rIn >> nDummy16;
4951 nFlags ^= nMask;
4953 nMask <<= 1;
4955 bValid = rIn.Tell() == nRecEndPos;
4956 return bValid;
4959 PPTTextParagraphStyleAtomInterpreter::~PPTTextParagraphStyleAtomInterpreter()
4964 ////////////////////////////////////////////////////////////////////////////////////////////////////
4966 PPTTextSpecInfo::PPTTextSpecInfo( sal_uInt32 _nCharIdx ) :
4967 nCharIdx ( _nCharIdx ),
4968 nDontKnow ( 1 )
4970 nLanguage[ 0 ] = 0x400;
4971 nLanguage[ 1 ] = 0;
4972 nLanguage[ 2 ] = 0;
4975 PPTTextSpecInfo::~PPTTextSpecInfo()
4979 PPTTextSpecInfoAtomInterpreter::PPTTextSpecInfoAtomInterpreter() :
4980 bValid ( sal_False )
4984 sal_Bool PPTTextSpecInfoAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader& rRecHd,
4985 sal_uInt16 nRecordType, const PPTTextSpecInfo* pTextSpecDefault )
4987 bValid = sal_False;
4988 sal_uInt32 nCharIdx = 0;
4989 rRecHd.SeekToContent( rIn );
4991 while ( rIn.Tell() < rRecHd.GetRecEndFilePos() )
4993 sal_uInt32 nCharCount,
4994 nFlags, i;
4996 if ( nRecordType == PPT_PST_TextSpecInfoAtom )
4998 rIn >> nCharCount;
4999 nCharIdx += nCharCount;
5001 rIn >> nFlags;
5003 PPTTextSpecInfo* pEntry = new PPTTextSpecInfo( nCharIdx );
5004 if ( pTextSpecDefault )
5006 pEntry->nDontKnow = pTextSpecDefault->nDontKnow;
5007 pEntry->nLanguage[ 0 ] = pTextSpecDefault->nLanguage[ 0 ];
5008 pEntry->nLanguage[ 1 ] = pTextSpecDefault->nLanguage[ 1 ];
5009 pEntry->nLanguage[ 2 ] = pTextSpecDefault->nLanguage[ 2 ];
5011 for ( i = 1; nFlags && i ; i <<= 1 )
5013 sal_uInt16 nLang = 0;
5014 switch( nFlags & i )
5016 case 0 : break;
5017 case 1 : rIn >> pEntry->nDontKnow; break;
5018 case 2 : rIn >> nLang; break;
5019 case 4 : rIn >> nLang; break;
5020 default :
5022 rIn.SeekRel( 2 );
5025 if ( nLang )
5027 sal_uInt16 nScriptType = GetI18NScriptTypeOfLanguage( nLang );
5028 if ( nScriptType & SCRIPTTYPE_LATIN )
5029 pEntry->nLanguage[ 0 ] = nLang;
5030 if ( nScriptType & SCRIPTTYPE_ASIAN )
5031 pEntry->nLanguage[ 1 ] = nLang;
5032 if ( nScriptType & SCRIPTTYPE_COMPLEX )
5033 pEntry->nLanguage[ 2 ] = nLang;
5035 nFlags &= ~i;
5037 aList.Insert( pEntry, LIST_APPEND );
5039 bValid = rIn.Tell() == rRecHd.GetRecEndFilePos();
5040 return bValid;
5043 PPTTextSpecInfoAtomInterpreter::~PPTTextSpecInfoAtomInterpreter()
5045 void *pPtr;
5046 for ( pPtr = aList.First(); pPtr; pPtr = aList.Next() )
5047 delete (PPTTextSpecInfo*)pPtr;
5050 ////////////////////////////////////////////////////////////////////////////////////////////////////
5052 void StyleTextProp9::Read( SvStream& rIn )
5054 rIn >> mnExtParagraphMask;
5055 if ( mnExtParagraphMask & 0x800000 )
5056 rIn >> mnBuBlip;
5057 if ( mnExtParagraphMask & 0x2000000 )
5058 rIn >> mnHasAnm;
5059 if ( mnExtParagraphMask & 0x1000000 )
5060 rIn >> mnAnmScheme;
5061 if ( mnExtParagraphMask & 0x4000000 )
5062 rIn >> mpfPP10Ext;
5063 rIn >> mnExtCharacterMask;
5064 if ( mnExtCharacterMask & 0x100000 )
5065 rIn >> mncfPP10Ext;
5066 rIn >> mnSpecialInfoMask;
5067 if ( mnSpecialInfoMask & 0x20 )
5068 rIn >> mnPP10Ext;
5069 if ( mnSpecialInfoMask & 0x40 )
5070 rIn >> mfBidi;
5073 PPTStyleTextPropReader::PPTStyleTextPropReader( SvStream& rIn, SdrPowerPointImport& rMan, const DffRecordHeader& rTextHeader,
5074 PPTTextRulerInterpreter& rRuler, const DffRecordHeader& rExtParaHd, sal_uInt32 nInstance )
5076 Init(rIn, rMan, rTextHeader, rRuler, rExtParaHd, nInstance);
5079 void PPTStyleTextPropReader::ReadParaProps( SvStream& rIn, SdrPowerPointImport& rMan, const DffRecordHeader& rTextHeader,
5080 const String& aString, PPTTextRulerInterpreter& rRuler,
5081 sal_uInt32& nCharCount, sal_Bool& bTextPropAtom )
5083 sal_uInt32 nMask = 0; //TODO: nMask initialized here to suppress warning for now, see corresponding TODO below
5084 sal_uInt32 nCharAnzRead = 0;
5085 sal_uInt16 nDummy16;
5087 sal_uInt16 nStringLen = aString.Len();
5089 DffRecordHeader aTextHd2;
5090 rTextHeader.SeekToContent( rIn );
5091 if ( rMan.SeekToRec( rIn, PPT_PST_StyleTextPropAtom, rTextHeader.GetRecEndFilePos(), &aTextHd2 ) )
5092 bTextPropAtom = sal_True;
5093 while ( nCharAnzRead <= nStringLen )
5095 PPTParaPropSet aParaPropSet;
5096 ImplPPTParaPropSet& aSet = *aParaPropSet.pParaSet;
5097 if ( bTextPropAtom )
5099 rIn >> nCharCount
5100 >> aParaPropSet.pParaSet->mnDepth; // Einruecktiefe
5102 nCharCount--;
5104 rIn >> nMask;
5105 aSet.mnAttrSet = nMask & 0x207df7;
5106 sal_uInt16 nBulFlg = 0;
5107 if ( nMask & 0xF )
5108 rIn >> nBulFlg; // Bullet-HardAttr-Flags
5109 aSet.mpArry[ PPT_ParaAttr_BulletOn ] = ( nBulFlg & 1 ) ? 1 : 0;
5110 aSet.mpArry[ PPT_ParaAttr_BuHardFont ] = ( nBulFlg & 2 ) ? 1 : 0;
5111 aSet.mpArry[ PPT_ParaAttr_BuHardColor ] = ( nBulFlg & 4 ) ? 1 : 0;
5113 if ( nMask & 0x0080 ) // buChar
5114 rIn >> aSet.mpArry[ PPT_ParaAttr_BulletChar ];
5115 if ( nMask & 0x0010 ) // buTypeface
5116 rIn >> aSet.mpArry[ PPT_ParaAttr_BulletFont ];
5117 if ( nMask & 0x0040 ) // buSize
5119 rIn >> aSet.mpArry[ PPT_ParaAttr_BulletHeight ];
5120 if ( ! ( ( nMask & ( 1 << PPT_ParaAttr_BuHardHeight ) )
5121 && ( nBulFlg & ( 1 << PPT_ParaAttr_BuHardHeight ) ) ) )
5122 aSet.mnAttrSet ^= 0x40;
5124 if ( nMask & 0x0020 ) // buColor
5126 sal_uInt32 nVal32, nHiByte;
5127 rIn >> nVal32;
5128 nHiByte = nVal32 >> 24;
5129 if ( nHiByte <= 8 )
5130 nVal32 = nHiByte | PPT_COLSCHEME;
5131 aSet.mnBulletColor = nVal32;
5133 if ( nMask & 0x0800 ) // pfAlignment
5135 rIn >> nDummy16;
5136 aSet.mpArry[ PPT_ParaAttr_Adjust ] = nDummy16 & 3;
5138 if ( nMask & 0x1000 ) // pfLineSpacing
5139 rIn >> aSet.mpArry[ PPT_ParaAttr_LineFeed ];
5140 if ( nMask & 0x2000 ) // pfSpaceBefore
5141 rIn >> aSet.mpArry[ PPT_ParaAttr_UpperDist ];
5142 if ( nMask & 0x4000 ) // pfSpaceAfter
5143 rIn >> aSet.mpArry[ PPT_ParaAttr_LowerDist ];
5144 if ( nMask & 0x100 ) // pfLeftMargin
5145 rIn >> nDummy16;
5146 if ( nMask & 0x400 ) // pfIndent
5147 rIn >> nDummy16;
5148 if ( nMask & 0x8000 ) // pfDefaultTabSize
5149 rIn >> nDummy16;
5150 if ( nMask & 0x100000 ) // pfTabStops
5152 sal_uInt16 i, nDistance, nAlignment, nNumberOfTabStops = 0;
5153 rIn >> nNumberOfTabStops;
5154 for ( i = 0; i < nNumberOfTabStops; i++ )
5156 rIn >> nDistance
5157 >> nAlignment;
5160 if ( nMask & 0x10000 ) // pfBaseLine
5161 rIn >> nDummy16;
5162 if ( nMask & 0xe0000 ) // pfCharWrap, pfWordWrap, pfOverflow
5164 rIn >> nDummy16;
5165 if ( nMask & 0x20000 )
5166 aSet.mpArry[ PPT_ParaAttr_AsianLB_1 ] = nDummy16 & 1;
5167 if ( nMask & 0x40000 )
5168 aSet.mpArry[ PPT_ParaAttr_AsianLB_2 ] = ( nDummy16 >> 1 ) & 1;
5169 if ( nMask & 0x80000 )
5170 aSet.mpArry[ PPT_ParaAttr_AsianLB_3 ] = ( nDummy16 >> 2 ) & 1;
5171 aSet.mnAttrSet |= ( ( nMask >> 17 ) & 7 ) << PPT_ParaAttr_AsianLB_1;
5173 if ( nMask & 0x200000 ) // pfTextDirection
5174 rIn >> aSet.mpArry[ PPT_ParaAttr_BiDi ];
5176 else
5177 nCharCount = nStringLen;
5179 if ( rRuler.GetTextOfs( aParaPropSet.pParaSet->mnDepth, aSet.mpArry[ PPT_ParaAttr_TextOfs ] ) )
5180 aSet.mnAttrSet |= 1 << PPT_ParaAttr_TextOfs;
5181 if ( rRuler.GetBulletOfs( aParaPropSet.pParaSet->mnDepth, aSet.mpArry[ PPT_ParaAttr_BulletOfs ] ) )
5182 aSet.mnAttrSet |= 1 << PPT_ParaAttr_BulletOfs;
5183 if ( rRuler.GetDefaultTab( aParaPropSet.pParaSet->mnDepth, aSet.mpArry[ PPT_ParaAttr_DefaultTab ] ) )
5184 aSet.mnAttrSet |= 1 << PPT_ParaAttr_DefaultTab;
5186 if ( ( nCharCount > nStringLen ) || ( nStringLen < nCharAnzRead + nCharCount ) )
5188 bTextPropAtom = sal_False;
5189 nCharCount = nStringLen - nCharAnzRead;
5190 // please fix the right hand side of
5191 // PPTParaPropSet& PPTParaPropSet::operator=(PPTParaPropSet&),
5192 // it should be a const reference
5193 PPTParaPropSet aTmpPPTParaPropSet;
5194 aParaPropSet = aTmpPPTParaPropSet;
5195 DBG_ERROR( "SJ:PPTStyleTextPropReader::could not get this PPT_PST_StyleTextPropAtom by reading the paragraph attributes" );
5197 PPTParaPropSet* pPara = new PPTParaPropSet( aParaPropSet );
5198 pPara->mnOriginalTextPos = nCharAnzRead;
5199 aParaPropList.Insert( pPara, LIST_APPEND );
5200 if ( nCharCount )
5202 sal_uInt32 nCount;
5203 const sal_Unicode* pDat = aString.GetBuffer() + nCharAnzRead;
5204 for ( nCount = 0; nCount < nCharCount; nCount++ )
5206 if ( pDat[ nCount ] == 0xd )
5208 pPara = new PPTParaPropSet( aParaPropSet );
5209 pPara->mnOriginalTextPos = nCharAnzRead + nCount + 1;
5210 aParaPropList.Insert( pPara, LIST_APPEND );
5214 nCharAnzRead += nCharCount + 1;
5218 void PPTStyleTextPropReader::ReadCharProps( SvStream& rIn, PPTCharPropSet& aCharPropSet, const String& aString,
5219 sal_uInt32& nCharCount, sal_uInt32 nCharAnzRead,
5220 sal_Bool& bTextPropAtom, sal_uInt32 nExtParaPos,
5221 const std::vector< StyleTextProp9 >& aStyleTextProp9,
5222 sal_uInt32& nExtParaFlags, sal_uInt16& nBuBlip,
5223 sal_uInt16& nHasAnm, sal_uInt32& nAnmScheme )
5225 sal_uInt32 nMask = 0; //TODO: nMask initialized here to suppress warning for now, see corresponding TODO below
5226 sal_uInt16 nDummy16;
5227 sal_Int32 nCharsToRead;
5228 sal_uInt32 nExtParaNibble = 0;
5230 sal_uInt16 nStringLen = aString.Len();
5232 rIn >> nDummy16;
5233 nCharCount = nDummy16;
5234 rIn >> nDummy16;
5235 nCharsToRead = nStringLen - ( nCharAnzRead + nCharCount );
5236 if ( nCharsToRead < 0 )
5238 nCharCount = nStringLen - nCharAnzRead;
5239 if ( nCharsToRead < -1 )
5241 bTextPropAtom = sal_False;
5242 DBG_ERROR( "SJ:PPTStyleTextPropReader::could not get this PPT_PST_StyleTextPropAtom by reading the character attributes" );
5245 ImplPPTCharPropSet& aSet = *aCharPropSet.pCharSet;
5247 // character attributes
5248 rIn >> nMask;
5249 if ( (sal_uInt16)nMask )
5251 aSet.mnAttrSet |= (sal_uInt16)nMask;
5252 rIn >> aSet.mnFlags;
5254 if ( nMask & 0x10000 ) // cfTypeface
5256 rIn >> aSet.mnFont;
5257 aSet.mnAttrSet |= 1 << PPT_CharAttr_Font;
5259 if ( nMask & 0x200000 ) // cfFEOldTypeface
5261 rIn >> aSet.mnAsianOrComplexFont;
5262 aSet.mnAttrSet |= 1 << PPT_CharAttr_AsianOrComplexFont;
5264 if ( nMask & 0x400000 ) // cfANSITypeface
5266 rIn >> aSet.mnANSITypeface;
5267 aSet.mnAttrSet |= 1 << PPT_CharAttr_ANSITypeface;
5269 if ( nMask & 0x800000 ) // cfSymbolTypeface
5271 rIn >> aSet.mnSymbolFont;
5272 aSet.mnAttrSet |= 1 << PPT_CharAttr_Symbol;
5274 if ( nMask & 0x20000 ) // cfSize
5276 rIn >> aSet.mnFontHeight;
5277 aSet.mnAttrSet |= 1 << PPT_CharAttr_FontHeight;
5279 if ( nMask & 0x40000 ) // cfColor
5281 sal_uInt32 nVal;
5282 rIn >> nVal;
5283 if ( !( nVal & 0xff000000 ) )
5284 nVal = PPT_COLSCHEME_HINTERGRUND;
5285 aSet.mnColor = nVal;
5286 aSet.mnAttrSet |= 1 << PPT_CharAttr_FontColor;
5288 if ( nMask & 0x80000 ) // cfPosition
5290 rIn >> aSet.mnEscapement;
5291 aSet.mnAttrSet |= 1 << PPT_CharAttr_Escapement;
5293 if ( nExtParaPos )
5295 sal_uInt32 nExtBuInd = nMask & 0x3c00;
5296 if ( nExtBuInd )
5297 nExtBuInd = ( aSet.mnFlags & 0x3c00 ) >> 10;
5298 if ( nExtBuInd < aStyleTextProp9.size() )
5300 if ( nExtParaNibble && ( ( nExtBuInd + nExtParaNibble ) < aStyleTextProp9.size() ) )
5301 nExtBuInd += nExtParaNibble;
5303 nExtParaFlags = aStyleTextProp9[ nExtBuInd ].mnExtParagraphMask;
5304 nBuBlip = aStyleTextProp9[ nExtBuInd ].mnBuBlip;
5305 nHasAnm = aStyleTextProp9[ nExtBuInd ].mnHasAnm;
5306 nAnmScheme = aStyleTextProp9[ nExtBuInd ].mnAnmScheme;
5308 if ( ( nExtBuInd & 0xf ) == 0xf )
5309 nExtParaNibble += 16;
5313 void PPTStyleTextPropReader::Init( SvStream& rIn, SdrPowerPointImport& rMan, const DffRecordHeader& rTextHeader,
5314 PPTTextRulerInterpreter& rRuler, const DffRecordHeader& rExtParaHd, sal_uInt32 nInstance )
5316 sal_uInt32 nMerk = rIn.Tell();
5317 sal_uInt32 nExtParaPos = ( rExtParaHd.nRecType == PPT_PST_ExtendedParagraphAtom ) ? rExtParaHd.nFilePos + 8 : 0;
5319 std::vector< StyleTextProp9 > aStyleTextProp9;
5320 if ( rExtParaHd.nRecType == PPT_PST_ExtendedParagraphAtom )
5322 rIn.Seek( rExtParaHd.nFilePos + 8 );
5323 while( ( rIn.GetError() == 0 ) && ( rIn.Tell() < rExtParaHd.GetRecEndFilePos() ) )
5325 aStyleTextProp9.resize( aStyleTextProp9.size() + 1 );
5326 aStyleTextProp9.back().Read( rIn );
5328 rIn.Seek( nMerk );
5331 String aString;
5332 DffRecordHeader aTextHd;
5333 rIn >> aTextHd;
5334 sal_uInt32 nMaxLen = aTextHd.nRecLen;
5335 if ( nMaxLen > 0xFFFF )
5336 nMaxLen = 0xFFFF;
5338 if( aTextHd.nRecType == PPT_PST_TextCharsAtom )
5340 sal_uInt32 i;
5341 sal_Unicode nChar,*pBuf = new sal_Unicode[ ( nMaxLen >> 1 ) + 1 ];
5342 rIn.Read( pBuf, nMaxLen );
5343 nMaxLen >>= 1;
5344 pBuf[ nMaxLen ] = 0;
5345 sal_Unicode* pPtr = pBuf;
5346 #ifdef OSL_BIGENDIAN
5347 sal_Unicode nTemp;
5348 for ( i = 0; i < nMaxLen; i++ )
5350 nTemp = *pPtr;
5351 *pPtr++ = ( nTemp << 8 ) | ( nTemp >> 8 );
5353 pPtr = pBuf;
5354 #endif
5356 for ( i = 0; i < nMaxLen; pPtr++, i++ )
5358 nChar = *pPtr;
5359 if ( !nChar )
5360 break;
5361 if ( ( nChar & 0xff00 ) == 0xf000 ) // in this special case we got a symbol
5362 aSpecMarkerList.Insert( (void*)( i | PPT_SPEC_SYMBOL ), LIST_APPEND );
5363 else if ( nChar == 0xd )
5365 if ( nInstance == TSS_TYPE_PAGETITLE )
5366 *pPtr = 0xb;
5367 else
5368 aSpecMarkerList.Insert( (void*)( i | PPT_SPEC_NEWLINE ), LIST_APPEND );
5371 if ( i )
5372 aString = String( pBuf, (sal_uInt16)i );
5373 delete[] pBuf;
5375 else if( aTextHd.nRecType == PPT_PST_TextBytesAtom )
5377 sal_Char *pBuf = new sal_Char[ nMaxLen + 1 ];
5378 pBuf[ nMaxLen ] = 0;
5379 rIn.Read( pBuf, nMaxLen );
5380 sal_Char* pPtr = pBuf;
5381 for (;;)
5383 sal_Char cLo = *pPtr;
5384 if ( cLo == 0 )
5385 break;
5386 if ( cLo == 0xd )
5388 if ( nInstance == TSS_TYPE_PAGETITLE )
5389 *pPtr = 0xb;
5390 else
5391 aSpecMarkerList.Insert( (void*)( pPtr - pBuf | PPT_SPEC_NEWLINE ), LIST_APPEND );
5393 pPtr++;
5395 xub_StrLen nLen = sal::static_int_cast< xub_StrLen >( pPtr - pBuf );
5396 if ( nLen )
5397 aString = String( pBuf, nLen, RTL_TEXTENCODING_MS_1252 );
5398 delete[] pBuf;
5400 else
5402 // no chars, but potentially char/para props?
5403 sal_uInt32 nCharCount;
5404 sal_Bool bTextPropAtom = sal_False;
5405 ReadParaProps( rIn, rMan, rTextHeader, aString, rRuler, nCharCount, bTextPropAtom );
5407 if ( bTextPropAtom )
5409 // yeah, StyleTextProp is there, read it all & push to
5410 // aParaPropList
5411 PPTCharPropSet aCharPropSet(0);
5412 aCharPropSet.mnOriginalTextPos = 0;
5414 sal_uInt32 nCharAnzRead = 0;
5415 sal_uInt32 nExtParaFlags = 0, nAnmScheme = 0;
5416 sal_uInt16 nBuBlip = 0xffff, nHasAnm = 0;
5417 ReadCharProps( rIn, aCharPropSet, aString, nCharCount, nCharAnzRead,
5418 bTextPropAtom, nExtParaPos, aStyleTextProp9, nExtParaFlags,
5419 nBuBlip, nHasAnm, nAnmScheme );
5421 aCharPropList.Insert(
5422 new PPTCharPropSet( aCharPropSet, 0 ), LIST_APPEND );
5426 if ( aString.Len() )
5428 sal_uInt32 nCharCount;
5429 sal_Bool bTextPropAtom = sal_False;
5431 ReadParaProps( rIn, rMan, rTextHeader, aString, rRuler, nCharCount, bTextPropAtom );
5433 sal_Bool bEmptyParaPossible = sal_True;
5434 sal_uInt32 nCharAnzRead = 0;
5435 sal_uInt32 nCurrentPara = 0;
5436 sal_uInt32 nCurrentSpecMarker = (sal_uInt32)(sal_uIntPtr)aSpecMarkerList.First();
5437 sal_uInt16 nStringLen = aString.Len();
5439 while ( nCharAnzRead < nStringLen )
5441 sal_uInt32 nExtParaFlags = 0, nLatestParaUpdate = 0xffffffff, nAnmScheme = 0;
5442 sal_uInt16 nBuBlip = 0xffff, nHasAnm = 0;
5444 PPTCharPropSet aCharPropSet( nCurrentPara );
5445 if ( bTextPropAtom )
5446 ReadCharProps( rIn, aCharPropSet, aString, nCharCount, nCharAnzRead,
5447 bTextPropAtom, nExtParaPos, aStyleTextProp9, nExtParaFlags,
5448 nBuBlip, nHasAnm, nAnmScheme );
5449 else
5450 nCharCount = nStringLen;
5452 sal_uInt32 nLen;
5453 while( nCharCount )
5455 if ( nExtParaPos && ( nLatestParaUpdate != nCurrentPara ) && ( nCurrentPara < aParaPropList.Count() ) )
5457 PPTParaPropSet* pPropSet = (PPTParaPropSet*)aParaPropList.GetObject( nCurrentPara );
5458 pPropSet->pParaSet->mnExtParagraphMask = nExtParaFlags;
5459 if ( nExtParaFlags & 0x800000 )
5460 pPropSet->pParaSet->mnBuBlip = nBuBlip;
5461 if ( nExtParaFlags & 0x01000000 )
5462 pPropSet->pParaSet->mnAnmScheme = nAnmScheme;
5463 if ( nExtParaFlags & 0x02000000 )
5464 pPropSet->pParaSet->mnHasAnm = nHasAnm;
5465 nLatestParaUpdate = nCurrentPara;
5467 aCharPropSet.mnOriginalTextPos = nCharAnzRead;
5468 if ( nCurrentSpecMarker && ( ( nCurrentSpecMarker & 0xffff ) < ( nCharAnzRead + nCharCount ) ) )
5470 if ( nCurrentSpecMarker & PPT_SPEC_NEWLINE )
5472 nLen = ( nCurrentSpecMarker & 0xffff ) - nCharAnzRead;
5473 if ( nLen )
5474 aCharPropSet.maString = String( aString, (sal_uInt16)nCharAnzRead, (sal_uInt16)nLen );
5475 else if ( bEmptyParaPossible )
5476 aCharPropSet.maString = String();
5477 if ( nLen || bEmptyParaPossible )
5478 aCharPropList.Insert( new PPTCharPropSet( aCharPropSet, nCurrentPara ), LIST_APPEND );
5479 nCurrentPara++;
5480 nLen++;
5481 nCharAnzRead += nLen;
5482 nCharCount -= nLen;
5483 bEmptyParaPossible = sal_True;
5485 else if ( nCurrentSpecMarker & PPT_SPEC_SYMBOL )
5487 if ( ( nCurrentSpecMarker & 0xffff ) != nCharAnzRead )
5489 nLen = ( nCurrentSpecMarker & 0xffff ) - nCharAnzRead;
5490 aCharPropSet.maString = String( aString, (sal_uInt16)nCharAnzRead, (sal_uInt16)nLen );
5491 aCharPropList.Insert( new PPTCharPropSet( aCharPropSet, nCurrentPara ), LIST_APPEND );
5492 nCharCount -= nLen;
5493 nCharAnzRead += nLen;
5495 PPTCharPropSet* pCPropSet = new PPTCharPropSet( aCharPropSet, nCurrentPara );
5496 pCPropSet->maString = aString.GetChar( (sal_uInt16)nCharAnzRead );
5497 if ( aCharPropSet.pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_Symbol ) )
5498 pCPropSet->SetFont( aCharPropSet.pCharSet->mnSymbolFont );
5499 aCharPropList.Insert( pCPropSet, LIST_APPEND );
5500 nCharCount--;
5501 nCharAnzRead++;
5502 bEmptyParaPossible = sal_False;
5504 nCurrentSpecMarker = (sal_uInt32)(sal_uIntPtr)aSpecMarkerList.Next();
5506 else
5508 aCharPropSet.maString = String( aString, (sal_uInt16)nCharAnzRead, (sal_uInt16)nCharCount );
5509 aCharPropList.Insert( new PPTCharPropSet( aCharPropSet, nCurrentPara ), LIST_APPEND );
5510 nCharAnzRead += nCharCount;
5511 bEmptyParaPossible = sal_False;
5512 break;
5516 if ( aCharPropList.Count() && ( ((PPTCharPropSet*)aCharPropList.Last())->mnParagraph != nCurrentPara ) )
5518 PPTCharPropSet* pCharPropSet = new PPTCharPropSet( *(PPTCharPropSet*)aCharPropList.Last(), nCurrentPara );
5519 pCharPropSet->maString = String();
5520 pCharPropSet->mnOriginalTextPos = nStringLen - 1;
5521 aCharPropList.Insert( pCharPropSet, LIST_APPEND );
5524 rIn.Seek( nMerk );
5527 PPTStyleTextPropReader::~PPTStyleTextPropReader()
5529 void* pTmp;
5530 for ( pTmp = aParaPropList.First(); pTmp; pTmp = aParaPropList.Next() )
5531 delete (PPTParaPropSet*)pTmp;
5532 for ( pTmp = aCharPropList.First(); pTmp; pTmp = aCharPropList.Next() )
5533 delete (PPTCharPropSet*)pTmp;
5536 ////////////////////////////////////////////////////////////////////////////////////////////////////
5538 struct FieldEntry
5540 UINT32 nFieldType;
5541 UINT32 nFieldStartPos;
5542 UINT32 nFieldEndPos;
5543 String aFieldUrl;
5545 FieldEntry( UINT32 nType, UINT32 nStart, UINT32 nEnd )
5547 nFieldType = nType;
5548 nFieldStartPos = nStart;
5549 nFieldEndPos = nEnd;
5551 FieldEntry( FieldEntry& rFieldEntry )
5553 nFieldType = rFieldEntry.nFieldType;
5554 nFieldStartPos = rFieldEntry.nFieldStartPos;
5555 nFieldEndPos = rFieldEntry.nFieldEndPos;
5556 aFieldUrl = rFieldEntry.aFieldUrl;
5561 PPTPortionObj::PPTPortionObj( const PPTStyleSheet& rStyleSheet, UINT32 nInstance, UINT32 nDepth ) :
5562 PPTCharPropSet ( 0 ),
5563 mrStyleSheet ( rStyleSheet ),
5564 mnInstance ( nInstance ),
5565 mnDepth ( ( nDepth > 4 ) ? 4 : nDepth )
5569 PPTPortionObj::PPTPortionObj( PPTCharPropSet& rCharPropSet, const PPTStyleSheet& rStyleSheet, UINT32 nInstance, UINT32 nDepth ) :
5570 PPTCharPropSet ( rCharPropSet ),
5571 mrStyleSheet ( rStyleSheet ),
5572 mnInstance ( nInstance ),
5573 mnDepth ( nDepth )
5577 PPTPortionObj::PPTPortionObj( PPTPortionObj& rPortionObj ) :
5578 PPTCharPropSet ( rPortionObj ),
5579 mrStyleSheet ( rPortionObj.mrStyleSheet ),
5580 mnInstance ( rPortionObj.mnInstance ),
5581 mnDepth ( rPortionObj.mnDepth )
5585 PPTPortionObj::~PPTPortionObj()
5589 BOOL PPTPortionObj::HasTabulator()
5591 BOOL bRetValue = FALSE;
5592 sal_Int32 nCount;
5593 const sal_Unicode* pPtr = maString.GetBuffer();
5594 for ( nCount = 0; nCount < maString.Len(); nCount++ )
5596 if ( pPtr[ nCount ] == 0x9 )
5598 bRetValue = TRUE;
5599 break;
5603 return bRetValue;
5606 BOOL PPTPortionObj::GetAttrib( UINT32 nAttr, UINT32& nRetValue, UINT32 nDestinationInstance )
5608 UINT32 nMask = 1 << nAttr;
5609 nRetValue = 0;
5611 UINT32 bIsHardAttribute = ( ( pCharSet->mnAttrSet & nMask ) != 0 ) ? 1 : 0;
5613 if ( bIsHardAttribute )
5615 switch ( nAttr )
5617 case PPT_CharAttr_Bold :
5618 case PPT_CharAttr_Italic :
5619 case PPT_CharAttr_Underline :
5620 case PPT_CharAttr_Shadow :
5621 case PPT_CharAttr_Strikeout :
5622 case PPT_CharAttr_Embossed :
5623 nRetValue = ( pCharSet->mnFlags & nMask ) ? 1 : 0;
5624 break;
5625 case PPT_CharAttr_Font :
5626 nRetValue = pCharSet->mnFont;
5627 break;
5628 case PPT_CharAttr_AsianOrComplexFont :
5629 nRetValue = pCharSet->mnAsianOrComplexFont;
5630 break;
5631 case PPT_CharAttr_FontHeight :
5632 nRetValue = pCharSet->mnFontHeight;
5633 break;
5634 case PPT_CharAttr_FontColor :
5635 nRetValue = pCharSet->mnColor;
5636 break;
5637 case PPT_CharAttr_Escapement :
5638 nRetValue = pCharSet->mnEscapement;
5639 break;
5640 default :
5641 DBG_ERROR( "SJ:PPTPortionObj::GetAttrib ( hard attribute does not exist )" );
5644 else
5646 const PPTCharLevel& rCharLevel = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ mnDepth ];
5647 PPTCharLevel* pCharLevel = NULL;
5648 if ( ( nDestinationInstance == 0xffffffff )
5649 || ( mnDepth && ( ( mnInstance == TSS_TYPE_SUBTITLE ) || ( mnInstance == TSS_TYPE_TEXT_IN_SHAPE ) ) ) )
5650 bIsHardAttribute = 1;
5651 else if ( nDestinationInstance != mnInstance )
5652 pCharLevel = &mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ mnDepth ];
5653 switch( nAttr )
5655 case PPT_CharAttr_Bold :
5656 case PPT_CharAttr_Italic :
5657 case PPT_CharAttr_Underline :
5658 case PPT_CharAttr_Shadow :
5659 case PPT_CharAttr_Strikeout :
5660 case PPT_CharAttr_Embossed :
5662 nRetValue = ( rCharLevel.mnFlags & nMask ) ? 1 : 0;
5663 if ( pCharLevel )
5665 UINT32 nTmp = ( pCharLevel->mnFlags & nMask ) ? 1 : 0;
5666 if ( nRetValue != nTmp )
5667 bIsHardAttribute = 1;
5670 break;
5671 case PPT_CharAttr_Font :
5673 nRetValue = rCharLevel.mnFont;
5674 if ( pCharLevel && ( nRetValue != pCharLevel->mnFont ) )
5675 bIsHardAttribute = 1;
5677 break;
5678 case PPT_CharAttr_AsianOrComplexFont :
5680 nRetValue = rCharLevel.mnAsianOrComplexFont;
5681 if ( pCharLevel && ( nRetValue != pCharLevel->mnAsianOrComplexFont ) )
5682 bIsHardAttribute = 1;
5684 break;
5685 case PPT_CharAttr_FontHeight :
5687 nRetValue = rCharLevel.mnFontHeight;
5688 if ( pCharLevel && ( nRetValue != pCharLevel->mnFontHeight ) )
5689 bIsHardAttribute = 1;
5691 break;
5692 case PPT_CharAttr_FontColor :
5694 nRetValue = rCharLevel.mnFontColor;
5695 if ( pCharLevel && ( nRetValue != pCharLevel->mnFontColor ) )
5696 bIsHardAttribute = 1;
5698 break;
5699 case PPT_CharAttr_Escapement :
5701 nRetValue = rCharLevel.mnEscapement;
5702 if ( pCharLevel && ( nRetValue != pCharLevel->mnEscapement ) )
5703 bIsHardAttribute = 1;
5705 break;
5706 default :
5707 DBG_ERROR( "SJ:PPTPortionObj::GetAttrib ( attribute does not exist )" );
5710 return (BOOL)bIsHardAttribute;
5713 void PPTPortionObj::ApplyTo( SfxItemSet& rSet, SdrPowerPointImport& rManager, UINT32 nDestinationInstance )
5715 ApplyTo( rSet, rManager, nDestinationInstance, NULL );
5718 void PPTPortionObj::ApplyTo( SfxItemSet& rSet, SdrPowerPointImport& rManager, UINT32 nDestinationInstance, const PPTTextObj* pTextObj )
5720 UINT32 nVal;
5721 if ( GetAttrib( PPT_CharAttr_Bold, nVal, nDestinationInstance ) )
5723 rSet.Put( SvxWeightItem( nVal != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
5724 rSet.Put( SvxWeightItem( nVal != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
5725 rSet.Put( SvxWeightItem( nVal != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
5727 if ( GetAttrib( PPT_CharAttr_Italic, nVal, nDestinationInstance ) )
5729 rSet.Put( SvxPostureItem( nVal != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC ) );
5730 rSet.Put( SvxPostureItem( nVal != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
5731 rSet.Put( SvxPostureItem( nVal != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
5733 if ( GetAttrib( PPT_CharAttr_Underline, nVal, nDestinationInstance ) )
5734 rSet.Put( SvxUnderlineItem( nVal != 0 ? UNDERLINE_SINGLE : UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
5736 if ( GetAttrib( PPT_CharAttr_Shadow, nVal, nDestinationInstance ) )
5737 rSet.Put( SvxShadowedItem( nVal != 0, EE_CHAR_SHADOW ) );
5739 if ( GetAttrib( PPT_CharAttr_Strikeout, nVal, nDestinationInstance ) )
5740 rSet.Put( SvxCrossedOutItem( nVal != 0 ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) );
5742 sal_uInt32 nAsianFontId = 0xffff;
5743 if ( GetAttrib( PPT_CharAttr_AsianOrComplexFont, nAsianFontId, nDestinationInstance ) )
5745 if ( nAsianFontId != 0xffff )
5747 PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nAsianFontId );
5748 if ( pFontEnityAtom )
5750 rSet.Put( SvxFontItem( pFontEnityAtom->eFamily, pFontEnityAtom->aName,
5751 String(), pFontEnityAtom->ePitch, pFontEnityAtom->eCharSet, EE_CHAR_FONTINFO_CJK ) );
5752 rSet.Put( SvxFontItem( pFontEnityAtom->eFamily, pFontEnityAtom->aName,
5753 String(), pFontEnityAtom->ePitch, pFontEnityAtom->eCharSet, EE_CHAR_FONTINFO_CTL ) );
5757 if ( GetAttrib( PPT_CharAttr_Font, nVal, nDestinationInstance ) )
5759 PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nVal );
5760 if ( pFontEnityAtom )
5761 rSet.Put( SvxFontItem( pFontEnityAtom->eFamily, pFontEnityAtom->aName, String(), pFontEnityAtom->ePitch, pFontEnityAtom->eCharSet, EE_CHAR_FONTINFO ) );
5763 if ( GetAttrib( PPT_CharAttr_FontHeight, nVal, nDestinationInstance ) ) // Schriftgrad in Point
5765 sal_uInt32 nHeight = rManager.ScalePoint( nVal );
5766 rSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
5767 rSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
5768 rSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
5771 if ( GetAttrib( PPT_CharAttr_Embossed, nVal, nDestinationInstance ) )
5772 rSet.Put( SvxCharReliefItem( nVal != 0 ? RELIEF_EMBOSSED : RELIEF_NONE, EE_CHAR_RELIEF ) );
5773 if ( nVal ) /* if Embossed is set, the font color depends to the fillstyle/color of the object,
5774 if the object has no fillstyle, the font color depends to fillstyle of the background */
5776 Color aDefColor( COL_BLACK );
5777 MSO_FillType eFillType = mso_fillSolid;
5778 if ( rManager.GetPropertyValue( DFF_Prop_fNoFillHitTest ) & 0x10 )
5779 eFillType = (MSO_FillType)rManager.GetPropertyValue( DFF_Prop_fillType, mso_fillSolid );
5780 else
5781 eFillType = mso_fillBackground;
5782 switch( eFillType )
5784 case mso_fillShade :
5785 case mso_fillShadeCenter :
5786 case mso_fillShadeShape :
5787 case mso_fillShadeScale :
5788 case mso_fillShadeTitle :
5789 case mso_fillSolid :
5790 aDefColor = rManager.MSO_CLR_ToColor( rManager.GetPropertyValue( DFF_Prop_fillColor ) );
5791 break;
5792 case mso_fillPattern :
5793 aDefColor = rManager.MSO_CLR_ToColor( rManager.GetPropertyValue( DFF_Prop_fillBackColor ) );
5794 break;
5795 case mso_fillTexture :
5797 Graphic aGraf;
5798 if ( rManager.GetBLIP( rManager.GetPropertyValue( DFF_Prop_fillBlip ), aGraf, NULL ) )
5800 Bitmap aBmp( aGraf.GetBitmap() );
5801 Size aSize( aBmp.GetSizePixel() );
5802 if ( aSize.Width() && aSize.Height() )
5804 if ( aSize.Width () > 64 )
5805 aSize.Width () = 64;
5806 if ( aSize.Height() > 64 )
5807 aSize.Height() = 64;
5809 ULONG nRt = 0, nGn = 0, nBl = 0;
5810 BitmapReadAccess* pAcc = aBmp.AcquireReadAccess();
5811 if( pAcc )
5813 const long nWidth = aSize.Width();
5814 const long nHeight = aSize.Height();
5816 if( pAcc->HasPalette() )
5818 for( long nY = 0L; nY < nHeight; nY++ )
5820 for( long nX = 0L; nX < nWidth; nX++ )
5822 const BitmapColor& rCol = pAcc->GetPaletteColor( (BYTE) pAcc->GetPixel( nY, nX ) );
5823 nRt+=rCol.GetRed(); nGn+=rCol.GetGreen(); nBl+=rCol.GetBlue();
5827 else
5829 for( long nY = 0L; nY < nHeight; nY++ )
5831 for( long nX = 0L; nX < nWidth; nX++ )
5833 const BitmapColor aCol( pAcc->GetPixel( nY, nX ) );
5834 nRt+=aCol.GetRed(); nGn+=aCol.GetGreen(); nBl+=aCol.GetBlue();
5838 aBmp.ReleaseAccess( pAcc );
5839 sal_uInt32 nC = ( aSize.Width() * aSize.Height() );
5840 nRt /= nC;
5841 nGn /= nC;
5842 nBl /= nC;
5843 aDefColor = Color(sal_uInt8( nRt ), sal_uInt8( nGn ),sal_uInt8( nBl ) );
5848 break;
5849 case mso_fillBackground :
5851 if ( pTextObj ) // the textobject is needed
5853 const SfxItemSet* pItemSet = pTextObj->GetBackground();
5854 if ( pItemSet )
5856 const SfxPoolItem* pFillStyleItem = NULL;
5857 pItemSet->GetItemState( XATTR_FILLSTYLE, FALSE, &pFillStyleItem );
5858 if ( pFillStyleItem )
5860 XFillStyle eFillStyle = ((XFillStyleItem*)pFillStyleItem)->GetValue();
5861 switch( eFillStyle )
5863 case XFILL_SOLID :
5865 const SfxPoolItem* pFillColorItem = NULL;
5866 pItemSet->GetItemState( XATTR_FILLCOLOR, FALSE, &pFillColorItem );
5867 if ( pFillColorItem )
5868 aDefColor = ((XColorItem*)pFillColorItem)->GetColorValue();
5870 break;
5871 case XFILL_GRADIENT :
5873 const SfxPoolItem* pGradientItem = NULL;
5874 pItemSet->GetItemState( XATTR_FILLGRADIENT, FALSE, &pGradientItem );
5875 if ( pGradientItem )
5876 aDefColor = ((XFillGradientItem*)pGradientItem)->GetGradientValue().GetStartColor();
5878 break;
5879 case XFILL_HATCH :
5880 case XFILL_BITMAP :
5881 aDefColor = Color( COL_WHITE );
5882 break;
5883 default: break;
5889 break;
5890 // case mso_fillPicture :
5891 default: break;
5893 rSet.Put( SvxColorItem( aDefColor, EE_CHAR_COLOR ) );
5895 else
5897 if ( GetAttrib( PPT_CharAttr_FontColor, nVal, nDestinationInstance ) ) // Textfarbe (4Byte-Arg)
5899 Color aCol( rManager.MSO_CLR_ToColor( nVal ) );
5900 rSet.Put( SvxColorItem( aCol, EE_CHAR_COLOR ) );
5901 if ( nDestinationInstance == 0xffffffff )
5902 mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ mnDepth ].mnFontColorInStyleSheet = aCol;
5904 else if ( nVal & 0x0f000000 ) // this is not a hard attribute, but maybe the page has a different colerscheme,
5905 { // so that in this case we must use a hard color attribute
5906 Color aCol( rManager.MSO_CLR_ToColor( nVal ) );
5907 Color& aColorInSheet = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ mnDepth ].mnFontColorInStyleSheet;
5908 if ( aColorInSheet != aCol )
5909 rSet.Put( SvxColorItem( aCol, EE_CHAR_COLOR ) );
5913 if ( GetAttrib( PPT_CharAttr_Escapement, nVal, nDestinationInstance ) ) // Hoch/Tiefstellung in %
5915 sal_uInt16 nEsc = 0;
5916 sal_uInt8 nProp = 100;
5918 if ( nVal )
5920 nEsc = (sal_Int16)nVal;
5921 nProp = DFLT_ESC_PROP;
5923 SvxEscapementItem aItem( nEsc, nProp, EE_CHAR_ESCAPEMENT );
5924 rSet.Put( aItem );
5926 if ( mnLanguage[ 0 ] )
5927 rSet.Put( SvxLanguageItem( mnLanguage[ 0 ], EE_CHAR_LANGUAGE ) );
5928 if ( mnLanguage[ 1 ] )
5929 rSet.Put( SvxLanguageItem( mnLanguage[ 1 ], EE_CHAR_LANGUAGE_CJK ) );
5930 if ( mnLanguage[ 2 ] )
5931 rSet.Put( SvxLanguageItem( mnLanguage[ 2 ], EE_CHAR_LANGUAGE_CTL ) );
5934 SvxFieldItem* PPTPortionObj::GetTextField()
5936 if ( mpFieldItem )
5937 return new SvxFieldItem( *mpFieldItem );
5938 return NULL;
5941 // -----------------------------------------------------------------------
5943 PPTParagraphObj::PPTParagraphObj( const PPTStyleSheet& rStyleSheet, UINT32 nInstance, UINT16 nDepth ) :
5944 PPTNumberFormatCreator ( NULL ),
5945 mrStyleSheet ( rStyleSheet ),
5946 mnInstance ( nInstance ),
5947 mbTab ( TRUE ), // style sheets always have to get the right tabulator setting
5948 mnPortionCount ( 0 ),
5949 mpPortionList ( NULL )
5951 if ( nDepth > 4 )
5952 nDepth = 4;
5953 pParaSet->mnDepth = nDepth;
5956 PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader, const PPTStyleSheet& rStyleSheet,
5957 UINT32 nInstance, PPTTextRulerInterpreter& rRuler ) :
5958 PPTParaPropSet ( *( (PPTParaPropSet*)rPropReader.aParaPropList.GetCurObject() ) ),
5959 PPTNumberFormatCreator ( NULL ),
5960 PPTTextRulerInterpreter ( rRuler ),
5961 mrStyleSheet ( rStyleSheet ),
5962 mnInstance ( nInstance ),
5963 mbTab ( FALSE ),
5964 mnCurrentObject ( 0 ),
5965 mnPortionCount ( 0 ),
5966 mpPortionList ( NULL )
5968 sal_uInt32 nCurPos = rPropReader.aCharPropList.GetCurPos();
5969 PPTCharPropSet* pCharPropSet = (PPTCharPropSet*)rPropReader.aCharPropList.GetCurObject();
5970 if ( pCharPropSet )
5972 sal_uInt32 nCurrentParagraph = pCharPropSet->mnParagraph;
5973 for ( ; pCharPropSet && ( pCharPropSet->mnParagraph == nCurrentParagraph ); pCharPropSet = (PPTCharPropSet*)rPropReader.aCharPropList.Next() )
5974 mnPortionCount++; // counting number of portions that are part of this paragraph
5975 pCharPropSet = (PPTCharPropSet*)rPropReader.aCharPropList.Seek( nCurPos );
5977 mpPortionList = new PPTPortionObj*[ mnPortionCount ];
5978 for ( UINT32 i = 0; i < mnPortionCount; i++ )
5980 if ( pCharPropSet )
5982 PPTPortionObj* pPPTPortion = new PPTPortionObj( *pCharPropSet, rStyleSheet, nInstance, pParaSet->mnDepth );
5983 mpPortionList[ i ] = pPPTPortion;
5984 if ( !mbTab )
5985 mbTab = mpPortionList[ i ]->HasTabulator();
5987 else
5989 DBG_ERROR( "SJ:PPTParagraphObj::It seems that there are missing some textportions" );
5990 mpPortionList[ i ] = NULL;
5992 pCharPropSet = (PPTCharPropSet*)rPropReader.aCharPropList.Next();
5997 PPTParagraphObj::~PPTParagraphObj()
5999 ImplClear();
6002 void PPTParagraphObj::AppendPortion( PPTPortionObj& rPPTPortion )
6004 UINT32 i;
6005 PPTPortionObj** mpOldPortionList = mpPortionList;
6006 mpPortionList = new PPTPortionObj*[ ++mnPortionCount ];
6007 for ( i = 0; i < mnPortionCount - 1; i++ )
6008 mpPortionList[ i ] = mpOldPortionList[ i ];
6009 delete[] mpOldPortionList;
6010 mpPortionList[ mnPortionCount - 1 ] = new PPTPortionObj( rPPTPortion );
6011 if ( !mbTab )
6012 mbTab = mpPortionList[ mnPortionCount - 1 ]->HasTabulator();
6015 void PPTParagraphObj::UpdateBulletRelSize( sal_uInt32& nBulletRelSize ) const
6017 if ( nBulletRelSize > 0x7fff ) // a negative value is the absolute bullet height
6019 sal_uInt16 nFontHeight = 0;
6020 if ( mpPortionList )
6022 PPTPortionObj* pPortion = mpPortionList[ 0 ];
6023 if ( pPortion && ( pPortion->pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_FontHeight ) ) )
6024 nFontHeight = pPortion->pCharSet->mnFontHeight;
6026 // if we do not have a hard attributed fontheight, the fontheight is taken from the style
6027 if ( !nFontHeight )
6028 nFontHeight = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontHeight;
6029 nBulletRelSize = nFontHeight ? ((-((sal_Int16)nBulletRelSize)) * 100 ) / nFontHeight : 100;
6033 BOOL PPTParagraphObj::GetAttrib( UINT32 nAttr, UINT32& nRetValue, UINT32 nDestinationInstance )
6035 UINT32 nMask = 1 << nAttr;
6036 nRetValue = 0;
6038 if ( nAttr > 21 )
6040 DBG_ERROR( "SJ:PPTParagraphObj::GetAttrib - attribute does not exist" );
6041 return FALSE;
6044 UINT32 bIsHardAttribute = ( ( pParaSet->mnAttrSet & nMask ) != 0 ) ? 1 : 0;
6046 if ( bIsHardAttribute )
6048 if ( nAttr == PPT_ParaAttr_BulletColor )
6050 sal_Bool bHardBulletColor;
6051 if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardColor ) )
6052 bHardBulletColor = pParaSet->mpArry[ PPT_ParaAttr_BuHardColor ] != 0;
6053 else
6054 bHardBulletColor = ( mrStyleSheet.mpParaSheet[ mnInstance ]->maParaLevel[ pParaSet->mnDepth ].mnBuFlags
6055 & ( 1 << PPT_ParaAttr_BuHardColor ) ) != 0;
6056 if ( bHardBulletColor )
6057 nRetValue = pParaSet->mnBulletColor;
6058 else
6060 nRetValue = PPT_COLSCHEME_TEXT_UND_ZEILEN;
6061 if ( ( nDestinationInstance != 0xffffffff ) && mnPortionCount )
6063 PPTPortionObj* pPortion = mpPortionList[ 0 ];
6064 if ( pPortion )
6066 if ( pPortion->pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_FontColor ) )
6067 nRetValue = pPortion->pCharSet->mnColor;
6068 else
6069 nRetValue = mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontColor;
6074 else if ( nAttr == PPT_ParaAttr_BulletFont )
6076 sal_Bool bHardBuFont;
6077 if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardFont ) )
6078 bHardBuFont = pParaSet->mpArry[ PPT_ParaAttr_BuHardFont ] != 0;
6079 else
6080 bHardBuFont = ( mrStyleSheet.mpParaSheet[ mnInstance ]->maParaLevel[ pParaSet->mnDepth ].mnBuFlags
6081 & ( 1 << PPT_ParaAttr_BuHardFont ) ) != 0;
6082 if ( bHardBuFont )
6083 nRetValue = pParaSet->mpArry[ PPT_ParaAttr_BulletFont ];
6084 else
6086 // it is the font used which assigned to the first character of the following text
6087 nRetValue = 0;
6088 if ( ( nDestinationInstance != 0xffffffff ) && mnPortionCount )
6090 PPTPortionObj* pPortion = mpPortionList[ 0 ];
6091 if ( pPortion )
6093 if ( pPortion->pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_Font ) )
6094 nRetValue = pPortion->pCharSet->mnFont;
6095 else
6096 nRetValue = mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFont;
6101 else
6102 nRetValue = pParaSet->mpArry[ nAttr ];
6104 else
6106 const PPTParaLevel& rParaLevel = mrStyleSheet.mpParaSheet[ mnInstance ]->maParaLevel[ pParaSet->mnDepth ];
6108 PPTParaLevel* pParaLevel = NULL;
6109 if ( ( nDestinationInstance == 0xffffffff )
6110 || ( pParaSet->mnDepth && ( ( mnInstance == TSS_TYPE_SUBTITLE ) || ( mnInstance == TSS_TYPE_TEXT_IN_SHAPE ) ) ) )
6111 bIsHardAttribute = 1;
6112 else if ( nDestinationInstance != mnInstance )
6113 pParaLevel = &mrStyleSheet.mpParaSheet[ nDestinationInstance ]->maParaLevel[ pParaSet->mnDepth ];
6114 switch ( nAttr )
6116 case PPT_ParaAttr_BulletOn :
6118 nRetValue = rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BulletOn );
6119 if ( pParaLevel )
6121 if ( nRetValue != ( (sal_uInt32)pParaLevel->mnBuFlags & ( 1 << PPT_ParaAttr_BulletOn ) ) )
6122 bIsHardAttribute = 1;
6125 break;
6126 case PPT_ParaAttr_BuHardFont :
6127 case PPT_ParaAttr_BuHardColor :
6128 case PPT_ParaAttr_BuHardHeight :
6129 DBG_ERROR( "SJ:PPTParagraphObj::GetAttrib - this attribute does not make sense" );
6130 break;
6131 case PPT_ParaAttr_BulletChar :
6133 nRetValue = rParaLevel.mnBulletChar;
6134 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletChar ) )
6135 bIsHardAttribute = 1;
6137 break;
6138 case PPT_ParaAttr_BulletFont :
6140 sal_Bool bHardBuFont;
6141 if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardFont ) )
6142 bHardBuFont = pParaSet->mpArry[ PPT_ParaAttr_BuHardFont ] != 0;
6143 else
6144 bHardBuFont = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardFont ) ) != 0;
6145 if ( bHardBuFont )
6147 nRetValue = rParaLevel.mnBulletFont;
6148 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletFont ) )
6149 bIsHardAttribute = 1;
6151 else
6153 if ( mnPortionCount )
6155 PPTPortionObj* pPortion = mpPortionList[ 0 ];
6156 if ( pPortion )
6157 bIsHardAttribute = pPortion->GetAttrib( PPT_CharAttr_Font, nRetValue, nDestinationInstance );
6159 else
6161 nRetValue = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFont;
6162 bIsHardAttribute = 1;
6166 break;
6167 case PPT_ParaAttr_BulletHeight :
6169 nRetValue = rParaLevel.mnBulletHeight;
6170 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletHeight ) )
6171 bIsHardAttribute = 1;
6173 break;
6174 case PPT_ParaAttr_BulletColor :
6176 sal_Bool bHardBulletColor;
6177 if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardColor ) )
6178 bHardBulletColor = pParaSet->mpArry[ PPT_ParaAttr_BuHardColor ] != 0;
6179 else
6180 bHardBulletColor = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardColor ) ) != 0;
6181 if ( bHardBulletColor )
6183 nRetValue = rParaLevel.mnBulletColor;
6184 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletColor ) )
6185 bIsHardAttribute = 1;
6187 else
6189 if ( mnPortionCount )
6191 PPTPortionObj* pPortion = mpPortionList[ 0 ];
6192 if ( pPortion )
6193 bIsHardAttribute = pPortion->GetAttrib( PPT_CharAttr_FontColor, nRetValue, nDestinationInstance );
6195 else
6197 nRetValue = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontColor;
6198 bIsHardAttribute = 1;
6202 break;
6203 case PPT_ParaAttr_Adjust :
6205 nRetValue = rParaLevel.mnAdjust;
6206 if ( pParaLevel && ( nRetValue != pParaLevel->mnAdjust ) )
6207 bIsHardAttribute = 1;
6209 break;
6210 case PPT_ParaAttr_LineFeed :
6212 nRetValue = rParaLevel.mnLineFeed;
6213 if ( pParaLevel && ( nRetValue != pParaLevel->mnLineFeed ) )
6214 bIsHardAttribute = 1;
6216 break;
6217 case PPT_ParaAttr_UpperDist :
6219 nRetValue = rParaLevel.mnUpperDist;
6220 if ( pParaLevel && ( nRetValue != pParaLevel->mnUpperDist ) )
6221 bIsHardAttribute = 1;
6223 break;
6224 case PPT_ParaAttr_LowerDist :
6226 nRetValue = rParaLevel.mnLowerDist;
6227 if ( pParaLevel && ( nRetValue != pParaLevel->mnLowerDist ) )
6228 bIsHardAttribute = 1;
6230 break;
6231 case PPT_ParaAttr_TextOfs :
6233 nRetValue = rParaLevel.mnTextOfs;
6234 if ( pParaLevel && ( nRetValue != pParaLevel->mnTextOfs ) )
6235 bIsHardAttribute = 1;
6237 break;
6238 case PPT_ParaAttr_BulletOfs :
6240 nRetValue = rParaLevel.mnBulletOfs;
6241 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletOfs ) )
6242 bIsHardAttribute = 1;
6244 break;
6245 case PPT_ParaAttr_DefaultTab :
6247 nRetValue = rParaLevel.mnDefaultTab;
6248 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletOfs ) )
6249 bIsHardAttribute = 1;
6251 break;
6252 case PPT_ParaAttr_AsianLB_1 :
6254 nRetValue = rParaLevel.mnAsianLineBreak & 1;
6255 if ( pParaLevel && ( nRetValue != ( (sal_uInt32)pParaLevel->mnAsianLineBreak & 1 ) ) )
6256 bIsHardAttribute = 1;
6258 break;
6259 case PPT_ParaAttr_AsianLB_2 :
6261 nRetValue = ( rParaLevel.mnAsianLineBreak >> 1 ) & 1;
6262 if ( pParaLevel && ( nRetValue != ( ( (sal_uInt32)pParaLevel->mnAsianLineBreak >> 1 ) & 1 ) ) )
6263 bIsHardAttribute = 1;
6265 break;
6266 case PPT_ParaAttr_AsianLB_3 :
6268 nRetValue = ( rParaLevel.mnAsianLineBreak >> 2 ) & 1;
6269 if ( pParaLevel && ( nRetValue != ( ( (sal_uInt32)pParaLevel->mnAsianLineBreak >> 2 ) & 1 ) ) )
6270 bIsHardAttribute = 1;
6272 break;
6273 case PPT_ParaAttr_BiDi :
6275 nRetValue = rParaLevel.mnBiDi;
6276 if ( pParaLevel && ( nRetValue != pParaLevel->mnBiDi ) )
6277 bIsHardAttribute = 1;
6279 break;
6282 return (BOOL)bIsHardAttribute;
6285 void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, boost::optional< sal_Int16 >& rStartNumbering, SdrPowerPointImport& rManager, sal_uInt32 nDestinationInstance, const PPTParagraphObj* /*pPrev*/)
6287 INT16 nVal2;
6288 UINT32 nVal, nUpperDist, nLowerDist;
6289 UINT32 nInstance = nDestinationInstance != 0xffffffff ? nDestinationInstance : mnInstance;
6291 if ( ( nDestinationInstance != 0xffffffff ) || ( pParaSet->mnDepth <= 1 ) )
6293 SvxNumBulletItem* pNumBulletItem = mrStyleSheet.mpNumBulletItem[ nInstance ];
6294 if ( pNumBulletItem )
6296 SvxNumberFormat aNumberFormat( SVX_NUM_NUMBER_NONE );
6297 if ( GetNumberFormat( rManager, aNumberFormat, this, nDestinationInstance, rStartNumbering ) )
6299 if ( aNumberFormat.GetNumberingType() == SVX_NUM_NUMBER_NONE )
6301 aNumberFormat.SetLSpace( 0 );
6302 aNumberFormat.SetAbsLSpace( 0 );
6303 aNumberFormat.SetFirstLineOffset( 0 );
6304 aNumberFormat.SetCharTextDistance( 0 );
6305 aNumberFormat.SetFirstLineIndent( 0 );
6306 aNumberFormat.SetIndentAt( 0 );
6308 SvxNumBulletItem aNewNumBulletItem( *pNumBulletItem );
6309 SvxNumRule* pRule = aNewNumBulletItem.GetNumRule();
6310 if ( pRule )
6312 pRule->SetLevel( pParaSet->mnDepth, aNumberFormat );
6313 sal_uInt16 i, n;
6314 for ( i = 0; i < pRule->GetLevelCount(); i++ )
6316 if ( i != pParaSet->mnDepth )
6318 n = i > 4 ? 4 : i;
6320 SvxNumberFormat aNumberFormat2( pRule->GetLevel( i ) );
6321 const PPTParaLevel& rParaLevel = mrStyleSheet.mpParaSheet[ nInstance ]->maParaLevel[ n ];
6322 const PPTCharLevel& rCharLevel = mrStyleSheet.mpCharSheet[ nInstance ]->maCharLevel[ n ];
6323 sal_uInt32 nColor;
6324 if ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardColor ) )
6325 nColor = rParaLevel.mnBulletColor;
6326 else
6327 nColor = rCharLevel.mnFontColor;
6328 aNumberFormat2.SetBulletColor( rManager.MSO_CLR_ToColor( nColor ) );
6329 pRule->SetLevel( i, aNumberFormat2 );
6332 rSet.Put( aNewNumBulletItem );
6338 UINT32 nIsBullet2, _nTextOfs, _nBulletOfs, nHardAttribute = 0;
6339 GetAttrib( PPT_ParaAttr_BulletOn, nIsBullet2, nDestinationInstance );
6340 nHardAttribute += GetAttrib( PPT_ParaAttr_TextOfs, _nTextOfs, nDestinationInstance );
6341 nHardAttribute += GetAttrib( PPT_ParaAttr_BulletOfs, _nBulletOfs, nDestinationInstance );
6342 if ( !nIsBullet2 )
6344 SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE );
6345 UINT16 nAbsLSpace = (UINT16)( ( (UINT32)_nTextOfs * 2540 ) / 576 );
6346 UINT16 nFirstLineOffset = nAbsLSpace - (UINT16)( ( (UINT32)_nBulletOfs * 2540 ) / 576 );
6347 aLRSpaceItem.SetLeft( nAbsLSpace );
6348 aLRSpaceItem.SetTxtFirstLineOfstValue( -nFirstLineOffset );
6349 rSet.Put( aLRSpaceItem );
6351 else
6353 SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE );
6354 aLRSpaceItem.SetLeft( 0 );
6355 aLRSpaceItem.SetTxtFirstLineOfstValue( 0 );
6356 rSet.Put( aLRSpaceItem );
6358 if ( GetAttrib( PPT_ParaAttr_Adjust, nVal, nDestinationInstance ) )
6360 if ( nVal <= 3 )
6361 { // Absatzausrichtung
6362 static SvxAdjust __READONLY_DATA aAdj[ 4 ] = { SVX_ADJUST_LEFT, SVX_ADJUST_CENTER, SVX_ADJUST_RIGHT, SVX_ADJUST_BLOCK };
6363 rSet.Put( SvxAdjustItem( aAdj[ nVal ], EE_PARA_JUST ) );
6367 if ( GetAttrib( PPT_ParaAttr_AsianLB_1, nVal, nDestinationInstance ) )
6368 rSet.Put( SfxBoolItem( EE_PARA_FORBIDDENRULES, nVal != 0 ) );
6369 if ( GetAttrib( PPT_ParaAttr_AsianLB_3, nVal, nDestinationInstance ) )
6370 rSet.Put( SfxBoolItem( EE_PARA_HANGINGPUNCTUATION, nVal != 0 ) );
6372 if ( GetAttrib( PPT_ParaAttr_BiDi, nVal, nDestinationInstance ) )
6373 rSet.Put( SvxFrameDirectionItem( nVal == 1 ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
6375 // LineSpacing
6376 PPTPortionObj* pPortion = First();
6377 BOOL bIsHardAttribute = GetAttrib( PPT_ParaAttr_LineFeed, nVal, nDestinationInstance );
6378 nVal2 = (INT16)nVal;
6379 sal_uInt32 nFont = sal_uInt32();
6380 if ( pPortion && pPortion->GetAttrib( PPT_CharAttr_Font, nFont, nDestinationInstance ) )
6381 bIsHardAttribute = TRUE;
6383 if ( bIsHardAttribute )
6385 if ( pPortion && ( nVal2 > 200 ) )
6387 UINT32 nFontHeight;
6388 pPortion->GetAttrib( PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance );
6389 nVal2 = -(sal_Int16)( ( nFontHeight * nVal * 8 ) / 100 );
6391 rSet.Put( SdrTextFixedCellHeightItem( TRUE ), SDRATTR_TEXT_USEFIXEDCELLHEIGHT );
6392 SvxLineSpacingItem aItem( 200, EE_PARA_SBL );
6393 if ( nVal2 <= 0 ) {
6394 aItem.SetLineHeight( (UINT16)( rManager.ScalePoint( -nVal2 ) / 8 ) );
6395 aItem.GetLineSpaceRule() = SVX_LINE_SPACE_FIX;
6396 aItem.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
6397 } else
6399 sal_uInt8 nPropLineSpace = (BYTE)nVal2;
6400 aItem.SetPropLineSpace( nPropLineSpace );
6401 aItem.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
6403 rSet.Put( aItem );
6406 // Paragraph Spacing
6407 UINT32 nFontHeight = 0;
6408 bIsHardAttribute = ( (UINT32)GetAttrib( PPT_ParaAttr_UpperDist, nUpperDist, nDestinationInstance ) +
6409 (UINT32)GetAttrib( PPT_ParaAttr_LowerDist, nLowerDist, nDestinationInstance ) ) != 0;
6410 if ( ( nUpperDist > 0 ) || ( nLowerDist > 0 ) )
6412 if ( mnPortionCount )
6414 mpPortionList[ mnPortionCount - 1 ]->GetAttrib( PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance );
6415 if ( ((INT16)nUpperDist) > 0 )
6416 nUpperDist = - (sal_Int16)( ( nFontHeight * nUpperDist * 100 ) / 1000 );
6417 if ( ((INT16)nLowerDist) > 0 )
6418 nLowerDist = - (sal_Int16)( ( nFontHeight * nLowerDist * 100 ) / 1000 );
6420 bIsHardAttribute = TRUE;
6422 if ( bIsHardAttribute )
6424 SvxULSpaceItem aULSpaceItem( EE_PARA_ULSPACE );
6425 nVal2 = (INT16)nUpperDist;
6426 if ( nVal2 <= 0 )
6427 aULSpaceItem.SetUpper( (UINT16)(((UINT32) - nVal2 * 2540 ) / ( 72 * 8 ) ) );
6428 else
6430 aULSpaceItem.SetUpperValue( 0 );
6431 aULSpaceItem.SetPropUpper( (UINT16)nUpperDist == 100 ? 101 : (UINT16)nUpperDist );
6433 nVal2 = (INT16)nLowerDist;
6434 if ( nVal2 <= 0 )
6435 aULSpaceItem.SetLower( (UINT16)(((UINT32) - nVal2 * 2540 ) / ( 72 * 8 ) ) );
6436 else
6438 aULSpaceItem.SetLowerValue( 0 );
6439 aULSpaceItem.SetPropLower( (UINT16)nLowerDist == 100 ? 101 : (UINT16)nLowerDist );
6441 rSet.Put( aULSpaceItem );
6444 if ( mbTab ) // makes it sense to apply tabsettings
6446 UINT32 i, nDefaultTab, nTab, nTextOfs2 = 0;
6447 UINT32 nLatestManTab = 0;
6448 GetAttrib( PPT_ParaAttr_TextOfs, nTextOfs2, nDestinationInstance );
6449 GetAttrib( PPT_ParaAttr_BulletOfs, nTab, nDestinationInstance );
6450 GetAttrib( PPT_ParaAttr_BulletOn, i, nDestinationInstance );
6451 GetAttrib( PPT_ParaAttr_DefaultTab, nDefaultTab, nDestinationInstance );
6452 SvxTabStopItem aTabItem( 0, 0, SVX_TAB_ADJUST_DEFAULT, EE_PARA_TABS );
6453 if ( GetTabCount() )
6455 for ( i = 0; i < GetTabCount(); i++ )
6457 SvxTabAdjust eTabAdjust;
6458 nTab = GetTabOffsetByIndex( (sal_uInt16)i );
6459 switch( GetTabStyleByIndex( (sal_uInt16)i ) )
6461 case 1 : eTabAdjust = SVX_TAB_ADJUST_CENTER; break;
6462 case 2 : eTabAdjust = SVX_TAB_ADJUST_RIGHT; break;
6463 case 3 : eTabAdjust = SVX_TAB_ADJUST_DECIMAL; break;
6464 default : eTabAdjust = SVX_TAB_ADJUST_LEFT;
6466 if ( nTab > nTextOfs2 )
6467 aTabItem.Insert( SvxTabStop( (UINT16)( ( ( nTab - nTextOfs2 ) * 2540 ) / 576 ), eTabAdjust ) );
6469 nLatestManTab = nTab;
6471 if ( nIsBullet2 == 0 )
6472 aTabItem.Insert( SvxTabStop( (sal_uInt16)0 ) );
6473 if ( nDefaultTab )
6475 nTab = ( nTextOfs2 > nLatestManTab ) ? nTextOfs2 : nLatestManTab;
6476 nTab /= nDefaultTab;
6477 nTab = nDefaultTab * ( 1 + nTab );
6478 for ( i = 0; ( i < 20 ) && ( nTab < 0x1b00 ); i++ )
6480 aTabItem.Insert( SvxTabStop( (UINT16)( ( ( nTab - nTextOfs2 ) * 2540 ) / 576 ) ) );
6481 nTab += nDefaultTab;
6484 rSet.Put( aTabItem );
6488 UINT32 PPTParagraphObj::GetTextSize()
6490 UINT32 nCount, nRetValue = 0;
6491 for ( UINT32 i = 0; i < mnPortionCount; i++ )
6493 PPTPortionObj* pPortionObj = mpPortionList[ i ];
6494 nCount = pPortionObj->Count();
6495 if ( ( !nCount ) && pPortionObj->mpFieldItem )
6496 nCount++;
6497 nRetValue += nCount;
6499 return nRetValue;
6502 PPTPortionObj* PPTParagraphObj::First()
6504 mnCurrentObject = 0;
6505 if ( !mnPortionCount )
6506 return NULL;
6507 return mpPortionList[ 0 ];
6510 PPTPortionObj* PPTParagraphObj::Next()
6512 UINT32 i = mnCurrentObject + 1;
6513 if ( i >= mnPortionCount )
6514 return NULL;
6515 mnCurrentObject++;
6516 return mpPortionList[ i ];
6519 void PPTParagraphObj::ImplClear()
6521 for ( void* pPtr = First(); pPtr; pPtr = Next() )
6522 delete (PPTPortionObj*)pPtr;
6523 delete[] mpPortionList;
6526 PPTFieldEntry::~PPTFieldEntry()
6528 delete pField1;
6529 delete pField2;
6530 delete pString;
6533 void PPTFieldEntry::GetDateTime( const sal_uInt32 nVal, SvxDateFormat& eDateFormat, SvxTimeFormat& eTimeFormat )
6535 eDateFormat = SVXDATEFORMAT_APPDEFAULT;
6536 eTimeFormat = SVXTIMEFORMAT_APPDEFAULT;
6537 // ID auswerten
6538 switch( nVal )
6540 case 0:
6541 case 6:
6542 eDateFormat = SVXDATEFORMAT_A;
6543 break;
6544 case 1:
6545 eDateFormat = SVXDATEFORMAT_F;
6546 break;
6547 case 2:
6548 case 3:
6549 eDateFormat = SVXDATEFORMAT_D;
6550 break;
6551 case 4:
6552 case 5:
6553 eDateFormat = SVXDATEFORMAT_C;
6554 break;
6555 case 7:
6556 eDateFormat = SVXDATEFORMAT_A;
6557 case 9:
6558 eTimeFormat = SVXTIMEFORMAT_24_HM;
6559 break;
6560 case 8:
6561 eDateFormat = SVXDATEFORMAT_A;
6562 case 11:
6563 eTimeFormat = SVXTIMEFORMAT_12_HM;
6564 break;
6565 case 10:
6566 eTimeFormat = SVXTIMEFORMAT_24_HMS;
6567 break;
6568 case 12:
6569 eTimeFormat = SVXTIMEFORMAT_12_HMS;
6570 break;
6574 void PPTFieldEntry::SetDateTime( UINT32 nVal )
6576 SvxDateFormat eDateFormat;
6577 SvxTimeFormat eTimeFormat;
6578 GetDateTime( nVal, eDateFormat, eTimeFormat );
6579 if ( eDateFormat != SVXDATEFORMAT_APPDEFAULT )
6580 pField1 = new SvxFieldItem( SvxDateField( Date(), SVXDATETYPE_VAR, eDateFormat ), EE_FEATURE_FIELD );
6581 if ( eTimeFormat != SVXTIMEFORMAT_APPDEFAULT )
6583 SvxFieldItem* pFieldItem = new SvxFieldItem( SvxExtTimeField( Time(), SVXTIMETYPE_VAR, eTimeFormat ), EE_FEATURE_FIELD );
6584 if ( pField1 )
6585 pField2 = pFieldItem;
6586 else
6587 pField1 = pFieldItem;
6591 // -----------------------------------------------------------------------
6593 PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport, PptSlidePersistEntry& rPersistEntry, DffObjData* pObjData ) :
6594 mpImplTextObj ( new ImplPPTTextObj( rPersistEntry ) )
6596 mpImplTextObj->mnRefCount = 1;
6597 mpImplTextObj->mnShapeId = 0;
6598 mpImplTextObj->mnShapeMaster = 0;
6599 mpImplTextObj->mpPlaceHolderAtom = NULL;
6600 mpImplTextObj->mnDestinationInstance = mpImplTextObj->mnInstance = 4;
6601 mpImplTextObj->mnCurrentObject = 0;
6602 mpImplTextObj->mnParagraphCount = 0;
6603 mpImplTextObj->mpParagraphList = NULL;
6604 mpImplTextObj->mnTextFlags = 0;
6605 mpImplTextObj->meShapeType = ( pObjData && pObjData->bShapeType ) ? pObjData->eShapeType : mso_sptMin;
6607 DffRecordHeader aExtParaHd;
6608 aExtParaHd.nRecType = 0; // set empty
6610 UINT32 bStatus = TRUE;
6612 DffRecordHeader aShapeContainerHd;
6613 rIn >> aShapeContainerHd;
6615 if ( ( pObjData == NULL ) || ( pObjData->bShapeType ) )
6617 PPTExtParaProv* pExtParaProv = rSdrPowerPointImport.pPPTStyleSheet->pExtParaProv;
6618 if ( pObjData )
6620 mpImplTextObj->mnShapeId = pObjData->nShapeId;
6621 if ( pObjData->nSpFlags & SP_FHAVEMASTER )
6622 mpImplTextObj->mnShapeMaster = rSdrPowerPointImport.GetPropertyValue( DFF_Prop_hspMaster, 0 );
6624 ////////////////
6625 // ClientData //
6626 ////////////////
6627 if ( rSdrPowerPointImport.maShapeRecords.SeekToContent( rIn, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) )
6629 UINT32 nOldPos = rIn.Tell();
6630 DffRecordHeader& aClientDataContainerHd = *rSdrPowerPointImport.maShapeRecords.Current();
6631 DffRecordHeader aPlaceHolderAtomHd;
6632 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_OEPlaceholderAtom, aClientDataContainerHd.GetRecEndFilePos(), &aPlaceHolderAtomHd ) )
6634 mpImplTextObj->mpPlaceHolderAtom = new PptOEPlaceholderAtom;
6635 rIn >> *( mpImplTextObj->mpPlaceHolderAtom );
6637 rIn.Seek( nOldPos );
6638 DffRecordHeader aProgTagHd;
6639 if ( rSdrPowerPointImport.SeekToContentOfProgTag( 9, rIn, aClientDataContainerHd, aProgTagHd ) )
6641 rIn >> aExtParaHd;
6645 ///////////////////
6646 // ClientTextBox //
6647 ///////////////////
6648 if ( rSdrPowerPointImport.maShapeRecords.SeekToContent( rIn, DFF_msofbtClientTextbox, SEEK_FROM_CURRENT_AND_RESTART ) )
6650 DffRecordHeader aClientTextBoxHd( *rSdrPowerPointImport.maShapeRecords.Current() );
6651 UINT32 nTextRulerAtomOfs = 0; // case of zero -> this atom may be found in aClientDataContainerHd;
6652 // case of -1 -> ther is no atom of this kind
6653 // else -> this is the fileofs where we can get it
6655 //////////////////////////////////////
6656 // checkout if this is a referenced //
6657 // textobj, if so the we will patch //
6658 // the ClientTextBoxHd for a //
6659 // equivalent one //
6660 //////////////////////////////////////
6661 DffRecordHeader aTextHd;
6662 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_OutlineTextRefAtom, aClientTextBoxHd.GetRecEndFilePos(), &aTextHd ) )
6664 UINT32 nRefNum;
6665 rIn >> nRefNum;
6667 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_TextRulerAtom, aClientTextBoxHd.GetRecEndFilePos() ) )
6668 nTextRulerAtomOfs = rIn.Tell();
6669 else
6670 nTextRulerAtomOfs = 0xffffffff;
6672 UINT32 nInstance = 0;
6673 switch( rSdrPowerPointImport.eAktPageKind )
6675 case PPT_NOTEPAGE :
6676 nInstance++;
6677 case PPT_MASTERPAGE :
6678 nInstance++;
6679 case PPT_SLIDEPAGE :
6680 break;
6681 default :
6682 bStatus = FALSE;
6684 if ( bStatus )
6686 sal_uInt32 nSlideId = rSdrPowerPointImport.GetAktPageId();
6687 if ( !nSlideId )
6688 bStatus = FALSE;
6689 else
6691 if ( !aExtParaHd.nRecType )
6693 UINT32 nOldPos = rIn.Tell();
6694 // try to locate the referenced ExtendedParaHd
6695 DffRecordHeader* pHd = pExtParaProv->
6696 aExtendedPresRules.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom,
6697 SEEK_FROM_CURRENT_AND_RESTART );
6698 DffRecordHeader aPresRuleHd;
6699 DffRecordHeader* pFirst = pHd;
6701 UINT32 nTmpSlideId, nTmpRef;
6702 while ( pHd )
6704 pHd->SeekToContent( rIn );
6705 rIn >> nTmpSlideId
6706 >> nTmpRef; // this seems to be the instance
6708 if ( ( nTmpSlideId == nSlideId ) && ( pHd->nRecInstance == nRefNum ) )
6710 pHd->SeekToEndOfRecord( rIn );
6711 rIn >> aPresRuleHd;
6712 if ( aPresRuleHd.nRecType == PPT_PST_ExtendedParagraphAtom )
6714 aExtParaHd = aPresRuleHd;
6715 break;
6718 pHd = pExtParaProv->
6719 aExtendedPresRules.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom,
6720 SEEK_FROM_CURRENT_AND_RESTART );
6721 if ( pHd == pFirst )
6722 break;
6724 rIn.Seek( nOldPos );
6726 // now pHd points to the right SlideListWithText Container
6727 PptSlidePersistList* pPageList = rSdrPowerPointImport.GetPageList( rSdrPowerPointImport.eAktPageKind );
6728 PptSlidePersistEntry* pE = NULL;
6729 if ( pPageList && ( rSdrPowerPointImport.nAktPageNum < pPageList->Count() ) )
6730 pE = (*pPageList)[ rSdrPowerPointImport.nAktPageNum ];
6731 if ( (!pE) || (!pE->nSlidePersistStartOffset) || ( pE->aPersistAtom.nSlideId != nSlideId ) )
6732 bStatus = sal_False;
6733 else
6735 rIn.Seek( pE->nSlidePersistStartOffset );
6736 // now we got the right page and are searching for the right
6737 // TextHeaderAtom
6738 while ( rIn.Tell() < pE->nSlidePersistEndOffset )
6740 rIn >> aClientTextBoxHd;
6741 if ( aClientTextBoxHd.nRecType == PPT_PST_TextHeaderAtom )
6743 if ( aClientTextBoxHd.nRecInstance == nRefNum )
6745 aClientTextBoxHd.SeekToEndOfRecord( rIn );
6746 break;
6749 aClientTextBoxHd.SeekToEndOfRecord( rIn );
6751 if ( rIn.Tell() > pE->nSlidePersistEndOffset )
6752 bStatus = FALSE;
6753 else
6754 { // patching the RecordHeader
6755 aClientTextBoxHd.nFilePos -= DFF_COMMON_RECORD_HEADER_SIZE;
6756 aClientTextBoxHd.nRecLen += DFF_COMMON_RECORD_HEADER_SIZE;
6757 aClientTextBoxHd.nRecType = DFF_msofbtClientTextbox;
6758 aClientTextBoxHd.nRecVer = DFF_PSFLAG_CONTAINER;
6760 // we have to calculate the correct record len
6761 DffRecordHeader aTmpHd;
6762 while ( rIn.Tell() < pE->nSlidePersistEndOffset )
6764 rIn >> aTmpHd;
6765 if ( ( aTmpHd.nRecType == PPT_PST_SlidePersistAtom ) || ( aTmpHd.nRecType == PPT_PST_TextHeaderAtom ) )
6766 break;
6767 aTmpHd.SeekToEndOfRecord( rIn );
6768 aClientTextBoxHd.nRecLen += aTmpHd.nRecLen + DFF_COMMON_RECORD_HEADER_SIZE;
6770 aClientTextBoxHd.SeekToContent( rIn );
6777 if ( bStatus )
6779 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_TextHeaderAtom, aClientTextBoxHd.GetRecEndFilePos(), &aTextHd ) )
6781 // TextHeaderAtom is always the first Atom
6782 UINT16 nInstance;
6783 rIn >> nInstance; // this number tells us the TxMasterStyleAtom Instance
6784 if ( nInstance > 8 )
6785 nInstance = 4;
6786 aTextHd.SeekToEndOfRecord( rIn );
6787 mpImplTextObj->mnInstance = nInstance;
6789 UINT32 nFilePos = rIn.Tell();
6790 if ( rSdrPowerPointImport.SeekToRec2( PPT_PST_TextBytesAtom,
6791 PPT_PST_TextCharsAtom,
6792 aClientTextBoxHd.GetRecEndFilePos() )
6793 || rSdrPowerPointImport.SeekToRec( rIn,
6794 PPT_PST_StyleTextPropAtom,
6795 aClientTextBoxHd.GetRecEndFilePos() ) )
6797 PPTTextRulerInterpreter aTextRulerInterpreter( nTextRulerAtomOfs, rSdrPowerPointImport,
6798 aClientTextBoxHd, rIn );
6800 PPTStyleTextPropReader aStyleTextPropReader( rIn, rSdrPowerPointImport, aClientTextBoxHd,
6801 aTextRulerInterpreter, aExtParaHd, nInstance );
6802 sal_uInt32 nParagraphs = mpImplTextObj->mnParagraphCount = aStyleTextPropReader.aParaPropList.Count();
6803 if ( nParagraphs )
6805 // the language settings will be merged into the list of PPTCharPropSet
6806 DffRecordHeader aTextSpecInfoHd;
6807 PPTTextSpecInfoAtomInterpreter aTextSpecInfoAtomInterpreter;
6808 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_TextSpecInfoAtom,
6809 aClientTextBoxHd.GetRecEndFilePos(), &aTextSpecInfoHd ) )
6811 if ( aTextSpecInfoAtomInterpreter.Read( rIn, aTextSpecInfoHd, PPT_PST_TextSpecInfoAtom,
6812 &(rSdrPowerPointImport.pPPTStyleSheet->maTxSI) ) )
6814 sal_uInt32 nI = 0;
6815 PPTTextSpecInfo* pSpecInfo;
6816 for ( pSpecInfo = (PPTTextSpecInfo*)aTextSpecInfoAtomInterpreter.aList.First();
6817 pSpecInfo; pSpecInfo =(PPTTextSpecInfo*)aTextSpecInfoAtomInterpreter.aList.Next() )
6819 sal_uInt32 nCharIdx = pSpecInfo->nCharIdx;
6821 // portions and text have to been splitted in some cases
6822 for ( ; nI < aStyleTextPropReader.aCharPropList.Count(); )
6824 PPTCharPropSet* pSet = (PPTCharPropSet*)aStyleTextPropReader.aCharPropList.GetObject( nI );
6825 if ( pSet->mnOriginalTextPos < nCharIdx )
6827 pSet->mnLanguage[ 0 ] = pSpecInfo->nLanguage[ 0 ];
6828 pSet->mnLanguage[ 1 ] = pSpecInfo->nLanguage[ 1 ];
6829 pSet->mnLanguage[ 2 ] = pSpecInfo->nLanguage[ 2 ];
6830 // test if the current portion needs to be splitted
6831 if ( pSet->maString.Len() > 1 )
6833 sal_Int32 nIndexOfNextPortion = pSet->maString.Len() + pSet->mnOriginalTextPos;
6834 sal_Int32 nNewLen = nIndexOfNextPortion - nCharIdx;
6835 sal_Int32 nOldLen = pSet->maString.Len() - nNewLen;
6837 if ( ( nNewLen > 0 ) && ( nOldLen > 0 ) )
6839 String aString( pSet->maString );
6840 PPTCharPropSet* pNew = new PPTCharPropSet( *pSet );
6841 pSet->maString = String( aString, 0, (sal_uInt16)nOldLen );
6842 pNew->maString = String( aString, (sal_uInt16)nOldLen, (sal_uInt16)nNewLen );
6843 pNew->mnOriginalTextPos += nOldLen;
6844 aStyleTextPropReader.aCharPropList.Insert( pNew, nI + 1 );
6848 else
6849 break;
6850 nI++;
6854 #ifdef DBG_UTIL
6855 else
6857 if (!(rSdrPowerPointImport.rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT))
6859 DBG_ERROR( "SdrTextSpecInfoAtomInterpreter::Ctor(): parsing error, this document needs to be analysed (SJ)" );
6862 #endif
6865 // now will search for possible textextensions such as date/time fields
6866 // or ParaTabStops and append them on this textobj
6868 rIn.Seek( nFilePos );
6869 List* pFieldList = NULL;
6870 while ( rIn.Tell() < aClientTextBoxHd.GetRecEndFilePos() )
6872 rIn >> aTextHd;
6873 UINT16 nVal = 0;
6874 PPTFieldEntry* pEntry = NULL;
6875 switch ( aTextHd.nRecType )
6877 case PPT_PST_DateTimeMCAtom :
6879 pEntry = new PPTFieldEntry;
6880 rIn >> pEntry->nPos
6881 >> nVal
6882 >> nVal;
6883 pEntry->SetDateTime( nVal & 0xff );
6885 break;
6887 case PPT_PST_FooterMCAtom :
6889 pEntry = new PPTFieldEntry;
6890 rIn >> pEntry->nPos;
6891 pEntry->pField1 = new SvxFieldItem( SvxFooterField(), EE_FEATURE_FIELD );
6893 break;
6895 case PPT_PST_HeaderMCAtom :
6897 pEntry = new PPTFieldEntry;
6898 rIn >> pEntry->nPos;
6899 pEntry->pField1 = new SvxFieldItem( SvxHeaderField(), EE_FEATURE_FIELD );
6901 break;
6903 case PPT_PST_GenericDateMCAtom :
6905 pEntry = new PPTFieldEntry;
6906 rIn >> pEntry->nPos;
6907 pEntry->pField1 = new SvxFieldItem( SvxDateTimeField(), EE_FEATURE_FIELD );
6908 if ( rPersistEntry.pHeaderFooterEntry ) // sj: #i34111# on master pages it is possible
6909 { // that there is no HeaderFooterEntry available
6910 if ( rPersistEntry.pHeaderFooterEntry->nAtom & 0x20000 ) // auto date time
6911 pEntry->SetDateTime( rPersistEntry.pHeaderFooterEntry->nAtom & 0xff );
6912 else
6913 pEntry->pString = new String( rPersistEntry.pHeaderFooterEntry->pPlaceholder[ nVal ] );
6916 break;
6918 case PPT_PST_SlideNumberMCAtom :
6919 case PPT_PST_RTFDateTimeMCAtom :
6921 pEntry = new PPTFieldEntry;
6922 if ( aTextHd.nRecLen >= 4 )
6924 rIn >> pEntry->nPos
6925 >> nVal;
6927 // ID auswerten
6928 //SvxFieldItem* pFieldItem = NULL;
6929 switch( aTextHd.nRecType )
6931 case PPT_PST_SlideNumberMCAtom:
6932 pEntry->pField1 = new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD );
6933 break;
6935 case PPT_PST_RTFDateTimeMCAtom:
6937 // Rude workaround for one specal case reported
6938 // by a customer. (#i75203#)
6940 // Don't even attempt to handle the general use
6941 // case for PPT_PST_RTFDateTimeMCAtom (a generic
6942 // MS style date/time format string). Just handle
6943 // the special case where the format string
6944 // contains only one or several possibly empty
6945 // quoted strings. I.e. something that doesn't
6946 // expand to any date or time at all, but to a
6947 // fixed string. How on earth somebody manages to
6948 // produce such things in PPT slides I have no
6949 // idea.
6950 if (nVal == 0)
6952 sal_Unicode n;
6953 xub_StrLen nLen;
6954 String aStr;
6955 bool inquote = FALSE;
6956 for (nLen = 0, n = 0; nLen < 64; nLen++)
6958 rIn >> n;
6960 // Collect quoted characters into aStr
6961 if ( n == '\'')
6962 inquote = !inquote;
6963 else if (!n)
6965 // End of format string
6966 pEntry->pString = new String( aStr );
6967 break;
6969 else if (!inquote)
6971 // Non-quoted character, i.e. a real
6972 // format specifier. We don't handle
6973 // those. Sorry.
6974 break;
6976 else
6978 aStr += n;
6982 if ( pEntry->pString == NULL )
6984 // Handle as previously
6985 pEntry->pField1 = new SvxFieldItem( SvxDateField( Date(), SVXDATETYPE_FIX ), EE_FEATURE_FIELD );
6991 break;
6993 case PPT_PST_InteractiveInfo :
6995 DffRecordHeader aHdInteractiveInfoAtom;
6996 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_InteractiveInfoAtom, aTextHd.GetRecEndFilePos(), &aHdInteractiveInfoAtom ) )
6998 PptInteractiveInfoAtom aInteractiveInfoAtom;
6999 rIn >> aInteractiveInfoAtom;
7000 for ( SdHyperlinkEntry* pHyperlink = (SdHyperlinkEntry*)rSdrPowerPointImport.aHyperList.First();
7001 pHyperlink; pHyperlink = (SdHyperlinkEntry*)rSdrPowerPointImport.aHyperList.Next() )
7003 if ( pHyperlink->nIndex == aInteractiveInfoAtom.nExHyperlinkId )
7005 aTextHd.SeekToEndOfRecord( rIn );
7006 rIn >> aTextHd;
7007 if ( aTextHd.nRecType != PPT_PST_TxInteractiveInfoAtom )
7009 aTextHd.SeekToBegOfRecord( rIn );
7010 continue;
7012 else
7014 sal_uInt32 nStartPos, nEndPos;
7015 rIn >> nStartPos
7016 >> nEndPos;
7017 if ( nEndPos )
7019 pEntry = new PPTFieldEntry;
7020 pEntry->nPos = (sal_uInt16)nStartPos;
7021 pEntry->nTextRangeEnd = (sal_uInt16)nEndPos;
7022 String aTarget( pHyperlink->aTarget );
7023 if ( pHyperlink->aConvSubString.Len() )
7025 aTarget.Append( (sal_Unicode)'#' );
7026 aTarget.Append( pHyperlink->aConvSubString );
7028 pEntry->pField1 = new SvxFieldItem( SvxURLField( aTarget, String(), SVXURLFORMAT_REPR ), EE_FEATURE_FIELD );
7031 break;
7036 break;
7038 aTextHd.SeekToEndOfRecord( rIn );
7039 if ( pEntry )
7041 if ( !pFieldList )
7042 pFieldList = new List;
7043 UINT32 n;
7044 for ( n = 0; n < pFieldList->Count(); n++ )
7045 { // sorting fields ( hi >> lo )
7046 if ( ( (PPTFieldEntry*)pFieldList->GetObject( n ) )->nPos < pEntry->nPos )
7047 break;
7049 pFieldList->Insert( pEntry, (UINT32)n );
7052 if ( pFieldList )
7054 PPTFieldEntry* pFE = (PPTFieldEntry*)pFieldList->First();
7055 List& aCharPropList = aStyleTextPropReader.aCharPropList;
7057 sal_Int32 i = nParagraphs - 1;
7058 sal_Int32 n = aCharPropList.Count() - 1;
7060 // at this point we just have a list of textportions(aCharPropList)
7061 // the next while loop tries to resolve the list of fields(pFieldList)
7062 while( pFE && ( n >= 0 ) && ( i >= 0 ) )
7064 PPTCharPropSet* pSet = (PPTCharPropSet*)aCharPropList.GetObject( n );
7065 String aString( pSet->maString );
7066 UINT32 nCount = aString.Len();
7067 UINT32 nPos = pSet->mnOriginalTextPos + nCount;
7068 while ( pFE && nCount-- )
7070 nPos--;
7071 while ( pFE && ( pFE->nPos > nPos ) )
7072 pFE = (PPTFieldEntry*)pFieldList->Next();
7073 if ( !pFE )
7074 break;
7076 if ( pFE->nPos == nPos )
7078 if ( aString.GetChar( (sal_uInt16)nCount ) == 0x2a )
7080 UINT32 nBehind = aString.Len() - ( nCount + 1 );
7081 pSet->maString = String();
7082 if ( nBehind )
7084 PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet );
7085 pNewCPS->maString = String( aString, (UINT16)nCount + 1, (UINT16)nBehind );
7086 aCharPropList.Insert( pNewCPS, n + 1 );
7088 if ( pFE->pField2 )
7090 PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet );
7091 pNewCPS->mpFieldItem = pFE->pField2, pFE->pField2 = NULL;
7092 aCharPropList.Insert( pNewCPS, n + 1 );
7094 pNewCPS = new PPTCharPropSet( *pSet );
7095 pNewCPS->maString = String( String( RTL_CONSTASCII_USTRINGPARAM( " " ) ) );
7096 aCharPropList.Insert( pNewCPS, n + 1 );
7098 if ( nCount )
7100 PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet );
7101 pNewCPS->maString = String( aString, (UINT16)0, (UINT16)nCount );
7102 aCharPropList.Insert( pNewCPS, n++ );
7104 if ( pFE->pField1 )
7106 pSet->mpFieldItem = pFE->pField1, pFE->pField1 = NULL;
7108 else if ( pFE->pString )
7109 pSet->maString = *pFE->pString;
7111 else
7113 if ( pFE->nTextRangeEnd ) // text range hyperlink
7115 sal_uInt32 nHyperLen = pFE->nTextRangeEnd - nPos;
7116 if ( nHyperLen )
7118 PPTCharPropSet* pBefCPS = NULL;
7119 if ( nCount )
7121 pBefCPS = new PPTCharPropSet( *pSet );
7122 pSet->maString = String( pSet->maString, (UINT16)nCount, (UINT16)( pSet->maString.Len() - nCount ) );
7124 sal_uInt32 nIdx = n;
7125 sal_Int32 nHyperLenLeft = nHyperLen;
7127 while ( ( aCharPropList.Count() > nIdx ) && nHyperLenLeft )
7129 // the textrange hyperlink can take more than 1 paragraph
7130 // the solution here is to clone the hyperlink...
7132 PPTCharPropSet* pCurrent = (PPTCharPropSet*)aCharPropList.GetObject( nIdx );
7133 sal_Int32 nNextStringLen = pCurrent->maString.Len();
7135 const SvxURLField* pField = (const SvxURLField*)pFE->pField1->GetField();
7137 if ( pCurrent->mpFieldItem )
7139 pCurrent->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK );
7140 if ( pCurrent->mpFieldItem->GetField()->ISA( SvxURLField ) )
7141 break;
7142 nHyperLenLeft--;
7144 else if ( nNextStringLen )
7146 if ( nNextStringLen <= nHyperLenLeft )
7148 pCurrent->mpFieldItem = new SvxFieldItem( SvxURLField( pField->GetURL(), pCurrent->maString, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD );
7149 nHyperLenLeft -= nNextStringLen;
7151 if ( nHyperLenLeft )
7153 // if the next portion is in a higher paragraph,
7154 // the textrange is to decrease (because of the LineBreak character)
7155 if ( aCharPropList.Count() > ( nIdx + 1 ) )
7157 PPTCharPropSet* pNext = (PPTCharPropSet*)aCharPropList.GetObject( nIdx + 1 );
7158 if ( pNext->mnParagraph > pCurrent->mnParagraph )
7159 nHyperLenLeft--;
7163 else
7165 PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pCurrent );
7166 pNewCPS->maString = String( pCurrent->maString, (UINT16)nHyperLenLeft, (UINT16)( nNextStringLen - nHyperLenLeft ) );
7167 aCharPropList.Insert( pNewCPS, nIdx + 1 );
7168 String aRepresentation( pCurrent->maString, 0, (UINT16)nHyperLenLeft );
7169 pCurrent->mpFieldItem = new SvxFieldItem( SvxURLField( pField->GetURL(), aRepresentation, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD );
7170 nHyperLenLeft = 0;
7172 pCurrent->maString = String();
7173 pCurrent->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK );
7175 nIdx++;
7177 delete pFE->pField1, pFE->pField1 = NULL;
7179 if ( pBefCPS )
7181 pBefCPS->maString = String( aString, (UINT16)0, (UINT16)nCount );
7182 aCharPropList.Insert( pBefCPS, n++ );
7188 break;
7191 n--;
7193 for ( void* pPtr = pFieldList->First(); pPtr; pPtr = pFieldList->Next() )
7194 delete (PPTFieldEntry*)pPtr;
7195 delete pFieldList;
7197 mpImplTextObj->mpParagraphList = new PPTParagraphObj*[ nParagraphs ];
7198 aStyleTextPropReader.aCharPropList.First();
7199 UINT32 nCount = 0;
7200 for ( void* pPtr = aStyleTextPropReader.aParaPropList.First();
7201 pPtr;
7202 pPtr = aStyleTextPropReader.aParaPropList.Next() )
7204 PPTParagraphObj* pPara = new PPTParagraphObj( aStyleTextPropReader, *rSdrPowerPointImport.pPPTStyleSheet, nInstance, aTextRulerInterpreter );
7205 mpImplTextObj->mpParagraphList[ nCount++ ] = pPara;
7207 sal_uInt32 nParaAdjust, nFlags = 0;
7208 pPara->GetAttrib( PPT_ParaAttr_Adjust, nParaAdjust, GetInstance() );
7210 switch ( nParaAdjust )
7212 case 0 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT; break;
7213 case 1 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER; break;
7214 case 2 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT; break;
7215 case 3 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK; break;
7217 mpImplTextObj->mnTextFlags |= nFlags;
7227 PPTTextObj::PPTTextObj( PPTTextObj& rTextObj )
7229 mpImplTextObj = rTextObj.mpImplTextObj;
7230 mpImplTextObj->mnRefCount++;
7233 PPTTextObj::~PPTTextObj()
7235 ImplClear();
7238 PPTParagraphObj* PPTTextObj::First()
7240 mpImplTextObj->mnCurrentObject = 0;
7241 if ( !mpImplTextObj->mnParagraphCount )
7242 return NULL;
7243 return mpImplTextObj->mpParagraphList[ 0 ];
7246 PPTParagraphObj* PPTTextObj::Next()
7248 UINT32 i = mpImplTextObj->mnCurrentObject + 1;
7249 if ( i >= mpImplTextObj->mnParagraphCount )
7250 return NULL;
7251 mpImplTextObj->mnCurrentObject++;
7252 return mpImplTextObj->mpParagraphList[ i ];
7255 const SfxItemSet* PPTTextObj::GetBackground() const
7257 if ( mpImplTextObj->mrPersistEntry.pBObj )
7258 return &mpImplTextObj->mrPersistEntry.pBObj->GetMergedItemSet();
7259 else
7260 return NULL;
7263 void PPTTextObj::ImplClear()
7265 if ( ! ( --mpImplTextObj->mnRefCount ) )
7267 for ( PPTParagraphObj* pPtr = First(); pPtr; pPtr = Next() )
7268 delete pPtr;
7269 delete[] mpImplTextObj->mpParagraphList;
7270 delete mpImplTextObj->mpPlaceHolderAtom;
7271 delete mpImplTextObj;
7275 PPTTextObj& PPTTextObj::operator=( PPTTextObj& rTextObj )
7277 if ( this != &rTextObj )
7279 ImplClear();
7280 mpImplTextObj = rTextObj.mpImplTextObj;
7281 mpImplTextObj->mnRefCount++;
7283 return *this;
7286 sal_Bool IsLine( const SdrObject* pObj )
7288 return pObj->ISA( SdrPathObj ) && ((SdrPathObj*)pObj)->IsLine() && (((SdrPathObj*)pObj)->GetPointCount() == 2 );
7291 sal_Bool GetCellPosition( const SdrObject* pObj, const std::set< sal_Int32 >& rRows, const std::set< sal_Int32 >& rColumns,
7292 sal_Int32& nTableIndex, sal_Int32& nRow, sal_Int32& nRowCount, sal_Int32& nColumn, sal_Int32& nColumnCount )
7294 Rectangle aSnapRect( pObj->GetSnapRect() );
7295 sal_Bool bCellObject = ( aSnapRect.GetWidth() > 1 ) && ( aSnapRect.GetHeight() > 1 );
7296 if ( bCellObject )
7298 std::set< sal_Int32 >::const_iterator aRowIter( rRows.find( aSnapRect.Top() ) );
7299 std::set< sal_Int32 >::const_iterator aColumnIter( rColumns.find( aSnapRect.Left() ) );
7300 if ( ( aRowIter == rRows.end() ) || ( aColumnIter == rColumns.end() ) )
7301 bCellObject = sal_False;
7302 else
7304 nRowCount = 1;
7305 nRow = std::distance( rRows.begin(), aRowIter );
7306 while( ++aRowIter != rRows.end() )
7308 if ( *aRowIter >= aSnapRect.Bottom() )
7309 break;
7310 nRowCount++;
7312 nColumnCount = 1;
7313 nColumn = std::distance( rColumns.begin(), aColumnIter );
7314 while( ++aColumnIter != rColumns.end() )
7316 if ( *aColumnIter >= aSnapRect.Right() )
7317 break;
7318 nColumnCount++;
7320 nTableIndex = nRow * rColumns.size() + nColumn;
7323 return bCellObject;
7326 #define LinePositionLeft 0x01000000
7327 #define LinePositionTop 0x02000000
7328 #define LinePositionRight 0x04000000
7329 #define LinePositionBottom 0x08000000
7330 #define LinePositionTLBR 0x10000000
7331 #define LinePositionBLTR 0x20000000
7334 void GetRowPositions( const Rectangle& rSnapRect, const std::set< sal_Int32 >& rRows,
7335 const std::set< sal_Int32 >& rColumns, std::vector< sal_Int32 >& rPositions, sal_Int32 nColumn, sal_Int32 nFlags )
7337 std::set< sal_Int32 >::const_iterator aRow( rRows.find( rSnapRect.Top() ) );
7338 if ( aRow != rRows.end() )
7340 sal_Int32 nRow = std::distance( rRows.begin(), aRow );
7341 while( ( aRow != rRows.end() ) && ((*aRow) < rSnapRect.Bottom() ) )
7343 if ( nFlags & LinePositionLeft )
7344 rPositions.push_back( ( ( nRow * rColumns.size() ) + nColumn ) | LinePositionLeft );
7345 if ( nFlags & LinePositionRight )
7346 rPositions.push_back( ( ( nRow * rColumns.size() ) + ( nColumn - 1 ) ) | LinePositionRight );
7348 nRow++;
7349 aRow++;
7355 void GetColumnPositions( const Rectangle& rSnapRect, const std::set< sal_Int32 >& /* rRows */,
7356 const std::set< sal_Int32 >& rColumns, std::vector< sal_Int32 >& rPositions, sal_Int32 nRow, sal_Int32 nFlags )
7358 std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( rSnapRect.Left() ) );
7359 if ( aColumn != rColumns.end() )
7361 sal_Int32 nColumn = std::distance( rColumns.begin(), aColumn );
7362 while( ( aColumn != rColumns.end() ) && ((*aColumn) < rSnapRect.Right() ) )
7364 if ( nFlags & LinePositionTop )
7365 rPositions.push_back( ( ( nRow * rColumns.size() ) + nColumn ) | LinePositionTop );
7366 if ( nFlags & LinePositionBottom )
7367 rPositions.push_back( ( ( ( nRow - 1 ) * rColumns.size() ) + nColumn ) | LinePositionBottom );
7369 nColumn++;
7370 aColumn++;
7375 void GetLinePositions( const SdrObject* pObj, const std::set< sal_Int32 >& rRows, const std::set< sal_Int32 >& rColumns,
7376 std::vector< sal_Int32 >& rPositions, const Rectangle& rGroupSnap )
7378 Rectangle aSnapRect( pObj->GetSnapRect() );
7379 if ( aSnapRect.Left() == aSnapRect.Right() )
7381 std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( aSnapRect.Left() ) );
7382 if ( ( aColumn != rColumns.end() ) || ( aSnapRect.Left() == rGroupSnap.Right() ) )
7384 sal_Int32 nColumn, nFlags;
7385 if ( aColumn != rColumns.end() )
7387 nColumn = std::distance( rColumns.begin(), aColumn );
7388 nFlags = LinePositionLeft;
7389 if ( aColumn != rColumns.begin() )
7390 nFlags |= LinePositionRight;
7392 else
7394 nColumn = rColumns.size();
7395 nFlags = LinePositionRight;
7397 GetRowPositions( aSnapRect, rRows, rColumns, rPositions, nColumn, nFlags );
7400 else if ( aSnapRect.Top() == aSnapRect.Bottom() )
7402 std::set< sal_Int32 >::const_iterator aRow( rRows.find( aSnapRect.Top() ) );
7403 if ( ( aRow != rRows.end() ) || ( aSnapRect.Top() == rGroupSnap.Bottom() ) )
7405 sal_Int32 nRow, nFlags;
7406 if ( aRow != rRows.end() )
7408 nRow = std::distance( rRows.begin(), aRow );
7409 nFlags = LinePositionTop;
7410 if ( aRow != rRows.begin() )
7411 nFlags |= LinePositionBottom;
7413 else
7415 nRow = rRows.size();
7416 nFlags = LinePositionBottom;
7418 GetColumnPositions( aSnapRect, rRows, rColumns, rPositions, nRow, nFlags );
7421 else
7423 sal_uInt32 nPosition = 0;
7424 Point aPt1( ((SdrPathObj*)pObj)->GetPoint( 0 ) );
7425 Point aPt2( ((SdrPathObj*)pObj)->GetPoint( 1 ) );
7426 if ( aPt1.X() < aPt2.X() )
7427 nPosition |= aPt1.Y() < aPt2.Y() ? LinePositionTLBR : LinePositionBLTR;
7428 else
7429 nPosition |= aPt1.Y() < aPt2.Y() ? LinePositionBLTR : LinePositionTLBR;
7431 std::set< sal_Int32 >::const_iterator aRow( rRows.find( aPt1.Y() < aPt2.Y() ? aPt1.Y() : aPt2.Y() ) );
7432 std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( aPt1.X() < aPt2.X() ? aPt1.X() : aPt2.X() ) );
7433 if ( ( aRow != rRows.end() ) && ( aColumn != rColumns.end() ) )
7435 nPosition |= ( std::distance( rRows.begin(), aRow ) * rColumns.size() ) + std::distance( rColumns.begin(), aColumn );
7436 rPositions.push_back( nPosition );
7441 void CreateTableRows( Reference< XTableRows > xTableRows, const std::set< sal_Int32 >& rRows, sal_Int32 nTableBottom )
7443 if ( rRows.size() > 1 )
7444 xTableRows->insertByIndex( 0, rRows.size() - 1 );
7446 std::set< sal_Int32 >::const_iterator aIter( rRows.begin() );
7447 sal_Int32 nLastPosition( *aIter );
7448 Reference< XIndexAccess > xIndexAccess( xTableRows, UNO_QUERY_THROW );
7449 for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ )
7451 sal_Int32 nHeight;
7452 if ( ++aIter != rRows.end() )
7454 nHeight = *aIter - nLastPosition;
7455 nLastPosition = *aIter;
7457 else
7458 nHeight = nTableBottom - nLastPosition;
7460 static const rtl::OUString sWidth( RTL_CONSTASCII_USTRINGPARAM ( "Height" ) );
7461 Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW );
7462 xPropSet->setPropertyValue( sWidth, Any( nHeight ) );
7466 void CreateTableColumns( Reference< XTableColumns > xTableColumns, const std::set< sal_Int32 >& rColumns, sal_Int32 nTableRight )
7468 if ( rColumns.size() > 1 )
7469 xTableColumns->insertByIndex( 0, rColumns.size() - 1 );
7471 std::set< sal_Int32 >::const_iterator aIter( rColumns.begin() );
7472 sal_Int32 nLastPosition( *aIter );
7473 Reference< XIndexAccess > xIndexAccess( xTableColumns, UNO_QUERY_THROW );
7474 for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ )
7476 sal_Int32 nWidth;
7477 if ( ++aIter != rColumns.end() )
7479 nWidth = *aIter - nLastPosition;
7480 nLastPosition = *aIter;
7482 else
7483 nWidth = nTableRight - nLastPosition;
7485 static const rtl::OUString sWidth( RTL_CONSTASCII_USTRINGPARAM ( "Width" ) );
7486 Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW );
7487 xPropSet->setPropertyValue( sWidth, Any( nWidth ) );
7491 void MergeCells( const Reference< XTable >& xTable, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan )
7493 DBG_ASSERT( (nColSpan > 1) || (nRowSpan > 1), "nonsense parameter!!" );
7494 DBG_ASSERT( (nCol >= 0) && (nCol < xTable->getColumnCount()) && (nRow >= 0) && (nRow < xTable->getRowCount()), "die celle gibts nicht!!" );
7495 DBG_ASSERT( (nColSpan >= 1) && ((nCol + nColSpan - 1) < xTable->getColumnCount()), "nColSpan murks!" );
7496 DBG_ASSERT( (nRowSpan >= 1) && ((nRow + nRowSpan - 1) < xTable->getRowCount()), "nRowSpan murks!" );
7498 if( xTable.is() ) try
7500 Reference< XMergeableCellRange > xRange( xTable->createCursorByRange( xTable->getCellRangeByPosition( nCol, nRow,nCol + nColSpan - 1, nRow + nRowSpan - 1 ) ), UNO_QUERY_THROW );
7501 if( xRange->isMergeable() )
7502 xRange->merge();
7504 catch( Exception& )
7506 DBG_ASSERT( false, "exception caught!" );
7510 void ApplyCellAttributes( const SdrObject* pObj, Reference< XCell >& xCell )
7514 Reference< XPropertySet > xPropSet( xCell, UNO_QUERY_THROW );
7516 const sal_Int32 nLeftDist(((const SdrTextLeftDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_LEFTDIST)).GetValue());
7517 const sal_Int32 nRightDist(((const SdrTextRightDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_RIGHTDIST)).GetValue());
7518 const sal_Int32 nUpperDist(((const SdrTextUpperDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST)).GetValue());
7519 const sal_Int32 nLowerDist(((const SdrTextLowerDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST)).GetValue());
7520 static const rtl::OUString sTopBorder( RTL_CONSTASCII_USTRINGPARAM( "TextUpperDistance" ) );
7521 static const rtl::OUString sBottomBorder( RTL_CONSTASCII_USTRINGPARAM( "TextLowerDistance" ) );
7522 static const rtl::OUString sLeftBorder( RTL_CONSTASCII_USTRINGPARAM( "TextLeftDistance" ) );
7523 static const rtl::OUString sRightBorder( RTL_CONSTASCII_USTRINGPARAM( "TextRightDistance" ) );
7524 xPropSet->setPropertyValue( sTopBorder, Any( nUpperDist ) );
7525 xPropSet->setPropertyValue( sRightBorder, Any( nRightDist ) );
7526 xPropSet->setPropertyValue( sLeftBorder, Any( nLeftDist ) );
7527 xPropSet->setPropertyValue( sBottomBorder, Any( nLowerDist ) );
7529 static const rtl::OUString sTextVerticalAdjust( RTL_CONSTASCII_USTRINGPARAM( "TextVerticalAdjust" ) );
7530 const SdrTextVertAdjust eTextVertAdjust(((const SdrTextVertAdjustItem&)pObj->GetMergedItem(SDRATTR_TEXT_VERTADJUST)).GetValue());
7531 drawing::TextVerticalAdjust eVA( drawing::TextVerticalAdjust_TOP );
7532 if ( eTextVertAdjust == SDRTEXTVERTADJUST_CENTER )
7533 eVA = drawing::TextVerticalAdjust_CENTER;
7534 else if ( eTextVertAdjust == SDRTEXTVERTADJUST_BOTTOM )
7535 eVA = drawing::TextVerticalAdjust_BOTTOM;
7536 xPropSet->setPropertyValue( sTextVerticalAdjust, Any( eVA ) );
7538 SfxItemSet aSet( pObj->GetMergedItemSet() );
7539 XFillStyle eFillStyle(((XFillStyleItem&)pObj->GetMergedItem( XATTR_FILLSTYLE )).GetValue());
7540 ::com::sun::star::drawing::FillStyle eFS( com::sun::star::drawing::FillStyle_NONE );
7541 switch( eFillStyle )
7543 case XFILL_SOLID :
7545 static const rtl::OUString sFillColor( String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ) );
7546 eFS = com::sun::star::drawing::FillStyle_SOLID;
7547 Color aFillColor( ((XFillColorItem&)pObj->GetMergedItem( XATTR_FILLCOLOR )).GetColorValue() );
7548 sal_Int32 nFillColor( aFillColor.GetColor() );
7549 xPropSet->setPropertyValue( sFillColor, Any( nFillColor ) );
7551 break;
7552 case XFILL_GRADIENT :
7554 eFS = com::sun::star::drawing::FillStyle_GRADIENT;
7555 XGradient aXGradient(((const XFillGradientItem&)pObj->GetMergedItem(XATTR_FILLGRADIENT)).GetGradientValue());
7557 com::sun::star::awt::Gradient aGradient;
7558 aGradient.Style = (awt::GradientStyle) aXGradient.GetGradientStyle();
7559 aGradient.StartColor = (INT32)aXGradient.GetStartColor().GetColor();
7560 aGradient.EndColor = (INT32)aXGradient.GetEndColor().GetColor();
7561 aGradient.Angle = (short)aXGradient.GetAngle();
7562 aGradient.Border = aXGradient.GetBorder();
7563 aGradient.XOffset = aXGradient.GetXOffset();
7564 aGradient.YOffset = aXGradient.GetYOffset();
7565 aGradient.StartIntensity = aXGradient.GetStartIntens();
7566 aGradient.EndIntensity = aXGradient.GetEndIntens();
7567 aGradient.StepCount = aXGradient.GetSteps();
7569 static const rtl::OUString sFillGradient( String( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ) ) );
7570 xPropSet->setPropertyValue( sFillGradient, Any( aGradient ) );
7572 break;
7573 case XFILL_HATCH :
7574 eFS = com::sun::star::drawing::FillStyle_HATCH;
7575 break;
7576 case XFILL_BITMAP :
7578 eFS = com::sun::star::drawing::FillStyle_BITMAP;
7580 XFillBitmapItem aXFillBitmapItem((const XFillBitmapItem&)pObj->GetMergedItem( XATTR_FILLBITMAP ));
7581 XOBitmap aLocalXOBitmap( aXFillBitmapItem.GetBitmapValue() );
7582 rtl::OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
7583 aURL += rtl::OUString::createFromAscii( aLocalXOBitmap.GetGraphicObject().GetUniqueID().GetBuffer() );
7585 static const rtl::OUString sFillBitmapURL( String( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" ) ) );
7586 xPropSet->setPropertyValue( sFillBitmapURL, Any( aURL ) );
7588 break;
7589 case XFILL_NONE :
7590 eFS = com::sun::star::drawing::FillStyle_NONE;
7591 break;
7594 static const rtl::OUString sFillStyle( String( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ) ) );
7595 xPropSet->setPropertyValue( sFillStyle, Any( eFS ) );
7596 if ( eFillStyle != XFILL_NONE )
7598 sal_Int16 nFillTransparence( ( (const XFillTransparenceItem&)pObj->GetMergedItem( XATTR_FILLTRANSPARENCE ) ).GetValue() );
7599 if ( nFillTransparence != 100 )
7601 nFillTransparence *= 100;
7602 static const rtl::OUString sFillTransparence( String( RTL_CONSTASCII_USTRINGPARAM( "FillTransparence" ) ) );
7603 xPropSet->setPropertyValue( sFillTransparence, Any( nFillTransparence ) );
7607 catch( Exception& )
7612 void ApplyCellLineAttributes( const SdrObject* pLine, Reference< XTable >& xTable, const std::vector< sal_Int32 > vPositions, sal_Int32 nColumns )
7616 SfxItemSet aSet( pLine->GetMergedItemSet() );
7617 XLineStyle eLineStyle(((XLineStyleItem&)pLine->GetMergedItem( XATTR_LINESTYLE )).GetValue());
7618 com::sun::star::table::BorderLine aBorderLine;
7619 switch( eLineStyle )
7621 case XLINE_DASH :
7622 case XLINE_SOLID :
7624 Color aLineColor( ((XLineColorItem&)pLine->GetMergedItem( XATTR_LINECOLOR )).GetColorValue() );
7625 aBorderLine.Color = aLineColor.GetColor();
7626 aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( ((const XLineWidthItem&)(pLine->GetMergedItem(XATTR_LINEWIDTH))).GetValue() );
7627 aBorderLine.InnerLineWidth = 0;
7628 aBorderLine.LineDistance = 0;
7630 break;
7631 case XLINE_NONE :
7633 aBorderLine.OuterLineWidth = 0;
7634 aBorderLine.InnerLineWidth = 0;
7635 aBorderLine.LineDistance = 0;
7637 break;
7639 Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
7640 std::vector< sal_Int32 >::const_iterator aIter( vPositions.begin() );
7641 while( aIter != vPositions.end() )
7643 static const rtl::OUString sTopBorder( String( RTL_CONSTASCII_USTRINGPARAM( "TopBorder" ) ) );
7644 static const rtl::OUString sBottomBorder( String( RTL_CONSTASCII_USTRINGPARAM( "BottomBorder" ) ) );
7645 static const rtl::OUString sLeftBorder( String( RTL_CONSTASCII_USTRINGPARAM( "LeftBorder" ) ) );
7646 static const rtl::OUString sRightBorder( String( RTL_CONSTASCII_USTRINGPARAM( "RightBorder" ) ) );
7647 static const rtl::OUString sDiagonalTLBR( RTL_CONSTASCII_USTRINGPARAM ( "DiagonalTLBR" ) );
7648 static const rtl::OUString sDiagonalBLTR( RTL_CONSTASCII_USTRINGPARAM ( "DiagonalBLTR" ) );
7650 sal_Int32 nPosition = *aIter & 0xffffff;
7651 sal_Int32 nFlags = *aIter &~0xffffff;
7652 sal_Int32 nRow = nPosition / nColumns;
7653 sal_Int32 nColumn = nPosition - ( nRow * nColumns );
7654 Reference< XCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ) );
7655 Reference< XPropertySet > xPropSet( xCell, UNO_QUERY_THROW );
7657 if ( nFlags & LinePositionLeft )
7658 xPropSet->setPropertyValue( sLeftBorder, Any( aBorderLine ) );
7659 if ( nFlags & LinePositionTop )
7660 xPropSet->setPropertyValue( sTopBorder, Any( aBorderLine ) );
7661 if ( nFlags & LinePositionRight )
7662 xPropSet->setPropertyValue( sRightBorder, Any( aBorderLine ) );
7663 if ( nFlags & LinePositionBottom )
7664 xPropSet->setPropertyValue( sBottomBorder, Any( aBorderLine ) );
7665 if ( nFlags & LinePositionTLBR )
7666 xPropSet->setPropertyValue( sDiagonalTLBR, Any( sal_True ) );
7667 if ( nFlags & LinePositionBLTR )
7668 xPropSet->setPropertyValue( sDiagonalBLTR, Any( sal_True ) );
7669 aIter++;
7672 catch( Exception& )
7677 SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, sal_uInt32* pTableArry, SvxMSDffSolverContainer* pSolverContainer ) const
7679 SdrObject* pRet = pGroup;
7680 sal_uInt32 nRows = pTableArry[ 1 ];
7681 if ( nRows && pGroup->ISA( SdrObjGroup ) )
7683 SdrObjList* pSubList(((SdrObjGroup*)pGroup)->GetSubList());
7684 if ( pSubList )
7686 std::set< sal_Int32 > aRows;
7687 std::set< sal_Int32 > aColumns;
7689 SdrObjListIter aGroupIter( *pSubList, IM_DEEPNOGROUPS, FALSE );
7690 while( aGroupIter.IsMore() )
7692 const SdrObject* pObj( aGroupIter.Next() );
7693 if ( !IsLine( pObj ) )
7695 Rectangle aSnapRect( pObj->GetSnapRect() );
7696 aRows.insert( aSnapRect.Top() );
7697 aColumns.insert( aSnapRect.Left() );
7700 ::sdr::table::SdrTableObj* pTable = new ::sdr::table::SdrTableObj( pSdrModel );
7701 pTable->uno_lock();
7702 Reference< XTable > xTable( pTable->getTable() );
7705 Reference< XColumnRowRange > xColumnRowRange( xTable, UNO_QUERY_THROW );
7707 CreateTableRows( xColumnRowRange->getRows(), aRows, pGroup->GetSnapRect().Bottom() );
7708 CreateTableColumns( xColumnRowRange->getColumns(), aColumns, pGroup->GetSnapRect().Right() );
7710 sal_Int32 nCellCount = aRows.size() * aColumns.size();
7711 sal_Int32 *pMergedCellIndexTable = new sal_Int32[ nCellCount ];
7712 for ( sal_Int32 i = 0; i < nCellCount; i++ )
7713 pMergedCellIndexTable[ i ] = i;
7715 aGroupIter.Reset();
7716 while( aGroupIter.IsMore() )
7718 SdrObject* pObj( aGroupIter.Next() );
7719 if ( !IsLine( pObj ) )
7721 Rectangle aSnapRect( pObj->GetSnapRect() );
7722 sal_Int32 nTableIndex = 0;
7723 sal_Int32 nRow = 0;
7724 sal_Int32 nRowCount = 0;
7725 sal_Int32 nColumn = 0;
7726 sal_Int32 nColumnCount = 0;
7727 if ( GetCellPosition( pObj, aRows, aColumns, nTableIndex, nRow, nRowCount, nColumn, nColumnCount ) )
7729 Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
7730 Reference< XCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ) );
7732 ApplyCellAttributes( pObj, xCell );
7734 if ( ( nRowCount > 1 ) || ( nColumnCount > 1 ) ) // cell merging
7736 MergeCells( xTable, nColumn, nRow, nColumnCount, nRowCount );
7737 for ( sal_Int32 nRowIter = 0; nRowIter < nRowCount; nRowIter++ )
7739 for ( sal_Int32 nColumnIter = 0; nColumnIter < nColumnCount; nColumnIter++ )
7740 { // now set the correct index for the merged cell
7741 pMergedCellIndexTable[ ( ( nRow + nRowIter ) * aColumns.size() ) + nColumn + nColumnIter ] = nTableIndex;
7746 // applying text
7747 OutlinerParaObject* pParaObject = pObj->GetOutlinerParaObject();
7748 if ( pParaObject )
7750 SdrText* pSdrText = pTable->getText( nTableIndex );
7751 if ( pSdrText )
7752 pSdrText->SetOutlinerParaObject(new OutlinerParaObject(*pParaObject) );
7757 aGroupIter.Reset();
7758 while( aGroupIter.IsMore() )
7760 SdrObject* pObj( aGroupIter.Next() );
7761 if ( IsLine( pObj ) )
7763 std::vector< sal_Int32 > vPositions; // containing cell indexes + cell position
7764 GetLinePositions( pObj, aRows, aColumns, vPositions, pGroup->GetSnapRect() );
7766 // correcting merged cell position
7767 std::vector< sal_Int32 >::iterator aIter( vPositions.begin() );
7768 while( aIter != vPositions.end() )
7770 sal_Int32 nOldPosition = *aIter & 0xffff;
7771 sal_Int32 nOldFlags = *aIter & 0xffff0000;
7772 sal_Int32 nNewPosition = pMergedCellIndexTable[ nOldPosition ] | nOldFlags;
7773 *aIter++ = nNewPosition;
7775 ApplyCellLineAttributes( pObj, xTable, vPositions, aColumns.size() );
7778 delete[] pMergedCellIndexTable;
7780 // we are replacing the whole group object by a single table object, so
7781 // possibly connections to the group object have to be removed.
7782 if ( pSolverContainer )
7784 for ( SvxMSDffConnectorRule* pPtr = (SvxMSDffConnectorRule*)pSolverContainer->aCList.First();
7785 pPtr; pPtr = (SvxMSDffConnectorRule*)pSolverContainer->aCList.Next() )
7787 SdrObjListIter aIter( *pGroup, IM_DEEPWITHGROUPS );
7788 while( aIter.IsMore() )
7790 SdrObject* pPartObj = aIter.Next();
7791 if ( pPtr->pAObj == pPartObj )
7792 pPtr->pAObj = NULL;
7793 if ( pPtr->pBObj == pPartObj )
7794 pPtr->pBObj = NULL;
7798 pTable->uno_unlock();
7799 pTable->SetSnapRect( pGroup->GetSnapRect() );
7800 pRet = pTable;
7801 SdrObject::Free( pGroup );
7803 catch( Exception& )
7805 pTable->uno_unlock();
7806 SdrObject* pObj = pTable;
7807 SdrObject::Free( pObj );
7811 return pRet;
7815 ////////////////////////////////////////////////////////////////////////////////////////////////////