LCOV - code coverage report
Current view: top level - filter/source/msfilter - svdfppt.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 4284 0.0 %
Date: 2014-04-14 Functions: 0 183 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10