LCOV - code coverage report
Current view: top level - filter/source/msfilter - svdfppt.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 3119 4288 72.7 %
Date: 2014-04-11 Functions: 157 183 85.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10