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