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