1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <osl/endian.h>
21 #include <vcl/svapp.hxx>
22 #include <unotools/tempfile.hxx>
24 #include <editeng/eeitem.hxx>
25 #include <editeng/editdata.hxx>
26 #include <sot/storage.hxx>
27 #include <sot/storinfo.hxx>
28 #include <sot/stg.hxx>
29 #include <com/sun/star/embed/Aspects.hpp>
30 #include <com/sun/star/office/XAnnotation.hpp>
31 #include <com/sun/star/office/XAnnotationAccess.hpp>
32 #include <com/sun/star/text/XText.hpp>
33 #include <com/sun/star/geometry/RealPoint2D.hpp>
34 #include <com/sun/star/util/DateTime.hpp>
35 #include <com/sun/star/drawing/BitmapMode.hpp>
36 #include <unotools/streamwrap.hxx>
37 #include <filter/msfilter/svdfppt.hxx>
38 #include <svx/xpoly.hxx>
39 #include <svx/svdtrans.hxx>
40 #include <svx/svdmodel.hxx>
41 #include <svx/svdpage.hxx>
42 #include <svx/svdobj.hxx>
43 #include <svx/svdogrp.hxx>
44 #include <svx/svdorect.hxx>
45 #include <svx/svdopage.hxx>
46 #include <svx/svdograf.hxx>
47 #include <svx/svdopath.hxx>
48 #include <svx/svdocirc.hxx>
49 #include <svx/svdocapt.hxx>
50 #include <svx/svdotable.hxx>
51 #include <editeng/outlobj.hxx>
52 #include <editeng/numdef.hxx>
53 #include <svx/svdattr.hxx>
54 #include "svx/xattr.hxx"
55 #include <svx/svdetc.hxx>
56 #include <editeng/bulletitem.hxx>
57 #include <svx/polysc3d.hxx>
58 #include <svx/extrud3d.hxx>
59 #include <svx/svdoashp.hxx>
60 #include <editeng/tstpitem.hxx>
61 #include <editeng/unoprnms.hxx>
62 #include <editeng/editids.hrc>
64 #include <editeng/adjustitem.hxx>
65 #include <editeng/escapementitem.hxx>
66 #include <editeng/colritem.hxx>
67 #include <editeng/fhgtitem.hxx>
68 #include <editeng/wghtitem.hxx>
69 #include <editeng/postitem.hxx>
70 #include <editeng/udlnitem.hxx>
71 #include <editeng/crossedoutitem.hxx>
72 #include <editeng/shdditem.hxx>
73 #include <editeng/charreliefitem.hxx>
74 #include <editeng/fontitem.hxx>
75 #include <svx/svdoutl.hxx>
76 #include <editeng/editeng.hxx>
77 #include <editeng/lspcitem.hxx>
78 #include <editeng/ulspitem.hxx>
79 #include <editeng/lrspitem.hxx>
80 #include <vcl/metric.hxx>
81 #include <vcl/bmpacc.hxx>
82 #include <svx/svditer.hxx>
83 #include <svx/svdoedge.hxx>
84 #include <svx/sxekitm.hxx>
85 #include <editeng/flditem.hxx>
86 #include <tools/zcodec.hxx>
87 #include <filter/msfilter/svxmsbas.hxx>
88 #include <sfx2/objsh.hxx>
89 #include <editeng/brushitem.hxx>
90 #include <editeng/langitem.hxx>
91 #include <svx/svdoole2.hxx>
92 #include <svx/unoapi.hxx>
93 #include <toolkit/unohlp.hxx>
94 #include <com/sun/star/container/XIndexContainer.hpp>
95 #include <com/sun/star/drawing/XShapes.hpp>
96 #include <com/sun/star/drawing/XControlShape.hpp>
97 #include <com/sun/star/form/XFormComponent.hpp>
98 #include <com/sun/star/beans/XPropertySet.hpp>
99 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
100 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
101 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
102 #include <com/sun/star/awt/Size.hpp>
103 #include <com/sun/star/awt/Point.hpp>
104 #include <com/sun/star/drawing/FillStyle.hpp>
105 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
106 #include <editeng/writingmodeitem.hxx>
107 #include <vcl/print.hxx>
108 #include <editeng/svxfont.hxx>
109 #include <editeng/frmdiritem.hxx>
110 #include <svx/sdtfchim.hxx>
111 #include <unotools/ucbstreamhelper.hxx>
112 #include <editeng/scripttypeitem.hxx>
113 #include "com/sun/star/awt/Gradient.hpp"
114 #include <com/sun/star/table/XMergeableCellRange.hpp>
115 #include <com/sun/star/table/BorderLine2.hpp>
116 #include <com/sun/star/table/BorderLineStyle.hpp>
117 #include <vcl/virdev.hxx>
120 #include <rtl/strbuf.hxx>
121 #include <tools/time.hxx>
123 // PPT ColorScheme Slots
124 #define PPT_COLSCHEME (0x08000000)
125 #define PPT_COLSCHEME_HINTERGRUND (0x08000000)
126 #define PPT_COLSCHEME_TEXT_UND_ZEILEN (0x08000001)
127 #define PPT_COLSCHEME_TITELTEXT (0x08000003)
128 #define PPT_COLSCHEME_A_UND_HYPERLINK (0x08000006)
130 #define ANSI_CHARSET 0
131 #define SYMBOL_CHARSET 2
134 #define FF_ROMAN 0x10
135 #define FF_SWISS 0x20
136 #define FF_MODERN 0x30
137 #define FF_SCRIPT 0x40
138 #define FF_DECORATIVE 0x50
140 #define DEFAULT_PITCH 0x00
141 #define FIXED_PITCH 0x01
142 #define VARIABLE_PITCH 0x02
144 using namespace ::com::sun::star
;
145 using namespace uno
;
146 using namespace beans
;
147 using namespace drawing
;
148 using namespace container
;
149 using namespace table
;
151 PowerPointImportParam::PowerPointImportParam( SvStream
& rDocStrm
, sal_uInt32 nFlags
) :
152 rDocStream ( rDocStrm
),
153 nImportFlags ( nFlags
)
157 SvStream
& operator>>( SvStream
& rIn
, PptCurrentUserAtom
& rAtom
)
161 if ( aHd
.nRecType
== PPT_PST_CurrentUserAtom
)
164 sal_uInt16 nUserNameLen
, nPad
;
167 >> rAtom
.nCurrentUserEdit
169 >> rAtom
.nDocFileVersion
170 >> rAtom
.nMajorVersion
171 >> rAtom
.nMinorVersion
173 rAtom
.aCurrentUser
= SvxMSDffManager::MSDFFReadZString( rIn
, nUserNameLen
, sal_True
);
175 aHd
.SeekToEndOfRecord( rIn
);
179 void PptSlidePersistAtom::Clear()
181 nReserved
= nPsrReference
= nFlags
= nNumberTexts
= nSlideId
= 0;
184 SvStream
& operator>>( SvStream
& rIn
, PptSlidePersistAtom
& rAtom
)
188 >> rAtom
.nPsrReference
190 >> rAtom
.nNumberTexts
192 aHd
.SeekToEndOfRecord( rIn
);
196 sal_uInt16
PptSlidePersistList::FindPage(sal_uInt32 nId
) const
198 for ( sal_uInt16 i
=0; i
< size(); i
++ )
200 if (operator[](i
)->GetSlideId()==nId
) return i
;
202 return PPTSLIDEPERSIST_ENTRY_NOTFOUND
;
205 SvStream
& operator>>( SvStream
& rIn
, PptInteractiveInfoAtom
& rAtom
)
207 rIn
>> rAtom
.nSoundRef
208 >> rAtom
.nExHyperlinkId
213 >> rAtom
.nHyperlinkType
220 SvStream
& operator>>( SvStream
& rIn
, PptExOleObjAtom
& rAtom
)
235 Size
PptDocumentAtom::GetPageSize(const Size
& rSiz
) const
240 SvStream
& operator>>(SvStream
& rIn
, PptDocumentAtom
& rAtom
)
243 // 00 aSlidePageSizeXY 8
244 // 08 aNotesPageSizeXY 8
245 // 16 aZoomRatio (OLE) 8
246 // 24 nNotesMasterPersist 4
247 // 28 nHandoutMasterPersist 4
248 // 32 n1stPageNumber 2
250 // 36 bEmbeddedTrueType 1
251 // 37 bOmitTitlePlace 1
253 // 39 bShowComments 1
256 sal_Int32 nSlideX
,nSlideY
, nNoticeX
, nNoticeY
, nDummy
;
257 sal_uInt16 nSlidePageFormat
;
258 sal_Int8 nEmbeddedTrueType
, nTitlePlaceHoldersOmitted
, nRightToLeft
, nShowComments
;
261 >> nSlideX
>> nSlideY
262 >> nNoticeX
>> nNoticeY
263 >> nDummy
>> nDummy
// skip ZoomRation
264 >> rAtom
.nNotesMasterPersist
265 >> rAtom
.nHandoutMasterPersist
266 >> rAtom
.n1stPageNumber
269 >> nTitlePlaceHoldersOmitted
272 rAtom
.aSlidesPageSize
.Width() = nSlideX
;
273 rAtom
.aSlidesPageSize
.Height() = nSlideY
;
274 rAtom
.aNotesPageSize
.Width() = nNoticeX
;
275 rAtom
.aNotesPageSize
.Height() = nNoticeY
;
276 rAtom
.eSlidesPageFormat
= (PptPageFormat
)nSlidePageFormat
;
277 rAtom
.bEmbeddedTrueType
= nEmbeddedTrueType
;
278 rAtom
.bTitlePlaceholdersOmitted
= nTitlePlaceHoldersOmitted
;
279 rAtom
.bRightToLeft
= nRightToLeft
;
280 rAtom
.bShowComments
= nShowComments
;
281 aHd
.SeekToEndOfRecord( rIn
);
285 void PptSlideLayoutAtom::Clear()
288 for ( sal_uInt16 i
= 0; i
< 8; i
++ )
289 aPlaceholderId
[ i
] = 0;
292 SvStream
& operator>>( SvStream
& rIn
, PptSlideLayoutAtom
& rAtom
)
294 rIn
>> rAtom
.eLayout
;
295 rIn
.Read( rAtom
.aPlaceholderId
, 8 );
299 SvStream
& operator>>( SvStream
& rIn
, PptSlideAtom
& rAtom
)
307 aHd
.SeekToEndOfRecord( rIn
);
311 void PptSlideAtom::Clear()
313 nMasterId
= nNotesId
= 0;
317 SvStream
& operator>>( SvStream
& rIn
, PptNotesAtom
& rAtom
)
323 aHd
.SeekToEndOfRecord( rIn
);
327 void PptNotesAtom::Clear()
333 void PptColorSchemeAtom::Clear()
335 memset(&aData
[0], 0, 32);
338 Color
PptColorSchemeAtom::GetColor( sal_uInt16 nNum
) const
344 aRetval
.SetRed( aData
[ nNum
++ ] );
345 aRetval
.SetGreen( aData
[ nNum
++ ] );
346 aRetval
.SetBlue( aData
[ nNum
++ ] );
351 SvStream
& operator>>( SvStream
& rIn
, PptColorSchemeAtom
& rAtom
)
355 rIn
.Read( rAtom
.aData
, 32 );
356 aHd
.SeekToEndOfRecord( rIn
);
360 SvStream
& operator>>( SvStream
& rIn
, PptFontEntityAtom
& rAtom
)
364 sal_Unicode nTemp
, cData
[ 32 ];
365 rIn
.Read( cData
, 64 );
367 sal_uInt8 lfCharset
, lfPitchAndFamily
;
370 >> rAtom
.lfClipPrecision
376 case SYMBOL_CHARSET
:
377 rAtom
.eCharSet
= RTL_TEXTENCODING_SYMBOL
;
380 rAtom
.eCharSet
= RTL_TEXTENCODING_MS_1252
;
384 rAtom
.eCharSet
= osl_getThreadTextEncoding();
386 switch ( lfPitchAndFamily
& 0xf0 )
389 rAtom
.eFamily
= FAMILY_ROMAN
;
393 rAtom
.eFamily
= FAMILY_SWISS
;
397 rAtom
.eFamily
= FAMILY_MODERN
;
401 rAtom
.eFamily
= FAMILY_SCRIPT
;
405 rAtom
.eFamily
= FAMILY_DECORATIVE
;
409 rAtom
.eFamily
= FAMILY_DONTKNOW
;
413 switch ( lfPitchAndFamily
& 0x0f )
416 rAtom
.ePitch
= PITCH_FIXED
;
422 rAtom
.ePitch
= PITCH_VARIABLE
;
426 for ( i
= 0; i
< 32; i
++ )
432 cData
[ i
] = ( nTemp
>> 8 ) | ( nTemp
<< 8 );
435 rAtom
.aName
= OUString(cData
, i
);
436 OutputDevice
* pDev
= (OutputDevice
*)Application::GetDefaultDevice();
437 rAtom
.bAvailable
= pDev
->IsFontAvailable( rAtom
.aName
);
438 aHd
.SeekToEndOfRecord( rIn
);
442 class PptFontCollection
: public boost::ptr_vector
<PptFontEntityAtom
> {
445 SvStream
& operator>>( SvStream
& rIn
, PptUserEditAtom
& rAtom
)
448 >> rAtom
.nLastSlideID
450 >> rAtom
.nOffsetLastEdit
451 >> rAtom
.nOffsetPersistDirectory
452 >> rAtom
.nDocumentRef
453 >> rAtom
.nMaxPersistWritten
454 >> rAtom
.eLastViewType
;
455 rAtom
.aHd
.SeekToEndOfRecord(rIn
);
459 void PptOEPlaceholderAtom::Clear()
462 nPlaceholderSize
= nPlaceholderId
= 0;
465 SvStream
& operator>>( SvStream
& rIn
, PptOEPlaceholderAtom
& rAtom
)
467 rIn
>> rAtom
.nPlacementId
468 >> rAtom
.nPlaceholderId
469 >> rAtom
.nPlaceholderSize
;
473 PptSlidePersistEntry::PptSlidePersistEntry() :
474 pStyleSheet ( NULL
),
475 pHeaderFooterEntry ( NULL
),
476 pSolverContainer ( NULL
),
477 nSlidePersistStartOffset( 0 ),
478 nSlidePersistEndOffset ( 0 ),
479 nBackgroundOffset ( 0 ),
480 nDrawingDgId ( 0xffffffff ),
481 pPresentationObjects ( NULL
),
483 bBObjIsTemporary ( sal_True
),
484 ePageKind ( PPT_MASTERPAGE
),
485 bNotesMaster ( sal_False
),
486 bHandoutMaster ( sal_False
),
487 bStarDrawFiller ( sal_False
)
489 HeaderFooterOfs
[ 0 ] = HeaderFooterOfs
[ 1 ] = HeaderFooterOfs
[ 2 ] = HeaderFooterOfs
[ 3 ] = 0;
493 PptSlidePersistEntry::~PptSlidePersistEntry()
496 delete pHeaderFooterEntry
;
497 delete pSolverContainer
;
498 delete[] pPresentationObjects
;
501 SdrEscherImport::SdrEscherImport( PowerPointImportParam
& rParam
, const OUString
& rBaseURL
) :
502 SvxMSDffManager ( rParam
.rDocStream
, rBaseURL
),
505 nTextStylesIndex ( 0xffff ),
506 eCharSetSystem ( osl_getThreadTextEncoding() ),
507 bWingdingsChecked ( sal_False
),
508 bWingdingsAvailable ( sal_False
),
509 bMonotypeSortsChecked ( sal_False
),
510 bMonotypeSortsAvailable ( sal_False
),
511 bTimesNewRomanChecked ( sal_False
),
512 bTimesNewRomanAvailable ( sal_False
),
513 rImportParam ( rParam
)
517 SdrEscherImport::~SdrEscherImport()
519 for ( size_t i
= 0, n
= aOleObjectList
.size(); i
< n
; ++i
)
520 delete aOleObjectList
[ i
];
521 aOleObjectList
.clear();
525 const PptSlideLayoutAtom
* SdrEscherImport::GetSlideLayoutAtom() const
530 sal_Bool
SdrEscherImport::ReadString( OUString
& rStr
) const
532 sal_Bool bRet
= sal_False
;
533 DffRecordHeader aStrHd
;
535 if (aStrHd
.nRecType
== PPT_PST_TextBytesAtom
536 || aStrHd
.nRecType
== PPT_PST_TextCharsAtom
537 || aStrHd
.nRecType
== PPT_PST_CString
)
540 (aStrHd
.nRecType
== PPT_PST_TextCharsAtom
541 || aStrHd
.nRecType
== PPT_PST_CString
);
543 sal_uLong nBytes
= aStrHd
.nRecLen
;
544 rStr
= MSDFFReadZString( rStCtrl
, nBytes
, bUniCode
);
545 aStrHd
.SeekToEndOfRecord( rStCtrl
);
548 aStrHd
.SeekToBegOfRecord( rStCtrl
);
552 bool SdrEscherImport::GetColorFromPalette(sal_uInt16
/*nNum*/, Color
& /*rColor*/) const
557 sal_Bool
SdrEscherImport::SeekToShape( SvStream
& /*rSt*/, void* /*pClientData*/, sal_uInt32
/*nId*/) const
562 PptFontEntityAtom
* SdrEscherImport::GetFontEnityAtom( sal_uInt32 nNum
) const
564 PptFontEntityAtom
* pRetValue
= NULL
;
565 if ( pFonts
&& ( nNum
< pFonts
->size() ) )
566 pRetValue
= &(*pFonts
)[ (sal_uInt16
)nNum
];
570 SdrObject
* SdrEscherImport::ReadObjText( PPTTextObj
* /*pTextObj*/, SdrObject
* pObj
, SdPage
* /*pPage*/) const
575 void SdrEscherImport::ProcessClientAnchor2( SvStream
& rSt
, DffRecordHeader
& rHd
, void* /*pData*/, DffObjData
& rObj
)
577 sal_Int32 l
, t
, r
, b
;
578 if ( rHd
.nRecLen
== 16 )
580 rSt
>> l
>> t
>> r
>> b
;
584 sal_Int16 ls
, ts
, rs
, bs
;
585 rSt
>> ts
>> ls
>> rs
>> bs
; // the order of coordinates is a bit strange...
586 l
= ls
, t
= ts
, r
= rs
, b
= bs
;
592 rObj
.aChildAnchor
= Rectangle( l
, t
, r
, b
);
593 rObj
.bChildAnchor
= sal_True
;
597 void SdrEscherImport::RecolorGraphic( SvStream
& rSt
, sal_uInt32 nRecLen
, Graphic
& rGraphic
)
599 if ( rGraphic
.GetType() == GRAPHIC_GDIMETAFILE
)
601 sal_uInt16 nX
, nGlobalColorsCount
, nFillColorsCount
;
604 >> nGlobalColorsCount
610 if ( ( nGlobalColorsCount
<= 64 ) && ( nFillColorsCount
<= 64 ) )
612 if ( (sal_uInt32
)( ( nGlobalColorsCount
+ nFillColorsCount
) * 44 + 12 ) == nRecLen
)
614 sal_uInt32 OriginalGlobalColors
[ 64 ];
615 sal_uInt32 NewGlobalColors
[ 64 ];
616 sal_uInt32 OriginalFillColors
[ 64 ];
617 sal_uInt32 NewFillColors
[ 64 ];
619 sal_uInt32 i
, j
, nGlobalColorsChanged
, nFillColorsChanged
;
620 nGlobalColorsChanged
= nFillColorsChanged
= 0;
622 sal_uInt32
* pCurrentOriginal
= OriginalGlobalColors
;
623 sal_uInt32
* pCurrentNew
= NewGlobalColors
;
624 sal_uInt32
* pCount
= &nGlobalColorsChanged
;
625 i
= nGlobalColorsCount
;
627 for ( j
= 0; j
< 2; j
++ )
631 sal_uInt32 nIndex
, nPos
= rSt
.Tell();
632 sal_uInt8 nDummy
, nRed
, nGreen
, nBlue
;
637 sal_uInt32 nColor
= 0;
648 Color aColor
= MSO_CLR_ToColor( nIndex
<< 24 );
649 nRed
= aColor
.GetRed();
650 nGreen
= aColor
.GetGreen();
651 nBlue
= aColor
.GetBlue();
653 nColor
= nRed
| ( nGreen
<< 8 ) | ( nBlue
<< 16 );
654 *pCurrentNew
++ = nColor
;
661 nColor
= nRed
| ( nGreen
<< 8 ) | ( nBlue
<< 16 );
662 *pCurrentOriginal
++ = nColor
;
665 rSt
.Seek( nPos
+ 44 );
667 pCurrentOriginal
= OriginalFillColors
;
668 pCurrentNew
= NewFillColors
;
669 pCount
= &nFillColorsChanged
;
670 i
= nFillColorsCount
;
672 if ( nGlobalColorsChanged
|| nFillColorsChanged
)
674 Color
* pSearchColors
= new Color
[ nGlobalColorsChanged
];
675 Color
* pReplaceColors
= new Color
[ nGlobalColorsChanged
];
677 for ( j
= 0; j
< nGlobalColorsChanged
; j
++ )
679 sal_uInt32 nSearch
= OriginalGlobalColors
[ j
];
680 sal_uInt32 nReplace
= NewGlobalColors
[ j
];
682 pSearchColors
[ j
].SetRed( (sal_uInt8
)nSearch
);
683 pSearchColors
[ j
].SetGreen( (sal_uInt8
)( nSearch
>> 8 ) );
684 pSearchColors
[ j
].SetBlue( (sal_uInt8
)( nSearch
>> 16 ) );
686 pReplaceColors
[ j
].SetRed( (sal_uInt8
)nReplace
);
687 pReplaceColors
[ j
].SetGreen( (sal_uInt8
)( nReplace
>> 8 ) );
688 pReplaceColors
[ j
].SetBlue( (sal_uInt8
)( nReplace
>> 16 ) );
690 GDIMetaFile
aGdiMetaFile( rGraphic
.GetGDIMetaFile() );
691 aGdiMetaFile
.ReplaceColors( pSearchColors
, pReplaceColors
,
692 nGlobalColorsChanged
, NULL
);
693 rGraphic
= aGdiMetaFile
;
695 delete[] pSearchColors
;
696 delete[] pReplaceColors
;
703 /* ProcessObject is called from ImplSdPPTImport::ProcessObj to hanlde all application specific things,
704 such as the import of text, animation effects, header footer and placeholder.
706 The parameter pOriginalObj is the object as it was imported by our general escher import, it must either
707 be deleted or it can be returned to be inserted into the sdr page.
709 SdrObject
* SdrEscherImport::ProcessObj( SvStream
& rSt
, DffObjData
& rObjData
, void* pData
, Rectangle
& rTextRect
, SdrObject
* pOriginalObj
)
711 if ( pOriginalObj
&& pOriginalObj
->ISA( SdrObjCustomShape
) )
712 pOriginalObj
->SetMergedItem( SdrTextFixedCellHeightItem( sal_True
) );
714 // we are initializing our return value with the object that was imported by our escher import
715 SdrObject
* pRet
= pOriginalObj
;
717 ProcessData
& rData
= *((ProcessData
*)pData
);
718 PptSlidePersistEntry
& rPersistEntry
= rData
.rPersistEntry
;
720 if ( ! ( rObjData
.nSpFlags
& SP_FGROUP
) ) // sj: #114758# ...
722 PptOEPlaceholderAtom aPlaceholderAtom
;
724 if ( maShapeRecords
.SeekToContent( rSt
, DFF_msofbtClientData
, SEEK_FROM_CURRENT_AND_RESTART
) )
726 sal_Int16 nHeaderFooterInstance
= -1;
727 DffRecordHeader aClientDataHd
;
728 while ( ( rSt
.GetError() == 0 ) && ( rSt
.Tell() < maShapeRecords
.Current()->GetRecEndFilePos() ) )
730 rSt
>> aClientDataHd
;
731 switch ( aClientDataHd
.nRecType
)
733 // importing header/footer object from master page
734 case PPT_PST_OEPlaceholderAtom
:
736 rSt
>> aPlaceholderAtom
;
737 if ( nHeaderFooterInstance
== -1 )
739 switch ( aPlaceholderAtom
.nPlaceholderId
)
741 case PPT_PLACEHOLDER_MASTERSLIDENUMBER
: nHeaderFooterInstance
++;
742 case PPT_PLACEHOLDER_MASTERFOOTER
: nHeaderFooterInstance
++;
743 case PPT_PLACEHOLDER_MASTERHEADER
: nHeaderFooterInstance
++;
744 case PPT_PLACEHOLDER_MASTERDATE
: nHeaderFooterInstance
++; break;
746 if ( ! ( nHeaderFooterInstance
& 0xfffc ) ) // is this a valid instance ( 0->3 )
747 rPersistEntry
.HeaderFooterOfs
[ nHeaderFooterInstance
] = rObjData
.rSpHd
.GetRecBegFilePos();
752 case PPT_PST_RecolorInfoAtom
:
754 if ( pRet
&& ( pRet
->ISA( SdrGrafObj
) && ((SdrGrafObj
*)pRet
)->HasGDIMetaFile() ) )
756 Graphic
aGraphic( ((SdrGrafObj
*)pRet
)->GetGraphic() );
757 RecolorGraphic( rSt
, aClientDataHd
.nRecLen
, aGraphic
);
758 ((SdrGrafObj
*)pRet
)->SetGraphic( aGraphic
);
763 aClientDataHd
.SeekToEndOfRecord( rSt
);
766 if ( ( aPlaceholderAtom
.nPlaceholderId
== PPT_PLACEHOLDER_NOTESSLIDEIMAGE
) && ( rPersistEntry
.bNotesMaster
== sal_False
) )
768 sal_uInt16 nPageNum
= pSdrModel
->GetPageCount();
772 // replacing the object which we will return with a SdrPageObj
773 SdrObject::Free( pRet
);
774 pRet
= new SdrPageObj( rObjData
.aBoundRect
, pSdrModel
->GetPage( nPageNum
- 1 ) );
778 // try to load some ppt text
779 PPTTextObj
aTextObj( rSt
, (SdrPowerPointImport
&)*this, rPersistEntry
, &rObjData
);
780 if ( ( aTextObj
.Count() || aTextObj
.GetOEPlaceHolderAtom() ) )
782 sal_Bool bVerticalText
= sal_False
;
783 // and if the text object is not empty, it must be applied to pRet, the object we
784 // initially got from our escher import
785 sal_Int32 nTextRotationAngle
= 0;
786 if ( IsProperty( DFF_Prop_txflTextFlow
) )
788 MSO_TextFlow eTextFlow
= (MSO_TextFlow
)( GetPropertyValue( DFF_Prop_txflTextFlow
) & 0xFFFF );
791 case mso_txflBtoT
: // Bottom to Top non-@, unten -> oben
792 nTextRotationAngle
+= 9000;
794 case mso_txflTtoBA
: /* #68110# */ // Top to Bottom @-font, oben -> unten
795 case mso_txflTtoBN
: // Top to Bottom non-@, oben -> unten
796 case mso_txflVertN
: // Vertical, non-@, oben -> unten
797 bVerticalText
= !bVerticalText
; // nTextRotationAngle += 27000;
799 // case mso_txflHorzN : // Horizontal non-@, normal
800 // case mso_txflHorzA : // Horizontal @-font, normal
804 sal_Int32 nFontDirection
= GetPropertyValue( DFF_Prop_cdirFont
, mso_cdir0
);
805 nTextRotationAngle
-= nFontDirection
* 9000;
806 if ( ( nFontDirection
== 1 ) || ( nFontDirection
== 3 ) ) // #104546#
808 bVerticalText
= !bVerticalText
;
810 aTextObj
.SetVertical( bVerticalText
);
813 sal_Bool bDeleteSource
= aTextObj
.GetOEPlaceHolderAtom() != 0;
814 if ( bDeleteSource
&& ( pRet
->ISA( SdrGrafObj
) == sal_False
) // we are not allowed to get
815 && ( pRet
->ISA( SdrObjGroup
) == sal_False
) // grouped placeholder objects
816 && ( pRet
->ISA( SdrOle2Obj
) == sal_False
) )
817 SdrObject::Free( pRet
);
819 sal_uInt32 nTextFlags
= aTextObj
.GetTextFlags();
820 sal_Int32 nTextLeft
= GetPropertyValue( DFF_Prop_dxTextLeft
, 25 * 3600 ); // 0.25 cm (emu)
821 sal_Int32 nTextRight
= GetPropertyValue( DFF_Prop_dxTextRight
, 25 * 3600 ); // 0.25 cm (emu)
822 sal_Int32 nTextTop
= GetPropertyValue( DFF_Prop_dyTextTop
, 13 * 3600 ); // 0.13 cm (emu)
823 sal_Int32 nTextBottom
= GetPropertyValue( DFF_Prop_dyTextBottom
, 13 * 3600 );
824 ScaleEmu( nTextLeft
);
825 ScaleEmu( nTextRight
);
826 ScaleEmu( nTextTop
);
827 ScaleEmu( nTextBottom
);
829 sal_Int32 nMinFrameWidth
= 0;
830 sal_Int32 nMinFrameHeight
= 0;
831 sal_Bool bAutoGrowWidth
, bAutoGrowHeight
;
833 SdrTextVertAdjust eTVA
;
834 SdrTextHorzAdjust eTHA
;
836 nTextFlags
&= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT
| PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT
837 | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER
| PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK
;
841 eTVA
= SDRTEXTVERTADJUST_BLOCK
;
842 eTHA
= SDRTEXTHORZADJUST_CENTER
;
845 MSO_Anchor eTextAnchor
= (MSO_Anchor
)GetPropertyValue( DFF_Prop_anchorText
, mso_anchorTop
);
847 switch( eTextAnchor
)
850 case mso_anchorTopCentered
:
851 case mso_anchorTopBaseline
:
852 case mso_anchorTopCenteredBaseline
:
853 eTHA
= SDRTEXTHORZADJUST_RIGHT
;
856 case mso_anchorMiddle
:
857 case mso_anchorMiddleCentered
:
858 eTHA
= SDRTEXTHORZADJUST_CENTER
;
861 case mso_anchorBottom
:
862 case mso_anchorBottomCentered
:
863 case mso_anchorBottomBaseline
:
864 case mso_anchorBottomCenteredBaseline
:
865 eTHA
= SDRTEXTHORZADJUST_LEFT
;
868 // if there is a 100% use of following attributes, the textbox can been aligned also in vertical direction
869 switch ( eTextAnchor
)
871 case mso_anchorTopCentered
:
872 case mso_anchorMiddleCentered
:
873 case mso_anchorBottomCentered
:
874 case mso_anchorTopCenteredBaseline
:
875 case mso_anchorBottomCenteredBaseline
:
877 // check if it is sensible to use the centered alignment
878 sal_uInt32 nMask
= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT
| PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT
;
879 if ( ( nTextFlags
& nMask
) != nMask
) // if the textobject has left and also right aligned pararagraphs
880 eTVA
= SDRTEXTVERTADJUST_CENTER
; // the text has to be displayed using the full width;
886 if ( nTextFlags
== PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT
)
887 eTVA
= SDRTEXTVERTADJUST_TOP
;
888 else if ( nTextFlags
== PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT
)
889 eTVA
= SDRTEXTVERTADJUST_BOTTOM
;
893 nMinFrameWidth
= rTextRect
.GetWidth() - ( nTextLeft
+ nTextRight
);
897 eTVA
= SDRTEXTVERTADJUST_CENTER
;
898 eTHA
= SDRTEXTHORZADJUST_BLOCK
;
901 MSO_Anchor eTextAnchor
= (MSO_Anchor
)GetPropertyValue( DFF_Prop_anchorText
, mso_anchorTop
);
903 switch( eTextAnchor
)
906 case mso_anchorTopCentered
:
907 case mso_anchorTopBaseline
:
908 case mso_anchorTopCenteredBaseline
:
909 eTVA
= SDRTEXTVERTADJUST_TOP
;
912 case mso_anchorMiddle
:
913 case mso_anchorMiddleCentered
:
914 eTVA
= SDRTEXTVERTADJUST_CENTER
;
917 case mso_anchorBottom
:
918 case mso_anchorBottomCentered
:
919 case mso_anchorBottomBaseline
:
920 case mso_anchorBottomCenteredBaseline
:
921 eTVA
= SDRTEXTVERTADJUST_BOTTOM
;
924 // if there is a 100% usage of following attributes, the textbox can be aligned also in horizontal direction
925 switch ( eTextAnchor
)
927 case mso_anchorTopCentered
:
928 case mso_anchorMiddleCentered
:
929 case mso_anchorBottomCentered
:
930 case mso_anchorTopCenteredBaseline
:
931 case mso_anchorBottomCenteredBaseline
:
933 // check if it is sensible to use the centered alignment
934 sal_uInt32 nMask
= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT
| PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT
;
935 if ( ( nTextFlags
& nMask
) != nMask
) // if the textobject has left and also right aligned pararagraphs
936 eTHA
= SDRTEXTHORZADJUST_CENTER
; // the text has to be displayed using the full width;
942 if ( nTextFlags
== PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT
)
943 eTHA
= SDRTEXTHORZADJUST_LEFT
;
944 else if ( nTextFlags
== PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT
)
945 eTHA
= SDRTEXTHORZADJUST_RIGHT
;
949 nMinFrameHeight
= rTextRect
.GetHeight() - ( nTextTop
+ nTextBottom
);
952 SdrObjKind eTextKind
= OBJ_RECT
;
953 if ( ( aPlaceholderAtom
.nPlaceholderId
== PPT_PLACEHOLDER_NOTESSLIDEIMAGE
)
954 || ( aPlaceholderAtom
.nPlaceholderId
== PPT_PLACEHOLDER_MASTERNOTESSLIDEIMAGE
) )
956 aTextObj
.SetInstance( 2 );
957 eTextKind
= OBJ_TITLETEXT
;
959 else if ( ( aPlaceholderAtom
.nPlaceholderId
== PPT_PLACEHOLDER_MASTERNOTESBODYIMAGE
)
960 || ( aPlaceholderAtom
.nPlaceholderId
== PPT_PLACEHOLDER_NOTESBODY
) )
962 aTextObj
.SetInstance( 2 );
963 eTextKind
= OBJ_TEXT
;
966 sal_uInt32 nDestinationInstance
= aTextObj
.GetInstance();
967 if ( rPersistEntry
.ePageKind
== PPT_MASTERPAGE
)
969 if ( !rPersistEntry
.pPresentationObjects
)
971 rPersistEntry
.pPresentationObjects
= new sal_uInt32
[ PPT_STYLESHEETENTRYS
];
972 memset( rPersistEntry
.pPresentationObjects
, 0, PPT_STYLESHEETENTRYS
* 4 );
974 if ( !rPersistEntry
.pPresentationObjects
[ nDestinationInstance
] )
975 rPersistEntry
.pPresentationObjects
[ nDestinationInstance
] = rObjData
.rSpHd
.GetRecBegFilePos();
977 switch ( nDestinationInstance
)
979 case TSS_TYPE_PAGETITLE
:
980 case TSS_TYPE_TITLE
:
982 if ( GetSlideLayoutAtom()->eLayout
== PPT_LAYOUT_TITLEMASTERSLIDE
)
983 nDestinationInstance
= TSS_TYPE_TITLE
;
985 nDestinationInstance
= TSS_TYPE_PAGETITLE
;
989 case TSS_TYPE_HALFBODY
:
990 case TSS_TYPE_QUARTERBODY
:
991 nDestinationInstance
= TSS_TYPE_BODY
;
994 aTextObj
.SetDestinationInstance( (sal_uInt16
)nDestinationInstance
);
996 bool bAutoFit
= false; // auto-scale text into shape box
997 switch ( aTextObj
.GetInstance() )
999 case TSS_TYPE_PAGETITLE
:
1000 case TSS_TYPE_TITLE
: eTextKind
= OBJ_TITLETEXT
; break;
1001 case TSS_TYPE_SUBTITLE
: eTextKind
= OBJ_TEXT
; break;
1002 case TSS_TYPE_BODY
:
1003 case TSS_TYPE_HALFBODY
:
1004 case TSS_TYPE_QUARTERBODY
: eTextKind
= OBJ_OUTLINETEXT
; bAutoFit
= true; break;
1006 if ( aTextObj
.GetDestinationInstance() != TSS_TYPE_TEXT_IN_SHAPE
)
1008 if ( !aTextObj
.GetOEPlaceHolderAtom() || !aTextObj
.GetOEPlaceHolderAtom()->nPlaceholderId
)
1010 aTextObj
.SetDestinationInstance( TSS_TYPE_TEXT_IN_SHAPE
);
1011 eTextKind
= OBJ_RECT
;
1014 SdrObject
* pTObj
= NULL
;
1015 sal_Bool bWordWrap
= (MSO_WrapMode
)GetPropertyValue( DFF_Prop_WrapText
, mso_wrapSquare
) != mso_wrapNone
;
1016 sal_Bool bFitShapeToText
= ( GetPropertyValue( DFF_Prop_FitTextToShape
) & 2 ) != 0;
1018 if ( pRet
&& pRet
->ISA( SdrObjCustomShape
) && ( eTextKind
== OBJ_RECT
) )
1020 bAutoGrowHeight
= bFitShapeToText
;
1022 bAutoGrowWidth
= sal_False
;
1024 bAutoGrowWidth
= sal_True
;
1030 if ( pRet
&& pRet
->ISA( SdrObjCustomShape
) )
1032 SdrObject::Free( pRet
);
1035 pTObj
= new SdrRectObj( eTextKind
!= OBJ_RECT
? eTextKind
: OBJ_TEXT
);
1036 pTObj
->SetModel( pSdrModel
);
1037 SfxItemSet
aSet( pSdrModel
->GetItemPool() );
1039 ((SdrEscherImport
*)this)->ApplyAttributes( rSt
, aSet
, rObjData
);
1040 pTObj
->SetMergedItemSet( aSet
);
1043 pTObj
->SetMergedItem( XLineStyleItem( XLINE_NONE
) );
1044 pTObj
->SetMergedItem( XFillStyleItem( XFILL_NONE
) );
1046 if ( bVerticalText
)
1048 bAutoGrowWidth
= bFitShapeToText
;
1049 bAutoGrowHeight
= sal_False
;
1053 bAutoGrowWidth
= sal_False
;
1055 // #119885# re-activationg bFitShapeToText here, could not find deeper explanations
1056 // for it (it was from 2005). Keeping the old comment here for reference
1057 // old comment: // bFitShapeToText; can't be used, because we cut the text if it is too height,
1058 bAutoGrowHeight
= bFitShapeToText
;
1061 pTObj
->SetMergedItem( SvxFrameDirectionItem( bVerticalText
? FRMDIR_VERT_TOP_RIGHT
: FRMDIR_HORI_LEFT_TOP
, EE_PARA_WRITINGDIR
) );
1063 //Autofit text only if there is no auto grow height and width
1065 if (bAutoFit
&& !bAutoGrowHeight
&& !bAutoGrowWidth
)
1067 pTObj
->SetMergedItem( SdrTextFitToSizeTypeItem(SDRTEXTFIT_AUTOFIT
) );
1070 if ( !pTObj
->ISA( SdrObjCustomShape
) )
1072 pTObj
->SetMergedItem( SdrTextAutoGrowWidthItem( bAutoGrowWidth
) );
1073 pTObj
->SetMergedItem( SdrTextAutoGrowHeightItem( bAutoGrowHeight
) );
1077 pTObj
->SetMergedItem( SdrTextWordWrapItem( bWordWrap
) );
1078 pTObj
->SetMergedItem( SdrTextAutoGrowHeightItem( bFitShapeToText
) );
1081 pTObj
->SetMergedItem( SdrTextVertAdjustItem( eTVA
) );
1082 pTObj
->SetMergedItem( SdrTextHorzAdjustItem( eTHA
) );
1084 if ( nMinFrameHeight
< 0 )
1085 nMinFrameHeight
= 0;
1086 if ( !pTObj
->ISA( SdrObjCustomShape
) )
1087 pTObj
->SetMergedItem( SdrTextMinFrameHeightItem( nMinFrameHeight
) );
1089 if ( nMinFrameWidth
< 0 )
1091 if ( !pTObj
->ISA( SdrObjCustomShape
) )
1092 pTObj
->SetMergedItem( SdrTextMinFrameWidthItem( nMinFrameWidth
) );
1094 // set margins at the borders of the textbox
1095 pTObj
->SetMergedItem( SdrTextLeftDistItem( nTextLeft
) );
1096 pTObj
->SetMergedItem( SdrTextRightDistItem( nTextRight
) );
1097 pTObj
->SetMergedItem( SdrTextUpperDistItem( nTextTop
) );
1098 pTObj
->SetMergedItem( SdrTextLowerDistItem( nTextBottom
) );
1099 pTObj
->SetMergedItem( SdrTextFixedCellHeightItem( sal_True
) );
1101 if ( !pTObj
->ISA( SdrObjCustomShape
) )
1102 pTObj
->SetSnapRect( rTextRect
);
1103 pTObj
= ReadObjText( &aTextObj
, pTObj
, rData
.pPage
);
1107 /* check if our new snaprect makes trouble,
1108 because we do not display the ADJUST_BLOCK
1109 properly if the textsize is bigger than the
1110 snaprect of the object. Then we will use
1111 ADJUST_CENTER instead of ADJUST_BLOCK.
1113 if ( !pTObj
->ISA( SdrObjCustomShape
) && !bFitShapeToText
&& !bWordWrap
)
1115 SdrTextObj
* pText
= PTR_CAST( SdrTextObj
, pTObj
);
1118 if ( bVerticalText
)
1120 if ( eTVA
== SDRTEXTVERTADJUST_BLOCK
)
1122 Size
aTextSize( pText
->GetTextSize() );
1123 aTextSize
.Width() += nTextLeft
+ nTextRight
;
1124 aTextSize
.Height() += nTextTop
+ nTextBottom
;
1125 if ( rTextRect
.GetHeight() < aTextSize
.Height() )
1126 pTObj
->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER
) );
1131 if ( eTHA
== SDRTEXTHORZADJUST_BLOCK
)
1133 Size
aTextSize( pText
->GetTextSize() );
1134 aTextSize
.Width() += nTextLeft
+ nTextRight
;
1135 aTextSize
.Height() += nTextTop
+ nTextBottom
;
1136 if ( rTextRect
.GetWidth() < aTextSize
.Width() )
1137 pTObj
->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_CENTER
) );
1142 // rotate text with shape?
1143 sal_Int32 nAngle
= ( rObjData
.nSpFlags
& SP_FFLIPV
) ? -mnFix16Angle
: mnFix16Angle
; // #72116# vertical flip -> rotate by using the other way
1144 nAngle
+= nTextRotationAngle
;
1146 if ( !pTObj
->ISA( SdrObjCustomShape
) )
1148 if ( rObjData
.nSpFlags
& SP_FFLIPV
)
1150 double a
= 18000 * nPi180
;
1151 pTObj
->Rotate( rTextRect
.Center(), 18000, sin( a
), cos( a
) );
1153 if ( rObjData
.nSpFlags
& SP_FFLIPH
)
1154 nAngle
= 36000 - nAngle
;
1157 double a
= nAngle
* nPi180
;
1158 pTObj
->NbcRotate( rObjData
.aBoundRect
.Center(), nAngle
, sin( a
), cos( a
) );
1163 SdrObject
* pGroup
= new SdrObjGroup
;
1164 pGroup
->GetSubList()->NbcInsertObject( pRet
);
1165 pGroup
->GetSubList()->NbcInsertObject( pTObj
);
1176 if ( maShapeRecords
.SeekToContent( rSt
, DFF_msofbtUDefProp
, SEEK_FROM_CURRENT_AND_RESTART
) )
1178 maShapeRecords
.Current()->SeekToBegOfRecord( rSt
);
1179 DffPropertyReader
aSecPropSet( *this );
1180 aSecPropSet
.ReadPropSet( rSt
, (ProcessData
*)pData
);
1181 sal_Int32 nTableProperties
= aSecPropSet
.GetPropertyValue( DFF_Prop_tableProperties
, 0 );
1182 if ( nTableProperties
& 3 )
1184 if ( aSecPropSet
.SeekToContent( DFF_Prop_tableRowProperties
, rSt
) )
1186 sal_Int16 i
, nRowCount
= 0;
1187 rSt
>> nRowCount
>> i
>> i
;
1190 sal_uInt32
* pTableArry
= new sal_uInt32
[ nRowCount
+ 2 ];
1191 pTableArry
[ 0 ] = nTableProperties
;
1192 pTableArry
[ 1 ] = nRowCount
;
1193 for ( i
= 0; i
< nRowCount
; i
++ )
1194 rSt
>> pTableArry
[ i
+ 2 ];
1195 rData
.pTableRowProperties
= pTableArry
;
1201 if ( pRet
) // sj: #i38501#, and and taking care of connections to group objects
1203 if ( rObjData
.nSpFlags
& SP_FBACKGROUND
)
1205 pRet
->NbcSetSnapRect( Rectangle( Point(), ((SdrPage
*)rData
.pPage
)->GetSize() ) ); // set size
1207 if ( rPersistEntry
.pSolverContainer
)
1209 for ( size_t i
= 0; i
< rPersistEntry
.pSolverContainer
->aCList
.size(); ++i
)
1211 SvxMSDffConnectorRule
* pPtr
= rPersistEntry
.pSolverContainer
->aCList
[ i
];
1212 if ( rObjData
.nShapeId
== pPtr
->nShapeC
)
1216 SdrObject
* pConnectObj
= pRet
;
1217 if ( pOriginalObj
&& pRet
->ISA( SdrObjGroup
) )
1218 { /* check if the original object from the escherimport is part of the group object,
1219 if this is the case, we will use the original object to connect to */
1220 SdrObjListIter
aIter( *pRet
, IM_DEEPWITHGROUPS
);
1221 while( aIter
.IsMore() )
1223 SdrObject
* pPartObj
= aIter
.Next();
1224 if ( pPartObj
== pOriginalObj
)
1226 pConnectObj
= pPartObj
;
1231 if ( rObjData
.nShapeId
== pPtr
->nShapeA
)
1233 pPtr
->pAObj
= pConnectObj
;
1234 pPtr
->nSpFlagsA
= rObjData
.nSpFlags
;
1236 if ( rObjData
.nShapeId
== pPtr
->nShapeB
)
1238 pPtr
->pBObj
= pConnectObj
;
1239 pPtr
->nSpFlagsB
= rObjData
.nSpFlags
;
1244 if ( rPersistEntry
.ePageKind
== PPT_MASTERPAGE
)
1245 { // maybe the escher clusterlist is not correct, but we have to got the right page by using the
1246 // spMaster property, so we are patching the table
1247 if ( rPersistEntry
.nDrawingDgId
!= 0xffffffff )
1249 sal_uInt32 nSec
= ( rObjData
.nShapeId
>> 10 ) - 1;
1250 if ( !maFidcls
.empty() && ( nSec
< mnIdClusters
) )
1251 maFidcls
[ nSec
].dgid
= rPersistEntry
.nDrawingDgId
; // insert the correct drawing id;
1254 if ( GetPropertyValue( DFF_Prop_fNoFillHitTest
) & 0x10 )
1256 if ( (MSO_FillType
)GetPropertyValue( DFF_Prop_fillType
, mso_fillSolid
) == mso_fillBackground
)
1258 rData
.aBackgroundColoredObjects
.push_back( pRet
);
1265 SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam
& rParam
, const OUString
& rBaseURL
) :
1266 SdrEscherImport ( rParam
, rBaseURL
),
1267 bOk ( rStCtrl
.GetErrorCode() == SVSTREAM_OK
),
1268 pPersistPtr ( NULL
),
1269 nPersistPtrAnz ( 0 ),
1270 pDefaultSheet ( NULL
),
1271 pMasterPages ( NULL
),
1272 pSlidePages ( NULL
),
1273 pNotePages ( NULL
),
1275 nDocStreamPos ( 0 ),
1276 nPageColorsNum ( 0xFFFF ),
1277 ePageColorsKind ( PPT_MASTERPAGE
),
1278 eAktPageKind ( PPT_MASTERPAGE
)
1280 DffRecordHeader
* pHd
;
1283 rStCtrl
.Seek( STREAM_SEEK_TO_END
);
1284 nStreamLen
= rStCtrl
.Tell();
1286 // try to allocate the UserEditAtom via CurrentUserAtom
1287 sal_uInt32 nCurrentUserEdit
= rParam
.aCurrentUserAtom
.nCurrentUserEdit
;
1288 if ( nCurrentUserEdit
)
1290 rStCtrl
.Seek( nCurrentUserEdit
);
1291 rStCtrl
>> aUserEditAtom
;
1293 if ( !aUserEditAtom
.nOffsetPersistDirectory
)
1294 { // if there is no UserEditAtom try to search the last one
1297 DffRecordManager aPptRecManager
; // contains all first level container and atoms
1298 aPptRecManager
.Consume( rStCtrl
, sal_False
, nStreamLen
);
1299 for ( pHd
= aPptRecManager
.Last(); pHd
; pHd
= aPptRecManager
.Prev() )
1301 if ( pHd
->nRecType
== PPT_PST_UserEditAtom
)
1303 pHd
->SeekToBegOfRecord( rStCtrl
);
1304 rStCtrl
>> aUserEditAtom
;
1312 if ( rStCtrl
.GetError() != 0 )
1317 nPersistPtrAnz
= aUserEditAtom
.nMaxPersistWritten
+ 1;
1318 if ( ( nPersistPtrAnz
>> 2 ) > nStreamLen
) // sj: at least nPersistPtrAnz is not allowed to be greater than filesize
1319 bOk
= sal_False
; // (it should not be greater than the PPT_PST_PersistPtrIncrementalBlock, but
1320 // we are reading this block later, so we do not have access yet)
1322 if ( bOk
&& ( nPersistPtrAnz
< ( SAL_MAX_UINT32
/ sizeof( sal_uInt32
) ) -1 ) )
1323 pPersistPtr
= new (std::nothrow
) sal_uInt32
[ nPersistPtrAnz
+ 1 ];
1328 memset( pPersistPtr
, 0x00, (nPersistPtrAnz
+1) * sizeof(sal_uInt32
) );
1330 // SJ: new search mechanism from bottom to top (Issue 21122)
1331 PptUserEditAtom
aCurrentEditAtom( aUserEditAtom
);
1332 sal_uInt32 nCurrentEditAtomStrmPos
= aCurrentEditAtom
.aHd
.GetRecEndFilePos();
1333 while( nCurrentEditAtomStrmPos
)
1335 sal_uInt32 nPersistIncPos
= aCurrentEditAtom
.nOffsetPersistDirectory
;
1336 if ( nPersistIncPos
)
1338 rStCtrl
.Seek( nPersistIncPos
);
1339 DffRecordHeader aPersistHd
;
1340 rStCtrl
>> aPersistHd
;
1341 if ( aPersistHd
.nRecType
== PPT_PST_PersistPtrIncrementalBlock
)
1343 sal_uLong nPibLen
= aPersistHd
.GetRecEndFilePos();
1344 while ( bOk
&& ( rStCtrl
.GetError() == 0 ) && ( rStCtrl
.Tell() < nPibLen
) )
1348 sal_uInt32 nAnz
= nOfs
;
1351 while ( bOk
&& ( rStCtrl
.GetError() == 0 ) && ( nAnz
> 0 ) && ( nOfs
<= nPersistPtrAnz
) )
1355 if ( !pPersistPtr
[ nOfs
] )
1357 pPersistPtr
[ nOfs
] = nPt
;
1358 if ( pPersistPtr
[ nOfs
] > nStreamLen
)
1361 OSL_FAIL("SdrPowerPointImport::Ctor(): Ungueltiger Eintrag im Persist-Directory!");
1367 if ( bOk
&& nAnz
> 0 )
1369 OSL_FAIL("SdrPowerPointImport::Ctor(): Nicht alle Persist-Directory Entraege gelesen!");
1375 nCurrentEditAtomStrmPos
= aCurrentEditAtom
.nOffsetLastEdit
< nCurrentEditAtomStrmPos
? aCurrentEditAtom
.nOffsetLastEdit
: 0;
1376 if ( nCurrentEditAtomStrmPos
)
1378 rStCtrl
.Seek( nCurrentEditAtomStrmPos
);
1379 rStCtrl
>> aCurrentEditAtom
;
1384 if ( rStCtrl
.GetError() != 0 )
1387 { // check Document PersistEntry
1388 nDocStreamPos
= aUserEditAtom
.nDocumentRef
;
1389 if ( nDocStreamPos
> nPersistPtrAnz
)
1391 OSL_FAIL("SdrPowerPointImport::Ctor(): aUserEditAtom.nDocumentRef ungueltig!");
1396 { // check Document FilePos
1397 nDocStreamPos
= pPersistPtr
[ nDocStreamPos
];
1398 if ( nDocStreamPos
>= nStreamLen
)
1400 OSL_FAIL("SdrPowerPointImport::Ctor(): nDocStreamPos >= nStreamLen!");
1406 rStCtrl
.Seek( nDocStreamPos
);
1407 aDocRecManager
.Consume( rStCtrl
);
1409 DffRecordHeader aDocHd
;
1411 // read DocumentAtom
1412 DffRecordHeader aDocAtomHd
;
1413 rStCtrl
>> aDocAtomHd
;
1414 if ( aDocHd
.nRecType
== PPT_PST_Document
&& aDocAtomHd
.nRecType
== PPT_PST_DocumentAtom
)
1416 aDocAtomHd
.SeekToBegOfRecord( rStCtrl
);
1417 rStCtrl
>> aDocAtom
;
1425 ReadFontCollection();
1427 // reading TxPF, TxSI
1428 PPTTextCharacterStyleAtomInterpreter aTxCFStyle
; // SJ: TODO, this atom needs to be interpreted, it contains character default styles for standard objects (instance4)
1429 PPTTextParagraphStyleAtomInterpreter aTxPFStyle
;
1430 PPTTextSpecInfoAtomInterpreter aTxSIStyle
; // styles (default language setting ... )
1432 DffRecordHeader
* pEnvHd
= aDocRecManager
.GetRecordHeader( PPT_PST_Environment
);
1435 pEnvHd
->SeekToContent( rStCtrl
);
1436 DffRecordHeader aTxPFStyleRecHd
;
1437 if ( SeekToRec( rStCtrl
, PPT_PST_TxPFStyleAtom
, pEnvHd
->GetRecEndFilePos(), &aTxPFStyleRecHd
) )
1438 aTxPFStyle
.Read( rStCtrl
, aTxPFStyleRecHd
);
1440 pEnvHd
->SeekToContent( rStCtrl
);
1441 DffRecordHeader aTxSIStyleRecHd
;
1442 if ( SeekToRec( rStCtrl
, PPT_PST_TxSIStyleAtom
, pEnvHd
->GetRecEndFilePos(), &aTxSIStyleRecHd
) )
1444 aTxSIStyle
.Read( rStCtrl
, aTxSIStyleRecHd
, PPT_PST_TxSIStyleAtom
);
1446 if ( !aTxSIStyle
.bValid
)
1448 if (!(rImportParam
.nImportFlags
& PPT_IMPORTFLAGS_NO_TEXT_ASSERT
))
1450 OSL_FAIL( "SdrTextSpecInfoAtomInterpreter::Ctor(): parsing error, this document needs to be analysed (SJ)" );
1457 // TODO:: PPT_PST_TxPFStyleAtom
1459 // read SlidePersists
1460 pMasterPages
=new PptSlidePersistList
;
1461 pSlidePages
=new PptSlidePersistList
;
1462 pNotePages
=new PptSlidePersistList
;
1464 // now always creating the handout page, it will be the first in our masterpage list
1465 PptSlidePersistEntry
* pE
= new PptSlidePersistEntry
;
1466 pE
->aPersistAtom
.nPsrReference
= aDocAtom
.nHandoutMasterPersist
;
1467 pE
->bHandoutMaster
= sal_True
;
1468 if ( !aDocAtom
.nHandoutMasterPersist
)
1469 pE
->bStarDrawFiller
= sal_True
; // this is a dummy master page
1470 pMasterPages
->insert( pMasterPages
->begin(), pE
);
1472 sal_uInt16 nPageListNum
= 0;
1473 DffRecordHeader
* pSlideListWithTextHd
= aDocRecManager
.GetRecordHeader( PPT_PST_SlideListWithText
);
1474 PptSlidePersistEntry
* pPreviousPersist
= NULL
;
1475 while ( pSlideListWithTextHd
&& ( nPageListNum
< 3 ) )
1477 pSlideListWithTextHd
->SeekToContent( rStCtrl
);
1478 PptSlidePersistList
* pPageList
= GetPageList( PptPageKind( nPageListNum
) );
1479 sal_uInt32 nSlideListWithTextHdEndOffset
= pSlideListWithTextHd
->GetRecEndFilePos();
1480 while ( SeekToRec( rStCtrl
, PPT_PST_SlidePersistAtom
, nSlideListWithTextHdEndOffset
) )
1482 if ( pPreviousPersist
)
1483 pPreviousPersist
->nSlidePersistEndOffset
= rStCtrl
.Tell();
1484 PptSlidePersistEntry
* pE2
= new PptSlidePersistEntry
;
1485 rStCtrl
>> pE2
->aPersistAtom
;
1486 pE2
->nSlidePersistStartOffset
= rStCtrl
.Tell();
1487 pE2
->ePageKind
= PptPageKind( nPageListNum
);
1488 pPageList
->push_back( pE2
);
1489 pPreviousPersist
= pE2
;
1491 if ( pPreviousPersist
)
1492 pPreviousPersist
->nSlidePersistEndOffset
= nSlideListWithTextHdEndOffset
;
1493 pSlideListWithTextHd
= aDocRecManager
.GetRecordHeader( PPT_PST_SlideListWithText
, SEEK_FROM_CURRENT
);
1497 // we will ensure that there is at least one master page
1498 if ( pMasterPages
->size() == 1 ) // -> there is only a handout page available
1500 PptSlidePersistEntry
* pE2
= new PptSlidePersistEntry
;
1501 pE2
->bStarDrawFiller
= sal_True
; // this is a dummy master page
1502 pMasterPages
->insert( pMasterPages
->begin() + 1, pE2
);
1505 // now we will insert at least one notes master for each master page
1506 sal_uInt16 nMasterPage
;
1507 sal_uInt16 nMasterPages
= pMasterPages
->size() - 1;
1508 for ( nMasterPage
= 0; nMasterPage
< nMasterPages
; nMasterPage
++ )
1510 PptSlidePersistEntry
* pE2
= new PptSlidePersistEntry
;
1511 pE2
->bNotesMaster
= sal_True
;
1512 pE2
->bStarDrawFiller
= sal_True
; // this is a dummy master page
1513 if ( !nMasterPage
&& aDocAtom
.nNotesMasterPersist
)
1514 { // special treatment for the first notes master
1515 pE2
->aPersistAtom
.nPsrReference
= aDocAtom
.nNotesMasterPersist
;
1516 pE2
->bStarDrawFiller
= sal_False
; // this is a dummy master page
1518 pMasterPages
->insert( pMasterPages
->begin() + (( nMasterPage
+ 1 ) << 1), pE2
);
1521 // read for each page the SlideAtom respectively the NotesAtom if it exists
1523 for ( nPageListNum
= 0; nPageListNum
< 3; nPageListNum
++ )
1525 PptSlidePersistList
* pPageList
= GetPageList( PptPageKind( nPageListNum
) );
1526 for ( sal_uInt16 nPageNum
= 0; nPageNum
< pPageList
->size(); nPageNum
++ )
1528 PptSlidePersistEntry
* pE2
= (*pPageList
)[ nPageNum
];
1529 sal_uLong nPersist
= pE2
->aPersistAtom
.nPsrReference
;
1530 if ( ( nPersist
> 0 ) && ( nPersist
< nPersistPtrAnz
) )
1532 sal_uLong nFPos
= pPersistPtr
[ nPersist
];
1533 if ( nFPos
< nStreamLen
)
1535 rStCtrl
.Seek( nFPos
);
1536 DffRecordHeader aSlideHd
;
1537 rStCtrl
>> aSlideHd
;
1538 if ( SeekToRec( rStCtrl
, PPT_PST_SlideAtom
, aSlideHd
.GetRecEndFilePos() ) )
1539 rStCtrl
>> pE2
->aSlideAtom
;
1540 else if ( SeekToRec( rStCtrl
, PPT_PST_NotesAtom
, aSlideHd
.GetRecEndFilePos() ) )
1541 rStCtrl
>> pE2
->aNotesAtom
;
1542 aSlideHd
.SeekToContent( rStCtrl
);
1544 DffRecordHeader aPPTDrawingHd
;
1545 if ( SeekToRec( rStCtrl
, PPT_PST_PPDrawing
, aSlideHd
.GetRecEndFilePos(), &aPPTDrawingHd
) )
1547 DffRecordHeader aPPTDgContainer
;
1548 if ( SeekToRec( rStCtrl
, DFF_msofbtDgContainer
, aPPTDrawingHd
.GetRecEndFilePos(), &aPPTDgContainer
) )
1550 if ( SeekToRec( rStCtrl
, DFF_msofbtDg
, aPPTDrawingHd
.GetRecEndFilePos() ) )
1552 DffRecordHeader aDgRecordHeader
;
1553 rStCtrl
>> aDgRecordHeader
;
1554 pE2
->nDrawingDgId
= aDgRecordHeader
.nRecInstance
;
1555 aDgRecordHeader
.SeekToEndOfRecord( rStCtrl
);
1557 if ( SeekToRec( rStCtrl
, DFF_msofbtSolverContainer
, aPPTDgContainer
.GetRecEndFilePos() ) )
1559 pE2
->pSolverContainer
= new SvxMSDffSolverContainer
;
1560 rStCtrl
>> *( pE2
->pSolverContainer
);
1562 aPPTDgContainer
.SeekToBegOfRecord( rStCtrl
);
1563 SetDgContainer( rStCtrl
); // set this, so that the escherimport is knowing of our drawings
1566 // office xp is supporting more than one stylesheet
1567 if ( ( pE2
->ePageKind
== PPT_MASTERPAGE
) && ( pE2
->aSlideAtom
.nMasterId
== 0 ) && ( pE2
->bNotesMaster
== 0 ) )
1569 PPTTextSpecInfo
aTxSI( 0 );
1570 if ( aTxSIStyle
.bValid
&& !aTxSIStyle
.aList
.empty() )
1571 aTxSI
= *( aTxSIStyle
.aList
[ 0 ] );
1573 pE2
->pStyleSheet
= new PPTStyleSheet( aSlideHd
, rStCtrl
, *this, aTxCFStyle
, aTxPFStyle
, aTxSI
);
1574 pDefaultSheet
= pE2
->pStyleSheet
;
1576 if ( SeekToRec( rStCtrl
, PPT_PST_ColorSchemeAtom
, aSlideHd
.GetRecEndFilePos() ) )
1577 rStCtrl
>> pE2
->aColorScheme
;
1580 OSL_FAIL( "SdrPowerPointImport::Ctor(): could not get SlideColorScheme! (SJ)" );
1585 OSL_FAIL("SdrPowerPointImport::Ctor(): Persist-Eintrag fehlerhaft! (SJ)");
1590 DffRecordHeader
* pHeadersFootersHd
= aDocRecManager
.GetRecordHeader( PPT_PST_HeadersFooters
, SEEK_FROM_BEGINNING
);
1591 if ( pHeadersFootersHd
)
1593 HeaderFooterEntry aNormalMaster
, aNotesMaster
;
1594 for ( ; pHeadersFootersHd
; pHeadersFootersHd
= aDocRecManager
.GetRecordHeader( PPT_PST_HeadersFooters
, SEEK_FROM_CURRENT
) )
1596 if ( pHeadersFootersHd
->nRecInstance
== 3 ) // normal master
1597 ImportHeaderFooterContainer( *pHeadersFootersHd
, aNormalMaster
);
1598 else if ( pHeadersFootersHd
->nRecInstance
== 4 ) // notes master
1599 ImportHeaderFooterContainer( *pHeadersFootersHd
, aNotesMaster
);
1601 for ( sal_uInt16 i
= 0; i
< pMasterPages
->size(); i
++ )
1603 if ( (*pMasterPages
)[ i
]->bNotesMaster
)
1604 (*pMasterPages
)[ i
]->pHeaderFooterEntry
= new HeaderFooterEntry( aNotesMaster
);
1606 (*pMasterPages
)[ i
]->pHeaderFooterEntry
= new HeaderFooterEntry( aNormalMaster
);
1611 if ( ( rStCtrl
.GetError() != 0 ) || ( pDefaultSheet
== NULL
) )
1613 pPPTStyleSheet
= pDefaultSheet
;
1617 SdrPowerPointImport::~SdrPowerPointImport()
1619 for ( size_t i
= 0, n
= aHyperList
.size(); i
< n
; ++i
) {
1620 delete aHyperList
[ i
];
1623 delete pMasterPages
;
1626 delete[] pPersistPtr
;
1629 sal_Bool
PPTConvertOCXControls::ReadOCXStream( SotStorageRef
& rSrc
,
1630 com::sun::star::uno::Reference
<
1631 com::sun::star::drawing::XShape
> *pShapeRef
,
1632 sal_Bool bFloatingCtrl
)
1635 uno::Reference
< form::XFormComponent
> xFComp
;
1636 if ( mpPPTImporter
&& mpPPTImporter
->ReadFormControl( rSrc
, xFComp
) )
1640 com::sun::star::awt::Size aSz
; // not used in import
1641 bRes
= InsertControl( xFComp
, aSz
,pShapeRef
,bFloatingCtrl
);
1647 sal_Bool
PPTConvertOCXControls::InsertControl(
1648 const com::sun::star::uno::Reference
<
1649 com::sun::star::form::XFormComponent
> &rFComp
,
1650 const com::sun::star::awt::Size
& rSize
,
1651 com::sun::star::uno::Reference
<
1652 com::sun::star::drawing::XShape
> *pShape
,
1653 sal_Bool
/*bFloatingCtrl*/)
1655 sal_Bool bRetValue
= sal_False
;
1658 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> xShape
;
1660 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
> & rFormComps
=
1663 ::com::sun::star::uno::Any
aTmp( &rFComp
, ::getCppuType((const ::com::sun::star::uno::Reference
<
1664 com::sun::star::form::XFormComponent
>*)0) );
1666 rFormComps
->insertByIndex( rFormComps
->getCount(), aTmp
);
1668 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & rServiceFactory
=
1669 GetServiceFactory();
1670 if( rServiceFactory
.is() )
1672 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> xCreate
= rServiceFactory
1673 ->createInstance(String( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ControlShape" ) ) );
1676 xShape
= ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>(xCreate
, ::com::sun::star::uno::UNO_QUERY
);
1679 xShape
->setSize(rSize
);
1680 // set the Control-Model at the Control-Shape
1681 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XControlShape
> xControlShape( xShape
,
1682 ::com::sun::star::uno::UNO_QUERY
);
1683 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
> xControlModel( rFComp
,
1684 ::com::sun::star::uno::UNO_QUERY
);
1685 if ( xControlShape
.is() && xControlModel
.is() )
1687 xControlShape
->setControl( xControlModel
);
1690 bRetValue
= sal_True
;
1698 bRetValue
= sal_False
;
1702 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>& PPTConvertOCXControls::GetDrawPage()
1704 if( !xDrawPage
.is() && mxModel
.is() )
1706 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPages
> xDrawPages
;
1709 case PPT_SLIDEPAGE
:
1712 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPagesSupplier
>
1713 xDrawPagesSupplier( mxModel
, ::com::sun::star::uno::UNO_QUERY
);
1714 if ( xDrawPagesSupplier
.is() )
1715 xDrawPages
= xDrawPagesSupplier
->getDrawPages();
1719 case PPT_MASTERPAGE
:
1721 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XMasterPagesSupplier
>
1722 xMasterPagesSupplier( mxModel
, ::com::sun::star::uno::UNO_QUERY
);
1723 if ( xMasterPagesSupplier
.is() )
1724 xDrawPages
= xMasterPagesSupplier
->getMasterPages();
1728 if ( xDrawPages
.is() && xDrawPages
->getCount() )
1730 xDrawPages
->getCount();
1731 ::com::sun::star::uno::Any
aAny( xDrawPages
->getByIndex( xDrawPages
->getCount() - 1 ) );
1738 sal_Bool
SdrPowerPointOLEDecompress( SvStream
& rOutput
, SvStream
& rInput
, sal_uInt32 nInputSize
)
1740 sal_uInt32 nOldPos
= rInput
.Tell();
1741 char* pBuf
= new char[ nInputSize
];
1742 rInput
.Read( pBuf
, nInputSize
);
1743 ZCodec
aZCodec( 0x8000, 0x8000 );
1744 aZCodec
.BeginCompression();
1745 SvMemoryStream
aSource( pBuf
, nInputSize
, STREAM_READ
);
1746 aZCodec
.Decompress( aSource
, rOutput
);
1747 const sal_Bool
bSuccess(0L != aZCodec
.EndCompression());
1749 rInput
.Seek( nOldPos
);
1753 // #i32596# - add new parameter <_nCalledByGroup>
1754 SdrObject
* SdrPowerPointImport::ImportOLE( long nOLEId
,
1755 const Graphic
& rGraf
,
1756 const Rectangle
& rBoundRect
,
1757 const Rectangle
& rVisArea
,
1758 const int /*_nCalledByGroup*/,
1759 sal_Int64
/*nAspect*/ ) const
1761 SdrObject
* pRet
= NULL
;
1763 sal_uInt32 nOldPos
= rStCtrl
.Tell();
1765 Graphic
aGraphic( rGraf
);
1767 if ( ((SdrPowerPointImport
*)this)->maShapeRecords
.SeekToContent( rStCtrl
, DFF_msofbtClientData
, SEEK_FROM_CURRENT_AND_RESTART
) )
1769 DffRecordHeader aPlaceHd
;
1770 while ( ( rStCtrl
.GetError() == 0 )
1771 && ( rStCtrl
.Tell() < ((SdrPowerPointImport
*)this)->maShapeRecords
.Current()->GetRecEndFilePos() ) )
1773 rStCtrl
>> aPlaceHd
;
1774 if ( aPlaceHd
.nRecType
== PPT_PST_RecolorInfoAtom
)
1776 ((SdrPowerPointImport
*)this)->RecolorGraphic( rStCtrl
, aPlaceHd
.nRecLen
, aGraphic
);
1780 aPlaceHd
.SeekToEndOfRecord( rStCtrl
);
1785 for ( size_t i
= 0; i
< ((SdrPowerPointImport
*)this)->aOleObjectList
.size(); ++i
)
1787 pOe
= ((SdrPowerPointImport
*)this)->aOleObjectList
[ i
];
1788 if ( pOe
->nId
!= (sal_uInt32
)nOLEId
)
1791 rStCtrl
.Seek( pOe
->nRecHdOfs
);
1793 DffRecordHeader aHd
;
1796 sal_uInt32 nLen
= aHd
.nRecLen
- 4;
1797 if ( (sal_Int32
)nLen
> 0 )
1799 sal_Bool bSuccess
= sal_False
;
1801 rStCtrl
.SeekRel( 4 );
1803 ::utl::TempFile aTmpFile
;
1804 aTmpFile
.EnableKillingFile( sal_True
);
1806 if ( aTmpFile
.IsValid() )
1808 SvStream
* pDest
= ::utl::UcbStreamHelper::CreateStream( aTmpFile
.GetURL(), STREAM_TRUNC
| STREAM_WRITE
);
1810 bSuccess
= SdrPowerPointOLEDecompress( *pDest
, rStCtrl
, nLen
);
1815 SvStream
* pDest
= ::utl::UcbStreamHelper::CreateStream( aTmpFile
.GetURL(), STREAM_READ
);
1816 Storage
* pObjStor
= pDest
? new Storage( *pDest
, sal_True
) : NULL
;
1819 SotStorageRef
xObjStor( new SotStorage( pObjStor
) );
1820 if ( xObjStor
.Is() && !xObjStor
->GetError() )
1822 if ( xObjStor
->GetClassName() == SvGlobalName() )
1824 ClsId
aId( pObjStor
->GetClassId() );
1825 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
),
1826 pObjStor
->GetFormat(), pObjStor
->GetUserName() );
1828 SotStorageStreamRef xSrcTst
= xObjStor
->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "\1Ole" ) ) );
1831 sal_uInt8 aTestA
[ 10 ];
1832 sal_Bool bGetItAsOle
= ( sizeof( aTestA
) == xSrcTst
->Read( aTestA
, sizeof( aTestA
) ) );
1834 { // maybe there is a contentsstream in here
1835 xSrcTst
= xObjStor
->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "Contents" ) ), STREAM_READWRITE
| STREAM_NOCREATE
);
1836 bGetItAsOle
= ( xSrcTst
.Is() && sizeof( aTestA
) == xSrcTst
->Read( aTestA
, sizeof( aTestA
) ) );
1841 // if ( nSvxMSDffOLEConvFlags )
1843 uno::Reference
< embed::XStorage
> xDestStorage( pOe
->pShell
->GetStorage() );
1844 uno::Reference
< embed::XEmbeddedObject
> xObj
=
1845 CheckForConvertToSOObj( nSvxMSDffOLEConvFlags
, *xObjStor
, xDestStorage
, rGraf
, rVisArea
);
1848 pOe
->pShell
->getEmbeddedObjectContainer().InsertEmbeddedObject( xObj
, aNm
);
1850 svt::EmbeddedObjectRef
aObj( xObj
, pOe
->nAspect
);
1852 // TODO/LATER: need MediaType for Graphic
1853 aObj
.SetGraphic( rGraf
, OUString() );
1854 pRet
= new SdrOle2Obj( aObj
, aNm
, rBoundRect
, sal_False
);
1857 if ( !pRet
&& ( pOe
->nType
== PPT_PST_ExControl
) )
1859 uno::Reference
< io::XInputStream
> xIStrm
= new utl::OSeekableInputStreamWrapper(*pDest
);
1860 uno::Reference
< frame::XModel
> xModel( pOe
->pShell
? pOe
->pShell
->GetModel() : NULL
);
1861 PPTConvertOCXControls
aPPTConvertOCXControls( this, xIStrm
, xModel
, eAktPageKind
);
1862 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> xShape
;
1863 if ( aPPTConvertOCXControls
.ReadOCXStream( xObjStor
, &xShape
, sal_False
) )
1864 pRet
= GetSdrObjectFromXShape( xShape
);
1869 aNm
= pOe
->pShell
->getEmbeddedObjectContainer().CreateUniqueObjectName();
1871 // object is not an own object
1872 SotStorageRef xTarget
= SotStorage::OpenOLEStorage( pOe
->pShell
->GetStorage(), aNm
, STREAM_READWRITE
);
1873 if ( xObjStor
.Is() && xTarget
.Is() )
1875 xObjStor
->CopyTo( xTarget
);
1876 if( !xTarget
->GetError() )
1881 uno::Reference
< embed::XEmbeddedObject
> xObj
=
1882 pOe
->pShell
->getEmbeddedObjectContainer().GetEmbeddedObject( aNm
);
1885 if ( pOe
->nAspect
!= embed::Aspects::MSOLE_ICON
)
1887 //TODO/LATER: keep on hacking?!
1888 // we don't want to be modified
1889 //xInplaceObj->EnableSetModified( sal_False );
1890 if ( rVisArea
.IsEmpty() )
1892 MapUnit aMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( pOe
->nAspect
) );
1893 Size
aSize( OutputDevice::LogicToLogic( aGraphic
.GetPrefSize(),
1894 aGraphic
.GetPrefMapMode(), MapMode( aMapUnit
) ) );
1897 aSz
.Width
= aSize
.Width();
1898 aSz
.Height
= aSize
.Height();
1899 xObj
->setVisualAreaSize( pOe
->nAspect
, aSz
);
1903 awt::Size
aSize( rVisArea
.GetSize().Width(), rVisArea
.GetSize().Height() );
1904 xObj
->setVisualAreaSize( pOe
->nAspect
, aSize
);
1906 //xInplaceObj->EnableSetModified( sal_True );
1909 svt::EmbeddedObjectRef
aObj( xObj
, pOe
->nAspect
);
1911 // TODO/LATER: need MediaType for Graphic
1912 aObj
.SetGraphic( aGraphic
, OUString() );
1914 pRet
= new SdrOle2Obj( aObj
, aNm
, rBoundRect
, sal_False
);
1925 rStCtrl
.Seek( nOldPos
);
1930 SvMemoryStream
* SdrPowerPointImport::ImportExOleObjStg( sal_uInt32 nPersistPtr
, sal_uInt32
& nOleId
) const
1932 SvMemoryStream
* pRet
= NULL
;
1933 if ( nPersistPtr
&& ( nPersistPtr
< nPersistPtrAnz
) )
1935 sal_uInt32 nOldPos
, nOfs
= pPersistPtr
[ nPersistPtr
];
1936 nOldPos
= rStCtrl
.Tell();
1937 rStCtrl
.Seek( nOfs
);
1938 DffRecordHeader aHd
;
1940 if ( aHd
.nRecType
== DFF_PST_ExOleObjStg
)
1942 sal_uInt32 nLen
= aHd
.nRecLen
- 4;
1943 if ( (sal_Int32
)nLen
> 0 )
1946 pRet
= new SvMemoryStream
;
1947 ZCodec
aZCodec( 0x8000, 0x8000 );
1948 aZCodec
.BeginCompression();
1949 aZCodec
.Decompress( rStCtrl
, *pRet
);
1950 if ( !aZCodec
.EndCompression() )
1951 delete pRet
, pRet
= NULL
;
1954 rStCtrl
.Seek( nOldPos
);
1959 void SdrPowerPointImport::SeekOle( SfxObjectShell
* pShell
, sal_uInt32 nFilterOptions
)
1963 DffRecordHeader
* pHd
;
1965 sal_uInt32 nOldPos
= rStCtrl
.Tell();
1966 if ( nFilterOptions
& 1 )
1968 pHd
= aDocRecManager
.GetRecordHeader( PPT_PST_List
, SEEK_FROM_BEGINNING
);
1971 // we try to locate the basic atom
1972 pHd
->SeekToContent( rStCtrl
);
1973 if ( SeekToRec( rStCtrl
, PPT_PST_VBAInfo
, pHd
->GetRecEndFilePos(), pHd
) )
1975 if ( SeekToRec( rStCtrl
, PPT_PST_VBAInfoAtom
, pHd
->GetRecEndFilePos(), pHd
) )
1977 sal_uInt32 nPersistPtr
, nIDoNotKnow1
, nIDoNotKnow2
;
1978 rStCtrl
>> nPersistPtr
1983 SvMemoryStream
* pBas
= ImportExOleObjStg( nPersistPtr
, nOleId
);
1986 SotStorageRef
xSource( new SotStorage( pBas
, sal_True
) );
1987 SotStorageRef
xDest( new SotStorage( new SvMemoryStream(), sal_True
) );
1988 if ( xSource
.Is() && xDest
.Is() )
1990 // is this a visual basic storage ?
1991 SotStorageRef xSubStorage
= xSource
->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "VBA" ) ),
1992 STREAM_READWRITE
| STREAM_NOCREATE
| STREAM_SHARE_DENYALL
);
1993 if( xSubStorage
.Is() && ( SVSTREAM_OK
== xSubStorage
->GetError() ) )
1995 SotStorageRef xMacros
= xDest
->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "MACROS" ) ) );
1998 SvStorageInfoList aList
;
1999 xSource
->FillInfoList( &aList
);
2002 sal_Bool bCopied
= sal_True
;
2003 for ( i
= 0; i
< aList
.size(); i
++ ) // copy all entries
2005 const SvStorageInfo
& rInfo
= aList
[ i
];
2006 if ( !xSource
->CopyTo( rInfo
.GetName(), xMacros
, rInfo
.GetName() ) )
2007 bCopied
= sal_False
;
2011 SvxImportMSVBasic
aMSVBas( *pShell
, *xDest
);
2013 uno::Reference
< embed::XStorage
> xDoc( pShell
->GetStorage() );
2016 SotStorageRef xVBA
= SotStorage::OpenOLEStorage( xDoc
, String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Macros" ) ) );
2017 if ( xVBA
.Is() && ( xVBA
->GetError() == SVSTREAM_OK
) )
2019 SotStorageRef xSubVBA
= xVBA
->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Overhead" ) ) );
2020 if ( xSubVBA
.Is() && ( xSubVBA
->GetError() == SVSTREAM_OK
) )
2022 SotStorageStreamRef xOriginal
= xSubVBA
->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Overhead2" ) ) );
2023 if ( xOriginal
.Is() && ( xOriginal
->GetError() == SVSTREAM_OK
) )
2025 if ( nPersistPtr
&& ( nPersistPtr
< nPersistPtrAnz
) )
2027 rStCtrl
.Seek( pPersistPtr
[ nPersistPtr
] );
2030 *xOriginal
<< nIDoNotKnow1
2033 sal_uInt32 nToCopy
, nBufSize
;
2034 nToCopy
= pHd
->nRecLen
;
2035 sal_uInt8
* pBuf
= new sal_uInt8
[ 0x40000 ]; // 256KB Buffer
2040 nBufSize
= ( nToCopy
>= 0x40000 ) ? 0x40000 : nToCopy
;
2041 rStCtrl
.Read( pBuf
, nBufSize
);
2042 xOriginal
->Write( pBuf
, nBufSize
);
2043 nToCopy
-= nBufSize
;
2061 pHd
= aDocRecManager
.GetRecordHeader( PPT_PST_ExObjList
, SEEK_FROM_BEGINNING
);
2064 DffRecordManager
* pExObjListManager
= NULL
;
2065 DffRecordHeader
* pExEmbed
= NULL
;
2067 pHd
->SeekToBegOfRecord( rStCtrl
);
2068 pExObjListManager
= new DffRecordManager( rStCtrl
);
2069 sal_uInt16 i
, nRecType(PPT_PST_ExEmbed
);
2071 for ( i
= 0; i
< 2; i
++ )
2075 case 0 : nRecType
= PPT_PST_ExEmbed
; break;
2076 case 1 : nRecType
= PPT_PST_ExControl
; break;
2078 for ( pExEmbed
= pExObjListManager
->GetRecordHeader( nRecType
, SEEK_FROM_BEGINNING
);
2079 pExEmbed
; pExEmbed
= pExObjListManager
->GetRecordHeader( nRecType
, SEEK_FROM_CURRENT
) )
2081 pExEmbed
->SeekToContent( rStCtrl
);
2083 DffRecordHeader aExOleAtHd
;
2084 if ( SeekToRec( rStCtrl
, PPT_PST_ExOleObjAtom
, pExEmbed
->GetRecEndFilePos(), &aExOleAtHd
) )
2086 PptExOleObjAtom aAt
;
2089 if ( aAt
.nPersistPtr
&& ( aAt
.nPersistPtr
< nPersistPtrAnz
) )
2092 rStCtrl
.Seek( pPersistPtr
[ aAt
.nPersistPtr
] );
2093 DffRecordHeader aHd
;
2095 if ( aHd
.nRecType
== DFF_PST_ExOleObjStg
)
2098 aOleObjectList
.push_back(
2099 new PPTOleEntry( aAt
.nId
, aHd
.nFilePos
, pShell
, nRecType
, aAt
.nAspect
) );
2105 delete pExObjListManager
;
2107 rStCtrl
.Seek( nOldPos
);
2111 sal_Bool
SdrPowerPointImport::ReadFontCollection()
2113 sal_Bool bRet
= sal_False
;
2114 DffRecordHeader
* pEnvHd
= aDocRecManager
.GetRecordHeader( PPT_PST_Environment
);
2117 sal_uLong nFPosMerk
= rStCtrl
.Tell(); // remember FilePos for restoring it later
2118 pEnvHd
->SeekToContent( rStCtrl
);
2119 DffRecordHeader aListHd
;
2120 if ( SeekToRec( rStCtrl
, PPT_PST_FontCollection
, pEnvHd
->GetRecEndFilePos(), &aListHd
) )
2122 sal_uInt16 nCount2
= 0;
2123 while ( SeekToRec( rStCtrl
, PPT_PST_FontEntityAtom
, aListHd
.GetRecEndFilePos() ) )
2127 pFonts
= new PptFontCollection
;
2128 PptFontEntityAtom
* pFont
= new PptFontEntityAtom
;
2132 aFont
.SetCharSet( pFont
->eCharSet
);
2133 aFont
.SetName( pFont
->aName
);
2134 aFont
.SetFamily( pFont
->eFamily
);
2135 aFont
.SetPitch( pFont
->ePitch
);
2136 aFont
.SetHeight( 100 );
2138 // following block is necessary, because our old PowerPoint export did not set the
2140 if ( pFont
->aName
.equalsIgnoreAsciiCase( "Wingdings" ) ||
2141 pFont
->aName
.equalsIgnoreAsciiCase( "Wingdings 2" ) ||
2142 pFont
->aName
.equalsIgnoreAsciiCase( "Wingdings 3" ) ||
2143 pFont
->aName
.equalsIgnoreAsciiCase( "Monotype Sorts" ) ||
2144 pFont
->aName
.equalsIgnoreAsciiCase( "Monotype Sorts 2" ) ||
2145 pFont
->aName
.equalsIgnoreAsciiCase( "Webdings" ) ||
2146 pFont
->aName
.equalsIgnoreAsciiCase( "StarBats" ) ||
2147 pFont
->aName
.equalsIgnoreAsciiCase( "StarMath" ) ||
2148 pFont
->aName
.equalsIgnoreAsciiCase( "ZapfDingbats" ) )
2150 pFont
->eCharSet
= RTL_TEXTENCODING_SYMBOL
;
2152 pFonts
->insert( pFonts
->begin() + nCount2
++, pFont
);
2155 rStCtrl
.Seek( nFPosMerk
); // restore FilePos
2160 PptSlidePersistList
* SdrPowerPointImport::GetPageList(PptPageKind ePageKind
) const
2162 if ( ePageKind
== PPT_MASTERPAGE
)
2163 return pMasterPages
;
2164 if ( ePageKind
== PPT_SLIDEPAGE
)
2166 if ( ePageKind
== PPT_NOTEPAGE
)
2171 SdrOutliner
* SdrPowerPointImport::GetDrawOutliner( SdrTextObj
* pSdrText
) const
2176 return &pSdrText
->ImpGetDrawOutliner();
2180 SdrObject
* SdrPowerPointImport::ReadObjText( PPTTextObj
* pTextObj
, SdrObject
* pSdrObj
, SdPage
* pPage
) const
2182 SdrTextObj
* pText
= PTR_CAST( SdrTextObj
, pSdrObj
);
2185 if ( !ApplyTextObj( pTextObj
, pText
, pPage
, NULL
, NULL
) )
2192 SdrObject
* SdrPowerPointImport::ApplyTextObj( PPTTextObj
* pTextObj
, SdrTextObj
* pSdrText
, SdPage
* /*pPage*/,
2193 SfxStyleSheet
* pSheet
, SfxStyleSheet
** ppStyleSheetAry
) const
2195 SdrTextObj
* pText
= pSdrText
;
2196 if ( pTextObj
->Count() )
2198 sal_uInt32 nDestinationInstance
= pTextObj
->GetDestinationInstance() ;
2199 SdrOutliner
& rOutliner
= pText
->ImpGetDrawOutliner();
2200 if ( ( pText
->GetObjInventor() == SdrInventor
) && ( pText
->GetObjIdentifier() == OBJ_TITLETEXT
) ) // Outliner-Style for Title-Text object?!? (->of DL)
2201 rOutliner
.Init( OUTLINERMODE_TITLEOBJECT
); // Outliner reset
2203 sal_Bool bOldUpdateMode
= rOutliner
.GetUpdateMode();
2204 rOutliner
.SetUpdateMode( sal_False
);
2207 if ( rOutliner
.GetStyleSheet( 0 ) != pSheet
)
2208 rOutliner
.SetStyleSheet( 0, pSheet
);
2210 rOutliner
.SetVertical( pTextObj
->GetVertical() );
2211 const PPTParagraphObj
* pPreviousParagraph
= NULL
;
2212 for ( PPTParagraphObj
* pPara
= pTextObj
->First(); pPara
; pPara
= pTextObj
->Next() )
2214 sal_uInt32 nTextSize
= pPara
->GetTextSize();
2215 if ( ! ( nTextSize
& 0xffff0000 ) )
2217 PPTPortionObj
* pPortion
;
2218 sal_Unicode
* pParaText
= new sal_Unicode
[ nTextSize
];
2219 sal_Int32 nCurrentIndex
= 0;
2220 for ( pPortion
= pPara
->First(); pPortion
; pPortion
= pPara
->Next() )
2222 if ( pPortion
->mpFieldItem
)
2223 pParaText
[ nCurrentIndex
++ ] = ' ';
2226 sal_Int32 nCharacters
= pPortion
->Count();
2227 const sal_Unicode
* pSource
= pPortion
->maString
.getStr();
2228 sal_Unicode
* pDest
= pParaText
+ nCurrentIndex
;
2231 pPortion
->GetAttrib( PPT_CharAttr_Font
, nFont
, pTextObj
->GetInstance() );
2232 PptFontEntityAtom
* pFontEnityAtom
= GetFontEnityAtom( nFont
);
2233 if ( pFontEnityAtom
&& ( pFontEnityAtom
->eCharSet
== RTL_TEXTENCODING_SYMBOL
) )
2235 sal_Unicode nUnicode
;
2236 for (sal_Int32 i
= 0; i
< nCharacters
; i
++ )
2238 nUnicode
= pSource
[ i
];
2239 if ( ! ( nUnicode
& 0xff00 ) )
2241 pDest
[ i
] = nUnicode
;
2245 memcpy( pDest
, pSource
, nCharacters
<< 1 );
2246 nCurrentIndex
+= nCharacters
;
2249 sal_Int32 nParaIndex
= pTextObj
->GetCurrentIndex();
2250 SfxStyleSheet
* pS
= ( ppStyleSheetAry
) ? ppStyleSheetAry
[ pPara
->pParaSet
->mnDepth
] : pSheet
;
2252 ESelection
aSelection( nParaIndex
, 0, nParaIndex
, 0 );
2253 rOutliner
.Insert( String(), nParaIndex
, pPara
->pParaSet
->mnDepth
);
2254 rOutliner
.QuickInsertText( OUString(pParaText
, nCurrentIndex
), aSelection
);
2255 rOutliner
.SetParaAttribs( nParaIndex
, rOutliner
.GetEmptyItemSet() );
2257 rOutliner
.SetStyleSheet( nParaIndex
, pS
);
2259 for ( pPortion
= pPara
->First(); pPortion
; pPortion
= pPara
->Next() )
2261 SfxItemSet
aPortionAttribs( rOutliner
.GetEmptyItemSet() );
2262 SvxFieldItem
* pFieldItem
= pPortion
->GetTextField();
2265 rOutliner
.QuickInsertField( *pFieldItem
, ESelection( nParaIndex
, aSelection
.nEndPos
, nParaIndex
, aSelection
.nEndPos
+ 1 ) );
2266 aSelection
.nEndPos
++;
2271 const sal_Unicode
*pF
, *pPtr
= pPortion
->maString
.getStr();
2272 const sal_Unicode
*pMax
= pPtr
+ pPortion
->maString
.getLength();
2274 for ( pF
= pPtr
; pPtr
< pMax
; pPtr
++ )
2280 aSelection
.nEndPos
=
2281 sal::static_int_cast
< sal_uInt16
>(
2282 aSelection
.nEndPos
+ nLen
);
2284 rOutliner
.QuickInsertLineBreak( ESelection( nParaIndex
, aSelection
.nEndPos
, nParaIndex
, aSelection
.nEndPos
+ 1 ) );
2285 aSelection
.nEndPos
++;
2290 aSelection
.nEndPos
= sal::static_int_cast
< sal_uInt16
>(
2291 aSelection
.nEndPos
+ nLen
);
2293 pPortion
->ApplyTo( aPortionAttribs
, (SdrPowerPointImport
&)*this, nDestinationInstance
, pTextObj
);
2294 rOutliner
.QuickSetAttribs( aPortionAttribs
, aSelection
);
2296 // set the attribs for the entire paragraph, if it is a placeholder
2297 if ( pTextObj
->GetOEPlaceHolderAtom() && aSelection
.nStartPos
== aSelection
.nEndPos
)
2299 SfxItemSet
& rItemSet
= rOutliner
.GetStyleSheet( nParaIndex
)->GetItemSet();
2300 pPortion
->ApplyTo( rItemSet
, (SdrPowerPointImport
&)*this, nDestinationInstance
, pTextObj
);
2303 aSelection
.nStartPos
= aSelection
.nEndPos
;
2305 boost::optional
< sal_Int16
> oStartNumbering
;
2306 SfxItemSet
aParagraphAttribs( rOutliner
.GetEmptyItemSet() );
2307 pPara
->ApplyTo( aParagraphAttribs
, oStartNumbering
, (SdrPowerPointImport
&)*this, nDestinationInstance
, pPreviousParagraph
);
2309 sal_uInt32 nIsBullet2
= 0; //, nInstance = nDestinationInstance != 0xffffffff ? nDestinationInstance : pTextObj->GetInstance();
2310 pPara
->GetAttrib( PPT_ParaAttr_BulletOn
, nIsBullet2
, nDestinationInstance
);
2312 aParagraphAttribs
.Put( SfxBoolItem( EE_PARA_BULLETSTATE
, sal_False
) );
2314 pPreviousParagraph
= pPara
;
2315 if ( !aSelection
.nStartPos
) // in PPT empty paragraphs never gets a bullet
2317 aParagraphAttribs
.Put( SfxBoolItem( EE_PARA_BULLETSTATE
, sal_False
) );
2319 aSelection
.nStartPos
= 0;
2320 rOutliner
.QuickSetAttribs( aParagraphAttribs
, aSelection
);
2324 OutlinerParaObject
* pNewText
= rOutliner
.CreateParaObject();
2326 rOutliner
.SetUpdateMode( bOldUpdateMode
);
2327 pText
->SetOutlinerParaObject( pNewText
);
2332 sal_Bool
SdrPowerPointImport::SeekToDocument( DffRecordHeader
* pRecHd
) const
2335 sal_uLong nFPosMerk
= rStCtrl
.Tell(); // remember FilePos for restoring it should the situation arise
2336 rStCtrl
.Seek( nDocStreamPos
);
2337 DffRecordHeader aDocHd
;
2339 bRet
= aDocHd
.nRecType
== PPT_PST_Document
;
2345 aDocHd
.SeekToBegOfRecord( rStCtrl
);
2348 rStCtrl
.Seek( nFPosMerk
); // restore FilePos
2352 sal_Bool
SdrPowerPointImport::SeekToContentOfProgTag( sal_Int32 nVersion
, SvStream
& rSt
,
2353 const DffRecordHeader
& rSourceHd
, DffRecordHeader
& rContentHd
)
2355 sal_Bool bRetValue
= sal_False
;
2356 sal_uInt32 nOldPos
= rSt
.Tell();
2358 DffRecordHeader aProgTagsHd
, aProgTagBinaryDataHd
;
2359 rSourceHd
.SeekToContent( rSt
);
2360 sal_Bool bFound
= rSourceHd
.nRecType
== PPT_PST_ProgTags
;
2362 bFound
= SeekToRec( rSt
, PPT_PST_ProgTags
, rSourceHd
.GetRecEndFilePos(), &aProgTagsHd
);
2365 while( SeekToRec( rSt
, PPT_PST_ProgBinaryTag
, aProgTagsHd
.GetRecEndFilePos(), &aProgTagBinaryDataHd
) )
2368 if ( rContentHd
.nRecType
== PPT_PST_CString
)
2371 sal_uInt32 i
= rContentHd
.nRecLen
>> 1;
2374 String aPre
= read_uInt16s_ToOUString(rSt
, n
);
2375 n
= (sal_uInt16
)( i
- 6 );
2376 String aSuf
= read_uInt16s_ToOUString(rSt
, n
);
2377 sal_Int32 nV
= aSuf
.ToInt32();
2378 if ( ( nV
== nVersion
) && ( aPre
== String( RTL_CONSTASCII_USTRINGPARAM( "___PPT" ) ) ) )
2380 rContentHd
.SeekToEndOfRecord( rSt
);
2382 if ( rContentHd
.nRecType
== PPT_PST_BinaryTagData
)
2384 bRetValue
= sal_True
;
2390 aProgTagBinaryDataHd
.SeekToEndOfRecord( rSt
);
2394 rSt
.Seek( nOldPos
);
2398 sal_uInt32
SdrPowerPointImport::GetAktPageId()
2400 PptSlidePersistList
* pList
= GetPageList( eAktPageKind
);
2401 if ( pList
&& nAktPageNum
< pList
->size() )
2402 return (*pList
)[ (sal_uInt16
)nAktPageNum
]->aPersistAtom
.nSlideId
;
2406 sal_Bool
SdrPowerPointImport::SeekToAktPage( DffRecordHeader
* pRecHd
) const
2408 sal_Bool bRet
= sal_False
;
2409 PptSlidePersistList
* pList
= GetPageList( eAktPageKind
);
2410 if ( pList
&& ( nAktPageNum
< pList
->size() ) )
2412 sal_uLong nPersist
= (*pList
)[ (sal_uInt16
)nAktPageNum
]->aPersistAtom
.nPsrReference
;
2413 if ( nPersist
> 0 && nPersist
< nPersistPtrAnz
)
2415 sal_uLong nFPos
= 0;
2416 nFPos
= pPersistPtr
[ nPersist
];
2417 if ( nFPos
< nStreamLen
)
2419 rStCtrl
.Seek( nFPos
);
2429 sal_uInt16
SdrPowerPointImport::GetPageCount( PptPageKind ePageKind
) const
2431 PptSlidePersistList
* pList
= GetPageList( ePageKind
);
2433 return pList
->size();
2437 void SdrPowerPointImport::SetPageNum( sal_uInt16 nPageNum
, PptPageKind eKind
)
2439 eAktPageKind
= eKind
;
2440 nAktPageNum
= nPageNum
;
2442 pPPTStyleSheet
= NULL
;
2444 sal_Bool bHasMasterPage
= sal_True
;
2445 sal_uInt16 nMasterIndex
= 0;
2447 if ( eKind
== PPT_MASTERPAGE
)
2448 nMasterIndex
= nPageNum
;
2451 if ( HasMasterPage( nPageNum
, eKind
) )
2452 nMasterIndex
= GetMasterPageIndex( nPageNum
, eKind
);
2454 bHasMasterPage
= sal_False
;
2456 if ( bHasMasterPage
)
2458 PptSlidePersistList
* pPageList
= GetPageList( PPT_MASTERPAGE
);
2459 if ( pPageList
&& nMasterIndex
< pPageList
->size() )
2461 PptSlidePersistEntry
* pMasterPersist
= (*pPageList
)[ nMasterIndex
];
2462 if ( ( pMasterPersist
->pStyleSheet
== NULL
) && pMasterPersist
->aSlideAtom
.nMasterId
)
2464 nMasterIndex
= pMasterPages
->FindPage( pMasterPersist
->aSlideAtom
.nMasterId
);
2465 if ( nMasterIndex
!= PPTSLIDEPERSIST_ENTRY_NOTFOUND
)
2466 pMasterPersist
= (*pPageList
)[ nMasterIndex
];
2468 pPPTStyleSheet
= pMasterPersist
->pStyleSheet
;
2471 if ( !pPPTStyleSheet
)
2472 pPPTStyleSheet
= pDefaultSheet
;
2475 Size
SdrPowerPointImport::GetPageSize() const
2477 Size
aRet( IsNoteOrHandout( nAktPageNum
, eAktPageKind
) ? aDocAtom
.GetNotesPageSize() : aDocAtom
.GetSlidesPageSize() );
2479 // PPT works with units of 576 dpi in any case. To avoid inacurracies
2480 // I do round the last decimal digit away.
2481 if ( nMapMul
> 2 * nMapDiv
)
2483 MapUnit eMap
= pSdrModel
->GetScaleUnit();
2484 bool bInch
= IsInch( eMap
);
2485 long nInchMul
= 1, nInchDiv
= 1;
2487 { // temporarily convert size (for rounding it) from inch to metric units
2488 Fraction
aFact(GetMapFactor(eMap
,MAP_100TH_MM
).X());
2489 nInchMul
= aFact
.GetNumerator();
2490 nInchDiv
= aFact
.GetDenominator();
2491 aRet
.Width() = BigMulDiv( aRet
.Width(), nInchMul
, nInchDiv
);
2492 aRet
.Height() = BigMulDiv( aRet
.Height(), nInchMul
, nInchDiv
);
2494 aRet
.Width() += 5; aRet
.Width() /= 10; aRet
.Width()*=10;
2495 aRet
.Height() += 5; aRet
.Height() /= 10; aRet
.Height()*=10;
2498 aRet
.Width() = BigMulDiv( aRet
.Width(), nInchDiv
, nInchMul
);
2499 aRet
.Height() = BigMulDiv( aRet
.Height(), nInchDiv
, nInchMul
);
2505 bool SdrPowerPointImport::GetColorFromPalette( sal_uInt16 nNum
, Color
& rColor
) const
2507 if ( nPageColorsNum
!= nAktPageNum
|| ePageColorsKind
!= eAktPageKind
)
2509 sal_uInt16 nSlideFlags
= 0;
2510 PptSlidePersistList
* pPageList
= GetPageList( eAktPageKind
);
2511 if ( pPageList
&& ( nAktPageNum
< pPageList
->size() ) )
2513 PptSlidePersistEntry
* pE
= (*pPageList
)[ nAktPageNum
];
2515 nSlideFlags
= pE
->aSlideAtom
.nFlags
;
2516 if ( ! ( nSlideFlags
& 2 ) )
2517 ((SdrPowerPointImport
*)this)->aPageColors
= pE
->aColorScheme
;
2519 if ( nSlideFlags
& 2 ) // follow master colorscheme?
2521 PptSlidePersistList
* pPageList2
= GetPageList( PPT_MASTERPAGE
);
2524 PptSlidePersistEntry
* pMasterPersist
= NULL
;
2525 if ( eAktPageKind
== PPT_MASTERPAGE
)
2526 pMasterPersist
= (*pPageList2
)[ nAktPageNum
];
2529 if ( HasMasterPage( nAktPageNum
, eAktPageKind
) )
2531 sal_uInt16 nMasterNum
= GetMasterPageIndex( nAktPageNum
, eAktPageKind
);
2532 if ( nMasterNum
< pPageList2
->size() )
2533 pMasterPersist
= (*pPageList2
)[ nMasterNum
];
2536 if ( pMasterPersist
)
2538 while( ( pMasterPersist
&& pMasterPersist
->aSlideAtom
.nFlags
& 2 ) // it is possible that a masterpage
2539 && pMasterPersist
->aSlideAtom
.nMasterId
) // itself is following a master colorscheme
2541 sal_uInt16 nNextMaster
= pMasterPages
->FindPage( pMasterPersist
->aSlideAtom
.nMasterId
);
2542 if ( nNextMaster
== PPTSLIDEPERSIST_ENTRY_NOTFOUND
)
2545 pMasterPersist
= (*pPageList2
)[ nNextMaster
];
2547 ((SdrPowerPointImport
*)this)->aPageColors
= pMasterPersist
->aColorScheme
;
2551 // resgister current color scheme
2552 ((SdrPowerPointImport
*)this)->nPageColorsNum
= nAktPageNum
;
2553 ((SdrPowerPointImport
*)this)->ePageColorsKind
= eAktPageKind
;
2555 rColor
= aPageColors
.GetColor( nNum
);
2559 sal_Bool
SdrPowerPointImport::SeekToShape( SvStream
& rSt
, void* pClientData
, sal_uInt32 nId
) const
2561 sal_Bool bRet
= SvxMSDffManager::SeekToShape( rSt
, pClientData
, nId
);
2564 ProcessData
& rData
= *( (ProcessData
*)pClientData
);
2565 PptSlidePersistEntry
& rPersistEntry
= rData
.rPersistEntry
;
2566 if ( rPersistEntry
.ePageKind
== PPT_SLIDEPAGE
)
2568 if ( HasMasterPage( nAktPageNum
, eAktPageKind
) )
2570 sal_uInt16 nMasterNum
= GetMasterPageIndex( nAktPageNum
, eAktPageKind
);
2571 PptSlidePersistList
* pPageList
= GetPageList( PPT_MASTERPAGE
);
2572 if ( pPageList
&& ( nMasterNum
< pPageList
->size() ) )
2574 PptSlidePersistEntry
* pPersist
= (*pPageList
)[ nMasterNum
]; // get the masterpage's persistentry
2575 if ( pPersist
&& pPersist
->pPresentationObjects
)
2577 sal_uInt32
nCurrent(0L);
2578 DffRecordList
* pCList
= maShapeRecords
.pCList
; // we got a backup of the current position
2580 nCurrent
= pCList
->nCurrent
;
2581 if ( ((SdrEscherImport
*)this )->maShapeRecords
.SeekToContent( rSt
, DFF_msofbtClientData
, SEEK_FROM_CURRENT_AND_RESTART
) )
2583 sal_uInt32 nStreamPos
= rSt
.Tell();
2584 PPTTextObj
aTextObj( rSt
, (SdrPowerPointImport
&)*this, rPersistEntry
, NULL
);
2585 if ( aTextObj
.Count() || aTextObj
.GetOEPlaceHolderAtom() )
2587 sal_uInt32 nShapePos
= 0;
2588 switch ( aTextObj
.GetInstance() )
2590 case TSS_TYPE_TITLE
:
2591 nShapePos
= pPersist
->pPresentationObjects
[ TSS_TYPE_PAGETITLE
];
2593 case TSS_TYPE_PAGETITLE
:
2594 nShapePos
= pPersist
->pPresentationObjects
[ TSS_TYPE_PAGETITLE
];
2596 case TSS_TYPE_SUBTITLE
:
2597 case TSS_TYPE_HALFBODY
:
2598 case TSS_TYPE_QUARTERBODY
:
2599 case TSS_TYPE_BODY
:
2600 nShapePos
= pPersist
->pPresentationObjects
[ TSS_TYPE_BODY
];
2605 rSt
.Seek( nShapePos
);
2610 rSt
.Seek( nStreamPos
);
2612 if ( pCList
) // restoring
2613 pCList
->nCurrent
= nCurrent
;
2614 ((SdrEscherImport
*)this )->maShapeRecords
.pCList
= pCList
;
2623 SdrPage
* SdrPowerPointImport::MakeBlancPage( sal_Bool bMaster
) const
2625 SdrPage
* pRet
= pSdrModel
->AllocPage( bMaster
);
2626 pRet
->SetSize( GetPageSize() );
2631 void ImportComment10( SvxMSDffManager
& rMan
, SvStream
& rStCtrl
, SdrPage
* pPage
, DffRecordHeader
& rComment10Hd
)
2637 sal_Int32 nIndex
= 0;
2638 util::DateTime aDateTime
;
2639 sal_Int32 nPosX
= 0;
2640 sal_Int32 nPosY
= 0;
2642 while ( ( rStCtrl
.GetError() == 0 ) && ( rStCtrl
.Tell() < rComment10Hd
.GetRecEndFilePos() ) )
2644 DffRecordHeader aCommentHd
;
2645 rStCtrl
>> aCommentHd
;
2646 switch( aCommentHd
.nRecType
)
2648 case PPT_PST_CString
:
2650 OUString aString
= SvxMSDffManager::MSDFFReadZString( rStCtrl
,
2651 aCommentHd
.nRecLen
, sal_True
);
2652 switch ( aCommentHd
.nRecInstance
)
2654 case 0 : sAuthor
= aString
; break;
2655 case 1 : sText
= aString
; break;
2656 case 2 : sInitials
= aString
; break;
2661 case PPT_PST_CommentAtom10
:
2666 >> aDateTime
.Day
// DayOfWeek
2669 >> aDateTime
.Minutes
2670 >> aDateTime
.Seconds
2671 >> aDateTime
.NanoSeconds
2675 aDateTime
.NanoSeconds
*= ::Time::nanoPerMilli
;
2679 aCommentHd
.SeekToEndOfRecord( rStCtrl
);
2681 Point
aPosition( nPosX
, nPosY
);
2682 rMan
.Scale( aPosition
);
2686 uno::Reference
< office::XAnnotationAccess
> xAnnotationAccess( pPage
->getUnoPage(), UNO_QUERY_THROW
);
2687 uno::Reference
< office::XAnnotation
> xAnnotation( xAnnotationAccess
->createAndInsertAnnotation() );
2688 xAnnotation
->setPosition( geometry::RealPoint2D( aPosition
.X() / 100.0, aPosition
.Y() / 100.0 ) );
2689 xAnnotation
->setAuthor( sAuthor
);
2690 xAnnotation
->setDateTime( aDateTime
);
2691 uno::Reference
< text::XText
> xText( xAnnotation
->getTextRange() );
2692 xText
->setString( sText
);
2694 catch( const uno::Exception
& )
2701 // be sure not to import masterpages with this method
2702 void SdrPowerPointImport::ImportPage( SdrPage
* pRet
, const PptSlidePersistEntry
* pMasterPersist
)
2704 sal_uInt32 nMerk
= rStCtrl
.Tell();
2705 PptSlidePersistList
* pList
= GetPageList( eAktPageKind
);
2706 if ( ( !pList
) || ( pList
->size() <= nAktPageNum
) )
2708 PptSlidePersistEntry
& rSlidePersist
= *(*pList
)[ nAktPageNum
];
2709 if ( rSlidePersist
.bStarDrawFiller
)
2712 DffRecordHeader aPageHd
;
2713 if ( SeekToAktPage( &aPageHd
) )
2715 rSlidePersist
.pHeaderFooterEntry
= new HeaderFooterEntry( pMasterPersist
);
2716 ProcessData
aProcessData( rSlidePersist
, (SdPage
*)pRet
);
2717 while ( ( rStCtrl
.GetError() == 0 ) && ( rStCtrl
.Tell() < aPageHd
.GetRecEndFilePos() ) )
2719 DffRecordHeader aHd
;
2721 switch ( aHd
.nRecType
)
2723 case PPT_PST_HeadersFooters
:
2725 ImportHeaderFooterContainer( aHd
, *rSlidePersist
.pHeaderFooterEntry
);
2729 case PPT_PST_ProgTags
:
2731 DffRecordHeader aContentDataHd
;
2732 if ( SeekToContentOfProgTag( 10, rStCtrl
, aHd
, aContentDataHd
) )
2734 DffRecordHeader aComment10Hd
;
2735 while( ( rStCtrl
.GetError() == 0 ) && SeekToRec( rStCtrl
, PPT_PST_Comment10
, aContentDataHd
.GetRecEndFilePos(), &aComment10Hd
) )
2737 ImportComment10( *this, rStCtrl
, pRet
, aComment10Hd
);
2738 aComment10Hd
.SeekToEndOfRecord( rStCtrl
);
2744 case PPT_PST_PPDrawing
:
2746 DffRecordHeader aPPDrawHd
;
2747 if ( SeekToRec( rStCtrl
, DFF_msofbtDgContainer
, aHd
.GetRecEndFilePos(), &aPPDrawHd
) )
2749 sal_uInt32 nPPDrawOfs
= rStCtrl
.Tell();
2751 // importing the background object before importing the page
2752 while ( ( rStCtrl
.GetError() == 0 ) && ( rStCtrl
.Tell() < aPPDrawHd
.GetRecEndFilePos() ) )
2754 DffRecordHeader aEscherObjListHd
;
2755 rStCtrl
>> aEscherObjListHd
;
2756 switch ( aEscherObjListHd
.nRecType
)
2758 case DFF_msofbtSpContainer
:
2760 Rectangle
aPageSize( Point(), pRet
->GetSize() );
2761 if ( rSlidePersist
.aSlideAtom
.nFlags
& 4 ) // follow master background?
2763 if ( HasMasterPage( nAktPageNum
, eAktPageKind
) )
2765 sal_uInt16 nMasterNum
= GetMasterPageIndex( nAktPageNum
, eAktPageKind
);
2766 PptSlidePersistList
* pPageList
= GetPageList( PPT_MASTERPAGE
);
2767 PptSlidePersistEntry
* pE
= (*pPageList
)[ nMasterNum
];
2768 while( ( pE
->aSlideAtom
.nFlags
& 4 ) && pE
->aSlideAtom
.nMasterId
)
2770 sal_uInt16 nNextMaster
= pMasterPages
->FindPage( pE
->aSlideAtom
.nMasterId
);
2771 if ( nNextMaster
== PPTSLIDEPERSIST_ENTRY_NOTFOUND
)
2774 pE
= (*pPageList
)[ nNextMaster
];
2776 if ( pE
->nBackgroundOffset
)
2778 // do not follow master colorscheme?
2779 sal_Bool bTemporary
= ( rSlidePersist
.aSlideAtom
.nFlags
& 2 ) != 0;
2780 sal_uInt32 nPos
= rStCtrl
.Tell();
2781 rStCtrl
.Seek( pE
->nBackgroundOffset
);
2782 rSlidePersist
.pBObj
= ImportObj( rStCtrl
, (void*)&aProcessData
, aPageSize
, aPageSize
);
2783 rSlidePersist
.bBObjIsTemporary
= bTemporary
;
2784 rStCtrl
.Seek( nPos
);
2790 DffRecordHeader aShapeHd
;
2791 rStCtrl
>> aShapeHd
;
2792 if ( aShapeHd
.nRecType
== DFF_msofbtSp
)
2794 sal_uInt32 nSpFlags
;
2795 rStCtrl
>> nSpFlags
>> nSpFlags
;
2796 if ( nSpFlags
& SP_FBACKGROUND
)
2798 aEscherObjListHd
.SeekToBegOfRecord( rStCtrl
);
2799 rSlidePersist
.pBObj
= ImportObj( rStCtrl
, (void*)&aProcessData
, aPageSize
, aPageSize
);
2800 rSlidePersist
.bBObjIsTemporary
= sal_False
;
2807 if ( aEscherObjListHd
.nRecType
== DFF_msofbtSpContainer
)
2809 aEscherObjListHd
.SeekToEndOfRecord( rStCtrl
);
2812 // now importing page
2813 rStCtrl
.Seek( nPPDrawOfs
);
2814 while ( ( rStCtrl
.GetError() == 0 ) && ( rStCtrl
.Tell() < aPPDrawHd
.GetRecEndFilePos() ) )
2816 DffRecordHeader aEscherObjListHd
;
2817 rStCtrl
>> aEscherObjListHd
;
2818 switch ( aEscherObjListHd
.nRecType
)
2820 case DFF_msofbtSpgrContainer
:
2822 DffRecordHeader aShapeHd
;
2823 if ( SeekToRec( rStCtrl
, DFF_msofbtSpContainer
, aEscherObjListHd
.GetRecEndFilePos(), &aShapeHd
) )
2825 aShapeHd
.SeekToEndOfRecord( rStCtrl
);
2826 while ( ( rStCtrl
.GetError() == 0 ) && ( rStCtrl
.Tell() < aEscherObjListHd
.GetRecEndFilePos() ) )
2828 rStCtrl
>> aShapeHd
;
2829 if ( ( aShapeHd
.nRecType
== DFF_msofbtSpContainer
) || ( aShapeHd
.nRecType
== DFF_msofbtSpgrContainer
) )
2832 aShapeHd
.SeekToBegOfRecord( rStCtrl
);
2834 aProcessData
.pTableRowProperties
= NULL
;
2835 SdrObject
* pObj
= ImportObj( rStCtrl
, (void*)&aProcessData
, aEmpty
, aEmpty
, 0, &nShapeId
);
2838 if ( aProcessData
.pTableRowProperties
)
2839 pObj
= CreateTable( pObj
, aProcessData
.pTableRowProperties
, aProcessData
.rPersistEntry
.pSolverContainer
);
2841 pRet
->NbcInsertObject( pObj
);
2844 insertShapeId( nShapeId
, pObj
);
2847 aShapeHd
.SeekToEndOfRecord( rStCtrl
);
2853 if ( aEscherObjListHd
.nRecType
== DFF_msofbtSpgrContainer
)
2855 aEscherObjListHd
.SeekToEndOfRecord( rStCtrl
);
2858 /* There are a lot of Shapes which are dependent to
2859 the current background color */
2860 if ( rSlidePersist
.ePageKind
== PPT_SLIDEPAGE
)
2862 if ( !aProcessData
.aBackgroundColoredObjects
.empty() )
2864 if ( rSlidePersist
.pBObj
)
2866 const SfxPoolItem
* pPoolItem
= NULL
;
2867 const SfxItemSet
& rObjectItemSet
= rSlidePersist
.pBObj
->GetMergedItemSet();
2869 //SfxItemState eState = rObjectItemSet.GetItemState( XATTR_FILLCOLOR, sal_False, &pPoolItem );
2872 SfxItemSet
aNewSet(*rObjectItemSet
.GetPool());
2873 aNewSet
.Put(*pPoolItem
);
2874 aNewSet
.Put(XFillStyleItem( XFILL_SOLID
));
2877 size_t i
= 0, n
= aProcessData
.aBackgroundColoredObjects
.size();
2881 aProcessData
.aBackgroundColoredObjects
[ i
]->SetMergedItemSet(aNewSet
);
2887 if ( rSlidePersist
.pBObj
)
2889 // #i99386# transfer the attributes from the temporary BackgroundObject
2890 // to the Page and delete it. Maybe rSlidePersist.bBObjIsTemporary is
2891 // obsolete here, too.
2892 pRet
->getSdrPageProperties().ClearItem();
2893 pRet
->getSdrPageProperties().PutItemSet(rSlidePersist
.pBObj
->GetMergedItemSet());
2894 SdrObject::Free( rSlidePersist
.pBObj
);
2900 aHd
.SeekToEndOfRecord( rStCtrl
);
2902 if ( rSlidePersist
.pSolverContainer
)
2903 SolveSolver( *rSlidePersist
.pSolverContainer
);
2905 rStCtrl
.Seek( nMerk
);
2908 const PptSlideLayoutAtom
* SdrPowerPointImport::GetSlideLayoutAtom() const
2910 PptSlidePersistList
* pPageList
= GetPageList( eAktPageKind
);
2911 if ( pPageList
&& nAktPageNum
< pPageList
->size() )
2913 PptSlidePersistEntry
* pE
= (*pPageList
)[ nAktPageNum
];
2915 return &pE
->aSlideAtom
.aLayout
;
2920 sal_Bool
SdrPowerPointImport::IsNoteOrHandout( sal_uInt16 nPageNum
, PptPageKind
/*ePageKind*/) const
2922 sal_Bool bNote
= eAktPageKind
== PPT_NOTEPAGE
;
2923 if ( eAktPageKind
== PPT_MASTERPAGE
)
2924 bNote
= ( nPageNum
& 1 ) == 0;
2928 sal_uInt32
SdrPowerPointImport::GetMasterPageId( sal_uInt16 nPageNum
, PptPageKind ePageKind
) const
2930 PptSlidePersistList
* pPageList
= GetPageList( ePageKind
);
2931 if ( pPageList
&& nPageNum
< pPageList
->size() )
2932 return (*pPageList
)[ nPageNum
]->aSlideAtom
.nMasterId
;
2936 sal_uInt32
SdrPowerPointImport::GetNotesPageId( sal_uInt16 nPageNum
) const
2938 PptSlidePersistList
* pPageList
=GetPageList( PPT_SLIDEPAGE
);
2939 if ( pPageList
&& nPageNum
< pPageList
->size() )
2940 return (*pPageList
)[ nPageNum
]->aSlideAtom
.nNotesId
;
2944 sal_Bool
SdrPowerPointImport::HasMasterPage( sal_uInt16 nPageNum
, PptPageKind ePageKind
) const
2946 if ( ePageKind
== PPT_NOTEPAGE
)
2947 return aDocAtom
.nNotesMasterPersist
!= 0;
2948 if ( ePageKind
== PPT_MASTERPAGE
)
2950 return GetMasterPageId( nPageNum
, ePageKind
) != 0;
2953 sal_uInt16
SdrPowerPointImport::GetMasterPageIndex( sal_uInt16 nPageNum
, PptPageKind ePageKind
) const
2955 sal_uInt16 nIdx
= 0;
2956 if ( ePageKind
== PPT_NOTEPAGE
)
2958 sal_uInt32 nId
= GetMasterPageId( nPageNum
, ePageKind
);
2959 if ( nId
&& pMasterPages
)
2961 nIdx
= pMasterPages
->FindPage( nId
);
2962 if ( nIdx
== PPTSLIDEPERSIST_ENTRY_NOTFOUND
)
2968 SdrObject
* SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage
& rPage
, sal_uInt32
& nBgFileOffset
, sal_Bool bForce
)
2970 SdrObject
* pRet
= NULL
;
2971 sal_Bool bCreateObj
= bForce
;
2972 SfxItemSet
* pSet
= NULL
;
2973 sal_uLong nFPosMerk
= rStCtrl
.Tell(); // remember FilePos for restoring it later
2974 DffRecordHeader aPageHd
;
2975 if ( SeekToAktPage( &aPageHd
) )
2976 { // and now search for the background attributes of the Page
2977 sal_uLong nPageRecEnd
= aPageHd
.GetRecEndFilePos();
2978 DffRecordHeader aPPDrawHd
;
2979 if ( SeekToRec( rStCtrl
, PPT_PST_PPDrawing
, nPageRecEnd
, &aPPDrawHd
) )
2981 sal_uLong nPPDrawEnd
= aPPDrawHd
.GetRecEndFilePos();
2982 DffRecordHeader aEscherF002Hd
;
2983 if ( SeekToRec( rStCtrl
, DFF_msofbtDgContainer
, nPPDrawEnd
, &aEscherF002Hd
) )
2985 sal_uLong nEscherF002End
= aEscherF002Hd
.GetRecEndFilePos();
2986 DffRecordHeader aEscherObjectHd
;
2987 if ( SeekToRec( rStCtrl
, DFF_msofbtSpContainer
, nEscherF002End
, &aEscherObjectHd
) )
2989 nBgFileOffset
= aEscherObjectHd
.GetRecBegFilePos();
2990 //sal_uLong nEscherObjectEnd = aEscherObjectHd.GetRecEndFilePos();
2991 //DffRecordHeader aEscherPropertiesHd;
2992 if ( SeekToRec( rStCtrl
, DFF_msofbtOPT
,nEscherF002End
) )
2994 rStCtrl
>> (DffPropertyReader
&)*this;
2995 mnFix16Angle
= Fix16ToAngle( GetPropertyValue( DFF_Prop_Rotation
, 0 ) );
2996 sal_uInt32 nColor
= GetPropertyValue( DFF_Prop_fillColor
, 0xffffff );
2997 pSet
= new SfxItemSet( pSdrModel
->GetItemPool() );
2998 DffObjData
aObjData( aEscherObjectHd
, Rectangle( 0, 0, 28000, 21000 ), 0 );
2999 ApplyAttributes( rStCtrl
, *pSet
, aObjData
);
3000 Color
aColor( MSO_CLR_ToColor( nColor
) );
3001 pSet
->Put( XFillColorItem( String(), aColor
) );
3007 rStCtrl
.Seek( nFPosMerk
); // restore FilePos
3012 pSet
= new SfxItemSet( pSdrModel
->GetItemPool() );
3013 pSet
->Put( XFillStyleItem( XFILL_NONE
) );
3015 pSet
->Put( XLineStyleItem( XLINE_NONE
) );
3016 Rectangle
aRect( rPage
.GetLftBorder(), rPage
.GetUppBorder(), rPage
.GetWdt()-rPage
.GetRgtBorder(), rPage
.GetHgt()-rPage
.GetLwrBorder() );
3017 pRet
= new SdrRectObj( aRect
);
3018 pRet
->SetModel( pSdrModel
);
3020 pRet
->SetMergedItemSet(*pSet
);
3022 pRet
->SetMarkProtect( sal_True
);
3023 pRet
->SetMoveProtect( sal_True
);
3024 pRet
->SetResizeProtect( sal_True
);
3030 HeaderFooterEntry::HeaderFooterEntry( const PptSlidePersistEntry
* pMPE
) :
3031 pMasterPersist ( pMPE
),
3036 HeaderFooterEntry
* pMHFE
= pMPE
->pHeaderFooterEntry
;
3039 nAtom
= pMPE
->pHeaderFooterEntry
->nAtom
;
3040 pPlaceholder
[ 0 ] = pMHFE
->pPlaceholder
[ 0 ];
3041 pPlaceholder
[ 1 ] = pMHFE
->pPlaceholder
[ 1 ];
3042 pPlaceholder
[ 2 ] = pMHFE
->pPlaceholder
[ 2 ];
3043 pPlaceholder
[ 3 ] = pMHFE
->pPlaceholder
[ 3 ];
3048 HeaderFooterEntry::~HeaderFooterEntry()
3052 sal_uInt32
HeaderFooterEntry::GetMaskForInstance( sal_uInt32 nInstance
)
3054 sal_uInt32 nRet
= 0;
3055 switch ( nInstance
)
3057 case 0 : nRet
= 0x07ffff; break;
3058 case 1 : nRet
= 0x100000; break;
3059 case 2 : nRet
= 0x200000; break;
3060 case 3 : nRet
= 0x080000; break;
3065 sal_uInt32
HeaderFooterEntry::IsToDisplay( sal_uInt32 nInstance
)
3067 sal_uInt32 nMask
= 0;
3068 switch ( nInstance
)
3070 case 0 : nMask
= 0x010000; break;
3071 case 1 : nMask
= 0x100000; break;
3072 case 2 : nMask
= 0x200000; break;
3073 case 3 : nMask
= 0x080000; break;
3075 return ( nAtom
& nMask
);
3078 // The following method checks if the slide is using a different colorscheme than
3079 // its master, if this is the fact, then the HeaderFooter must probably be
3080 // imported as real sdrobject. In this case, the return value is the offset to the
3081 // master header footer object, so it can be re-loaded with a different color set
3082 sal_uInt32
HeaderFooterEntry::NeedToImportInstance( const sal_uInt32 nInstance
, const PptSlidePersistEntry
& rSlidePersist
)
3084 sal_uInt32 nRet
= 0;
3085 if ( pMasterPersist
)
3087 if ( !( rSlidePersist
.aSlideAtom
.nFlags
& 2 ) )
3088 { // not following the master persist, so we have to check if the colors are changed
3089 if ( memcmp( &rSlidePersist
.aColorScheme
, &pMasterPersist
->aColorScheme
, 32 ) )
3091 nRet
= pMasterPersist
->HeaderFooterOfs
[ nInstance
];
3098 void SdrEscherImport::ImportHeaderFooterContainer( DffRecordHeader
& rHd
, HeaderFooterEntry
& rE
)
3100 rHd
.SeekToContent( rStCtrl
);
3101 while ( ( rStCtrl
.GetError() == 0 ) && ( rStCtrl
.Tell() < rHd
.GetRecEndFilePos() ) )
3103 DffRecordHeader aHd
;
3105 switch ( aHd
.nRecType
)
3107 case PPT_PST_HeadersFootersAtom
:
3108 rStCtrl
>> rE
.nAtom
;
3111 case PPT_PST_CString
:
3113 if ( aHd
.nRecInstance
< 4 )
3115 rE
.pPlaceholder
[ aHd
.nRecInstance
] = MSDFFReadZString( rStCtrl
,
3116 aHd
.nRecLen
, sal_True
);
3121 aHd
.SeekToEndOfRecord( rStCtrl
);
3126 sal_Unicode
SdrPowerPointImport::PPTSubstitute( sal_uInt16
/*nFont*/, sal_Unicode
/*nChar*/,
3127 sal_uInt32
& /*nMappedFontId*/, Font
& /*rFont*/, char /*nDefault*/) const
3132 PPTBuGraEntry::PPTBuGraEntry( Graphic
& rGraphic
, sal_uInt32 nInst
) :
3133 nInstance ( nInst
),
3134 aBuGra ( rGraphic
) {}
3136 PPTExtParaLevel::PPTExtParaLevel()
3137 : mnExtParagraphMask( 0 )
3138 , mnBuBlip( 0xffff )
3142 , mnExtCharacterMask( 0 )
3144 , mbSet( sal_False
)
3147 SvStream
& operator>>( SvStream
& rIn
, PPTExtParaLevel
& rLevel
)
3149 rLevel
.mbSet
= sal_True
;
3150 rIn
>> rLevel
.mnExtParagraphMask
;
3151 if ( rLevel
.mnExtParagraphMask
& 0x00800000 )
3152 rIn
>> rLevel
.mnBuBlip
;
3153 if ( rLevel
.mnExtParagraphMask
& 0x02000000 )
3154 rIn
>> rLevel
.mnHasAnm
;
3155 if ( rLevel
.mnExtParagraphMask
& 0x01000000 )
3156 rIn
>> rLevel
.mnAnmScheme
;
3157 if ( rLevel
.mnExtParagraphMask
& 0x04000000 )
3158 rIn
>> rLevel
.mpfPP10Ext
;
3159 rIn
>> rLevel
.mnExtCharacterMask
;
3160 if ( rLevel
.mnExtCharacterMask
& 0x100000 )
3161 rIn
>> rLevel
.mcfPP10Ext
;
3165 sal_Bool
PPTExtParaProv::GetGraphic( sal_uInt32 nInstance
, Graphic
& rGraph
) const
3167 sal_Bool bRetValue
= sal_False
;
3168 PPTBuGraEntry
* pPtr
= NULL
;
3169 if ( nInstance
< aBuGraList
.size() )
3171 pPtr
= aBuGraList
[ nInstance
];
3172 if ( pPtr
->nInstance
== nInstance
)
3173 bRetValue
= sal_True
;
3177 for (size_t i
= 0; i
< aBuGraList
.size(); i
++ )
3179 pPtr
= aBuGraList
[ i
];
3180 if ( pPtr
->nInstance
== nInstance
)
3182 bRetValue
= sal_True
;
3188 rGraph
= pPtr
->aBuGra
;
3192 PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport
& rMan
, SvStream
& rSt
, const DffRecordHeader
* pHd
) :
3193 bStyles ( sal_False
),
3194 bGraphics ( sal_False
)
3196 sal_uInt32 nOldPos
= rSt
.Tell();
3198 // here we have to get the graphical bullets...
3200 DffRecordHeader aHd
;
3201 DffRecordHeader aContentDataHd
;
3203 const DffRecordHeader
* pListHd
= rMan
.aDocRecManager
.GetRecordHeader( PPT_PST_List
, SEEK_FROM_BEGINNING
);
3206 pListHd
->SeekToContent( rSt
);
3207 if ( !rMan
.SeekToContentOfProgTag( 9, rSt
, *pListHd
, aContentDataHd
) )
3209 while ( ( rSt
.GetError() == 0 ) && ( rSt
.Tell() < aContentDataHd
.GetRecEndFilePos() ) )
3212 switch ( aHd
.nRecType
)
3214 case PPT_PST_ExtendedBuGraContainer
:
3216 while ( ( rSt
.GetError() == 0 ) && ( rSt
.Tell() < aHd
.GetRecEndFilePos() ) )
3219 DffRecordHeader aBuGraAtomHd
;
3220 rSt
>> aBuGraAtomHd
;
3221 if ( aBuGraAtomHd
.nRecType
== PPT_PST_ExtendedBuGraAtom
)
3225 if ( rMan
.GetBLIPDirect( rSt
, aGraphic
, NULL
) )
3227 sal_uInt32 nInstance
= aBuGraAtomHd
.nRecInstance
;
3228 PPTBuGraEntry
* pBuGra
= new PPTBuGraEntry( aGraphic
, nInstance
);
3230 size_t nBuGraCount
= aBuGraList
.size();
3233 if ( aBuGraList
[ nBuGraCount
- 1 ]->nInstance
< nInstance
)
3236 { // maybe the instances are not sorted, we sort it
3237 for ( n
= 0; n
< nBuGraCount
; n
++ )
3238 { // sorting fields ( hi >> lo )
3239 if ( aBuGraList
[ n
]->nInstance
< nInstance
)
3244 if ( n
< nBuGraCount
) {
3245 aBuGraList
.insert( aBuGraList
.begin() + n
, pBuGra
);
3247 aBuGraList
.push_back( pBuGra
);
3251 else OSL_FAIL( "PPTExParaProv::PPTExParaProv - bullet graphic is not valid (SJ)" );
3255 else OSL_FAIL( "PPTExParaProv::PPTExParaProv - unknown atom interpreting the PPT_PST_ExtendedBuGraContainer (SJ)" );
3257 aBuGraAtomHd
.SeekToEndOfRecord( rSt
);
3259 if ( !aBuGraList
.empty() )
3260 bGraphics
= sal_True
;
3264 case PPT_PST_ExtendedPresRuleContainer
:
3265 aExtendedPresRules
.Consume( rSt
, sal_False
, aHd
.GetRecEndFilePos() );
3269 OSL_FAIL( "PPTExParaProv::PPTExParaProv - unknown atom reading ppt2000 num rules (SJ)" );
3270 case PPT_PST_MasterText
: // first seen in: ms-tt02.ppt
3271 case PPT_PST_SrKinsoku
:
3272 case PPT_PST_NewlyAddedAtom4016
:
3273 case PPT_PST_NewlyAddedAtomByPPT2000_6010
:
3274 case PPT_PST_NewlyAddedAtomByPPT2000_6011
:
3275 case PPT_PST_NewlyAddedAtomByXP1037
:
3276 case PPT_PST_NewlyAddedAtomByXP12004
:
3277 case PPT_PST_NewlyAddedAtomByXP14001
:
3281 aHd
.SeekToEndOfRecord( rSt
);
3287 { // get the extended paragraph styles on mainmaster ( graphical bullets, num ruling ... )
3288 if ( !rMan
.SeekToContentOfProgTag( 9, rSt
, *pHd
, aContentDataHd
) )
3290 while ( ( rSt
.GetError() == 0 ) && ( rSt
.Tell() < aContentDataHd
.GetRecEndFilePos() ) )
3293 switch ( aHd
.nRecType
)
3295 case PPT_PST_ExtendedParagraphMasterAtom
:
3297 if ( aHd
.nRecInstance
< PPT_STYLESHEETENTRYS
)
3299 sal_uInt16 nDepth
, i
= 0;
3304 while ( ( rSt
.GetError() == 0 ) && ( rSt
.Tell() < aHd
.GetRecEndFilePos() ) && ( i
< nDepth
) )
3307 rSt
>> aExtParaSheet
[ aHd
.nRecInstance
].aExtParaLevel
[ i
++ ];
3310 if ( rSt
.Tell() != aHd
.GetRecEndFilePos() )
3311 OSL_FAIL( "PPTExParaProv::PPTExParaProv - error reading PPT_PST_ExtendedParagraphMasterAtom (SJ)" );
3315 else OSL_FAIL( "PPTExParaProv::PPTExParaProv - depth is greater than 5 (SJ)" );
3319 else OSL_FAIL( "PPTExParaProv::PPTExParaProv - instance out of range (SJ)" );
3324 OSL_FAIL( "PPTExParaProv::PPTExParaProv - unknown atom, assuming PPT_PST_ExtendedParagraphMasterAtom (SJ)" );
3325 case PPT_PST_NewlyAddedAtomByXP11008
:
3326 case PPT_PST_NewlyAddedAtomByXP11010
:
3327 case PPT_PST_NewlyAddedAtomByXP12010
:
3328 case PPT_PST_NewlyAddedAtomByXP12011
:
3332 aHd
.SeekToEndOfRecord( rSt
);
3336 rSt
.Seek( nOldPos
);
3339 PPTExtParaProv::~PPTExtParaProv()
3341 for ( size_t i
= 0, n
= aBuGraList
.size(); i
< n
; ++i
)
3342 delete aBuGraList
[ i
];
3346 PPTNumberFormatCreator::PPTNumberFormatCreator( PPTExtParaProv
* pParaProv
) :
3347 pExtParaProv ( pParaProv
)
3351 PPTNumberFormatCreator::~PPTNumberFormatCreator()
3353 delete pExtParaProv
;
3356 sal_Bool
PPTNumberFormatCreator::ImplGetExtNumberFormat( SdrPowerPointImport
& rManager
,
3357 SvxNumberFormat
& rNumberFormat
, sal_uInt32 nLevel
, sal_uInt32 nInstance
, sal_uInt32 nDestinationInstance
,
3358 boost::optional
< sal_Int16
>& rStartNumbering
, sal_uInt32 nFontHeight
, PPTParagraphObj
* pPara
)
3360 sal_Bool bHardAttribute
= ( nDestinationInstance
== 0xffffffff );
3362 sal_uInt32 nBuFlags
= 0;
3363 sal_uInt16 nHasAnm
= 0;
3364 sal_uInt32 nAnmScheme
= 0xFFFF0003;
3365 sal_uInt16 nBuBlip
= 0xffff;
3367 const PPTExtParaProv
* pParaProv
= pExtParaProv
;
3368 if ( !pExtParaProv
)
3369 pParaProv
= ( pPara
) ? pPara
->mrStyleSheet
.pExtParaProv
3370 : rManager
.pPPTStyleSheet
->pExtParaProv
;
3373 nBuFlags
= pPara
->pParaSet
->mnExtParagraphMask
;
3376 if ( nBuFlags
& 0x00800000 )
3377 nBuBlip
= pPara
->pParaSet
->mnBuBlip
;
3378 if ( nBuFlags
& 0x01000000 )
3379 nAnmScheme
= pPara
->pParaSet
->mnAnmScheme
;
3380 if ( nBuFlags
& 0x02000000 )
3381 nHasAnm
= pPara
->pParaSet
->mnHasAnm
;
3382 bHardAttribute
= sal_True
;
3386 if ( ( nBuFlags
& 0x03800000 ) != 0x03800000 ) // merge style sheet
3387 { // we have to read the master attributes
3388 if ( pParaProv
&& ( nLevel
< 5 ) )
3390 if ( pParaProv
->bStyles
)
3392 const PPTExtParaLevel
& rLev
= pParaProv
->aExtParaSheet
[ nInstance
].aExtParaLevel
[ nLevel
];
3395 sal_uInt32 nMaBuFlags
= rLev
.mnExtParagraphMask
;
3397 if ( (!( nBuFlags
& 0x00800000)) && ( nMaBuFlags
& 0x00800000 ) )
3399 if (!( nBuFlags
& 0x02000000)) // if there is a BuStart without BuInstance,
3400 nBuBlip
= rLev
.mnBuBlip
; // then there is no graphical Bullet possible
3402 if ( (!( nBuFlags
& 0x01000000)) && ( nMaBuFlags
& 0x01000000 ) )
3403 nAnmScheme
= rLev
.mnAnmScheme
;
3404 if ( (!( nBuFlags
& 0x02000000)) && ( nMaBuFlags
& 0x02000000 ) )
3405 nHasAnm
= rLev
.mnHasAnm
;
3406 nBuFlags
|= nMaBuFlags
;
3411 if ( nBuBlip
!= 0xffff ) // set graphical bullet
3414 if ( pParaProv
->GetGraphic( nBuBlip
, aGraphic
) )
3416 SvxBrushItem
aBrush( aGraphic
, GPOS_MM
, SID_ATTR_BRUSH
);
3417 rNumberFormat
.SetGraphicBrush( &aBrush
);
3418 sal_uInt32 nHeight
= (sal_uInt32
)( (double)nFontHeight
* 0.2540 * nBulletHeight
+ 0.5 );
3419 Size
aPrefSize( aGraphic
.GetPrefSize() );
3420 sal_uInt32 nWidth
= ( nHeight
* aPrefSize
.Width() ) / aPrefSize
.Height();
3421 rNumberFormat
.SetGraphicSize( Size( nWidth
, nHeight
) );
3422 rNumberFormat
.SetNumberingType ( SVX_NUM_BITMAP
);
3427 switch( static_cast< sal_uInt16
>( nAnmScheme
) )
3432 rNumberFormat
.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER
);
3433 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3438 rNumberFormat
.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER
);
3439 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3444 rNumberFormat
.SetNumberingType( SVX_NUM_ARABIC
);
3445 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3450 rNumberFormat
.SetNumberingType( SVX_NUM_ARABIC
);
3451 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3456 rNumberFormat
.SetNumberingType( SVX_NUM_ROMAN_LOWER
);
3457 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3458 rNumberFormat
.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3463 rNumberFormat
.SetNumberingType( SVX_NUM_ROMAN_LOWER
);
3464 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3469 rNumberFormat
.SetNumberingType( SVX_NUM_ROMAN_LOWER
);
3470 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3475 rNumberFormat
.SetNumberingType( SVX_NUM_ROMAN_UPPER
);
3476 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3481 rNumberFormat
.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER
);
3482 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3483 rNumberFormat
.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3488 rNumberFormat
.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER
);
3489 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3494 rNumberFormat
.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER
);
3495 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3496 rNumberFormat
.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3501 rNumberFormat
.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER
);
3502 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3507 rNumberFormat
.SetNumberingType( SVX_NUM_ARABIC
);
3508 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3509 rNumberFormat
.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3514 rNumberFormat
.SetNumberingType( SVX_NUM_ARABIC
);
3519 rNumberFormat
.SetNumberingType( SVX_NUM_ROMAN_UPPER
);
3520 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3521 rNumberFormat
.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) );
3526 rNumberFormat
.SetNumberingType( SVX_NUM_ROMAN_UPPER
);
3527 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) );
3530 case 16: // Simplified Chinese.
3532 rNumberFormat
.SetNumberingType( SVX_NUM_NUMBER_UPPER_ZH
);
3535 case 17: // Simplified Chinese with single-byte period.
3537 rNumberFormat
.SetNumberingType( SVX_NUM_NUMBER_UPPER_ZH
);
3538 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3541 case 18: // Double byte circle numbers.
3542 case 19: // Wingdings white circle numbers.
3543 case 20: // Wingdings black circle numbers.
3545 rNumberFormat
.SetNumberingType( SVX_NUM_CIRCLE_NUMBER
);
3548 case 21: // Traditional Chinese.
3550 rNumberFormat
.SetNumberingType( SVX_NUM_NUMBER_UPPER_ZH_TW
);
3553 case 22: // Traditional Chinese with single-byte period.
3555 rNumberFormat
.SetNumberingType( SVX_NUM_NUMBER_UPPER_ZH_TW
);
3556 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3559 case 26: // Japanese/Korean.
3561 rNumberFormat
.SetNumberingType( SVX_NUM_NUMBER_LOWER_ZH
);
3564 case 27: // Japanese/Korean with single-byte period.
3566 rNumberFormat
.SetNumberingType( SVX_NUM_NUMBER_LOWER_ZH
);
3567 rNumberFormat
.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) );
3570 case 28: // Double-byte Arabic numbers.
3572 rNumberFormat
.SetNumberingType( SVX_NUM_FULL_WIDTH_ARABIC
);
3575 case 29: // Double-byte Arabic numbers with double-byte period.
3577 rNumberFormat
.SetNumberingType( SVX_NUM_FULL_WIDTH_ARABIC
);
3578 rNumberFormat
.SetSuffix( OUString( sal_Unicode(0xff0e) ) );
3581 case 38: // Japanese with double-byte period.
3583 rNumberFormat
.SetNumberingType( SVX_NUM_NUMBER_LOWER_ZH
); // No such type. Instead with Lower Chinese Number
3584 rNumberFormat
.SetSuffix( OUString( sal_Unicode(0xff0e) ) );
3588 rStartNumbering
= boost::optional
< sal_Int16
>( nAnmScheme
>> 16 );
3589 sal_Int16 nBuStart
= *rStartNumbering
;
3590 //The Seventh bit of nBuFlags that specifies whether fBulletHasAutoNumber exists,
3591 //and fBulletHasAutoNumber that specifies whether this paragraph has an automatic numbering scheme.
3592 if ( ( nBuFlags
& 0x02000000 ) && ( nBuStart
!= -1 ))
3594 rNumberFormat
.SetStart( static_cast<sal_uInt16
>(nBuStart
) );
3597 return bHardAttribute
;
3600 void PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport
& rManager
, SvxNumberFormat
& rNumberFormat
, sal_uInt32 nLevel
, const PPTParaLevel
& rParaLevel
, const PPTCharLevel
& rCharLevel
, sal_uInt32 nInstance
)
3602 nIsBullet
= ( rParaLevel
.mnBuFlags
& ( 1 << PPT_ParaAttr_BulletOn
) ) != 0 ? 1 : 0;
3603 nBulletChar
= rParaLevel
.mnBulletChar
;
3605 sal_Bool bBuHardFont
;
3606 bBuHardFont
= ( rParaLevel
.mnBuFlags
& ( 1 << PPT_ParaAttr_BuHardFont
) ) != 0;
3608 nBulletFont
= rParaLevel
.mnBulletFont
;
3610 nBulletFont
= rCharLevel
.mnFont
;
3611 nBulletHeight
= rParaLevel
.mnBulletHeight
;
3612 nBulletColor
= rParaLevel
.mnBulletColor
;
3613 nTextOfs
= rParaLevel
.mnTextOfs
;
3614 nBulletOfs
= rParaLevel
.mnBulletOfs
;
3616 boost::optional
< sal_Int16
> oStartNumbering
;
3617 ImplGetExtNumberFormat( rManager
, rNumberFormat
, nLevel
, nInstance
, 0xffffffff, oStartNumbering
, rCharLevel
.mnFontHeight
, NULL
);
3618 if ( ( rNumberFormat
.GetNumberingType() != SVX_NUM_BITMAP
) && ( nBulletHeight
> 0x7fff ) )
3619 nBulletHeight
= rCharLevel
.mnFontHeight
? ((-((sal_Int16
)nBulletHeight
)) * 100 ) / rCharLevel
.mnFontHeight
: 100;
3620 ImplGetNumberFormat( rManager
, rNumberFormat
, nLevel
);
3621 switch ( rNumberFormat
.GetNumberingType() )
3623 case SVX_NUM_CHARS_UPPER_LETTER
:
3624 case SVX_NUM_CHARS_LOWER_LETTER
:
3625 case SVX_NUM_ROMAN_UPPER
:
3626 case SVX_NUM_ROMAN_LOWER
:
3627 case SVX_NUM_ARABIC
:
3628 case SVX_NUM_CHARS_UPPER_LETTER_N
:
3629 case SVX_NUM_CHARS_LOWER_LETTER_N
:
3631 sal_uInt32 nFont
= rCharLevel
.mnFont
;
3632 PptFontEntityAtom
* pFontEnityAtom
= rManager
.GetFontEnityAtom( nFont
);
3633 if ( pFontEnityAtom
)
3636 aFont
.SetCharSet( pFontEnityAtom
->eCharSet
);
3637 aFont
.SetName( pFontEnityAtom
->aName
);
3638 aFont
.SetFamily( pFontEnityAtom
->eFamily
);
3639 aFont
.SetPitch( pFontEnityAtom
->ePitch
);
3640 rNumberFormat
.SetBulletFont( &aFont
);
3647 sal_Bool
PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport
& rManager
, SvxNumberFormat
& rNumberFormat
, PPTParagraphObj
* pParaObj
,
3648 sal_uInt32 nDestinationInstance
, boost::optional
< sal_Int16
>& rStartNumbering
)
3650 sal_uInt32 nHardCount
= 0;
3651 nHardCount
+= pParaObj
->GetAttrib( PPT_ParaAttr_BulletOn
, nIsBullet
, nDestinationInstance
);
3652 nHardCount
+= pParaObj
->GetAttrib( PPT_ParaAttr_BulletChar
, nBulletChar
, nDestinationInstance
);
3653 nHardCount
+= pParaObj
->GetAttrib( PPT_ParaAttr_BulletFont
, nBulletFont
, nDestinationInstance
);
3654 nHardCount
+= pParaObj
->GetAttrib( PPT_ParaAttr_BulletHeight
, nBulletHeight
, nDestinationInstance
);
3655 nHardCount
+= pParaObj
->GetAttrib( PPT_ParaAttr_BulletColor
, nBulletColor
, nDestinationInstance
);
3656 nHardCount
+= pParaObj
->GetAttrib( PPT_ParaAttr_TextOfs
, nTextOfs
, nDestinationInstance
);
3657 nHardCount
+= pParaObj
->GetAttrib( PPT_ParaAttr_BulletOfs
, nBulletOfs
, nDestinationInstance
);
3660 rNumberFormat
.SetNumberingType( SVX_NUM_CHAR_SPECIAL
);
3662 sal_uInt32 nFontHeight
= 24;
3663 PPTPortionObj
* pPtr
= pParaObj
->First();
3665 pPtr
->GetAttrib( PPT_CharAttr_FontHeight
, nFontHeight
, nDestinationInstance
);
3667 nHardCount
+= ImplGetExtNumberFormat( rManager
, rNumberFormat
, pParaObj
->pParaSet
->mnDepth
,
3668 pParaObj
->mnInstance
, nDestinationInstance
, rStartNumbering
, nFontHeight
, pParaObj
);
3670 if ( rNumberFormat
.GetNumberingType() != SVX_NUM_BITMAP
)
3671 pParaObj
->UpdateBulletRelSize( nBulletHeight
);
3673 ImplGetNumberFormat( rManager
, rNumberFormat
, pParaObj
->pParaSet
->mnDepth
);
3677 switch ( rNumberFormat
.GetNumberingType() )
3679 case SVX_NUM_CHARS_UPPER_LETTER
:
3680 case SVX_NUM_CHARS_LOWER_LETTER
:
3681 case SVX_NUM_ROMAN_UPPER
:
3682 case SVX_NUM_ROMAN_LOWER
:
3683 case SVX_NUM_ARABIC
:
3684 case SVX_NUM_CHARS_UPPER_LETTER_N
:
3685 case SVX_NUM_CHARS_LOWER_LETTER_N
:
3690 pPtr
->GetAttrib( PPT_CharAttr_Font
, nFont
, nDestinationInstance
);
3691 PptFontEntityAtom
* pFontEnityAtom
= rManager
.GetFontEnityAtom( nFont
);
3692 if ( pFontEnityAtom
)
3695 aFont
.SetCharSet( pFontEnityAtom
->eCharSet
);
3696 aFont
.SetName( pFontEnityAtom
->aName
);
3697 aFont
.SetFamily( pFontEnityAtom
->eFamily
);
3698 aFont
.SetPitch( pFontEnityAtom
->ePitch
);
3699 rNumberFormat
.SetBulletFont( &aFont
);
3706 return ( nHardCount
) ? sal_True
: sal_False
;
3709 void PPTNumberFormatCreator::ImplGetNumberFormat( SdrPowerPointImport
& rManager
, SvxNumberFormat
& rNumberFormat
, sal_uInt32
/*nLevel*/)
3712 PptFontEntityAtom
* pAtom
= rManager
.GetFontEnityAtom( nBulletFont
);
3715 CharSet
eCharSet( pAtom
->eCharSet
);
3716 aFont
.SetName( pAtom
->aName
);
3717 aFont
.SetCharSet( eCharSet
);
3718 aFont
.SetFamily( pAtom
->eFamily
);
3719 aFont
.SetPitch( pAtom
->ePitch
);
3721 Color
aCol( rManager
.MSO_TEXT_CLR_ToColor( nBulletColor
) );
3722 aFont
.SetColor( aCol
);
3724 sal_uInt16 nBuChar
= (sal_uInt16
)nBulletChar
;
3725 if ( aFont
.GetCharSet() == RTL_TEXTENCODING_SYMBOL
)
3730 rNumberFormat
.SetBulletFont( &aFont
);
3731 rNumberFormat
.SetBulletChar( nBuChar
);
3732 rNumberFormat
.SetBulletRelSize( (sal_uInt16
)nBulletHeight
);
3733 rNumberFormat
.SetBulletColor( aCol
);
3734 sal_uInt16 nAbsLSpace
= (sal_uInt16
)( ( (sal_uInt32
)nTextOfs
* 2540 ) / 576 );
3735 sal_uInt16 nFirstLineOffset
= nAbsLSpace
- (sal_uInt16
)( ( (sal_uInt32
)nBulletOfs
* 2540 ) / 576 );
3736 rNumberFormat
.SetAbsLSpace( nAbsLSpace
);
3737 rNumberFormat
.SetFirstLineOffset( -nFirstLineOffset
);
3740 PPTCharSheet::PPTCharSheet( sal_uInt32 nInstance
)
3742 sal_uInt32 nColor
= PPT_COLSCHEME_TEXT_UND_ZEILEN
;
3743 sal_uInt16
nFontHeight(0);
3744 switch ( nInstance
)
3746 case TSS_TYPE_PAGETITLE
:
3747 case TSS_TYPE_TITLE
:
3749 nColor
= PPT_COLSCHEME_TITELTEXT
;
3753 case TSS_TYPE_BODY
:
3754 case TSS_TYPE_SUBTITLE
:
3755 case TSS_TYPE_HALFBODY
:
3756 case TSS_TYPE_QUARTERBODY
:
3759 case TSS_TYPE_NOTES
:
3762 case TSS_TYPE_UNUSED
:
3763 case TSS_TYPE_TEXT_IN_SHAPE
:
3767 for ( sal_uInt32 nDepth
= 0; nDepth
< 5; nDepth
++ )
3769 maCharLevel
[ nDepth
].mnFlags
= 0;
3770 maCharLevel
[ nDepth
].mnFont
= 0;
3771 maCharLevel
[ nDepth
].mnAsianOrComplexFont
= 0xffff;
3772 maCharLevel
[ nDepth
].mnFontHeight
= nFontHeight
;
3773 maCharLevel
[ nDepth
].mnFontColor
= nColor
;
3774 maCharLevel
[ nDepth
].mnFontColorInStyleSheet
= Color( (sal_uInt8
)nColor
, (sal_uInt8
)( nColor
>> 8 ), (sal_uInt8
)( nColor
>> 16 ) );
3775 maCharLevel
[ nDepth
].mnEscapement
= 0;
3779 PPTCharSheet::PPTCharSheet( const PPTCharSheet
& rAttr
)
3784 void PPTCharSheet::Read( SvStream
& rIn
, sal_Bool
/*bMasterStyle*/, sal_uInt32 nLevel
, sal_Bool
/*bFirst*/)
3791 if ( nCMask
& 0x0000FFFF )
3793 sal_uInt16 nBitAttr
;
3794 maCharLevel
[ nLevel
].mnFlags
&= ~( (sal_uInt16
)nCMask
);
3795 rIn
>> nBitAttr
; // Bit attributes (bold, underlined, ...)
3796 maCharLevel
[ nLevel
].mnFlags
|= nBitAttr
;
3798 if ( nCMask
& ( 1 << PPT_CharAttr_Font
) ) // 0x00010000
3799 rIn
>> maCharLevel
[ nLevel
].mnFont
;
3800 if ( nCMask
& ( 1 << PPT_CharAttr_AsianOrComplexFont
) ) // 0x00200000
3801 rIn
>> maCharLevel
[ nLevel
].mnAsianOrComplexFont
;
3802 if ( nCMask
& ( 1 << PPT_CharAttr_ANSITypeface
) ) // 0x00400000
3804 if ( nCMask
& ( 1 << PPT_CharAttr_Symbol
) ) // 0x00800000
3806 if ( nCMask
& ( 1 << PPT_CharAttr_FontHeight
) ) // 0x00020000
3807 rIn
>> maCharLevel
[ nLevel
].mnFontHeight
;
3808 if ( nCMask
& ( 1 << PPT_CharAttr_FontColor
) ) // 0x00040000
3810 rIn
>> maCharLevel
[ nLevel
].mnFontColor
;
3811 if( ! (maCharLevel
[ nLevel
].mnFontColor
& 0xff000000 ) )
3812 maCharLevel
[ nLevel
].mnFontColor
= PPT_COLSCHEME_HINTERGRUND
;
3814 if ( nCMask
& ( 1 << PPT_CharAttr_Escapement
) ) // 0x00080000
3815 rIn
>> maCharLevel
[ nLevel
].mnEscapement
;
3816 if ( nCMask
& 0x00100000 ) // 0x00100000
3824 OSL_FAIL( "PPTCharSheet::Read - unknown attribute, send me this document (SJ)" );
3831 PPTParaSheet::PPTParaSheet( sal_uInt32 nInstance
)
3833 sal_uInt16 nBuFlags
= 0;
3834 sal_uInt32 nBulletColor
= 0x8000000;
3835 sal_uInt16 nUpperDist
= 0;
3837 switch ( nInstance
)
3839 case TSS_TYPE_PAGETITLE
:
3840 case TSS_TYPE_TITLE
:
3841 nBulletColor
= PPT_COLSCHEME_TITELTEXT
;
3843 case TSS_TYPE_BODY
:
3844 case TSS_TYPE_SUBTITLE
:
3845 case TSS_TYPE_HALFBODY
:
3846 case TSS_TYPE_QUARTERBODY
:
3852 case TSS_TYPE_NOTES
:
3856 for ( sal_uInt32 i
= 0; i
< 5; i
++ )
3858 maParaLevel
[ i
].mnBuFlags
= nBuFlags
;
3859 maParaLevel
[ i
].mnBulletChar
= 0x2022;
3860 maParaLevel
[ i
].mnBulletFont
= 0;
3861 maParaLevel
[ i
].mnBulletHeight
= 100;
3862 maParaLevel
[ i
].mnBulletColor
= nBulletColor
;
3863 maParaLevel
[ i
].mnAdjust
= 0;
3864 maParaLevel
[ i
].mnLineFeed
= 100;
3865 maParaLevel
[ i
].mnLowerDist
= 0;
3866 maParaLevel
[ i
].mnUpperDist
= nUpperDist
;
3867 maParaLevel
[ i
].mnTextOfs
= 0;
3868 maParaLevel
[ i
].mnBulletOfs
= 0;
3869 maParaLevel
[ i
].mnDefaultTab
= 0x240;
3870 maParaLevel
[ i
].mnAsianLineBreak
= 0;
3871 maParaLevel
[ i
].mnBiDi
= 0;
3875 PPTParaSheet::PPTParaSheet( const PPTParaSheet
& rSheet
)
3880 void PPTParaSheet::Read( SdrPowerPointImport
&
3884 , SvStream
& rIn
, sal_Bool
/*bMasterStyle*/,
3885 sal_uInt32 nLevel
, sal_Bool bFirst
)
3888 sal_uInt16 nVal16
, i
, nMask16
;
3889 sal_uInt32 nVal32
, nPMask
;
3892 nMask16
= (sal_uInt16
)nPMask
& 0xf;
3896 maParaLevel
[ nLevel
].mnBuFlags
&=~ nMask16
;
3898 maParaLevel
[ nLevel
].mnBuFlags
|= nVal16
;
3900 if ( nPMask
& 0x0080 )
3901 rIn
>> maParaLevel
[ nLevel
].mnBulletChar
;
3902 if ( nPMask
& 0x0010 )
3903 rIn
>> maParaLevel
[ nLevel
].mnBulletFont
;
3904 if ( nPMask
& 0x0040 )
3907 maParaLevel
[ nLevel
].mnBulletHeight
= nVal16
;
3909 if ( nPMask
& 0x0020 )
3912 maParaLevel
[ nLevel
].mnBulletColor
= nVal32
;
3916 if ( nPMask
& 0xF00 )
3919 maParaLevel
[ nLevel
].mnAdjust
= nVal16
& 3;
3921 if ( nPMask
& 0x1000 )
3922 rIn
>> maParaLevel
[ nLevel
].mnLineFeed
;
3923 if ( nPMask
& 0x2000 )
3924 rIn
>> maParaLevel
[ nLevel
].mnUpperDist
;
3925 if ( nPMask
& 0x4000 )
3926 rIn
>> maParaLevel
[ nLevel
].mnLowerDist
;
3927 if ( nPMask
& 0x8000 )
3928 rIn
>> maParaLevel
[ nLevel
].mnTextOfs
;
3929 if ( nPMask
& 0x10000 )
3930 rIn
>> maParaLevel
[ nLevel
].mnBulletOfs
;
3931 if ( nPMask
& 0x20000 )
3932 rIn
>> maParaLevel
[ nLevel
].mnDefaultTab
;
3933 if ( nPMask
& 0x200000 )
3935 // number of tabulators
3937 for ( i
= 0; i
< nVal16
; i
++ )
3938 rIn
>> nVal32
; // reading the tabulators
3940 if ( nPMask
& 0x40000 )
3942 if ( nPMask
& 0x80000 )
3943 rIn
>> maParaLevel
[ nLevel
].mnAsianLineBreak
;
3944 if ( nPMask
& 0x100000 )
3945 rIn
>> maParaLevel
[ nLevel
].mnBiDi
;
3949 if ( nPMask
& 0x800 )
3952 maParaLevel
[ nLevel
].mnAdjust
= nVal16
& 3;
3954 if ( nPMask
& 0x1000 )
3955 rIn
>> maParaLevel
[ nLevel
].mnLineFeed
;
3956 if ( nPMask
& 0x2000 )
3957 rIn
>> maParaLevel
[ nLevel
].mnUpperDist
;
3958 if ( nPMask
& 0x4000 )
3959 rIn
>> maParaLevel
[ nLevel
].mnLowerDist
;
3960 if ( nPMask
& 0x8000 )
3962 if ( nPMask
& 0x100 )
3963 rIn
>> maParaLevel
[ nLevel
].mnTextOfs
;
3964 if ( nPMask
& 0x200 )
3966 if ( nPMask
& 0x400 )
3967 rIn
>> maParaLevel
[ nLevel
].mnBulletOfs
;
3968 if ( nPMask
& 0x10000 )
3970 if ( nPMask
& 0xe0000 )
3972 sal_uInt16 nFlagsToModifyMask
= (sal_uInt16
)( ( nPMask
>> 17 ) & 7 );
3974 // bits that are not involved to zero
3975 nVal16
&= nFlagsToModifyMask
;
3976 // bits that are to change to zero
3977 maParaLevel
[ nLevel
].mnAsianLineBreak
&=~nFlagsToModifyMask
;
3978 // now set the corresponding bits
3979 maParaLevel
[ nLevel
].mnAsianLineBreak
|= nVal16
;
3981 if ( nPMask
& 0x100000 )
3983 // number of tabulators
3985 for ( i
= 0; i
< nVal16
; i
++ )
3986 rIn
>> nVal32
; // reading the tabulators
3988 if ( nPMask
& 0x200000 )
3989 rIn
>> maParaLevel
[ nLevel
].mnBiDi
; // #88602#
3998 if (!(rManager
.rImportParam
.nImportFlags
& PPT_IMPORTFLAGS_NO_TEXT_ASSERT
))
4000 OSL_FAIL( "PPTParaSheet::Read - unknown attribute, send me this document (SJ)" );
4009 void PPTParaSheet::UpdateBulletRelSize( sal_uInt32 nLevel
, sal_uInt16 nFontHeight
)
4011 if ( maParaLevel
[ nLevel
].mnBulletHeight
> 0x7fff ) // a negative value is the absolute bullet height
4013 sal_Int16 nBulletRelSize
= ( sal_Int16
)maParaLevel
[ nLevel
].mnBulletHeight
;
4014 nBulletRelSize
= nFontHeight
? ((-nBulletRelSize
) * 100 ) / nFontHeight
: 100;
4015 if ( nBulletRelSize
< 0 ) //bullet size over flow
4016 nBulletRelSize
= 100;
4017 maParaLevel
[ nLevel
].mnBulletHeight
= nBulletRelSize
;
4021 PPTStyleSheet::PPTStyleSheet( const DffRecordHeader
& rSlideHd
, SvStream
& rIn
, SdrPowerPointImport
& rManager
,
4022 const PPTTextCharacterStyleAtomInterpreter
& /*rTxCFStyle*/, const PPTTextParagraphStyleAtomInterpreter
& rTxPFStyle
,
4023 const PPTTextSpecInfo
& rTextSpecInfo
) :
4025 PPTNumberFormatCreator ( new PPTExtParaProv( rManager
, rIn
, &rSlideHd
) ),
4026 maTxSI ( rTextSpecInfo
)
4029 sal_uInt32 nOldFilePos
= rIn
.Tell();
4031 // default stylesheets
4032 mpCharSheet
[ TSS_TYPE_PAGETITLE
] = new PPTCharSheet( TSS_TYPE_PAGETITLE
);
4033 mpCharSheet
[ TSS_TYPE_BODY
] = new PPTCharSheet( TSS_TYPE_BODY
);
4034 mpCharSheet
[ TSS_TYPE_NOTES
] = new PPTCharSheet( TSS_TYPE_NOTES
);
4035 mpCharSheet
[ TSS_TYPE_UNUSED
] = new PPTCharSheet( TSS_TYPE_UNUSED
); // this entry is not used by ppt
4036 mpCharSheet
[ TSS_TYPE_TEXT_IN_SHAPE
] = new PPTCharSheet( TSS_TYPE_TEXT_IN_SHAPE
);
4037 mpParaSheet
[ TSS_TYPE_PAGETITLE
] = new PPTParaSheet( TSS_TYPE_PAGETITLE
);
4038 mpParaSheet
[ TSS_TYPE_BODY
] = new PPTParaSheet( TSS_TYPE_BODY
);
4039 mpParaSheet
[ TSS_TYPE_NOTES
] = new PPTParaSheet( TSS_TYPE_NOTES
);
4040 mpParaSheet
[ TSS_TYPE_UNUSED
] = new PPTParaSheet( TSS_TYPE_UNUSED
);
4041 mpParaSheet
[ TSS_TYPE_TEXT_IN_SHAPE
] = new PPTParaSheet( TSS_TYPE_TEXT_IN_SHAPE
);
4042 mpCharSheet
[ TSS_TYPE_QUARTERBODY
] = mpCharSheet
[ TSS_TYPE_HALFBODY
] = mpCharSheet
[ TSS_TYPE_TITLE
] = mpCharSheet
[ TSS_TYPE_SUBTITLE
] = NULL
;
4043 mpParaSheet
[ TSS_TYPE_QUARTERBODY
] = mpParaSheet
[ TSS_TYPE_HALFBODY
] = mpParaSheet
[ TSS_TYPE_TITLE
] = mpParaSheet
[ TSS_TYPE_SUBTITLE
] = NULL
;
4045 /* SJ: try to locate the txMasterStyleAtom in the Environment
4047 it seems that the environment TextStyle is having a higher priority
4048 than the TextStyle that can be found within the master page
4050 sal_Bool bFoundTxMasterStyleAtom04
= sal_False
;
4051 DffRecordHeader
* pEnvHeader
= rManager
.aDocRecManager
.GetRecordHeader( PPT_PST_Environment
);
4054 pEnvHeader
->SeekToContent( rIn
);
4055 DffRecordHeader aTxMasterStyleHd
;
4056 while ( rIn
.Tell() < pEnvHeader
->GetRecEndFilePos() )
4058 rIn
>> aTxMasterStyleHd
;
4059 if ( aTxMasterStyleHd
.nRecType
== PPT_PST_TxMasterStyleAtom
)
4061 sal_uInt16 nLevelAnz
;
4064 sal_uInt16 nLev
= 0;
4065 sal_Bool bFirst
= sal_True
;
4066 bFoundTxMasterStyleAtom04
= sal_True
;
4067 while ( rIn
.GetError() == 0 && rIn
.Tell() < aTxMasterStyleHd
.GetRecEndFilePos() && nLev
< nLevelAnz
)
4071 mpParaSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maParaLevel
[ nLev
] = mpParaSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maParaLevel
[ nLev
- 1 ];
4072 mpCharSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maCharLevel
[ nLev
] = mpCharSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maCharLevel
[ nLev
- 1 ];
4074 mpParaSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->Read( rManager
, rIn
, sal_True
, nLev
, bFirst
);
4077 // set paragraph defaults for instance 4 (TSS_TYPE_TEXT_IN_SHAPE)
4078 if ( rTxPFStyle
.bValid
)
4080 PPTParaLevel
& rParaLevel
= mpParaSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maParaLevel
[ 0 ];
4081 rParaLevel
.mnAsianLineBreak
= 0;
4082 if ( rTxPFStyle
.bForbiddenRules
)
4083 rParaLevel
.mnAsianLineBreak
|= 1;
4084 if ( !rTxPFStyle
.bLatinTextWrap
)
4085 rParaLevel
.mnAsianLineBreak
|= 2;
4086 if ( rTxPFStyle
.bHangingPunctuation
)
4087 rParaLevel
.mnAsianLineBreak
|= 4;
4090 mpCharSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->Read( rIn
, sal_True
, nLev
, bFirst
);
4091 mpParaSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->UpdateBulletRelSize( nLev
, mpCharSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maCharLevel
[ nLev
].mnFontHeight
);
4098 aTxMasterStyleHd
.SeekToEndOfRecord( rIn
);
4102 rSlideHd
.SeekToContent( rIn
);
4103 DffRecordHeader aTxMasterStyleHd
;
4104 while ( rIn
.Tell() < rSlideHd
.GetRecEndFilePos() )
4106 rIn
>> aTxMasterStyleHd
;
4107 if ( aTxMasterStyleHd
.nRecType
== PPT_PST_TxMasterStyleAtom
)
4110 aTxMasterStyleHd
.SeekToEndOfRecord( rIn
);
4112 while ( ( aTxMasterStyleHd
.nRecType
== PPT_PST_TxMasterStyleAtom
) && ( rIn
.Tell() < rSlideHd
.GetRecEndFilePos() ) ) //TODO: aTxMasterStyleHd may be used without having been properly initialized
4114 sal_uInt32 nInstance
= aTxMasterStyleHd
.nRecInstance
;
4115 if ( ( nInstance
< PPT_STYLESHEETENTRYS
) &&
4116 ( ( nInstance
!= TSS_TYPE_TEXT_IN_SHAPE
) || ( bFoundTxMasterStyleAtom04
== sal_False
) ) )
4118 if ( nInstance
> 4 )
4120 delete mpCharSheet
[ nInstance
]; // be sure to delete the old one if this instance comes twice
4121 delete mpParaSheet
[ nInstance
];
4123 switch ( nInstance
)
4125 case TSS_TYPE_SUBTITLE
:
4127 mpCharSheet
[ TSS_TYPE_SUBTITLE
] = new PPTCharSheet( *( mpCharSheet
[ TSS_TYPE_BODY
] ) );
4128 mpParaSheet
[ TSS_TYPE_SUBTITLE
] = new PPTParaSheet( *( mpParaSheet
[ TSS_TYPE_BODY
] ) );
4131 case TSS_TYPE_TITLE
:
4133 mpCharSheet
[ TSS_TYPE_TITLE
] = new PPTCharSheet( *( mpCharSheet
[ TSS_TYPE_PAGETITLE
] ) );
4134 mpParaSheet
[ TSS_TYPE_TITLE
] = new PPTParaSheet( *( mpParaSheet
[ TSS_TYPE_PAGETITLE
] ) );
4137 case TSS_TYPE_HALFBODY
:
4139 mpCharSheet
[ TSS_TYPE_HALFBODY
] = new PPTCharSheet( *( mpCharSheet
[ TSS_TYPE_BODY
] ) );
4140 mpParaSheet
[ TSS_TYPE_HALFBODY
] = new PPTParaSheet( *( mpParaSheet
[ TSS_TYPE_BODY
] ) );
4144 case TSS_TYPE_QUARTERBODY
:
4146 mpCharSheet
[ TSS_TYPE_QUARTERBODY
] = new PPTCharSheet( *( mpCharSheet
[ TSS_TYPE_BODY
] ) );
4147 mpParaSheet
[ TSS_TYPE_QUARTERBODY
] = new PPTParaSheet( *( mpParaSheet
[ TSS_TYPE_BODY
] ) );
4152 sal_uInt16 nLevelAnz
;
4154 if ( nLevelAnz
> 5 )
4156 OSL_FAIL( "PPTStyleSheet::Ppt-TextStylesheet hat mehr als 5 Ebenen! (SJ)" );
4159 sal_uInt16 nLev
= 0;
4160 sal_Bool bFirst
= sal_True
;
4162 while ( rIn
.GetError() == 0 && rIn
.Tell() < aTxMasterStyleHd
.GetRecEndFilePos() && nLev
< nLevelAnz
)
4164 if ( nLev
&& ( nInstance
< 5 ) )
4166 mpParaSheet
[ nInstance
]->maParaLevel
[ nLev
] = mpParaSheet
[ nInstance
]->maParaLevel
[ nLev
- 1 ];
4167 mpCharSheet
[ nInstance
]->maCharLevel
[ nLev
] = mpCharSheet
[ nInstance
]->maCharLevel
[ nLev
- 1 ];
4170 // Exception: Template 5, 6 (MasterTitle Title und SubTitle)
4171 if ( nInstance
>= TSS_TYPE_SUBTITLE
)
4175 sal_uInt16 nDontKnow
;
4178 mpParaSheet
[ nInstance
]->Read( rManager
, rIn
, sal_True
, nLev
, bFirst
);
4179 mpCharSheet
[ nInstance
]->Read( rIn
, sal_True
, nLev
, bFirst
);
4180 mpParaSheet
[ nInstance
]->UpdateBulletRelSize( nLev
, mpCharSheet
[ nInstance
]->maCharLevel
[ nLev
].mnFontHeight
);
4185 if (!(rManager
.rImportParam
.nImportFlags
& PPT_IMPORTFLAGS_NO_TEXT_ASSERT
))
4187 if ( rIn
.GetError() == 0 )
4190 if ( rIn
.Tell() > aTxMasterStyleHd
.GetRecEndFilePos() )
4192 aMsg
.append("\n reading too many bytes:" +
4193 OString::number(rIn
.Tell() - aTxMasterStyleHd
.GetRecEndFilePos()));
4195 if ( rIn
.Tell() < aTxMasterStyleHd
.GetRecEndFilePos() )
4197 aMsg
.append("\n reading too few bytes:" +
4198 OString::number(aTxMasterStyleHd
.GetRecEndFilePos() - rIn
.Tell()));
4200 if (aMsg
.getLength())
4202 aMsg
.insert(0, "PptStyleSheet::operator>>[]");
4203 OSL_FAIL(aMsg
.getStr());
4206 if ( rIn
.Tell() != aTxMasterStyleHd
.GetRecEndFilePos() )
4207 DBG_ASSERT(0, "SJ: Falsche Anzahl von Bytes gelesen beim Import der PPT-Formatvorlagen");
4211 aTxMasterStyleHd
.SeekToEndOfRecord( rIn
);
4212 rIn
>> aTxMasterStyleHd
;
4214 if ( !mpCharSheet
[ TSS_TYPE_SUBTITLE
] )
4216 mpCharSheet
[ TSS_TYPE_SUBTITLE
] = new PPTCharSheet( *( mpCharSheet
[ TSS_TYPE_BODY
] ) );
4217 mpParaSheet
[ TSS_TYPE_SUBTITLE
] = new PPTParaSheet( *( mpParaSheet
[ TSS_TYPE_BODY
] ) );
4219 if ( !mpCharSheet
[ TSS_TYPE_TITLE
] )
4221 mpCharSheet
[ TSS_TYPE_TITLE
] = new PPTCharSheet( *( mpCharSheet
[ TSS_TYPE_PAGETITLE
] ) );
4222 mpParaSheet
[ TSS_TYPE_TITLE
] = new PPTParaSheet( *( mpParaSheet
[ TSS_TYPE_PAGETITLE
] ) );
4224 if ( !mpCharSheet
[ TSS_TYPE_HALFBODY
] )
4226 mpCharSheet
[ TSS_TYPE_HALFBODY
] = new PPTCharSheet( *( mpCharSheet
[ TSS_TYPE_BODY
] ) );
4227 mpParaSheet
[ TSS_TYPE_HALFBODY
] = new PPTParaSheet( *( mpParaSheet
[ TSS_TYPE_BODY
] ) );
4229 if ( !mpCharSheet
[ TSS_TYPE_QUARTERBODY
] )
4231 mpCharSheet
[ TSS_TYPE_QUARTERBODY
] = new PPTCharSheet( *( mpCharSheet
[ TSS_TYPE_BODY
] ) );
4232 mpParaSheet
[ TSS_TYPE_QUARTERBODY
] = new PPTParaSheet( *( mpParaSheet
[ TSS_TYPE_BODY
] ) );
4234 if ( !bFoundTxMasterStyleAtom04
)
4235 { // try to locate the txMasterStyleAtom in the Environment
4236 DffRecordHeader
* pEnvHeader2
= rManager
.aDocRecManager
.GetRecordHeader( PPT_PST_Environment
);
4239 pEnvHeader2
->SeekToContent( rIn
);
4240 DffRecordHeader aTxMasterStyleHd2
;
4241 while ( rIn
.Tell() < pEnvHeader2
->GetRecEndFilePos() )
4243 rIn
>> aTxMasterStyleHd2
;
4244 if ( aTxMasterStyleHd2
.nRecType
== PPT_PST_TxMasterStyleAtom
)
4246 sal_uInt16 nLevelAnz
;
4249 sal_uInt16 nLev
= 0;
4250 sal_Bool bFirst
= sal_True
;
4251 while ( rIn
.GetError() == 0 && rIn
.Tell() < aTxMasterStyleHd2
.GetRecEndFilePos() && nLev
< nLevelAnz
)
4255 mpParaSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maParaLevel
[ nLev
] = mpParaSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maParaLevel
[ nLev
- 1 ];
4256 mpCharSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maCharLevel
[ nLev
] = mpCharSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maCharLevel
[ nLev
- 1 ];
4258 mpParaSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->Read( rManager
, rIn
, sal_True
, nLev
, bFirst
);
4261 // set paragraph defaults for instance 4 (TSS_TYPE_TEXT_IN_SHAPE)
4262 if ( rTxPFStyle
.bValid
)
4264 PPTParaLevel
& rParaLevel
= mpParaSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maParaLevel
[ 0 ];
4265 rParaLevel
.mnAsianLineBreak
= 0;
4266 if ( rTxPFStyle
.bForbiddenRules
)
4267 rParaLevel
.mnAsianLineBreak
|= 1;
4268 if ( !rTxPFStyle
.bLatinTextWrap
)
4269 rParaLevel
.mnAsianLineBreak
|= 2;
4270 if ( rTxPFStyle
.bHangingPunctuation
)
4271 rParaLevel
.mnAsianLineBreak
|= 4;
4274 mpCharSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->Read( rIn
, sal_True
, nLev
, bFirst
);
4275 mpParaSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->UpdateBulletRelSize( nLev
, mpCharSheet
[ TSS_TYPE_TEXT_IN_SHAPE
]->maCharLevel
[ nLev
].mnFontHeight
);
4282 aTxMasterStyleHd2
.SeekToEndOfRecord( rIn
);
4286 rIn
.Seek( nOldFilePos
);
4288 // will will create the default numbulletitem for each instance
4289 for ( i
= 0; i
< PPT_STYLESHEETENTRYS
; i
++ )
4291 sal_uInt16 nLevels
, nDepth
= 0;
4292 SvxNumRuleType eNumRuleType
;
4296 case TSS_TYPE_PAGETITLE
:
4297 case TSS_TYPE_TITLE
:
4299 eNumRuleType
= SVX_RULETYPE_NUMBERING
;
4301 case TSS_TYPE_SUBTITLE
:
4302 nLevels
= SVX_MAX_NUM
;
4303 eNumRuleType
= SVX_RULETYPE_NUMBERING
;
4305 case TSS_TYPE_BODY
:
4306 case TSS_TYPE_HALFBODY
:
4307 case TSS_TYPE_QUARTERBODY
:
4308 nLevels
= SVX_MAX_NUM
;
4309 eNumRuleType
= SVX_RULETYPE_PRESENTATION_NUMBERING
;
4312 case TSS_TYPE_NOTES
:
4313 case TSS_TYPE_UNUSED
:
4314 case TSS_TYPE_TEXT_IN_SHAPE
:
4315 nLevels
= SVX_MAX_NUM
;
4316 eNumRuleType
= SVX_RULETYPE_NUMBERING
;
4319 SvxNumRule
aRule( NUM_BULLET_REL_SIZE
| NUM_BULLET_COLOR
|
4320 NUM_CHAR_TEXT_DISTANCE
| NUM_SYMBOL_ALIGNMENT
,
4321 nLevels
, sal_False
, eNumRuleType
);
4322 for ( sal_uInt16 nCount
= 0; nDepth
< nLevels
; nCount
++ )
4324 const PPTParaLevel
& rParaLevel
= mpParaSheet
[ i
]->maParaLevel
[ nCount
];
4325 const PPTCharLevel
& rCharLevel
= mpCharSheet
[ i
]->maCharLevel
[ nCount
];
4326 SvxNumberFormat
aNumberFormat( SVX_NUM_CHAR_SPECIAL
);
4327 aNumberFormat
.SetBulletChar( ' ' );
4328 GetNumberFormat( rManager
, aNumberFormat
, nCount
, rParaLevel
, rCharLevel
, i
);
4329 aRule
.SetLevel( nDepth
++, aNumberFormat
);
4332 for ( ;nDepth
< nLevels
; nDepth
++ )
4333 aRule
.SetLevel( nDepth
, aNumberFormat
);
4334 if ( eNumRuleType
== SVX_RULETYPE_PRESENTATION_NUMBERING
)
4335 aRule
.SetLevel( 0, aNumberFormat
);
4338 mpNumBulletItem
[ i
] = new SvxNumBulletItem( aRule
, EE_PARA_NUMBULLET
);
4342 PPTStyleSheet::~PPTStyleSheet()
4344 for ( sal_uInt32 i
= 0; i
< PPT_STYLESHEETENTRYS
; i
++ )
4346 delete mpCharSheet
[ i
];
4347 delete mpParaSheet
[ i
];
4348 delete mpNumBulletItem
[ i
];
4352 PPTParaPropSet::PPTParaPropSet() :
4353 pParaSet( new ImplPPTParaPropSet
)
4355 pParaSet
->mnHasAnm
= 1;
4358 PPTParaPropSet::PPTParaPropSet( PPTParaPropSet
& rParaPropSet
)
4360 pParaSet
= rParaPropSet
.pParaSet
;
4361 pParaSet
->mnRefCount
++;
4363 mnOriginalTextPos
= rParaPropSet
.mnOriginalTextPos
;
4366 PPTParaPropSet::~PPTParaPropSet()
4368 if ( ! ( --pParaSet
->mnRefCount
) )
4372 PPTParaPropSet
& PPTParaPropSet::operator=( PPTParaPropSet
& rParaPropSet
)
4374 if ( this != &rParaPropSet
)
4376 if ( ! ( --pParaSet
->mnRefCount
) )
4378 pParaSet
= rParaPropSet
.pParaSet
;
4379 pParaSet
->mnRefCount
++;
4381 mnOriginalTextPos
= rParaPropSet
.mnOriginalTextPos
;
4386 PPTCharPropSet::PPTCharPropSet( sal_uInt32 nParagraph
) :
4387 mnParagraph ( nParagraph
),
4388 mpFieldItem ( NULL
),
4389 pCharSet ( new ImplPPTCharPropSet
)
4391 mnHylinkOrigColor
= 0;
4392 mbIsHyperlink
= sal_False
;
4393 mbHardHylinkOrigColor
= sal_False
;
4394 mnLanguage
[ 0 ] = mnLanguage
[ 1 ] = mnLanguage
[ 2 ] = 0;
4397 PPTCharPropSet::PPTCharPropSet( const PPTCharPropSet
& rCharPropSet
)
4399 mnHylinkOrigColor
= rCharPropSet
.mnHylinkOrigColor
;
4400 mbIsHyperlink
= rCharPropSet
.mbIsHyperlink
;
4401 mbHardHylinkOrigColor
= rCharPropSet
.mbHardHylinkOrigColor
;
4402 pCharSet
= rCharPropSet
.pCharSet
;
4403 pCharSet
->mnRefCount
++;
4405 mnParagraph
= rCharPropSet
.mnParagraph
;
4406 mnOriginalTextPos
= rCharPropSet
.mnOriginalTextPos
;
4407 maString
= rCharPropSet
.maString
;
4408 mpFieldItem
= ( rCharPropSet
.mpFieldItem
) ? new SvxFieldItem( *rCharPropSet
.mpFieldItem
) : NULL
;
4409 mnLanguage
[ 0 ] = rCharPropSet
.mnLanguage
[ 0 ];
4410 mnLanguage
[ 1 ] = rCharPropSet
.mnLanguage
[ 1 ];
4411 mnLanguage
[ 2 ] = rCharPropSet
.mnLanguage
[ 2 ];
4414 PPTCharPropSet::PPTCharPropSet( const PPTCharPropSet
& rCharPropSet
, sal_uInt32 nParagraph
)
4416 pCharSet
= rCharPropSet
.pCharSet
;
4417 pCharSet
->mnRefCount
++;
4419 mnHylinkOrigColor
= rCharPropSet
.mnHylinkOrigColor
;
4420 mbIsHyperlink
= rCharPropSet
.mbIsHyperlink
;
4421 mbHardHylinkOrigColor
= rCharPropSet
.mbHardHylinkOrigColor
;
4423 mnParagraph
= nParagraph
;
4424 mnOriginalTextPos
= rCharPropSet
.mnOriginalTextPos
;
4425 maString
= rCharPropSet
.maString
;
4426 mpFieldItem
= ( rCharPropSet
.mpFieldItem
) ? new SvxFieldItem( *rCharPropSet
.mpFieldItem
) : NULL
;
4427 mnLanguage
[ 0 ] = mnLanguage
[ 1 ] = mnLanguage
[ 2 ] = 0;
4430 PPTCharPropSet::~PPTCharPropSet()
4432 if ( ! ( --pCharSet
->mnRefCount
) )
4437 PPTCharPropSet
& PPTCharPropSet::operator=( const PPTCharPropSet
& rCharPropSet
)
4439 if ( this != &rCharPropSet
)
4441 if ( ! ( --pCharSet
->mnRefCount
) )
4443 pCharSet
= rCharPropSet
.pCharSet
;
4444 pCharSet
->mnRefCount
++;
4446 mnOriginalTextPos
= rCharPropSet
.mnOriginalTextPos
;
4447 mnParagraph
= rCharPropSet
.mnParagraph
;
4448 maString
= rCharPropSet
.maString
;
4449 mpFieldItem
= ( rCharPropSet
.mpFieldItem
) ? new SvxFieldItem( *rCharPropSet
.mpFieldItem
) : NULL
;
4454 void PPTCharPropSet::ImplMakeUnique()
4456 if ( pCharSet
->mnRefCount
> 1 )
4458 ImplPPTCharPropSet
& rOld
= *pCharSet
;
4460 pCharSet
= new ImplPPTCharPropSet( rOld
);
4461 pCharSet
->mnRefCount
= 1;
4465 void PPTCharPropSet::SetFont( sal_uInt16 nFont
)
4467 sal_uInt32 nMask
= 1 << PPT_CharAttr_Font
;
4468 sal_uInt32 bDoNotMake
= pCharSet
->mnAttrSet
& nMask
;
4471 bDoNotMake
= nFont
== pCharSet
->mnFont
;
4476 pCharSet
->mnFont
= nFont
;
4477 pCharSet
->mnAttrSet
|= nMask
;
4481 void PPTCharPropSet::SetColor( sal_uInt32 nColor
)
4484 pCharSet
->mnColor
= nColor
;
4485 pCharSet
->mnAttrSet
|= 1 << PPT_CharAttr_FontColor
;
4488 PPTRuler::PPTRuler()
4491 , nDefaultTab(0x240)
4495 memset(nTextOfs
, 0, sizeof(nTextOfs
));
4496 memset(nBulletOfs
, 0, sizeof(nBulletOfs
));
4499 PPTRuler::~PPTRuler()
4505 PPTTextRulerInterpreter::PPTTextRulerInterpreter() :
4506 mpImplRuler ( new PPTRuler() )
4510 PPTTextRulerInterpreter::PPTTextRulerInterpreter( PPTTextRulerInterpreter
& rRuler
)
4512 mpImplRuler
= rRuler
.mpImplRuler
;
4513 mpImplRuler
->nRefCount
++;
4516 PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs
, SdrPowerPointImport
& rMan
, DffRecordHeader
& rHeader
, SvStream
& rIn
) :
4517 mpImplRuler ( new PPTRuler() )
4519 if ( nFileOfs
!= 0xffffffff )
4521 sal_uInt32 nOldPos
= rIn
.Tell();
4522 DffRecordHeader rHd
;
4525 rIn
.Seek( nFileOfs
);
4530 rHeader
.SeekToContent( rIn
);
4531 if ( rMan
.SeekToRec( rIn
, PPT_PST_TextRulerAtom
, rHeader
.GetRecEndFilePos(), &rHd
) )
4538 rIn
>> mpImplRuler
->nFlags
;
4540 // number of indent levels, unused now
4541 if ( mpImplRuler
->nFlags
& 2 )
4543 if ( mpImplRuler
->nFlags
& 1 )
4544 rIn
>> mpImplRuler
->nDefaultTab
;
4545 if ( mpImplRuler
->nFlags
& 4 )
4550 mpImplRuler
->nTabCount
= (sal_uInt16
)nTCount
;
4551 mpImplRuler
->pTab
= new PPTTabEntry
[ mpImplRuler
->nTabCount
];
4552 for ( i
= 0; i
< nTCount
; i
++ )
4554 rIn
>> mpImplRuler
->pTab
[ i
].nOffset
4555 >> mpImplRuler
->pTab
[ i
].nStyle
;
4559 for ( i
= 0; i
< 5; i
++ )
4561 if ( mpImplRuler
->nFlags
& ( 8 << i
) )
4562 rIn
>> mpImplRuler
->nTextOfs
[ i
];
4563 if ( mpImplRuler
->nFlags
& ( 256 << i
) )
4564 rIn
>> mpImplRuler
->nBulletOfs
[ i
];
4565 if( mpImplRuler
->nBulletOfs
[ i
] > 0x7fff)
4568 // when bullet offset is > 0x7fff, the paragraph should look like
4569 // * first line text
4572 // we add to bullet para indent 0xffff - bullet offset. it looks like
4573 // best we can do for now
4574 mpImplRuler
->nTextOfs
[ i
] += 0xffff - mpImplRuler
->nBulletOfs
[ i
];
4575 mpImplRuler
->nBulletOfs
[ i
] = 0;
4579 rIn
.Seek( nOldPos
);
4583 sal_Bool
PPTTextRulerInterpreter::GetDefaultTab( sal_uInt32
/*nLevel*/, sal_uInt16
& nValue
) const
4585 if ( ! ( mpImplRuler
->nFlags
& 1 ) )
4587 nValue
= mpImplRuler
->nDefaultTab
;
4591 sal_Bool
PPTTextRulerInterpreter::GetTextOfs( sal_uInt32 nLevel
, sal_uInt16
& nValue
) const
4593 if ( ! ( ( nLevel
< 5 ) && ( mpImplRuler
->nFlags
& ( 8 << nLevel
) ) ) )
4595 nValue
= mpImplRuler
->nTextOfs
[ nLevel
];
4599 sal_Bool
PPTTextRulerInterpreter::GetBulletOfs( sal_uInt32 nLevel
, sal_uInt16
& nValue
) const
4601 if ( ! ( ( nLevel
< 5 ) && ( mpImplRuler
->nFlags
& ( 256 << nLevel
) ) ) )
4603 nValue
= mpImplRuler
->nBulletOfs
[ nLevel
];
4607 PPTTextRulerInterpreter
& PPTTextRulerInterpreter::operator=( PPTTextRulerInterpreter
& rRuler
)
4609 if ( this != &rRuler
)
4611 if ( ! ( --mpImplRuler
->nRefCount
) )
4613 mpImplRuler
= rRuler
.mpImplRuler
;
4614 mpImplRuler
->nRefCount
++;
4619 PPTTextRulerInterpreter::~PPTTextRulerInterpreter()
4621 if ( ! ( --mpImplRuler
->nRefCount
) )
4625 PPTTextCharacterStyleAtomInterpreter::PPTTextCharacterStyleAtomInterpreter() :
4632 sal_Bool
PPTTextCharacterStyleAtomInterpreter::Read( SvStream
& rIn
, const DffRecordHeader
& rRecHd
)
4634 rRecHd
.SeekToContent( rIn
);
4646 PPTTextCharacterStyleAtomInterpreter::~PPTTextCharacterStyleAtomInterpreter()
4650 PPTTextParagraphStyleAtomInterpreter::PPTTextParagraphStyleAtomInterpreter() :
4651 bValid ( sal_False
),
4652 bForbiddenRules ( sal_False
),
4653 bHangingPunctuation ( sal_False
),
4654 bLatinTextWrap ( sal_False
)
4658 sal_Bool
PPTTextParagraphStyleAtomInterpreter::Read( SvStream
& rIn
, const DffRecordHeader
& rRecHd
)
4661 rRecHd
.SeekToContent( rIn
);
4662 sal_uInt32 nDummy32
, nFlags
, nRecEndPos
= rRecHd
.GetRecEndFilePos();
4663 sal_uInt16 nDummy16
;
4668 if ( nFlags
& 0xf && ( rIn
.Tell() < nRecEndPos
) )
4669 rIn
>> nDummy16
; // BuFlags
4670 if ( nFlags
& 0x80 && ( rIn
.Tell() < nRecEndPos
) )
4671 rIn
>> nDummy16
; // BuChar
4672 if ( nFlags
& 0x10 && ( rIn
.Tell() < nRecEndPos
) )
4673 rIn
>> nDummy16
; // nBuFont;
4674 if ( nFlags
& 0x40 && ( rIn
.Tell() < nRecEndPos
) )
4675 rIn
>> nDummy16
; // nBuHeight;
4676 if ( nFlags
& 0x0020 && ( rIn
.Tell() < nRecEndPos
) )
4677 rIn
>> nDummy32
; // nBuColor;
4678 if ( nFlags
& 0x800 && ( rIn
.Tell() < nRecEndPos
) )
4679 rIn
>> nDummy16
; // AbsJust!
4680 if ( nFlags
& 0x400 && ( rIn
.Tell() < nRecEndPos
) )
4682 if ( nFlags
& 0x200 && ( rIn
.Tell() < nRecEndPos
) )
4684 if ( nFlags
& 0x100 && ( rIn
.Tell() < nRecEndPos
) )
4686 if ( nFlags
& 0x1000 && ( rIn
.Tell() < nRecEndPos
) )
4687 rIn
>> nDummy16
; // LineFeed
4688 if ( nFlags
& 0x2000 && ( rIn
.Tell() < nRecEndPos
) )
4689 rIn
>> nDummy16
; // nUpperDist
4690 if ( nFlags
& 0x4000 && ( rIn
.Tell() < nRecEndPos
) )
4691 rIn
>> nDummy16
; // nLowerDist
4692 if ( nFlags
& 0x8000 && ( rIn
.Tell() < nRecEndPos
) )
4694 if ( nFlags
& 0x10000 && ( rIn
.Tell() < nRecEndPos
) )
4696 if ( nFlags
& 0xe0000 && ( rIn
.Tell() < nRecEndPos
) )
4699 if ( nFlags
& 0x20000 )
4700 bForbiddenRules
= ( nDummy16
& 1 ) == 1;
4701 if ( nFlags
& 0x40000 )
4702 bLatinTextWrap
= ( nDummy16
& 2 ) == 0;
4703 if ( nFlags
& 0x80000 )
4704 bHangingPunctuation
= ( nDummy16
& 4 ) == 4;
4707 sal_uInt32 nMask
= 0x100000;
4708 while ( nFlags
&& nMask
&& ( rIn
.Tell() < nRecEndPos
) )
4710 if ( nFlags
& nMask
)
4717 bValid
= rIn
.Tell() == nRecEndPos
;
4721 PPTTextParagraphStyleAtomInterpreter::~PPTTextParagraphStyleAtomInterpreter()
4726 PPTTextSpecInfo::PPTTextSpecInfo( sal_uInt32 _nCharIdx
) :
4727 nCharIdx ( _nCharIdx
),
4730 nLanguage
[ 0 ] = 0x400;
4735 PPTTextSpecInfo::~PPTTextSpecInfo()
4739 PPTTextSpecInfoAtomInterpreter::PPTTextSpecInfoAtomInterpreter() :
4740 bValid ( sal_False
)
4744 sal_Bool
PPTTextSpecInfoAtomInterpreter::Read( SvStream
& rIn
, const DffRecordHeader
& rRecHd
,
4745 sal_uInt16 nRecordType
, const PPTTextSpecInfo
* pTextSpecDefault
)
4748 sal_uInt32 nCharIdx
= 0;
4749 rRecHd
.SeekToContent( rIn
);
4751 while ( rIn
.Tell() < rRecHd
.GetRecEndFilePos() )
4753 sal_uInt32 nCharCount
,
4756 if ( nRecordType
== PPT_PST_TextSpecInfoAtom
)
4759 nCharIdx
+= nCharCount
;
4763 PPTTextSpecInfo
* pEntry
= new PPTTextSpecInfo( nCharIdx
);
4764 if ( pTextSpecDefault
)
4766 pEntry
->nDontKnow
= pTextSpecDefault
->nDontKnow
;
4767 pEntry
->nLanguage
[ 0 ] = pTextSpecDefault
->nLanguage
[ 0 ];
4768 pEntry
->nLanguage
[ 1 ] = pTextSpecDefault
->nLanguage
[ 1 ];
4769 pEntry
->nLanguage
[ 2 ] = pTextSpecDefault
->nLanguage
[ 2 ];
4771 for ( i
= 1; nFlags
&& i
; i
<<= 1 )
4773 sal_uInt16 nLang
= 0;
4774 switch( nFlags
& i
)
4777 case 1 : rIn
>> pEntry
->nDontKnow
; break;
4778 case 2 : rIn
>> nLang
; break;
4779 case 4 : rIn
>> nLang
; break;
4787 sal_uInt16 nScriptType
= GetI18NScriptTypeOfLanguage( nLang
);
4788 if ( nScriptType
& SCRIPTTYPE_LATIN
)
4789 pEntry
->nLanguage
[ 0 ] = nLang
;
4790 if ( nScriptType
& SCRIPTTYPE_ASIAN
)
4791 pEntry
->nLanguage
[ 1 ] = nLang
;
4792 if ( nScriptType
& SCRIPTTYPE_COMPLEX
)
4793 pEntry
->nLanguage
[ 2 ] = nLang
;
4797 aList
.push_back( pEntry
);
4799 bValid
= rIn
.Tell() == rRecHd
.GetRecEndFilePos();
4803 PPTTextSpecInfoAtomInterpreter::~PPTTextSpecInfoAtomInterpreter()
4805 for ( size_t i
= 0, n
= aList
.size(); i
< n
; ++i
) {
4811 void StyleTextProp9::Read( SvStream
& rIn
)
4813 rIn
>> mnExtParagraphMask
;
4814 if ( mnExtParagraphMask
& 0x800000 )
4816 if ( mnExtParagraphMask
& 0x2000000 )
4818 if ( mnExtParagraphMask
& 0x1000000 )
4820 if ( mnExtParagraphMask
& 0x4000000 )
4822 rIn
>> mnExtCharacterMask
;
4823 if ( mnExtCharacterMask
& 0x100000 )
4825 rIn
>> mnSpecialInfoMask
;
4826 if ( mnSpecialInfoMask
& 0x20 )
4828 if ( mnSpecialInfoMask
& 0x40 )
4832 PPTStyleTextPropReader::PPTStyleTextPropReader( SvStream
& rIn
, SdrPowerPointImport
& rMan
, const DffRecordHeader
& rTextHeader
,
4833 PPTTextRulerInterpreter
& rRuler
, const DffRecordHeader
& rExtParaHd
, sal_uInt32 nInstance
)
4835 Init(rIn
, rMan
, rTextHeader
, rRuler
, rExtParaHd
, nInstance
);
4838 void PPTStyleTextPropReader::ReadParaProps( SvStream
& rIn
, SdrPowerPointImport
& rMan
, const DffRecordHeader
& rTextHeader
,
4839 const OUString
& aString
, PPTTextRulerInterpreter
& rRuler
,
4840 sal_uInt32
& nCharCount
, sal_Bool
& bTextPropAtom
)
4842 sal_uInt32 nMask
= 0; //TODO: nMask initialized here to suppress warning for now, see corresponding TODO below
4843 sal_uInt32 nCharAnzRead
= 0;
4844 sal_uInt16 nDummy16
;
4846 sal_uInt16 nStringLen
= aString
.getLength();
4848 DffRecordHeader aTextHd2
;
4849 rTextHeader
.SeekToContent( rIn
);
4850 if ( rMan
.SeekToRec( rIn
, PPT_PST_StyleTextPropAtom
, rTextHeader
.GetRecEndFilePos(), &aTextHd2
) )
4851 bTextPropAtom
= sal_True
;
4852 while ( nCharAnzRead
<= nStringLen
)
4854 PPTParaPropSet aParaPropSet
;
4855 ImplPPTParaPropSet
& aSet
= *aParaPropSet
.pParaSet
;
4856 if ( bTextPropAtom
)
4859 >> aParaPropSet
.pParaSet
->mnDepth
; // indent depth
4861 aParaPropSet
.pParaSet
->mnDepth
= // taking care of about using not more than 9 outliner levels
4862 std::min(sal_uInt16(8),
4863 aParaPropSet
.pParaSet
->mnDepth
);
4868 aSet
.mnAttrSet
= nMask
& 0x207df7;
4869 sal_uInt16 nBulFlg
= 0;
4871 rIn
>> nBulFlg
; // Bullet-HardAttr-Flags
4872 aSet
.mpArry
[ PPT_ParaAttr_BulletOn
] = ( nBulFlg
& 1 ) ? 1 : 0;
4873 aSet
.mpArry
[ PPT_ParaAttr_BuHardFont
] = ( nBulFlg
& 2 ) ? 1 : 0;
4874 aSet
.mpArry
[ PPT_ParaAttr_BuHardColor
] = ( nBulFlg
& 4 ) ? 1 : 0;
4876 if ( nMask
& 0x0080 ) // buChar
4877 rIn
>> aSet
.mpArry
[ PPT_ParaAttr_BulletChar
];
4878 if ( nMask
& 0x0010 ) // buTypeface
4879 rIn
>> aSet
.mpArry
[ PPT_ParaAttr_BulletFont
];
4880 if ( nMask
& 0x0040 ) // buSize
4882 rIn
>> aSet
.mpArry
[ PPT_ParaAttr_BulletHeight
];
4883 if ( ! ( ( nMask
& ( 1 << PPT_ParaAttr_BuHardHeight
) )
4884 && ( nBulFlg
& ( 1 << PPT_ParaAttr_BuHardHeight
) ) ) )
4885 aSet
.mnAttrSet
^= 0x40;
4887 if ( nMask
& 0x0020 ) // buColor
4889 sal_uInt32 nVal32
, nHiByte
;
4891 nHiByte
= nVal32
>> 24;
4893 nVal32
= nHiByte
| PPT_COLSCHEME
;
4894 aSet
.mnBulletColor
= nVal32
;
4896 if ( nMask
& 0x0800 ) // pfAlignment
4899 aSet
.mpArry
[ PPT_ParaAttr_Adjust
] = nDummy16
& 3;
4901 if ( nMask
& 0x1000 ) // pfLineSpacing
4902 rIn
>> aSet
.mpArry
[ PPT_ParaAttr_LineFeed
];
4903 if ( nMask
& 0x2000 ) // pfSpaceBefore
4904 rIn
>> aSet
.mpArry
[ PPT_ParaAttr_UpperDist
];
4905 if ( nMask
& 0x4000 ) // pfSpaceAfter
4906 rIn
>> aSet
.mpArry
[ PPT_ParaAttr_LowerDist
];
4907 if ( nMask
& 0x100 ) // pfLeftMargin
4909 rIn
>> aSet
.mpArry
[ PPT_ParaAttr_TextOfs
];
4910 aSet
.mnAttrSet
|= 1 << PPT_ParaAttr_TextOfs
;
4912 if ( nMask
& 0x400 ) // pfIndent
4914 rIn
>> aSet
.mpArry
[ PPT_ParaAttr_BulletOfs
];
4915 aSet
.mnAttrSet
|= 1 << PPT_ParaAttr_BulletOfs
;
4917 if ( nMask
& 0x8000 ) // pfDefaultTabSize
4919 if ( nMask
& 0x100000 ) // pfTabStops
4921 sal_uInt16 i
, nDistance
, nAlignment
, nNumberOfTabStops
= 0;
4922 rIn
>> nNumberOfTabStops
;
4923 for ( i
= 0; i
< nNumberOfTabStops
; i
++ )
4929 if ( nMask
& 0x10000 ) // pfBaseLine
4931 if ( nMask
& 0xe0000 ) // pfCharWrap, pfWordWrap, pfOverflow
4934 if ( nMask
& 0x20000 )
4935 aSet
.mpArry
[ PPT_ParaAttr_AsianLB_1
] = nDummy16
& 1;
4936 if ( nMask
& 0x40000 )
4937 aSet
.mpArry
[ PPT_ParaAttr_AsianLB_2
] = ( nDummy16
>> 1 ) & 1;
4938 if ( nMask
& 0x80000 )
4939 aSet
.mpArry
[ PPT_ParaAttr_AsianLB_3
] = ( nDummy16
>> 2 ) & 1;
4940 aSet
.mnAttrSet
|= ( ( nMask
>> 17 ) & 7 ) << PPT_ParaAttr_AsianLB_1
;
4942 if ( nMask
& 0x200000 ) // pfTextDirection
4943 rIn
>> aSet
.mpArry
[ PPT_ParaAttr_BiDi
];
4946 nCharCount
= nStringLen
;
4948 //if the textofs attr has been read at above, need not to reset.
4949 if ( ( !( aSet
.mnAttrSet
& 1 << PPT_ParaAttr_TextOfs
) ) && rRuler
.GetTextOfs( aParaPropSet
.pParaSet
->mnDepth
, aSet
.mpArry
[ PPT_ParaAttr_TextOfs
] ) )
4950 aSet
.mnAttrSet
|= 1 << PPT_ParaAttr_TextOfs
;
4951 if ( ( !( aSet
.mnAttrSet
& 1 << PPT_ParaAttr_BulletOfs
) ) && rRuler
.GetBulletOfs( aParaPropSet
.pParaSet
->mnDepth
, aSet
.mpArry
[ PPT_ParaAttr_BulletOfs
] ) )
4952 aSet
.mnAttrSet
|= 1 << PPT_ParaAttr_BulletOfs
;
4953 if ( rRuler
.GetDefaultTab( aParaPropSet
.pParaSet
->mnDepth
, aSet
.mpArry
[ PPT_ParaAttr_DefaultTab
] ) )
4954 aSet
.mnAttrSet
|= 1 << PPT_ParaAttr_DefaultTab
;
4956 if ( ( nCharCount
> nStringLen
) || ( nStringLen
< nCharAnzRead
+ nCharCount
) )
4958 bTextPropAtom
= sal_False
;
4959 nCharCount
= nStringLen
- nCharAnzRead
;
4960 // please fix the right hand side of
4961 // PPTParaPropSet& PPTParaPropSet::operator=(PPTParaPropSet&),
4962 // it should be a const reference
4963 PPTParaPropSet aTmpPPTParaPropSet
;
4964 aParaPropSet
= aTmpPPTParaPropSet
;
4965 OSL_FAIL( "SJ:PPTStyleTextPropReader::could not get this PPT_PST_StyleTextPropAtom by reading the paragraph attributes" );
4967 PPTParaPropSet
* pPara
= new PPTParaPropSet( aParaPropSet
);
4968 pPara
->mnOriginalTextPos
= nCharAnzRead
;
4969 aParaPropList
.push_back( pPara
);
4973 const sal_Unicode
* pDat
= aString
.getStr() + nCharAnzRead
;
4974 for ( nCount
= 0; nCount
< nCharCount
; nCount
++ )
4976 if ( pDat
[ nCount
] == 0xd )
4978 pPara
= new PPTParaPropSet( aParaPropSet
);
4979 pPara
->mnOriginalTextPos
= nCharAnzRead
+ nCount
+ 1;
4980 aParaPropList
.push_back( pPara
);
4984 nCharAnzRead
+= nCharCount
+ 1;
4988 void PPTStyleTextPropReader::ReadCharProps( SvStream
& rIn
, PPTCharPropSet
& aCharPropSet
, const OUString
& aString
,
4989 sal_uInt32
& nCharCount
, sal_uInt32 nCharAnzRead
,
4990 sal_Bool
& bTextPropAtom
, sal_uInt32 nExtParaPos
,
4991 const std::vector
< StyleTextProp9
>& aStyleTextProp9
,
4992 sal_uInt32
& nExtParaFlags
, sal_uInt16
& nBuBlip
,
4993 sal_uInt16
& nHasAnm
, sal_uInt32
& nAnmScheme
)
4995 sal_uInt32 nMask
= 0; //TODO: nMask initialized here to suppress warning for now, see corresponding TODO below
4996 sal_uInt16 nDummy16
;
4997 sal_Int32 nCharsToRead
;
4998 sal_uInt16 nStringLen
= aString
.getLength();
5001 nCharCount
= nDummy16
;
5003 nCharsToRead
= nStringLen
- ( nCharAnzRead
+ nCharCount
);
5004 if ( nCharsToRead
< 0 )
5006 nCharCount
= nStringLen
- nCharAnzRead
;
5007 if ( nCharsToRead
< -1 )
5009 bTextPropAtom
= sal_False
;
5010 OSL_FAIL( "SJ:PPTStyleTextPropReader::could not get this PPT_PST_StyleTextPropAtom by reading the character attributes" );
5013 ImplPPTCharPropSet
& aSet
= *aCharPropSet
.pCharSet
;
5015 // character attributes
5017 if ( (sal_uInt16
)nMask
)
5019 aSet
.mnAttrSet
|= (sal_uInt16
)nMask
;
5020 rIn
>> aSet
.mnFlags
;
5022 if ( nMask
& 0x10000 ) // cfTypeface
5025 aSet
.mnAttrSet
|= 1 << PPT_CharAttr_Font
;
5027 if ( nMask
& 0x200000 ) // cfFEOldTypeface
5029 rIn
>> aSet
.mnAsianOrComplexFont
;
5030 aSet
.mnAttrSet
|= 1 << PPT_CharAttr_AsianOrComplexFont
;
5032 if ( nMask
& 0x400000 ) // cfANSITypeface
5034 rIn
>> aSet
.mnANSITypeface
;
5035 aSet
.mnAttrSet
|= 1 << PPT_CharAttr_ANSITypeface
;
5037 if ( nMask
& 0x800000 ) // cfSymbolTypeface
5039 rIn
>> aSet
.mnSymbolFont
;
5040 aSet
.mnAttrSet
|= 1 << PPT_CharAttr_Symbol
;
5042 if ( nMask
& 0x20000 ) // cfSize
5044 rIn
>> aSet
.mnFontHeight
;
5045 aSet
.mnAttrSet
|= 1 << PPT_CharAttr_FontHeight
;
5047 if ( nMask
& 0x40000 ) // cfColor
5051 if ( !( nVal
& 0xff000000 ) )
5052 nVal
= PPT_COLSCHEME_HINTERGRUND
;
5053 aSet
.mnColor
= nVal
;
5054 aSet
.mnAttrSet
|= 1 << PPT_CharAttr_FontColor
;
5056 if ( nMask
& 0x80000 ) // cfPosition
5058 rIn
>> aSet
.mnEscapement
;
5059 aSet
.mnAttrSet
|= 1 << PPT_CharAttr_Escapement
;
5063 sal_uInt32 nExtBuInd
= nMask
& 0x3c00;
5065 nExtBuInd
= ( aSet
.mnFlags
& 0x3c00 ) >> 10;
5066 if ( nExtBuInd
< aStyleTextProp9
.size() )
5068 nExtParaFlags
= aStyleTextProp9
[ nExtBuInd
].mnExtParagraphMask
;
5069 nBuBlip
= aStyleTextProp9
[ nExtBuInd
].mnBuBlip
;
5070 nHasAnm
= aStyleTextProp9
[ nExtBuInd
].mnHasAnm
;
5071 nAnmScheme
= aStyleTextProp9
[ nExtBuInd
].mnAnmScheme
;
5076 void PPTStyleTextPropReader::Init( SvStream
& rIn
, SdrPowerPointImport
& rMan
, const DffRecordHeader
& rTextHeader
,
5077 PPTTextRulerInterpreter
& rRuler
, const DffRecordHeader
& rExtParaHd
, sal_uInt32 nInstance
)
5079 sal_uInt32 nMerk
= rIn
.Tell();
5080 sal_uInt32 nExtParaPos
= ( rExtParaHd
.nRecType
== PPT_PST_ExtendedParagraphAtom
) ? rExtParaHd
.nFilePos
+ 8 : 0;
5082 std::vector
< StyleTextProp9
> aStyleTextProp9
;
5083 if ( rExtParaHd
.nRecType
== PPT_PST_ExtendedParagraphAtom
)
5085 rIn
.Seek( rExtParaHd
.nFilePos
+ 8 );
5086 while( ( rIn
.GetError() == 0 ) && ( rIn
.Tell() < rExtParaHd
.GetRecEndFilePos() ) )
5088 aStyleTextProp9
.resize( aStyleTextProp9
.size() + 1 );
5089 aStyleTextProp9
.back().Read( rIn
);
5095 DffRecordHeader aTextHd
;
5097 sal_uInt32 nMaxLen
= aTextHd
.nRecLen
;
5098 if ( nMaxLen
>= 0xFFFF )
5101 if( aTextHd
.nRecType
== PPT_PST_TextCharsAtom
)
5104 sal_Unicode nChar
,*pBuf
= new sal_Unicode
[ ( nMaxLen
>> 1 ) + 1 ];
5105 rIn
.Read( pBuf
, nMaxLen
);
5107 pBuf
[ nMaxLen
] = 0;
5108 sal_Unicode
* pPtr
= pBuf
;
5109 #ifdef OSL_BIGENDIAN
5111 for ( i
= 0; i
< nMaxLen
; i
++ )
5114 *pPtr
++ = ( nTemp
<< 8 ) | ( nTemp
>> 8 );
5119 for ( i
= 0; i
< nMaxLen
; pPtr
++, i
++ )
5124 if ( ( nChar
& 0xff00 ) == 0xf000 ) // in this special case we got a symbol
5125 aSpecMarkerList
.push_back( (sal_uInt32
)( i
| PPT_SPEC_SYMBOL
) );
5126 else if ( nChar
== 0xd )
5128 if ( nInstance
== TSS_TYPE_PAGETITLE
)
5131 aSpecMarkerList
.push_back( (sal_uInt32
)( i
| PPT_SPEC_NEWLINE
) );
5135 aString
= OUString(pBuf
, i
);
5138 else if( aTextHd
.nRecType
== PPT_PST_TextBytesAtom
)
5140 sal_Char
*pBuf
= new sal_Char
[ nMaxLen
+ 1 ];
5141 pBuf
[ nMaxLen
] = 0;
5142 rIn
.Read( pBuf
, nMaxLen
);
5143 sal_Char
* pPtr
= pBuf
;
5146 sal_Char cLo
= *pPtr
;
5151 if ( nInstance
== TSS_TYPE_PAGETITLE
)
5154 aSpecMarkerList
.push_back( (sal_uInt32
)( (pPtr
- pBuf
) | PPT_SPEC_NEWLINE
) );
5158 xub_StrLen nLen
= sal::static_int_cast
< xub_StrLen
>( pPtr
- pBuf
);
5160 aString
= OUString( pBuf
, nLen
, RTL_TEXTENCODING_MS_1252
);
5165 // no chars, but potentially char/para props?
5166 sal_uInt32 nCharCount
;
5167 sal_Bool bTextPropAtom
= sal_False
;
5168 ReadParaProps( rIn
, rMan
, rTextHeader
, aString
, rRuler
, nCharCount
, bTextPropAtom
);
5170 if ( bTextPropAtom
)
5172 // yeah, StyleTextProp is there, read it all & push to
5174 PPTCharPropSet
aCharPropSet(0);
5175 aCharPropSet
.mnOriginalTextPos
= 0;
5177 sal_uInt32 nCharAnzRead
= 0;
5178 sal_uInt32 nExtParaFlags
= 0, nAnmScheme
= 0;
5179 sal_uInt16 nBuBlip
= 0xffff, nHasAnm
= 0;
5180 ReadCharProps( rIn
, aCharPropSet
, aString
, nCharCount
, nCharAnzRead
,
5181 bTextPropAtom
, nExtParaPos
, aStyleTextProp9
, nExtParaFlags
,
5182 nBuBlip
, nHasAnm
, nAnmScheme
);
5184 aCharPropList
.push_back( new PPTCharPropSet( aCharPropSet
, 0 ) );
5188 if ( !aString
.isEmpty() )
5190 sal_uInt32 nCharCount
;
5191 sal_Bool bTextPropAtom
= sal_False
;
5193 ReadParaProps( rIn
, rMan
, rTextHeader
, aString
, rRuler
, nCharCount
, bTextPropAtom
);
5195 sal_Bool bEmptyParaPossible
= sal_True
;
5196 sal_uInt32 nCharAnzRead
= 0;
5197 sal_uInt32 nCurrentPara
= 0;
5198 size_t i
= 1; // points to the next element to process
5199 sal_uInt32 nCurrentSpecMarker
= aSpecMarkerList
.empty() ? 0 : aSpecMarkerList
[0];
5200 sal_uInt32 nStringLen
= aString
.getLength();
5202 while ( nCharAnzRead
< nStringLen
)
5204 sal_uInt32 nExtParaFlags
= 0, nLatestParaUpdate
= 0xffffffff, nAnmScheme
= 0;
5205 sal_uInt16 nBuBlip
= 0xffff, nHasAnm
= 0;
5207 PPTCharPropSet
aCharPropSet( nCurrentPara
);
5208 if ( bTextPropAtom
)
5209 ReadCharProps( rIn
, aCharPropSet
, aString
, nCharCount
, nCharAnzRead
,
5210 bTextPropAtom
, nExtParaPos
, aStyleTextProp9
, nExtParaFlags
,
5211 nBuBlip
, nHasAnm
, nAnmScheme
);
5213 nCharCount
= nStringLen
;
5218 if ( nExtParaPos
&& ( nLatestParaUpdate
!= nCurrentPara
) && ( nCurrentPara
< aParaPropList
.size() ) )
5220 PPTParaPropSet
* pPropSet
= aParaPropList
[ nCurrentPara
];
5221 pPropSet
->pParaSet
->mnExtParagraphMask
= nExtParaFlags
;
5222 if ( nExtParaFlags
& 0x800000 )
5223 pPropSet
->pParaSet
->mnBuBlip
= nBuBlip
;
5224 if ( nExtParaFlags
& 0x01000000 )
5225 pPropSet
->pParaSet
->mnAnmScheme
= nAnmScheme
;
5226 if ( nExtParaFlags
& 0x02000000 )
5227 pPropSet
->pParaSet
->mnHasAnm
= nHasAnm
;
5228 nLatestParaUpdate
= nCurrentPara
;
5230 aCharPropSet
.mnOriginalTextPos
= nCharAnzRead
;
5231 if ( nCurrentSpecMarker
&& ( ( nCurrentSpecMarker
& 0xffff ) < ( nCharAnzRead
+ nCharCount
) ) )
5233 if ( nCurrentSpecMarker
& PPT_SPEC_NEWLINE
)
5235 nLen
= ( nCurrentSpecMarker
& 0xffff ) - nCharAnzRead
;
5237 aCharPropSet
.maString
= aString
.copy( nCharAnzRead
, nLen
);
5238 else if ( bEmptyParaPossible
)
5239 aCharPropSet
.maString
= OUString();
5240 if ( nLen
|| bEmptyParaPossible
)
5241 aCharPropList
.push_back( new PPTCharPropSet( aCharPropSet
, nCurrentPara
) );
5244 nCharAnzRead
+= nLen
;
5246 bEmptyParaPossible
= sal_True
;
5248 else if ( nCurrentSpecMarker
& PPT_SPEC_SYMBOL
)
5250 if ( ( nCurrentSpecMarker
& 0xffff ) != nCharAnzRead
)
5252 nLen
= ( nCurrentSpecMarker
& 0xffff ) - nCharAnzRead
;
5253 aCharPropSet
.maString
= aString
.copy(nCharAnzRead
, nLen
);
5254 aCharPropList
.push_back( new PPTCharPropSet( aCharPropSet
, nCurrentPara
) );
5256 nCharAnzRead
+= nLen
;
5258 PPTCharPropSet
* pCPropSet
= new PPTCharPropSet( aCharPropSet
, nCurrentPara
);
5259 pCPropSet
->maString
= aString
.copy(nCharAnzRead
, 1);
5260 if ( aCharPropSet
.pCharSet
->mnAttrSet
& ( 1 << PPT_CharAttr_Symbol
) )
5261 pCPropSet
->SetFont( aCharPropSet
.pCharSet
->mnSymbolFont
);
5262 aCharPropList
.push_back( pCPropSet
);
5265 bEmptyParaPossible
= sal_False
;
5267 nCurrentSpecMarker
= ( i
< aSpecMarkerList
.size() ) ? aSpecMarkerList
[ i
++ ] : 0;
5271 aCharPropSet
.maString
= aString
.copy(nCharAnzRead
, nCharCount
);
5272 aCharPropList
.push_back( new PPTCharPropSet( aCharPropSet
, nCurrentPara
) );
5273 nCharAnzRead
+= nCharCount
;
5274 bEmptyParaPossible
= sal_False
;
5279 if ( !aCharPropList
.empty() && ( aCharPropList
.back()->mnParagraph
!= nCurrentPara
) )
5281 PPTCharPropSet
* pCharPropSet
= new PPTCharPropSet( *aCharPropList
.back(), nCurrentPara
);
5282 pCharPropSet
->maString
= OUString();
5283 pCharPropSet
->mnOriginalTextPos
= nStringLen
- 1;
5284 aCharPropList
.push_back( pCharPropSet
);
5290 PPTStyleTextPropReader::~PPTStyleTextPropReader()
5292 for ( PPTParaPropSetList::const_iterator it
= aParaPropList
.begin(); it
!= aParaPropList
.end(); ++it
)
5294 for ( PPTCharPropSetList::const_iterator it
= aCharPropList
.begin(); it
!= aCharPropList
.end(); ++it
)
5300 sal_uInt32 nFieldType
;
5301 sal_uInt32 nFieldStartPos
;
5302 sal_uInt32 nFieldEndPos
;
5305 FieldEntry( sal_uInt32 nType
, sal_uInt32 nStart
, sal_uInt32 nEnd
)
5308 nFieldStartPos
= nStart
;
5309 nFieldEndPos
= nEnd
;
5311 FieldEntry( FieldEntry
& rFieldEntry
)
5313 nFieldType
= rFieldEntry
.nFieldType
;
5314 nFieldStartPos
= rFieldEntry
.nFieldStartPos
;
5315 nFieldEndPos
= rFieldEntry
.nFieldEndPos
;
5316 aFieldUrl
= rFieldEntry
.aFieldUrl
;
5321 PPTPortionObj::PPTPortionObj( const PPTStyleSheet
& rStyleSheet
, sal_uInt32 nInstance
, sal_uInt32 nDepth
) :
5322 PPTCharPropSet ( 0 ),
5323 mrStyleSheet ( rStyleSheet
),
5324 mnInstance ( nInstance
),
5325 mnDepth ( ( nDepth
> 4 ) ? 4 : nDepth
)
5329 PPTPortionObj::PPTPortionObj( const PPTCharPropSet
& rCharPropSet
, const PPTStyleSheet
& rStyleSheet
, sal_uInt32 nInstance
, sal_uInt32 nDepth
) :
5330 PPTCharPropSet ( rCharPropSet
),
5331 mrStyleSheet ( rStyleSheet
),
5332 mnInstance ( nInstance
),
5337 PPTPortionObj::PPTPortionObj( const PPTPortionObj
& rPortionObj
) :
5338 PPTCharPropSet ( rPortionObj
),
5339 mrStyleSheet ( rPortionObj
.mrStyleSheet
),
5340 mnInstance ( rPortionObj
.mnInstance
),
5341 mnDepth ( rPortionObj
.mnDepth
)
5345 PPTPortionObj::~PPTPortionObj()
5349 sal_Bool
PPTPortionObj::HasTabulator()
5351 sal_Bool bRetValue
= sal_False
;
5353 const sal_Unicode
* pPtr
= maString
.getStr();
5354 for ( nCount
= 0; nCount
< maString
.getLength(); nCount
++ )
5356 if ( pPtr
[ nCount
] == 0x9 )
5358 bRetValue
= sal_True
;
5366 sal_Bool
PPTPortionObj::GetAttrib( sal_uInt32 nAttr
, sal_uInt32
& nRetValue
, sal_uInt32 nDestinationInstance
) const
5368 sal_uInt32 nMask
= 1 << nAttr
;
5371 sal_uInt32 bIsHardAttribute
= ( ( pCharSet
->mnAttrSet
& nMask
) != 0 ) ? 1 : 0;
5373 if ( bIsHardAttribute
)
5377 case PPT_CharAttr_Bold
:
5378 case PPT_CharAttr_Italic
:
5379 case PPT_CharAttr_Underline
:
5380 case PPT_CharAttr_Shadow
:
5381 case PPT_CharAttr_Strikeout
:
5382 case PPT_CharAttr_Embossed
:
5383 nRetValue
= ( pCharSet
->mnFlags
& nMask
) ? 1 : 0;
5385 case PPT_CharAttr_Font
:
5386 nRetValue
= pCharSet
->mnFont
;
5388 case PPT_CharAttr_AsianOrComplexFont
:
5389 nRetValue
= pCharSet
->mnAsianOrComplexFont
;
5391 case PPT_CharAttr_FontHeight
:
5392 nRetValue
= pCharSet
->mnFontHeight
;
5394 case PPT_CharAttr_FontColor
:
5395 nRetValue
= pCharSet
->mnColor
;
5397 case PPT_CharAttr_Escapement
:
5398 nRetValue
= pCharSet
->mnEscapement
;
5401 OSL_FAIL( "SJ:PPTPortionObj::GetAttrib ( hard attribute does not exist )" );
5406 const PPTCharLevel
& rCharLevel
= mrStyleSheet
.mpCharSheet
[ mnInstance
]->maCharLevel
[ mnDepth
];
5407 PPTCharLevel
* pCharLevel
= NULL
;
5408 if ( ( nDestinationInstance
== 0xffffffff )
5409 || ( mnDepth
&& ( ( mnInstance
== TSS_TYPE_SUBTITLE
) || ( mnInstance
== TSS_TYPE_TEXT_IN_SHAPE
) ) ) )
5410 bIsHardAttribute
= 1;
5411 else if ( nDestinationInstance
!= mnInstance
)
5412 pCharLevel
= &mrStyleSheet
.mpCharSheet
[ nDestinationInstance
]->maCharLevel
[ mnDepth
];
5415 case PPT_CharAttr_Bold
:
5416 case PPT_CharAttr_Italic
:
5417 case PPT_CharAttr_Underline
:
5418 case PPT_CharAttr_Shadow
:
5419 case PPT_CharAttr_Strikeout
:
5420 case PPT_CharAttr_Embossed
:
5422 nRetValue
= ( rCharLevel
.mnFlags
& nMask
) ? 1 : 0;
5425 sal_uInt32 nTmp
= ( pCharLevel
->mnFlags
& nMask
) ? 1 : 0;
5426 if ( nRetValue
!= nTmp
)
5427 bIsHardAttribute
= 1;
5431 case PPT_CharAttr_Font
:
5433 nRetValue
= rCharLevel
.mnFont
;
5434 if ( pCharLevel
&& ( nRetValue
!= pCharLevel
->mnFont
) )
5435 bIsHardAttribute
= 1;
5438 case PPT_CharAttr_AsianOrComplexFont
:
5440 nRetValue
= rCharLevel
.mnAsianOrComplexFont
;
5441 if ( pCharLevel
&& ( nRetValue
!= pCharLevel
->mnAsianOrComplexFont
) )
5442 bIsHardAttribute
= 1;
5445 case PPT_CharAttr_FontHeight
:
5447 nRetValue
= rCharLevel
.mnFontHeight
;
5448 if ( pCharLevel
&& ( nRetValue
!= pCharLevel
->mnFontHeight
) )
5449 bIsHardAttribute
= 1;
5452 case PPT_CharAttr_FontColor
:
5454 nRetValue
= rCharLevel
.mnFontColor
;
5455 if ( pCharLevel
&& ( nRetValue
!= pCharLevel
->mnFontColor
) )
5456 bIsHardAttribute
= 1;
5459 case PPT_CharAttr_Escapement
:
5461 nRetValue
= rCharLevel
.mnEscapement
;
5462 if ( pCharLevel
&& ( nRetValue
!= pCharLevel
->mnEscapement
) )
5463 bIsHardAttribute
= 1;
5467 OSL_FAIL( "SJ:PPTPortionObj::GetAttrib ( attribute does not exist )" );
5470 return (sal_Bool
)bIsHardAttribute
;
5473 void PPTPortionObj::ApplyTo( SfxItemSet
& rSet
, SdrPowerPointImport
& rManager
, sal_uInt32 nDestinationInstance
)
5475 ApplyTo( rSet
, rManager
, nDestinationInstance
, NULL
);
5478 void PPTPortionObj::ApplyTo( SfxItemSet
& rSet
, SdrPowerPointImport
& rManager
, sal_uInt32 nDestinationInstance
, const PPTTextObj
* pTextObj
)
5481 if ( GetAttrib( PPT_CharAttr_Bold
, nVal
, nDestinationInstance
) )
5483 rSet
.Put( SvxWeightItem( nVal
!= 0 ? WEIGHT_BOLD
: WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
5484 rSet
.Put( SvxWeightItem( nVal
!= 0 ? WEIGHT_BOLD
: WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
5485 rSet
.Put( SvxWeightItem( nVal
!= 0 ? WEIGHT_BOLD
: WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
5487 if ( GetAttrib( PPT_CharAttr_Italic
, nVal
, nDestinationInstance
) )
5489 rSet
.Put( SvxPostureItem( nVal
!= 0 ? ITALIC_NORMAL
: ITALIC_NONE
, EE_CHAR_ITALIC
) );
5490 rSet
.Put( SvxPostureItem( nVal
!= 0 ? ITALIC_NORMAL
: ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
5491 rSet
.Put( SvxPostureItem( nVal
!= 0 ? ITALIC_NORMAL
: ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
5493 if ( GetAttrib( PPT_CharAttr_Underline
, nVal
, nDestinationInstance
) )
5494 rSet
.Put( SvxUnderlineItem( nVal
!= 0 ? UNDERLINE_SINGLE
: UNDERLINE_NONE
, EE_CHAR_UNDERLINE
) );
5496 if ( GetAttrib( PPT_CharAttr_Shadow
, nVal
, nDestinationInstance
) )
5497 rSet
.Put( SvxShadowedItem( nVal
!= 0, EE_CHAR_SHADOW
) );
5499 if ( GetAttrib( PPT_CharAttr_Strikeout
, nVal
, nDestinationInstance
) )
5500 rSet
.Put( SvxCrossedOutItem( nVal
!= 0 ? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
) );
5502 sal_uInt32 nAsianFontId
= 0xffff;
5503 if ( GetAttrib( PPT_CharAttr_AsianOrComplexFont
, nAsianFontId
, nDestinationInstance
) )
5505 if ( nAsianFontId
!= 0xffff )
5507 PptFontEntityAtom
* pFontEnityAtom
= rManager
.GetFontEnityAtom( nAsianFontId
);
5508 if ( pFontEnityAtom
)
5510 rSet
.Put( SvxFontItem( pFontEnityAtom
->eFamily
, pFontEnityAtom
->aName
,
5511 String(), pFontEnityAtom
->ePitch
, pFontEnityAtom
->eCharSet
, EE_CHAR_FONTINFO_CJK
) );
5512 rSet
.Put( SvxFontItem( pFontEnityAtom
->eFamily
, pFontEnityAtom
->aName
,
5513 String(), pFontEnityAtom
->ePitch
, pFontEnityAtom
->eCharSet
, EE_CHAR_FONTINFO_CTL
) );
5517 if ( GetAttrib( PPT_CharAttr_Font
, nVal
, nDestinationInstance
) )
5519 PptFontEntityAtom
* pFontEnityAtom
= rManager
.GetFontEnityAtom( nVal
);
5520 if ( pFontEnityAtom
)
5522 rSet
.Put( SvxFontItem( pFontEnityAtom
->eFamily
, pFontEnityAtom
->aName
, String(), pFontEnityAtom
->ePitch
, pFontEnityAtom
->eCharSet
, EE_CHAR_FONTINFO
) );
5524 // #i119475# bullet font info for CJK and CTL
5525 if ( RTL_TEXTENCODING_SYMBOL
== pFontEnityAtom
->eCharSet
)
5527 rSet
.Put( SvxFontItem( pFontEnityAtom
->eFamily
, pFontEnityAtom
->aName
, String(), pFontEnityAtom
->ePitch
, pFontEnityAtom
->eCharSet
, EE_CHAR_FONTINFO_CJK
) );
5528 rSet
.Put( SvxFontItem( pFontEnityAtom
->eFamily
, pFontEnityAtom
->aName
, String(), pFontEnityAtom
->ePitch
, pFontEnityAtom
->eCharSet
, EE_CHAR_FONTINFO_CTL
) );
5532 if ( GetAttrib( PPT_CharAttr_FontHeight
, nVal
, nDestinationInstance
) ) // Schriftgrad in Point
5534 sal_uInt32 nHeight
= rManager
.ScalePoint( nVal
);
5535 rSet
.Put( SvxFontHeightItem( nHeight
, 100, EE_CHAR_FONTHEIGHT
) );
5536 rSet
.Put( SvxFontHeightItem( nHeight
, 100, EE_CHAR_FONTHEIGHT_CJK
) );
5537 rSet
.Put( SvxFontHeightItem( nHeight
, 100, EE_CHAR_FONTHEIGHT_CTL
) );
5540 if ( GetAttrib( PPT_CharAttr_Embossed
, nVal
, nDestinationInstance
) )
5541 rSet
.Put( SvxCharReliefItem( nVal
!= 0 ? RELIEF_EMBOSSED
: RELIEF_NONE
, EE_CHAR_RELIEF
) );
5542 if ( nVal
) /* if Embossed is set, the font color depends to the fillstyle/color of the object,
5543 if the object has no fillstyle, the font color depends to fillstyle of the background */
5545 Color
aDefColor( COL_BLACK
);
5546 MSO_FillType eFillType
= mso_fillSolid
;
5547 if ( rManager
.GetPropertyValue( DFF_Prop_fNoFillHitTest
) & 0x10 )
5548 eFillType
= (MSO_FillType
)rManager
.GetPropertyValue( DFF_Prop_fillType
, mso_fillSolid
);
5550 eFillType
= mso_fillBackground
;
5553 case mso_fillShade
:
5554 case mso_fillShadeCenter
:
5555 case mso_fillShadeShape
:
5556 case mso_fillShadeScale
:
5557 case mso_fillShadeTitle
:
5558 case mso_fillSolid
:
5559 aDefColor
= rManager
.MSO_CLR_ToColor( rManager
.GetPropertyValue( DFF_Prop_fillColor
) );
5561 case mso_fillPattern
:
5562 aDefColor
= rManager
.MSO_CLR_ToColor( rManager
.GetPropertyValue( DFF_Prop_fillBackColor
) );
5564 case mso_fillTexture
:
5567 if ( rManager
.GetBLIP( rManager
.GetPropertyValue( DFF_Prop_fillBlip
), aGraf
, NULL
) )
5569 Bitmap
aBmp( aGraf
.GetBitmap() );
5570 Size
aSize( aBmp
.GetSizePixel() );
5571 if ( aSize
.Width() && aSize
.Height() )
5573 if ( aSize
.Width () > 64 )
5574 aSize
.Width () = 64;
5575 if ( aSize
.Height() > 64 )
5576 aSize
.Height() = 64;
5578 BitmapReadAccess
* pAcc
= aBmp
.AcquireReadAccess();
5581 sal_uLong nRt
= 0, nGn
= 0, nBl
= 0;
5582 const long nWidth
= aSize
.Width();
5583 const long nHeight
= aSize
.Height();
5585 if( pAcc
->HasPalette() )
5587 for( long nY
= 0L; nY
< nHeight
; nY
++ )
5589 for( long nX
= 0L; nX
< nWidth
; nX
++ )
5591 const BitmapColor
& rCol
= pAcc
->GetPaletteColor( pAcc
->GetPixelIndex( nY
, nX
) );
5592 nRt
+=rCol
.GetRed(); nGn
+=rCol
.GetGreen(); nBl
+=rCol
.GetBlue();
5598 for( long nY
= 0L; nY
< nHeight
; nY
++ )
5600 for( long nX
= 0L; nX
< nWidth
; nX
++ )
5602 const BitmapColor
aCol( pAcc
->GetPixel( nY
, nX
) );
5603 nRt
+=aCol
.GetRed(); nGn
+=aCol
.GetGreen(); nBl
+=aCol
.GetBlue();
5607 aBmp
.ReleaseAccess( pAcc
);
5608 sal_uInt32 nC
= ( aSize
.Width() * aSize
.Height() );
5612 aDefColor
= Color(sal_uInt8( nRt
), sal_uInt8( nGn
),sal_uInt8( nBl
) );
5618 case mso_fillBackground
:
5620 if ( pTextObj
) // the textobject is needed
5622 const SfxItemSet
* pItemSet
= pTextObj
->GetBackground();
5625 const SfxPoolItem
* pFillStyleItem
= NULL
;
5626 pItemSet
->GetItemState( XATTR_FILLSTYLE
, sal_False
, &pFillStyleItem
);
5627 if ( pFillStyleItem
)
5629 XFillStyle eFillStyle
= ((XFillStyleItem
*)pFillStyleItem
)->GetValue();
5630 switch( eFillStyle
)
5634 const SfxPoolItem
* pFillColorItem
= NULL
;
5635 pItemSet
->GetItemState( XATTR_FILLCOLOR
, sal_False
, &pFillColorItem
);
5636 if ( pFillColorItem
)
5637 aDefColor
= ((XColorItem
*)pFillColorItem
)->GetColorValue();
5640 case XFILL_GRADIENT
:
5642 const SfxPoolItem
* pGradientItem
= NULL
;
5643 pItemSet
->GetItemState( XATTR_FILLGRADIENT
, sal_False
, &pGradientItem
);
5644 if ( pGradientItem
)
5645 aDefColor
= ((XFillGradientItem
*)pGradientItem
)->GetGradientValue().GetStartColor();
5650 aDefColor
= Color( COL_WHITE
);
5661 rSet
.Put( SvxColorItem( aDefColor
, EE_CHAR_COLOR
) );
5665 if ( GetAttrib( PPT_CharAttr_FontColor
, nVal
, nDestinationInstance
) ) // text color (4Byte-Arg)
5667 Color
aCol( rManager
.MSO_TEXT_CLR_ToColor( nVal
) );
5668 rSet
.Put( SvxColorItem( aCol
, EE_CHAR_COLOR
) );
5669 if ( nDestinationInstance
== 0xffffffff )
5670 mrStyleSheet
.mpCharSheet
[ mnInstance
]->maCharLevel
[ mnDepth
].mnFontColorInStyleSheet
= aCol
;
5672 else if ( nVal
& 0x0f000000 ) // this is not a hard attribute, but maybe the page has a different colerscheme,
5673 { // so that in this case we must use a hard color attribute
5674 Color
aCol( rManager
.MSO_TEXT_CLR_ToColor( nVal
) );
5675 Color
& aColorInSheet
= mrStyleSheet
.mpCharSheet
[ mnInstance
]->maCharLevel
[ mnDepth
].mnFontColorInStyleSheet
;
5676 if ( aColorInSheet
!= aCol
)
5677 rSet
.Put( SvxColorItem( aCol
, EE_CHAR_COLOR
) );
5681 if ( GetAttrib( PPT_CharAttr_Escapement
, nVal
, nDestinationInstance
) ) // super-/subscript in %
5683 sal_uInt16 nEsc
= 0;
5684 sal_uInt8 nProp
= 100;
5688 nEsc
= (sal_Int16
)nVal
;
5689 nProp
= DFLT_ESC_PROP
;
5691 SvxEscapementItem
aItem( nEsc
, nProp
, EE_CHAR_ESCAPEMENT
);
5694 if ( mnLanguage
[ 0 ] )
5695 rSet
.Put( SvxLanguageItem( mnLanguage
[ 0 ], EE_CHAR_LANGUAGE
) );
5696 if ( mnLanguage
[ 1 ] )
5697 rSet
.Put( SvxLanguageItem( mnLanguage
[ 1 ], EE_CHAR_LANGUAGE_CJK
) );
5698 if ( mnLanguage
[ 2 ] )
5699 rSet
.Put( SvxLanguageItem( mnLanguage
[ 2 ], EE_CHAR_LANGUAGE_CTL
) );
5702 SvxFieldItem
* PPTPortionObj::GetTextField()
5705 return new SvxFieldItem( *mpFieldItem
);
5709 PPTParagraphObj::PPTParagraphObj( const PPTStyleSheet
& rStyleSheet
, sal_uInt32 nInstance
, sal_uInt16 nDepth
) :
5710 PPTNumberFormatCreator ( NULL
),
5711 mrStyleSheet ( rStyleSheet
),
5712 mnInstance ( nInstance
),
5713 mbTab ( sal_True
) // style sheets always have to get the right tabulator setting
5717 pParaSet
->mnDepth
= nDepth
;
5720 PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader
& rPropReader
,
5721 size_t const nCurParaPos
, size_t& rnCurCharPos
,
5722 const PPTStyleSheet
& rStyleSheet
,
5723 sal_uInt32 nInstance
, PPTTextRulerInterpreter
& rRuler
) :
5724 PPTParaPropSet ( *rPropReader
.aParaPropList
[nCurParaPos
] ),
5725 PPTNumberFormatCreator ( NULL
),
5726 PPTTextRulerInterpreter ( rRuler
),
5727 mrStyleSheet ( rStyleSheet
),
5728 mnInstance ( nInstance
),
5729 mbTab ( sal_False
),
5730 mnCurrentObject ( 0 )
5732 if (rnCurCharPos
< rPropReader
.aCharPropList
.size())
5734 sal_uInt32
const nCurrentParagraph
=
5735 rPropReader
.aCharPropList
[rnCurCharPos
]->mnParagraph
;
5736 for (; rnCurCharPos
< rPropReader
.aCharPropList
.size() &&
5737 rPropReader
.aCharPropList
[rnCurCharPos
]->mnParagraph
== nCurrentParagraph
;
5740 PPTCharPropSet
*const pCharPropSet
=
5741 rPropReader
.aCharPropList
[rnCurCharPos
];
5742 PPTPortionObj
* pPPTPortion
= new PPTPortionObj( *pCharPropSet
,
5743 rStyleSheet
, nInstance
, pParaSet
->mnDepth
);
5744 m_PortionList
.push_back(pPPTPortion
);
5747 mbTab
= pPPTPortion
->HasTabulator();
5753 PPTParagraphObj::~PPTParagraphObj()
5758 void PPTParagraphObj::AppendPortion( PPTPortionObj
& rPPTPortion
)
5760 m_PortionList
.push_back(new PPTPortionObj(rPPTPortion
));
5763 mbTab
= m_PortionList
.back().HasTabulator();
5767 void PPTParagraphObj::UpdateBulletRelSize( sal_uInt32
& nBulletRelSize
) const
5769 if ( nBulletRelSize
> 0x7fff ) // a negative value is the absolute bullet height
5771 sal_uInt16 nFontHeight
= 0;
5772 if (!m_PortionList
.empty())
5774 PPTPortionObj
const& rPortion
= m_PortionList
.front();
5775 if (rPortion
.pCharSet
->mnAttrSet
& (1 << PPT_CharAttr_FontHeight
))
5777 nFontHeight
= rPortion
.pCharSet
->mnFontHeight
;
5780 // if we do not have a hard attributed fontheight, the fontheight is taken from the style
5782 nFontHeight
= mrStyleSheet
.mpCharSheet
[ mnInstance
]->maCharLevel
[ pParaSet
->mnDepth
].mnFontHeight
;
5783 nBulletRelSize
= nFontHeight
? ((-((sal_Int16
)nBulletRelSize
)) * 100 ) / nFontHeight
: 100;
5787 sal_Bool
PPTParagraphObj::GetAttrib( sal_uInt32 nAttr
, sal_uInt32
& nRetValue
, sal_uInt32 nDestinationInstance
)
5789 sal_uInt32 nMask
= 1 << nAttr
;
5794 OSL_FAIL( "SJ:PPTParagraphObj::GetAttrib - attribute does not exist" );
5798 sal_uInt32 bIsHardAttribute
= ( ( pParaSet
->mnAttrSet
& nMask
) != 0 ) ? 1 : 0;
5800 if ( bIsHardAttribute
)
5802 if ( nAttr
== PPT_ParaAttr_BulletColor
)
5804 sal_Bool bHardBulletColor
;
5805 if ( pParaSet
->mnAttrSet
& ( 1 << PPT_ParaAttr_BuHardColor
) )
5806 bHardBulletColor
= pParaSet
->mpArry
[ PPT_ParaAttr_BuHardColor
] != 0;
5808 bHardBulletColor
= ( mrStyleSheet
.mpParaSheet
[ mnInstance
]->maParaLevel
[ pParaSet
->mnDepth
].mnBuFlags
5809 & ( 1 << PPT_ParaAttr_BuHardColor
) ) != 0;
5810 if ( bHardBulletColor
)
5811 nRetValue
= pParaSet
->mnBulletColor
;
5814 nRetValue
= PPT_COLSCHEME_TEXT_UND_ZEILEN
;
5815 if ((nDestinationInstance
!= 0xffffffff) && !m_PortionList
.empty())
5817 PPTPortionObj
const& rPortion
= m_PortionList
.front();
5818 if (rPortion
.pCharSet
->mnAttrSet
& (1 << PPT_CharAttr_FontColor
))
5820 nRetValue
= rPortion
.pCharSet
->mnColor
;
5824 nRetValue
= mrStyleSheet
.mpCharSheet
[ nDestinationInstance
]->maCharLevel
[ pParaSet
->mnDepth
].mnFontColor
;
5829 else if ( nAttr
== PPT_ParaAttr_BulletFont
)
5831 sal_Bool bHardBuFont
;
5832 if ( pParaSet
->mnAttrSet
& ( 1 << PPT_ParaAttr_BuHardFont
) )
5833 bHardBuFont
= pParaSet
->mpArry
[ PPT_ParaAttr_BuHardFont
] != 0;
5835 bHardBuFont
= ( mrStyleSheet
.mpParaSheet
[ mnInstance
]->maParaLevel
[ pParaSet
->mnDepth
].mnBuFlags
5836 & ( 1 << PPT_ParaAttr_BuHardFont
) ) != 0;
5838 nRetValue
= pParaSet
->mpArry
[ PPT_ParaAttr_BulletFont
];
5841 // it is the font used which assigned to the first character of the following text
5843 if ((nDestinationInstance
!= 0xffffffff) && !m_PortionList
.empty())
5845 PPTPortionObj
const& rPortion
= m_PortionList
.front();
5846 if (rPortion
.pCharSet
->mnAttrSet
& ( 1 << PPT_CharAttr_Font
) )
5848 nRetValue
= rPortion
.pCharSet
->mnFont
;
5852 nRetValue
= mrStyleSheet
.mpCharSheet
[ nDestinationInstance
]->maCharLevel
[ pParaSet
->mnDepth
].mnFont
;
5858 nRetValue
= pParaSet
->mpArry
[ nAttr
];
5862 const PPTParaLevel
& rParaLevel
= mrStyleSheet
.mpParaSheet
[ mnInstance
]->maParaLevel
[ pParaSet
->mnDepth
];
5864 PPTParaLevel
* pParaLevel
= NULL
;
5865 if ( ( nDestinationInstance
== 0xffffffff )
5866 || ( pParaSet
->mnDepth
&& ( ( mnInstance
== TSS_TYPE_SUBTITLE
) || ( mnInstance
== TSS_TYPE_TEXT_IN_SHAPE
) ) ) )
5867 bIsHardAttribute
= 1;
5868 else if ( nDestinationInstance
!= mnInstance
)
5869 pParaLevel
= &mrStyleSheet
.mpParaSheet
[ nDestinationInstance
]->maParaLevel
[ pParaSet
->mnDepth
];
5872 case PPT_ParaAttr_BulletOn
:
5874 nRetValue
= rParaLevel
.mnBuFlags
& ( 1 << PPT_ParaAttr_BulletOn
);
5877 if ( nRetValue
!= ( (sal_uInt32
)pParaLevel
->mnBuFlags
& ( 1 << PPT_ParaAttr_BulletOn
) ) )
5878 bIsHardAttribute
= 1;
5882 case PPT_ParaAttr_BuHardFont
:
5883 case PPT_ParaAttr_BuHardColor
:
5884 case PPT_ParaAttr_BuHardHeight
:
5885 OSL_FAIL( "SJ:PPTParagraphObj::GetAttrib - this attribute does not make sense" );
5887 case PPT_ParaAttr_BulletChar
:
5889 nRetValue
= rParaLevel
.mnBulletChar
;
5890 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnBulletChar
) )
5891 bIsHardAttribute
= 1;
5894 case PPT_ParaAttr_BulletFont
:
5896 sal_Bool bHardBuFont
;
5897 if ( pParaSet
->mnAttrSet
& ( 1 << PPT_ParaAttr_BuHardFont
) )
5898 bHardBuFont
= pParaSet
->mpArry
[ PPT_ParaAttr_BuHardFont
] != 0;
5900 bHardBuFont
= ( rParaLevel
.mnBuFlags
& ( 1 << PPT_ParaAttr_BuHardFont
) ) != 0;
5903 nRetValue
= rParaLevel
.mnBulletFont
;
5904 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnBulletFont
) )
5905 bIsHardAttribute
= 1;
5909 if (!m_PortionList
.empty())
5911 PPTPortionObj
const& rPortion
= m_PortionList
.front();
5912 bIsHardAttribute
= rPortion
.GetAttrib(
5913 PPT_CharAttr_Font
, nRetValue
, nDestinationInstance
);
5917 nRetValue
= mrStyleSheet
.mpCharSheet
[ mnInstance
]->maCharLevel
[ pParaSet
->mnDepth
].mnFont
;
5918 bIsHardAttribute
= 1;
5923 case PPT_ParaAttr_BulletHeight
:
5925 nRetValue
= rParaLevel
.mnBulletHeight
;
5926 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnBulletHeight
) )
5927 bIsHardAttribute
= 1;
5930 case PPT_ParaAttr_BulletColor
:
5932 sal_Bool bHardBulletColor
;
5933 if ( pParaSet
->mnAttrSet
& ( 1 << PPT_ParaAttr_BuHardColor
) )
5934 bHardBulletColor
= pParaSet
->mpArry
[ PPT_ParaAttr_BuHardColor
] != 0;
5936 bHardBulletColor
= ( rParaLevel
.mnBuFlags
& ( 1 << PPT_ParaAttr_BuHardColor
) ) != 0;
5937 if ( bHardBulletColor
)
5939 nRetValue
= rParaLevel
.mnBulletColor
;
5940 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnBulletColor
) )
5941 bIsHardAttribute
= 1;
5945 if (!m_PortionList
.empty())
5947 PPTPortionObj
const& rPortion
= m_PortionList
.front();
5948 if (rPortion
.mbIsHyperlink
)
5950 if( rPortion
.mbHardHylinkOrigColor
)
5951 nRetValue
= rPortion
.mnHylinkOrigColor
;
5953 nRetValue
= mrStyleSheet
.mpCharSheet
[ mnInstance
]->maCharLevel
[ pParaSet
->mnDepth
].mnFontColor
;
5954 bIsHardAttribute
= sal_True
;
5958 bIsHardAttribute
= rPortion
.GetAttrib( PPT_CharAttr_FontColor
, nRetValue
, nDestinationInstance
);
5963 nRetValue
= mrStyleSheet
.mpCharSheet
[ mnInstance
]->maCharLevel
[ pParaSet
->mnDepth
].mnFontColor
;
5964 bIsHardAttribute
= 1;
5969 case PPT_ParaAttr_Adjust
:
5971 nRetValue
= rParaLevel
.mnAdjust
;
5972 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnAdjust
) )
5973 bIsHardAttribute
= 1;
5976 case PPT_ParaAttr_LineFeed
:
5978 nRetValue
= rParaLevel
.mnLineFeed
;
5979 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnLineFeed
) )
5980 bIsHardAttribute
= 1;
5983 case PPT_ParaAttr_UpperDist
:
5985 nRetValue
= rParaLevel
.mnUpperDist
;
5986 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnUpperDist
) )
5987 bIsHardAttribute
= 1;
5990 case PPT_ParaAttr_LowerDist
:
5992 nRetValue
= rParaLevel
.mnLowerDist
;
5993 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnLowerDist
) )
5994 bIsHardAttribute
= 1;
5997 case PPT_ParaAttr_TextOfs
:
5999 nRetValue
= rParaLevel
.mnTextOfs
;
6000 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnTextOfs
) )
6001 bIsHardAttribute
= 1;
6004 case PPT_ParaAttr_BulletOfs
:
6006 nRetValue
= rParaLevel
.mnBulletOfs
;
6007 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnBulletOfs
) )
6008 bIsHardAttribute
= 1;
6011 case PPT_ParaAttr_DefaultTab
:
6013 nRetValue
= rParaLevel
.mnDefaultTab
;
6014 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnDefaultTab
) )
6015 bIsHardAttribute
= 1;
6018 case PPT_ParaAttr_AsianLB_1
:
6020 nRetValue
= rParaLevel
.mnAsianLineBreak
& 1;
6021 if ( pParaLevel
&& ( nRetValue
!= ( (sal_uInt32
)pParaLevel
->mnAsianLineBreak
& 1 ) ) )
6022 bIsHardAttribute
= 1;
6025 case PPT_ParaAttr_AsianLB_2
:
6027 nRetValue
= ( rParaLevel
.mnAsianLineBreak
>> 1 ) & 1;
6028 if ( pParaLevel
&& ( nRetValue
!= ( ( (sal_uInt32
)pParaLevel
->mnAsianLineBreak
>> 1 ) & 1 ) ) )
6029 bIsHardAttribute
= 1;
6032 case PPT_ParaAttr_AsianLB_3
:
6034 nRetValue
= ( rParaLevel
.mnAsianLineBreak
>> 2 ) & 1;
6035 if ( pParaLevel
&& ( nRetValue
!= ( ( (sal_uInt32
)pParaLevel
->mnAsianLineBreak
>> 2 ) & 1 ) ) )
6036 bIsHardAttribute
= 1;
6039 case PPT_ParaAttr_BiDi
:
6041 nRetValue
= rParaLevel
.mnBiDi
;
6042 if ( pParaLevel
&& ( nRetValue
!= pParaLevel
->mnBiDi
) )
6043 bIsHardAttribute
= 1;
6048 return (sal_Bool
)bIsHardAttribute
;
6051 void PPTParagraphObj::ApplyTo( SfxItemSet
& rSet
, boost::optional
< sal_Int16
>& rStartNumbering
, SdrPowerPointImport
& rManager
, sal_uInt32 nDestinationInstance
, const PPTParagraphObj
* /*pPrev*/)
6054 sal_uInt32 nVal
, nUpperDist
, nLowerDist
;
6055 sal_uInt32 nInstance
= nDestinationInstance
!= 0xffffffff ? nDestinationInstance
: mnInstance
;
6057 if ( ( nDestinationInstance
!= 0xffffffff ) || ( pParaSet
->mnDepth
<= 1 ) )
6059 SvxNumBulletItem
* pNumBulletItem
= mrStyleSheet
.mpNumBulletItem
[ nInstance
];
6060 if ( pNumBulletItem
)
6062 SvxNumberFormat
aNumberFormat( SVX_NUM_NUMBER_NONE
);
6063 if ( GetNumberFormat( rManager
, aNumberFormat
, this, nDestinationInstance
, rStartNumbering
) )
6065 if ( aNumberFormat
.GetNumberingType() == SVX_NUM_NUMBER_NONE
)
6067 aNumberFormat
.SetLSpace( 0 );
6068 aNumberFormat
.SetAbsLSpace( 0 );
6069 aNumberFormat
.SetFirstLineOffset( 0 );
6070 aNumberFormat
.SetCharTextDistance( 0 );
6071 aNumberFormat
.SetFirstLineIndent( 0 );
6072 aNumberFormat
.SetIndentAt( 0 );
6074 SvxNumBulletItem
aNewNumBulletItem( *pNumBulletItem
);
6075 SvxNumRule
* pRule
= aNewNumBulletItem
.GetNumRule();
6078 pRule
->SetLevel( pParaSet
->mnDepth
, aNumberFormat
);
6080 for ( i
= 0; i
< pRule
->GetLevelCount(); i
++ )
6082 if ( i
!= pParaSet
->mnDepth
)
6086 SvxNumberFormat
aNumberFormat2( pRule
->GetLevel( i
) );
6087 const PPTParaLevel
& rParaLevel
= mrStyleSheet
.mpParaSheet
[ nInstance
]->maParaLevel
[ n
];
6088 const PPTCharLevel
& rCharLevel
= mrStyleSheet
.mpCharSheet
[ nInstance
]->maCharLevel
[ n
];
6090 if ( rParaLevel
.mnBuFlags
& ( 1 << PPT_ParaAttr_BuHardColor
) )
6091 nColor
= rParaLevel
.mnBulletColor
;
6093 nColor
= rCharLevel
.mnFontColor
;
6094 aNumberFormat2
.SetBulletColor( rManager
.MSO_TEXT_CLR_ToColor( nColor
) );
6095 pRule
->SetLevel( i
, aNumberFormat2
);
6098 rSet
.Put( aNewNumBulletItem
);
6104 sal_uInt32 nIsBullet2
, _nTextOfs
, _nBulletOfs
, nHardAttribute
= 0;
6105 GetAttrib( PPT_ParaAttr_BulletOn
, nIsBullet2
, nDestinationInstance
);
6106 nHardAttribute
+= GetAttrib( PPT_ParaAttr_TextOfs
, _nTextOfs
, nDestinationInstance
);
6107 nHardAttribute
+= GetAttrib( PPT_ParaAttr_BulletOfs
, _nBulletOfs
, nDestinationInstance
);
6110 SvxLRSpaceItem
aLRSpaceItem( EE_PARA_LRSPACE
);
6111 sal_uInt16 nAbsLSpace
= (sal_uInt16
)( ( (sal_uInt32
)_nTextOfs
* 2540 ) / 576 );
6112 sal_uInt16 nFirstLineOffset
= nAbsLSpace
- (sal_uInt16
)( ( (sal_uInt32
)_nBulletOfs
* 2540 ) / 576 );
6113 aLRSpaceItem
.SetLeft( nAbsLSpace
);
6114 aLRSpaceItem
.SetTxtFirstLineOfstValue( -nFirstLineOffset
);
6115 rSet
.Put( aLRSpaceItem
);
6119 SvxLRSpaceItem
aLRSpaceItem( EE_PARA_LRSPACE
);
6120 aLRSpaceItem
.SetLeft( 0 );
6121 aLRSpaceItem
.SetTxtFirstLineOfstValue( 0 );
6122 rSet
.Put( aLRSpaceItem
);
6124 if ( GetAttrib( PPT_ParaAttr_Adjust
, nVal
, nDestinationInstance
) )
6127 { // paragraph adjustment
6128 static SvxAdjust
const aAdj
[ 4 ] = { SVX_ADJUST_LEFT
, SVX_ADJUST_CENTER
, SVX_ADJUST_RIGHT
, SVX_ADJUST_BLOCK
};
6129 rSet
.Put( SvxAdjustItem( aAdj
[ nVal
], EE_PARA_JUST
) );
6133 if ( GetAttrib( PPT_ParaAttr_AsianLB_1
, nVal
, nDestinationInstance
) )
6134 rSet
.Put( SfxBoolItem( EE_PARA_FORBIDDENRULES
, nVal
!= 0 ) );
6135 if ( GetAttrib( PPT_ParaAttr_AsianLB_3
, nVal
, nDestinationInstance
) )
6136 rSet
.Put( SfxBoolItem( EE_PARA_HANGINGPUNCTUATION
, nVal
!= 0 ) );
6138 if ( GetAttrib( PPT_ParaAttr_BiDi
, nVal
, nDestinationInstance
) )
6139 rSet
.Put( SvxFrameDirectionItem( nVal
== 1 ? FRMDIR_HORI_RIGHT_TOP
: FRMDIR_HORI_LEFT_TOP
, EE_PARA_WRITINGDIR
) );
6142 PPTPortionObj
* pPortion
= First();
6143 sal_Bool bIsHardAttribute
= GetAttrib( PPT_ParaAttr_LineFeed
, nVal
, nDestinationInstance
);
6144 nVal2
= (sal_Int16
)nVal
;
6145 sal_uInt32 nFont
= sal_uInt32();
6146 if ( pPortion
&& pPortion
->GetAttrib( PPT_CharAttr_Font
, nFont
, nDestinationInstance
) )
6147 bIsHardAttribute
= sal_True
;
6149 if ( bIsHardAttribute
)
6151 if ( pPortion
&& ( nVal2
> 200 ) )
6153 sal_uInt32 nFontHeight
;
6154 pPortion
->GetAttrib( PPT_CharAttr_FontHeight
, nFontHeight
, nDestinationInstance
);
6155 nVal2
= -(sal_Int16
)( ( nFontHeight
* nVal
* 8 ) / 100 );
6157 rSet
.Put( SdrTextFixedCellHeightItem( sal_True
), SDRATTR_TEXT_USEFIXEDCELLHEIGHT
);
6158 SvxLineSpacingItem
aItem( 200, EE_PARA_SBL
);
6160 aItem
.SetLineHeight( (sal_uInt16
)( rManager
.ScalePoint( -nVal2
) / 8 ) );
6161 aItem
.GetLineSpaceRule() = SVX_LINE_SPACE_FIX
;
6162 aItem
.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF
;
6165 sal_uInt8 nPropLineSpace
= (sal_uInt8
)nVal2
;
6166 aItem
.SetPropLineSpace( nPropLineSpace
);
6167 aItem
.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO
;
6172 // Paragraph Spacing
6173 bIsHardAttribute
= ( (sal_uInt32
)GetAttrib( PPT_ParaAttr_UpperDist
, nUpperDist
, nDestinationInstance
) +
6174 (sal_uInt32
)GetAttrib( PPT_ParaAttr_LowerDist
, nLowerDist
, nDestinationInstance
) ) != 0;
6175 if ( ( nUpperDist
> 0 ) || ( nLowerDist
> 0 ) )
6177 if (!m_PortionList
.empty())
6179 sal_uInt32 nFontHeight
= 0;
6180 m_PortionList
.back().GetAttrib(
6181 PPT_CharAttr_FontHeight
, nFontHeight
, nDestinationInstance
);
6182 if ( ((sal_Int16
)nUpperDist
) > 0 )
6183 nUpperDist
= - (sal_Int16
)( ( nFontHeight
* nUpperDist
* 100 ) / 1000 );
6184 if ( ((sal_Int16
)nLowerDist
) > 0 )
6185 nLowerDist
= - (sal_Int16
)( ( nFontHeight
* nLowerDist
* 100 ) / 1000 );
6187 bIsHardAttribute
= sal_True
;
6189 if ( bIsHardAttribute
)
6191 SvxULSpaceItem
aULSpaceItem( EE_PARA_ULSPACE
);
6192 nVal2
= (sal_Int16
)nUpperDist
;
6194 aULSpaceItem
.SetUpper( (sal_uInt16
)(((sal_uInt32
) - nVal2
* 2540 ) / ( 72 * 8 ) ) );
6197 aULSpaceItem
.SetUpperValue( 0 );
6198 aULSpaceItem
.SetPropUpper( (sal_uInt16
)nUpperDist
== 100 ? 101 : (sal_uInt16
)nUpperDist
);
6200 nVal2
= (sal_Int16
)nLowerDist
;
6202 aULSpaceItem
.SetLower( (sal_uInt16
)(((sal_uInt32
) - nVal2
* 2540 ) / ( 72 * 8 ) ) );
6205 aULSpaceItem
.SetLowerValue( 0 );
6206 aULSpaceItem
.SetPropLower( (sal_uInt16
)nLowerDist
== 100 ? 101 : (sal_uInt16
)nLowerDist
);
6208 rSet
.Put( aULSpaceItem
);
6211 if ( mbTab
) // makes it sense to apply tabsettings
6213 sal_uInt32 i
, nDefaultTab
, nTab
, nTextOfs2
= 0;
6214 sal_uInt32 nLatestManTab
= 0;
6215 GetAttrib( PPT_ParaAttr_TextOfs
, nTextOfs2
, nDestinationInstance
);
6216 GetAttrib( PPT_ParaAttr_BulletOfs
, nTab
, nDestinationInstance
);
6217 GetAttrib( PPT_ParaAttr_BulletOn
, i
, nDestinationInstance
);
6218 GetAttrib( PPT_ParaAttr_DefaultTab
, nDefaultTab
, nDestinationInstance
);
6219 SvxTabStopItem
aTabItem( 0, 0, SVX_TAB_ADJUST_DEFAULT
, EE_PARA_TABS
);
6220 if ( GetTabCount() )
6222 for ( i
= 0; i
< GetTabCount(); i
++ )
6224 SvxTabAdjust eTabAdjust
;
6225 nTab
= GetTabOffsetByIndex( (sal_uInt16
)i
);
6226 switch( GetTabStyleByIndex( (sal_uInt16
)i
) )
6228 case 1 : eTabAdjust
= SVX_TAB_ADJUST_CENTER
; break;
6229 case 2 : eTabAdjust
= SVX_TAB_ADJUST_RIGHT
; break;
6230 case 3 : eTabAdjust
= SVX_TAB_ADJUST_DECIMAL
; break;
6231 default : eTabAdjust
= SVX_TAB_ADJUST_LEFT
;
6233 if ( nTab
> nTextOfs2
)
6234 aTabItem
.Insert( SvxTabStop( (sal_uInt16
)( ( ( nTab
- nTextOfs2
) * 2540 ) / 576 ), eTabAdjust
) );
6236 nLatestManTab
= nTab
;
6238 if ( nIsBullet2
== 0 )
6239 aTabItem
.Insert( SvxTabStop( (sal_uInt16
)0 ) );
6242 nTab
= ( nTextOfs2
> nLatestManTab
) ? nTextOfs2
: nLatestManTab
;
6243 nTab
/= nDefaultTab
;
6244 nTab
= nDefaultTab
* ( 1 + nTab
);
6245 for ( i
= 0; ( i
< 20 ) && ( nTab
< 0x1b00 ); i
++ )
6247 aTabItem
.Insert( SvxTabStop( (sal_uInt16
)( ( ( nTab
- nTextOfs2
) * 2540 ) / 576 ) ) );
6248 nTab
+= nDefaultTab
;
6251 rSet
.Put( aTabItem
);
6255 sal_uInt32
PPTParagraphObj::GetTextSize()
6257 sal_uInt32 nCount
, nRetValue
= 0;
6258 for (size_t i
= 0; i
< m_PortionList
.size(); i
++)
6260 PPTPortionObj
const& rPortionObj
= m_PortionList
[i
];
6261 nCount
= rPortionObj
.Count();
6262 if ((!nCount
) && rPortionObj
.mpFieldItem
)
6264 nRetValue
+= nCount
;
6269 PPTPortionObj
* PPTParagraphObj::First()
6271 mnCurrentObject
= 0;
6272 if (m_PortionList
.empty())
6274 return &m_PortionList
.front();
6277 PPTPortionObj
* PPTParagraphObj::Next()
6279 sal_uInt32 i
= mnCurrentObject
+ 1;
6280 if (i
>= m_PortionList
.size())
6283 return &m_PortionList
[i
];
6286 void PPTParagraphObj::ImplClear()
6290 PPTFieldEntry::~PPTFieldEntry()
6297 void PPTFieldEntry::GetDateTime( const sal_uInt32 nVal
, SvxDateFormat
& eDateFormat
, SvxTimeFormat
& eTimeFormat
)
6299 eDateFormat
= SVXDATEFORMAT_APPDEFAULT
;
6300 eTimeFormat
= SVXTIMEFORMAT_APPDEFAULT
;
6306 eDateFormat
= SVXDATEFORMAT_A
;
6309 eDateFormat
= SVXDATEFORMAT_F
;
6313 eDateFormat
= SVXDATEFORMAT_D
;
6317 eDateFormat
= SVXDATEFORMAT_C
;
6320 eDateFormat
= SVXDATEFORMAT_A
;
6322 eTimeFormat
= SVXTIMEFORMAT_24_HM
;
6325 eDateFormat
= SVXDATEFORMAT_A
;
6327 eTimeFormat
= SVXTIMEFORMAT_12_HM
;
6330 eTimeFormat
= SVXTIMEFORMAT_24_HMS
;
6333 eTimeFormat
= SVXTIMEFORMAT_12_HMS
;
6338 void PPTFieldEntry::SetDateTime( sal_uInt32 nVal
)
6340 SvxDateFormat eDateFormat
;
6341 SvxTimeFormat eTimeFormat
;
6342 GetDateTime( nVal
, eDateFormat
, eTimeFormat
);
6343 if ( eDateFormat
!= SVXDATEFORMAT_APPDEFAULT
)
6344 pField1
= new SvxFieldItem( SvxDateField( Date( Date::SYSTEM
), SVXDATETYPE_VAR
, eDateFormat
), EE_FEATURE_FIELD
);
6345 if ( eTimeFormat
!= SVXTIMEFORMAT_APPDEFAULT
)
6347 SvxFieldItem
* pFieldItem
= new SvxFieldItem( SvxExtTimeField( Time( Time::SYSTEM
), SVXTIMETYPE_VAR
, eTimeFormat
), EE_FEATURE_FIELD
);
6349 pField2
= pFieldItem
;
6351 pField1
= pFieldItem
;
6355 PPTTextObj::PPTTextObj( SvStream
& rIn
, SdrPowerPointImport
& rSdrPowerPointImport
, PptSlidePersistEntry
& rPersistEntry
, DffObjData
* pObjData
) :
6356 mpImplTextObj ( new ImplPPTTextObj( rPersistEntry
) )
6358 mpImplTextObj
->mnRefCount
= 1;
6359 mpImplTextObj
->mnShapeId
= 0;
6360 mpImplTextObj
->mnShapeMaster
= 0;
6361 mpImplTextObj
->mpPlaceHolderAtom
= NULL
;
6362 mpImplTextObj
->mnDestinationInstance
= mpImplTextObj
->mnInstance
= 4;
6363 mpImplTextObj
->mnCurrentObject
= 0;
6364 mpImplTextObj
->mnParagraphCount
= 0;
6365 mpImplTextObj
->mpParagraphList
= NULL
;
6366 mpImplTextObj
->mnTextFlags
= 0;
6367 mpImplTextObj
->meShapeType
= ( pObjData
&& pObjData
->bShapeType
) ? pObjData
->eShapeType
: mso_sptMin
;
6369 DffRecordHeader aExtParaHd
;
6370 aExtParaHd
.nRecType
= 0; // set empty
6372 bool bStatus
= true;
6374 DffRecordHeader aShapeContainerHd
;
6375 rIn
>> aShapeContainerHd
;
6377 if ( ( pObjData
== NULL
) || ( pObjData
->bShapeType
) )
6379 PPTExtParaProv
* pExtParaProv
= rSdrPowerPointImport
.pPPTStyleSheet
->pExtParaProv
;
6382 mpImplTextObj
->mnShapeId
= pObjData
->nShapeId
;
6383 if ( pObjData
->nSpFlags
& SP_FHAVEMASTER
)
6384 mpImplTextObj
->mnShapeMaster
= rSdrPowerPointImport
.GetPropertyValue( DFF_Prop_hspMaster
, 0 );
6387 if ( rSdrPowerPointImport
.maShapeRecords
.SeekToContent( rIn
, DFF_msofbtClientData
, SEEK_FROM_CURRENT_AND_RESTART
) )
6389 sal_uInt32 nOldPos
= rIn
.Tell();
6390 DffRecordHeader
& aClientDataContainerHd
= *rSdrPowerPointImport
.maShapeRecords
.Current();
6391 DffRecordHeader aPlaceHolderAtomHd
;
6392 if ( rSdrPowerPointImport
.SeekToRec( rIn
, PPT_PST_OEPlaceholderAtom
, aClientDataContainerHd
.GetRecEndFilePos(), &aPlaceHolderAtomHd
) )
6394 mpImplTextObj
->mpPlaceHolderAtom
= new PptOEPlaceholderAtom
;
6395 rIn
>> *( mpImplTextObj
->mpPlaceHolderAtom
);
6397 rIn
.Seek( nOldPos
);
6398 DffRecordHeader aProgTagHd
;
6399 if ( rSdrPowerPointImport
.SeekToContentOfProgTag( 9, rIn
, aClientDataContainerHd
, aProgTagHd
) )
6406 if ( rSdrPowerPointImport
.maShapeRecords
.SeekToContent( rIn
, DFF_msofbtClientTextbox
, SEEK_FROM_CURRENT_AND_RESTART
) )
6408 DffRecordHeader
aClientTextBoxHd( *rSdrPowerPointImport
.maShapeRecords
.Current() );
6409 sal_uInt32 nTextRulerAtomOfs
= 0; // case of zero -> this atom may be found in aClientDataContainerHd;
6410 // case of -1 -> ther is no atom of this kind
6411 // else -> this is the fileofs where we can get it
6413 // checkout if this is a referenced
6414 // textobj, if so the we will patch
6415 // the ClientTextBoxHd for a
6417 DffRecordHeader aTextHd
;
6418 if ( rSdrPowerPointImport
.SeekToRec( rIn
, PPT_PST_OutlineTextRefAtom
, aClientTextBoxHd
.GetRecEndFilePos(), &aTextHd
) )
6423 if ( rSdrPowerPointImport
.SeekToRec( rIn
, PPT_PST_TextRulerAtom
, aClientTextBoxHd
.GetRecEndFilePos() ) )
6424 nTextRulerAtomOfs
= rIn
.Tell();
6426 nTextRulerAtomOfs
= 0xffffffff;
6428 sal_uInt32 nInstance
= 0;
6429 switch( rSdrPowerPointImport
.eAktPageKind
)
6433 case PPT_MASTERPAGE
:
6435 case PPT_SLIDEPAGE
:
6442 sal_uInt32 nSlideId
= rSdrPowerPointImport
.GetAktPageId();
6447 if ( !aExtParaHd
.nRecType
)
6449 sal_uInt32 nOldPos
= rIn
.Tell();
6450 // try to locate the referenced ExtendedParaHd
6451 DffRecordHeader
* pHd
= pExtParaProv
->
6452 aExtendedPresRules
.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom
,
6453 SEEK_FROM_CURRENT_AND_RESTART
);
6454 DffRecordHeader aPresRuleHd
;
6455 DffRecordHeader
* pFirst
= pHd
;
6457 sal_uInt32 nTmpSlideId
, nTmpRef
;
6460 pHd
->SeekToContent( rIn
);
6462 >> nTmpRef
; // this seems to be the instance
6464 if ( ( nTmpSlideId
== nSlideId
) && ( pHd
->nRecInstance
== nRefNum
) )
6466 pHd
->SeekToEndOfRecord( rIn
);
6468 if ( aPresRuleHd
.nRecType
== PPT_PST_ExtendedParagraphAtom
)
6470 aExtParaHd
= aPresRuleHd
;
6474 pHd
= pExtParaProv
->
6475 aExtendedPresRules
.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom
,
6476 SEEK_FROM_CURRENT_AND_RESTART
);
6477 if ( pHd
== pFirst
)
6480 rIn
.Seek( nOldPos
);
6482 // now pHd points to the right SlideListWithText Container
6483 PptSlidePersistList
* pPageList
= rSdrPowerPointImport
.GetPageList( rSdrPowerPointImport
.eAktPageKind
);
6484 PptSlidePersistEntry
* pE
= NULL
;
6485 if ( pPageList
&& ( rSdrPowerPointImport
.nAktPageNum
< pPageList
->size() ) )
6486 pE
= (*pPageList
)[ rSdrPowerPointImport
.nAktPageNum
];
6487 if ( (!pE
) || (!pE
->nSlidePersistStartOffset
) || ( pE
->aPersistAtom
.nSlideId
!= nSlideId
) )
6491 rIn
.Seek( pE
->nSlidePersistStartOffset
);
6492 // now we got the right page and are searching for the right
6494 while ( rIn
.Tell() < pE
->nSlidePersistEndOffset
)
6496 rIn
>> aClientTextBoxHd
;
6497 if ( aClientTextBoxHd
.nRecType
== PPT_PST_TextHeaderAtom
)
6499 if ( aClientTextBoxHd
.nRecInstance
== nRefNum
)
6501 aClientTextBoxHd
.SeekToEndOfRecord( rIn
);
6505 aClientTextBoxHd
.SeekToEndOfRecord( rIn
);
6507 if ( rIn
.Tell() > pE
->nSlidePersistEndOffset
)
6510 { // patching the RecordHeader
6511 aClientTextBoxHd
.nFilePos
-= DFF_COMMON_RECORD_HEADER_SIZE
;
6512 aClientTextBoxHd
.nRecLen
+= DFF_COMMON_RECORD_HEADER_SIZE
;
6513 aClientTextBoxHd
.nRecType
= DFF_msofbtClientTextbox
;
6514 aClientTextBoxHd
.nRecVer
= DFF_PSFLAG_CONTAINER
;
6516 // we have to calculate the correct record len
6517 DffRecordHeader aTmpHd
;
6518 while ( rIn
.Tell() < pE
->nSlidePersistEndOffset
)
6521 if ( ( aTmpHd
.nRecType
== PPT_PST_SlidePersistAtom
) || ( aTmpHd
.nRecType
== PPT_PST_TextHeaderAtom
) )
6523 aTmpHd
.SeekToEndOfRecord( rIn
);
6524 aClientTextBoxHd
.nRecLen
+= aTmpHd
.nRecLen
+ DFF_COMMON_RECORD_HEADER_SIZE
;
6526 aClientTextBoxHd
.SeekToContent( rIn
);
6535 if ( rSdrPowerPointImport
.SeekToRec( rIn
, PPT_PST_TextHeaderAtom
, aClientTextBoxHd
.GetRecEndFilePos(), &aTextHd
) )
6537 // TextHeaderAtom is always the first Atom
6538 sal_uInt16 nInstance
;
6539 rIn
>> nInstance
; // this number tells us the TxMasterStyleAtom Instance
6540 if ( nInstance
> 8 )
6542 aTextHd
.SeekToEndOfRecord( rIn
);
6543 mpImplTextObj
->mnInstance
= nInstance
;
6545 sal_uInt32 nFilePos
= rIn
.Tell();
6546 if ( rSdrPowerPointImport
.SeekToRec2( PPT_PST_TextBytesAtom
,
6547 PPT_PST_TextCharsAtom
,
6548 aClientTextBoxHd
.GetRecEndFilePos() )
6549 || rSdrPowerPointImport
.SeekToRec( rIn
,
6550 PPT_PST_StyleTextPropAtom
,
6551 aClientTextBoxHd
.GetRecEndFilePos() ) )
6553 PPTTextRulerInterpreter
aTextRulerInterpreter( nTextRulerAtomOfs
, rSdrPowerPointImport
,
6554 aClientTextBoxHd
, rIn
);
6556 PPTStyleTextPropReader
aStyleTextPropReader( rIn
, rSdrPowerPointImport
, aClientTextBoxHd
,
6557 aTextRulerInterpreter
, aExtParaHd
, nInstance
);
6558 sal_uInt32 nParagraphs
= mpImplTextObj
->mnParagraphCount
= aStyleTextPropReader
.aParaPropList
.size();
6561 // the language settings will be merged into the list of PPTCharPropSet
6562 DffRecordHeader aTextSpecInfoHd
;
6563 PPTTextSpecInfoAtomInterpreter aTextSpecInfoAtomInterpreter
;
6564 if ( rSdrPowerPointImport
.SeekToRec( rIn
, PPT_PST_TextSpecInfoAtom
,
6565 aClientTextBoxHd
.GetRecEndFilePos(), &aTextSpecInfoHd
) )
6567 if ( aTextSpecInfoAtomInterpreter
.Read( rIn
, aTextSpecInfoHd
, PPT_PST_TextSpecInfoAtom
,
6568 &(rSdrPowerPointImport
.pPPTStyleSheet
->maTxSI
) ) )
6571 PPTTextSpecInfo
* pSpecInfo
;
6572 for ( size_t i
= 0; i
< aTextSpecInfoAtomInterpreter
.aList
.size(); ++i
)
6574 pSpecInfo
= aTextSpecInfoAtomInterpreter
.aList
[ i
];
6575 sal_uInt32 nCharIdx
= pSpecInfo
->nCharIdx
;
6577 // portions and text have to been splitted in some cases
6578 for ( ; nI
< aStyleTextPropReader
.aCharPropList
.size(); )
6580 PPTCharPropSet
* pSet
= aStyleTextPropReader
.aCharPropList
[ nI
];
6581 if ( pSet
->mnOriginalTextPos
< nCharIdx
)
6583 pSet
->mnLanguage
[ 0 ] = pSpecInfo
->nLanguage
[ 0 ];
6584 pSet
->mnLanguage
[ 1 ] = pSpecInfo
->nLanguage
[ 1 ];
6585 pSet
->mnLanguage
[ 2 ] = pSpecInfo
->nLanguage
[ 2 ];
6586 // test if the current portion needs to be splitted
6587 if ( pSet
->maString
.getLength() > 1 )
6589 sal_Int32 nIndexOfNextPortion
= pSet
->maString
.getLength() + pSet
->mnOriginalTextPos
;
6590 sal_Int32 nNewLen
= nIndexOfNextPortion
- nCharIdx
;
6591 sal_Int32 nOldLen
= pSet
->maString
.getLength() - nNewLen
;
6593 if ( ( nNewLen
> 0 ) && ( nOldLen
> 0 ) )
6595 OUString
aString( pSet
->maString
);
6596 PPTCharPropSet
* pNew
= new PPTCharPropSet( *pSet
);
6597 pSet
->maString
= aString
.copy( 0, nOldLen
);
6598 pNew
->maString
= aString
.copy( nOldLen
, nNewLen
);
6599 pNew
->mnOriginalTextPos
+= nOldLen
;
6600 aStyleTextPropReader
.aCharPropList
.insert( aStyleTextPropReader
.aCharPropList
.begin() + nI
+ 1, pNew
);
6613 if (!(rSdrPowerPointImport
.rImportParam
.nImportFlags
& PPT_IMPORTFLAGS_NO_TEXT_ASSERT
))
6615 OSL_FAIL( "SdrTextSpecInfoAtomInterpreter::Ctor(): parsing error, this document needs to be analysed (SJ)" );
6620 // now will search for possible textextensions such as date/time fields
6621 // or ParaTabStops and append them on this textobj
6622 rIn
.Seek( nFilePos
);
6623 ::std::vector
< PPTFieldEntry
* > FieldList
;
6624 while ( rIn
.Tell() < aClientTextBoxHd
.GetRecEndFilePos() )
6627 sal_uInt16 nVal
= 0;
6628 PPTFieldEntry
* pEntry
= NULL
;
6629 switch ( aTextHd
.nRecType
)
6631 case PPT_PST_DateTimeMCAtom
:
6633 pEntry
= new PPTFieldEntry
;
6637 pEntry
->SetDateTime( nVal
& 0xff );
6641 case PPT_PST_FooterMCAtom
:
6643 pEntry
= new PPTFieldEntry
;
6644 rIn
>> pEntry
->nPos
;
6645 pEntry
->pField1
= new SvxFieldItem( SvxFooterField(), EE_FEATURE_FIELD
);
6649 case PPT_PST_HeaderMCAtom
:
6651 pEntry
= new PPTFieldEntry
;
6652 rIn
>> pEntry
->nPos
;
6653 pEntry
->pField1
= new SvxFieldItem( SvxHeaderField(), EE_FEATURE_FIELD
);
6657 case PPT_PST_GenericDateMCAtom
:
6659 pEntry
= new PPTFieldEntry
;
6660 rIn
>> pEntry
->nPos
;
6661 pEntry
->pField1
= new SvxFieldItem( SvxDateTimeField(), EE_FEATURE_FIELD
);
6662 if ( rPersistEntry
.pHeaderFooterEntry
) // sj: #i34111# on master pages it is possible
6663 { // that there is no HeaderFooterEntry available
6664 if ( rPersistEntry
.pHeaderFooterEntry
->nAtom
& 0x20000 ) // auto date time
6665 pEntry
->SetDateTime( rPersistEntry
.pHeaderFooterEntry
->nAtom
& 0xff );
6667 pEntry
->pString
= new OUString( rPersistEntry
.pHeaderFooterEntry
->pPlaceholder
[ nVal
] );
6672 case PPT_PST_SlideNumberMCAtom
:
6673 case PPT_PST_RTFDateTimeMCAtom
:
6675 pEntry
= new PPTFieldEntry
;
6676 if ( aTextHd
.nRecLen
>= 4 )
6682 //SvxFieldItem* pFieldItem = NULL;
6683 switch( aTextHd
.nRecType
)
6685 case PPT_PST_SlideNumberMCAtom
:
6686 pEntry
->pField1
= new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD
);
6689 case PPT_PST_RTFDateTimeMCAtom
:
6691 // Rude workaround for one special case reported
6692 // by a customer. (#i75203#)
6694 // Don't even attempt to handle the general use
6695 // case for PPT_PST_RTFDateTimeMCAtom (a generic
6696 // MS style date/time format string). Just handle
6697 // the special case where the format string
6698 // contains only one or several possibly empty
6699 // quoted strings. I.e. something that doesn't
6700 // expand to any date or time at all, but to a
6701 // fixed string. How on earth somebody manages to
6702 // produce such things in PPT slides I have no
6709 bool inquote
= sal_False
;
6710 for (nLen
= 0, n
= 0; nLen
< 64; nLen
++)
6714 // Collect quoted characters into aStr
6719 // End of format string
6720 pEntry
->pString
= new OUString( aStr
);
6725 // Non-quoted character, i.e. a real
6726 // format specifier. We don't handle
6736 if ( pEntry
->pString
== NULL
)
6738 // Handle as previously
6739 pEntry
->pField1
= new SvxFieldItem( SvxDateField( Date( Date::SYSTEM
), SVXDATETYPE_FIX
), EE_FEATURE_FIELD
);
6747 case PPT_PST_InteractiveInfo
:
6749 DffRecordHeader aHdInteractiveInfoAtom
;
6750 if ( rSdrPowerPointImport
.SeekToRec( rIn
, PPT_PST_InteractiveInfoAtom
, aTextHd
.GetRecEndFilePos(), &aHdInteractiveInfoAtom
) )
6752 PptInteractiveInfoAtom aInteractiveInfoAtom
;
6753 rIn
>> aInteractiveInfoAtom
;
6754 for ( size_t i
= 0; i
< rSdrPowerPointImport
.aHyperList
.size(); ++i
)
6756 SdHyperlinkEntry
* pHyperlink
= rSdrPowerPointImport
.aHyperList
[ i
];
6757 if ( pHyperlink
->nIndex
== aInteractiveInfoAtom
.nExHyperlinkId
)
6759 aTextHd
.SeekToEndOfRecord( rIn
);
6761 if ( aTextHd
.nRecType
!= PPT_PST_TxInteractiveInfoAtom
)
6763 aTextHd
.SeekToBegOfRecord( rIn
);
6768 sal_uInt32 nStartPos
, nEndPos
;
6773 pEntry
= new PPTFieldEntry
;
6774 pEntry
->nPos
= (sal_uInt16
)nStartPos
;
6775 pEntry
->nTextRangeEnd
= (sal_uInt16
)nEndPos
;
6776 OUString
aTarget( pHyperlink
->aTarget
);
6777 if ( !pHyperlink
->aConvSubString
.isEmpty() )
6780 aTarget
+= pHyperlink
->aConvSubString
;
6782 pEntry
->pField1
= new SvxFieldItem( SvxURLField( aTarget
, String(), SVXURLFORMAT_REPR
), EE_FEATURE_FIELD
);
6792 aTextHd
.SeekToEndOfRecord( rIn
);
6795 // sorting fields ( hi >> lo )
6796 ::std::vector
< PPTFieldEntry
* >::iterator it
= FieldList
.begin();
6797 for( ; it
!= FieldList
.end(); ++it
) {
6798 if ( (*it
)->nPos
< pEntry
->nPos
) {
6802 if ( it
!= FieldList
.end() ) {
6803 FieldList
.insert( it
, pEntry
);
6805 FieldList
.push_back( pEntry
);
6809 if ( !FieldList
.empty() )
6811 ::std::vector
< PPTFieldEntry
* >::iterator FE
= FieldList
.begin();
6812 PPTCharPropSetList
& aCharPropList
= aStyleTextPropReader
.aCharPropList
;
6814 sal_Int32 i
= nParagraphs
- 1;
6815 sal_Int32 n
= aCharPropList
.size() - 1;
6817 // at this point we just have a list of textportions(aCharPropList)
6818 // the next while loop tries to resolve the list of fields(pFieldList)
6819 while( ( FE
< FieldList
.end() ) && ( n
>= 0 ) && ( i
>= 0 ) )
6821 PPTCharPropSet
* pSet
= aCharPropList
[n
];
6822 OUString
aString( pSet
->maString
);
6823 sal_uInt32 nCount
= aString
.getLength();
6824 sal_uInt32 nPos
= pSet
->mnOriginalTextPos
+ nCount
;
6825 while ( ( FE
< FieldList
.end() ) && nCount
-- )
6828 while ( ( FE
< FieldList
.end() ) && ( (*FE
)->nPos
> nPos
) )
6830 if ( !(FE
< FieldList
.end()) )
6833 if ( (*FE
)->nPos
== nPos
)
6835 if ( aString
[nCount
] == 0x2a )
6837 sal_uInt32 nBehind
= aString
.getLength() - ( nCount
+ 1 );
6838 pSet
->maString
= OUString();
6841 PPTCharPropSet
* pNewCPS
= new PPTCharPropSet( *pSet
);
6842 pNewCPS
->maString
= aString
.copy( nCount
+ 1, nBehind
);
6843 aCharPropList
.insert( aCharPropList
.begin() + n
+ 1, pNewCPS
);
6845 if ( (*FE
)->pField2
)
6847 PPTCharPropSet
* pNewCPS
= new PPTCharPropSet( *pSet
);
6848 pNewCPS
->mpFieldItem
= (*FE
)->pField2
, (*FE
)->pField2
= NULL
;
6849 aCharPropList
.insert( aCharPropList
.begin() + n
+ 1, pNewCPS
);
6851 pNewCPS
= new PPTCharPropSet( *pSet
);
6852 pNewCPS
->maString
= " ";
6853 aCharPropList
.insert( aCharPropList
.begin() + n
+ 1, pNewCPS
);
6857 PPTCharPropSet
* pNewCPS
= new PPTCharPropSet( *pSet
);
6858 pNewCPS
->maString
= aString
.copy( 0, nCount
);
6859 aCharPropList
.insert( aCharPropList
.begin() + n
++, pNewCPS
);
6861 if ( (*FE
)->pField1
)
6863 pSet
->mpFieldItem
= (*FE
)->pField1
, (*FE
)->pField1
= NULL
;
6865 else if ( (*FE
)->pString
)
6866 pSet
->maString
= *(*FE
)->pString
;
6870 if ( (*FE
)->nTextRangeEnd
) // text range hyperlink
6872 sal_uInt32 nHyperLen
= (*FE
)->nTextRangeEnd
- nPos
;
6875 PPTCharPropSet
* pBefCPS
= NULL
;
6878 pBefCPS
= new PPTCharPropSet( *pSet
);
6879 pSet
->maString
= pSet
->maString
.copy(nCount
, pSet
->maString
.getLength() - nCount
);
6881 sal_uInt32 nIdx
= n
;
6882 sal_Int32 nHyperLenLeft
= nHyperLen
;
6884 while ( ( aCharPropList
.size() > nIdx
) && nHyperLenLeft
)
6886 // the textrange hyperlink can take more than 1 paragraph
6887 // the solution here is to clone the hyperlink...
6889 PPTCharPropSet
* pCurrent
= aCharPropList
[ nIdx
];
6890 sal_Int32 nNextStringLen
= pCurrent
->maString
.getLength();
6892 DBG_ASSERT( (*FE
)->pField1
, "missing field!" );
6893 if (!(*FE
)->pField1
)
6896 const SvxURLField
* pField
= (const SvxURLField
*)(*FE
)->pField1
->GetField();
6898 pCurrent
->mbIsHyperlink
=sal_True
;
6899 pCurrent
->mnHylinkOrigColor
=pCurrent
->pCharSet
->mnColor
;
6900 pCurrent
->mbHardHylinkOrigColor
= ( ( pCurrent
->pCharSet
->mnAttrSet
>>PPT_CharAttr_FontColor
) & 1)>0;
6902 if ( pCurrent
->mpFieldItem
)
6904 pCurrent
->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK
);
6905 if ( pCurrent
->mpFieldItem
->GetField()->ISA( SvxURLField
) )
6909 else if ( nNextStringLen
)
6911 if ( nNextStringLen
<= nHyperLenLeft
)
6913 pCurrent
->mpFieldItem
= new SvxFieldItem( SvxURLField( pField
->GetURL(), pCurrent
->maString
, SVXURLFORMAT_REPR
), EE_FEATURE_FIELD
);
6914 nHyperLenLeft
-= nNextStringLen
;
6916 if ( nHyperLenLeft
)
6918 // if the next portion is in a higher paragraph,
6919 // the textrange is to decrease (because of the LineBreak character)
6920 if ( aCharPropList
.size() > ( nIdx
+ 1 ) )
6922 PPTCharPropSet
* pNext
= aCharPropList
[ nIdx
+ 1 ];
6923 if ( pNext
->mnParagraph
> pCurrent
->mnParagraph
)
6930 PPTCharPropSet
* pNewCPS
= new PPTCharPropSet( *pCurrent
);
6931 pNewCPS
->maString
= pCurrent
->maString
.copy( nHyperLenLeft
,( nNextStringLen
- nHyperLenLeft
) );
6932 aCharPropList
.insert( aCharPropList
.begin() + nIdx
+ 1, pNewCPS
);
6933 OUString aRepresentation
= pCurrent
->maString
.copy( 0, nHyperLenLeft
);
6934 pCurrent
->mpFieldItem
= new SvxFieldItem( SvxURLField( pField
->GetURL(), aRepresentation
, SVXURLFORMAT_REPR
), EE_FEATURE_FIELD
);
6937 pCurrent
->maString
= OUString();
6938 pCurrent
->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK
);
6942 delete (*FE
)->pField1
, (*FE
)->pField1
= NULL
;
6946 pBefCPS
->maString
= aString
.copy( 0, nCount
);
6947 aCharPropList
.insert( aCharPropList
.begin() + n
, pBefCPS
);
6958 for( size_t j
= 0, n2
= FieldList
.size(); j
< n2
; ++j
) {
6959 delete FieldList
[ j
];
6962 mpImplTextObj
->mpParagraphList
= new PPTParagraphObj
*[ nParagraphs
];
6963 for (size_t nCurCharPos
= 0, nCurPos
= 0;
6964 nCurPos
< aStyleTextPropReader
.aParaPropList
.size();
6967 PPTParagraphObj
* pPara
= new PPTParagraphObj(
6968 aStyleTextPropReader
, nCurPos
, nCurCharPos
,
6969 *rSdrPowerPointImport
.pPPTStyleSheet
,
6970 nInstance
, aTextRulerInterpreter
);
6971 mpImplTextObj
->mpParagraphList
[ nCurPos
] = pPara
;
6973 sal_uInt32 nParaAdjust
, nFlags
= 0;
6974 pPara
->GetAttrib( PPT_ParaAttr_Adjust
, nParaAdjust
, GetInstance() );
6976 switch ( nParaAdjust
)
6978 case 0 : nFlags
= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT
; break;
6979 case 1 : nFlags
= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER
; break;
6980 case 2 : nFlags
= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT
; break;
6981 case 3 : nFlags
= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK
; break;
6983 mpImplTextObj
->mnTextFlags
|= nFlags
;
6993 PPTTextObj::PPTTextObj( PPTTextObj
& rTextObj
)
6995 mpImplTextObj
= rTextObj
.mpImplTextObj
;
6996 mpImplTextObj
->mnRefCount
++;
6999 PPTTextObj::~PPTTextObj()
7004 PPTParagraphObj
* PPTTextObj::First()
7006 mpImplTextObj
->mnCurrentObject
= 0;
7007 if ( !mpImplTextObj
->mnParagraphCount
)
7009 return mpImplTextObj
->mpParagraphList
[ 0 ];
7012 PPTParagraphObj
* PPTTextObj::Next()
7014 sal_uInt32 i
= mpImplTextObj
->mnCurrentObject
+ 1;
7015 if ( i
>= mpImplTextObj
->mnParagraphCount
)
7017 mpImplTextObj
->mnCurrentObject
++;
7018 return mpImplTextObj
->mpParagraphList
[ i
];
7021 const SfxItemSet
* PPTTextObj::GetBackground() const
7023 if ( mpImplTextObj
->mrPersistEntry
.pBObj
)
7024 return &mpImplTextObj
->mrPersistEntry
.pBObj
->GetMergedItemSet();
7029 void PPTTextObj::ImplClear()
7031 if ( ! ( --mpImplTextObj
->mnRefCount
) )
7033 for ( PPTParagraphObj
* pPtr
= First(); pPtr
; pPtr
= Next() )
7035 delete[] mpImplTextObj
->mpParagraphList
;
7036 delete mpImplTextObj
->mpPlaceHolderAtom
;
7037 delete mpImplTextObj
;
7041 PPTTextObj
& PPTTextObj::operator=( PPTTextObj
& rTextObj
)
7043 if ( this != &rTextObj
)
7046 mpImplTextObj
= rTextObj
.mpImplTextObj
;
7047 mpImplTextObj
->mnRefCount
++;
7052 sal_Bool
IsLine( const SdrObject
* pObj
)
7054 return pObj
->ISA( SdrPathObj
) && ((SdrPathObj
*)pObj
)->IsLine() && (((SdrPathObj
*)pObj
)->GetPointCount() == 2 );
7057 sal_Bool
GetCellPosition( const SdrObject
* pObj
, const std::set
< sal_Int32
>& rRows
, const std::set
< sal_Int32
>& rColumns
,
7058 sal_Int32
& nTableIndex
, sal_Int32
& nRow
, sal_Int32
& nRowCount
, sal_Int32
& nColumn
, sal_Int32
& nColumnCount
)
7060 Rectangle
aSnapRect( pObj
->GetSnapRect() );
7061 sal_Bool bCellObject
= ( aSnapRect
.GetWidth() > 1 ) && ( aSnapRect
.GetHeight() > 1 );
7064 std::set
< sal_Int32
>::const_iterator
aRowIter( rRows
.find( aSnapRect
.Top() ) );
7065 std::set
< sal_Int32
>::const_iterator
aColumnIter( rColumns
.find( aSnapRect
.Left() ) );
7066 if ( ( aRowIter
== rRows
.end() ) || ( aColumnIter
== rColumns
.end() ) )
7067 bCellObject
= sal_False
;
7071 nRow
= std::distance( rRows
.begin(), aRowIter
);
7072 while( ++aRowIter
!= rRows
.end() )
7074 if ( *aRowIter
>= aSnapRect
.Bottom() )
7079 nColumn
= std::distance( rColumns
.begin(), aColumnIter
);
7080 while( ++aColumnIter
!= rColumns
.end() )
7082 if ( *aColumnIter
>= aSnapRect
.Right() )
7086 nTableIndex
= nRow
* rColumns
.size() + nColumn
;
7092 #define LinePositionLeft 0x01000000
7093 #define LinePositionTop 0x02000000
7094 #define LinePositionRight 0x04000000
7095 #define LinePositionBottom 0x08000000
7096 #define LinePositionTLBR 0x10000000
7097 #define LinePositionBLTR 0x20000000
7100 void GetRowPositions( const Rectangle
& rSnapRect
, const std::set
< sal_Int32
>& rRows
,
7101 const std::set
< sal_Int32
>& rColumns
, std::vector
< sal_Int32
>& rPositions
, sal_Int32 nColumn
, sal_Int32 nFlags
)
7103 std::set
< sal_Int32
>::const_iterator
aRow( rRows
.find( rSnapRect
.Top() ) );
7104 if ( aRow
!= rRows
.end() )
7106 sal_Int32 nRow
= std::distance( rRows
.begin(), aRow
);
7107 while( ( aRow
!= rRows
.end() ) && ((*aRow
) < rSnapRect
.Bottom() ) )
7109 if ( nFlags
& LinePositionLeft
)
7110 rPositions
.push_back( ( ( nRow
* rColumns
.size() ) + nColumn
) | LinePositionLeft
);
7111 if ( nFlags
& LinePositionRight
)
7112 rPositions
.push_back( ( ( nRow
* rColumns
.size() ) + ( nColumn
- 1 ) ) | LinePositionRight
);
7121 void GetColumnPositions( const Rectangle
& rSnapRect
, const std::set
< sal_Int32
>& /* rRows */,
7122 const std::set
< sal_Int32
>& rColumns
, std::vector
< sal_Int32
>& rPositions
, sal_Int32 nRow
, sal_Int32 nFlags
)
7124 std::set
< sal_Int32
>::const_iterator
aColumn( rColumns
.find( rSnapRect
.Left() ) );
7125 if ( aColumn
!= rColumns
.end() )
7127 sal_Int32 nColumn
= std::distance( rColumns
.begin(), aColumn
);
7128 while( ( aColumn
!= rColumns
.end() ) && ((*aColumn
) < rSnapRect
.Right() ) )
7130 if ( nFlags
& LinePositionTop
)
7131 rPositions
.push_back( ( ( nRow
* rColumns
.size() ) + nColumn
) | LinePositionTop
);
7132 if ( nFlags
& LinePositionBottom
)
7133 rPositions
.push_back( ( ( ( nRow
- 1 ) * rColumns
.size() ) + nColumn
) | LinePositionBottom
);
7141 void GetLinePositions( const SdrObject
* pObj
, const std::set
< sal_Int32
>& rRows
, const std::set
< sal_Int32
>& rColumns
,
7142 std::vector
< sal_Int32
>& rPositions
, const Rectangle
& rGroupSnap
)
7144 Rectangle
aSnapRect( pObj
->GetSnapRect() );
7145 if ( aSnapRect
.Left() == aSnapRect
.Right() )
7147 std::set
< sal_Int32
>::const_iterator
aColumn( rColumns
.find( aSnapRect
.Left() ) );
7148 if ( ( aColumn
!= rColumns
.end() ) || ( aSnapRect
.Left() == rGroupSnap
.Right() ) )
7150 sal_Int32 nColumn
, nFlags
;
7151 if ( aColumn
!= rColumns
.end() )
7153 nColumn
= std::distance( rColumns
.begin(), aColumn
);
7154 nFlags
= LinePositionLeft
;
7155 if ( aColumn
!= rColumns
.begin() )
7156 nFlags
|= LinePositionRight
;
7160 nColumn
= rColumns
.size();
7161 nFlags
= LinePositionRight
;
7163 GetRowPositions( aSnapRect
, rRows
, rColumns
, rPositions
, nColumn
, nFlags
);
7166 else if ( aSnapRect
.Top() == aSnapRect
.Bottom() )
7168 std::set
< sal_Int32
>::const_iterator
aRow( rRows
.find( aSnapRect
.Top() ) );
7169 if ( ( aRow
!= rRows
.end() ) || ( aSnapRect
.Top() == rGroupSnap
.Bottom() ) )
7171 sal_Int32 nRow
, nFlags
;
7172 if ( aRow
!= rRows
.end() )
7174 nRow
= std::distance( rRows
.begin(), aRow
);
7175 nFlags
= LinePositionTop
;
7176 if ( aRow
!= rRows
.begin() )
7177 nFlags
|= LinePositionBottom
;
7181 nRow
= rRows
.size();
7182 nFlags
= LinePositionBottom
;
7184 GetColumnPositions( aSnapRect
, rRows
, rColumns
, rPositions
, nRow
, nFlags
);
7189 sal_uInt32 nPosition
= 0;
7190 Point
aPt1( ((SdrPathObj
*)pObj
)->GetPoint( 0 ) );
7191 Point
aPt2( ((SdrPathObj
*)pObj
)->GetPoint( 1 ) );
7192 if ( aPt1
.X() < aPt2
.X() )
7193 nPosition
|= aPt1
.Y() < aPt2
.Y() ? LinePositionTLBR
: LinePositionBLTR
;
7195 nPosition
|= aPt1
.Y() < aPt2
.Y() ? LinePositionBLTR
: LinePositionTLBR
;
7197 std::set
< sal_Int32
>::const_iterator
aRow( rRows
.find( aPt1
.Y() < aPt2
.Y() ? aPt1
.Y() : aPt2
.Y() ) );
7198 std::set
< sal_Int32
>::const_iterator
aColumn( rColumns
.find( aPt1
.X() < aPt2
.X() ? aPt1
.X() : aPt2
.X() ) );
7199 if ( ( aRow
!= rRows
.end() ) && ( aColumn
!= rColumns
.end() ) )
7201 nPosition
|= ( std::distance( rRows
.begin(), aRow
) * rColumns
.size() ) + std::distance( rColumns
.begin(), aColumn
);
7202 rPositions
.push_back( nPosition
);
7207 void CreateTableRows( Reference
< XTableRows
> xTableRows
, const std::set
< sal_Int32
>& rRows
, sal_Int32 nTableBottom
)
7209 if ( rRows
.size() > 1 )
7210 xTableRows
->insertByIndex( 0, rRows
.size() - 1 );
7212 std::set
< sal_Int32
>::const_iterator
aIter( rRows
.begin() );
7213 sal_Int32
nLastPosition( *aIter
);
7214 Reference
< XIndexAccess
> xIndexAccess( xTableRows
, UNO_QUERY_THROW
);
7215 for ( sal_Int32 n
= 0; n
< xIndexAccess
->getCount(); n
++ )
7218 if ( ++aIter
!= rRows
.end() )
7220 nHeight
= *aIter
- nLastPosition
;
7221 nLastPosition
= *aIter
;
7224 nHeight
= nTableBottom
- nLastPosition
;
7226 static const OUString
sWidth( "Height" );
7227 Reference
< XPropertySet
> xPropSet( xIndexAccess
->getByIndex( n
), UNO_QUERY_THROW
);
7228 xPropSet
->setPropertyValue( sWidth
, Any( nHeight
) );
7232 void CreateTableColumns( Reference
< XTableColumns
> xTableColumns
, const std::set
< sal_Int32
>& rColumns
, sal_Int32 nTableRight
)
7234 if ( rColumns
.size() > 1 )
7235 xTableColumns
->insertByIndex( 0, rColumns
.size() - 1 );
7237 std::set
< sal_Int32
>::const_iterator
aIter( rColumns
.begin() );
7238 sal_Int32
nLastPosition( *aIter
);
7239 Reference
< XIndexAccess
> xIndexAccess( xTableColumns
, UNO_QUERY_THROW
);
7240 for ( sal_Int32 n
= 0; n
< xIndexAccess
->getCount(); n
++ )
7243 if ( ++aIter
!= rColumns
.end() )
7245 nWidth
= *aIter
- nLastPosition
;
7246 nLastPosition
= *aIter
;
7249 nWidth
= nTableRight
- nLastPosition
;
7251 static const OUString
sWidth( "Width" );
7252 Reference
< XPropertySet
> xPropSet( xIndexAccess
->getByIndex( n
), UNO_QUERY_THROW
);
7253 xPropSet
->setPropertyValue( sWidth
, Any( nWidth
) );
7257 void MergeCells( const Reference
< XTable
>& xTable
, sal_Int32 nCol
, sal_Int32 nRow
, sal_Int32 nColSpan
, sal_Int32 nRowSpan
)
7259 DBG_ASSERT( (nColSpan
> 1) || (nRowSpan
> 1), "nonsense parameter!!" );
7260 DBG_ASSERT( (nCol
>= 0) && (nCol
< xTable
->getColumnCount()) && (nRow
>= 0) && (nRow
< xTable
->getRowCount()), "die celle gibts nicht!!" );
7261 DBG_ASSERT( (nColSpan
>= 1) && ((nCol
+ nColSpan
- 1) < xTable
->getColumnCount()), "nColSpan murks!" );
7262 DBG_ASSERT( (nRowSpan
>= 1) && ((nRow
+ nRowSpan
- 1) < xTable
->getRowCount()), "nRowSpan murks!" );
7264 if( xTable
.is() ) try
7266 Reference
< XMergeableCellRange
> xRange( xTable
->createCursorByRange( xTable
->getCellRangeByPosition( nCol
, nRow
,nCol
+ nColSpan
- 1, nRow
+ nRowSpan
- 1 ) ), UNO_QUERY_THROW
);
7267 if( xRange
->isMergeable() )
7270 catch( const Exception
& )
7272 DBG_ASSERT( false, "exception caught!" );
7276 void ApplyCellAttributes( const SdrObject
* pObj
, Reference
< XCell
>& xCell
)
7280 Reference
< XPropertySet
> xPropSet( xCell
, UNO_QUERY_THROW
);
7282 const sal_Int32
nLeftDist(((const SdrTextLeftDistItem
&)pObj
->GetMergedItem(SDRATTR_TEXT_LEFTDIST
)).GetValue());
7283 const sal_Int32
nRightDist(((const SdrTextRightDistItem
&)pObj
->GetMergedItem(SDRATTR_TEXT_RIGHTDIST
)).GetValue());
7284 const sal_Int32
nUpperDist(((const SdrTextUpperDistItem
&)pObj
->GetMergedItem(SDRATTR_TEXT_UPPERDIST
)).GetValue());
7285 const sal_Int32
nLowerDist(((const SdrTextLowerDistItem
&)pObj
->GetMergedItem(SDRATTR_TEXT_LOWERDIST
)).GetValue());
7286 static const OUString
sTopBorder( "TextUpperDistance" );
7287 static const OUString
sBottomBorder( "TextLowerDistance" );
7288 static const OUString
sLeftBorder( "TextLeftDistance" );
7289 static const OUString
sRightBorder( "TextRightDistance" );
7290 xPropSet
->setPropertyValue( sTopBorder
, Any( nUpperDist
) );
7291 xPropSet
->setPropertyValue( sRightBorder
, Any( nRightDist
) );
7292 xPropSet
->setPropertyValue( sLeftBorder
, Any( nLeftDist
) );
7293 xPropSet
->setPropertyValue( sBottomBorder
, Any( nLowerDist
) );
7295 static const OUString
sTextVerticalAdjust( "TextVerticalAdjust" );
7296 const SdrTextVertAdjust
eTextVertAdjust(((const SdrTextVertAdjustItem
&)pObj
->GetMergedItem(SDRATTR_TEXT_VERTADJUST
)).GetValue());
7297 drawing::TextVerticalAdjust
eVA( drawing::TextVerticalAdjust_TOP
);
7298 if ( eTextVertAdjust
== SDRTEXTVERTADJUST_CENTER
)
7299 eVA
= drawing::TextVerticalAdjust_CENTER
;
7300 else if ( eTextVertAdjust
== SDRTEXTVERTADJUST_BOTTOM
)
7301 eVA
= drawing::TextVerticalAdjust_BOTTOM
;
7302 xPropSet
->setPropertyValue( sTextVerticalAdjust
, Any( eVA
) );
7304 //set textHorizontalAdjust and TextWritingMode attr
7305 const sal_Int32
eHA(((const SdrTextLeftDistItem
&)pObj
->GetMergedItem(SDRATTR_TEXT_HORZADJUST
)).GetValue());
7306 const SvxFrameDirection eDirection
= (const SvxFrameDirection
)((( const SvxFrameDirectionItem
&)pObj
->GetMergedItem(EE_PARA_WRITINGDIR
)).GetValue());
7307 static const OUString
sHorizontalAdjust( "TextHorizontalAdjust" );
7308 static const OUString
sWritingMode( "TextWritingMode" );
7309 xPropSet
->setPropertyValue( sHorizontalAdjust
, Any( eHA
) );
7310 if ( eDirection
== FRMDIR_VERT_TOP_RIGHT
)
7312 xPropSet
->setPropertyValue( sWritingMode
, Any( ::com::sun::star::text::WritingMode_TB_RL
) );
7314 SfxItemSet
aSet( pObj
->GetMergedItemSet() );
7315 XFillStyle
eFillStyle(((XFillStyleItem
&)pObj
->GetMergedItem( XATTR_FILLSTYLE
)).GetValue());
7316 ::com::sun::star::drawing::FillStyle
eFS( com::sun::star::drawing::FillStyle_NONE
);
7317 switch( eFillStyle
)
7321 static const OUString
sFillColor( String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ) );
7322 eFS
= com::sun::star::drawing::FillStyle_SOLID
;
7323 Color
aFillColor( ((XFillColorItem
&)pObj
->GetMergedItem( XATTR_FILLCOLOR
)).GetColorValue() );
7324 sal_Int32
nFillColor( aFillColor
.GetColor() );
7325 xPropSet
->setPropertyValue( sFillColor
, Any( nFillColor
) );
7328 case XFILL_GRADIENT
:
7330 eFS
= com::sun::star::drawing::FillStyle_GRADIENT
;
7331 XGradient
aXGradient(((const XFillGradientItem
&)pObj
->GetMergedItem(XATTR_FILLGRADIENT
)).GetGradientValue());
7333 com::sun::star::awt::Gradient aGradient
;
7334 aGradient
.Style
= (awt::GradientStyle
) aXGradient
.GetGradientStyle();
7335 aGradient
.StartColor
= (sal_Int32
)aXGradient
.GetStartColor().GetColor();
7336 aGradient
.EndColor
= (sal_Int32
)aXGradient
.GetEndColor().GetColor();
7337 aGradient
.Angle
= (short)aXGradient
.GetAngle();
7338 aGradient
.Border
= aXGradient
.GetBorder();
7339 aGradient
.XOffset
= aXGradient
.GetXOffset();
7340 aGradient
.YOffset
= aXGradient
.GetYOffset();
7341 aGradient
.StartIntensity
= aXGradient
.GetStartIntens();
7342 aGradient
.EndIntensity
= aXGradient
.GetEndIntens();
7343 aGradient
.StepCount
= aXGradient
.GetSteps();
7345 static const OUString
sFillGradient( String( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ) ) );
7346 xPropSet
->setPropertyValue( sFillGradient
, Any( aGradient
) );
7350 eFS
= com::sun::star::drawing::FillStyle_HATCH
;
7354 eFS
= com::sun::star::drawing::FillStyle_BITMAP
;
7356 const XFillBitmapItem
aXFillBitmapItem((const XFillBitmapItem
&)pObj
->GetMergedItem( XATTR_FILLBITMAP
));
7357 OUString
aURL( UNO_NAME_GRAPHOBJ_URLPREFIX
);
7358 aURL
+= OStringToOUString(
7359 aXFillBitmapItem
.GetGraphicObject().GetUniqueID(),
7360 RTL_TEXTENCODING_ASCII_US
);
7362 xPropSet
->setPropertyValue( OUString("FillBitmapURL"), Any( aURL
) );
7364 const XFillBmpStretchItem
aStretchItem(( const XFillBmpStretchItem
&)pObj
->GetMergedItem( XATTR_FILLBMP_STRETCH
));
7365 const XFillBmpTileItem
aTileItem(( const XFillBmpTileItem
&)pObj
->GetMergedItem( XATTR_FILLBMP_TILE
));
7366 if( aTileItem
.GetValue() )
7367 xPropSet
->setPropertyValue( "FillBitmapMode", Any( com::sun::star::drawing::BitmapMode_REPEAT
) );
7368 else if( aStretchItem
.GetValue() )
7369 xPropSet
->setPropertyValue( "FillBitmapMode", Any( com::sun::star::drawing::BitmapMode_STRETCH
) );
7371 xPropSet
->setPropertyValue( "FillBitmapMode", Any( com::sun::star::drawing::BitmapMode_NO_REPEAT
) );
7375 eFS
= com::sun::star::drawing::FillStyle_NONE
;
7379 static const OUString
sFillStyle( String( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ) ) );
7380 xPropSet
->setPropertyValue( sFillStyle
, Any( eFS
) );
7381 if ( eFillStyle
!= XFILL_NONE
)
7383 sal_Int16
nFillTransparence( ( (const XFillTransparenceItem
&)pObj
->GetMergedItem( XATTR_FILLTRANSPARENCE
) ).GetValue() );
7384 static const OUString
sFillTransparence( String( RTL_CONSTASCII_USTRINGPARAM( "FillTransparence" ) ) );
7385 xPropSet
->setPropertyValue( sFillTransparence
, Any( nFillTransparence
) );
7388 catch( const Exception
& )
7393 void ApplyCellLineAttributes( const SdrObject
* pLine
, Reference
< XTable
>& xTable
, const std::vector
< sal_Int32
>& vPositions
, sal_Int32 nColumns
)
7397 SfxItemSet
aSet( pLine
->GetMergedItemSet() );
7398 XLineStyle
eLineStyle(((XLineStyleItem
&)pLine
->GetMergedItem( XATTR_LINESTYLE
)).GetValue());
7399 com::sun::star::table::BorderLine2 aBorderLine
;
7400 switch( eLineStyle
)
7405 Color
aLineColor( ((XLineColorItem
&)pLine
->GetMergedItem( XATTR_LINECOLOR
)).GetColorValue() );
7406 aBorderLine
.Color
= aLineColor
.GetColor();
7407 // Avoid width = 0, the min value should be 1.
7408 sal_Int32 nLineWidth
= std::max(sal_Int32(1), ((const XLineWidthItem
&)(pLine
->GetMergedItem(XATTR_LINEWIDTH
))).GetValue() / 4);
7409 aBorderLine
.LineWidth
= static_cast< sal_Int16
>( nLineWidth
);
7410 aBorderLine
.LineStyle
= eLineStyle
== XLINE_SOLID
? table::BorderLineStyle::SOLID
: table::BorderLineStyle::DASHED
;
7415 aBorderLine
.LineWidth
= 0;
7416 aBorderLine
.LineStyle
= table::BorderLineStyle::NONE
;
7420 Reference
< XCellRange
> xCellRange( xTable
, UNO_QUERY_THROW
);
7421 std::vector
< sal_Int32
>::const_iterator
aIter( vPositions
.begin() );
7422 while( aIter
!= vPositions
.end() )
7424 static const OUString
sTopBorder( String( RTL_CONSTASCII_USTRINGPARAM( "TopBorder" ) ) );
7425 static const OUString
sBottomBorder( String( RTL_CONSTASCII_USTRINGPARAM( "BottomBorder" ) ) );
7426 static const OUString
sLeftBorder( String( RTL_CONSTASCII_USTRINGPARAM( "LeftBorder" ) ) );
7427 static const OUString
sRightBorder( String( RTL_CONSTASCII_USTRINGPARAM( "RightBorder" ) ) );
7428 static const OUString
sDiagonalTLBR( "DiagonalTLBR" );
7429 static const OUString
sDiagonalBLTR( "DiagonalBLTR" );
7431 sal_Int32 nPosition
= *aIter
& 0xffffff;
7432 sal_Int32 nFlags
= *aIter
&~0xffffff;
7433 sal_Int32 nRow
= nPosition
/ nColumns
;
7434 sal_Int32 nColumn
= nPosition
- ( nRow
* nColumns
);
7435 Reference
< XCell
> xCell( xCellRange
->getCellByPosition( nColumn
, nRow
) );
7436 Reference
< XPropertySet
> xPropSet( xCell
, UNO_QUERY_THROW
);
7438 if ( nFlags
& LinePositionLeft
)
7439 xPropSet
->setPropertyValue( sLeftBorder
, Any( aBorderLine
) );
7440 if ( nFlags
& LinePositionTop
)
7441 xPropSet
->setPropertyValue( sTopBorder
, Any( aBorderLine
) );
7442 if ( nFlags
& LinePositionRight
)
7443 xPropSet
->setPropertyValue( sRightBorder
, Any( aBorderLine
) );
7444 if ( nFlags
& LinePositionBottom
)
7445 xPropSet
->setPropertyValue( sBottomBorder
, Any( aBorderLine
) );
7446 if ( nFlags
& LinePositionTLBR
)
7447 xPropSet
->setPropertyValue( sDiagonalTLBR
, Any( sal_True
) );
7448 if ( nFlags
& LinePositionBLTR
)
7449 xPropSet
->setPropertyValue( sDiagonalBLTR
, Any( sal_True
) );
7453 catch( const Exception
& )
7458 SdrObject
* SdrPowerPointImport::CreateTable( SdrObject
* pGroup
, sal_uInt32
* pTableArry
, SvxMSDffSolverContainer
* pSolverContainer
)
7460 SdrObject
* pRet
= pGroup
;
7461 sal_uInt32 nRows
= pTableArry
[ 1 ];
7462 if ( nRows
&& pGroup
->ISA( SdrObjGroup
) )
7464 SdrObjList
* pSubList(((SdrObjGroup
*)pGroup
)->GetSubList());
7467 std::set
< sal_Int32
> aRows
;
7468 std::set
< sal_Int32
> aColumns
;
7470 SdrObjListIter
aGroupIter( *pSubList
, IM_DEEPNOGROUPS
, sal_False
);
7471 while( aGroupIter
.IsMore() )
7473 const SdrObject
* pObj( aGroupIter
.Next() );
7474 if ( !IsLine( pObj
) )
7476 Rectangle
aSnapRect( pObj
->GetSnapRect() );
7477 aRows
.insert( aSnapRect
.Top() );
7478 aColumns
.insert( aSnapRect
.Left() );
7481 ::sdr::table::SdrTableObj
* pTable
= new ::sdr::table::SdrTableObj( pSdrModel
);
7483 Reference
< XTable
> xTable( pTable
->getTable() );
7486 Reference
< XColumnRowRange
> xColumnRowRange( xTable
, UNO_QUERY_THROW
);
7488 CreateTableRows( xColumnRowRange
->getRows(), aRows
, pGroup
->GetSnapRect().Bottom() );
7489 CreateTableColumns( xColumnRowRange
->getColumns(), aColumns
, pGroup
->GetSnapRect().Right() );
7491 sal_Int32 nCellCount
= aRows
.size() * aColumns
.size();
7492 sal_Int32
*pMergedCellIndexTable
= new sal_Int32
[ nCellCount
];
7493 for ( sal_Int32 i
= 0; i
< nCellCount
; i
++ )
7494 pMergedCellIndexTable
[ i
] = i
;
7497 while( aGroupIter
.IsMore() )
7499 SdrObject
* pObj( aGroupIter
.Next() );
7500 if ( !IsLine( pObj
) )
7502 sal_Int32 nTableIndex
= 0;
7504 sal_Int32 nRowCount
= 0;
7505 sal_Int32 nColumn
= 0;
7506 sal_Int32 nColumnCount
= 0;
7507 if ( GetCellPosition( pObj
, aRows
, aColumns
, nTableIndex
, nRow
, nRowCount
, nColumn
, nColumnCount
) )
7509 Reference
< XCellRange
> xCellRange( xTable
, UNO_QUERY_THROW
);
7510 Reference
< XCell
> xCell( xCellRange
->getCellByPosition( nColumn
, nRow
) );
7512 ApplyCellAttributes( pObj
, xCell
);
7514 if ( ( nRowCount
> 1 ) || ( nColumnCount
> 1 ) ) // cell merging
7516 MergeCells( xTable
, nColumn
, nRow
, nColumnCount
, nRowCount
);
7517 for ( sal_Int32 nRowIter
= 0; nRowIter
< nRowCount
; nRowIter
++ )
7519 for ( sal_Int32 nColumnIter
= 0; nColumnIter
< nColumnCount
; nColumnIter
++ )
7520 { // now set the correct index for the merged cell
7521 pMergedCellIndexTable
[ ( ( nRow
+ nRowIter
) * aColumns
.size() ) + nColumn
+ nColumnIter
] = nTableIndex
;
7527 OutlinerParaObject
* pParaObject
= pObj
->GetOutlinerParaObject();
7530 SdrText
* pSdrText
= pTable
->getText( nTableIndex
);
7532 pSdrText
->SetOutlinerParaObject(new OutlinerParaObject(*pParaObject
) );
7538 while( aGroupIter
.IsMore() )
7540 SdrObject
* pObj( aGroupIter
.Next() );
7541 if ( IsLine( pObj
) )
7543 std::vector
< sal_Int32
> vPositions
; // containing cell indexes + cell position
7544 GetLinePositions( pObj
, aRows
, aColumns
, vPositions
, pGroup
->GetSnapRect() );
7546 // correcting merged cell position
7547 std::vector
< sal_Int32
>::iterator
aIter( vPositions
.begin() );
7548 while( aIter
!= vPositions
.end() )
7550 sal_Int32 nOldPosition
= *aIter
& 0xffff;
7551 sal_Int32 nOldFlags
= *aIter
& 0xffff0000;
7552 sal_Int32 nNewPosition
= pMergedCellIndexTable
[ nOldPosition
] | nOldFlags
;
7553 *aIter
++ = nNewPosition
;
7555 ApplyCellLineAttributes( pObj
, xTable
, vPositions
, aColumns
.size() );
7558 delete[] pMergedCellIndexTable
;
7560 // we are replacing the whole group object by a single table object, so
7561 // possibly connections to the group object have to be removed.
7562 if ( pSolverContainer
)
7564 for ( size_t i
= 0; i
< pSolverContainer
->aCList
.size(); ++i
)
7566 SvxMSDffConnectorRule
* pPtr
= pSolverContainer
->aCList
[ i
];
7568 // check connections to the group object
7569 if ( pPtr
->pAObj
== pGroup
)
7571 if ( pPtr
->pBObj
== pGroup
)
7574 // check connections to all its subobjects
7575 SdrObjListIter
aIter( *pGroup
, IM_DEEPWITHGROUPS
);
7576 while( aIter
.IsMore() )
7578 SdrObject
* pPartObj
= aIter
.Next();
7579 if ( pPtr
->pAObj
== pPartObj
)
7581 if ( pPtr
->pBObj
== pPartObj
)
7584 //In MS, the one_row_one_col table is made up of five
7585 //shape,the connector is connected to some part of a
7586 //table. But for us, the connector is connected to the
7587 //whole group table,so the connector obj is a group
7588 //table when export by us. We should process this
7589 //situation when importing.
7590 if ( pPtr
->pAObj
== pGroup
)
7591 pPtr
->pAObj
= pTable
;
7592 if ( pPtr
->pBObj
== pGroup
)
7593 pPtr
->pBObj
= pTable
;
7596 pTable
->uno_unlock();
7597 pTable
->SetSnapRect( pGroup
->GetSnapRect() );
7600 //Remove Objects from shape map
7601 SdrObjListIter
aIter( *pGroup
, IM_DEEPWITHGROUPS
);
7602 while( aIter
.IsMore() )
7604 SdrObject
* pPartObj
= aIter
.Next();
7605 removeShapeId( pPartObj
);
7608 SdrObject::Free( pGroup
);
7610 catch( const Exception
& )
7612 pTable
->uno_unlock();
7613 SdrObject
* pObj
= pTable
;
7614 SdrObject::Free( pObj
);
7621 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */