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

Generated by: LCOV version 1.10