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