LCOV - code coverage report
Current view: top level - filter/source/msfilter - msdffimp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1491 3921 38.0 %
Date: 2012-08-25 Functions: 92 115 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1466 6732 21.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <com/sun/star/embed/Aspects.hpp>
      31                 :            : 
      32                 :            : #include <math.h>
      33                 :            : #include <limits.h>
      34                 :            : #include <vector>
      35                 :            : #include <osl/endian.h>
      36                 :            : #include <tools/solar.h>
      37                 :            : #include <rtl/math.hxx>
      38                 :            : 
      39                 :            : #include <sot/clsids.hxx>
      40                 :            : #include <toolkit/helper/vclunohelper.hxx>
      41                 :            : #include <unotools/streamwrap.hxx>
      42                 :            : #include <comphelper/processfactory.hxx>
      43                 :            : #include <comphelper/string.hxx>
      44                 :            : #include <sot/exchange.hxx>
      45                 :            : #include <sot/storinfo.hxx>
      46                 :            : #include <vcl/cvtgrf.hxx>
      47                 :            : #include "viscache.hxx"
      48                 :            : 
      49                 :            : // SvxItem-Mapping. Is needed to successfully include the SvxItem-Header
      50                 :            : #include <editeng/eeitem.hxx>
      51                 :            : #include <editeng/editdata.hxx>
      52                 :            : #include <svl/urihelper.hxx>
      53                 :            : #include <tools/stream.hxx>
      54                 :            : #include <tools/debug.hxx>
      55                 :            : #include <tools/zcodec.hxx>
      56                 :            : #include <unotools/ucbstreamhelper.hxx>
      57                 :            : #include <unotools/localfilehelper.hxx>
      58                 :            : #include <filter/msfilter/escherex.hxx>
      59                 :            : #include <basegfx/range/b2drange.hxx>
      60                 :            : #include <com/sun/star/container/XIdentifierContainer.hpp>
      61                 :            : #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
      62                 :            : #include <com/sun/star/drawing/Position3D.hpp>
      63                 :            : #include <com/sun/star/drawing/Direction3D.hpp>
      64                 :            : #include <com/sun/star/drawing/GluePoint2.hpp>
      65                 :            : #include <com/sun/star/drawing/XShapes.hpp>
      66                 :            : #include <editeng/charscaleitem.hxx>
      67                 :            : #include <editeng/kernitem.hxx>
      68                 :            : #include <svtools/filter.hxx>
      69                 :            : #include <tools/string.hxx>
      70                 :            : #include <tools/urlobj.hxx>
      71                 :            : #include <vcl/virdev.hxx>
      72                 :            : #include <vcl/bmpacc.hxx>
      73                 :            : #include <sot/storage.hxx>
      74                 :            : #include <sfx2/docfac.hxx>
      75                 :            : #include <sfx2/docfilt.hxx>
      76                 :            : #include <sfx2/docfile.hxx>
      77                 :            : #include <sfx2/fcontnr.hxx>
      78                 :            : #include <sfx2/module.hxx>
      79                 :            : #include <svx/sdgcpitm.hxx>
      80                 :            : #include <svx/sdgmoitm.hxx>
      81                 :            : #include <editeng/tstpitem.hxx>
      82                 :            : #include <svx/fmmodel.hxx>
      83                 :            : #include <svx/svdmodel.hxx>
      84                 :            : #include <svx/svdobj.hxx>
      85                 :            : #include <svx/svdpage.hxx>
      86                 :            : #include <svx/svdogrp.hxx>
      87                 :            : #include <svx/svdograf.hxx>
      88                 :            : #include <svx/svdotext.hxx>
      89                 :            : #include <svx/svdorect.hxx>
      90                 :            : #include <svx/svdocapt.hxx>
      91                 :            : #include <svx/svdoedge.hxx>
      92                 :            : #include <svx/svdocirc.hxx>
      93                 :            : #include <svx/svdoutl.hxx>
      94                 :            : #include <svx/svdoole2.hxx>
      95                 :            : #include <svx/svdopath.hxx>
      96                 :            : #include <editeng/frmdir.hxx>
      97                 :            : #include <editeng/frmdiritem.hxx>
      98                 :            : #include <svx/svdtrans.hxx>
      99                 :            : #include <svx/sxenditm.hxx>
     100                 :            : #include <svx/sdgluitm.hxx>
     101                 :            : #include <editeng/fhgtitem.hxx>
     102                 :            : #include <editeng/wghtitem.hxx>
     103                 :            : #include <editeng/postitem.hxx>
     104                 :            : #include <editeng/udlnitem.hxx>
     105                 :            : #include <editeng/crsditem.hxx>
     106                 :            : #include <editeng/shdditem.hxx>
     107                 :            : #include <editeng/fontitem.hxx>
     108                 :            : #include <editeng/colritem.hxx>
     109                 :            : #include <svx/sxekitm.hxx>
     110                 :            : #include <editeng/bulitem.hxx>
     111                 :            : #include <svx/polysc3d.hxx>
     112                 :            : #include <svx/extrud3d.hxx>
     113                 :            : #include "svx/svditer.hxx"
     114                 :            : #include <svx/xpoly.hxx>
     115                 :            : #include "svx/xattr.hxx"
     116                 :            : #include <filter/msfilter/msdffimp.hxx> // externally visible header file
     117                 :            : #include <editeng/outliner.hxx>
     118                 :            : #include <editeng/outlobj.hxx>
     119                 :            : #include <editeng/editobj.hxx>
     120                 :            : #include <editeng/editeng.hxx>
     121                 :            : #include "svx/gallery.hxx"
     122                 :            : #include <com/sun/star/drawing/ShadeMode.hpp>
     123                 :            : #include <svl/itempool.hxx>
     124                 :            : #include <vcl/svapp.hxx>
     125                 :            : #include <svx/svx3ditems.hxx>
     126                 :            : #include <svx/svdoashp.hxx>
     127                 :            : #include <svx/sdasaitm.hxx>
     128                 :            : #include <ucbhelper/content.hxx>
     129                 :            : #include <ucbhelper/contentbroker.hxx>
     130                 :            : 
     131                 :            : #include "svx/EnhancedCustomShapeTypeNames.hxx"
     132                 :            : #include "svx/EnhancedCustomShapeGeometry.hxx"
     133                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
     134                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
     135                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
     136                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp>
     137                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
     138                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
     139                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
     140                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
     141                 :            : #include <com/sun/star/beans/PropertyValues.hpp>
     142                 :            : #include <com/sun/star/drawing/ProjectionMode.hpp>
     143                 :            : #include "svx/EnhancedCustomShape2d.hxx"
     144                 :            : #include <rtl/strbuf.hxx>
     145                 :            : #include <rtl/oustringostreaminserter.hxx>
     146                 :            : #include <boost/scoped_array.hpp>
     147                 :            : 
     148                 :            : using namespace ::com::sun::star    ;
     149                 :            : using namespace ::com::sun::star::drawing;
     150                 :            : using namespace uno                 ;
     151                 :            : using namespace beans               ;
     152                 :            : using namespace drawing             ;
     153                 :            : using namespace container           ;
     154                 :            : 
     155                 :            : #define ITEMVALUE(ItemSet,Id,Cast)  ((const Cast&)(ItemSet).Get(Id)).GetValue()
     156                 :            : 
     157                 :            : // static counter for OLE-Objects
     158                 :            : static sal_uInt32 nMSOleObjCntr = 0;
     159                 :            : #define MSO_OLE_Obj "MSO_OLE_Obj"
     160                 :            : 
     161                 :            : /************************************************************************/
     162                 :          0 : void Impl_OlePres::Write( SvStream & rStm )
     163                 :            : {
     164                 :          0 :     WriteClipboardFormat( rStm, FORMAT_GDIMETAFILE );
     165                 :          0 :     rStm << (sal_Int32)(nJobLen +4);       // a TargetDevice that's always empty
     166         [ #  # ]:          0 :     if( nJobLen )
     167                 :          0 :         rStm.Write( pJob, nJobLen );
     168                 :          0 :     rStm << (sal_uInt32)nAspect;
     169                 :          0 :     rStm << (sal_Int32)-1;      //L-Index always -1
     170                 :          0 :     rStm << (sal_Int32)nAdvFlags;
     171                 :          0 :     rStm << (sal_Int32)0;       //Compression
     172                 :          0 :     rStm << (sal_Int32)aSize.Width();
     173                 :          0 :     rStm << (sal_Int32)aSize.Height();
     174                 :          0 :     sal_uLong nPos = rStm.Tell();
     175                 :          0 :     rStm << (sal_Int32)0;
     176                 :            : 
     177 [ #  # ][ #  # ]:          0 :     if( GetFormat() == FORMAT_GDIMETAFILE && pMtf )
                 [ #  # ]
     178                 :            :     {
     179                 :            :         // Immer auf 1/100 mm, bis Mtf-Loesung gefunden
     180                 :            :         // Annahme (keine Skalierung, keine Org-Verschiebung)
     181                 :            :         DBG_ASSERT( pMtf->GetPrefMapMode().GetScaleX() == Fraction( 1, 1 ),
     182                 :            :                     "X-Skalierung im Mtf" );
     183                 :            :         DBG_ASSERT( pMtf->GetPrefMapMode().GetScaleY() == Fraction( 1, 1 ),
     184                 :            :                     "Y-Skalierung im Mtf" );
     185                 :            :         DBG_ASSERT( pMtf->GetPrefMapMode().GetOrigin() == Point(),
     186                 :            :                     "Origin-Verschiebung im Mtf" );
     187                 :          0 :         MapUnit nMU = pMtf->GetPrefMapMode().GetMapUnit();
     188         [ #  # ]:          0 :         if( MAP_100TH_MM != nMU )
     189                 :            :         {
     190                 :          0 :             Size aPrefS( pMtf->GetPrefSize() );
     191                 :          0 :             Size aS( aPrefS );
     192 [ #  # ][ #  # ]:          0 :             aS = OutputDevice::LogicToLogic( aS, nMU, MAP_100TH_MM );
         [ #  # ][ #  # ]
                 [ #  # ]
     193                 :            : 
     194                 :          0 :             pMtf->Scale( Fraction( aS.Width(), aPrefS.Width() ),
     195   [ #  #  #  # ]:          0 :                          Fraction( aS.Height(), aPrefS.Height() ) );
                 [ #  # ]
     196 [ #  # ][ #  # ]:          0 :             pMtf->SetPrefMapMode( MAP_100TH_MM );
                 [ #  # ]
     197                 :          0 :             pMtf->SetPrefSize( aS );
     198                 :            :         }
     199                 :          0 :         WriteWindowMetafileBits( rStm, *pMtf );
     200                 :            :     }
     201                 :            :     else
     202                 :            :     {
     203                 :            :         OSL_FAIL( "unknown format" );
     204                 :            :     }
     205                 :          0 :     sal_uLong nEndPos = rStm.Tell();
     206                 :          0 :     rStm.Seek( nPos );
     207                 :          0 :     rStm << (sal_uInt32)(nEndPos - nPos - 4);
     208                 :          0 :     rStm.Seek( nEndPos );
     209                 :          0 : }
     210                 :            : 
     211                 :            : //---------------------------------------------------------------------------
     212                 :            : //  Hilfs Klassen aus MSDFFDEF.HXX
     213                 :            : //---------------------------------------------------------------------------
     214                 :            : 
     215                 :      17625 : SvStream& operator>>( SvStream& rIn, DffRecordHeader& rRec )
     216                 :            : {
     217                 :      17625 :     rRec.nFilePos = rIn.Tell();
     218                 :      17625 :     sal_uInt16 nTmp(0);
     219         [ +  - ]:      17625 :     rIn >> nTmp;
     220                 :      17625 :     rRec.nImpVerInst = nTmp;
     221                 :      17625 :     rRec.nRecVer = sal::static_int_cast< sal_uInt8 >(nTmp & 0x000F);
     222                 :      17625 :     rRec.nRecInstance = nTmp >> 4;
     223         [ +  - ]:      17625 :     rIn >> rRec.nRecType;
     224         [ +  - ]:      17625 :     rIn >> rRec.nRecLen;
     225                 :      17625 :     return rIn;
     226                 :            : }
     227                 :            : 
     228                 :            : // measurements  dashed lines
     229                 :            : #define LLEN_MIDDLE         (450)
     230                 :            : #define LLEN_SPACE_MIDDLE   (360)
     231                 :            : #define LLEN_LONG           (LLEN_MIDDLE * 2)
     232                 :            : #define LLEN_SPACE_LONG     (LLEN_SPACE_MIDDLE + 20)
     233                 :            : #define LLEN_POINT          (LLEN_MIDDLE / 4)
     234                 :            : #define LLEN_SPACE_POINT    (LLEN_SPACE_MIDDLE / 4)
     235                 :            : 
     236                 :        886 : SvStream& operator>>( SvStream& rIn, DffPropSet& rRec )
     237                 :            : {
     238         [ +  - ]:        886 :     rRec.InitializePropSet();
     239                 :            : 
     240                 :        886 :     DffRecordHeader aHd;
     241         [ +  - ]:        886 :     rIn >> aHd;
     242                 :        886 :     sal_uInt32 nPropCount = aHd.nRecInstance;
     243                 :            : 
     244                 :            :     // remember FilePos of the ComplexData
     245                 :        886 :     sal_uInt32 nComplexDataFilePos = rIn.Tell() + ( nPropCount * 6 );
     246                 :            : 
     247         [ +  + ]:       8259 :     for( sal_uInt32 nPropNum = 0; nPropNum < nPropCount; nPropNum++ )
     248                 :            :     {
     249                 :            :         sal_uInt16 nTmp;
     250                 :       7373 :         sal_uInt32 nRecType, nContent, nContentEx = 0xffff0000;
     251         [ +  - ]:       7373 :         rIn >> nTmp
     252         [ +  - ]:       7373 :             >> nContent;
     253                 :            : 
     254                 :       7373 :         nRecType = nTmp & 0x3fff;
     255                 :            : 
     256         [ +  - ]:       7373 :         if ( nRecType > 0x3ff )
     257                 :            :             break;
     258         [ +  + ]:       7373 :         if ( ( nRecType & 0x3f ) == 0x3f )
     259                 :            :         {   // clear flags that have to be cleared
     260                 :       3005 :             rRec.mpContents[ nRecType ] &= ( ( nContent >> 16 ) ^ 0xffffffff );
     261                 :            :             // set flags that have to be set
     262                 :       3005 :             rRec.mpContents[ nRecType ] |= nContent;
     263                 :       3005 :             nContentEx |= ( nContent >> 16 );
     264         [ +  - ]:       3005 :             rRec.maRecordTypes[ nRecType ] = nContentEx;
     265                 :            :         }
     266                 :            :         else
     267                 :            :         {
     268                 :       4368 :             DffPropFlags aPropFlag = { 1, 0, 0, 0 };
     269         [ +  + ]:       4368 :             if ( nTmp & 0x4000 )
     270                 :        139 :                 aPropFlag.bBlip = sal_True;
     271         [ +  + ]:       4368 :             if ( nTmp & 0x8000 )
     272                 :         50 :                 aPropFlag.bComplex = sal_True;
     273 [ +  + ][ +  + ]:       4368 :             if ( aPropFlag.bComplex && nContent && ( nComplexDataFilePos < aHd.GetRecEndFilePos() ) )
         [ +  - ][ +  + ]
     274                 :            :             {
     275                 :            :                 // normally nContent is the complete size of the complex property,
     276                 :            :                 // but this is not always true for IMsoArrays ( what the hell is a IMsoArray ? )
     277                 :            : 
     278                 :            :                 // I love special treatments :-(
     279 [ +  + ][ +  + ]:         38 :                 if ( ( nRecType == DFF_Prop_pVertices ) || ( nRecType == DFF_Prop_pSegmentInfo )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ -  + ]
     280                 :            :                     || ( nRecType == DFF_Prop_fillShadeColors ) || ( nRecType == DFF_Prop_lineDashStyle )
     281                 :            :                         || ( nRecType == DFF_Prop_pWrapPolygonVertices ) || ( nRecType == DFF_Prop_connectorPoints )
     282                 :            :                             || ( nRecType == DFF_Prop_Handles ) || ( nRecType == DFF_Prop_pFormulas )
     283                 :            :                                 || ( nRecType == DFF_Prop_textRectangles ) )
     284                 :            :                 {
     285                 :            :                     // now check if the current content size is possible, or 6 bytes too small
     286                 :          6 :                     sal_uInt32  nOldPos = rIn.Tell();
     287                 :            :                     sal_Int16   nNumElem, nNumElemReserved, nSize;
     288                 :            : 
     289         [ +  - ]:          6 :                     rIn.Seek( nComplexDataFilePos );
     290 [ +  - ][ +  - ]:          6 :                     rIn >>  nNumElem >> nNumElemReserved >> nSize;
                 [ +  - ]
     291         [ +  - ]:          6 :                     if ( nNumElemReserved >= nNumElem )
     292                 :            :                     {
     293                 :            :                         // the size of these array elements is nowhere defined,
     294                 :            :                         // what if the size is negative ?
     295                 :            :                         // ok, we will make it positive and shift it.
     296                 :            :                         // for -16 this works
     297         [ +  + ]:          6 :                         if ( nSize < 0 )
     298                 :          3 :                             nSize = ( -nSize ) >> 2;
     299                 :          6 :                         sal_uInt32 nDataSize = (sal_uInt32)( nSize * nNumElem );
     300                 :            : 
     301                 :            :                         // sometimes the content size is 6 bytes too small (array header information is missing )
     302         [ +  + ]:          6 :                         if ( nDataSize == nContent )
     303                 :          3 :                             nContent += 6;
     304                 :            : 
     305                 :            :                         // check if array fits into the PropertyContainer
     306         [ -  + ]:          6 :                         if ( ( nComplexDataFilePos + nContent ) > aHd.GetRecEndFilePos() )
     307                 :          0 :                             nContent = 0;
     308                 :            :                     }
     309                 :            :                     else
     310                 :          0 :                         nContent = 0;
     311         [ +  - ]:          6 :                     rIn.Seek( nOldPos );
     312                 :            :                 }
     313         [ +  - ]:         38 :                 if ( nContent )
     314                 :            :                 {
     315                 :         38 :                     nContentEx = nComplexDataFilePos;   // insert the filepos of this property;
     316                 :         38 :                     nComplexDataFilePos += nContent;    // store filepos, that is used for the next complex property
     317                 :            :                 }
     318                 :            :                 else                                    // a complex property needs content
     319                 :          0 :                     aPropFlag.bSet = sal_False;         // otherwise something is wrong
     320                 :            :             }
     321                 :       4368 :             rRec.mpContents[ nRecType ] = nContent;
     322                 :       4368 :             rRec.mpFlags[ nRecType ] = aPropFlag;
     323         [ +  - ]:       4368 :             rRec.maRecordTypes[ nRecType ] = nContentEx;
     324                 :            :         }
     325                 :            :     }
     326         [ +  - ]:        886 :     aHd.SeekToEndOfRecord( rIn );
     327                 :        886 :     return rIn;
     328                 :            : }
     329                 :            : 
     330                 :       1022 : void DffPropSet::InitializePropSet() const
     331                 :            : {
     332                 :            :     /*
     333                 :            :     cmc:
     334                 :            :     " Boolean properties are grouped in bitfields by property set; note that
     335                 :            :     the Boolean properties in each property set are contiguous. They are saved
     336                 :            :     under the property ID of the last Boolean property in the set, and are
     337                 :            :     placed in the value field in reverse order starting with the last property
     338                 :            :     in the low bit. "
     339                 :            : 
     340                 :            :     e.g.
     341                 :            : 
     342                 :            :     fEditedWrap
     343                 :            :     fBehindDocument
     344                 :            :     fOnDblClickNotify
     345                 :            :     fIsButton
     346                 :            :     fOneD
     347                 :            :     fHidden
     348                 :            :     fPrint
     349                 :            : 
     350                 :            :     are all part of a group and all are by default false except for fPrint,
     351                 :            :     which equates to a default bit sequence for the group of 0000001 -> 0x1
     352                 :            : 
     353                 :            :     If at a later stage word sets fBehindDocument away from the default it
     354                 :            :     will be done by having a property named fPrint whose bitsequence will have
     355                 :            :     the fBehindDocument bit set. e.g. a DFF_Prop_fPrint with value 0x200020
     356                 :            :     has set bit 6 on so as to enable fBehindDocument (as well as disabling
     357                 :            :     everything else)
     358                 :            :     */
     359                 :            : 
     360                 :       1022 :     DffPropSet* self = (DffPropSet*) this;
     361                 :       1022 :     memset( self->mpFlags, 0, 0x400 * sizeof(DffPropFlags) );
     362                 :       1022 :     self->maRecordTypes.clear();
     363                 :            : 
     364                 :       1022 :     DffPropFlags nFlags = { 1, 0, 0, 1 };
     365                 :            : 
     366                 :            :     //0x01ff0000;
     367         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_LockAgainstGrouping, 0x0000, nFlags, 0xffff0000 );
     368                 :            :     //0x001f0010;
     369         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_FitTextToShape, 0x0010, nFlags, 0xffff0000 );
     370                 :            :     //0xffff0000;
     371         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_gtextFStrikethrough, 0x0000, nFlags, 0xffff0000 );
     372                 :            :     //0x000f0000;
     373         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_pictureActive, 0x0000, nFlags, 0xffff0000 );
     374                 :            :     //0x003f0039;
     375         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_fFillOK, 0x0039, nFlags, 0xffff0000 );
     376                 :            :     //0x001f001c;
     377         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_fNoFillHitTest, 0x001c, nFlags, 0xffff0000 );
     378                 :            :     //0x001f000e;
     379         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_fNoLineDrawDash, 0x001e, nFlags, 0xffff0000 );
     380                 :            :     //0x00030000;
     381         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_fshadowObscured, 0x0000, nFlags, 0xffff0000 );
     382                 :            :     //0x00010000;
     383         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_fPerspective, 0x0000, nFlags, 0xffff0000 );
     384                 :            :     //0x000f0001;
     385         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_fc3DLightFace, 0x0001, nFlags, 0xffff0000 );
     386                 :            :     //0x001f0016;
     387         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_fc3DFillHarsh, 0x0016, nFlags, 0xffff0000 );
     388                 :            :     //0x001f0000;
     389         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_fBackground, 0x0000, nFlags, 0xffff0000 );
     390                 :            :     //0x00ef0010;
     391         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_fCalloutLengthSpecified, 0x0010, nFlags, 0xffff0000 );
     392                 :            :     //0x00ef0001;
     393         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_fPrint, 0x0001, nFlags, 0xffff0000 );
     394                 :            : 
     395         [ +  - ]:       1022 :     InitializeProp( DFF_Prop_fillColor, 0xffffff, nFlags, 0xffff0000 );
     396                 :       1022 : }
     397                 :            : 
     398                 :      15330 : void DffPropSet::InitializeProp(sal_uInt32 nKey, sal_uInt32 nContent, DffPropFlags& rFlags, sal_uInt32 nRecordType ) const
     399                 :            : {
     400                 :      15330 :     DffPropSet* self = (DffPropSet*) this;
     401                 :      15330 :     self->mpContents[ nKey ] = nContent;
     402                 :      15330 :     self->mpFlags[ nKey ] = rFlags;
     403                 :      15330 :     self->maRecordTypes[ nKey ] =  nRecordType;
     404                 :      15330 : }
     405                 :            : 
     406                 :            : 
     407                 :         15 : void DffPropSet::Merge( DffPropSet& rMaster ) const
     408                 :            : {
     409 [ +  - ][ +  - ]:        732 :     for ( RecordTypesMap::const_iterator it = rMaster.maRecordTypes.begin();
         [ +  - ][ +  + ]
     410         [ +  - ]:        366 :           it != rMaster.maRecordTypes.end(); ++it )
     411                 :            :     {
     412         [ +  - ]:        351 :         sal_uInt32 nRecType = it->first;
     413         [ +  + ]:        351 :         if ( ( nRecType & 0x3f ) == 0x3f )      // this is something called FLAGS
     414                 :            :         {
     415                 :        210 :             sal_uInt32 nCurrentFlags = mpContents[ nRecType ];
     416                 :        210 :             sal_uInt32 nMergeFlags = rMaster.mpContents[ nRecType ];
     417                 :        210 :             nMergeFlags &=  ( nMergeFlags >> 16 ) | 0xffff0000;             // clearing low word
     418                 :            :             nMergeFlags &= ( ( nCurrentFlags & 0xffff0000 )                 // remove already hard set
     419                 :        210 :                             | ( nCurrentFlags >> 16 ) ) ^ 0xffffffff;       // attributes from mergeflags
     420                 :            :             nCurrentFlags &= ( ( nMergeFlags & 0xffff0000 )                 // apply zero master bits
     421                 :        210 :                             | ( nMergeFlags >> 16 ) ) ^ 0xffffffff;
     422                 :        210 :             nCurrentFlags |= (sal_uInt16)nMergeFlags;                           // apply filled master bits
     423                 :        210 :             ( (DffPropSet*) this )->mpContents[ nRecType ] = nCurrentFlags;
     424                 :            : 
     425                 :            : 
     426         [ +  - ]:        210 :             sal_uInt32 nNewContentEx = it->second;
     427         [ +  - ]:        210 :             RecordTypesMap::const_iterator it2 = maRecordTypes.find( nRecType );
     428 [ +  - ][ +  - ]:        210 :             if ( it2 != maRecordTypes.end() )
     429         [ +  - ]:        210 :                 nNewContentEx |= it2->second;
     430         [ +  - ]:        210 :             ( (DffPropSet*) this )->maRecordTypes[ nRecType ] = nNewContentEx;
     431                 :            :         }
     432                 :            :         else
     433                 :            :         {
     434 [ +  + ][ +  - ]:        141 :             if ( !IsProperty( nRecType ) || !IsHardAttribute( nRecType ) )
         [ +  + ][ +  + ]
     435                 :            :             {
     436                 :         45 :                 ( (DffPropSet*) this )->mpContents[ nRecType ] = rMaster.mpContents[ nRecType ];
     437                 :         45 :                 DffPropFlags nFlags( rMaster.mpFlags[ nRecType ] );
     438                 :         45 :                 nFlags.bSoftAttr = sal_True;
     439                 :         45 :                 ( (DffPropSet*) this )->mpFlags[ nRecType ] = nFlags;
     440 [ +  - ][ +  - ]:         45 :                 ( (DffPropSet*) this )->maRecordTypes[ nRecType ] = it->second;
     441                 :            :             }
     442                 :            :         }
     443                 :            :     }
     444                 :         15 : }
     445                 :            : 
     446                 :       5848 : sal_Bool DffPropSet::IsHardAttribute( sal_uInt32 nId ) const
     447                 :            : {
     448                 :       5848 :     sal_Bool bRetValue = sal_True;
     449                 :       5848 :     nId &= 0x3ff;
     450         [ +  + ]:       5848 :     if ( ( nId & 0x3f ) >= 48 ) // is this a flag id
     451                 :            :     {
     452         [ +  - ]:       5737 :         RecordTypesMap::const_iterator it = maRecordTypes.find( nId | 0x3f );
     453 [ +  - ][ +  - ]:       5737 :         if ( it != maRecordTypes.end() )
     454                 :            :         {
     455         [ +  - ]:       5737 :             sal_uInt32 nContentEx = it->second;
     456                 :       5737 :             bRetValue = ( nContentEx & ( 1 << ( 0xf - ( nId & 0xf ) ) ) ) != 0;
     457                 :            :         }
     458                 :            :     }
     459                 :            :     else
     460                 :        111 :         bRetValue = ( mpFlags[ nId ].bSoftAttr == 0 );
     461                 :       5848 :     return bRetValue;
     462                 :            : };
     463                 :            : 
     464                 :      31108 : sal_uInt32 DffPropSet::GetPropertyValue( sal_uInt32 nId, sal_uInt32 nDefault ) const
     465                 :            : {
     466                 :      31108 :     nId &= 0x3ff;
     467         [ +  + ]:      31108 :     return ( mpFlags[ nId ].bSet ) ? mpContents[ nId ] : nDefault;
     468                 :            : };
     469                 :            : 
     470                 :        243 : bool DffPropSet::GetPropertyBool( sal_uInt32 nId, bool bDefault ) const
     471                 :            : {
     472                 :        243 :     sal_uInt32 nBaseId = nId | 31;              // base ID to get the sal_uInt32 property value
     473                 :        243 :     sal_uInt32 nMask = 1 << (nBaseId - nId);    // bit mask of the boolean property
     474                 :            : 
     475         [ -  + ]:        243 :     sal_uInt32 nPropValue = GetPropertyValue( nBaseId, bDefault ? nMask : 0 );
     476                 :        243 :     return (nPropValue & nMask) != 0;
     477                 :            : }
     478                 :            : 
     479                 :        838 : ::rtl::OUString DffPropSet::GetPropertyString( sal_uInt32 nId, SvStream& rStrm ) const
     480                 :            : {
     481                 :        838 :     sal_Size nOldPos = rStrm.Tell();
     482                 :        838 :     ::rtl::OUStringBuffer aBuffer;
     483         [ +  - ]:        838 :     sal_uInt32 nBufferSize = GetPropertyValue( nId );
     484 [ +  + ][ +  - ]:        838 :     if( (nBufferSize > 0) && SeekToContent( nId, rStrm ) )
         [ +  - ][ +  + ]
     485                 :            :     {
     486                 :         31 :         sal_Int32 nStrLen = static_cast< sal_Int32 >( nBufferSize / 2 );
     487                 :            :         //clip initial size of buffer to something sane in case of silly length
     488                 :            :         //strings. If there really is a silly amount of data available it still
     489                 :            :         //works out ok of course
     490 [ +  - ][ +  - ]:         31 :         aBuffer.ensureCapacity(std::min(nStrLen,static_cast<sal_Int32>(8192)));
     491         [ +  - ]:        445 :         for( sal_Int32 nCharIdx = 0; nCharIdx < nStrLen; ++nCharIdx )
     492                 :            :         {
     493                 :        414 :             sal_uInt16 nChar = 0;
     494         [ +  - ]:        414 :             rStrm >> nChar;
     495         [ +  + ]:        414 :             if( nChar > 0 )
     496         [ +  - ]:        383 :                 aBuffer.append( static_cast< sal_Unicode >( nChar ) );
     497                 :            :             else
     498                 :            :                 break;
     499                 :            :         }
     500                 :            :     }
     501         [ +  - ]:        838 :     rStrm.Seek( nOldPos );
     502         [ +  - ]:        838 :     return aBuffer.makeStringAndClear();
     503                 :            : }
     504                 :            : 
     505                 :        651 : sal_Bool DffPropSet::SeekToContent( sal_uInt32 nRecType, SvStream& rStrm ) const
     506                 :            : {
     507                 :        651 :     nRecType &= 0x3ff;
     508         [ +  + ]:        651 :     if ( mpFlags[ nRecType ].bSet )
     509                 :            :     {
     510         [ +  - ]:         49 :         if ( mpFlags[ nRecType ].bComplex )
     511                 :            :         {
     512         [ +  - ]:         49 :             RecordTypesMap::const_iterator it = maRecordTypes.find( nRecType );
     513 [ +  - ][ +  - ]:         49 :             if ( it != maRecordTypes.end() )
     514                 :            :             {
     515         [ +  - ]:         49 :                 sal_uInt32 nOffset = it->second;
     516 [ +  - ][ +  - ]:         49 :                 if ( nOffset && ( ( nOffset & 0xffff0000 ) != 0xffff0000 ) )
     517                 :            :                 {
     518         [ +  - ]:         49 :                     rStrm.Seek( nOffset );
     519                 :         49 :                     return sal_True;
     520                 :            :                 }
     521                 :            :             }
     522                 :            :         }
     523                 :            :     }
     524                 :        651 :     return sal_False;
     525                 :            : }
     526                 :            : 
     527                 :         74 : DffPropertyReader::DffPropertyReader( const SvxMSDffManager& rMan ) :
     528                 :            :     rManager( rMan ),
     529                 :         74 :     pDefaultPropSet( NULL )
     530                 :            : {
     531         [ +  - ]:         74 :     InitializePropSet();
     532                 :         74 : }
     533                 :            : 
     534                 :         71 : void DffPropertyReader::SetDefaultPropSet( SvStream& rStCtrl, sal_uInt32 nOffsDgg ) const
     535                 :            : {
     536         [ -  + ]:         71 :     delete pDefaultPropSet;
     537                 :         71 :     sal_uInt32 nMerk = rStCtrl.Tell();
     538         [ +  - ]:         71 :     rStCtrl.Seek( nOffsDgg );
     539                 :         71 :     DffRecordHeader aRecHd;
     540         [ +  - ]:         71 :     rStCtrl >> aRecHd;
     541         [ +  + ]:         71 :     if ( aRecHd.nRecType == DFF_msofbtDggContainer )
     542                 :            :     {
     543 [ +  - ][ +  + ]:         62 :         if ( rManager.SeekToRec( rStCtrl, DFF_msofbtOPT, aRecHd.GetRecEndFilePos() ) )
     544                 :            :         {
     545 [ +  - ][ +  - ]:         32 :             ( (DffPropertyReader*) this )->pDefaultPropSet = new DffPropSet;
     546         [ +  - ]:         32 :             rStCtrl >> *pDefaultPropSet;
     547                 :            :         }
     548                 :            :     }
     549         [ +  - ]:         71 :     rStCtrl.Seek( nMerk );
     550                 :         71 : }
     551                 :            : 
     552                 :            : #ifdef DBG_CUSTOMSHAPE
     553                 :            : void DffPropertyReader::ReadPropSet( SvStream& rIn, void* pClientData, sal_uInt32 nShapeId ) const
     554                 :            : #else
     555                 :        818 : void DffPropertyReader::ReadPropSet( SvStream& rIn, void* pClientData ) const
     556                 :            : #endif
     557                 :            : {
     558                 :        818 :     sal_uLong nFilePos = rIn.Tell();
     559                 :        818 :     rIn >> (DffPropertyReader&)*this;
     560                 :            : 
     561         [ +  + ]:        818 :     if ( IsProperty( DFF_Prop_hspMaster ) )
     562                 :            :     {
     563         [ +  - ]:         15 :         if ( rManager.SeekToShape( rIn, pClientData, GetPropertyValue( DFF_Prop_hspMaster ) ) )
     564                 :            :         {
     565                 :         15 :             DffRecordHeader aRecHd;
     566         [ +  - ]:         15 :             rIn >> aRecHd;
     567 [ +  - ][ +  - ]:         15 :             if ( rManager.SeekToRec( rIn, DFF_msofbtOPT, aRecHd.GetRecEndFilePos() ) )
     568                 :            :             {
     569         [ +  - ]:         15 :                 DffPropSet aMasterPropSet;
     570         [ +  - ]:         15 :                 rIn >> aMasterPropSet;
     571         [ +  - ]:         15 :                 Merge( aMasterPropSet );
     572                 :            :             }
     573                 :            :         }
     574                 :            :     }
     575                 :            : 
     576                 :        818 :     ( (DffPropertyReader*) this )->mnFix16Angle = Fix16ToAngle( GetPropertyValue( DFF_Prop_Rotation, 0 ) );
     577                 :            : 
     578                 :            : #ifdef DBG_CUSTOMSHAPE
     579                 :            : 
     580                 :            :     rtl::OUString aURLStr;
     581                 :            : 
     582                 :            :     if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("d:\\ashape.dbg")), aURLStr ) )
     583                 :            :     {
     584                 :            :         SvStream* pOut = ::utl::UcbStreamHelper::CreateStream( aURLStr, STREAM_WRITE );
     585                 :            : 
     586                 :            :         if( pOut )
     587                 :            :         {
     588                 :            :             pOut->Seek( STREAM_SEEK_TO_END );
     589                 :            : 
     590                 :            :             if ( IsProperty( DFF_Prop_adjustValue ) || IsProperty( DFF_Prop_pVertices ) )
     591                 :            :             {
     592                 :            :                 pOut->WriteLine( "" );
     593                 :            :                 rtl::OStringBuffer aString(RTL_CONSTASCII_STRINGPARAM("ShapeId: "));
     594                 :            :                 aString.append(static_cast<sal_Int32>(nShapeId));
     595                 :            :                 pOut->WriteLine(aString.makeStringAndClear());
     596                 :            :             }
     597                 :            :             for ( sal_uInt32 i = DFF_Prop_adjustValue; i <= DFF_Prop_adjust10Value; i++ )
     598                 :            :             {
     599                 :            :                 if ( IsProperty( i ) )
     600                 :            :                 {
     601                 :            :                     rtl::OStringBuffer aString(RTL_CONSTASCII_STRINGPARAM("Prop_adjustValue"));
     602                 :            :                     aString.append(static_cast<sal_Int32>( ( i - DFF_Prop_adjustValue ) + 1 ) );
     603                 :            :                     aString.append(':');
     604                 :            :                     aString.append(static_cast<sal_Int32>(GetPropertyValue(i)));
     605                 :            :                     pOut->WriteLine(aString.makeStringAndClear());
     606                 :            :                 }
     607                 :            :             }
     608                 :            :             sal_Int32 i;
     609                 :            :             for ( i = 320; i < 383; i++ )
     610                 :            :             {
     611                 :            :                 if ( ( i >= DFF_Prop_adjustValue ) && ( i <= DFF_Prop_adjust10Value ) )
     612                 :            :                     continue;
     613                 :            :                 if ( IsProperty( i ) )
     614                 :            :                 {
     615                 :            :                     if ( SeekToContent( i, rIn ) )
     616                 :            :                     {
     617                 :            :                         sal_Int32 nLen = (sal_Int32)GetPropertyValue( i );
     618                 :            :                         if ( nLen )
     619                 :            :                         {
     620                 :            :                             pOut->WriteLine( "" );
     621                 :            :                             rtl::OStringBuffer aDesc(RTL_CONSTASCII_STRINGPARAM("Property:"));
     622                 :            :                             aDesc.append(static_cast<sal_Int32>(i));
     623                 :            :                             aDesc.append(RTL_CONSTASCII_STRINGPARAM("  Size:"));
     624                 :            :                             aDesc.append(nLen);
     625                 :            :                             pOut->WriteLine(aDesc.makeStringAndClear());
     626                 :            :                             sal_Int16   nNumElem, nNumElemMem, nNumSize;
     627                 :            :                             rIn >> nNumElem >> nNumElemMem >> nNumSize;
     628                 :            :                             aDesc.append(RTL_CONSTASCII_STRINGPARAM("Entries: "));
     629                 :            :                             aDesc.append(static_cast<sal_Int32>(nNumElem));
     630                 :            :                             aDesc.append(RTL_CONSTASCII_STRINGPARAM("  Size:"));
     631                 :            :                             aDesc.append(static_cast<sal_Int32>(nNumSize));
     632                 :            :                             pOut->WriteLine(aDesc.makeStringAndClear());
     633                 :            :                             if ( nNumSize < 0 )
     634                 :            :                                 nNumSize = ( ( -nNumSize ) >> 2 );
     635                 :            :                             if ( !nNumSize )
     636                 :            :                                 nNumSize = 16;
     637                 :            :                             nLen -= 6;
     638                 :            :                             while ( nLen > 0 )
     639                 :            :                             {
     640                 :            :                                 for ( sal_uInt32 j = 0; nLen && ( j < ( nNumSize >> 1 ) ); j++ )
     641                 :            :                                 {
     642                 :            :                                     for ( sal_uInt32 k = 0; k < 2; k++ )
     643                 :            :                                     {
     644                 :            :                                         if ( nLen )
     645                 :            :                                         {
     646                 :            :                                             sal_uInt8 nVal;
     647                 :            :                                             rIn >> nVal;
     648                 :            :                                             if ( ( nVal >> 4 ) > 9 )
     649                 :            :                                                 *pOut << (sal_uInt8)( ( nVal >> 4 ) + 'A' - 10 );
     650                 :            :                                             else
     651                 :            :                                                 *pOut << (sal_uInt8)( ( nVal >> 4 ) + '0' );
     652                 :            : 
     653                 :            :                                             if ( ( nVal & 0xf ) > 9 )
     654                 :            :                                                 *pOut << (sal_uInt8)( ( nVal & 0xf ) + 'A' - 10 );
     655                 :            :                                             else
     656                 :            :                                                 *pOut << (sal_uInt8)( ( nVal & 0xf ) + '0' );
     657                 :            : 
     658                 :            :                                             nLen--;
     659                 :            :                                         }
     660                 :            :                                     }
     661                 :            :                                     *pOut << (char)( ' ' );
     662                 :            :                                 }
     663                 :            :                                 pOut->WriteLine( rtl::OString() );
     664                 :            :                             }
     665                 :            :                         }
     666                 :            :                     }
     667                 :            :                     else
     668                 :            :                     {
     669                 :            :                         rtl::OStringBuffer aString(RTL_CONSTASCII_STRINGPARAM("Property"));
     670                 :            :                         aString.append(static_cast<sal_Int32>(i));
     671                 :            :                         aString.append(':');
     672                 :            :                         aString.append(static_cast<sal_Int32>(GetPropertyValue(i)));
     673                 :            :                         pOut->WriteLine(aString.makeStringAndClear());
     674                 :            :                     }
     675                 :            :                 }
     676                 :            :             }
     677                 :            : 
     678                 :            :             delete pOut;
     679                 :            :         }
     680                 :            :     }
     681                 :            : 
     682                 :            : #endif
     683                 :            : 
     684                 :        818 :     rIn.Seek( nFilePos );
     685                 :        818 : }
     686                 :            : 
     687                 :            : 
     688                 :        839 : sal_Int32 DffPropertyReader::Fix16ToAngle( sal_Int32 nContent ) const
     689                 :            : {
     690                 :        839 :     sal_Int32 nAngle = 0;
     691         [ -  + ]:        839 :     if ( nContent )
     692                 :            :     {
     693                 :          0 :         nAngle = ( (sal_Int16)( nContent >> 16) * 100L ) + ( ( ( nContent & 0x0000ffff) * 100L ) >> 16 );
     694                 :          0 :         nAngle = NormAngle360( -nAngle );
     695                 :            :     }
     696                 :        839 :     return nAngle;
     697                 :            : }
     698                 :            : 
     699                 :         74 : DffPropertyReader::~DffPropertyReader()
     700                 :            : {
     701         [ +  + ]:         74 :     delete pDefaultPropSet;
     702                 :         74 : }
     703                 :            : 
     704                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     705                 :            : 
     706                 :          0 : SvStream& operator>>( SvStream& rIn, SvxMSDffConnectorRule& rRule )
     707                 :            : {
     708                 :          0 :     rIn >> rRule.nRuleId
     709                 :          0 :         >> rRule.nShapeA
     710                 :          0 :         >> rRule.nShapeB
     711                 :          0 :         >> rRule.nShapeC
     712                 :          0 :         >> rRule.ncptiA
     713                 :          0 :         >> rRule.ncptiB;
     714                 :            : 
     715                 :          0 :     return rIn;
     716                 :            : }
     717                 :            : 
     718                 :         62 : SvxMSDffSolverContainer::SvxMSDffSolverContainer()
     719                 :            : {
     720                 :         62 : }
     721                 :            : 
     722                 :         62 : SvxMSDffSolverContainer::~SvxMSDffSolverContainer()
     723                 :            : {
     724         [ -  + ]:         62 :     for( size_t i = 0, n = aCList.size(); i < n; ++i ) {
     725                 :          0 :         delete aCList[ i ];
     726                 :            :     }
     727                 :         62 :     aCList.clear();
     728                 :         62 : }
     729                 :            : 
     730                 :         12 : SvStream& operator>>( SvStream& rIn, SvxMSDffSolverContainer& rContainer )
     731                 :            : {
     732                 :         12 :     DffRecordHeader aHd;
     733         [ +  - ]:         12 :     rIn >> aHd;
     734         [ +  - ]:         12 :     if ( aHd.nRecType == DFF_msofbtSolverContainer )
     735                 :            :     {
     736                 :         12 :         DffRecordHeader aCRule;
     737 [ +  - ][ +  + ]:         27 :         while ( ( rIn.GetError() == 0 ) && ( rIn.Tell() < aHd.GetRecEndFilePos() ) )
                 [ +  + ]
     738                 :            :         {
     739         [ +  - ]:         15 :             rIn >> aCRule;
     740         [ -  + ]:         15 :             if ( aCRule.nRecType == DFF_msofbtConnectorRule )
     741                 :            :             {
     742         [ #  # ]:          0 :                 SvxMSDffConnectorRule* pRule = new SvxMSDffConnectorRule;
     743         [ #  # ]:          0 :                 rIn >> *pRule;
     744         [ #  # ]:          0 :                 rContainer.aCList.push_back( pRule );
     745                 :            :             }
     746         [ +  - ]:         15 :             aCRule.SeekToEndOfRecord( rIn );
     747                 :            :         }
     748                 :            :     }
     749                 :         12 :     return rIn;
     750                 :            : }
     751                 :            : 
     752                 :         62 : void SvxMSDffManager::SolveSolver( const SvxMSDffSolverContainer& rSolver )
     753                 :            : {
     754                 :            :     size_t i, nCnt;
     755         [ -  + ]:         62 :     for ( i = 0, nCnt = rSolver.aCList.size(); i < nCnt; i++ )
     756                 :            :     {
     757                 :          0 :         SvxMSDffConnectorRule* pPtr = rSolver.aCList[ i ];
     758         [ #  # ]:          0 :         if ( pPtr->pCObj )
     759                 :            :         {
     760         [ #  # ]:          0 :             for ( int nN = 0; nN < 2; nN++ )
     761                 :            :             {
     762                 :            :                 SdrObject*  pO;
     763                 :            :                 sal_uInt32  nC, nSpFlags;
     764         [ #  # ]:          0 :                 if ( !nN )
     765                 :            :                 {
     766                 :          0 :                     pO = pPtr->pAObj;
     767                 :          0 :                     nC = pPtr->ncptiA;
     768                 :          0 :                     nSpFlags = pPtr->nSpFlagsA;
     769                 :            :                 }
     770                 :            :                 else
     771                 :            :                 {
     772                 :          0 :                     pO = pPtr->pBObj;
     773                 :          0 :                     nC = pPtr->ncptiB;
     774                 :          0 :                     nSpFlags = pPtr->nSpFlagsB;
     775                 :            :                 }
     776         [ #  # ]:          0 :                 if ( pO )
     777                 :            :                 {
     778                 :          0 :                     Any aAny;
     779                 :          0 :                     SdrGluePoint aGluePoint;
     780 [ #  # ][ #  # ]:          0 :                     Reference< XShape > aXShape( pO->getUnoShape(), UNO_QUERY );
     781 [ #  # ][ #  # ]:          0 :                     Reference< XShape > aXConnector( pPtr->pCObj->getUnoShape(), UNO_QUERY );
     782         [ #  # ]:          0 :                     SdrGluePointList* pList = pO->ForceGluePointList();
     783                 :            : 
     784                 :          0 :                     sal_Bool bValidGluePoint = sal_False;
     785                 :          0 :                     sal_Int32 nId = nC;
     786         [ #  # ]:          0 :                     sal_uInt32 nInventor = pO->GetObjInventor();
     787                 :            : 
     788         [ #  # ]:          0 :                     if( nInventor == SdrInventor )
     789                 :            :                     {
     790         [ #  # ]:          0 :                         sal_uInt32 nObjId = pO->GetObjIdentifier();
     791   [ #  #  #  # ]:          0 :                         switch( nObjId )
     792                 :            :                         {
     793                 :            :                             case OBJ_GRUP :
     794                 :            :                             case OBJ_GRAF :
     795                 :            :                             case OBJ_RECT :
     796                 :            :                             case OBJ_TEXT :
     797                 :            :                             case OBJ_PAGE :
     798                 :            :                             case OBJ_TEXTEXT :
     799                 :            :                             case OBJ_wegFITTEXT :
     800                 :            :                             case OBJ_wegFITALLTEXT :
     801                 :            :                             case OBJ_TITLETEXT :
     802                 :            :                             case OBJ_OUTLINETEXT :
     803                 :            :                             {
     804         [ #  # ]:          0 :                                 if ( nC & 1 )
     805                 :            :                                 {
     806         [ #  # ]:          0 :                                     if ( nSpFlags & SP_FFLIPH )
     807                 :          0 :                                         nC ^= 2;    // 1 <-> 3
     808                 :            :                                 }
     809                 :            :                                 else
     810                 :            :                                 {
     811         [ #  # ]:          0 :                                     if ( nSpFlags & SP_FFLIPV )
     812                 :          0 :                                         nC ^= 1;    // 0 <-> 2
     813                 :            :                                 }
     814   [ #  #  #  #  :          0 :                                 switch( nC )
                      # ]
     815                 :            :                                 {
     816                 :            :                                     case 0 :
     817                 :          0 :                                         nId = 0;    // SDRVERTALIGN_TOP;
     818                 :          0 :                                     break;
     819                 :            :                                     case 1 :
     820                 :          0 :                                         nId = 3;    // SDRHORZALIGN_RIGHT;
     821                 :          0 :                                     break;
     822                 :            :                                     case 2 :
     823                 :          0 :                                         nId = 2;    // SDRVERTALIGN_BOTTOM;
     824                 :          0 :                                     break;
     825                 :            :                                     case 3 :
     826                 :          0 :                                         nId = 1; // SDRHORZALIGN_LEFT;
     827                 :          0 :                                     break;
     828                 :            :                                 }
     829         [ #  # ]:          0 :                                 if ( nId <= 3 )
     830                 :          0 :                                     bValidGluePoint = sal_True;
     831                 :            :                             }
     832                 :          0 :                             break;
     833                 :            :                             case OBJ_POLY :
     834                 :            :                             case OBJ_PLIN :
     835                 :            :                             case OBJ_LINE :
     836                 :            :                             case OBJ_PATHLINE :
     837                 :            :                             case OBJ_PATHFILL :
     838                 :            :                             case OBJ_FREELINE :
     839                 :            :                             case OBJ_FREEFILL :
     840                 :            :                             case OBJ_SPLNLINE :
     841                 :            :                             case OBJ_SPLNFILL :
     842                 :            :                             case OBJ_PATHPOLY :
     843                 :            :                             case OBJ_PATHPLIN :
     844                 :            :                             {
     845 [ #  # ][ #  # ]:          0 :                                 if ( pList && ( pList->GetCount() > nC ) )
                 [ #  # ]
     846                 :            :                                 {
     847                 :          0 :                                     bValidGluePoint = sal_True;
     848         [ #  # ]:          0 :                                     nId = (sal_Int32)((*pList)[ (sal_uInt16)nC].GetId() + 3 );
     849                 :            :                                 }
     850                 :            :                                 else
     851                 :            :                                 {
     852                 :          0 :                                     sal_Bool bNotFound = sal_True;
     853                 :            : 
     854         [ #  # ]:          0 :                                     PolyPolygon aPolyPoly( EscherPropertyContainer::GetPolyPolygon( aXShape ) );
     855         [ #  # ]:          0 :                                     sal_uInt16 k, j, nPolySize = aPolyPoly.Count();
     856         [ #  # ]:          0 :                                     if ( nPolySize )
     857                 :            :                                     {
     858         [ #  # ]:          0 :                                         Rectangle aBoundRect( aPolyPoly.GetBoundRect() );
     859 [ #  # ][ #  # ]:          0 :                                         if ( aBoundRect.GetWidth() && aBoundRect.GetHeight() )
         [ #  # ][ #  # ]
                 [ #  # ]
     860                 :            :                                         {
     861                 :          0 :                                             sal_uInt32  nPointCount = 0;
     862 [ #  # ][ #  # ]:          0 :                                             for ( k = 0; bNotFound && ( k < nPolySize ); k++ )
                 [ #  # ]
     863                 :            :                                             {
     864         [ #  # ]:          0 :                                                 const Polygon& rPolygon = aPolyPoly.GetObject( k );
     865 [ #  # ][ #  # ]:          0 :                                                 for ( j = 0; bNotFound && ( j < rPolygon.GetSize() ); j++ )
         [ #  # ][ #  # ]
     866                 :            :                                                 {
     867         [ #  # ]:          0 :                                                     PolyFlags eFlags = rPolygon.GetFlags( j );
     868         [ #  # ]:          0 :                                                     if ( eFlags == POLY_NORMAL )
     869                 :            :                                                     {
     870         [ #  # ]:          0 :                                                         if ( nC == nPointCount )
     871                 :            :                                                         {
     872         [ #  # ]:          0 :                                                             const Point& rPoint = rPolygon.GetPoint( j );
     873                 :          0 :                                                             double fXRel = rPoint.X() - aBoundRect.Left();
     874                 :          0 :                                                             double fYRel = rPoint.Y() - aBoundRect.Top();
     875         [ #  # ]:          0 :                                                             sal_Int32 nWidth = aBoundRect.GetWidth();
     876         [ #  # ]:          0 :                                                             if ( !nWidth )
     877                 :          0 :                                                                 nWidth = 1;
     878         [ #  # ]:          0 :                                                             sal_Int32 nHeight= aBoundRect.GetHeight();
     879         [ #  # ]:          0 :                                                             if ( !nHeight )
     880                 :          0 :                                                                 nHeight = 1;
     881                 :          0 :                                                             fXRel /= (double)nWidth;
     882                 :          0 :                                                             fXRel *= 10000;
     883                 :          0 :                                                             fYRel /= (double)nHeight;
     884                 :          0 :                                                             fYRel *= 10000;
     885                 :          0 :                                                             aGluePoint.SetPos( Point( (sal_Int32)fXRel, (sal_Int32)fYRel ) );
     886                 :          0 :                                                             aGluePoint.SetPercent( sal_True );
     887                 :          0 :                                                             aGluePoint.SetAlign( SDRVERTALIGN_TOP | SDRHORZALIGN_LEFT );
     888                 :          0 :                                                             aGluePoint.SetEscDir( SDRESC_SMART );
     889 [ #  # ][ #  # ]:          0 :                                                             nId = (sal_Int32)((*pList)[ pList->Insert( aGluePoint ) ].GetId() + 3 );
     890                 :          0 :                                                             bNotFound = sal_False;
     891                 :            :                                                         }
     892                 :          0 :                                                         nPointCount++;
     893                 :            :                                                     }
     894                 :            :                                                 }
     895                 :            :                                             }
     896                 :            :                                         }
     897                 :            :                                     }
     898         [ #  # ]:          0 :                                     if ( !bNotFound )
     899                 :            :                                     {
     900                 :          0 :                                         bValidGluePoint = sal_True;
     901         [ #  # ]:          0 :                                     }
     902                 :            :                                 }
     903                 :            :                             }
     904                 :          0 :                             break;
     905                 :            : 
     906                 :            :                             case OBJ_CUSTOMSHAPE :
     907                 :            :                             {
     908 [ #  # ][ #  # ]:          0 :                                 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)((SdrObjCustomShape*)pO)->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
     909         [ #  # ]:          0 :                                 const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
     910         [ #  # ]:          0 :                                 const rtl::OUString sGluePointType( RTL_CONSTASCII_USTRINGPARAM ( "GluePointType" ) );
     911                 :          0 :                                 sal_Int16 nGluePointType = EnhancedCustomShapeGluePointType::SEGMENTS;
     912         [ #  # ]:          0 :                                 com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sPath, sGluePointType );
     913         [ #  # ]:          0 :                                 if ( pAny )
     914                 :          0 :                                     *pAny >>= nGluePointType;
     915                 :            :                                 else
     916                 :            :                                 {
     917         [ #  # ]:          0 :                                     const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
     918                 :          0 :                                     rtl::OUString sShapeType;
     919         [ #  # ]:          0 :                                     pAny = aGeometryItem.GetPropertyValueByName( sType );
     920         [ #  # ]:          0 :                                     if ( pAny )
     921                 :          0 :                                         *pAny >>= sShapeType;
     922         [ #  # ]:          0 :                                     MSO_SPT eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
     923         [ #  # ]:          0 :                                     nGluePointType = GetCustomShapeConnectionTypeDefault( eSpType );
     924                 :            :                                 }
     925         [ #  # ]:          0 :                                 if ( nGluePointType == EnhancedCustomShapeGluePointType::CUSTOM )
     926                 :            :                                 {
     927 [ #  # ][ #  # ]:          0 :                                     if ( pList && ( pList->GetCount() > nC ) )
                 [ #  # ]
     928                 :            :                                     {
     929                 :          0 :                                         bValidGluePoint = sal_True;
     930         [ #  # ]:          0 :                                         nId = (sal_Int32)((*pList)[ (sal_uInt16)nC].GetId() + 3 );
     931                 :            :                                     }
     932                 :            :                                 }
     933         [ #  # ]:          0 :                                 else if ( nGluePointType == EnhancedCustomShapeGluePointType::RECT )
     934                 :            :                                 {
     935         [ #  # ]:          0 :                                     if ( nC & 1 )
     936                 :            :                                     {
     937         [ #  # ]:          0 :                                         if ( nSpFlags & SP_FFLIPH )
     938                 :          0 :                                             nC ^= 2;    // 1 <-> 3
     939                 :            :                                     }
     940                 :            :                                     else
     941                 :            :                                     {
     942         [ #  # ]:          0 :                                         if ( nSpFlags & SP_FFLIPV )
     943                 :          0 :                                             nC ^= 1;    // 0 <-> 2
     944                 :            :                                     }
     945   [ #  #  #  #  :          0 :                                     switch( nC )
                      # ]
     946                 :            :                                     {
     947                 :            :                                         case 0 :
     948                 :          0 :                                             nId = 0;    // SDRVERTALIGN_TOP;
     949                 :          0 :                                         break;
     950                 :            :                                         case 1 :
     951                 :          0 :                                             nId = 3;    // SDRHORZALIGN_RIGHT;
     952                 :          0 :                                         break;
     953                 :            :                                         case 2 :
     954                 :          0 :                                             nId = 2;    // SDRVERTALIGN_BOTTOM;
     955                 :          0 :                                         break;
     956                 :            :                                         case 3 :
     957                 :          0 :                                             nId = 1; // SDRHORZALIGN_LEFT;
     958                 :          0 :                                         break;
     959                 :            :                                     }
     960         [ #  # ]:          0 :                                     if ( nId <= 3 )
     961                 :          0 :                                         bValidGluePoint = sal_True;
     962                 :            :                                 }
     963         [ #  # ]:          0 :                                 else if ( nGluePointType == EnhancedCustomShapeGluePointType::SEGMENTS )
     964                 :            :                                 {
     965         [ #  # ]:          0 :                                     const rtl::OUString sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
     966         [ #  # ]:          0 :                                     const rtl::OUString sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
     967                 :            : 
     968                 :          0 :                                     sal_uInt32 k, nPt = nC;
     969         [ #  # ]:          0 :                                     com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > aSegments;
     970         [ #  # ]:          0 :                                     pAny = aGeometryItem.GetPropertyValueByName( sPath, sSegments );
     971         [ #  # ]:          0 :                                     if ( pAny )
     972                 :            :                                     {
     973 [ #  # ][ #  # ]:          0 :                                         if ( *pAny >>= aSegments )
     974                 :            :                                         {
     975 [ #  # ][ #  # ]:          0 :                                             for ( nPt = 0, k = 1; nC && ( k < (sal_uInt32)aSegments.getLength() ); k++ )
                 [ #  # ]
     976                 :            :                                             {
     977         [ #  # ]:          0 :                                                 sal_Int16 j, nCnt2 = aSegments[ k ].Count;
     978 [ #  # ][ #  # ]:          0 :                                                 if ( aSegments[ k ].Command != EnhancedCustomShapeSegmentCommand::UNKNOWN )
     979                 :            :                                                 {
     980 [ #  # ][ #  # ]:          0 :                                                     for ( j = 0; nC && ( j < nCnt2 ); j++ )
                 [ #  # ]
     981                 :            :                                                     {
     982 [ #  # ][ #  #  :          0 :                                                         switch( aSegments[ k ].Command )
             #  #  #  # ]
     983                 :            :                                                         {
     984                 :            :                                                             case EnhancedCustomShapeSegmentCommand::ENDSUBPATH :
     985                 :            :                                                             case EnhancedCustomShapeSegmentCommand::CLOSESUBPATH :
     986                 :            :                                                             case EnhancedCustomShapeSegmentCommand::LINETO :
     987                 :            :                                                             case EnhancedCustomShapeSegmentCommand::MOVETO :
     988                 :            :                                                             {
     989                 :          0 :                                                                 nC--;
     990                 :          0 :                                                                 nPt++;
     991                 :            :                                                             }
     992                 :          0 :                                                             break;
     993                 :            :                                                             case EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX :
     994                 :            :                                                             case EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY :
     995                 :          0 :                                                             break;
     996                 :            : 
     997                 :            :                                                             case EnhancedCustomShapeSegmentCommand::CURVETO :
     998                 :            :                                                             {
     999                 :          0 :                                                                 nC--;
    1000                 :          0 :                                                                 nPt += 3;
    1001                 :            :                                                             }
    1002                 :          0 :                                                             break;
    1003                 :            : 
    1004                 :            :                                                             case EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO :
    1005                 :            :                                                             case EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE :
    1006                 :            :                                                             {
    1007                 :          0 :                                                                 nC--;
    1008                 :          0 :                                                                 nPt += 3;
    1009                 :            :                                                             }
    1010                 :          0 :                                                             break;
    1011                 :            :                                                             case EnhancedCustomShapeSegmentCommand::ARCTO :
    1012                 :            :                                                             case EnhancedCustomShapeSegmentCommand::ARC :
    1013                 :            :                                                             case EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO :
    1014                 :            :                                                             case EnhancedCustomShapeSegmentCommand::CLOCKWISEARC :
    1015                 :            :                                                             {
    1016                 :          0 :                                                                 nC--;
    1017                 :          0 :                                                                 nPt += 4;
    1018                 :            :                                                             }
    1019                 :          0 :                                                             break;
    1020                 :            :                                                         }
    1021                 :            :                                                     }
    1022                 :            :                                                 }
    1023                 :            :                                             }
    1024                 :            :                                         }
    1025                 :            :                                     }
    1026         [ #  # ]:          0 :                                     pAny = aGeometryItem.GetPropertyValueByName( sPath, sCoordinates );
    1027         [ #  # ]:          0 :                                     if ( pAny )
    1028                 :            :                                     {
    1029         [ #  # ]:          0 :                                         com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > aCoordinates;
    1030         [ #  # ]:          0 :                                         *pAny >>= aCoordinates;
    1031         [ #  # ]:          0 :                                         if ( nPt < (sal_uInt32)aCoordinates.getLength() )
    1032                 :            :                                         {
    1033                 :          0 :                                             nId = 4;
    1034         [ #  # ]:          0 :                                             com::sun::star::drawing::EnhancedCustomShapeParameterPair& rPara = aCoordinates[ nPt ];
    1035                 :          0 :                                             sal_Int32 nX = 0, nY = 0;
    1036 [ #  # ][ #  # ]:          0 :                                             if ( ( rPara.First.Value >>= nX ) && ( rPara.Second.Value >>= nY ) )
                 [ #  # ]
    1037                 :            :                                             {
    1038         [ #  # ]:          0 :                                                 const rtl::OUString sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
    1039         [ #  # ]:          0 :                                                 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > aGluePoints;
    1040         [ #  # ]:          0 :                                                 pAny = aGeometryItem.GetPropertyValueByName( sPath, sGluePoints );
    1041         [ #  # ]:          0 :                                                 if ( pAny )
    1042         [ #  # ]:          0 :                                                     *pAny >>= aGluePoints;
    1043                 :          0 :                                                 sal_Int32 nGluePoints = aGluePoints.getLength();
    1044         [ #  # ]:          0 :                                                 aGluePoints.realloc( nGluePoints + 1 );
    1045 [ #  # ][ #  # ]:          0 :                                                 EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aGluePoints[ nGluePoints ].First, nX );
    1046 [ #  # ][ #  # ]:          0 :                                                 EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aGluePoints[ nGluePoints ].Second, nY );
    1047                 :          0 :                                                 PropertyValue aProp;
    1048                 :          0 :                                                 aProp.Name = sGluePoints;
    1049         [ #  # ]:          0 :                                                 aProp.Value <<= aGluePoints;
    1050         [ #  # ]:          0 :                                                 aGeometryItem.SetPropertyValue( sPath, aProp );
    1051                 :          0 :                                                 bValidGluePoint = sal_True;
    1052         [ #  # ]:          0 :                                                 ((SdrObjCustomShape*)pO)->SetMergedItem( aGeometryItem );
    1053         [ #  # ]:          0 :                                                 SdrGluePointList* pLst = pO->ForceGluePointList();
    1054         [ #  # ]:          0 :                                                 if ( pLst->GetCount() > nGluePoints )
    1055 [ #  # ][ #  # ]:          0 :                                                     nId = (sal_Int32)((*pLst)[ (sal_uInt16)nGluePoints ].GetId() + 3 );
    1056                 :            :                                             }
    1057         [ #  # ]:          0 :                                         }
    1058         [ #  # ]:          0 :                                     }
    1059         [ #  # ]:          0 :                                 }
    1060                 :            :                             }
    1061                 :          0 :                             break;
    1062                 :            :                         }
    1063         [ #  # ]:          0 :                         if ( bValidGluePoint )
    1064                 :            :                         {
    1065         [ #  # ]:          0 :                             Reference< XPropertySet > xPropSet( aXConnector, UNO_QUERY );
    1066         [ #  # ]:          0 :                             if ( xPropSet.is() )
    1067                 :            :                             {
    1068         [ #  # ]:          0 :                                 if ( nN )
    1069                 :            :                                 {
    1070         [ #  # ]:          0 :                                     rtl::OUString aPropName( RTL_CONSTASCII_USTRINGPARAM( "EndShape" ) );
    1071         [ #  # ]:          0 :                                     aAny <<= aXShape;
    1072 [ #  # ][ #  # ]:          0 :                                     SetPropValue( aAny, xPropSet, aPropName, sal_True );
                 [ #  # ]
    1073         [ #  # ]:          0 :                                     aPropName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EndGluePointIndex" ) );
    1074         [ #  # ]:          0 :                                     aAny <<= nId;
    1075 [ #  # ][ #  # ]:          0 :                                     SetPropValue( aAny, xPropSet, aPropName, sal_True );
                 [ #  # ]
    1076                 :            :                                 }
    1077                 :            :                                 else
    1078                 :            :                                 {
    1079         [ #  # ]:          0 :                                     rtl::OUString aPropName( RTL_CONSTASCII_USTRINGPARAM( "StartShape" ) );
    1080         [ #  # ]:          0 :                                     aAny <<= aXShape;
    1081 [ #  # ][ #  # ]:          0 :                                     SetPropValue( aAny, xPropSet, aPropName, sal_True );
                 [ #  # ]
    1082         [ #  # ]:          0 :                                     aPropName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StartGluePointIndex" ) );
    1083         [ #  # ]:          0 :                                     aAny <<= nId;
    1084 [ #  # ][ #  # ]:          0 :                                     SetPropValue( aAny, xPropSet, aPropName, sal_True );
                 [ #  # ]
    1085                 :            :                                 }
    1086                 :            : 
    1087                 :            :                                 // Not sure what this is good for, repaint or broadcast of object change.
    1088                 :            :                                 //( Thus i am adding repaint here
    1089         [ #  # ]:          0 :                                 pO->SetChanged();
    1090         [ #  # ]:          0 :                                 pO->BroadcastObjectChange();
    1091                 :          0 :                             }
    1092                 :            :                         }
    1093                 :          0 :                     }
    1094                 :            :                 }
    1095                 :            :             }
    1096                 :            :         }
    1097                 :            :     }
    1098                 :         62 : }
    1099                 :            : 
    1100                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
    1101                 :            : 
    1102                 :          3 : static basegfx::B2DPolyPolygon GetLineArrow( const sal_Int32 nLineWidth, const MSO_LineEnd eLineEnd,
    1103                 :            :     const MSO_LineEndWidth eLineWidth, const MSO_LineEndLength eLineLenght,
    1104                 :            :     sal_Int32& rnArrowWidth, sal_Bool& rbArrowCenter,
    1105                 :            :     rtl::OUString& rsArrowName, sal_Bool bScaleArrow )
    1106                 :            : {
    1107         [ +  - ]:          3 :     basegfx::B2DPolyPolygon aRetPolyPoly;
    1108                 :            : 
    1109         [ -  + ]:          3 :     double      fLineWidth = nLineWidth < 70 ? 70.0 : nLineWidth;
    1110                 :            :     double      fLenghtMul, fWidthMul;
    1111                 :            :     sal_Int32   nLineNumber;
    1112      [ +  -  - ]:          3 :     switch( eLineLenght )
    1113                 :            :     {
    1114                 :            :         default :
    1115                 :          3 :         case mso_lineMediumLenArrow     : fLenghtMul = 3.0; nLineNumber = 2; break;
    1116                 :          0 :         case mso_lineShortArrow         : fLenghtMul = 2.0; nLineNumber = 1; break;
    1117                 :          0 :         case mso_lineLongArrow          : fLenghtMul = 5.0; nLineNumber = 3; break;
    1118                 :            :     }
    1119      [ +  -  - ]:          3 :     switch( eLineWidth )
    1120                 :            :     {
    1121                 :            :         default :
    1122                 :          3 :         case mso_lineMediumWidthArrow   : fWidthMul = 3.0; nLineNumber += 3; break;
    1123                 :          0 :         case mso_lineNarrowArrow        : fWidthMul = 2.0; break;
    1124                 :          0 :         case mso_lineWideArrow          : fWidthMul = 5.0; nLineNumber += 6; break;
    1125                 :            :     }
    1126                 :            : 
    1127         [ -  + ]:          3 :     if ( bScaleArrow )  // #i33630 arrows imported from Word are too big
    1128                 :            :     {
    1129                 :          0 :         fWidthMul /= 1.75;
    1130                 :          0 :         fLenghtMul/= 1.75;
    1131                 :            :     }
    1132                 :            : 
    1133                 :          3 :     rbArrowCenter = sal_False;
    1134                 :          3 :     rtl::OUStringBuffer aArrowName;
    1135   [ +  -  -  -  :          3 :     switch ( eLineEnd )
                   -  - ]
    1136                 :            :     {
    1137                 :            :         case mso_lineArrowEnd :
    1138                 :            :         {
    1139         [ +  - ]:          3 :             basegfx::B2DPolygon aTriangle;
    1140         [ +  - ]:          3 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth * 0.50, 0.0 ));
    1141         [ +  - ]:          3 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth, fLenghtMul * fLineWidth ));
    1142         [ +  - ]:          3 :             aTriangle.append(basegfx::B2DPoint( 0.0, fLenghtMul * fLineWidth ));
    1143         [ +  - ]:          3 :             aTriangle.setClosed(true);
    1144 [ +  - ][ +  - ]:          3 :             aRetPolyPoly = basegfx::B2DPolyPolygon(aTriangle);
                 [ +  - ]
    1145 [ +  - ][ +  - ]:          3 :             aArrowName.appendAscii(RTL_CONSTASCII_STRINGPARAM("msArrowEnd "));
    1146                 :            :         }
    1147                 :          3 :         break;
    1148                 :            : 
    1149                 :            :         case mso_lineArrowOpenEnd :
    1150                 :            :         {
    1151      [ #  #  # ]:          0 :             switch( eLineLenght )
    1152                 :            :             {
    1153                 :            :                 default :
    1154                 :          0 :                 case mso_lineMediumLenArrow     : fLenghtMul = 4.5; break;
    1155                 :          0 :                 case mso_lineShortArrow         : fLenghtMul = 3.5; break;
    1156                 :          0 :                 case mso_lineLongArrow          : fLenghtMul = 6.0; break;
    1157                 :            :             }
    1158      [ #  #  # ]:          0 :             switch( eLineWidth )
    1159                 :            :             {
    1160                 :            :                 default :
    1161                 :          0 :                 case mso_lineMediumWidthArrow   : fWidthMul = 4.5; break;
    1162                 :          0 :                 case mso_lineNarrowArrow        : fWidthMul = 3.5; break;
    1163                 :          0 :                 case mso_lineWideArrow          : fWidthMul = 6.0; break;
    1164                 :            :             }
    1165         [ #  # ]:          0 :             basegfx::B2DPolygon aTriangle;
    1166         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth * 0.50 , 0.0 ));
    1167         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth, fLenghtMul * fLineWidth * 0.91 ));
    1168         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth * 0.85, fLenghtMul * fLineWidth ));
    1169         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth * 0.50, fLenghtMul * fLineWidth * 0.36 ));
    1170         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth * 0.15, fLenghtMul * fLineWidth ));
    1171         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( 0.0, fLenghtMul * fLineWidth * 0.91 ));
    1172         [ #  # ]:          0 :             aTriangle.setClosed(true);
    1173 [ #  # ][ #  # ]:          0 :             aRetPolyPoly = basegfx::B2DPolyPolygon(aTriangle);
                 [ #  # ]
    1174 [ #  # ][ #  # ]:          0 :             aArrowName.appendAscii(RTL_CONSTASCII_STRINGPARAM("msArrowOpenEnd "));
    1175                 :            :         }
    1176                 :          0 :         break;
    1177                 :            :         case mso_lineArrowStealthEnd :
    1178                 :            :         {
    1179         [ #  # ]:          0 :             basegfx::B2DPolygon aTriangle;
    1180         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth * 0.50 , 0.0 ));
    1181         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth , fLenghtMul * fLineWidth ));
    1182         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth * 0.50 , fLenghtMul * fLineWidth * 0.60 ));
    1183         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( 0.0, fLenghtMul * fLineWidth ));
    1184         [ #  # ]:          0 :             aTriangle.setClosed(true);
    1185 [ #  # ][ #  # ]:          0 :             aRetPolyPoly = basegfx::B2DPolyPolygon(aTriangle);
                 [ #  # ]
    1186 [ #  # ][ #  # ]:          0 :             aArrowName.appendAscii(RTL_CONSTASCII_STRINGPARAM("msArrowStealthEnd "));
    1187                 :            :         }
    1188                 :          0 :         break;
    1189                 :            :         case mso_lineArrowDiamondEnd :
    1190                 :            :         {
    1191         [ #  # ]:          0 :             basegfx::B2DPolygon aTriangle;
    1192         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth * 0.50 , 0.0 ));
    1193         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth , fLenghtMul * fLineWidth * 0.50 ));
    1194         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( fWidthMul * fLineWidth * 0.50 , fLenghtMul * fLineWidth ));
    1195         [ #  # ]:          0 :             aTriangle.append(basegfx::B2DPoint( 0.0, fLenghtMul * fLineWidth * 0.50 ));
    1196         [ #  # ]:          0 :             aTriangle.setClosed(true);
    1197 [ #  # ][ #  # ]:          0 :             aRetPolyPoly = basegfx::B2DPolyPolygon(aTriangle);
                 [ #  # ]
    1198                 :          0 :             rbArrowCenter = sal_True;
    1199 [ #  # ][ #  # ]:          0 :             aArrowName.appendAscii(RTL_CONSTASCII_STRINGPARAM("msArrowDiamondEnd "));
    1200                 :            :         }
    1201                 :          0 :         break;
    1202                 :            :         case mso_lineArrowOvalEnd :
    1203                 :            :         {
    1204                 :            :             aRetPolyPoly = basegfx::B2DPolyPolygon( XPolygon( Point( (sal_Int32)( fWidthMul * fLineWidth * 0.50 ), 0 ),
    1205                 :            :                                 (sal_Int32)( fWidthMul * fLineWidth * 0.50 ),
    1206 [ #  # ][ #  # ]:          0 :                                     (sal_Int32)( fLenghtMul * fLineWidth * 0.50 ), 0, 3600 ).getB2DPolygon() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1207                 :          0 :             rbArrowCenter = sal_True;
    1208         [ #  # ]:          0 :             aArrowName.appendAscii(RTL_CONSTASCII_STRINGPARAM("msArrowOvalEnd "));
    1209                 :            :         }
    1210                 :          0 :         break;
    1211                 :          0 :         default: break;
    1212                 :            :     }
    1213         [ +  - ]:          3 :     aArrowName.append(nLineNumber);
    1214         [ +  - ]:          3 :     rsArrowName = aArrowName.makeStringAndClear();
    1215                 :          3 :     rnArrowWidth = (sal_Int32)( fLineWidth * fWidthMul );
    1216                 :            : 
    1217                 :          3 :     return aRetPolyPoly;
    1218                 :            : }
    1219                 :            : 
    1220                 :       1064 : void DffPropertyReader::ApplyLineAttributes( SfxItemSet& rSet, const MSO_SPT eShapeType ) const // #i28269#
    1221                 :            : {
    1222                 :       1064 :     sal_uInt32 nLineFlags(GetPropertyValue( DFF_Prop_fNoLineDrawDash ));
    1223                 :            : 
    1224 [ +  + ][ +  + ]:       1064 :     if(!IsHardAttribute( DFF_Prop_fLine ) && !IsCustomShapeStrokedByDefault( eShapeType ))
                 [ +  + ]
    1225                 :            :     {
    1226                 :          9 :         nLineFlags &= ~0x08;
    1227                 :            :     }
    1228                 :            : 
    1229         [ +  + ]:       1064 :     if ( nLineFlags & 8 )
    1230                 :            :     {
    1231                 :            :         // Linienattribute
    1232         [ +  - ]:        342 :         sal_Int32 nLineWidth = (sal_Int32)GetPropertyValue( DFF_Prop_lineWidth, 9525 );
    1233                 :            : 
    1234         [ +  - ]:        342 :         MSO_LineDashing eLineDashing = (MSO_LineDashing)GetPropertyValue( DFF_Prop_lineDashing, mso_lineSolid );
    1235         [ +  - ]:        342 :         if ( eLineDashing == mso_lineSolid )
    1236 [ +  - ][ +  - ]:        342 :             rSet.Put(XLineStyleItem( XLINE_SOLID ) );
                 [ +  - ]
    1237                 :            :         else
    1238                 :            :         {
    1239                 :            : //          MSO_LineCap eLineCap = (MSO_LineCap)GetPropertyValue( DFF_Prop_lineEndCapStyle, mso_lineEndCapSquare );
    1240                 :            : 
    1241                 :          0 :             XDashStyle  eDash = XDASH_RECT;
    1242                 :          0 :             sal_uInt16  nDots = 1;
    1243                 :          0 :             sal_uInt32  nDotLen = nLineWidth / 360;
    1244                 :          0 :             sal_uInt16  nDashes = 0;
    1245                 :          0 :             sal_uInt32  nDashLen = ( 8 * nLineWidth ) / 360;
    1246                 :          0 :             sal_uInt32  nDistance = ( 3 * nLineWidth ) / 360;;
    1247                 :            : 
    1248   [ #  #  #  #  :          0 :             switch ( eLineDashing )
                   #  # ]
    1249                 :            :             {
    1250                 :            :                 default:
    1251                 :            :                 case mso_lineDotSys :
    1252                 :            :                 {
    1253                 :          0 :                     nDots = 1;
    1254                 :          0 :                     nDashes = 0;
    1255                 :          0 :                     nDistance = nDotLen;
    1256                 :            :                 }
    1257                 :          0 :                 break;
    1258                 :            : 
    1259                 :            :                 case mso_lineDashGEL :
    1260                 :            :                 {
    1261                 :          0 :                     nDots = 0;
    1262                 :          0 :                     nDashes = 1;
    1263                 :          0 :                     nDashLen = ( 4 * nLineWidth ) / 360;
    1264                 :            :                 }
    1265                 :          0 :                 break;
    1266                 :            : 
    1267                 :            :                 case mso_lineDashDotGEL :
    1268                 :            :                 {
    1269                 :          0 :                     nDots = 1;
    1270                 :          0 :                     nDashes = 1;
    1271                 :          0 :                     nDashLen = ( 4 * nLineWidth ) / 360;
    1272                 :            :                 }
    1273                 :          0 :                 break;
    1274                 :            : 
    1275                 :            :                 case mso_lineLongDashGEL :
    1276                 :            :                 {
    1277                 :          0 :                     nDots = 0;
    1278                 :          0 :                     nDashes = 1;
    1279                 :            :                 }
    1280                 :          0 :                 break;
    1281                 :            : 
    1282                 :            :                 case mso_lineLongDashDotGEL :
    1283                 :            :                 {
    1284                 :          0 :                     nDots = 1;
    1285                 :          0 :                     nDashes = 1;
    1286                 :            :                 }
    1287                 :          0 :                 break;
    1288                 :            : 
    1289                 :            :                 case mso_lineLongDashDotDotGEL:
    1290                 :            :                 {
    1291                 :          0 :                     nDots = 2;
    1292                 :          0 :                     nDashes = 1;
    1293                 :            :                 }
    1294                 :          0 :                 break;
    1295                 :            :             }
    1296                 :            : 
    1297 [ #  # ][ #  # ]:          0 :             rSet.Put( XLineDashItem( rtl::OUString(), XDash( eDash, nDots, nDotLen, nDashes, nDashLen, nDistance ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1298 [ #  # ][ #  # ]:          0 :             rSet.Put( XLineStyleItem( XLINE_DASH ) );
                 [ #  # ]
    1299                 :            :         }
    1300 [ +  - ][ +  - ]:        342 :         rSet.Put( XLineColorItem( rtl::OUString(), rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_lineColor ), DFF_Prop_lineColor ) ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1301         [ -  + ]:        342 :         if ( IsProperty( DFF_Prop_lineOpacity ) )
    1302                 :            :         {
    1303         [ #  # ]:          0 :             double nTrans = GetPropertyValue(DFF_Prop_lineOpacity, 0x10000);
    1304                 :          0 :             nTrans = (nTrans * 100) / 65536;
    1305                 :            :             rSet.Put(XLineTransparenceItem(
    1306 [ #  # ][ #  # ]:          0 :                 sal_uInt16(100 - ::rtl::math::round(nTrans))));
                 [ #  # ]
    1307                 :            :         }
    1308                 :            : 
    1309         [ +  - ]:        342 :         rManager.ScaleEmu( nLineWidth );
    1310 [ +  - ][ +  - ]:        342 :         rSet.Put( XLineWidthItem( nLineWidth ) );
                 [ +  - ]
    1311                 :            : 
    1312                 :            :         // SJ: LineJoint (setting each time a line is set, because our internal joint type has another default)
    1313                 :        342 :         MSO_LineJoin eLineJointDefault = mso_lineJoinMiter;
    1314         [ +  + ]:        342 :         if ( eShapeType == mso_sptMin )
    1315                 :          3 :             eLineJointDefault = mso_lineJoinRound;
    1316         [ +  - ]:        342 :         MSO_LineJoin eLineJoint = (MSO_LineJoin)GetPropertyValue( DFF_Prop_lineJoinStyle, eLineJointDefault );
    1317                 :        342 :         XLineJoint eXLineJoint( XLINEJOINT_MITER );
    1318         [ -  + ]:        342 :         if ( eLineJoint == mso_lineJoinBevel )
    1319                 :          0 :             eXLineJoint = XLINEJOINT_BEVEL;
    1320         [ +  + ]:        342 :         else if ( eLineJoint == mso_lineJoinRound )
    1321                 :          6 :             eXLineJoint = XLINEJOINT_ROUND;
    1322 [ +  - ][ +  - ]:        342 :         rSet.Put( XLineJointItem( eXLineJoint ) );
                 [ +  - ]
    1323                 :            : 
    1324         [ +  - ]:        342 :         if ( nLineFlags & 0x10 )
    1325                 :            :         {
    1326                 :        342 :             sal_Bool bScaleArrows = rManager.pSdrModel->GetScaleUnit() == MAP_TWIP;
    1327                 :            :             ///////////////
    1328                 :            :             // LineStart //
    1329                 :            :             ///////////////
    1330         [ +  + ]:        342 :             if ( IsProperty( DFF_Prop_lineStartArrowhead ) )
    1331                 :            :             {
    1332         [ +  - ]:          3 :                 MSO_LineEnd         eLineEnd = (MSO_LineEnd)GetPropertyValue( DFF_Prop_lineStartArrowhead );
    1333         [ +  - ]:          3 :                 MSO_LineEndWidth    eWidth = (MSO_LineEndWidth)GetPropertyValue( DFF_Prop_lineStartArrowWidth, mso_lineMediumWidthArrow );
    1334         [ +  - ]:          3 :                 MSO_LineEndLength   eLenght = (MSO_LineEndLength)GetPropertyValue( DFF_Prop_lineStartArrowLength, mso_lineMediumLenArrow );
    1335                 :            : 
    1336                 :            :                 sal_Int32   nArrowWidth;
    1337                 :            :                 sal_Bool    bArrowCenter;
    1338                 :          3 :                 rtl::OUString aArrowName;
    1339         [ +  - ]:          3 :                 basegfx::B2DPolyPolygon aPolyPoly(GetLineArrow( nLineWidth, eLineEnd, eWidth, eLenght, nArrowWidth, bArrowCenter, aArrowName, bScaleArrows ));
    1340                 :            : 
    1341 [ +  - ][ +  - ]:          3 :                 rSet.Put( XLineStartWidthItem( nArrowWidth ) );
                 [ +  - ]
    1342 [ +  - ][ +  - ]:          3 :                 rSet.Put( XLineStartItem( aArrowName, aPolyPoly) );
         [ +  - ][ +  - ]
                 [ +  - ]
    1343 [ +  - ][ +  - ]:          3 :                 rSet.Put( XLineStartCenterItem( bArrowCenter ) );
         [ +  - ][ +  - ]
    1344                 :            :             }
    1345                 :            :             /////////////
    1346                 :            :             // LineEnd //
    1347                 :            :             /////////////
    1348         [ -  + ]:        342 :             if ( IsProperty( DFF_Prop_lineEndArrowhead ) )
    1349                 :            :             {
    1350         [ #  # ]:          0 :                 MSO_LineEnd         eLineEnd = (MSO_LineEnd)GetPropertyValue( DFF_Prop_lineEndArrowhead );
    1351         [ #  # ]:          0 :                 MSO_LineEndWidth    eWidth = (MSO_LineEndWidth)GetPropertyValue( DFF_Prop_lineEndArrowWidth, mso_lineMediumWidthArrow );
    1352         [ #  # ]:          0 :                 MSO_LineEndLength   eLenght = (MSO_LineEndLength)GetPropertyValue( DFF_Prop_lineEndArrowLength, mso_lineMediumLenArrow );
    1353                 :            : 
    1354                 :            :                 sal_Int32   nArrowWidth;
    1355                 :            :                 sal_Bool    bArrowCenter;
    1356                 :          0 :                 rtl::OUString aArrowName;
    1357         [ #  # ]:          0 :                 basegfx::B2DPolyPolygon aPolyPoly(GetLineArrow( nLineWidth, eLineEnd, eWidth, eLenght, nArrowWidth, bArrowCenter, aArrowName, bScaleArrows ));
    1358                 :            : 
    1359 [ #  # ][ #  # ]:          0 :                 rSet.Put( XLineEndWidthItem( nArrowWidth ) );
                 [ #  # ]
    1360 [ #  # ][ #  # ]:          0 :                 rSet.Put( XLineEndItem( aArrowName, aPolyPoly ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1361 [ #  # ][ #  # ]:          0 :                 rSet.Put( XLineEndCenterItem( bArrowCenter ) );
         [ #  # ][ #  # ]
    1362                 :            :             }
    1363         [ +  + ]:        342 :             if ( IsProperty( DFF_Prop_lineEndCapStyle ) )
    1364                 :            :             {
    1365         [ +  - ]:        144 :                 MSO_LineCap eLineCap = (MSO_LineCap)GetPropertyValue( DFF_Prop_lineEndCapStyle );
    1366                 :        144 :                 const SfxPoolItem* pPoolItem = NULL;
    1367 [ +  - ][ -  + ]:        144 :                 if ( rSet.GetItemState( XATTR_LINEDASH, sal_False, &pPoolItem ) == SFX_ITEM_SET )
    1368                 :            :                 {
    1369                 :          0 :                     XDashStyle eNewStyle = XDASH_RECT;
    1370         [ #  # ]:          0 :                     if ( eLineCap == mso_lineEndCapRound )
    1371                 :          0 :                         eNewStyle = XDASH_ROUND;
    1372         [ #  # ]:          0 :                     const XDash& rOldDash = ( (const XLineDashItem*)pPoolItem )->GetDashValue();
    1373         [ #  # ]:          0 :                     if ( rOldDash.GetDashStyle() != eNewStyle )
    1374                 :            :                     {
    1375                 :          0 :                         XDash aNew( rOldDash );
    1376                 :          0 :                         aNew.SetDashStyle( eNewStyle );
    1377 [ #  # ][ #  # ]:        342 :                         rSet.Put( XLineDashItem( rtl::OUString(), aNew ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1378                 :            :                     }
    1379                 :            :                 }
    1380                 :            :             }
    1381                 :            :         }
    1382                 :            :     }
    1383                 :            :     else
    1384         [ +  - ]:        722 :         rSet.Put( XLineStyleItem( XLINE_NONE ) );
    1385                 :       1064 : }
    1386                 :            : 
    1387                 :            : struct ShadeColor
    1388                 :            : {
    1389                 :            :     Color       aColor;
    1390                 :            :     double      fDist;
    1391                 :            : 
    1392                 :       2128 :     ShadeColor( const Color& rC, double fR ) : aColor( rC ), fDist( fR ) {};
    1393                 :            : };
    1394                 :            : 
    1395                 :       1064 : void GetShadeColors( const SvxMSDffManager& rManager, const DffPropertyReader& rProperties, SvStream& rIn, std::vector< ShadeColor >& rShadeColors )
    1396                 :            : {
    1397                 :       1064 :     sal_uInt32 nPos = rIn.Tell();
    1398         [ -  + ]:       1064 :     if ( rProperties.IsProperty( DFF_Prop_fillShadeColors ) )
    1399                 :            :     {
    1400         [ #  # ]:          0 :         if ( rProperties.SeekToContent( DFF_Prop_fillShadeColors, rIn ) )
    1401                 :            :         {
    1402                 :          0 :             sal_uInt16 i = 0, nNumElem = 0, nNumElemReserved = 0, nSize = 0;
    1403 [ #  # ][ #  # ]:          0 :             rIn >> nNumElem >> nNumElemReserved >> nSize;
                 [ #  # ]
    1404         [ #  # ]:          0 :             for ( ; i < nNumElem; i++ )
    1405                 :            :             {
    1406                 :            :                 sal_Int32   nColor;
    1407                 :            :                 sal_Int32   nDist;
    1408                 :            : 
    1409 [ #  # ][ #  # ]:          0 :                 rIn >> nColor >> nDist;
    1410 [ #  # ][ #  # ]:          0 :                 rShadeColors.push_back( ShadeColor( rManager.MSO_CLR_ToColor( nColor, DFF_Prop_fillColor ), 1.0 - ( nDist / 65536.0 ) ) );
    1411                 :            :             }
    1412                 :            :         }
    1413                 :            :     }
    1414         [ +  - ]:       1064 :     if ( rShadeColors.empty() )
    1415                 :            :     {
    1416         [ +  - ]:       1064 :         rShadeColors.push_back( ShadeColor( rManager.MSO_CLR_ToColor( rProperties.GetPropertyValue( DFF_Prop_fillBackColor, COL_WHITE ), DFF_Prop_fillBackColor ), 0 ) );
    1417         [ +  - ]:       1064 :         rShadeColors.push_back( ShadeColor( rManager.MSO_CLR_ToColor( rProperties.GetPropertyValue( DFF_Prop_fillColor, COL_WHITE ), DFF_Prop_fillColor ), 1 ) );
    1418                 :            :     }
    1419                 :       1064 :     rIn.Seek( nPos );
    1420                 :       1064 : }
    1421                 :            : 
    1422                 :            : struct QuantErr
    1423                 :            : {
    1424                 :            :     double  fRed;
    1425                 :            :     double  fGreen;
    1426                 :            :     double  fBlue;
    1427                 :            : 
    1428                 :            :     QuantErr() : fRed( 0.0 ), fGreen( 0.0 ), fBlue( 0.0 ){};
    1429                 :            : };
    1430                 :            : 
    1431                 :          0 : void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, SvStream& rIn, SfxItemSet& rSet, const std::vector< ShadeColor >& rShadeColors, const DffObjData& rObjData, sal_Int32 nFix16Angle )
    1432                 :            : {
    1433         [ #  # ]:          0 :     Size aBitmapSizePixel( static_cast< sal_Int32 >( ( rObjData.aBoundRect.GetWidth() / 2540.0 ) * 90.0 ),      // we will create a bitmap with 90 dpi
    1434         [ #  # ]:          0 :                            static_cast< sal_Int32 >( ( rObjData.aBoundRect.GetHeight() / 2540.0 ) * 90.0 ) );
    1435 [ #  # ][ #  # ]:          0 :     if ( aBitmapSizePixel.Width() && aBitmapSizePixel.Height() && ( aBitmapSizePixel.Width() <= 1024 ) && ( aBitmapSizePixel.Height() <= 1024 ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1436                 :            :     {
    1437         [ #  # ]:          0 :         double fFocusX = rManager.GetPropertyValue( DFF_Prop_fillToRight, 0 ) / 65536.0;
    1438         [ #  # ]:          0 :         double fFocusY = rManager.GetPropertyValue( DFF_Prop_fillToBottom, 0 ) / 65536.0;
    1439                 :            : 
    1440         [ #  # ]:          0 :         Bitmap aBitmap( aBitmapSizePixel, 24 );
    1441         [ #  # ]:          0 :         BitmapWriteAccess* pAcc = aBitmap.AcquireWriteAccess();
    1442         [ #  # ]:          0 :         if ( pAcc )
    1443                 :            :         {
    1444                 :            :             sal_Int32 nX, nY;
    1445         [ #  # ]:          0 :             for ( nY = 0; nY < aBitmapSizePixel.Height(); nY++ )
    1446                 :            :             {
    1447         [ #  # ]:          0 :                 for ( nX = 0; nX < aBitmapSizePixel.Width(); nX++ )
    1448                 :            :                 {
    1449                 :          0 :                     double fX = static_cast< double >( nX ) / aBitmapSizePixel.Width();
    1450                 :          0 :                     double fY = static_cast< double >( nY ) / aBitmapSizePixel.Height();
    1451                 :            : 
    1452                 :            :                     double fD, fDist;
    1453         [ #  # ]:          0 :                     if ( fX < fFocusX )
    1454                 :            :                     {
    1455         [ #  # ]:          0 :                         if ( fY < fFocusY )
    1456                 :            :                         {
    1457         [ #  # ]:          0 :                             if ( fX > fY )
    1458                 :          0 :                                 fDist = fY, fD = fFocusY;
    1459                 :            :                             else
    1460                 :          0 :                                 fDist = fX, fD = fFocusX;
    1461                 :            :                         }
    1462                 :            :                         else
    1463                 :            :                         {
    1464         [ #  # ]:          0 :                             if ( fX > ( 1 - fY ) )
    1465                 :          0 :                                 fDist = ( 1 - fY ), fD = 1 - fFocusY;
    1466                 :            :                             else
    1467                 :          0 :                                 fDist = fX, fD = fFocusX;
    1468                 :            :                         }
    1469                 :            :                     }
    1470                 :            :                     else
    1471                 :            :                     {
    1472         [ #  # ]:          0 :                         if ( fY < fFocusY )
    1473                 :            :                         {
    1474         [ #  # ]:          0 :                             if ( ( 1 - fX ) > fY )
    1475                 :          0 :                                 fDist = fY, fD = fFocusY;
    1476                 :            :                             else
    1477                 :          0 :                                 fDist = ( 1 - fX ), fD = 1 - fFocusX;
    1478                 :            :                         }
    1479                 :            :                         else
    1480                 :            :                         {
    1481         [ #  # ]:          0 :                             if ( ( 1 - fX ) > ( 1 - fY ) )
    1482                 :          0 :                                 fDist = ( 1 - fY ), fD = 1 - fFocusY;
    1483                 :            :                             else
    1484                 :          0 :                                 fDist = ( 1 - fX ), fD = 1 - fFocusX;
    1485                 :            :                         }
    1486                 :            :                     }
    1487         [ #  # ]:          0 :                     if ( fD != 0.0 )
    1488                 :          0 :                         fDist /= fD;
    1489                 :            : 
    1490                 :          0 :                     std::vector< ShadeColor >::const_iterator aIter( rShadeColors.begin() );
    1491                 :          0 :                     double fA = 0.0;
    1492                 :          0 :                     Color aColorA = aIter->aColor;
    1493                 :          0 :                     double fB = 1.0;
    1494                 :          0 :                     Color aColorB( aColorA );
    1495 [ #  # ][ #  # ]:          0 :                     while ( aIter != rShadeColors.end() )
    1496                 :            :                     {
    1497         [ #  # ]:          0 :                         if ( aIter->fDist <= fDist )
    1498                 :            :                         {
    1499         [ #  # ]:          0 :                             if ( aIter->fDist >= fA )
    1500                 :            :                             {
    1501                 :          0 :                                 fA = aIter->fDist;
    1502                 :          0 :                                 aColorA = aIter->aColor;
    1503                 :            :                             }
    1504                 :            :                         }
    1505         [ #  # ]:          0 :                         if ( aIter->fDist > fDist )
    1506                 :            :                         {
    1507         [ #  # ]:          0 :                             if ( aIter->fDist <= fB )
    1508                 :            :                             {
    1509                 :          0 :                                 fB = aIter->fDist;
    1510                 :          0 :                                 aColorB = aIter->aColor;
    1511                 :            :                             }
    1512                 :            :                         }
    1513                 :          0 :                         ++aIter;
    1514                 :            :                     }
    1515                 :          0 :                     double fRed = aColorA.GetRed(), fGreen = aColorA.GetGreen(), fBlue = aColorA.GetBlue();
    1516                 :          0 :                     double fD1 = fB - fA;
    1517         [ #  # ]:          0 :                     if ( fD1 != 0.0 )
    1518                 :            :                     {
    1519                 :          0 :                         fRed   += ( ( ( fDist - fA ) * ( aColorB.GetRed() - aColorA.GetRed() ) ) / fD1 );       // + aQuantErrCurrScan[ nX ].fRed;
    1520                 :          0 :                         fGreen += ( ( ( fDist - fA ) * ( aColorB.GetGreen() - aColorA.GetGreen() ) ) / fD1 );   // + aQuantErrCurrScan[ nX ].fGreen;
    1521                 :          0 :                         fBlue  += ( ( ( fDist - fA ) * ( aColorB.GetBlue() - aColorA.GetBlue() ) ) / fD1 );     // + aQuantErrCurrScan[ nX ].fBlue;
    1522                 :            :                     }
    1523                 :          0 :                     sal_Int16 nRed   = static_cast< sal_Int16 >( fRed   + 0.5 );
    1524                 :          0 :                     sal_Int16 nGreen = static_cast< sal_Int16 >( fGreen + 0.5 );
    1525                 :          0 :                     sal_Int16 nBlue  = static_cast< sal_Int16 >( fBlue  + 0.5 );
    1526         [ #  # ]:          0 :                     if ( nRed < 0 )
    1527                 :          0 :                         nRed = 0;
    1528         [ #  # ]:          0 :                     if ( nRed > 255 )
    1529                 :          0 :                         nRed = 255;
    1530         [ #  # ]:          0 :                     if ( nGreen < 0 )
    1531                 :          0 :                         nGreen = 0;
    1532         [ #  # ]:          0 :                     if ( nGreen > 255 )
    1533                 :          0 :                         nGreen = 255;
    1534         [ #  # ]:          0 :                     if ( nBlue < 0 )
    1535                 :          0 :                         nBlue = 0;
    1536         [ #  # ]:          0 :                     if ( nBlue > 255 )
    1537                 :          0 :                         nBlue = 255;
    1538                 :            : 
    1539         [ #  # ]:          0 :                     pAcc->SetPixel( nY, nX, BitmapColor( static_cast< sal_Int8 >( nRed ), static_cast< sal_Int8 >( nGreen ), static_cast< sal_Int8 >( nBlue ) ) );
    1540                 :            :                 }
    1541                 :            :             }
    1542         [ #  # ]:          0 :             aBitmap.ReleaseAccess( pAcc );
    1543                 :            : 
    1544         [ #  # ]:          0 :             if ( nFix16Angle )
    1545                 :            :             {
    1546                 :          0 :                 sal_Bool bRotateWithShape = sal_True;   // sal_True seems to be default
    1547                 :          0 :                 sal_uInt32 nPos = rIn.Tell();
    1548 [ #  # ][ #  # ]:          0 :                 if ( const_cast< SvxMSDffManager& >( rManager ).maShapeRecords.SeekToContent( rIn, DFF_msofbtUDefProp, SEEK_FROM_CURRENT_AND_RESTART ) )
    1549                 :            :                 {
    1550 [ #  # ][ #  # ]:          0 :                     const_cast< SvxMSDffManager& >( rManager ).maShapeRecords.Current()->SeekToBegOfRecord( rIn );
    1551         [ #  # ]:          0 :                     DffPropertyReader aSecPropSet( rManager );
    1552         [ #  # ]:          0 :                     aSecPropSet.ReadPropSet( rIn, NULL );
    1553         [ #  # ]:          0 :                     sal_Int32 nSecFillProperties = aSecPropSet.GetPropertyValue( DFF_Prop_fNoFillHitTest, 0x200020 );
    1554         [ #  # ]:          0 :                     bRotateWithShape = ( nSecFillProperties & 0x0020 );
    1555                 :            :                 }
    1556         [ #  # ]:          0 :                 rIn.Seek( nPos );
    1557         [ #  # ]:          0 :                 if ( bRotateWithShape )
    1558                 :            :                 {
    1559         [ #  # ]:          0 :                     aBitmap.Rotate( nFix16Angle / 10, rShadeColors[ 0 ].aColor );
    1560                 :            : 
    1561                 :          0 :                     sal_uLong nMirrorFlags = BMP_MIRROR_NONE;
    1562         [ #  # ]:          0 :                     if ( rObjData.nSpFlags & SP_FFLIPV )
    1563                 :          0 :                         nMirrorFlags |= BMP_MIRROR_VERT;
    1564         [ #  # ]:          0 :                     if ( rObjData.nSpFlags & SP_FFLIPH )
    1565                 :          0 :                         nMirrorFlags |= BMP_MIRROR_HORZ;
    1566         [ #  # ]:          0 :                     if ( nMirrorFlags != BMP_MIRROR_NONE )
    1567         [ #  # ]:          0 :                         aBitmap.Mirror( nMirrorFlags );
    1568                 :            :                 }
    1569                 :            :             }
    1570                 :            : 
    1571         [ #  # ]:          0 :             XOBitmap aXBmp( aBitmap, XBITMAP_STRETCH );
    1572 [ #  # ][ #  # ]:          0 :             rSet.Put( XFillBmpTileItem( sal_False ) );
                 [ #  # ]
    1573 [ #  # ][ #  # ]:          0 :             rSet.Put( XFillBitmapItem( rtl::OUString(), aXBmp ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1574         [ #  # ]:          0 :         }
    1575                 :            :     }
    1576                 :          0 : }
    1577                 :            : 
    1578                 :       1064 : void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, const DffObjData& rObjData ) const
    1579                 :            : {
    1580         [ +  - ]:       1064 :     sal_uInt32 nFillFlags(GetPropertyValue( DFF_Prop_fNoFillHitTest ));
    1581                 :            : 
    1582         [ +  - ]:       1064 :     std::vector< ShadeColor > aShadeColors;
    1583         [ +  - ]:       1064 :     GetShadeColors( rManager, *this, rIn, aShadeColors );
    1584                 :            : 
    1585 [ +  - ][ +  + ]:       1064 :     if(!IsHardAttribute( DFF_Prop_fFilled ) && !IsCustomShapeFilledByDefault( rObjData.eShapeType ))
         [ +  - ][ +  + ]
                 [ +  + ]
    1586                 :            :     {
    1587                 :         18 :         nFillFlags &= ~0x10;
    1588                 :            :     }
    1589                 :            : 
    1590         [ +  + ]:       1064 :     if ( nFillFlags & 0x10 )
    1591                 :            :     {
    1592         [ +  - ]:        131 :         MSO_FillType eMSO_FillType = (MSO_FillType)GetPropertyValue( DFF_Prop_fillType, mso_fillSolid );
    1593                 :        131 :         XFillStyle eXFill = XFILL_NONE;
    1594   [ +  -  -  -  :        131 :         switch( eMSO_FillType )
                      - ]
    1595                 :            :         {
    1596                 :            :             case mso_fillSolid :            // Fill with a solid color
    1597                 :        131 :                 eXFill = XFILL_SOLID;
    1598                 :        131 :             break;
    1599                 :            :             case mso_fillPattern :          // Fill with a pattern (bitmap)
    1600                 :            :             case mso_fillTexture :          // A texture (pattern with its own color map)
    1601                 :            :             case mso_fillPicture :          // Center a picture in the shape
    1602                 :          0 :                 eXFill = XFILL_BITMAP;
    1603                 :          0 :             break;
    1604                 :            :             case mso_fillShadeCenter :      // Shade from bounding rectangle to end point
    1605                 :            :             {
    1606 [ #  # ][ #  # ]:          0 :                 if ( rObjData.aBoundRect.IsEmpty() )// size of object needed to be able
    1607                 :          0 :                     eXFill = XFILL_GRADIENT;        // to create a bitmap substitution
    1608                 :            :                 else
    1609                 :          0 :                     eXFill = XFILL_BITMAP;
    1610                 :            :             }
    1611                 :          0 :             break;
    1612                 :            :             case mso_fillShade :            // Shade from start to end points
    1613                 :            :             case mso_fillShadeShape :       // Shade from shape outline to end point
    1614                 :            :             case mso_fillShadeScale :       // Similar to mso_fillShade, but the fillAngle
    1615                 :            :             case mso_fillShadeTitle :       // special type - shade to title ---  for PP
    1616                 :          0 :                 eXFill = XFILL_GRADIENT;
    1617                 :          0 :             break;
    1618                 :            : //          case mso_fillBackground :       // Use the background fill color/pattern
    1619                 :          0 :             default: break;
    1620                 :            :         }
    1621 [ +  - ][ +  - ]:        131 :         rSet.Put( XFillStyleItem( eXFill ) );
                 [ +  - ]
    1622                 :            : 
    1623         [ +  + ]:        131 :         if (IsProperty(DFF_Prop_fillOpacity))
    1624                 :            :         {
    1625         [ +  - ]:          9 :             double nTrans = GetPropertyValue(DFF_Prop_fillOpacity);
    1626                 :          9 :             nTrans = (nTrans * 100) / 65536;
    1627                 :            :             rSet.Put(XFillTransparenceItem(
    1628 [ +  - ][ +  - ]:          9 :                 sal_uInt16(100 - ::rtl::math::round(nTrans))));
                 [ +  - ]
    1629                 :            :         }
    1630                 :            : 
    1631 [ -  + ][ #  # ]:        131 :         if ( ( eMSO_FillType == mso_fillShadeCenter ) && ( eXFill == XFILL_BITMAP ) )
    1632                 :            :         {
    1633         [ #  # ]:          0 :             ApplyRectangularGradientAsBitmap( rManager, rIn, rSet, aShadeColors, rObjData, mnFix16Angle );
    1634                 :            :         }
    1635         [ -  + ]:        131 :         else if ( eXFill == XFILL_GRADIENT )
    1636                 :            :         {
    1637 [ #  # ][ #  # ]:          0 :             sal_Int32 nAngle = 3600 - ( ( Fix16ToAngle( GetPropertyValue( DFF_Prop_fillAngle, 0 ) ) + 5 ) / 10 );
    1638                 :            : 
    1639                 :            :             // force rotation angle to be within a certain range
    1640         [ #  # ]:          0 :             while ( nAngle >= 3600 )
    1641                 :          0 :                 nAngle -= 3600;
    1642         [ #  # ]:          0 :             while ( nAngle < 0 )
    1643                 :          0 :                 nAngle += 3600;
    1644                 :            : 
    1645         [ #  # ]:          0 :             sal_Int32 nFocus = GetPropertyValue( DFF_Prop_fillFocus, 0 );
    1646                 :          0 :             XGradientStyle eGrad = XGRAD_LINEAR;
    1647                 :          0 :             sal_Int32 nChgColors = 0;
    1648                 :            : 
    1649         [ #  # ]:          0 :             if ( nFocus < 0 )       // If the focus is negative the colors need to be swapped
    1650                 :            :             {
    1651                 :          0 :                 nFocus = -nFocus;
    1652                 :          0 :                 nChgColors ^= 1;
    1653                 :            :             }
    1654 [ #  # ][ #  # ]:          0 :             if( nFocus > 40 && nFocus < 60 )
    1655                 :            :             {
    1656                 :          0 :                 eGrad = XGRAD_AXIAL;    // Unfortunately there's no better solution
    1657                 :            :             }
    1658                 :            : 
    1659                 :          0 :             sal_uInt16 nFocusX = (sal_uInt16)nFocus;
    1660                 :          0 :             sal_uInt16 nFocusY = (sal_uInt16)nFocus;
    1661                 :            : 
    1662      [ #  #  # ]:          0 :             switch( eMSO_FillType )
    1663                 :            :             {
    1664                 :            :                 case mso_fillShadeShape :
    1665                 :            :                 {
    1666                 :          0 :                     eGrad = XGRAD_RECT;
    1667                 :          0 :                     nFocusY = nFocusX = 50;
    1668                 :          0 :                     nChgColors ^= 1;
    1669                 :            :                 }
    1670                 :          0 :                 break;
    1671                 :            :                 case mso_fillShadeCenter :
    1672                 :            :                 {
    1673                 :          0 :                     eGrad = XGRAD_RECT;
    1674         [ #  # ]:          0 :                     nFocusX = ( IsProperty( DFF_Prop_fillToRight ) ) ? 100 : 0;
    1675         [ #  # ]:          0 :                     nFocusY = ( IsProperty( DFF_Prop_fillToBottom ) ) ? 100 : 0;
    1676                 :          0 :                     nChgColors ^= 1;
    1677                 :            :                 }
    1678                 :          0 :                 break;
    1679                 :          0 :                 default: break;
    1680                 :            :             }
    1681 [ #  # ][ #  # ]:          0 :             Color aCol1( rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillColor, COL_WHITE ), DFF_Prop_fillColor ) );
    1682 [ #  # ][ #  # ]:          0 :             Color aCol2( rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillBackColor, COL_WHITE ), DFF_Prop_fillBackColor ) );
    1683                 :            : 
    1684         [ #  # ]:          0 :             if ( nChgColors )
    1685                 :            :             {
    1686                 :          0 :                 Color aZwi( aCol1 );
    1687                 :          0 :                 aCol1 = aCol2;
    1688                 :          0 :                 aCol2 = aZwi;
    1689                 :            :             }
    1690         [ #  # ]:          0 :             XGradient aGrad( aCol2, aCol1, eGrad, nAngle, nFocusX, nFocusY );
    1691                 :          0 :             aGrad.SetStartIntens( 100 );
    1692                 :          0 :             aGrad.SetEndIntens( 100 );
    1693 [ #  # ][ #  # ]:          0 :             rSet.Put( XFillGradientItem( rtl::OUString(), aGrad ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1694                 :            :         }
    1695         [ -  + ]:        131 :         else if ( eXFill == XFILL_BITMAP )
    1696                 :            :         {
    1697         [ #  # ]:          0 :             if( IsProperty( DFF_Prop_fillBlip ) )
    1698                 :            :             {
    1699         [ #  # ]:          0 :                 Graphic aGraf;
    1700                 :            :                 // first try to get BLIP from cache
    1701 [ #  # ][ #  # ]:          0 :                 sal_Bool bOK = const_cast<SvxMSDffManager&>(rManager).GetBLIP( GetPropertyValue( DFF_Prop_fillBlip ), aGraf, NULL );
    1702                 :            :                 // then try directly from stream (i.e. Excel chart hatches/bitmaps)
    1703         [ #  # ]:          0 :                 if ( !bOK )
    1704 [ #  # ][ #  # ]:          0 :                     bOK = SeekToContent( DFF_Prop_fillBlip, rIn ) && rManager.GetBLIPDirect( rIn, aGraf, NULL );
         [ #  # ][ #  # ]
    1705         [ #  # ]:          0 :                 if ( bOK )
    1706                 :            :                 {
    1707         [ #  # ]:          0 :                     Bitmap aBmp( aGraf.GetBitmap() );
    1708                 :            : 
    1709         [ #  # ]:          0 :                     if ( eMSO_FillType == mso_fillPattern )
    1710                 :            :                     {
    1711                 :          0 :                         Color aCol1( COL_WHITE ), aCol2( COL_WHITE );
    1712         [ #  # ]:          0 :                         if ( IsProperty( DFF_Prop_fillColor ) )
    1713 [ #  # ][ #  # ]:          0 :                             aCol1 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillColor ), DFF_Prop_fillColor );
    1714         [ #  # ]:          0 :                         if ( IsProperty( DFF_Prop_fillBackColor ) )
    1715 [ #  # ][ #  # ]:          0 :                             aCol2 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillBackColor ), DFF_Prop_fillBackColor );
    1716                 :            : 
    1717         [ #  # ]:          0 :                         XOBitmap aXOBitmap;
    1718         [ #  # ]:          0 :                         aXOBitmap.SetBitmap( aBmp );
    1719                 :          0 :                         aXOBitmap.SetBitmapType( XBITMAP_IMPORT );
    1720                 :            : 
    1721 [ #  # ][ #  # ]:          0 :                         if( aBmp.GetSizePixel().Width() == 8 && aBmp.GetSizePixel().Height() == 8 && aBmp.GetColorCount() == 2)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
                 [ #  # ]
    1722                 :            :                         {
    1723         [ #  # ]:          0 :                             aXOBitmap.Bitmap2Array();
    1724                 :          0 :                             aXOBitmap.SetBitmapType( XBITMAP_8X8 );
    1725         [ #  # ]:          0 :                             aXOBitmap.SetPixelSize( aBmp.GetSizePixel() );
    1726                 :            : 
    1727         [ #  # ]:          0 :                             if( aXOBitmap.GetBackgroundColor() == COL_BLACK )
    1728                 :            :                             {
    1729                 :          0 :                                 aXOBitmap.SetPixelColor( aCol1 );
    1730                 :          0 :                                 aXOBitmap.SetBackgroundColor( aCol2 );
    1731                 :            :                             }
    1732                 :            :                             else
    1733                 :            :                             {
    1734                 :          0 :                                 aXOBitmap.SetPixelColor( aCol2 );
    1735                 :          0 :                                 aXOBitmap.SetBackgroundColor( aCol1 );
    1736                 :            :                             }
    1737         [ #  # ]:          0 :                            aXOBitmap.Array2Bitmap();
    1738                 :            :                         }
    1739 [ #  # ][ #  # ]:          0 :                         rSet.Put( XFillBitmapItem( rtl::OUString(), aXOBitmap ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1740                 :            :                     }
    1741         [ #  # ]:          0 :                     else if ( eMSO_FillType == mso_fillTexture )
    1742                 :            :                     {
    1743         [ #  # ]:          0 :                         XOBitmap aXBmp( aBmp, XBITMAP_STRETCH );
    1744 [ #  # ][ #  # ]:          0 :                         rSet.Put( XFillBmpTileItem( sal_True ) );
                 [ #  # ]
    1745 [ #  # ][ #  # ]:          0 :                         rSet.Put( XFillBitmapItem( rtl::OUString(), aXBmp ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1746 [ #  # ][ #  # ]:          0 :                         rSet.Put( XFillBmpSizeXItem( GetPropertyValue( DFF_Prop_fillWidth, 0 ) / 360 ) );
         [ #  # ][ #  # ]
    1747 [ #  # ][ #  # ]:          0 :                         rSet.Put( XFillBmpSizeYItem( GetPropertyValue( DFF_Prop_fillHeight, 0 ) / 360 ) );
         [ #  # ][ #  # ]
    1748 [ #  # ][ #  # ]:          0 :                         rSet.Put( XFillBmpSizeLogItem( sal_True ) );
         [ #  # ][ #  # ]
    1749                 :            :                     }
    1750                 :            :                     else
    1751                 :            :                     {
    1752         [ #  # ]:          0 :                         XOBitmap aXBmp( aBmp, XBITMAP_STRETCH );
    1753 [ #  # ][ #  # ]:          0 :                         rSet.Put( XFillBitmapItem( rtl::OUString(), aXBmp ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1754 [ #  # ][ #  # ]:          0 :                         rSet.Put( XFillBmpTileItem( sal_False ) );
         [ #  # ][ #  # ]
    1755         [ #  # ]:          0 :                     }
    1756         [ #  # ]:        131 :                 }
    1757                 :            :             }
    1758                 :            :         }
    1759                 :            :     }
    1760                 :            :     else
    1761 [ +  - ][ +  - ]:       1064 :         rSet.Put( XFillStyleItem( XFILL_NONE ) );
                 [ +  - ]
    1762                 :       1064 : }
    1763                 :            : 
    1764                 :       1022 : void DffPropertyReader::ApplyCustomShapeTextAttributes( SfxItemSet& rSet ) const
    1765                 :            : {
    1766                 :       1022 :     sal_Bool  bVerticalText = sal_False;
    1767                 :       1022 :     sal_Int32 nTextLeft = GetPropertyValue( DFF_Prop_dxTextLeft, 25 * 3600 ) / 360;     // 0.25 cm (emu)
    1768                 :       1022 :     sal_Int32 nTextRight = GetPropertyValue( DFF_Prop_dxTextRight, 25 * 3600 ) / 360;   // 0.25 cm (emu)
    1769                 :       1022 :     sal_Int32 nTextTop = GetPropertyValue( DFF_Prop_dyTextTop, 13 * 3600 ) / 360;       // 0.13 cm (emu)
    1770                 :       1022 :     sal_Int32 nTextBottom = GetPropertyValue( DFF_Prop_dyTextBottom, 13 * 3600 ) /360;  // 0.13 cm (emu)
    1771                 :            : 
    1772                 :            :     SdrTextVertAdjust eTVA;
    1773                 :            :     SdrTextHorzAdjust eTHA;
    1774                 :            : 
    1775         [ -  + ]:       1022 :     if ( IsProperty( DFF_Prop_txflTextFlow ) )
    1776                 :            :     {
    1777                 :          0 :         MSO_TextFlow eTextFlow = (MSO_TextFlow)( GetPropertyValue( DFF_Prop_txflTextFlow ) & 0xFFFF );
    1778         [ #  # ]:          0 :         switch( eTextFlow )
    1779                 :            :         {
    1780                 :            :             case mso_txflTtoBA :    /* #68110# */   // Top to Bottom @-font, oben -> unten
    1781                 :            :             case mso_txflTtoBN :                    // Top to Bottom non-@, oben -> unten
    1782                 :            :             case mso_txflVertN :                    // Vertical, non-@, oben -> unten
    1783                 :          0 :                 bVerticalText = sal_True;           // nTextRotationAngle += 27000;
    1784                 :          0 :             break;
    1785                 :          0 :             default: break;
    1786                 :            :         }
    1787                 :            :     }
    1788                 :       1022 :     sal_Int32 nFontDirection = GetPropertyValue( DFF_Prop_cdirFont, mso_cdir0 );
    1789 [ -  + ][ +  - ]:       1022 :     if ( ( nFontDirection == 1 ) || ( nFontDirection == 3 ) )
    1790                 :          0 :         bVerticalText = !bVerticalText;
    1791                 :            : 
    1792         [ -  + ]:       1022 :     if ( bVerticalText )
    1793                 :            :     {
    1794                 :          0 :         eTVA = SDRTEXTVERTADJUST_BLOCK;
    1795                 :          0 :         eTHA = SDRTEXTHORZADJUST_CENTER;
    1796                 :            : 
    1797                 :            :         // read text anchor
    1798                 :          0 :         MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
    1799                 :            : 
    1800   [ #  #  #  # ]:          0 :         switch( eTextAnchor )
    1801                 :            :         {
    1802                 :            :             case mso_anchorTop:
    1803                 :            :             case mso_anchorTopCentered:
    1804                 :            :             case mso_anchorTopBaseline:
    1805                 :            :             case mso_anchorTopCenteredBaseline:
    1806                 :          0 :                 eTHA = SDRTEXTHORZADJUST_RIGHT;
    1807                 :          0 :             break;
    1808                 :            : 
    1809                 :            :             case mso_anchorMiddle :
    1810                 :            :             case mso_anchorMiddleCentered:
    1811                 :          0 :                 eTHA = SDRTEXTHORZADJUST_CENTER;
    1812                 :          0 :             break;
    1813                 :            : 
    1814                 :            :             case mso_anchorBottom:
    1815                 :            :             case mso_anchorBottomCentered:
    1816                 :            :             case mso_anchorBottomBaseline:
    1817                 :            :             case mso_anchorBottomCenteredBaseline:
    1818                 :          0 :                 eTHA = SDRTEXTHORZADJUST_LEFT;
    1819                 :          0 :             break;
    1820                 :            :         }
    1821                 :            :         // if there is a 100% use of following attributes, the textbox can been aligned also in vertical direction
    1822         [ #  # ]:          0 :         switch ( eTextAnchor )
    1823                 :            :         {
    1824                 :            :             case mso_anchorTopCentered :
    1825                 :            :             case mso_anchorMiddleCentered :
    1826                 :            :             case mso_anchorBottomCentered :
    1827                 :            :             case mso_anchorTopCenteredBaseline:
    1828                 :            :             case mso_anchorBottomCenteredBaseline:
    1829                 :          0 :                 eTVA = SDRTEXTVERTADJUST_CENTER;
    1830                 :          0 :             break;
    1831                 :            : 
    1832                 :            :             default :
    1833                 :          0 :                 eTVA = SDRTEXTVERTADJUST_TOP;
    1834                 :          0 :             break;
    1835                 :            :         }
    1836                 :            :     }
    1837                 :            :     else
    1838                 :            :     {
    1839                 :       1022 :         eTVA = SDRTEXTVERTADJUST_CENTER;
    1840                 :       1022 :         eTHA = SDRTEXTHORZADJUST_BLOCK;
    1841                 :            : 
    1842                 :            :         // read text anchor
    1843                 :       1022 :         MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
    1844                 :            : 
    1845   [ +  +  +  - ]:       1022 :         switch( eTextAnchor )
    1846                 :            :         {
    1847                 :            :             case mso_anchorTop:
    1848                 :            :             case mso_anchorTopCentered:
    1849                 :            :             case mso_anchorTopBaseline:
    1850                 :            :             case mso_anchorTopCenteredBaseline:
    1851                 :        887 :                 eTVA = SDRTEXTVERTADJUST_TOP;
    1852                 :        887 :             break;
    1853                 :            : 
    1854                 :            :             case mso_anchorMiddle :
    1855                 :            :             case mso_anchorMiddleCentered:
    1856                 :         90 :                 eTVA = SDRTEXTVERTADJUST_CENTER;
    1857                 :         90 :             break;
    1858                 :            : 
    1859                 :            :             case mso_anchorBottom:
    1860                 :            :             case mso_anchorBottomCentered:
    1861                 :            :             case mso_anchorBottomBaseline:
    1862                 :            :             case mso_anchorBottomCenteredBaseline:
    1863                 :         45 :                 eTVA = SDRTEXTVERTADJUST_BOTTOM;
    1864                 :         45 :             break;
    1865                 :            :         }
    1866                 :            :         // if there is a 100% usage of following attributes, the textbox can be aligned also in horizontal direction
    1867         [ -  + ]:       1022 :         switch ( eTextAnchor )
    1868                 :            :         {
    1869                 :            :             case mso_anchorTopCentered :
    1870                 :            :             case mso_anchorMiddleCentered :
    1871                 :            :             case mso_anchorBottomCentered :
    1872                 :            :             case mso_anchorTopCenteredBaseline:
    1873                 :            :             case mso_anchorBottomCenteredBaseline:
    1874                 :          0 :                 eTHA = SDRTEXTHORZADJUST_CENTER;    // the text has to be displayed using the full width;
    1875                 :          0 :             break;
    1876                 :            : 
    1877                 :            :             default :
    1878                 :       1022 :                 eTHA = SDRTEXTHORZADJUST_LEFT;
    1879                 :       1022 :             break;
    1880                 :            :         }
    1881                 :            :     }
    1882 [ -  + ][ +  - ]:       1022 :     rSet.Put( SvxFrameDirectionItem( bVerticalText ? FRMDIR_VERT_TOP_RIGHT : FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
    1883                 :            : 
    1884         [ +  - ]:       1022 :     rSet.Put( SdrTextVertAdjustItem( eTVA ) );
    1885         [ +  - ]:       1022 :     rSet.Put( SdrTextHorzAdjustItem( eTHA ) );
    1886                 :            : 
    1887         [ +  - ]:       1022 :     rSet.Put( SdrTextLeftDistItem( nTextLeft ) );
    1888         [ +  - ]:       1022 :     rSet.Put( SdrTextRightDistItem( nTextRight ) );
    1889         [ +  - ]:       1022 :     rSet.Put( SdrTextUpperDistItem( nTextTop ) );
    1890         [ +  - ]:       1022 :     rSet.Put( SdrTextLowerDistItem( nTextBottom ) );
    1891                 :            : 
    1892 [ +  - ][ +  + ]:       1022 :     rSet.Put( SdrTextWordWrapItem( (MSO_WrapMode)GetPropertyValue( DFF_Prop_WrapText, mso_wrapSquare ) != mso_wrapNone ? sal_True : sal_False ) );
    1893         [ +  - ]:       1022 :     rSet.Put( SdrTextAutoGrowHeightItem( ( GetPropertyValue( DFF_Prop_FitTextToShape ) & 2 ) != 0 ) );
    1894                 :       1022 : }
    1895                 :            : 
    1896                 :       1022 : void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxItemSet& rSet, const DffObjData& rObjData ) const
    1897                 :            : {
    1898                 :            : 
    1899                 :       1022 :     sal_uInt32 nAdjustmentsWhichNeedsToBeConverted = 0;
    1900                 :            : 
    1901                 :            :     ///////////////////////////////////////
    1902                 :            :     // creating SdrCustomShapeGeometryItem //
    1903                 :            :     ///////////////////////////////////////
    1904                 :            :     typedef uno::Sequence< beans::PropertyValue > PropSeq;
    1905                 :            :     typedef std::vector< beans::PropertyValue > PropVec;
    1906                 :            :     typedef PropVec::iterator PropVecIter;
    1907                 :       1022 :     PropVecIter aIter;
    1908                 :       1022 :     PropVecIter aEnd;
    1909                 :            : 
    1910                 :            : 
    1911                 :            :     // aPropVec will be filled with all PropertyValues
    1912         [ +  - ]:       1022 :     PropVec aPropVec;
    1913                 :       1022 :     PropertyValue aProp;
    1914                 :            : 
    1915                 :            :     /////////////////////////////////////////////////////////////////////
    1916                 :            :     // "Type" property, including the predefined CustomShape type name //
    1917                 :            :     /////////////////////////////////////////////////////////////////////
    1918         [ +  - ]:       1022 :     const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
    1919                 :       1022 :     aProp.Name  = sType;
    1920 [ +  - ][ +  - ]:       1022 :     aProp.Value <<= EnhancedCustomShapeTypeNames::Get( rObjData.eShapeType );
    1921         [ +  - ]:       1022 :     aPropVec.push_back( aProp );
    1922                 :            : 
    1923                 :            :     ///////////////
    1924                 :            :     // "ViewBox" //
    1925                 :            :     ///////////////
    1926                 :            : 
    1927                 :       1022 :     sal_Int32 nCoordWidth = 21600;  // needed to replace handle type center with absolute value
    1928                 :       1022 :     sal_Int32 nCoordHeight= 21600;
    1929 [ +  - ][ +  - ]:       1022 :     if ( IsProperty( DFF_Prop_geoLeft ) || IsProperty( DFF_Prop_geoTop ) || IsProperty( DFF_Prop_geoRight ) || IsProperty( DFF_Prop_geoBottom ) )
         [ +  + ][ -  + ]
                 [ +  + ]
    1930                 :            :     {
    1931                 :          3 :         com::sun::star::awt::Rectangle aViewBox;
    1932         [ +  - ]:          3 :         const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
    1933         [ +  - ]:          3 :         aViewBox.X = GetPropertyValue( DFF_Prop_geoLeft, 0 );
    1934         [ +  - ]:          3 :         aViewBox.Y = GetPropertyValue( DFF_Prop_geoTop, 0 );
    1935         [ +  - ]:          3 :         aViewBox.Width = nCoordWidth = ((sal_Int32)GetPropertyValue( DFF_Prop_geoRight, 21600 ) ) - aViewBox.X;
    1936         [ +  - ]:          3 :         aViewBox.Height = nCoordHeight = ((sal_Int32)GetPropertyValue( DFF_Prop_geoBottom, 21600 ) ) - aViewBox.Y;
    1937                 :          3 :         aProp.Name = sViewBox;
    1938         [ +  - ]:          3 :         aProp.Value <<= aViewBox;
    1939         [ +  - ]:          3 :         aPropVec.push_back( aProp );
    1940                 :            :     }
    1941                 :            :     /////////////////////
    1942                 :            :     // TextRotateAngle //
    1943                 :            :     /////////////////////
    1944 [ +  - ][ -  + ]:       1022 :     if ( IsProperty( DFF_Prop_txflTextFlow ) || IsProperty( DFF_Prop_cdirFont ) )
                 [ -  + ]
    1945                 :            :     {
    1946                 :          0 :         sal_Int32 nTextRotateAngle = 0;
    1947         [ #  # ]:          0 :         MSO_TextFlow eTextFlow = (MSO_TextFlow)( GetPropertyValue( DFF_Prop_txflTextFlow ) & 0xFFFF );
    1948                 :            : 
    1949         [ #  # ]:          0 :         if ( eTextFlow == mso_txflBtoT )    // Bottom to Top non-@
    1950                 :          0 :             nTextRotateAngle += 90;
    1951         [ #  # ]:          0 :         switch( GetPropertyValue( DFF_Prop_cdirFont, mso_cdir0 ) )  // SJ: mso_cdir90 and mso_cdir270 will be simulated by
           [ #  #  #  # ]
    1952                 :            :         {                                                           // activating vertical writing for the text objects
    1953                 :            :             case mso_cdir90 :
    1954                 :            :             {
    1955         [ #  # ]:          0 :                 if ( eTextFlow == mso_txflTtoBA )
    1956                 :          0 :                     nTextRotateAngle -= 180;
    1957                 :            :             }
    1958                 :          0 :             break;
    1959                 :          0 :             case mso_cdir180: nTextRotateAngle -= 180; break;
    1960                 :            :             case mso_cdir270:
    1961                 :            :             {
    1962         [ #  # ]:          0 :                 if ( eTextFlow != mso_txflTtoBA )
    1963                 :          0 :                     nTextRotateAngle -= 180;
    1964                 :            :             }
    1965                 :          0 :             break;
    1966                 :          0 :             default: break;
    1967                 :            :         }
    1968         [ #  # ]:          0 :         if ( nTextRotateAngle )
    1969                 :            :         {
    1970                 :          0 :             double fTextRotateAngle = nTextRotateAngle;
    1971         [ #  # ]:          0 :             const rtl::OUString sTextRotateAngle( RTL_CONSTASCII_USTRINGPARAM ( "TextRotateAngle" ) );
    1972                 :          0 :             aProp.Name = sTextRotateAngle;
    1973         [ #  # ]:          0 :             aProp.Value <<= fTextRotateAngle;
    1974         [ #  # ]:          0 :             aPropVec.push_back( aProp );
    1975                 :            :         }
    1976                 :            :     }
    1977                 :            :     //////////////////////////////////////////
    1978                 :            :     // "Extrusion" PropertySequence element //
    1979                 :            :     //////////////////////////////////////////
    1980         [ +  - ]:       1022 :     sal_Bool bExtrusionOn = ( GetPropertyValue( DFF_Prop_fc3DLightFace ) & 8 ) != 0;
    1981         [ -  + ]:       1022 :     if ( bExtrusionOn )
    1982                 :            :     {
    1983         [ #  # ]:          0 :         PropVec aExtrusionPropVec;
    1984                 :            : 
    1985                 :            :         // "Extrusion"
    1986         [ #  # ]:          0 :         const rtl::OUString sExtrusionOn( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
    1987                 :          0 :         aProp.Name = sExtrusionOn;
    1988         [ #  # ]:          0 :         aProp.Value <<= bExtrusionOn;
    1989         [ #  # ]:          0 :         aExtrusionPropVec.push_back( aProp );
    1990                 :            : 
    1991                 :            :         // "Brightness"
    1992         [ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DAmbientIntensity ) )
    1993                 :            :         {
    1994         [ #  # ]:          0 :             const rtl::OUString sExtrusionBrightness( RTL_CONSTASCII_USTRINGPARAM ( "Brightness" ) );
    1995         [ #  # ]:          0 :             double fBrightness = (sal_Int32)GetPropertyValue( DFF_Prop_c3DAmbientIntensity );
    1996                 :          0 :             fBrightness /= 655.36;
    1997                 :          0 :             aProp.Name = sExtrusionBrightness;
    1998         [ #  # ]:          0 :             aProp.Value <<= fBrightness;
    1999         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2000                 :            :         }
    2001                 :            :         // "Depth" in 1/100mm
    2002 [ #  # ][ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DExtrudeBackward ) || IsProperty( DFF_Prop_c3DExtrudeForward ) )
                 [ #  # ]
    2003                 :            :         {
    2004         [ #  # ]:          0 :             const rtl::OUString sDepth( RTL_CONSTASCII_USTRINGPARAM ( "Depth" ) );
    2005         [ #  # ]:          0 :             double fBackDepth = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DExtrudeBackward, 1270 * 360 )) / 360.0;
    2006         [ #  # ]:          0 :             double fForeDepth = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DExtrudeForward, 0 )) / 360.0;
    2007                 :          0 :             double fDepth = fBackDepth + fForeDepth;
    2008         [ #  # ]:          0 :             double fFraction = fDepth != 0.0 ? fForeDepth / fDepth : 0;
    2009                 :          0 :             EnhancedCustomShapeParameterPair aDepthParaPair;
    2010         [ #  # ]:          0 :             aDepthParaPair.First.Value <<= fDepth;
    2011                 :          0 :             aDepthParaPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
    2012         [ #  # ]:          0 :             aDepthParaPair.Second.Value <<= fFraction;
    2013                 :          0 :             aDepthParaPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
    2014                 :          0 :             aProp.Name = sDepth;
    2015         [ #  # ]:          0 :             aProp.Value <<= aDepthParaPair;
    2016         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2017                 :            :         }
    2018                 :            :         // "Diffusion"
    2019         [ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DDiffuseAmt ) )
    2020                 :            :         {
    2021         [ #  # ]:          0 :             const rtl::OUString sExtrusionDiffusion( RTL_CONSTASCII_USTRINGPARAM ( "Diffusion" ) );
    2022         [ #  # ]:          0 :             double fDiffusion = (sal_Int32)GetPropertyValue( DFF_Prop_c3DDiffuseAmt );
    2023                 :          0 :             fDiffusion /= 655.36;
    2024                 :          0 :             aProp.Name = sExtrusionDiffusion;
    2025         [ #  # ]:          0 :             aProp.Value <<= fDiffusion;
    2026         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2027                 :            :         }
    2028                 :            :         // "NumberOfLineSegments"
    2029         [ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DTolerance ) )
    2030                 :            :         {
    2031         [ #  # ]:          0 :             const rtl::OUString sExtrusionNumberOfLineSegments( RTL_CONSTASCII_USTRINGPARAM ( "NumberOfLineSegments" ) );
    2032                 :          0 :             aProp.Name = sExtrusionNumberOfLineSegments;
    2033 [ #  # ][ #  # ]:          0 :             aProp.Value <<= (sal_Int32)GetPropertyValue( DFF_Prop_c3DTolerance );
    2034         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2035                 :            :         }
    2036                 :            :         // "LightFace"
    2037         [ #  # ]:          0 :         const rtl::OUString sExtrusionLightFace( RTL_CONSTASCII_USTRINGPARAM ( "LightFace" ) );
    2038         [ #  # ]:          0 :         sal_Bool bExtrusionLightFace = ( GetPropertyValue( DFF_Prop_fc3DLightFace ) & 1 ) != 0;
    2039                 :          0 :         aProp.Name = sExtrusionLightFace;
    2040         [ #  # ]:          0 :         aProp.Value <<= bExtrusionLightFace;
    2041         [ #  # ]:          0 :         aExtrusionPropVec.push_back( aProp );
    2042                 :            :         // "FirstLightHarsh"
    2043         [ #  # ]:          0 :         const rtl::OUString sExtrusionFirstLightHarsh( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightHarsh" ) );
    2044         [ #  # ]:          0 :         sal_Bool bExtrusionFirstLightHarsh = ( GetPropertyValue( DFF_Prop_fc3DFillHarsh ) & 2 ) != 0;
    2045                 :          0 :         aProp.Name = sExtrusionFirstLightHarsh;
    2046         [ #  # ]:          0 :         aProp.Value <<= bExtrusionFirstLightHarsh;
    2047         [ #  # ]:          0 :         aExtrusionPropVec.push_back( aProp );
    2048                 :            :         // "SecondLightHarsh"
    2049         [ #  # ]:          0 :         const rtl::OUString sExtrusionSecondLightHarsh( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightHarsh" ) );
    2050         [ #  # ]:          0 :         sal_Bool bExtrusionSecondLightHarsh = ( GetPropertyValue( DFF_Prop_fc3DFillHarsh ) & 1 ) != 0;
    2051                 :          0 :         aProp.Name = sExtrusionSecondLightHarsh;
    2052         [ #  # ]:          0 :         aProp.Value <<= bExtrusionSecondLightHarsh;
    2053         [ #  # ]:          0 :         aExtrusionPropVec.push_back( aProp );
    2054                 :            :         // "FirstLightLevel"
    2055         [ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DKeyIntensity ) )
    2056                 :            :         {
    2057         [ #  # ]:          0 :             const rtl::OUString sExtrusionFirstLightLevel( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightLevel" ) );
    2058         [ #  # ]:          0 :             double fFirstLightLevel = (sal_Int32)GetPropertyValue( DFF_Prop_c3DKeyIntensity );
    2059                 :          0 :             fFirstLightLevel /= 655.36;
    2060                 :          0 :             aProp.Name = sExtrusionFirstLightLevel;
    2061         [ #  # ]:          0 :             aProp.Value <<= fFirstLightLevel;
    2062         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2063                 :            :         }
    2064                 :            :         // "SecondLightLevel"
    2065         [ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DFillIntensity ) )
    2066                 :            :         {
    2067         [ #  # ]:          0 :             const rtl::OUString sExtrusionSecondLightLevel( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightLevel" ) );
    2068         [ #  # ]:          0 :             double fSecondLightLevel = (sal_Int32)GetPropertyValue( DFF_Prop_c3DFillIntensity );
    2069                 :          0 :             fSecondLightLevel /= 655.36;
    2070                 :          0 :             aProp.Name = sExtrusionSecondLightLevel;
    2071         [ #  # ]:          0 :             aProp.Value <<= fSecondLightLevel;
    2072         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2073                 :            :         }
    2074                 :            :         // "FirtstLightDirection"
    2075 [ #  # ][ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DKeyX ) || IsProperty( DFF_Prop_c3DKeyY ) || IsProperty( DFF_Prop_c3DKeyZ ) )
         [ #  # ][ #  # ]
    2076                 :            :         {
    2077         [ #  # ]:          0 :             double fLightX = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DKeyX, 50000 ));
    2078         [ #  # ]:          0 :             double fLightY = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DKeyY, 0 ));
    2079         [ #  # ]:          0 :             double fLightZ = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DKeyZ, 10000 ));
    2080                 :          0 :             ::com::sun::star::drawing::Direction3D aExtrusionFirstLightDirection( fLightX, fLightY, fLightZ );
    2081         [ #  # ]:          0 :             const rtl::OUString sExtrusionFirstLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightDirection" ) );
    2082                 :          0 :             aProp.Name = sExtrusionFirstLightDirection;
    2083         [ #  # ]:          0 :             aProp.Value <<= aExtrusionFirstLightDirection;
    2084         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2085                 :            :         }
    2086                 :            :         // "SecondLightDirection"
    2087 [ #  # ][ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DFillX ) || IsProperty( DFF_Prop_c3DFillY ) || IsProperty( DFF_Prop_c3DFillZ ) )
         [ #  # ][ #  # ]
    2088                 :            :         {
    2089         [ #  # ]:          0 :             double fLight2X = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DFillX, (sal_uInt32)-50000 ));
    2090         [ #  # ]:          0 :             double fLight2Y = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DFillY, 0 ));
    2091         [ #  # ]:          0 :             double fLight2Z = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DFillZ, 10000 ));
    2092                 :          0 :             ::com::sun::star::drawing::Direction3D aExtrusionSecondLightDirection( fLight2X, fLight2Y, fLight2Z );
    2093         [ #  # ]:          0 :             const rtl::OUString sExtrusionSecondLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightDirection" ) );
    2094                 :          0 :             aProp.Name = sExtrusionSecondLightDirection;
    2095         [ #  # ]:          0 :             aProp.Value <<= aExtrusionSecondLightDirection;
    2096         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2097                 :            :         }
    2098                 :            : 
    2099                 :            :         // "Metal"
    2100         [ #  # ]:          0 :         const rtl::OUString sExtrusionMetal( RTL_CONSTASCII_USTRINGPARAM ( "Metal" ) );
    2101         [ #  # ]:          0 :         sal_Bool bExtrusionMetal = ( GetPropertyValue( DFF_Prop_fc3DLightFace ) & 4 ) != 0;
    2102                 :          0 :         aProp.Name = sExtrusionMetal;
    2103         [ #  # ]:          0 :         aProp.Value <<= bExtrusionMetal;
    2104         [ #  # ]:          0 :         aExtrusionPropVec.push_back( aProp );
    2105                 :            :         // "ShadeMode"
    2106         [ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DRenderMode ) )
    2107                 :            :         {
    2108         [ #  # ]:          0 :             const rtl::OUString sExtrusionShadeMode( RTL_CONSTASCII_USTRINGPARAM ( "ShadeMode" ) );
    2109         [ #  # ]:          0 :             sal_uInt32 nExtrusionRenderMode = GetPropertyValue( DFF_Prop_c3DRenderMode );
    2110                 :          0 :             com::sun::star::drawing::ShadeMode eExtrusionShadeMode( com::sun::star::drawing::ShadeMode_FLAT );
    2111         [ #  # ]:          0 :             if ( nExtrusionRenderMode == mso_Wireframe )
    2112                 :          0 :                 eExtrusionShadeMode = com::sun::star::drawing::ShadeMode_DRAFT;
    2113                 :            : 
    2114                 :          0 :             aProp.Name = sExtrusionShadeMode;
    2115         [ #  # ]:          0 :             aProp.Value <<= eExtrusionShadeMode;
    2116         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2117                 :            :         }
    2118                 :            :         // "RotateAngle" in Grad
    2119 [ #  # ][ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DXRotationAngle ) || IsProperty( DFF_Prop_c3DYRotationAngle ) )
                 [ #  # ]
    2120                 :            :         {
    2121         [ #  # ]:          0 :             const rtl::OUString sExtrusionAngle( RTL_CONSTASCII_USTRINGPARAM ( "RotateAngle" ) );
    2122         [ #  # ]:          0 :             double fAngleX = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DXRotationAngle, 0 )) / 65536.0;
    2123         [ #  # ]:          0 :             double fAngleY = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DYRotationAngle, 0 )) / 65536.0;
    2124                 :          0 :             EnhancedCustomShapeParameterPair aRotateAnglePair;
    2125         [ #  # ]:          0 :             aRotateAnglePair.First.Value <<= fAngleX;
    2126                 :          0 :             aRotateAnglePair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
    2127         [ #  # ]:          0 :             aRotateAnglePair.Second.Value <<= fAngleY;
    2128                 :          0 :             aRotateAnglePair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
    2129                 :          0 :             aProp.Name = sExtrusionAngle;
    2130         [ #  # ]:          0 :             aProp.Value <<= aRotateAnglePair;
    2131         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2132                 :            :         }
    2133                 :            : 
    2134                 :            :         // "AutoRotationCenter"
    2135 [ #  # ][ #  # ]:          0 :         if ( ( GetPropertyValue( DFF_Prop_fc3DFillHarsh ) & 8 ) == 0 )
    2136                 :            :         {
    2137                 :            :             // "RotationCenter"
    2138 [ #  # ][ #  # ]:          0 :             if ( IsProperty( DFF_Prop_c3DRotationCenterX ) || IsProperty( DFF_Prop_c3DRotationCenterY ) || IsProperty( DFF_Prop_c3DRotationCenterZ ) )
         [ #  # ][ #  # ]
    2139                 :            :             {
    2140                 :            :                 ::com::sun::star::drawing::Direction3D aRotationCenter(
    2141         [ #  # ]:          0 :                     (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DRotationCenterX, 0 )) / 360.0,
    2142         [ #  # ]:          0 :                     (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DRotationCenterY, 0 )) / 360.0,
    2143         [ #  # ]:          0 :                     (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DRotationCenterZ, 0 )) / 360.0 );
    2144                 :            : 
    2145         [ #  # ]:          0 :                 const rtl::OUString sExtrusionRotationCenter( RTL_CONSTASCII_USTRINGPARAM ( "RotationCenter" ) );
    2146                 :          0 :                 aProp.Name = sExtrusionRotationCenter;
    2147         [ #  # ]:          0 :                 aProp.Value <<= aRotationCenter;
    2148         [ #  # ]:          0 :                 aExtrusionPropVec.push_back( aProp );
    2149                 :            :             }
    2150                 :            :         }
    2151                 :            :         // "Shininess"
    2152         [ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DShininess ) )
    2153                 :            :         {
    2154         [ #  # ]:          0 :             const rtl::OUString sExtrusionShininess( RTL_CONSTASCII_USTRINGPARAM ( "Shininess" ) );
    2155         [ #  # ]:          0 :             double fShininess = (sal_Int32)GetPropertyValue( DFF_Prop_c3DShininess );
    2156                 :          0 :             fShininess /= 655.36;
    2157                 :          0 :             aProp.Name = sExtrusionShininess;
    2158         [ #  # ]:          0 :             aProp.Value <<= fShininess;
    2159         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2160                 :            :         }
    2161                 :            :         // "Skew"
    2162 [ #  # ][ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DSkewAmount ) || IsProperty( DFF_Prop_c3DSkewAngle ) )
                 [ #  # ]
    2163                 :            :         {
    2164         [ #  # ]:          0 :             const rtl::OUString sExtrusionSkew( RTL_CONSTASCII_USTRINGPARAM ( "Skew" ) );
    2165         [ #  # ]:          0 :             double fSkewAmount = (sal_Int32)GetPropertyValue( DFF_Prop_c3DSkewAmount, 50 );
    2166         [ #  # ]:          0 :             double fSkewAngle = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DSkewAngle, sal::static_int_cast< sal_uInt32 >(-135 * 65536) )) / 65536.0;
    2167                 :            : 
    2168                 :          0 :             EnhancedCustomShapeParameterPair aSkewPair;
    2169         [ #  # ]:          0 :             aSkewPair.First.Value <<= fSkewAmount;
    2170                 :          0 :             aSkewPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
    2171         [ #  # ]:          0 :             aSkewPair.Second.Value <<= fSkewAngle;
    2172                 :          0 :             aSkewPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
    2173                 :          0 :             aProp.Name = sExtrusionSkew;
    2174         [ #  # ]:          0 :             aProp.Value <<= aSkewPair;
    2175         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2176                 :            :         }
    2177                 :            :         // "Specularity"
    2178         [ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DSpecularAmt ) )
    2179                 :            :         {
    2180         [ #  # ]:          0 :             const rtl::OUString sExtrusionSpecularity( RTL_CONSTASCII_USTRINGPARAM ( "Specularity" ) );
    2181         [ #  # ]:          0 :             double fSpecularity = (sal_Int32)GetPropertyValue( DFF_Prop_c3DSpecularAmt );
    2182                 :          0 :             fSpecularity /= 1333;
    2183                 :          0 :             aProp.Name = sExtrusionSpecularity;
    2184         [ #  # ]:          0 :             aProp.Value <<= fSpecularity;
    2185         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2186                 :            :         }
    2187                 :            :         // "ProjectionMode"
    2188         [ #  # ]:          0 :         const rtl::OUString sExtrusionProjectionMode( RTL_CONSTASCII_USTRINGPARAM ( "ProjectionMode" ) );
    2189         [ #  # ]:          0 :         ProjectionMode eProjectionMode = GetPropertyValue( DFF_Prop_fc3DFillHarsh ) & 4 ? ProjectionMode_PARALLEL : ProjectionMode_PERSPECTIVE;
    2190                 :          0 :         aProp.Name = sExtrusionProjectionMode;
    2191         [ #  # ]:          0 :         aProp.Value <<= eProjectionMode;
    2192         [ #  # ]:          0 :         aExtrusionPropVec.push_back( aProp );
    2193                 :            : 
    2194                 :            :         // "ViewPoint" in 1/100mm
    2195 [ #  # ][ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DXViewpoint ) || IsProperty( DFF_Prop_c3DYViewpoint ) || IsProperty( DFF_Prop_c3DZViewpoint ) )
         [ #  # ][ #  # ]
    2196                 :            :         {
    2197         [ #  # ]:          0 :             double fViewX = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DXViewpoint, 1249920 )) / 360.0;
    2198         [ #  # ]:          0 :             double fViewY = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DYViewpoint, (sal_uInt32)-1249920 ))/ 360.0;
    2199         [ #  # ]:          0 :             double fViewZ = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DZViewpoint, 9000000 )) / 360.0;
    2200                 :          0 :             ::com::sun::star::drawing::Position3D aExtrusionViewPoint( fViewX, fViewY, fViewZ );
    2201         [ #  # ]:          0 :             const rtl::OUString sExtrusionViewPoint( RTL_CONSTASCII_USTRINGPARAM ( "ViewPoint" ) );
    2202                 :          0 :             aProp.Name = sExtrusionViewPoint;
    2203         [ #  # ]:          0 :             aProp.Value <<= aExtrusionViewPoint;
    2204         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2205                 :            :         }
    2206                 :            :         // "Origin"
    2207 [ #  # ][ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DOriginX ) || IsProperty( DFF_Prop_c3DOriginY ) )
                 [ #  # ]
    2208                 :            :         {
    2209         [ #  # ]:          0 :             const rtl::OUString sExtrusionOrigin( RTL_CONSTASCII_USTRINGPARAM ( "Origin" ) );
    2210         [ #  # ]:          0 :             double fOriginX = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DOriginX, 0 ));
    2211         [ #  # ]:          0 :             double fOriginY = (double)((sal_Int32)GetPropertyValue( DFF_Prop_c3DOriginY, 0 ));
    2212                 :          0 :             fOriginX /= 65536;
    2213                 :          0 :             fOriginY /= 65536;
    2214                 :          0 :             EnhancedCustomShapeParameterPair aOriginPair;
    2215         [ #  # ]:          0 :             aOriginPair.First.Value <<= fOriginX;
    2216                 :          0 :             aOriginPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
    2217         [ #  # ]:          0 :             aOriginPair.Second.Value <<= fOriginY;
    2218                 :          0 :             aOriginPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
    2219                 :          0 :             aProp.Name = sExtrusionOrigin;
    2220         [ #  # ]:          0 :             aProp.Value <<= aOriginPair;
    2221         [ #  # ]:          0 :             aExtrusionPropVec.push_back( aProp );
    2222                 :            :         }
    2223                 :            :         // "ExtrusionColor"
    2224         [ #  # ]:          0 :         const rtl::OUString sExtrusionColor( RTL_CONSTASCII_USTRINGPARAM ( "Color" ) );
    2225                 :          0 :         sal_Bool bExtrusionColor = IsProperty( DFF_Prop_c3DExtrusionColor );    // ( GetPropertyValue( DFF_Prop_fc3DLightFace ) & 2 ) != 0;
    2226                 :          0 :         aProp.Name = sExtrusionColor;
    2227         [ #  # ]:          0 :         aProp.Value <<= bExtrusionColor;
    2228         [ #  # ]:          0 :         aExtrusionPropVec.push_back( aProp );
    2229         [ #  # ]:          0 :         if ( IsProperty( DFF_Prop_c3DExtrusionColor ) )
    2230                 :            :             rSet.Put( XSecondaryFillColorItem( String(), rManager.MSO_CLR_ToColor(
    2231 [ #  # ][ #  # ]:          0 :                 GetPropertyValue( DFF_Prop_c3DExtrusionColor ), DFF_Prop_c3DExtrusionColor ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2232                 :            :         // pushing the whole Extrusion element
    2233         [ #  # ]:          0 :         const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
    2234         [ #  # ]:          0 :         PropSeq aExtrusionPropSeq( aExtrusionPropVec.size() );
    2235                 :          0 :         aIter = aExtrusionPropVec.begin();
    2236                 :          0 :         aEnd = aExtrusionPropVec.end();
    2237         [ #  # ]:          0 :         beans::PropertyValue* pExtrusionValues = aExtrusionPropSeq.getArray();
    2238 [ #  # ][ #  # ]:          0 :         while ( aIter != aEnd )
    2239         [ #  # ]:          0 :             *pExtrusionValues++ = *aIter++;
    2240                 :          0 :         aProp.Name = sExtrusion;
    2241         [ #  # ]:          0 :         aProp.Value <<= aExtrusionPropSeq;
    2242 [ #  # ][ #  # ]:          0 :         aPropVec.push_back( aProp );
    2243                 :            :     }
    2244                 :            : 
    2245                 :            :     /////////////////////////////////////////
    2246                 :            :     // "Equations" PropertySequence element //
    2247                 :            :     /////////////////////////////////////////
    2248         [ -  + ]:       1022 :     if ( IsProperty( DFF_Prop_pFormulas ) )
    2249                 :            :     {
    2250                 :          0 :         sal_uInt16 nNumElem = 0;
    2251                 :            : 
    2252 [ #  # ][ #  # ]:          0 :         if ( SeekToContent( DFF_Prop_pFormulas, rIn ) )
    2253                 :            :         {
    2254                 :          0 :             sal_uInt16 nNumElemMem = 0;
    2255                 :          0 :             sal_uInt16 nElemSize = 8;
    2256 [ #  # ][ #  # ]:          0 :             rIn >> nNumElem >> nNumElemMem >> nElemSize;
                 [ #  # ]
    2257                 :            :         }
    2258                 :            :         sal_Int16 nP1, nP2, nP3;
    2259                 :            :         sal_uInt16 nFlags;
    2260                 :            : 
    2261         [ #  # ]:          0 :         uno::Sequence< rtl::OUString > aEquations( nNumElem );
    2262         [ #  # ]:          0 :         for ( sal_uInt16 i = 0; i < nNumElem; i++ )
    2263                 :            :         {
    2264 [ #  # ][ #  # ]:          0 :             rIn >> nFlags >> nP1 >> nP2 >> nP3;
         [ #  # ][ #  # ]
    2265 [ #  # ][ #  # ]:          0 :             aEquations[ i ] = EnhancedCustomShape2d::GetEquation( nFlags, nP1, nP2, nP3 );
    2266                 :            :         }
    2267                 :            :         // pushing the whole Equations element
    2268         [ #  # ]:          0 :         const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM ( "Equations" ) );
    2269                 :          0 :         aProp.Name = sEquations;
    2270         [ #  # ]:          0 :         aProp.Value <<= aEquations;
    2271 [ #  # ][ #  # ]:          0 :         aPropVec.push_back( aProp );
    2272                 :            :     }
    2273                 :            : 
    2274                 :            :     ////////////////////////////////////////
    2275                 :            :     // "Handles" PropertySequence element //
    2276                 :            :     ////////////////////////////////////////
    2277         [ -  + ]:       1022 :     if ( IsProperty( DFF_Prop_Handles ) )
    2278                 :            :     {
    2279                 :          0 :         sal_uInt16 nNumElem = 0;
    2280                 :          0 :         sal_uInt16 nElemSize = 36;
    2281                 :            : 
    2282 [ #  # ][ #  # ]:          0 :         if ( SeekToContent( DFF_Prop_Handles, rIn ) )
    2283                 :            :         {
    2284                 :          0 :             sal_uInt16 nNumElemMem = 0;
    2285 [ #  # ][ #  # ]:          0 :             rIn >> nNumElem >> nNumElemMem >> nElemSize;
                 [ #  # ]
    2286                 :            :         }
    2287         [ #  # ]:          0 :         if ( nElemSize == 36 )
    2288                 :            :         {
    2289         [ #  # ]:          0 :             uno::Sequence< beans::PropertyValues > aHandles( nNumElem );
    2290         [ #  # ]:          0 :             for ( sal_uInt16 i = 0; i < nNumElem; i++ )
    2291                 :            :             {
    2292         [ #  # ]:          0 :                 PropVec aHandlePropVec;
    2293                 :            :                 sal_uInt32  nFlags;
    2294                 :            :                 sal_Int32   nPositionX, nPositionY, nCenterX, nCenterY, nRangeXMin, nRangeXMax, nRangeYMin, nRangeYMax;
    2295         [ #  # ]:          0 :                 rIn >> nFlags
    2296         [ #  # ]:          0 :                     >> nPositionX
    2297         [ #  # ]:          0 :                     >> nPositionY
    2298         [ #  # ]:          0 :                     >> nCenterX
    2299         [ #  # ]:          0 :                     >> nCenterY
    2300         [ #  # ]:          0 :                     >> nRangeXMin
    2301         [ #  # ]:          0 :                     >> nRangeXMax
    2302         [ #  # ]:          0 :                     >> nRangeYMin
    2303         [ #  # ]:          0 :                     >> nRangeYMax;
    2304                 :            : 
    2305         [ #  # ]:          0 :                 if ( nPositionX == 2 )  // replacing center position with absolute value
    2306                 :          0 :                     nPositionX = nCoordWidth / 2;
    2307         [ #  # ]:          0 :                 if ( nPositionY == 2 )
    2308                 :          0 :                     nPositionY = nCoordHeight / 2;
    2309                 :          0 :                 EnhancedCustomShapeParameterPair aPosition;
    2310         [ #  # ]:          0 :                 EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.First,  nPositionX, sal_True, sal_True  );
    2311         [ #  # ]:          0 :                 EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.Second, nPositionY, sal_True, sal_False );
    2312         [ #  # ]:          0 :                 const rtl::OUString sHandlePosition( RTL_CONSTASCII_USTRINGPARAM ( "Position" ) );
    2313                 :          0 :                 aProp.Name = sHandlePosition;
    2314         [ #  # ]:          0 :                 aProp.Value <<= aPosition;
    2315         [ #  # ]:          0 :                 aHandlePropVec.push_back( aProp );
    2316                 :            : 
    2317         [ #  # ]:          0 :                 if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
    2318                 :            :                 {
    2319                 :          0 :                     sal_Bool bMirroredX = sal_True;
    2320         [ #  # ]:          0 :                     const rtl::OUString sHandleMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
    2321                 :          0 :                     aProp.Name = sHandleMirroredX;
    2322         [ #  # ]:          0 :                     aProp.Value <<= bMirroredX;
    2323         [ #  # ]:          0 :                     aHandlePropVec.push_back( aProp );
    2324                 :            :                 }
    2325         [ #  # ]:          0 :                 if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
    2326                 :            :                 {
    2327                 :          0 :                     sal_Bool bMirroredY = sal_True;
    2328         [ #  # ]:          0 :                     const rtl::OUString sHandleMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
    2329                 :          0 :                     aProp.Name = sHandleMirroredY;
    2330         [ #  # ]:          0 :                     aProp.Value <<= bMirroredY;
    2331         [ #  # ]:          0 :                     aHandlePropVec.push_back( aProp );
    2332                 :            :                 }
    2333         [ #  # ]:          0 :                 if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
    2334                 :            :                 {
    2335                 :          0 :                     sal_Bool bSwitched = sal_True;
    2336         [ #  # ]:          0 :                     const rtl::OUString sHandleSwitched( RTL_CONSTASCII_USTRINGPARAM ( "Switched" ) );
    2337                 :          0 :                     aProp.Name = sHandleSwitched;
    2338         [ #  # ]:          0 :                     aProp.Value <<= bSwitched;
    2339         [ #  # ]:          0 :                     aHandlePropVec.push_back( aProp );
    2340                 :            :                 }
    2341         [ #  # ]:          0 :                 if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
    2342                 :            :                 {
    2343         [ #  # ]:          0 :                     if ( nCenterX == 2 )
    2344                 :          0 :                         nCenterX = nCoordWidth / 2;
    2345         [ #  # ]:          0 :                     if ( nCenterY == 2 )
    2346                 :          0 :                         nCenterY = nCoordHeight / 2;
    2347 [ #  # ][ #  # ]:          0 :                     if ( ( nPositionY >= 0x256 ) || ( nPositionY <= 0x107 ) )   // position y
    2348                 :          0 :                         nAdjustmentsWhichNeedsToBeConverted |= ( 1 << i );
    2349                 :          0 :                     EnhancedCustomShapeParameterPair aPolar;
    2350         [ #  # ]:          0 :                     EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPolar.First,  nCenterX, ( nFlags & 0x800  ) != 0, sal_True  );
    2351         [ #  # ]:          0 :                     EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPolar.Second, nCenterY, ( nFlags & 0x1000 ) != 0, sal_False );
    2352         [ #  # ]:          0 :                     const rtl::OUString sHandlePolar( RTL_CONSTASCII_USTRINGPARAM ( "Polar" ) );
    2353                 :          0 :                     aProp.Name = sHandlePolar;
    2354         [ #  # ]:          0 :                     aProp.Value <<= aPolar;
    2355         [ #  # ]:          0 :                     aHandlePropVec.push_back( aProp );
    2356                 :            :                 }
    2357         [ #  # ]:          0 :                 if ( nFlags & MSDFF_HANDLE_FLAGS_MAP )
    2358                 :            :                 {
    2359         [ #  # ]:          0 :                     if ( nCenterX == 2 )
    2360                 :          0 :                         nCenterX = nCoordWidth / 2;
    2361         [ #  # ]:          0 :                     if ( nCenterY == 2 )
    2362                 :          0 :                         nCenterY = nCoordHeight / 2;
    2363                 :          0 :                     EnhancedCustomShapeParameterPair aMap;
    2364         [ #  # ]:          0 :                     EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aMap.First,  nCenterX, ( nFlags & 0x800  ) != 0, sal_True  );
    2365         [ #  # ]:          0 :                     EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aMap.Second, nCenterY, ( nFlags & 0x1000 ) != 0, sal_False );
    2366         [ #  # ]:          0 :                     const rtl::OUString sHandleMap( RTL_CONSTASCII_USTRINGPARAM ( "Map" ) );
    2367                 :          0 :                     aProp.Name = sHandleMap;
    2368         [ #  # ]:          0 :                     aProp.Value <<= aMap;
    2369         [ #  # ]:          0 :                     aHandlePropVec.push_back( aProp );
    2370                 :            :                 }
    2371         [ #  # ]:          0 :                 if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
    2372                 :            :                 {
    2373         [ #  # ]:          0 :                     if ( (sal_uInt32)nRangeXMin != 0x80000000 )
    2374                 :            :                     {
    2375         [ #  # ]:          0 :                         if ( nRangeXMin == 2 )
    2376                 :          0 :                             nRangeXMin = nCoordWidth / 2;
    2377                 :          0 :                         EnhancedCustomShapeParameter aRangeXMinimum;
    2378                 :            :                         EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMinimum,  nRangeXMin,
    2379         [ #  # ]:          0 :                             ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True  );
    2380         [ #  # ]:          0 :                         const rtl::OUString sHandleRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMinimum" ) );
    2381                 :          0 :                         aProp.Name = sHandleRangeXMinimum;
    2382         [ #  # ]:          0 :                         aProp.Value <<= aRangeXMinimum;
    2383         [ #  # ]:          0 :                         aHandlePropVec.push_back( aProp );
    2384                 :            :                     }
    2385         [ #  # ]:          0 :                     if ( (sal_uInt32)nRangeXMax != 0x7fffffff )
    2386                 :            :                     {
    2387         [ #  # ]:          0 :                         if ( nRangeXMax == 2 )
    2388                 :          0 :                             nRangeXMax = nCoordWidth / 2;
    2389                 :          0 :                         EnhancedCustomShapeParameter aRangeXMaximum;
    2390                 :            :                         EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMaximum, nRangeXMax,
    2391         [ #  # ]:          0 :                             ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
    2392         [ #  # ]:          0 :                         const rtl::OUString sHandleRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMaximum" ) );
    2393                 :          0 :                         aProp.Name = sHandleRangeXMaximum;
    2394         [ #  # ]:          0 :                         aProp.Value <<= aRangeXMaximum;
    2395         [ #  # ]:          0 :                         aHandlePropVec.push_back( aProp );
    2396                 :            :                     }
    2397         [ #  # ]:          0 :                     if ( (sal_uInt32)nRangeYMin != 0x80000000 )
    2398                 :            :                     {
    2399         [ #  # ]:          0 :                         if ( nRangeYMin == 2 )
    2400                 :          0 :                             nRangeYMin = nCoordHeight / 2;
    2401                 :          0 :                         EnhancedCustomShapeParameter aRangeYMinimum;
    2402                 :            :                         EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMinimum, nRangeYMin,
    2403         [ #  # ]:          0 :                             ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0, sal_True );
    2404         [ #  # ]:          0 :                         const rtl::OUString sHandleRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMinimum" ) );
    2405                 :          0 :                         aProp.Name = sHandleRangeYMinimum;
    2406         [ #  # ]:          0 :                         aProp.Value <<= aRangeYMinimum;
    2407         [ #  # ]:          0 :                         aHandlePropVec.push_back( aProp );
    2408                 :            :                     }
    2409         [ #  # ]:          0 :                     if ( (sal_uInt32)nRangeYMax != 0x7fffffff )
    2410                 :            :                     {
    2411         [ #  # ]:          0 :                         if ( nRangeYMax == 2 )
    2412                 :          0 :                             nRangeYMax = nCoordHeight / 2;
    2413                 :          0 :                         EnhancedCustomShapeParameter aRangeYMaximum;
    2414                 :            :                         EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMaximum, nRangeYMax,
    2415         [ #  # ]:          0 :                             ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0, sal_False );
    2416         [ #  # ]:          0 :                         const rtl::OUString sHandleRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMaximum" ) );
    2417                 :          0 :                         aProp.Name = sHandleRangeYMaximum;
    2418         [ #  # ]:          0 :                         aProp.Value <<= aRangeYMaximum;
    2419         [ #  # ]:          0 :                         aHandlePropVec.push_back( aProp );
    2420                 :            :                     }
    2421                 :            :                 }
    2422         [ #  # ]:          0 :                 if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
    2423                 :            :                 {
    2424         [ #  # ]:          0 :                     if ( (sal_uInt32)nRangeXMin != 0x7fffffff )
    2425                 :            :                     {
    2426         [ #  # ]:          0 :                         if ( nRangeXMin == 2 )
    2427                 :          0 :                             nRangeXMin = nCoordWidth / 2;
    2428                 :          0 :                         EnhancedCustomShapeParameter aRadiusRangeMinimum;
    2429                 :            :                         EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMinimum, nRangeXMin,
    2430         [ #  # ]:          0 :                             ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True  );
    2431         [ #  # ]:          0 :                         const rtl::OUString sHandleRadiusRangeMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMinimum" ) );
    2432                 :          0 :                         aProp.Name = sHandleRadiusRangeMinimum;
    2433         [ #  # ]:          0 :                         aProp.Value <<= aRadiusRangeMinimum;
    2434         [ #  # ]:          0 :                         aHandlePropVec.push_back( aProp );
    2435                 :            :                     }
    2436         [ #  # ]:          0 :                     if ( (sal_uInt32)nRangeXMax != 0x80000000 )
    2437                 :            :                     {
    2438         [ #  # ]:          0 :                         if ( nRangeXMax == 2 )
    2439                 :          0 :                             nRangeXMax = nCoordWidth / 2;
    2440                 :          0 :                         EnhancedCustomShapeParameter aRadiusRangeMaximum;
    2441                 :            :                         EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMaximum, nRangeXMax,
    2442         [ #  # ]:          0 :                             ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
    2443         [ #  # ]:          0 :                         const rtl::OUString sHandleRadiusRangeMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMaximum" ) );
    2444                 :          0 :                         aProp.Name = sHandleRadiusRangeMaximum;
    2445         [ #  # ]:          0 :                         aProp.Value <<= aRadiusRangeMaximum;
    2446         [ #  # ]:          0 :                         aHandlePropVec.push_back( aProp );
    2447                 :            :                     }
    2448                 :            :                 }
    2449         [ #  # ]:          0 :                 if ( !aHandlePropVec.empty() )
    2450                 :            :                 {
    2451         [ #  # ]:          0 :                     PropSeq aHandlePropSeq( aHandlePropVec.size() );
    2452                 :          0 :                     aIter = aHandlePropVec.begin();
    2453                 :          0 :                     aEnd = aHandlePropVec.end();
    2454         [ #  # ]:          0 :                     beans::PropertyValue* pHandleValues = aHandlePropSeq.getArray();
    2455 [ #  # ][ #  # ]:          0 :                     while ( aIter != aEnd )
    2456         [ #  # ]:          0 :                         *pHandleValues++ = *aIter++;
    2457 [ #  # ][ #  # ]:          0 :                     aHandles[ i ] = aHandlePropSeq;
                 [ #  # ]
    2458                 :            :                 }
    2459                 :          0 :             }
    2460                 :            :             // pushing the whole Handles element
    2461         [ #  # ]:          0 :             const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM ( "Handles" ) );
    2462                 :          0 :             aProp.Name = sHandles;
    2463         [ #  # ]:          0 :             aProp.Value <<= aHandles;
    2464 [ #  # ][ #  # ]:          0 :             aPropVec.push_back( aProp );
    2465                 :            :         }
    2466                 :            :     }
    2467                 :            :     else
    2468                 :            :     {
    2469         [ +  - ]:       1022 :         const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( rObjData.eShapeType );
    2470 [ +  + ][ +  + ]:       1022 :         if ( pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles )
                 [ +  - ]
    2471                 :            :         {
    2472                 :         21 :             sal_Int32 i, nCnt = pDefCustomShape->nHandles;
    2473                 :         21 :             const SvxMSDffHandle* pData = pDefCustomShape->pHandles;
    2474         [ +  + ]:         48 :             for ( i = 0; i < nCnt; i++, pData++ )
    2475                 :            :             {
    2476         [ -  + ]:         27 :                 if ( pData->nFlags & MSDFF_HANDLE_FLAGS_POLAR )
    2477                 :            :                 {
    2478 [ #  # ][ #  # ]:          0 :                     if ( ( pData->nPositionY >= 0x256 ) || ( pData->nPositionY <= 0x107 ) )
    2479                 :          0 :                         nAdjustmentsWhichNeedsToBeConverted |= ( 1 << i );
    2480                 :            :                 }
    2481                 :            :             }
    2482                 :            :         }
    2483                 :            :     }
    2484                 :            :     /////////////////////////////////////
    2485                 :            :     // "Path" PropertySequence element //
    2486                 :            :     /////////////////////////////////////
    2487                 :            :     {
    2488         [ +  - ]:       1022 :         PropVec aPathPropVec;
    2489                 :            : 
    2490                 :            :         // "Path/ExtrusionAllowed"
    2491 [ +  - ][ -  + ]:       1022 :         if ( IsHardAttribute( DFF_Prop_f3DOK ) )
    2492                 :            :         {
    2493         [ #  # ]:          0 :             const rtl::OUString sExtrusionAllowed( RTL_CONSTASCII_USTRINGPARAM ( "ExtrusionAllowed" ) );
    2494         [ #  # ]:          0 :             sal_Bool bExtrusionAllowed = ( GetPropertyValue( DFF_Prop_fFillOK ) & 16 ) != 0;
    2495                 :          0 :             aProp.Name = sExtrusionAllowed;
    2496         [ #  # ]:          0 :             aProp.Value <<= bExtrusionAllowed;
    2497         [ #  # ]:          0 :             aPathPropVec.push_back( aProp );
    2498                 :            :         }
    2499                 :            :         // "Path/ConcentricGradientFillAllowed"
    2500 [ +  - ][ -  + ]:       1022 :         if ( IsHardAttribute( DFF_Prop_fFillShadeShapeOK ) )
    2501                 :            :         {
    2502         [ #  # ]:          0 :             const rtl::OUString sConcentricGradientFillAllowed( RTL_CONSTASCII_USTRINGPARAM ( "ConcentricGradientFillAllowed" ) );
    2503         [ #  # ]:          0 :             sal_Bool bConcentricGradientFillAllowed = ( GetPropertyValue( DFF_Prop_fFillOK ) & 2 ) != 0;
    2504                 :          0 :             aProp.Name = sConcentricGradientFillAllowed;
    2505         [ #  # ]:          0 :             aProp.Value <<= bConcentricGradientFillAllowed;
    2506         [ #  # ]:          0 :             aPathPropVec.push_back( aProp );
    2507                 :            :         }
    2508                 :            :         // "Path/TextPathAllowed"
    2509 [ +  - ][ +  - ]:       1022 :         if ( IsHardAttribute( DFF_Prop_fGtextOK ) || ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x4000 ) )
         [ +  - ][ -  + ]
                 [ -  + ]
    2510                 :            :         {
    2511         [ #  # ]:          0 :             const rtl::OUString sTextPathAllowed( RTL_CONSTASCII_USTRINGPARAM ( "TextPathAllowed" ) );
    2512         [ #  # ]:          0 :             sal_Bool bTextPathAllowed = ( GetPropertyValue( DFF_Prop_fFillOK ) & 4 ) != 0;
    2513                 :          0 :             aProp.Name = sTextPathAllowed;
    2514         [ #  # ]:          0 :             aProp.Value <<= bTextPathAllowed;
    2515         [ #  # ]:          0 :             aPathPropVec.push_back( aProp );
    2516                 :            :         }
    2517                 :            :         // Path/Coordinates
    2518         [ +  + ]:       1022 :         if ( IsProperty( DFF_Prop_pVertices ) )
    2519                 :            :         {
    2520         [ +  - ]:          3 :             com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > aCoordinates;
    2521                 :          3 :             sal_uInt16 nNumElemVert = 0;
    2522                 :          3 :             sal_uInt16 nElemSizeVert = 8;
    2523                 :            : 
    2524 [ +  - ][ +  - ]:          3 :             if ( SeekToContent( DFF_Prop_pVertices, rIn ) )
    2525                 :            :             {
    2526                 :          3 :                 sal_uInt16 nNumElemMemVert = 0;
    2527 [ +  - ][ +  - ]:          3 :                 rIn >> nNumElemVert >> nNumElemMemVert >> nElemSizeVert;
                 [ +  - ]
    2528                 :            :             }
    2529         [ +  - ]:          3 :             if ( nNumElemVert )
    2530                 :            :             {
    2531                 :            :                 sal_Int32 nX, nY;
    2532                 :            :                 sal_Int16 nTmpA, nTmpB;
    2533         [ +  - ]:          3 :                 aCoordinates.realloc( nNumElemVert );
    2534         [ +  + ]:         60 :                 for ( sal_uInt16 i = 0; i < nNumElemVert; i++ )
    2535                 :            :                 {
    2536         [ -  + ]:         57 :                     if ( nElemSizeVert == 8 )
    2537                 :            :                     {
    2538         [ #  # ]:          0 :                         rIn >> nX
    2539         [ #  # ]:          0 :                             >> nY;
    2540                 :            :                     }
    2541                 :            :                     else
    2542                 :            :                     {
    2543         [ +  - ]:         57 :                         rIn >> nTmpA
    2544         [ +  - ]:         57 :                             >> nTmpB;
    2545                 :            : 
    2546                 :         57 :                         nX = nTmpA;
    2547                 :         57 :                         nY = nTmpB;
    2548                 :            :                     }
    2549 [ +  - ][ +  - ]:         57 :                     EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aCoordinates[ i ].First, nX );
    2550 [ +  - ][ +  - ]:         57 :                     EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aCoordinates[ i ].Second, nY );
    2551                 :            :                 }
    2552                 :            :             }
    2553         [ +  - ]:          3 :             const rtl::OUString sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
    2554                 :          3 :             aProp.Name = sCoordinates;
    2555         [ +  - ]:          3 :             aProp.Value <<= aCoordinates;
    2556 [ +  - ][ +  - ]:          3 :             aPathPropVec.push_back( aProp );
    2557                 :            :         }
    2558                 :            :         // Path/Segments
    2559         [ +  + ]:       1022 :         if ( IsProperty( DFF_Prop_pSegmentInfo ) )
    2560                 :            :         {
    2561         [ +  - ]:          3 :             com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > aSegments;
    2562                 :            : 
    2563                 :            :             sal_uInt16 i, nTmp;
    2564                 :          3 :             sal_uInt16 nNumElemSeg = 0;
    2565                 :            : 
    2566 [ +  - ][ +  - ]:          3 :             if ( SeekToContent( DFF_Prop_pSegmentInfo, rIn ) )
    2567                 :            :             {
    2568                 :          3 :                 sal_uInt16 nNumElemMemSeg = 0;
    2569                 :          3 :                 sal_uInt16 nElemSizeSeg = 2;
    2570 [ +  - ][ +  - ]:          3 :                 rIn >> nNumElemSeg >> nNumElemMemSeg >> nElemSizeSeg;
                 [ +  - ]
    2571                 :            :             }
    2572         [ +  - ]:          3 :             if ( nNumElemSeg )
    2573                 :            :             {
    2574                 :            :                 sal_Int16 nCommand;
    2575                 :            :                 sal_Int16 nCnt;
    2576         [ +  - ]:          3 :                 aSegments.realloc( nNumElemSeg );
    2577         [ +  + ]:         48 :                 for ( i = 0; i < nNumElemSeg; i++ )
    2578                 :            :                 {
    2579         [ +  - ]:         45 :                     rIn >> nTmp;
    2580                 :         45 :                     nCommand = EnhancedCustomShapeSegmentCommand::UNKNOWN;
    2581                 :         45 :                     nCnt = (sal_Int16)( nTmp & 0xfff );
    2582   [ -  -  +  +  :         45 :                     switch( nTmp >> 12 )
             -  +  -  +  
                      - ]
    2583                 :            :                     {
    2584         [ #  # ]:          0 :                         case 0x0: nCommand = EnhancedCustomShapeSegmentCommand::LINETO; if ( !nCnt ) nCnt = 1; break;
    2585         [ #  # ]:          0 :                         case 0x1: nCommand = EnhancedCustomShapeSegmentCommand::LINETO; if ( !nCnt ) nCnt = 1; break;   // seems to the relative lineto
    2586         [ +  - ]:          3 :                         case 0x4: nCommand = EnhancedCustomShapeSegmentCommand::MOVETO; if ( !nCnt ) nCnt = 1; break;
    2587         [ -  + ]:         18 :                         case 0x2: nCommand = EnhancedCustomShapeSegmentCommand::CURVETO; if ( !nCnt ) nCnt = 1; break;
    2588         [ #  # ]:          0 :                         case 0x3: nCommand = EnhancedCustomShapeSegmentCommand::CURVETO; if ( !nCnt ) nCnt = 1; break;  // seems to be the relative curveto
    2589                 :          3 :                         case 0x8: nCommand = EnhancedCustomShapeSegmentCommand::ENDSUBPATH; nCnt = 0; break;
    2590                 :          0 :                         case 0x6: nCommand = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH; nCnt = 0; break;
    2591                 :            :                         case 0xa:
    2592                 :            :                         case 0xb:
    2593                 :            :                         {
    2594   [ -  -  -  -  :         21 :                             switch ( ( nTmp >> 8 ) & 0xf )
          -  -  -  -  -  
                -  -  + ]
    2595                 :            :                             {
    2596                 :            :                                 case 0x0:
    2597                 :            :                                 {
    2598                 :          0 :                                     nCommand = EnhancedCustomShapeSegmentCommand::LINETO;
    2599         [ #  # ]:          0 :                                     if ( !nCnt )
    2600                 :          0 :                                         nCnt = 1;
    2601                 :            :                                 }
    2602                 :          0 :                                 break;
    2603                 :            :                                 case 0x1:
    2604                 :            :                                 {
    2605                 :          0 :                                     nCommand = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO;
    2606                 :          0 :                                     nCnt = ( nTmp & 0xff ) / 3;
    2607                 :            :                                 }
    2608                 :          0 :                                 break;
    2609                 :            :                                 case 0x2:
    2610                 :            :                                 {
    2611                 :          0 :                                     nCommand = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE;
    2612                 :          0 :                                     nCnt = ( nTmp & 0xff ) / 3;
    2613                 :            :                                 }
    2614                 :          0 :                                 break;
    2615                 :            :                                 case 0x3:
    2616                 :            :                                 {
    2617                 :          0 :                                     nCommand = EnhancedCustomShapeSegmentCommand::ARCTO;
    2618                 :          0 :                                     nCnt = ( nTmp & 0xff ) >> 2;
    2619                 :            :                                 };
    2620                 :          0 :                                 break;
    2621                 :            :                                 case 0x4:
    2622                 :            :                                 {
    2623                 :          0 :                                     nCommand = EnhancedCustomShapeSegmentCommand::ARC;
    2624                 :          0 :                                     nCnt = ( nTmp & 0xff ) >> 2;
    2625                 :            :                                 }
    2626                 :          0 :                                 break;
    2627                 :            :                                 case 0x5:
    2628                 :            :                                 {
    2629                 :          0 :                                     nCommand = EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO;
    2630                 :          0 :                                     nCnt = ( nTmp & 0xff ) >> 2;
    2631                 :            :                                 }
    2632                 :          0 :                                 break;
    2633                 :            :                                 case 0x6:
    2634                 :            :                                 {
    2635                 :          0 :                                     nCommand = EnhancedCustomShapeSegmentCommand::CLOCKWISEARC;
    2636                 :          0 :                                     nCnt = ( nTmp & 0xff ) >> 2;
    2637                 :            :                                 }
    2638                 :          0 :                                 break;
    2639                 :            :                                 case 0x7:
    2640                 :            :                                 {
    2641                 :          0 :                                     nCommand = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX;
    2642                 :          0 :                                     nCnt = nTmp & 0xff;
    2643                 :            :                                 }
    2644                 :          0 :                                 break;
    2645                 :            :                                 case 0x8:
    2646                 :            :                                 {
    2647                 :          0 :                                     nCommand = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY;
    2648                 :          0 :                                     nCnt = nTmp & 0xff;
    2649                 :            :                                 }
    2650                 :          0 :                                 break;
    2651                 :          0 :                                 case 0xa: nCommand = EnhancedCustomShapeSegmentCommand::NOFILL; nCnt = 0; break;
    2652                 :          0 :                                 case 0xb: nCommand = EnhancedCustomShapeSegmentCommand::NOSTROKE; nCnt = 0; break;
    2653                 :            :                             }
    2654                 :            :                         }
    2655                 :         21 :                         break;
    2656                 :            :                     }
    2657                 :            :                     // if the command is unknown, we will store all the data in nCnt, so it will be possible to export without loss
    2658         [ +  + ]:         45 :                     if ( nCommand == EnhancedCustomShapeSegmentCommand::UNKNOWN )
    2659                 :         21 :                         nCnt = (sal_Int16)nTmp;
    2660         [ +  - ]:         45 :                     aSegments[ i ].Command = nCommand;
    2661         [ +  - ]:         45 :                     aSegments[ i ].Count = nCnt;
    2662                 :            :                 }
    2663                 :            :             }
    2664         [ +  - ]:          3 :             const rtl::OUString sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
    2665                 :          3 :             aProp.Name = sSegments;
    2666         [ +  - ]:          3 :             aProp.Value <<= aSegments;
    2667 [ +  - ][ +  - ]:          3 :             aPathPropVec.push_back( aProp );
    2668                 :            :         }
    2669                 :            :         // Path/StretchX
    2670         [ -  + ]:       1022 :         if ( IsProperty( DFF_Prop_stretchPointX ) )
    2671                 :            :         {
    2672         [ #  # ]:          0 :             const rtl::OUString sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) );
    2673         [ #  # ]:          0 :             sal_Int32 nStretchX = GetPropertyValue( DFF_Prop_stretchPointX, 0 );
    2674                 :          0 :             aProp.Name = sStretchX;
    2675         [ #  # ]:          0 :             aProp.Value <<= nStretchX;
    2676         [ #  # ]:          0 :             aPathPropVec.push_back( aProp );
    2677                 :            :         }
    2678                 :            :         // Path/StretchX
    2679         [ -  + ]:       1022 :         if ( IsProperty( DFF_Prop_stretchPointY ) )
    2680                 :            :         {
    2681         [ #  # ]:          0 :             const rtl::OUString sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) );
    2682         [ #  # ]:          0 :             sal_Int32 nStretchY = GetPropertyValue( DFF_Prop_stretchPointY, 0 );
    2683                 :          0 :             aProp.Name = sStretchY;
    2684         [ #  # ]:          0 :             aProp.Value <<= nStretchY;
    2685         [ #  # ]:          0 :             aPathPropVec.push_back( aProp );
    2686                 :            :         }
    2687                 :            :         // Path/TextFrames
    2688         [ -  + ]:       1022 :         if ( IsProperty( DFF_Prop_textRectangles ) )
    2689                 :            :         {
    2690                 :          0 :             sal_uInt16 nNumElem = 0;
    2691                 :          0 :             sal_uInt16 nElemSize = 16;
    2692                 :            : 
    2693 [ #  # ][ #  # ]:          0 :             if ( SeekToContent( DFF_Prop_textRectangles, rIn ) )
    2694                 :            :             {
    2695                 :          0 :                 sal_uInt16 nNumElemMem = 0;
    2696 [ #  # ][ #  # ]:          0 :                 rIn >> nNumElem >> nNumElemMem >> nElemSize;
                 [ #  # ]
    2697                 :            :             }
    2698         [ #  # ]:          0 :             if ( nElemSize == 16 )
    2699                 :            :             {
    2700                 :            :                 sal_Int32 nLeft, nTop, nRight, nBottom;
    2701         [ #  # ]:          0 :                 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > aTextFrames( nNumElem );
    2702         [ #  # ]:          0 :                 for ( sal_uInt16 i = 0; i < nNumElem; i++ )
    2703                 :            :                 {
    2704         [ #  # ]:          0 :                     rIn >> nLeft
    2705         [ #  # ]:          0 :                         >> nTop
    2706         [ #  # ]:          0 :                         >> nRight
    2707         [ #  # ]:          0 :                         >> nBottom;
    2708                 :            : 
    2709 [ #  # ][ #  # ]:          0 :                     EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrames[ i ].TopLeft.First,  nLeft );
    2710 [ #  # ][ #  # ]:          0 :                     EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrames[ i ].TopLeft.Second, nTop  );
    2711 [ #  # ][ #  # ]:          0 :                     EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrames[ i ].BottomRight.First,  nRight );
    2712 [ #  # ][ #  # ]:          0 :                     EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrames[ i ].BottomRight.Second, nBottom);
    2713                 :            :                 }
    2714         [ #  # ]:          0 :                 const rtl::OUString sTextFrames( RTL_CONSTASCII_USTRINGPARAM ( "TextFrames" ) );
    2715                 :          0 :                 aProp.Name = sTextFrames;
    2716         [ #  # ]:          0 :                 aProp.Value <<= aTextFrames;
    2717 [ #  # ][ #  # ]:          0 :                 aPathPropVec.push_back( aProp );
    2718                 :            :             }
    2719                 :            :         }
    2720                 :            :         //Path/GluePoints
    2721         [ -  + ]:       1022 :         if ( IsProperty( DFF_Prop_connectorPoints ) )
    2722                 :            :         {
    2723         [ #  # ]:          0 :             com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > aGluePoints;
    2724                 :          0 :             sal_uInt16 nNumElemVert = 0;
    2725                 :          0 :             sal_uInt16 nNumElemMemVert = 0;
    2726                 :          0 :             sal_uInt16 nElemSizeVert = 8;
    2727                 :            : 
    2728 [ #  # ][ #  # ]:          0 :             if ( SeekToContent( DFF_Prop_connectorPoints, rIn ) )
    2729 [ #  # ][ #  # ]:          0 :                 rIn >> nNumElemVert >> nNumElemMemVert >> nElemSizeVert;
                 [ #  # ]
    2730                 :            : 
    2731                 :            :             sal_Int32 nX, nY;
    2732                 :            :             sal_Int16 nTmpA, nTmpB;
    2733         [ #  # ]:          0 :             aGluePoints.realloc( nNumElemVert );
    2734         [ #  # ]:          0 :             for ( sal_uInt16 i = 0; i < nNumElemVert; i++ )
    2735                 :            :             {
    2736         [ #  # ]:          0 :                 if ( nElemSizeVert == 8 )
    2737                 :            :                 {
    2738         [ #  # ]:          0 :                     rIn >> nX
    2739         [ #  # ]:          0 :                         >> nY;
    2740                 :            :                 }
    2741                 :            :                 else
    2742                 :            :                 {
    2743         [ #  # ]:          0 :                     rIn >> nTmpA
    2744         [ #  # ]:          0 :                         >> nTmpB;
    2745                 :            : 
    2746                 :          0 :                     nX = nTmpA;
    2747                 :          0 :                     nY = nTmpB;
    2748                 :            :                 }
    2749 [ #  # ][ #  # ]:          0 :                 EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aGluePoints[ i ].First,  nX );
    2750 [ #  # ][ #  # ]:          0 :                 EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aGluePoints[ i ].Second, nY );
    2751                 :            :             }
    2752         [ #  # ]:          0 :             const rtl::OUString sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
    2753                 :          0 :             aProp.Name = sGluePoints;
    2754         [ #  # ]:          0 :             aProp.Value <<= aGluePoints;
    2755 [ #  # ][ #  # ]:          0 :             aPathPropVec.push_back( aProp );
    2756                 :            :         }
    2757         [ +  + ]:       1022 :         if ( IsProperty( DFF_Prop_connectorType ) )
    2758                 :            :         {
    2759         [ +  - ]:          3 :             sal_Int16 nGluePointType = (sal_uInt16)GetPropertyValue( DFF_Prop_connectorType );
    2760         [ +  - ]:          3 :             const rtl::OUString sGluePointType( RTL_CONSTASCII_USTRINGPARAM ( "GluePointType" ) );
    2761                 :          3 :             aProp.Name = sGluePointType;
    2762         [ +  - ]:          3 :             aProp.Value <<= nGluePointType;
    2763         [ +  - ]:          3 :             aPathPropVec.push_back( aProp );
    2764                 :            :         }
    2765                 :            :         // pushing the whole Path element
    2766         [ +  + ]:       1022 :         if ( !aPathPropVec.empty() )
    2767                 :            :         {
    2768         [ +  - ]:          6 :             const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
    2769         [ +  - ]:          6 :             PropSeq aPathPropSeq( aPathPropVec.size() );
    2770                 :          6 :             aIter = aPathPropVec.begin();
    2771                 :          6 :             aEnd = aPathPropVec.end();
    2772         [ +  - ]:          6 :             beans::PropertyValue* pPathValues = aPathPropSeq.getArray();
    2773 [ +  - ][ +  + ]:         15 :             while ( aIter != aEnd )
    2774         [ +  - ]:          9 :                 *pPathValues++ = *aIter++;
    2775                 :          6 :             aProp.Name = sPath;
    2776         [ +  - ]:          6 :             aProp.Value <<= aPathPropSeq;
    2777 [ +  - ][ +  - ]:          6 :             aPropVec.push_back( aProp );
    2778                 :       1022 :         }
    2779                 :            :     }
    2780                 :            :     /////////////////////////////////////////
    2781                 :            :     // "TextPath" PropertySequence element //
    2782                 :            :     /////////////////////////////////////////
    2783         [ +  - ]:       1022 :     sal_Bool bTextPathOn = ( GetPropertyValue( DFF_Prop_gtextFStrikethrough ) & 0x4000 ) != 0;
    2784         [ -  + ]:       1022 :     if ( bTextPathOn )
    2785                 :            :     {
    2786         [ #  # ]:          0 :         PropVec aTextPathPropVec;
    2787                 :            : 
    2788                 :            :         // TextPath
    2789         [ #  # ]:          0 :         const rtl::OUString sTextPathOn( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
    2790                 :          0 :         aProp.Name = sTextPathOn;
    2791         [ #  # ]:          0 :         aProp.Value <<= bTextPathOn;
    2792         [ #  # ]:          0 :         aTextPathPropVec.push_back( aProp );
    2793                 :            : 
    2794                 :            :         // TextPathMode
    2795         [ #  # ]:          0 :         const rtl::OUString sTextPathMode( RTL_CONSTASCII_USTRINGPARAM ( "TextPathMode" ) );
    2796         [ #  # ]:          0 :         sal_Bool bTextPathFitPath = ( GetPropertyValue( DFF_Prop_gtextFStrikethrough ) & 0x100 ) != 0;
    2797                 :            : 
    2798                 :            :         sal_Bool bTextPathFitShape;
    2799 [ #  # ][ #  # ]:          0 :         if ( IsHardAttribute( DFF_Prop_gtextFStretch ) )
    2800         [ #  # ]:          0 :             bTextPathFitShape = ( GetPropertyValue( DFF_Prop_gtextFStrikethrough ) & 0x400 ) != 0;
    2801                 :            :         else
    2802                 :            :         {
    2803                 :          0 :             bTextPathFitShape = true;
    2804         [ #  # ]:          0 :             switch( rObjData.eShapeType )
    2805                 :            :             {
    2806                 :            :                 case mso_sptTextArchUpCurve :
    2807                 :            :                 case mso_sptTextArchDownCurve :
    2808                 :            :                 case mso_sptTextCircleCurve :
    2809                 :            :                 case mso_sptTextButtonCurve :
    2810                 :          0 :                     bTextPathFitShape = false;
    2811                 :          0 :                 default : break;
    2812                 :            :             }
    2813                 :            :         }
    2814                 :          0 :         EnhancedCustomShapeTextPathMode eTextPathMode( EnhancedCustomShapeTextPathMode_NORMAL );
    2815         [ #  # ]:          0 :         if ( bTextPathFitShape )
    2816                 :          0 :             eTextPathMode = EnhancedCustomShapeTextPathMode_SHAPE;
    2817         [ #  # ]:          0 :         else if ( bTextPathFitPath )
    2818                 :          0 :             eTextPathMode = EnhancedCustomShapeTextPathMode_PATH;
    2819                 :          0 :         aProp.Name = sTextPathMode;
    2820         [ #  # ]:          0 :         aProp.Value <<= eTextPathMode;
    2821         [ #  # ]:          0 :         aTextPathPropVec.push_back( aProp );
    2822                 :            : 
    2823                 :            :         // ScaleX
    2824         [ #  # ]:          0 :         const rtl::OUString sTextPathScaleX( RTL_CONSTASCII_USTRINGPARAM ( "ScaleX" ) );
    2825         [ #  # ]:          0 :         sal_Bool bTextPathScaleX = ( GetPropertyValue( DFF_Prop_gtextFStrikethrough ) & 0x40 ) != 0;
    2826                 :          0 :         aProp.Name = sTextPathScaleX;
    2827         [ #  # ]:          0 :         aProp.Value <<= bTextPathScaleX;
    2828         [ #  # ]:          0 :         aTextPathPropVec.push_back( aProp );
    2829                 :            :         // SameLetterHeights
    2830         [ #  # ]:          0 :         const rtl::OUString sSameLetterHeight( RTL_CONSTASCII_USTRINGPARAM ( "SameLetterHeights" ) );
    2831         [ #  # ]:          0 :         sal_Bool bSameLetterHeight = ( GetPropertyValue( DFF_Prop_gtextFStrikethrough ) & 0x80 ) != 0;
    2832                 :          0 :         aProp.Name = sSameLetterHeight;
    2833         [ #  # ]:          0 :         aProp.Value <<= bSameLetterHeight;
    2834         [ #  # ]:          0 :         aTextPathPropVec.push_back( aProp );
    2835                 :            : 
    2836                 :            :         // pushing the whole TextPath element
    2837         [ #  # ]:          0 :         const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
    2838         [ #  # ]:          0 :         PropSeq aTextPathPropSeq( aTextPathPropVec.size() );
    2839                 :          0 :         aIter = aTextPathPropVec.begin();
    2840                 :          0 :         aEnd = aTextPathPropVec.end();
    2841         [ #  # ]:          0 :         beans::PropertyValue* pTextPathValues = aTextPathPropSeq.getArray();
    2842 [ #  # ][ #  # ]:          0 :         while ( aIter != aEnd )
    2843         [ #  # ]:          0 :             *pTextPathValues++ = *aIter++;
    2844                 :          0 :         aProp.Name = sTextPath;
    2845         [ #  # ]:          0 :         aProp.Value <<= aTextPathPropSeq;
    2846 [ #  # ][ #  # ]:          0 :         aPropVec.push_back( aProp );
    2847                 :            :     }
    2848                 :            :     ////////////////////////
    2849                 :            :     // "AdjustmentValues" // The AdjustmentValues are imported at last, because depending to the type of the
    2850                 :            :     //////////////////////// handle (POLAR) we will convert the adjustment value from a fixed float to double
    2851                 :            : 
    2852                 :            :     // checking the last used adjustment handle, so we can determine how many handles are to allocate
    2853                 :       1022 :     sal_Int32 i = DFF_Prop_adjust10Value;
    2854 [ +  + ][ +  + ]:      11194 :     while ( ( i >= DFF_Prop_adjustValue ) && !IsProperty( i ) )
                 [ +  + ]
    2855                 :      10172 :         i--;
    2856                 :       1022 :     sal_Int32 nAdjustmentValues = ( i - DFF_Prop_adjustValue ) + 1;
    2857         [ +  + ]:       1022 :     if ( nAdjustmentValues )
    2858                 :            :     {
    2859         [ +  - ]:         15 :         uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq( nAdjustmentValues );
    2860         [ +  + ]:         63 :         while( --nAdjustmentValues >= 0 )
    2861                 :            :         {
    2862                 :         48 :             sal_Int32 nValue = 0;
    2863                 :         48 :             beans::PropertyState ePropertyState = beans::PropertyState_DEFAULT_VALUE;
    2864         [ +  + ]:         48 :             if ( IsProperty( i ) )
    2865                 :            :             {
    2866         [ +  - ]:         45 :                 nValue = GetPropertyValue( i );
    2867                 :         45 :                 ePropertyState = beans::PropertyState_DIRECT_VALUE;
    2868                 :            :             }
    2869         [ -  + ]:         48 :             if ( nAdjustmentsWhichNeedsToBeConverted & ( 1 << ( i - DFF_Prop_adjustValue ) ) )
    2870                 :            :             {
    2871                 :          0 :                 double fValue = nValue;
    2872                 :          0 :                 fValue /= 65536;
    2873 [ #  # ][ #  # ]:          0 :                 aAdjustmentSeq[ nAdjustmentValues ].Value <<= fValue;
    2874                 :            :             }
    2875                 :            :             else
    2876 [ +  - ][ +  - ]:         48 :                 aAdjustmentSeq[ nAdjustmentValues ].Value <<= nValue;
    2877         [ +  - ]:         48 :             aAdjustmentSeq[ nAdjustmentValues ].State = ePropertyState;
    2878                 :         48 :             i--;
    2879                 :            :         }
    2880         [ +  - ]:         15 :         const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
    2881                 :         15 :         aProp.Name = sAdjustmentValues;
    2882         [ +  - ]:         15 :         aProp.Value <<= aAdjustmentSeq;
    2883 [ +  - ][ +  - ]:         15 :         aPropVec.push_back( aProp );
    2884                 :            :     }
    2885                 :            : 
    2886                 :            :     // creating the whole property set
    2887         [ +  - ]:       1022 :     PropSeq aSeq( aPropVec.size() );
    2888         [ +  - ]:       1022 :     beans::PropertyValue* pValues = aSeq.getArray();
    2889                 :       1022 :     aIter = aPropVec.begin();
    2890                 :       1022 :     aEnd = aPropVec.end();
    2891 [ +  - ][ +  + ]:       2068 :     while ( aIter != aEnd )
    2892         [ +  - ]:       1046 :         *pValues++ = *aIter++;
    2893 [ +  - ][ +  - ]:       1022 :     rSet.Put( SdrCustomShapeGeometryItem( aSeq ) );
         [ +  - ][ +  - ]
    2894                 :       1022 : }
    2895                 :            : 
    2896                 :         21 : void DffPropertyReader::ApplyAttributes( SvStream& rIn, SfxItemSet& rSet ) const
    2897                 :            : {
    2898         [ +  - ]:         21 :     Rectangle aEmptyRect;
    2899                 :         21 :     DffRecordHeader aHdTemp;
    2900         [ +  - ]:         21 :     DffObjData aDffObjTemp( aHdTemp, aEmptyRect, 0 );
    2901         [ +  - ]:         21 :     ApplyAttributes( rIn, rSet, aDffObjTemp );
    2902                 :         21 : }
    2903                 :            : 
    2904                 :       1064 : void DffPropertyReader::ApplyAttributes( SvStream& rIn, SfxItemSet& rSet, const DffObjData& rObjData ) const
    2905                 :            : {
    2906                 :       1064 :     sal_Bool bHasShadow = sal_False;
    2907                 :            : 
    2908 [ +  - ][ +  - ]:      22522 :     for ( RecordTypesMap::const_iterator it = maRecordTypes.begin(); it != maRecordTypes.end(); ++it )
                 [ +  + ]
    2909                 :            :     {
    2910         [ +  - ]:      21458 :         sal_uInt32 nRecType = it->first;
    2911                 :      21458 :         sal_uInt32 nContent = mpContents[ nRecType ];
    2912   [ -  +  +  -  :      21458 :         switch ( nRecType )
          +  -  -  -  +  
                      + ]
    2913                 :            :         {
    2914                 :            :             case DFF_Prop_gtextSize :
    2915 [ #  # ][ #  # ]:          0 :                 rSet.Put( SvxFontHeightItem( rManager.ScalePt( nContent ), 100, EE_CHAR_FONTHEIGHT ) );
         [ #  # ][ #  # ]
    2916                 :          0 :             break;
    2917                 :            :             // GeoText
    2918                 :            :             case DFF_Prop_gtextFStrikethrough :
    2919                 :            :             {
    2920         [ -  + ]:       1064 :                 if ( nContent & 0x20 )
    2921 [ #  # ][ #  # ]:          0 :                     rSet.Put( SvxWeightItem( nContent ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
         [ #  # ][ #  # ]
    2922         [ -  + ]:       1064 :                 if ( nContent & 0x10 )
    2923 [ #  # ][ #  # ]:          0 :                     rSet.Put( SvxPostureItem( nContent ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC ) );
         [ #  # ][ #  # ]
    2924         [ -  + ]:       1064 :                 if ( nContent & 0x08 )
    2925 [ #  # ][ #  # ]:          0 :                     rSet.Put( SvxUnderlineItem( nContent ? UNDERLINE_SINGLE : UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
         [ #  # ][ #  # ]
    2926         [ -  + ]:       1064 :                 if ( nContent & 0x40 )
    2927 [ #  # ][ #  # ]:          0 :                     rSet.Put(SvxShadowedItem( nContent != 0, EE_CHAR_SHADOW ) );
                 [ #  # ]
    2928         [ -  + ]:       1064 :                 if ( nContent & 0x01 )
    2929 [ #  # ][ #  # ]:          0 :                     rSet.Put( SvxCrossedOutItem( nContent ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) );
         [ #  # ][ #  # ]
    2930                 :            :             }
    2931                 :       1064 :             break;
    2932                 :            : 
    2933                 :            :             case DFF_Prop_fillColor :
    2934 [ +  - ][ +  - ]:       1064 :                 rSet.Put( XFillColorItem( rtl::OUString(), rManager.MSO_CLR_ToColor( nContent, DFF_Prop_fillColor ) ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2935                 :       1064 :             break;
    2936                 :            : 
    2937                 :            :             // ShadowStyle
    2938                 :            :             case DFF_Prop_shadowType :
    2939                 :            :             {
    2940                 :          0 :                 MSO_ShadowType eShadowType = (MSO_ShadowType)nContent;
    2941         [ #  # ]:          0 :                 if( eShadowType != mso_shadowOffset )
    2942                 :            :                 {
    2943                 :            :                     //   mso_shadowDouble
    2944                 :            :                     //   mso_shadowRich
    2945                 :            :                     //   mso_shadowEmbossOrEngrave
    2946                 :            :                     // not possible in LibreOffice, create default shadow with default distance
    2947 [ #  # ][ #  # ]:          0 :                     rSet.Put( SdrShadowXDistItem( 35 ) ); // 0,35 mm shadow distance
                 [ #  # ]
    2948 [ #  # ][ #  # ]:          0 :                     rSet.Put( SdrShadowYDistItem( 35 ) );
                 [ #  # ]
    2949                 :            :                 }
    2950                 :            :             }
    2951                 :          0 :             break;
    2952                 :            :             case DFF_Prop_shadowColor :
    2953 [ +  - ][ +  - ]:        813 :                 rSet.Put( SdrShadowColorItem( rtl::OUString(), rManager.MSO_CLR_ToColor( nContent, DFF_Prop_shadowColor ) ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2954                 :        813 :             break;
    2955                 :            :             case DFF_Prop_shadowOpacity :
    2956 [ #  # ][ #  # ]:          0 :                 rSet.Put( SdrShadowTransparenceItem( (sal_uInt16)( ( 0x10000 - nContent ) / 655 ) ) );
                 [ #  # ]
    2957                 :          0 :             break;
    2958                 :            :             case DFF_Prop_shadowOffsetX :
    2959                 :            :             {
    2960                 :          0 :                 sal_Int32 nVal = (sal_Int32)nContent;
    2961         [ #  # ]:          0 :                 rManager.ScaleEmu( nVal );
    2962         [ #  # ]:          0 :                 if ( nVal )
    2963 [ #  # ][ #  # ]:          0 :                     rSet.Put( SdrShadowXDistItem( nVal ) );
                 [ #  # ]
    2964                 :            :             }
    2965                 :          0 :             break;
    2966                 :            :             case DFF_Prop_shadowOffsetY :
    2967                 :            :             {
    2968                 :          0 :                 sal_Int32 nVal = (sal_Int32)nContent;
    2969         [ #  # ]:          0 :                 rManager.ScaleEmu( nVal );
    2970         [ #  # ]:          0 :                 if ( nVal )
    2971 [ #  # ][ #  # ]:          0 :                     rSet.Put( SdrShadowYDistItem( nVal ) );
                 [ #  # ]
    2972                 :            :             }
    2973                 :          0 :             break;
    2974                 :            :             case DFF_Prop_fshadowObscured :
    2975                 :            :             {
    2976                 :       1064 :                 bHasShadow = ( nContent & 2 ) != 0;
    2977         [ +  + ]:       1064 :                 if ( bHasShadow )
    2978                 :            :                 {
    2979         [ +  - ]:          3 :                     if ( !IsProperty( DFF_Prop_shadowOffsetX ) )
    2980 [ +  - ][ +  - ]:          3 :                         rSet.Put( SdrShadowXDistItem( 35 ) );
                 [ +  - ]
    2981         [ +  - ]:          3 :                     if ( !IsProperty( DFF_Prop_shadowOffsetY ) )
    2982 [ +  - ][ +  - ]:          3 :                         rSet.Put( SdrShadowYDistItem( 35 ) );
                 [ +  - ]
    2983                 :            :                 }
    2984                 :            :             }
    2985                 :       1064 :             break;
    2986                 :            :         }
    2987                 :            :     }
    2988                 :            : 
    2989         [ +  + ]:       1064 :     if ( bHasShadow )
    2990                 :            :     {
    2991                 :            :         // #160376# sj: activating shadow only if fill and or linestyle is used
    2992                 :            :         // this is required because of the latest drawing layer core changes.
    2993                 :            :         // Issue i104085 is related to this.
    2994                 :          3 :         sal_uInt32 nLineFlags(GetPropertyValue( DFF_Prop_fNoLineDrawDash ));
    2995 [ #  # ][ -  + ]:          3 :         if(!IsHardAttribute( DFF_Prop_fLine ) && !IsCustomShapeStrokedByDefault( rObjData.eShapeType ))
                 [ -  + ]
    2996                 :          0 :             nLineFlags &= ~0x08;
    2997                 :          3 :         sal_uInt32 nFillFlags(GetPropertyValue( DFF_Prop_fNoFillHitTest ));
    2998 [ #  # ][ -  + ]:          3 :         if(!IsHardAttribute( DFF_Prop_fFilled ) && !IsCustomShapeFilledByDefault( rObjData.eShapeType ))
                 [ -  + ]
    2999                 :          0 :             nFillFlags &= ~0x10;
    3000         [ +  - ]:          3 :         if ( nFillFlags & 0x10 )
    3001                 :            :         {
    3002                 :          3 :             MSO_FillType eMSO_FillType = (MSO_FillType)GetPropertyValue( DFF_Prop_fillType, mso_fillSolid );
    3003         [ +  - ]:          3 :             switch( eMSO_FillType )
    3004                 :            :             {
    3005                 :            :                 case mso_fillSolid :
    3006                 :            :                 case mso_fillPattern :
    3007                 :            :                 case mso_fillTexture :
    3008                 :            :                 case mso_fillPicture :
    3009                 :            :                 case mso_fillShade :
    3010                 :            :                 case mso_fillShadeCenter :
    3011                 :            :                 case mso_fillShadeShape :
    3012                 :            :                 case mso_fillShadeScale :
    3013                 :            :                 case mso_fillShadeTitle :
    3014                 :          3 :                 break;
    3015                 :            :                 default:
    3016                 :          0 :                     nFillFlags &=~0x10;         // no fillstyle used
    3017                 :          3 :                 break;
    3018                 :            :             }
    3019                 :            :         }
    3020 [ -  + ][ #  # ]:          3 :         if ( ( ( nLineFlags & 0x08 ) == 0 ) && ( ( nFillFlags & 0x10 ) == 0 ) ) // if there is no fillstyle and linestyle
    3021                 :          0 :             bHasShadow = sal_False;                                             // we are turning shadow off.
    3022                 :            : 
    3023         [ +  - ]:          3 :         if ( bHasShadow )
    3024         [ +  - ]:          3 :             rSet.Put( SdrShadowItem( bHasShadow ) );
    3025                 :            :     }
    3026                 :       1064 :     ApplyLineAttributes( rSet, rObjData.eShapeType ); // #i28269#
    3027                 :       1064 :     ApplyFillAttributes( rIn, rSet, rObjData );
    3028         [ +  + ]:       1064 :     if ( rObjData.eShapeType != mso_sptNil )
    3029                 :            :     {
    3030                 :       1022 :         ApplyCustomShapeGeometryAttributes( rIn, rSet, rObjData );
    3031                 :       1022 :         ApplyCustomShapeTextAttributes( rSet );
    3032                 :            :     }
    3033                 :       1064 : }
    3034                 :            : 
    3035                 :            : //---------------------------------------------------------------------------
    3036                 :            : //- Record Manager ----------------------------------------------------------
    3037                 :            : //---------------------------------------------------------------------------
    3038                 :            : 
    3039                 :        110 : DffRecordList::DffRecordList( DffRecordList* pList ) :
    3040                 :            :     nCount                  ( 0 ),
    3041                 :            :     nCurrent                ( 0 ),
    3042                 :            :     pPrev                   ( pList ),
    3043         [ +  + ]:       7150 :     pNext                   ( NULL )
    3044                 :            : {
    3045         [ -  + ]:        110 :     if ( pList )
    3046                 :          0 :         pList->pNext = this;
    3047                 :        110 : }
    3048                 :            : 
    3049                 :        110 : DffRecordList::~DffRecordList()
    3050                 :            : {
    3051         [ -  + ]:        110 :     delete pNext;
    3052                 :        110 : }
    3053                 :            : 
    3054                 :        101 : DffRecordManager::DffRecordManager() :
    3055                 :            :     DffRecordList   ( NULL ),
    3056                 :        101 :     pCList          ( (DffRecordList*)this )
    3057                 :            : {
    3058                 :        101 : }
    3059                 :            : 
    3060                 :          9 : DffRecordManager::DffRecordManager( SvStream& rIn ) :
    3061                 :            :     DffRecordList   ( NULL ),
    3062                 :          9 :     pCList          ( (DffRecordList*)this )
    3063                 :            : {
    3064         [ +  - ]:          9 :     Consume( rIn );
    3065                 :          9 : }
    3066                 :            : 
    3067                 :        110 : DffRecordManager::~DffRecordManager()
    3068                 :            : {
    3069                 :        110 : };
    3070                 :            : 
    3071                 :            : 
    3072                 :        907 : void DffRecordManager::Consume( SvStream& rIn, sal_Bool bAppend, sal_uInt32 nStOfs )
    3073                 :            : {
    3074         [ +  - ]:        907 :     if ( !bAppend )
    3075                 :        907 :         Clear();
    3076                 :        907 :     sal_uInt32 nOldPos = rIn.Tell();
    3077         [ +  + ]:        907 :     if ( !nStOfs )
    3078                 :            :     {
    3079                 :        904 :         DffRecordHeader aHd;
    3080         [ +  - ]:        904 :         rIn >> aHd;
    3081         [ +  - ]:        904 :         if ( aHd.nRecVer == DFF_PSFLAG_CONTAINER )
    3082                 :        904 :             nStOfs = aHd.GetRecEndFilePos();
    3083                 :            :     }
    3084         [ +  - ]:        907 :     if ( nStOfs )
    3085                 :            :     {
    3086                 :        907 :         pCList = (DffRecordList*)this;
    3087         [ -  + ]:        907 :         while ( pCList->pNext )
    3088                 :          0 :             pCList = pCList->pNext;
    3089 [ +  - ][ +  + ]:       4963 :         while ( ( rIn.GetError() == 0 ) && ( ( rIn.Tell() + 8 ) <=  nStOfs ) )
                 [ +  + ]
    3090                 :            :         {
    3091         [ -  + ]:       4056 :             if ( pCList->nCount == DFF_RECORD_MANAGER_BUF_SIZE )
    3092                 :          0 :                 pCList = new DffRecordList( pCList );
    3093                 :       4056 :             rIn >> pCList->mHd[ pCList->nCount ];
    3094                 :       4056 :             bool bSeekSucceeded = pCList->mHd[ pCList->nCount++ ].SeekToEndOfRecord(rIn);
    3095         [ -  + ]:       4056 :             if (!bSeekSucceeded)
    3096                 :          0 :                 break;
    3097                 :            :         }
    3098                 :        907 :         rIn.Seek( nOldPos );
    3099                 :            :     }
    3100                 :        907 : }
    3101                 :            : 
    3102                 :        907 : void DffRecordManager::Clear()
    3103                 :            : {
    3104                 :        907 :     pCList = (DffRecordList*)this;
    3105         [ -  + ]:        907 :     delete pNext, pNext = NULL;
    3106                 :        907 :     nCurrent = 0;
    3107                 :        907 :     nCount = 0;
    3108                 :        907 : }
    3109                 :            : 
    3110                 :       3860 : DffRecordHeader* DffRecordManager::Current()
    3111                 :            : {
    3112                 :       3860 :     DffRecordHeader* pRet = NULL;
    3113         [ +  - ]:       3860 :     if ( pCList->nCurrent < pCList->nCount )
    3114                 :       3860 :         pRet = &pCList->mHd[ pCList->nCurrent ];
    3115                 :       3860 :     return pRet;
    3116                 :            : }
    3117                 :            : 
    3118                 :       3531 : DffRecordHeader* DffRecordManager::First()
    3119                 :            : {
    3120                 :       3531 :     DffRecordHeader* pRet = NULL;
    3121                 :       3531 :     pCList = (DffRecordList*)this;
    3122         [ +  + ]:       3531 :     if ( pCList->nCount )
    3123                 :            :     {
    3124                 :       3522 :         pCList->nCurrent = 0;
    3125                 :       3522 :         pRet = &pCList->mHd[ 0 ];
    3126                 :            :     }
    3127                 :       3531 :     return pRet;
    3128                 :            : }
    3129                 :            : 
    3130                 :      13853 : DffRecordHeader* DffRecordManager::Next()
    3131                 :            : {
    3132                 :      13853 :     DffRecordHeader* pRet = NULL;
    3133                 :      13853 :     sal_uInt32 nC = pCList->nCurrent + 1;
    3134         [ +  + ]:      13853 :     if ( nC < pCList->nCount )
    3135                 :            :     {
    3136                 :      11271 :         pCList->nCurrent++;
    3137                 :      11271 :         pRet = &pCList->mHd[ nC ];
    3138                 :            :     }
    3139         [ -  + ]:       2582 :     else if ( pCList->pNext )
    3140                 :            :     {
    3141                 :          0 :         pCList = pCList->pNext;
    3142                 :          0 :         pCList->nCurrent = 0;
    3143                 :          0 :         pRet = &pCList->mHd[ 0 ];
    3144                 :            :     }
    3145                 :      13853 :     return pRet;
    3146                 :            : }
    3147                 :            : 
    3148                 :          0 : DffRecordHeader* DffRecordManager::Prev()
    3149                 :            : {
    3150                 :          0 :     DffRecordHeader* pRet = NULL;
    3151                 :          0 :     sal_uInt32 nCur = pCList->nCurrent;
    3152 [ #  # ][ #  # ]:          0 :     if ( !nCur && pCList->pPrev )
    3153                 :            :     {
    3154                 :          0 :         pCList = pCList->pPrev;
    3155                 :          0 :         nCur = pCList->nCount;
    3156                 :            :     }
    3157         [ #  # ]:          0 :     if ( nCur-- )
    3158                 :            :     {
    3159                 :          0 :         pCList->nCurrent = nCur;
    3160                 :          0 :         pRet = &pCList->mHd[ nCur ];
    3161                 :            :     }
    3162                 :          0 :     return pRet;
    3163                 :            : }
    3164                 :            : 
    3165                 :          0 : DffRecordHeader* DffRecordManager::Last()
    3166                 :            : {
    3167                 :          0 :     DffRecordHeader* pRet = NULL;
    3168         [ #  # ]:          0 :     while ( pCList->pNext )
    3169                 :          0 :         pCList = pCList->pNext;
    3170                 :          0 :     sal_uInt32 nCnt = pCList->nCount;
    3171         [ #  # ]:          0 :     if ( nCnt-- )
    3172                 :            :     {
    3173                 :          0 :         pCList->nCurrent = nCnt;
    3174                 :          0 :         pRet = &pCList->mHd[ nCnt ];
    3175                 :            :     }
    3176                 :          0 :     return pRet;
    3177                 :            : }
    3178                 :            : 
    3179                 :       5833 : sal_Bool DffRecordManager::SeekToContent( SvStream& rIn, sal_uInt16 nRecId, DffSeekToContentMode eMode )
    3180                 :            : {
    3181                 :       5833 :     DffRecordHeader* pHd = GetRecordHeader( nRecId, eMode );
    3182         [ +  + ]:       5833 :     if ( pHd )
    3183                 :            :     {
    3184                 :       3914 :         pHd->SeekToContent( rIn );
    3185                 :       3914 :         return sal_True;
    3186                 :            :     }
    3187                 :            :     else
    3188                 :       5833 :         return sal_False;
    3189                 :            : }
    3190                 :            : 
    3191                 :       6028 : DffRecordHeader* DffRecordManager::GetRecordHeader( sal_uInt16 nRecId, DffSeekToContentMode eMode )
    3192                 :            : {
    3193                 :       6028 :     sal_uInt32 nOldCurrent = pCList->nCurrent;
    3194                 :       6028 :     DffRecordList* pOldList = pCList;
    3195                 :            :     DffRecordHeader* pHd;
    3196                 :            : 
    3197         [ +  + ]:       6028 :     if ( eMode == SEEK_FROM_BEGINNING )
    3198                 :        994 :         pHd = First();
    3199                 :            :     else
    3200                 :       5034 :         pHd = Next();
    3201                 :            : 
    3202         [ +  + ]:       9601 :     while ( pHd )
    3203                 :            :     {
    3204         [ +  + ]:       7019 :         if ( pHd->nRecType == nRecId )
    3205                 :       3446 :             break;
    3206                 :       3573 :         pHd = Next();
    3207                 :            :     }
    3208 [ +  + ][ +  + ]:       6028 :     if ( !pHd && eMode == SEEK_FROM_CURRENT_AND_RESTART )
    3209                 :            :     {
    3210                 :       2537 :         DffRecordHeader* pBreak = &pOldList->mHd[ nOldCurrent ];
    3211                 :       2537 :         pHd = First();
    3212         [ +  + ]:       2537 :         if ( pHd )
    3213                 :            :         {
    3214         [ +  + ]:       7774 :             while ( pHd != pBreak )
    3215                 :            :             {
    3216         [ +  + ]:       5513 :                 if ( pHd->nRecType == nRecId )
    3217                 :        267 :                     break;
    3218                 :       5246 :                 pHd = Next();
    3219                 :            :             }
    3220         [ +  + ]:       2528 :             if ( pHd->nRecType != nRecId )
    3221                 :       1919 :                 pHd = NULL;
    3222                 :            :         }
    3223                 :            :     }
    3224         [ +  + ]:       6028 :     if ( !pHd )
    3225                 :            :     {
    3226                 :       1973 :         pCList = pOldList;
    3227                 :       1973 :         pOldList->nCurrent = nOldCurrent;
    3228                 :            :     }
    3229                 :       6028 :     return pHd;
    3230                 :            : }
    3231                 :            : 
    3232                 :            : //---------------------------------------------------------------------------
    3233                 :            : //  private methods
    3234                 :            : //---------------------------------------------------------------------------
    3235                 :            : 
    3236                 :       6285 : bool CompareSvxMSDffShapeInfoById::operator() (
    3237                 :            :     ::boost::shared_ptr<SvxMSDffShapeInfo> const& lhs,
    3238                 :            :     ::boost::shared_ptr<SvxMSDffShapeInfo> const& rhs) const
    3239                 :            : {
    3240                 :       6285 :     return lhs->nShapeId < rhs->nShapeId;
    3241                 :            : }
    3242                 :            : 
    3243                 :       4041 : bool CompareSvxMSDffShapeInfoByTxBxComp::operator() (
    3244                 :            :     ::boost::shared_ptr<SvxMSDffShapeInfo> const& lhs,
    3245                 :            :     ::boost::shared_ptr<SvxMSDffShapeInfo> const& rhs) const
    3246                 :            : {
    3247                 :       4041 :     return lhs->nTxBxComp < rhs->nTxBxComp;
    3248                 :            : }
    3249                 :            : 
    3250                 :       3528 : void SvxMSDffManager::Scale( sal_Int32& rVal ) const
    3251                 :            : {
    3252         [ +  + ]:       3528 :     if ( bNeedMap )
    3253                 :        648 :         rVal = BigMulDiv( rVal, nMapMul, nMapDiv );
    3254                 :       3528 : }
    3255                 :            : 
    3256                 :          0 : void SvxMSDffManager::Scale( Point& rPos ) const
    3257                 :            : {
    3258                 :          0 :     rPos.X() += nMapXOfs;
    3259                 :          0 :     rPos.Y() += nMapYOfs;
    3260         [ #  # ]:          0 :     if ( bNeedMap )
    3261                 :            :     {
    3262                 :          0 :         rPos.X() = BigMulDiv( rPos.X(), nMapMul, nMapDiv );
    3263                 :          0 :         rPos.Y() = BigMulDiv( rPos.Y(), nMapMul, nMapDiv );
    3264                 :            :     }
    3265                 :          0 : }
    3266                 :            : 
    3267                 :         84 : void SvxMSDffManager::Scale( Size& rSiz ) const
    3268                 :            : {
    3269         [ +  - ]:         84 :     if ( bNeedMap )
    3270                 :            :     {
    3271                 :         84 :         rSiz.Width() = BigMulDiv( rSiz.Width(), nMapMul, nMapDiv );
    3272                 :         84 :         rSiz.Height() = BigMulDiv( rSiz.Height(), nMapMul, nMapDiv );
    3273                 :            :     }
    3274                 :         84 : }
    3275                 :            : 
    3276                 :       1523 : void SvxMSDffManager::ScaleEmu( sal_Int32& rVal ) const
    3277                 :            : {
    3278                 :       1523 :     rVal = BigMulDiv( rVal, nEmuMul, nEmuDiv );
    3279                 :       1523 : }
    3280                 :            : 
    3281                 :          0 : sal_uInt32 SvxMSDffManager::ScalePt( sal_uInt32 nVal ) const
    3282                 :            : {
    3283                 :          0 :     MapUnit eMap = pSdrModel->GetScaleUnit();
    3284 [ #  # ][ #  # ]:          0 :     Fraction aFact( GetMapFactor( MAP_POINT, eMap ).X() );
    3285                 :          0 :     long aMul = aFact.GetNumerator();
    3286                 :          0 :     long aDiv = aFact.GetDenominator() * 65536;
    3287 [ #  # ][ #  # ]:          0 :     aFact = Fraction( aMul, aDiv ); // try again to shorten it
    3288         [ #  # ]:          0 :     return BigMulDiv( nVal, aFact.GetNumerator(), aFact.GetDenominator() );
    3289                 :            : }
    3290                 :            : 
    3291                 :        261 : sal_Int32 SvxMSDffManager::ScalePoint( sal_Int32 nVal ) const
    3292                 :            : {
    3293                 :        261 :     return BigMulDiv( nVal, nPntMul, nPntDiv );
    3294                 :            : };
    3295                 :            : 
    3296                 :        190 : void SvxMSDffManager::SetModel(SdrModel* pModel, long nApplicationScale)
    3297                 :            : {
    3298                 :        190 :     pSdrModel = pModel;
    3299 [ +  + ][ +  - ]:        190 :     if( pModel && (0 < nApplicationScale) )
    3300                 :            :     {
    3301                 :            :         // PPT arbeitet nur mit Einheiten zu 576DPI
    3302                 :            :         // WW hingegen verwendet twips, i.e. 1440DPI.
    3303                 :        133 :         MapUnit eMap = pSdrModel->GetScaleUnit();
    3304 [ +  - ][ +  - ]:        133 :         Fraction aFact( GetMapFactor(MAP_INCH, eMap).X() );
    3305                 :        133 :         long nMul=aFact.GetNumerator();
    3306                 :        133 :         long nDiv=aFact.GetDenominator()*nApplicationScale;
    3307 [ +  - ][ +  - ]:        133 :         aFact=Fraction(nMul,nDiv); // try again to shorten it
    3308                 :            :         // For 100TH_MM -> 2540/576=635/144
    3309                 :            :         // For Twip     -> 1440/576=5/2
    3310                 :        133 :         nMapMul  = aFact.GetNumerator();
    3311                 :        133 :         nMapDiv  = aFact.GetDenominator();
    3312                 :        133 :         bNeedMap = nMapMul!=nMapDiv;
    3313                 :            : 
    3314                 :            :         // MS-DFF-Properties are mostly given in EMU (English Metric Units)
    3315                 :            :         // 1mm=36000emu, 1twip=635emu
    3316 [ +  - ][ +  - ]:        133 :         aFact=GetMapFactor(MAP_100TH_MM,eMap).X();
    3317                 :        133 :         nMul=aFact.GetNumerator();
    3318                 :        133 :         nDiv=aFact.GetDenominator()*360;
    3319 [ +  - ][ +  - ]:        133 :         aFact=Fraction(nMul,nDiv); // try again to shorten it
    3320                 :            :         // For 100TH_MM ->                            1/360
    3321                 :            :         // For Twip     -> 14,40/(25,4*360)=144/91440=1/635
    3322                 :        133 :         nEmuMul=aFact.GetNumerator();
    3323                 :        133 :         nEmuDiv=aFact.GetDenominator();
    3324                 :            : 
    3325                 :            :         // And something for typographic Points
    3326 [ +  - ][ +  - ]:        133 :         aFact=GetMapFactor(MAP_POINT,eMap).X();
    3327                 :        133 :         nPntMul=aFact.GetNumerator();
    3328                 :        133 :         nPntDiv=aFact.GetDenominator();
    3329                 :            :     }
    3330                 :            :     else
    3331                 :            :     {
    3332                 :         57 :         pModel = 0;
    3333                 :         57 :         nMapMul = nMapDiv = nMapXOfs = nMapYOfs = nEmuMul = nEmuDiv = nPntMul = nPntDiv = 0;
    3334                 :         57 :         bNeedMap = sal_False;
    3335                 :            :     }
    3336                 :        190 : }
    3337                 :            : 
    3338                 :         15 : sal_Bool SvxMSDffManager::SeekToShape( SvStream& rSt, void* /* pClientData */, sal_uInt32 nId ) const
    3339                 :            : {
    3340                 :         15 :     sal_Bool bRet = sal_False;
    3341         [ +  - ]:         15 :     if ( !maFidcls.empty() )
    3342                 :            :     {
    3343                 :         15 :         sal_uInt32 nMerk = rSt.Tell();
    3344                 :         15 :         sal_uInt32 nShapeId, nSec = ( nId >> 10 ) - 1;
    3345         [ +  - ]:         15 :         if ( nSec < mnIdClusters )
    3346                 :            :         {
    3347         [ +  - ]:         15 :             OffsetMap::const_iterator it = maDgOffsetTable.find( maFidcls[ nSec ].dgid );
    3348 [ +  - ][ +  - ]:         15 :             if ( it != maDgOffsetTable.end() )
    3349                 :            :             {
    3350         [ +  - ]:         15 :                 sal_IntPtr nOfs = it->second;
    3351         [ +  - ]:         15 :                 rSt.Seek( nOfs );
    3352                 :         15 :                 DffRecordHeader aEscherF002Hd;
    3353         [ +  - ]:         15 :                 rSt >> aEscherF002Hd;
    3354                 :         15 :                 sal_uLong nEscherF002End = aEscherF002Hd.GetRecEndFilePos();
    3355                 :         15 :                 DffRecordHeader aEscherObjListHd;
    3356 [ +  - ][ +  - ]:         78 :                 while (rSt.good() && rSt.Tell() < nEscherF002End)
                 [ +  - ]
    3357                 :            :                 {
    3358         [ +  - ]:         63 :                     rSt >> aEscherObjListHd;
    3359         [ +  + ]:         63 :                     if ( aEscherObjListHd.nRecVer != 0xf )
    3360         [ +  - ]:         15 :                         aEscherObjListHd.SeekToEndOfRecord( rSt );
    3361         [ +  + ]:         48 :                     else if ( aEscherObjListHd.nRecType == DFF_msofbtSpContainer )
    3362                 :            :                     {
    3363                 :         33 :                         DffRecordHeader aShapeHd;
    3364 [ +  - ][ +  - ]:         33 :                         if ( SeekToRec( rSt, DFF_msofbtSp, aEscherObjListHd.GetRecEndFilePos(), &aShapeHd ) )
    3365                 :            :                         {
    3366         [ +  - ]:         33 :                             rSt >> nShapeId;
    3367         [ +  + ]:         33 :                             if ( nId == nShapeId )
    3368                 :            :                             {
    3369         [ +  - ]:         15 :                                 aEscherObjListHd.SeekToBegOfRecord( rSt );
    3370                 :         15 :                                 bRet = sal_True;
    3371                 :            :                                 break;
    3372                 :            :                             }
    3373                 :            :                         }
    3374         [ +  - ]:         18 :                         aEscherObjListHd.SeekToEndOfRecord( rSt );
    3375                 :            :                     }
    3376                 :            :                 }
    3377                 :            :             }
    3378                 :            :         }
    3379         [ -  + ]:         15 :         if ( !bRet )
    3380         [ #  # ]:         15 :             rSt.Seek( nMerk );
    3381                 :            :     }
    3382                 :         15 :     return bRet;
    3383                 :            : }
    3384                 :            : 
    3385                 :       1928 : bool SvxMSDffManager::SeekToRec( SvStream& rSt, sal_uInt16 nRecId, sal_uLong nMaxFilePos, DffRecordHeader* pRecHd, sal_uLong nSkipCount ) const
    3386                 :            : {
    3387                 :       1928 :     bool bRet = sal_False;
    3388                 :       1928 :     sal_uLong nFPosMerk = rSt.Tell(); // FilePos merken fuer ggf. spaetere Restauration
    3389                 :       1928 :     DffRecordHeader aHd;
    3390 [ +  + ][ +  + ]:      10650 :     do
           [ +  -  +  + ]
    3391                 :            :     {
    3392         [ +  - ]:       5328 :         rSt >> aHd;
    3393         [ -  + ]:       5328 :         if (!rSt.good())
    3394                 :          0 :             break;
    3395         [ -  + ]:       5328 :         if (aHd.nRecLen > nMaxLegalDffRecordLength)
    3396                 :          0 :             break;
    3397         [ +  + ]:       5328 :         if ( aHd.nRecType == nRecId )
    3398                 :            :         {
    3399         [ -  + ]:       1301 :             if ( nSkipCount )
    3400                 :          0 :                 nSkipCount--;
    3401                 :            :             else
    3402                 :            :             {
    3403                 :       1301 :                 bRet = sal_True;
    3404         [ +  + ]:       1301 :                 if ( pRecHd != NULL )
    3405                 :        990 :                     *pRecHd = aHd;
    3406                 :            :                 else
    3407         [ +  - ]:        311 :                     aHd.SeekToBegOfRecord( rSt );
    3408                 :            :             }
    3409                 :            :         }
    3410         [ +  + ]:       5328 :         if ( !bRet )
    3411                 :            :         {
    3412         [ +  - ]:       4027 :             bool bSeekSuccess = aHd.SeekToEndOfRecord( rSt );
    3413         [ +  + ]:       4027 :             if (!bSeekSuccess)
    3414                 :          3 :                 break;
    3415                 :            :         }
    3416                 :            :     }
    3417                 :      10650 :     while ( rSt.good() && rSt.Tell() < nMaxFilePos && !bRet );
    3418         [ +  + ]:       1928 :     if ( !bRet )
    3419         [ +  - ]:        627 :         rSt.Seek( nFPosMerk );  // restore FilePos
    3420                 :       1928 :     return bRet;
    3421                 :            : }
    3422                 :            : 
    3423                 :        144 : bool SvxMSDffManager::SeekToRec2( sal_uInt16 nRecId1, sal_uInt16 nRecId2, sal_uLong nMaxFilePos, DffRecordHeader* pRecHd, sal_uLong nSkipCount ) const
    3424                 :            : {
    3425                 :        144 :     bool bRet = sal_False;
    3426                 :        144 :     sal_uLong nFPosMerk = rStCtrl.Tell();   // FilePos merken fuer ggf. spaetere Restauration
    3427                 :        144 :     DffRecordHeader aHd;
    3428 [ -  + ][ -  + ]:        288 :     do
           [ +  -  +  + ]
    3429                 :            :     {
    3430         [ +  - ]:        144 :         rStCtrl >> aHd;
    3431 [ +  - ][ +  + ]:        144 :         if ( aHd.nRecType == nRecId1 || aHd.nRecType == nRecId2 )
    3432                 :            :         {
    3433         [ -  + ]:        105 :             if ( nSkipCount )
    3434                 :          0 :                 nSkipCount--;
    3435                 :            :             else
    3436                 :            :             {
    3437                 :        105 :                 bRet = sal_True;
    3438         [ -  + ]:        105 :                 if ( pRecHd )
    3439                 :          0 :                     *pRecHd = aHd;
    3440                 :            :                 else
    3441         [ +  - ]:        105 :                     aHd.SeekToBegOfRecord( rStCtrl );
    3442                 :            :             }
    3443                 :            :         }
    3444         [ +  + ]:        144 :         if ( !bRet )
    3445         [ +  - ]:         39 :             aHd.SeekToEndOfRecord( rStCtrl );
    3446                 :            :     }
    3447                 :        288 :     while ( rStCtrl.GetError() == 0 && rStCtrl.Tell() < nMaxFilePos && !bRet );
    3448         [ +  + ]:        144 :     if ( !bRet )
    3449         [ +  - ]:         39 :         rStCtrl.Seek( nFPosMerk ); // restore FilePos
    3450                 :        144 :     return bRet;
    3451                 :            : }
    3452                 :            : 
    3453                 :            : 
    3454                 :         18 : bool SvxMSDffManager::GetColorFromPalette( sal_uInt16 /* nNum */, Color& rColor ) const
    3455                 :            : {
    3456                 :            :     // diese Methode ist in der zum Excel-Import
    3457                 :            :     // abgeleiteten Klasse zu ueberschreiben...
    3458                 :         18 :     rColor.SetColor( COL_WHITE );
    3459                 :         18 :     return sal_True;
    3460                 :            : }
    3461                 :            : 
    3462                 :            : // sj: the documentation is not complete, especially in ppt the normal rgb for text
    3463                 :            : // color is written as 0xfeRRGGBB, this can't be explained by the documentation, nearly
    3464                 :            : // every bit in the upper code is set -> so there seems to be a special handling for
    3465                 :            : // ppt text colors, i decided not to fix this in MSO_CLR_ToColor because of possible
    3466                 :            : // side effects, instead MSO_TEXT_CLR_ToColor is called for PPT text colors, to map
    3467                 :            : // the color code to something that behaves like the other standard color codes used by
    3468                 :            : // fill and line color
    3469                 :       2385 : Color SvxMSDffManager::MSO_TEXT_CLR_ToColor( sal_uInt32 nColorCode ) const
    3470                 :            : {
    3471                 :            :     // for text colors: Header is 0xfeRRGGBB
    3472         [ +  + ]:       2385 :     if ( ( nColorCode & 0xfe000000 ) == 0xfe000000 )
    3473                 :       2040 :         nColorCode &= 0x00ffffff;
    3474                 :            :     else
    3475                 :            :     {
    3476                 :            :         // for colorscheme colors the color index are the lower three bits of the upper byte
    3477         [ +  + ]:        345 :         if ( ( nColorCode & 0xf8000000 ) == 0 ) // this must be a colorscheme index
    3478                 :            :         {
    3479                 :        285 :             nColorCode >>= 24;
    3480                 :        285 :             nColorCode |= 0x8000000;
    3481                 :            :         }
    3482                 :            :     }
    3483                 :       2385 :     return MSO_CLR_ToColor( nColorCode );
    3484                 :            : }
    3485                 :            : 
    3486                 :       6753 : Color SvxMSDffManager::MSO_CLR_ToColor( sal_uInt32 nColorCode, sal_uInt16 nContentProperty ) const
    3487                 :            : {
    3488                 :       6753 :     Color aColor( mnDefaultColor );
    3489                 :            : 
    3490                 :            :     // for text colors: Header is 0xfeRRGGBB
    3491         [ -  + ]:       6753 :     if ( ( nColorCode & 0xfe000000 ) == 0xfe000000 )    // sj: it needs to be checked if 0xfe is used in
    3492                 :          0 :         nColorCode &= 0x00ffffff;                       // other cases than ppt text -> if not this code can be removed
    3493                 :            : 
    3494                 :       6753 :     sal_uInt8 nUpper = (sal_uInt8)( nColorCode >> 24 );
    3495                 :            : 
    3496                 :            :     // sj: below change from 0x1b to 0x19 was done because of i84812 (0x02 -> rgb color),
    3497                 :            :     // now I have some problems to fix i104685 (there the color value is 0x02000000 whichs requires
    3498                 :            :     // a 0x2 scheme color to be displayed properly), the color docu seems to be incomplete
    3499         [ +  + ]:       6753 :     if( nUpper & 0x19 )      // if( nUpper & 0x1f )
    3500                 :            :     {
    3501 [ -  + ][ #  # ]:        936 :         if( ( nUpper & 0x08 ) || ( ( nUpper & 0x10 ) == 0 ) )
    3502                 :            :         {
    3503                 :            :             // SCHEMECOLOR
    3504 [ +  - ][ -  + ]:        936 :             if ( !GetColorFromPalette( ( nUpper & 8 ) ? (sal_uInt16)nColorCode : nUpper, aColor ) )
    3505                 :            :             {
    3506      [ #  #  # ]:          0 :                 switch( nContentProperty )
    3507                 :            :                 {
    3508                 :            :                     case DFF_Prop_pictureTransparent :
    3509                 :            :                     case DFF_Prop_shadowColor :
    3510                 :            :                     case DFF_Prop_fillBackColor :
    3511                 :            :                     case DFF_Prop_fillColor :
    3512                 :          0 :                         aColor = Color( COL_WHITE );
    3513                 :          0 :                     break;
    3514                 :            :                     case DFF_Prop_lineColor :
    3515                 :            :                     {
    3516                 :          0 :                         aColor = Color( COL_BLACK );
    3517                 :            :                     }
    3518                 :          0 :                     break;
    3519                 :            :                 }
    3520                 :            :             }
    3521                 :            :         }
    3522                 :            :         else    // SYSCOLOR
    3523                 :            :         {
    3524                 :          0 :             const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    3525                 :            : 
    3526                 :          0 :             sal_uInt16 nParameter = sal_uInt16(( nColorCode >> 16 ) & 0x00ff);  // the HiByte of nParameter is not zero, an exclusive AND is helping :o
    3527                 :          0 :             sal_uInt16 nFunctionBits = (sal_uInt16)( ( nColorCode & 0x00000f00 ) >> 8 );
    3528                 :          0 :             sal_uInt16 nAdditionalFlags = (sal_uInt16)( ( nColorCode & 0x0000f000) >> 8 );
    3529                 :          0 :             sal_uInt16 nColorIndex = sal_uInt16(nColorCode & 0x00ff);
    3530                 :          0 :             sal_uInt32 nPropColor = 0;
    3531                 :            : 
    3532                 :          0 :             sal_uInt16  nCProp = 0;
    3533                 :            : 
    3534   [ #  #  #  #  :          0 :             switch ( nColorIndex )
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
    3535                 :            :             {
    3536                 :          0 :                 case mso_syscolorButtonFace :           aColor = rStyleSettings.GetFaceColor(); break;
    3537                 :          0 :                 case mso_syscolorWindowText :           aColor = rStyleSettings.GetWindowTextColor(); break;
    3538                 :          0 :                 case mso_syscolorMenu :                 aColor = rStyleSettings.GetMenuColor(); break;
    3539                 :            :                 case mso_syscolor3DLight :
    3540                 :            :                 case mso_syscolorButtonHighlight :
    3541                 :          0 :                 case mso_syscolorHighlight :            aColor = rStyleSettings.GetHighlightColor(); break;
    3542                 :          0 :                 case mso_syscolorHighlightText :        aColor = rStyleSettings.GetHighlightTextColor(); break;
    3543                 :          0 :                 case mso_syscolorCaptionText :          aColor = rStyleSettings.GetMenuTextColor(); break;
    3544                 :          0 :                 case mso_syscolorActiveCaption :        aColor = rStyleSettings.GetHighlightColor(); break;
    3545                 :          0 :                 case mso_syscolorButtonShadow :         aColor = rStyleSettings.GetShadowColor(); break;
    3546                 :          0 :                 case mso_syscolorButtonText :           aColor = rStyleSettings.GetButtonTextColor(); break;
    3547                 :          0 :                 case mso_syscolorGrayText :             aColor = rStyleSettings.GetDeactiveColor(); break;
    3548                 :          0 :                 case mso_syscolorInactiveCaption :      aColor = rStyleSettings.GetDeactiveColor(); break;
    3549                 :          0 :                 case mso_syscolorInactiveCaptionText :  aColor = rStyleSettings.GetDeactiveColor(); break;
    3550                 :          0 :                 case mso_syscolorInfoBackground :       aColor = rStyleSettings.GetFaceColor(); break;
    3551                 :          0 :                 case mso_syscolorInfoText :             aColor = rStyleSettings.GetInfoTextColor(); break;
    3552                 :          0 :                 case mso_syscolorMenuText :             aColor = rStyleSettings.GetMenuTextColor(); break;
    3553                 :          0 :                 case mso_syscolorScrollbar :            aColor = rStyleSettings.GetFaceColor(); break;
    3554                 :          0 :                 case mso_syscolorWindow :               aColor = rStyleSettings.GetWindowColor(); break;
    3555                 :          0 :                 case mso_syscolorWindowFrame :          aColor = rStyleSettings.GetWindowColor(); break;
    3556                 :            : 
    3557                 :            :                 case mso_colorFillColor :
    3558                 :            :                 {
    3559                 :          0 :                     nPropColor = GetPropertyValue( DFF_Prop_fillColor, 0xffffff );
    3560                 :          0 :                     nCProp = DFF_Prop_fillColor;
    3561                 :            :                 }
    3562                 :          0 :                 break;
    3563                 :            :                 case mso_colorLineOrFillColor :     // ( use the line color only if there is a line )
    3564                 :            :                 {
    3565         [ #  # ]:          0 :                     if ( GetPropertyValue( DFF_Prop_fNoLineDrawDash ) & 8 )
    3566                 :            :                     {
    3567                 :          0 :                         nPropColor = GetPropertyValue( DFF_Prop_lineColor, 0 );
    3568                 :          0 :                         nCProp = DFF_Prop_lineColor;
    3569                 :            :                     }
    3570                 :            :                     else
    3571                 :            :                     {
    3572                 :          0 :                         nPropColor = GetPropertyValue( DFF_Prop_fillColor, 0xffffff );
    3573                 :          0 :                         nCProp = DFF_Prop_fillColor;
    3574                 :            :                     }
    3575                 :            :                 }
    3576                 :          0 :                 break;
    3577                 :            :                 case mso_colorLineColor :
    3578                 :            :                 {
    3579                 :          0 :                     nPropColor = GetPropertyValue( DFF_Prop_lineColor, 0 );
    3580                 :          0 :                     nCProp = DFF_Prop_lineColor;
    3581                 :            :                 }
    3582                 :          0 :                 break;
    3583                 :            :                 case mso_colorShadowColor :
    3584                 :            :                 {
    3585                 :          0 :                     nPropColor = GetPropertyValue( DFF_Prop_shadowColor, 0x808080 );
    3586                 :          0 :                     nCProp = DFF_Prop_shadowColor;
    3587                 :            :                 }
    3588                 :          0 :                 break;
    3589                 :            :                 case mso_colorThis :                // ( use this color ... )
    3590                 :            :                 {
    3591                 :          0 :                     nPropColor = GetPropertyValue( DFF_Prop_fillColor, 0xffffff );  //?????????????
    3592                 :          0 :                     nCProp = DFF_Prop_fillColor;
    3593                 :            :                 }
    3594                 :          0 :                 break;
    3595                 :            :                 case mso_colorFillBackColor :
    3596                 :            :                 {
    3597                 :          0 :                     nPropColor = GetPropertyValue( DFF_Prop_fillBackColor, 0xffffff );
    3598                 :          0 :                     nCProp = DFF_Prop_fillBackColor;
    3599                 :            :                 }
    3600                 :          0 :                 break;
    3601                 :            :                 case mso_colorLineBackColor :
    3602                 :            :                 {
    3603                 :          0 :                     nPropColor = GetPropertyValue( DFF_Prop_lineBackColor, 0xffffff );
    3604                 :          0 :                     nCProp = DFF_Prop_lineBackColor;
    3605                 :            :                 }
    3606                 :          0 :                 break;
    3607                 :            :                 case mso_colorFillThenLine :        // ( use the fillcolor unless no fill and line )
    3608                 :            :                 {
    3609                 :          0 :                     nPropColor = GetPropertyValue( DFF_Prop_fillColor, 0xffffff );  //?????????????
    3610                 :          0 :                     nCProp = DFF_Prop_fillColor;
    3611                 :            :                 }
    3612                 :          0 :                 break;
    3613                 :            :                 case mso_colorIndexMask :           // ( extract the color index ) ?
    3614                 :            :                 {
    3615                 :          0 :                     nPropColor = GetPropertyValue( DFF_Prop_fillColor, 0xffffff );  //?????????????
    3616                 :          0 :                     nCProp = DFF_Prop_fillColor;
    3617                 :            :                 }
    3618                 :          0 :                 break;
    3619                 :            :             }
    3620 [ #  # ][ #  # ]:          0 :             if ( nCProp && ( nPropColor & 0x10000000 ) == 0 )       // beware of looping recursive
    3621                 :          0 :                 aColor = MSO_CLR_ToColor( nPropColor, nCProp );
    3622                 :            : 
    3623         [ #  # ]:          0 :             if( nAdditionalFlags & 0x80 )           // make color gray
    3624                 :            :             {
    3625                 :          0 :                 sal_uInt8 nZwi = aColor.GetLuminance();
    3626                 :          0 :                 aColor = Color( nZwi, nZwi, nZwi );
    3627                 :            :             }
    3628   [ #  #  #  #  :          0 :             switch( nFunctionBits )
                #  #  # ]
    3629                 :            :             {
    3630                 :            :                 case 0x01 :     // darken color by parameter
    3631                 :            :                 {
    3632                 :          0 :                     aColor.SetRed( sal::static_int_cast< sal_uInt8 >( ( nParameter * aColor.GetRed() ) >> 8 ) );
    3633                 :          0 :                     aColor.SetGreen( sal::static_int_cast< sal_uInt8 >( ( nParameter * aColor.GetGreen() ) >> 8 ) );
    3634                 :          0 :                     aColor.SetBlue( sal::static_int_cast< sal_uInt8 >( ( nParameter * aColor.GetBlue() ) >> 8 ) );
    3635                 :            :                 }
    3636                 :          0 :                 break;
    3637                 :            :                 case 0x02 :     // lighten color by parameter
    3638                 :            :                 {
    3639                 :          0 :                     sal_uInt16 nInvParameter = ( 0x00ff - nParameter ) * 0xff;
    3640                 :          0 :                     aColor.SetRed( sal::static_int_cast< sal_uInt8 >( ( nInvParameter + ( nParameter * aColor.GetRed() ) ) >> 8 ) );
    3641                 :          0 :                     aColor.SetGreen( sal::static_int_cast< sal_uInt8 >( ( nInvParameter + ( nParameter * aColor.GetGreen() ) ) >> 8 ) );
    3642                 :          0 :                     aColor.SetBlue( sal::static_int_cast< sal_uInt8 >( ( nInvParameter + ( nParameter * aColor.GetBlue() ) ) >> 8 ) );
    3643                 :            :                 }
    3644                 :          0 :                 break;
    3645                 :            :                 case 0x03 :     // add grey level RGB(p,p,p)
    3646                 :            :                 {
    3647                 :          0 :                     sal_Int16 nR = (sal_Int16)aColor.GetRed() + (sal_Int16)nParameter;
    3648                 :          0 :                     sal_Int16 nG = (sal_Int16)aColor.GetGreen() + (sal_Int16)nParameter;
    3649                 :          0 :                     sal_Int16 nB = (sal_Int16)aColor.GetBlue() + (sal_Int16)nParameter;
    3650         [ #  # ]:          0 :                     if ( nR > 0x00ff )
    3651                 :          0 :                         nR = 0x00ff;
    3652         [ #  # ]:          0 :                     if ( nG > 0x00ff )
    3653                 :          0 :                         nG = 0x00ff;
    3654         [ #  # ]:          0 :                     if ( nB > 0x00ff )
    3655                 :          0 :                         nB = 0x00ff;
    3656                 :          0 :                     aColor = Color( (sal_uInt8)nR, (sal_uInt8)nG, (sal_uInt8)nB );
    3657                 :            :                 }
    3658                 :          0 :                 break;
    3659                 :            :                 case 0x04 :     // substract grey level RGB(p,p,p)
    3660                 :            :                 {
    3661                 :          0 :                     sal_Int16 nR = (sal_Int16)aColor.GetRed() - (sal_Int16)nParameter;
    3662                 :          0 :                     sal_Int16 nG = (sal_Int16)aColor.GetGreen() - (sal_Int16)nParameter;
    3663                 :          0 :                     sal_Int16 nB = (sal_Int16)aColor.GetBlue() - (sal_Int16)nParameter;
    3664         [ #  # ]:          0 :                     if ( nR < 0 )
    3665                 :          0 :                         nR = 0;
    3666         [ #  # ]:          0 :                     if ( nG < 0 )
    3667                 :          0 :                         nG = 0;
    3668         [ #  # ]:          0 :                     if ( nB < 0 )
    3669                 :          0 :                         nB = 0;
    3670                 :          0 :                     aColor = Color( (sal_uInt8)nR, (sal_uInt8)nG, (sal_uInt8)nB );
    3671                 :            :                 }
    3672                 :          0 :                 break;
    3673                 :            :                 case 0x05 :     // substract from gray level RGB(p,p,p)
    3674                 :            :                 {
    3675                 :          0 :                     sal_Int16 nR = (sal_Int16)nParameter - (sal_Int16)aColor.GetRed();
    3676                 :          0 :                     sal_Int16 nG = (sal_Int16)nParameter - (sal_Int16)aColor.GetGreen();
    3677                 :          0 :                     sal_Int16 nB = (sal_Int16)nParameter - (sal_Int16)aColor.GetBlue();
    3678         [ #  # ]:          0 :                     if ( nR < 0 )
    3679                 :          0 :                         nR = 0;
    3680         [ #  # ]:          0 :                     if ( nG < 0 )
    3681                 :          0 :                         nG = 0;
    3682         [ #  # ]:          0 :                     if ( nB < 0 )
    3683                 :          0 :                         nB = 0;
    3684                 :          0 :                     aColor = Color( (sal_uInt8)nR, (sal_uInt8)nG, (sal_uInt8)nB );
    3685                 :            :                 }
    3686                 :          0 :                 break;
    3687                 :            :                 case 0x06 :     // per component: black if < p, white if >= p
    3688                 :            :                 {
    3689         [ #  # ]:          0 :                     aColor.SetRed( aColor.GetRed() < nParameter ? 0x00 : 0xff );
    3690         [ #  # ]:          0 :                     aColor.SetGreen( aColor.GetGreen() < nParameter ? 0x00 : 0xff );
    3691         [ #  # ]:          0 :                     aColor.SetBlue( aColor.GetBlue() < nParameter ? 0x00 : 0xff );
    3692                 :            :                 }
    3693                 :          0 :                 break;
    3694                 :            :             }
    3695         [ #  # ]:          0 :             if ( nAdditionalFlags & 0x40 )                  // top-bit invert
    3696                 :          0 :                 aColor = Color( aColor.GetRed() ^ 0x80, aColor.GetGreen() ^ 0x80, aColor.GetBlue() ^ 0x80 );
    3697                 :            : 
    3698         [ #  # ]:          0 :             if ( nAdditionalFlags & 0x20 )                  // invert color
    3699                 :        936 :                 aColor = Color(0xff - aColor.GetRed(), 0xff - aColor.GetGreen(), 0xff - aColor.GetBlue());
    3700                 :            :         }
    3701                 :            :     }
    3702 [ -  + ][ #  # ]:       5817 :     else if ( ( nUpper & 4 ) && ( ( nColorCode & 0xfffff8 ) == 0 ) )
    3703                 :            :     {   // case of nUpper == 4 powerpoint takes this as agrument for a colorschemecolor
    3704                 :          0 :         GetColorFromPalette( nUpper, aColor );
    3705                 :            :     }
    3706                 :            :     else    // hart attributiert, eventuell mit Hinweis auf SYSTEMRGB
    3707                 :       5817 :         aColor = Color( (sal_uInt8)nColorCode, (sal_uInt8)( nColorCode >> 8 ), (sal_uInt8)( nColorCode >> 16 ) );
    3708                 :       6753 :     return aColor;
    3709                 :            : }
    3710                 :            : 
    3711                 :          0 : rtl::OUString SvxMSDffManager::ReadDffString(SvStream& rSt, DffRecordHeader aStrHd)
    3712                 :            : {
    3713         [ #  # ]:          0 :     String aRet;
    3714 [ #  # ][ #  # ]:          0 :     if( aStrHd.nRecType == 0x0 && !ReadCommonRecordHeader(aStrHd, rSt) )
         [ #  # ][ #  # ]
    3715         [ #  # ]:          0 :         rSt.Seek( aStrHd.nFilePos );
    3716 [ #  # ][ #  # ]:          0 :     else if ( aStrHd.nRecType == DFF_PST_TextBytesAtom || aStrHd.nRecType == DFF_PST_TextCharsAtom )
    3717                 :            :     {
    3718                 :          0 :         bool bUniCode=aStrHd.nRecType==DFF_PST_TextCharsAtom;
    3719                 :          0 :         sal_uInt32 nBytes = aStrHd.nRecLen;
    3720 [ #  # ][ #  # ]:          0 :         aRet = MSDFFReadZString( rSt, nBytes, bUniCode );
    3721         [ #  # ]:          0 :         if( !bUniCode )
    3722                 :            :         {
    3723         [ #  # ]:          0 :             for ( xub_StrLen n = 0; n < nBytes; n++ )
    3724                 :            :             {
    3725         [ #  # ]:          0 :                 if( aRet.GetChar( n ) == 0x0B )
    3726         [ #  # ]:          0 :                     aRet.SetChar( n, ' ' );     // Weicher Umbruch
    3727                 :            :                 // TODO: Zeilenumbruch im Absatz via Outliner setzen.
    3728                 :            :             }
    3729                 :            :         }
    3730         [ #  # ]:          0 :         aStrHd.SeekToEndOfRecord( rSt );
    3731                 :            :     }
    3732                 :            :     else
    3733         [ #  # ]:          0 :         aStrHd.SeekToBegOfRecord( rSt );
    3734 [ #  # ][ #  # ]:          0 :     return aRet;
    3735                 :            : }
    3736                 :            : 
    3737                 :            : // sj: I just want to set a string for a text object that may contain multiple
    3738                 :            : // paragraphs. If I now take a look at the follwing code I get the impression that
    3739                 :            : // our outliner is too complicate to be used properly,
    3740                 :          0 : void SvxMSDffManager::ReadObjText( const String& rText, SdrObject* pObj ) const
    3741                 :            : {
    3742 [ #  # ][ #  # ]:          0 :     SdrTextObj* pText = PTR_CAST( SdrTextObj, pObj );
    3743         [ #  # ]:          0 :     if ( pText )
    3744                 :            :     {
    3745                 :          0 :         SdrOutliner& rOutliner = pText->ImpGetDrawOutliner();
    3746                 :          0 :         rOutliner.Init( OUTLINERMODE_TEXTOBJECT );
    3747                 :            : 
    3748                 :          0 :         sal_Bool bOldUpdateMode = rOutliner.GetUpdateMode();
    3749                 :          0 :         rOutliner.SetUpdateMode( sal_False );
    3750                 :          0 :         rOutliner.SetVertical( pText->IsVerticalWriting() );
    3751                 :            : 
    3752                 :          0 :         sal_uInt16 nParaIndex = 0;
    3753                 :            :         sal_Int32 nParaSize;
    3754                 :          0 :         const sal_Unicode* pCurrent, *pBuf = rText.GetBuffer();
    3755                 :          0 :         const sal_Unicode* pEnd = rText.GetBuffer() + rText.Len();
    3756                 :            : 
    3757         [ #  # ]:          0 :         while( pBuf < pEnd )
    3758                 :            :         {
    3759                 :          0 :             pCurrent = pBuf;
    3760                 :            : 
    3761         [ #  # ]:          0 :             for ( nParaSize = 0; pBuf < pEnd; )
    3762                 :            :             {
    3763                 :          0 :                 sal_Unicode nChar = *pBuf++;
    3764         [ #  # ]:          0 :                 if ( nChar == 0xa )
    3765                 :            :                 {
    3766 [ #  # ][ #  # ]:          0 :                     if ( ( pBuf < pEnd ) && ( *pBuf == 0xd ) )
    3767                 :          0 :                         pBuf++;
    3768                 :          0 :                     break;
    3769                 :            :                 }
    3770         [ #  # ]:          0 :                 else if ( nChar == 0xd )
    3771                 :            :                 {
    3772 [ #  # ][ #  # ]:          0 :                     if ( ( pBuf < pEnd ) && ( *pBuf == 0xa ) )
    3773                 :          0 :                         pBuf++;
    3774                 :          0 :                     break;
    3775                 :            :                 }
    3776                 :            :                 else
    3777                 :          0 :                     ++nParaSize;
    3778                 :            :             }
    3779                 :          0 :             ESelection aSelection( nParaIndex, 0, nParaIndex, 0 );
    3780                 :          0 :             rtl::OUString aParagraph( pCurrent, nParaSize );
    3781 [ #  # ][ #  # ]:          0 :             if ( !nParaIndex && aParagraph.isEmpty() )              // SJ: we are crashing if the first paragraph is empty ?
                 [ #  # ]
    3782                 :          0 :                 aParagraph += rtl::OUString(' ');                   // otherwise these two lines can be removed.
    3783 [ #  # ][ #  # ]:          0 :             rOutliner.Insert( aParagraph, nParaIndex, 0 );
                 [ #  # ]
    3784 [ #  # ][ #  # ]:          0 :             rOutliner.SetParaAttribs( nParaIndex, rOutliner.GetEmptyItemSet() );
    3785                 :            : 
    3786 [ #  # ][ #  # ]:          0 :             SfxItemSet aParagraphAttribs( rOutliner.GetEmptyItemSet() );
    3787         [ #  # ]:          0 :             if ( !aSelection.nStartPos )
    3788 [ #  # ][ #  # ]:          0 :                 aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, sal_False ) );
                 [ #  # ]
    3789                 :          0 :             aSelection.nStartPos = 0;
    3790         [ #  # ]:          0 :             rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection );
    3791                 :          0 :             nParaIndex++;
    3792         [ #  # ]:          0 :         }
    3793                 :          0 :         OutlinerParaObject* pNewText = rOutliner.CreateParaObject();
    3794                 :          0 :         rOutliner.Clear();
    3795                 :          0 :         rOutliner.SetUpdateMode( bOldUpdateMode );
    3796                 :          0 :         pText->SetOutlinerParaObject( pNewText );
    3797                 :            :     }
    3798                 :          0 : }
    3799                 :            : 
    3800                 :          0 : bool SvxMSDffManager::ReadObjText(SvStream& rSt, SdrObject* pObj)
    3801                 :            : {
    3802                 :          0 :     bool bRet=sal_False;
    3803 [ #  # ][ #  # ]:          0 :     SdrTextObj* pText = PTR_CAST(SdrTextObj, pObj);
    3804         [ #  # ]:          0 :     if( pText )
    3805                 :            :     {
    3806                 :          0 :         DffRecordHeader aTextHd;
    3807 [ #  # ][ #  # ]:          0 :         if( !ReadCommonRecordHeader(aTextHd, rSt) )
    3808         [ #  # ]:          0 :             rSt.Seek( aTextHd.nFilePos );
    3809 [ #  # ][ #  # ]:          0 :         else if ( aTextHd.nRecType==DFF_msofbtClientTextbox || aTextHd.nRecType == 0x1022 )
    3810                 :            :         {
    3811                 :          0 :             bRet=sal_True;
    3812                 :          0 :             sal_uLong nRecEnd=aTextHd.GetRecEndFilePos();
    3813                 :          0 :             DffRecordHeader aHd;
    3814         [ #  # ]:          0 :             String aText;
    3815                 :            : 
    3816         [ #  # ]:          0 :             SdrOutliner& rOutliner=pText->ImpGetDrawOutliner();
    3817                 :          0 :             sal_uInt16 nOutlMode = rOutliner.GetMode();
    3818                 :            : 
    3819                 :            :             {   // apparently a small bug in the EditEngine which causes
    3820                 :            :                 // the paragraph attributes not to be delted on Clear()
    3821                 :          0 :                 bool bClearParaAttribs = true;
    3822         [ #  # ]:          0 :                 rOutliner.SetStyleSheet( 0, NULL );
    3823 [ #  # ][ #  # ]:          0 :                 SfxItemSet aSet(rOutliner.GetEmptyItemSet());
    3824 [ #  # ][ #  # ]:          0 :                 aSet.Put(SvxColorItem( COL_BLACK ));
                 [ #  # ]
    3825         [ #  # ]:          0 :                 rOutliner.SetParaAttribs(0,aSet);
    3826         [ #  # ]:          0 :                 pText->SetMergedItemSet(aSet);
    3827                 :            : 
    3828                 :          0 :                 bClearParaAttribs = sal_False;
    3829         [ #  # ]:          0 :                 if( bClearParaAttribs )
    3830                 :            :                 {
    3831                 :            :                     // apparently a small bug in the EditEngine which causes
    3832                 :            :                     // the paragraph attributes not to be delted on Clear()
    3833 [ #  # ][ #  # ]:          0 :                     rOutliner.SetParaAttribs(0,rOutliner.GetEmptyItemSet());
    3834         [ #  # ]:          0 :                 }
    3835                 :            :             }
    3836         [ #  # ]:          0 :             rOutliner.Init( OUTLINERMODE_TEXTOBJECT );
    3837                 :            : 
    3838                 :            :             ///////////////////////////////////
    3839                 :            :             // read TextString and MetaChars //
    3840                 :            :             ///////////////////////////////////
    3841         [ #  # ]:          0 :             do
           [ #  #  #  # ]
    3842                 :            :             {
    3843 [ #  # ][ #  # ]:          0 :                 if( !ReadCommonRecordHeader(aHd, rSt) )
    3844         [ #  # ]:          0 :                     rSt.Seek( aHd.nFilePos );
    3845                 :            :                 else
    3846                 :            :                 {
    3847      [ #  #  # ]:          0 :                     switch (aHd.nRecType)
    3848                 :            :                     {
    3849                 :            :                         default:
    3850                 :          0 :                             break;
    3851                 :            :                         //case DFF_PST_TextHeaderAtom:
    3852                 :            :                         //case TextSpecInfoAtom
    3853                 :            :                         case DFF_PST_TextBytesAtom:
    3854                 :            :                         case DFF_PST_TextCharsAtom:
    3855 [ #  # ][ #  # ]:          0 :                             aText = ReadDffString(rSt, aHd);
    3856                 :          0 :                             break;
    3857                 :            :                         case DFF_PST_TextRulerAtom               :
    3858                 :            :                         {
    3859                 :          0 :                             sal_uInt16 nLen = (sal_uInt16)aHd.nRecLen;
    3860         [ #  # ]:          0 :                             if(nLen)
    3861                 :            :                             {
    3862                 :            :                                 sal_uInt32 nMask;
    3863                 :            :                                 sal_uInt16 nVal1, nVal2, nVal3;
    3864                 :          0 :                                 sal_uInt16 nDefaultTab = 2540; // PPT def: 1 Inch //rOutliner.GetDefTab();
    3865                 :          0 :                                 sal_uInt16 nMostrightTab = 0;
    3866 [ #  # ][ #  # ]:          0 :                                 SfxItemSet aSet(rOutliner.GetEmptyItemSet());
    3867         [ #  # ]:          0 :                                 SvxTabStopItem aTabItem(0, 0, SVX_TAB_ADJUST_DEFAULT, EE_PARA_TABS);
    3868                 :            : 
    3869         [ #  # ]:          0 :                                 rSt >> nMask;
    3870                 :          0 :                                 nLen -= 4;
    3871                 :            : 
    3872 [ #  # ][ #  # ]:          0 :                                 if(nLen && (nMask & 0x0002))
    3873                 :            :                                 {
    3874                 :            :                                     // number of indent levels
    3875         [ #  # ]:          0 :                                     rSt >> nVal3;
    3876                 :          0 :                                     nLen -= 2;
    3877                 :            :                                 }
    3878                 :            : 
    3879                 :            :                                 // Allg. TAB verstellt auf Wert in nVal3
    3880 [ #  # ][ #  # ]:          0 :                                 if(nLen && (nMask & 0x0001))
    3881                 :            :                                 {
    3882         [ #  # ]:          0 :                                     rSt >> nVal3;
    3883                 :          0 :                                     nLen -= 2;
    3884                 :          0 :                                     nDefaultTab = (sal_uInt16)(((sal_uInt32)nVal3 * 1000) / 240);
    3885                 :            :                                 }
    3886                 :            : 
    3887                 :            :                                 // Weitere, frei gesetzte TABs
    3888 [ #  # ][ #  # ]:          0 :                                 if(nLen && (nMask & 0x0004))
    3889                 :            :                                 {
    3890         [ #  # ]:          0 :                                     rSt >> nVal1;
    3891                 :          0 :                                     nLen -= 2;
    3892                 :            : 
    3893                 :            :                                     // fest gesetzte TABs importieren
    3894 [ #  # ][ #  # ]:          0 :                                     while(nLen && nVal1--)
                 [ #  # ]
    3895                 :            :                                     {
    3896         [ #  # ]:          0 :                                         rSt >> nVal2;
    3897         [ #  # ]:          0 :                                         rSt >> nVal3;
    3898                 :          0 :                                         nLen -= 4;
    3899                 :            : 
    3900                 :          0 :                                         sal_uInt16 nNewTabPos = (sal_uInt16)(((sal_uInt32)nVal2 * 1000) / 240);
    3901         [ #  # ]:          0 :                                         if(nNewTabPos > nMostrightTab)
    3902                 :          0 :                                             nMostrightTab = nNewTabPos;
    3903                 :            : 
    3904         [ #  # ]:          0 :                                         SvxTabStop aTabStop(nNewTabPos);
    3905         [ #  # ]:          0 :                                         aTabItem.Insert(aTabStop);
    3906                 :            :                                     }
    3907                 :            :                                 }
    3908                 :            : 
    3909                 :            :                                 // evtl. noch default-TABs ergaenzen (immer)
    3910 [ #  # ][ #  # ]:          0 :                                 sal_uInt16 nObjWidth = sal_uInt16(pObj->GetSnapRect().GetWidth() + 1);
    3911                 :          0 :                                 sal_uInt16 nDefaultTabPos = nDefaultTab;
    3912                 :            : 
    3913 [ #  # ][ #  # ]:          0 :                                 while(nDefaultTabPos <= nObjWidth && nDefaultTabPos <= nMostrightTab)
                 [ #  # ]
    3914                 :            :                                     nDefaultTabPos =
    3915                 :          0 :                                         nDefaultTabPos + nDefaultTab;
    3916                 :            : 
    3917         [ #  # ]:          0 :                                 while(nDefaultTabPos <= nObjWidth)
    3918                 :            :                                 {
    3919         [ #  # ]:          0 :                                     SvxTabStop aTabStop(nDefaultTabPos);
    3920         [ #  # ]:          0 :                                     aTabItem.Insert(aTabStop);
    3921                 :            :                                     nDefaultTabPos =
    3922                 :          0 :                                         nDefaultTabPos + nDefaultTab;
    3923                 :            :                                 }
    3924                 :            : 
    3925                 :            :                                 // Falls TABs angelegt wurden, setze diese
    3926         [ #  # ]:          0 :                                 if(aTabItem.Count())
    3927                 :            :                                 {
    3928         [ #  # ]:          0 :                                     aSet.Put(aTabItem);
    3929         [ #  # ]:          0 :                                     rOutliner.SetParaAttribs(0, aSet);
    3930 [ #  # ][ #  # ]:          0 :                                 }
    3931                 :            :                             }
    3932                 :            :                         }
    3933                 :          0 :                         break;
    3934                 :            :                     }
    3935         [ #  # ]:          0 :                     aHd.SeekToEndOfRecord( rSt );
    3936                 :            :                 }
    3937                 :            :             }
    3938                 :          0 :             while ( rSt.GetError() == 0 && rSt.Tell() < nRecEnd );
    3939                 :            : 
    3940                 :            :             ////////////////////////
    3941                 :            :             // replace SHIFT-Ret  //
    3942                 :            :             ////////////////////////
    3943         [ #  # ]:          0 :             if ( aText.Len() )
    3944                 :            :             {
    3945         [ #  # ]:          0 :                 aText += ' ';
    3946         [ #  # ]:          0 :                 aText.SetChar( aText.Len()-1, 0x0D );
    3947 [ #  # ][ #  # ]:          0 :                 rOutliner.SetText( aText, rOutliner.GetParagraph( 0 ) );
    3948                 :            : 
    3949                 :            :                 // replace SHIFT-Ret in the Outliner
    3950 [ #  # ][ #  # ]:          0 :                 if (comphelper::string::getTokenCount(aText, 0x0B) > 1)
                 [ #  # ]
    3951                 :            :                 {
    3952         [ #  # ]:          0 :                     sal_uInt32 nParaCount = rOutliner.GetParagraphCount();
    3953         [ #  # ]:          0 :                     for(sal_uInt16 a=0;a<nParaCount;a++)
    3954                 :            :                     {
    3955         [ #  # ]:          0 :                         Paragraph* pActPara = rOutliner.GetParagraph(a);
    3956         [ #  # ]:          0 :                         String aParaText = rOutliner.GetText(pActPara);
    3957         [ #  # ]:          0 :                         for(sal_uInt16 b=0;b<aParaText.Len();b++)
    3958                 :            :                         {
    3959         [ #  # ]:          0 :                             if( aParaText.GetChar( b ) == 0x0B)
    3960                 :            :                             {
    3961                 :          0 :                                 ESelection aSelection(a, b, a, b+1);
    3962         [ #  # ]:          0 :                                 rOutliner.QuickInsertLineBreak(aSelection);
    3963                 :            :                             }
    3964                 :            :                         }
    3965         [ #  # ]:          0 :                     }
    3966                 :            :                 }
    3967                 :            :             }
    3968         [ #  # ]:          0 :             OutlinerParaObject* pNewText=rOutliner.CreateParaObject();
    3969         [ #  # ]:          0 :             rOutliner.Init( nOutlMode );
    3970 [ #  # ][ #  # ]:          0 :             pText->NbcSetOutlinerParaObject(pNewText);
    3971                 :            :         }
    3972                 :            :         else
    3973         [ #  # ]:          0 :             aTextHd.SeekToBegOfRecord(rSt);
    3974                 :            : 
    3975                 :            :     }
    3976                 :          0 :     return bRet;
    3977                 :            : }
    3978                 :            : 
    3979                 :            : //static
    3980                 :         27 : rtl::OUString SvxMSDffManager::MSDFFReadZString(SvStream& rIn,
    3981                 :            :     sal_uInt32 nLen, bool bUniCode)
    3982                 :            : {
    3983         [ -  + ]:         27 :     if (!nLen)
    3984                 :          0 :         return rtl::OUString();
    3985                 :            : 
    3986                 :         27 :     rtl::OUString sBuf;
    3987                 :            : 
    3988         [ +  - ]:         27 :     if( bUniCode )
    3989         [ +  - ]:         27 :         sBuf = read_uInt16s_ToOUString(rIn, nLen/2);
    3990                 :            :     else
    3991         [ #  # ]:          0 :         sBuf = read_uInt8s_ToOUString(rIn, nLen, RTL_TEXTENCODING_MS_1252);
    3992                 :            : 
    3993         [ +  - ]:         27 :     return comphelper::string::stripEnd(sBuf, 0);
    3994                 :            : }
    3995                 :            : 
    3996                 :          0 : static Size lcl_GetPrefSize(const Graphic& rGraf, MapMode aWanted)
    3997                 :            : {
    3998         [ #  # ]:          0 :     MapMode aPrefMapMode(rGraf.GetPrefMapMode());
    3999 [ #  # ][ #  # ]:          0 :     if (aPrefMapMode == aWanted)
    4000         [ #  # ]:          0 :         return rGraf.GetPrefSize();
    4001                 :          0 :     Size aRetSize;
    4002 [ #  # ][ #  # ]:          0 :     if (aPrefMapMode == MAP_PIXEL)
         [ #  # ][ #  # ]
    4003                 :            :     {
    4004                 :            :         aRetSize = Application::GetDefaultDevice()->PixelToLogic(
    4005 [ #  # ][ #  # ]:          0 :             rGraf.GetPrefSize(), aWanted);
                 [ #  # ]
    4006                 :            :     }
    4007                 :            :     else
    4008                 :            :     {
    4009         [ #  # ]:          0 :         aRetSize = Application::GetDefaultDevice()->LogicToLogic(
    4010 [ #  # ][ #  # ]:          0 :             rGraf.GetPrefSize(), rGraf.GetPrefMapMode(), aWanted);
         [ #  # ][ #  # ]
    4011                 :            :     }
    4012         [ #  # ]:          0 :     return aRetSize;
    4013                 :            : }
    4014                 :            : 
    4015                 :            : // sj: if the parameter pSet is null, then the resulting crop bitmap will be stored in rGraf,
    4016                 :            : // otherwise rGraf is untouched and pSet is used to store the corresponding SdrGrafCropItem
    4017                 :         23 : static void lcl_ApplyCropping( const DffPropSet& rPropSet, SfxItemSet* pSet, Graphic& rGraf )
    4018                 :            : {
    4019                 :         23 :     sal_Int32 nCropTop      = (sal_Int32)rPropSet.GetPropertyValue( DFF_Prop_cropFromTop, 0 );
    4020                 :         23 :     sal_Int32 nCropBottom   = (sal_Int32)rPropSet.GetPropertyValue( DFF_Prop_cropFromBottom, 0 );
    4021                 :         23 :     sal_Int32 nCropLeft     = (sal_Int32)rPropSet.GetPropertyValue( DFF_Prop_cropFromLeft, 0 );
    4022                 :         23 :     sal_Int32 nCropRight    = (sal_Int32)rPropSet.GetPropertyValue( DFF_Prop_cropFromRight, 0 );
    4023                 :            : 
    4024 [ +  - ][ +  - ]:         23 :     if( nCropTop || nCropBottom || nCropLeft || nCropRight )
         [ -  + ][ +  - ]
    4025                 :            :     {
    4026                 :            :         double      fFactor;
    4027                 :          0 :         Size        aCropSize;
    4028         [ #  # ]:          0 :         BitmapEx    aCropBitmap;
    4029                 :          0 :         sal_uInt32  nTop( 0 ),  nBottom( 0 ), nLeft( 0 ), nRight( 0 );
    4030                 :            : 
    4031         [ #  # ]:          0 :         if ( pSet ) // use crop attributes ?
    4032 [ #  # ][ #  # ]:          0 :             aCropSize = lcl_GetPrefSize( rGraf, MAP_100TH_MM );
                 [ #  # ]
    4033                 :            :         else
    4034                 :            :         {
    4035 [ #  # ][ #  # ]:          0 :             aCropBitmap = rGraf.GetBitmapEx();
                 [ #  # ]
    4036                 :          0 :             aCropSize = aCropBitmap.GetSizePixel();
    4037                 :            :         }
    4038         [ #  # ]:          0 :         if ( nCropTop )
    4039                 :            :         {
    4040                 :          0 :             fFactor = (double)nCropTop / 65536.0;
    4041                 :          0 :             nTop = (sal_uInt32)( ( (double)( aCropSize.Height() + 1 ) * fFactor ) + 0.5 );
    4042                 :            :         }
    4043         [ #  # ]:          0 :         if ( nCropBottom )
    4044                 :            :         {
    4045                 :          0 :             fFactor = (double)nCropBottom / 65536.0;
    4046                 :          0 :             nBottom = (sal_uInt32)( ( (double)( aCropSize.Height() + 1 ) * fFactor ) + 0.5 );
    4047                 :            :         }
    4048         [ #  # ]:          0 :         if ( nCropLeft )
    4049                 :            :         {
    4050                 :          0 :             fFactor = (double)nCropLeft / 65536.0;
    4051                 :          0 :             nLeft = (sal_uInt32)( ( (double)( aCropSize.Width() + 1 ) * fFactor ) + 0.5 );
    4052                 :            :         }
    4053         [ #  # ]:          0 :         if ( nCropRight )
    4054                 :            :         {
    4055                 :          0 :             fFactor = (double)nCropRight / 65536.0;
    4056                 :          0 :             nRight = (sal_uInt32)( ( (double)( aCropSize.Width() + 1 ) * fFactor ) + 0.5 );
    4057                 :            :         }
    4058         [ #  # ]:          0 :         if ( pSet ) // use crop attributes ?
    4059 [ #  # ][ #  # ]:          0 :             pSet->Put( SdrGrafCropItem( nLeft, nTop, nRight, nBottom ) );
                 [ #  # ]
    4060                 :            :         else
    4061                 :            :         {
    4062         [ #  # ]:          0 :             Rectangle aCropRect( nLeft, nTop, aCropSize.Width() - nRight, aCropSize.Height() - nBottom );
    4063         [ #  # ]:          0 :             aCropBitmap.Crop( aCropRect );
    4064 [ #  # ][ #  # ]:          0 :             rGraf = aCropBitmap;
                 [ #  # ]
    4065         [ #  # ]:          0 :         }
    4066                 :            :     }
    4067                 :         23 : }
    4068                 :            : 
    4069                 :         77 : SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, const DffObjData& rObjData )
    4070                 :            : {
    4071                 :         77 :     SdrObject*  pRet = NULL;
    4072         [ +  - ]:         77 :     String      aFileName;
    4073 [ +  - ][ +  - ]:         77 :     String      aLinkFileName, aLinkFilterName;
    4074         [ +  - ]:         77 :     Rectangle   aVisArea;
    4075                 :            : 
    4076         [ +  - ]:         77 :     MSO_BlipFlags eFlags = (MSO_BlipFlags)GetPropertyValue( DFF_Prop_pibFlags, mso_blipflagDefault );
    4077         [ +  - ]:         77 :     sal_uInt32 nBlipId = GetPropertyValue( DFF_Prop_pib, 0 );
    4078                 :         77 :     sal_Bool bGrfRead = sal_False,
    4079                 :            : 
    4080                 :            :     // Graphic linked
    4081                 :         77 :     bLinkGrf = 0 != ( eFlags & mso_blipflagLinkToFile );
    4082                 :            :     {
    4083         [ +  - ]:         77 :         Graphic aGraf;  // be sure this graphic is deleted before swapping out
    4084 [ +  - ][ +  + ]:         77 :         if( SeekToContent( DFF_Prop_pibName, rSt ) )
    4085 [ +  - ][ +  - ]:         12 :             aFileName = MSDFFReadZString( rSt, GetPropertyValue( DFF_Prop_pibName ), sal_True );
                 [ +  - ]
    4086                 :            : 
    4087                 :            :         //   AND, OR the following:
    4088         [ +  - ]:         77 :         if( !( eFlags & mso_blipflagDoNotSave ) ) // Graphic embedded
    4089                 :            :         {
    4090         [ +  - ]:         77 :             bGrfRead = GetBLIP( nBlipId, aGraf, &aVisArea );
    4091         [ +  + ]:         77 :             if ( !bGrfRead )
    4092                 :            :             {
    4093                 :            :                 /*
    4094                 :            :                 Still no luck, lets look at the end of this record for a FBSE pool,
    4095                 :            :                 this fallback is a specific case for how word does it sometimes
    4096                 :            :                 */
    4097         [ +  - ]:         39 :                 rObjData.rSpHd.SeekToEndOfRecord( rSt );
    4098                 :         39 :                 DffRecordHeader aHd;
    4099         [ +  - ]:         39 :                 rSt >> aHd;
    4100         [ +  + ]:         39 :                 if( DFF_msofbtBSE == aHd.nRecType )
    4101                 :            :                 {
    4102                 :          6 :                     const sal_uLong nSkipBLIPLen = 20;
    4103                 :          6 :                     const sal_uLong nSkipShapePos = 4;
    4104                 :          6 :                     const sal_uLong nSkipBLIP = 4;
    4105                 :            :                     const sal_uLong nSkip =
    4106                 :          6 :                         nSkipBLIPLen + 4 + nSkipShapePos + 4 + nSkipBLIP;
    4107                 :            : 
    4108         [ +  - ]:          6 :                     if (nSkip <= aHd.nRecLen)
    4109                 :            :                     {
    4110         [ +  - ]:          6 :                         rSt.SeekRel(nSkip);
    4111         [ +  - ]:          6 :                         if (0 == rSt.GetError())
    4112         [ +  - ]:         39 :                             bGrfRead = GetBLIPDirect( rSt, aGraf, &aVisArea );
    4113                 :            :                     }
    4114                 :            :                 }
    4115                 :            :             }
    4116                 :            :         }
    4117         [ +  + ]:         77 :         if ( bGrfRead )
    4118                 :            :         {
    4119                 :            :             // the writer is doing it's own cropping, so this part affects only impress and calc
    4120         [ +  + ]:         38 :             if ( GetSvxMSDffSettings() & SVXMSDFF_SETTINGS_CROP_BITMAPS )
    4121 [ +  + ][ +  - ]:         23 :                 lcl_ApplyCropping( *this, ( rObjData.nSpFlags & SP_FOLESHAPE ) == 0 ? &rSet : NULL, aGraf );
    4122                 :            : 
    4123         [ -  + ]:         38 :             if ( IsProperty( DFF_Prop_pictureTransparent ) )
    4124                 :            :             {
    4125         [ #  # ]:          0 :                 sal_uInt32 nTransColor = GetPropertyValue( DFF_Prop_pictureTransparent, 0 );
    4126                 :            : 
    4127 [ #  # ][ #  # ]:          0 :                 if ( aGraf.GetType() == GRAPHIC_BITMAP )
    4128                 :            :                 {
    4129         [ #  # ]:          0 :                     BitmapEx    aBitmapEx( aGraf.GetBitmapEx() );
    4130         [ #  # ]:          0 :                     Bitmap      aBitmap( aBitmapEx.GetBitmap() );
    4131 [ #  # ][ #  # ]:          0 :                     Bitmap      aMask( aBitmap.CreateMask( MSO_CLR_ToColor( nTransColor, DFF_Prop_pictureTransparent ), 9 ) );
    4132 [ #  # ][ #  # ]:          0 :                     if ( aBitmapEx.IsTransparent() )
    4133 [ #  # ][ #  # ]:          0 :                         aMask.CombineSimple( aBitmapEx.GetMask(), BMP_COMBINE_OR );
                 [ #  # ]
    4134 [ #  # ][ #  # ]:          0 :                     aGraf = BitmapEx( aBitmap, aMask );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    4135                 :            :                 }
    4136                 :            :             }
    4137                 :            : 
    4138         [ +  - ]:         38 :             sal_Int32 nContrast = GetPropertyValue( DFF_Prop_pictureContrast, 0x10000 );
    4139                 :            :             /*
    4140                 :            :             0x10000 is msoffice 50%
    4141                 :            :             < 0x10000 is in units of 1/50th of 0x10000 per 1%
    4142                 :            :             > 0x10000 is in units where
    4143                 :            :             a msoffice x% is stored as 50/(100-x) * 0x10000
    4144                 :            : 
    4145                 :            :             plus, a (ui) microsoft % ranges from 0 to 100, OOO
    4146                 :            :             from -100 to 100, so also normalize into that range
    4147                 :            :             */
    4148         [ -  + ]:         38 :             if ( nContrast > 0x10000 )
    4149                 :            :             {
    4150                 :          0 :                 double fX = nContrast;
    4151                 :          0 :                 fX /= 0x10000;
    4152                 :          0 :                 fX /= 51;   // 50 + 1 to round
    4153                 :          0 :                 fX = 1/fX;
    4154                 :          0 :                 nContrast = static_cast<sal_Int32>(fX);
    4155                 :          0 :                 nContrast -= 100;
    4156                 :          0 :                 nContrast = -nContrast;
    4157                 :          0 :                 nContrast = (nContrast-50)*2;
    4158                 :            :             }
    4159         [ +  - ]:         38 :             else if ( nContrast == 0x10000 )
    4160                 :         38 :                 nContrast = 0;
    4161                 :            :             else
    4162                 :            :             {
    4163                 :          0 :                 nContrast *= 101;   //100 + 1 to round
    4164                 :          0 :                 nContrast /= 0x10000;
    4165                 :          0 :                 nContrast -= 100;
    4166                 :            :             }
    4167         [ +  - ]:         38 :             sal_Int16   nBrightness     = (sal_Int16)( (sal_Int32)GetPropertyValue( DFF_Prop_pictureBrightness, 0 ) / 327 );
    4168         [ +  - ]:         38 :             sal_Int32   nGamma          = GetPropertyValue( DFF_Prop_pictureGamma, 0x10000 );
    4169                 :         38 :             GraphicDrawMode eDrawMode   = GRAPHICDRAWMODE_STANDARD;
    4170         [ +  - ]:         38 :             switch ( GetPropertyValue( DFF_Prop_pictureActive ) & 6 )
           [ -  -  +  - ]
    4171                 :            :             {
    4172                 :          0 :                 case 4 : eDrawMode = GRAPHICDRAWMODE_GREYS; break;
    4173                 :          0 :                 case 6 : eDrawMode = GRAPHICDRAWMODE_MONO; break;
    4174                 :            :                 case 0 :
    4175                 :            :                 {
    4176                 :            :                     //office considers the converted values of (in OOo) 70 to be the
    4177                 :            :                     //"watermark" values, which can vary slightly due to rounding from the
    4178                 :            :                     //above values
    4179 [ -  + ][ #  # ]:         38 :                     if (( nContrast == -70 ) && ( nBrightness == 70 ))
    4180                 :            :                     {
    4181                 :          0 :                         nContrast = 0;
    4182                 :          0 :                         nBrightness = 0;
    4183                 :          0 :                         eDrawMode = GRAPHICDRAWMODE_WATERMARK;
    4184                 :            :                     };
    4185                 :            :                 }
    4186                 :         38 :                 break;
    4187                 :            :             }
    4188                 :            : 
    4189 [ +  - ][ +  - ]:         38 :             if ( nContrast || nBrightness || ( nGamma != 0x10000 ) || ( eDrawMode != GRAPHICDRAWMODE_STANDARD ) )
         [ +  - ][ -  + ]
    4190                 :            :             {
    4191         [ #  # ]:          0 :                 if ( ( rObjData.nSpFlags & SP_FOLESHAPE ) == 0 )
    4192                 :            :                 {
    4193         [ #  # ]:          0 :                     if ( nBrightness )
    4194 [ #  # ][ #  # ]:          0 :                         rSet.Put( SdrGrafLuminanceItem( nBrightness ) );
                 [ #  # ]
    4195         [ #  # ]:          0 :                     if ( nContrast )
    4196 [ #  # ][ #  # ]:          0 :                         rSet.Put( SdrGrafContrastItem( (sal_Int16)nContrast ) );
                 [ #  # ]
    4197         [ #  # ]:          0 :                     if ( nGamma != 0x10000 )
    4198 [ #  # ][ #  # ]:          0 :                         rSet.Put( SdrGrafGamma100Item( nGamma / 655 ) );
                 [ #  # ]
    4199         [ #  # ]:          0 :                     if ( eDrawMode != GRAPHICDRAWMODE_STANDARD )
    4200 [ #  # ][ #  # ]:          0 :                         rSet.Put( SdrGrafModeItem( eDrawMode ) );
                 [ #  # ]
    4201                 :            :                 }
    4202                 :            :                 else
    4203                 :            :                 {
    4204         [ #  # ]:          0 :                     if ( eDrawMode == GRAPHICDRAWMODE_WATERMARK )
    4205                 :            :                     {
    4206                 :          0 :                         nContrast = 60;
    4207                 :          0 :                         nBrightness = 70;
    4208                 :          0 :                         eDrawMode = GRAPHICDRAWMODE_STANDARD;
    4209                 :            :                     }
    4210         [ #  # ]:          0 :                     switch ( aGraf.GetType() )
              [ #  #  # ]
    4211                 :            :                     {
    4212                 :            :                         case GRAPHIC_BITMAP :
    4213                 :            :                         {
    4214         [ #  # ]:          0 :                             BitmapEx    aBitmapEx( aGraf.GetBitmapEx() );
    4215 [ #  # ][ #  # ]:          0 :                             if ( nBrightness || nContrast || ( nGamma != 0x10000 ) )
                 [ #  # ]
    4216         [ #  # ]:          0 :                                 aBitmapEx.Adjust( nBrightness, (sal_Int16)nContrast, 0, 0, 0, (double)nGamma / 0x10000, sal_False );
    4217         [ #  # ]:          0 :                             if ( eDrawMode == GRAPHICDRAWMODE_GREYS )
    4218         [ #  # ]:          0 :                                 aBitmapEx.Convert( BMP_CONVERSION_8BIT_GREYS );
    4219         [ #  # ]:          0 :                             else if ( eDrawMode == GRAPHICDRAWMODE_MONO )
    4220         [ #  # ]:          0 :                                 aBitmapEx.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
    4221 [ #  # ][ #  # ]:          0 :                             aGraf = aBitmapEx;
         [ #  # ][ #  # ]
    4222                 :            : 
    4223                 :            :                         }
    4224                 :          0 :                         break;
    4225                 :            : 
    4226                 :            :                         case GRAPHIC_GDIMETAFILE :
    4227                 :            :                         {
    4228 [ #  # ][ #  # ]:          0 :                             GDIMetaFile aGdiMetaFile( aGraf.GetGDIMetaFile() );
    4229 [ #  # ][ #  # ]:          0 :                             if ( nBrightness || nContrast || ( nGamma != 0x10000 ) )
                 [ #  # ]
    4230         [ #  # ]:          0 :                                 aGdiMetaFile.Adjust( nBrightness, (sal_Int16)nContrast, 0, 0, 0, (double)nGamma / 0x10000, sal_False );
    4231         [ #  # ]:          0 :                             if ( eDrawMode == GRAPHICDRAWMODE_GREYS )
    4232         [ #  # ]:          0 :                                 aGdiMetaFile.Convert( MTF_CONVERSION_8BIT_GREYS );
    4233         [ #  # ]:          0 :                             else if ( eDrawMode == GRAPHICDRAWMODE_MONO )
    4234         [ #  # ]:          0 :                                 aGdiMetaFile.Convert( MTF_CONVERSION_1BIT_THRESHOLD );
    4235 [ #  # ][ #  # ]:          0 :                             aGraf = aGdiMetaFile;
         [ #  # ][ #  # ]
    4236                 :            :                         }
    4237                 :          0 :                         break;
    4238                 :         38 :                         default: break;
    4239                 :            :                     }
    4240                 :            :                 }
    4241                 :            :             }
    4242                 :            :         }
    4243                 :            : 
    4244                 :            :         // should it be an OLE object?
    4245 [ +  + ][ +  - ]:         77 :         if( bGrfRead && !bLinkGrf && IsProperty( DFF_Prop_pictureId ) )
         [ +  + ][ +  + ]
    4246                 :            :         {
    4247                 :            :             // TODO/LATER: in future probably the correct aspect should be provided here
    4248                 :         23 :             sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
    4249                 :            :             // #i32596# - pass <nCalledByGroup> to method
    4250 [ +  - ][ +  - ]:         23 :             pRet = ImportOLE( GetPropertyValue( DFF_Prop_pictureId ), aGraf, rObjData.aBoundRect, aVisArea, rObjData.nCalledByGroup, nAspect );
    4251                 :            :         }
    4252         [ +  + ]:         77 :         if( !pRet )
    4253                 :            :         {
    4254 [ +  - ][ +  - ]:         65 :             pRet = new SdrGrafObj;
    4255         [ +  + ]:         65 :             if( bGrfRead )
    4256         [ +  - ]:         26 :                 ((SdrGrafObj*)pRet)->SetGraphic( aGraf );
    4257                 :            : 
    4258 [ -  + ][ #  # ]:         65 :             if( bLinkGrf && !bGrfRead )     // sj: #i55484# if the graphic was embedded ( bGrfRead == true ) then
    4259                 :            :             {                               // we do not need to set a link. TODO: not to lose the information where the graphic is linked from
    4260         [ #  # ]:          0 :                 INetURLObject aAbsURL;
    4261 [ #  # ][ #  # ]:          0 :                 if ( !INetURLObject( maBaseURL ).GetNewAbsURL( rtl::OUStringToOString(aFileName, RTL_TEXTENCODING_UTF8), &aAbsURL ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4262                 :            :                 {
    4263                 :          0 :                     rtl::OUString aValidURL;
    4264 [ #  # ][ #  # ]:          0 :                     if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFileName, aValidURL ) )
                 [ #  # ]
    4265 [ #  # ][ #  # ]:          0 :                         aAbsURL = INetURLObject( aValidURL );
                 [ #  # ]
    4266                 :            :                 }
    4267         [ #  # ]:          0 :                 if( aAbsURL.GetProtocol() != INET_PROT_NOT_VALID )
    4268                 :            :                 {
    4269         [ #  # ]:          0 :                     GraphicFilter &rGrfFilter = GraphicFilter::GetGraphicFilter();
    4270                 :            :                     aLinkFilterName = rGrfFilter.GetImportFormatName(
    4271 [ #  # ][ #  # ]:          0 :                         rGrfFilter.GetImportFormatNumberForShortName( aAbsURL.getExtension() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4272 [ #  # ][ #  # ]:          0 :                     aLinkFileName = aAbsURL.GetMainURL( INetURLObject::DECODE_TO_IURI );
    4273                 :            :                 }
    4274                 :            :                 else
    4275 [ #  # ][ #  # ]:          0 :                     aLinkFileName = aFileName;
    4276                 :            :             }
    4277                 :            :         }
    4278                 :            : 
    4279                 :            :         // set the size from BLIP if there is one
    4280 [ +  - ][ +  + ]:         77 :         if ( pRet && bGrfRead && !aVisArea.IsEmpty() )
         [ +  - ][ +  + ]
                 [ +  + ]
    4281         [ +  - ]:         23 :             pRet->SetBLIPSizeRectangle( aVisArea );
    4282                 :            : 
    4283 [ +  - ][ +  - ]:         77 :         if (pRet->GetName().isEmpty())                   // SJ 22.02.00 : PPT OLE IMPORT:
    4284                 :            :         {                                                // name is already set in ImportOLE !!
    4285                 :            :             // JP 01.12.99: SetName before SetModel - because in the other order the Bug 70098 is active
    4286         [ +  + ]:         77 :             if ( ( eFlags & mso_blipflagType ) != mso_blipflagComment )
    4287                 :            :             {
    4288         [ +  - ]:          9 :                 INetURLObject aURL;
    4289 [ +  - ][ +  - ]:          9 :                 aURL.SetSmartURL( aFileName );
    4290 [ +  - ][ +  - ]:          9 :                 pRet->SetName( aURL.getBase() );
                 [ +  - ]
    4291                 :            :             }
    4292                 :            :             else
    4293 [ +  - ][ +  - ]:         68 :                 pRet->SetName( aFileName );
    4294         [ +  - ]:         77 :         }
    4295                 :            :     }
    4296         [ +  - ]:         77 :     pRet->SetModel( pSdrModel ); // required for GraphicLink
    4297         [ +  - ]:         77 :     pRet->SetLogicRect( rObjData.aBoundRect );
    4298                 :            : 
    4299 [ +  - ][ +  - ]:         77 :     if ( pRet->ISA( SdrGrafObj ) )
                 [ +  + ]
    4300                 :            :     {
    4301         [ -  + ]:         65 :         if( aLinkFileName.Len() )
    4302 [ #  # ][ #  # ]:          0 :             ((SdrGrafObj*)pRet)->SetGraphicLink( aLinkFileName, aLinkFilterName );
    4303                 :            : 
    4304 [ -  + ][ #  # ]:         65 :         if ( bLinkGrf && !bGrfRead )
    4305                 :            :         {
    4306         [ #  # ]:          0 :             ((SdrGrafObj*)pRet)->ForceSwapIn();
    4307 [ #  # ][ #  # ]:          0 :             Graphic aGraf(((SdrGrafObj*)pRet)->GetGraphic());
    4308 [ #  # ][ #  # ]:          0 :             lcl_ApplyCropping( *this, &rSet, aGraf );
    4309                 :            :         }
    4310         [ +  - ]:         65 :         ((SdrGrafObj*)pRet)->ForceSwapOut();
    4311                 :            :     }
    4312                 :            : 
    4313 [ +  - ][ +  - ]:         77 :     return pRet;
                 [ +  - ]
    4314                 :            : }
    4315                 :            : 
    4316                 :            : // PptSlidePersistEntry& rPersistEntry, SdPage* pPage
    4317                 :        556 : SdrObject* SvxMSDffManager::ImportObj( SvStream& rSt, void* pClientData,
    4318                 :            :     Rectangle& rClientRect, const Rectangle& rGlobalChildRect, int nCalledByGroup, sal_Int32* pShapeId )
    4319                 :            : {
    4320                 :        556 :     SdrObject* pRet = NULL;
    4321                 :        556 :     DffRecordHeader aObjHd;
    4322         [ +  - ]:        556 :     rSt >> aObjHd;
    4323         [ +  + ]:        556 :     if ( aObjHd.nRecType == DFF_msofbtSpgrContainer )
    4324                 :            :     {
    4325         [ +  - ]:         36 :         pRet = ImportGroup( aObjHd, rSt, pClientData, rClientRect, rGlobalChildRect, nCalledByGroup, pShapeId );
    4326                 :            :     }
    4327         [ +  - ]:        520 :     else if ( aObjHd.nRecType == DFF_msofbtSpContainer )
    4328                 :            :     {
    4329         [ +  - ]:        520 :         pRet = ImportShape( aObjHd, rSt, pClientData, rClientRect, rGlobalChildRect, nCalledByGroup, pShapeId );
    4330                 :            :     }
    4331         [ +  - ]:        556 :     aObjHd.SeekToBegOfRecord( rSt );    // restore FilePos
    4332                 :        556 :     return pRet;
    4333                 :            : }
    4334                 :            : 
    4335                 :         36 : SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& rSt, void* pClientData,
    4336                 :            :                                             Rectangle& rClientRect, const Rectangle& rGlobalChildRect,
    4337                 :            :                                                 int nCalledByGroup, sal_Int32* pShapeId )
    4338                 :            : {
    4339                 :         36 :     SdrObject* pRet = NULL;
    4340                 :            : 
    4341         [ -  + ]:         36 :     if( pShapeId )
    4342                 :          0 :         *pShapeId = 0;
    4343                 :            : 
    4344 [ +  - ][ -  + ]:         36 :     if (!rHd.SeekToContent(rSt))
    4345                 :          0 :         return pRet;
    4346                 :            : 
    4347                 :         36 :     DffRecordHeader aRecHd;     // the first atom has to be the SpContainer for the GroupObject
    4348         [ +  - ]:         36 :     rSt >> aRecHd;
    4349         [ +  - ]:         36 :     if ( aRecHd.nRecType == DFF_msofbtSpContainer )
    4350                 :            :     {
    4351                 :         36 :         mnFix16Angle = 0;
    4352 [ +  - ][ -  + ]:         36 :         if (!aRecHd.SeekToBegOfRecord(rSt))
    4353                 :          0 :             return pRet;
    4354         [ +  - ]:         36 :         pRet = ImportObj( rSt, pClientData, rClientRect, rGlobalChildRect, nCalledByGroup + 1, pShapeId );
    4355         [ +  - ]:         36 :         if ( pRet )
    4356                 :            :         {
    4357                 :         36 :             sal_Int32 nGroupRotateAngle = 0;
    4358                 :         36 :             sal_Int32 nSpFlags = nGroupShapeFlags;
    4359                 :         36 :             nGroupRotateAngle = mnFix16Angle;
    4360                 :            : 
    4361                 :         36 :             Rectangle aClientRect( rClientRect );
    4362                 :            : 
    4363         [ +  - ]:         36 :             Rectangle aGlobalChildRect;
    4364 [ -  + ][ #  # ]:         36 :             if ( !nCalledByGroup || rGlobalChildRect.IsEmpty() )
         [ #  # ][ +  - ]
    4365         [ +  - ]:         36 :                 aGlobalChildRect = GetGlobalChildAnchor( rHd, rSt, aClientRect );
    4366                 :            :             else
    4367                 :          0 :                 aGlobalChildRect = rGlobalChildRect;
    4368                 :            : 
    4369 [ -  + ][ #  # ]:         36 :             if ( ( nGroupRotateAngle > 4500 && nGroupRotateAngle <= 13500 )
         [ -  + ][ #  # ]
    4370                 :            :                 || ( nGroupRotateAngle > 22500 && nGroupRotateAngle <= 31500 ) )
    4371                 :            :             {
    4372         [ #  # ]:          0 :                 sal_Int32 nHalfWidth = ( aClientRect.GetWidth() + 1 ) >> 1;
    4373         [ #  # ]:          0 :                 sal_Int32 nHalfHeight = ( aClientRect.GetHeight() + 1 ) >> 1;
    4374                 :          0 :                 Point aTopLeft( aClientRect.Left() + nHalfWidth - nHalfHeight,
    4375                 :          0 :                                 aClientRect.Top() + nHalfHeight - nHalfWidth );
    4376 [ #  # ][ #  # ]:          0 :                 Size aNewSize( aClientRect.GetHeight(), aClientRect.GetWidth() );
    4377         [ #  # ]:          0 :                 Rectangle aNewRect( aTopLeft, aNewSize );
    4378                 :          0 :                 aClientRect = aNewRect;
    4379                 :            :             }
    4380                 :            : 
    4381                 :            :             // now importing the inner objects of the group
    4382 [ +  - ][ -  + ]:         36 :             if (!aRecHd.SeekToEndOfRecord(rSt))
    4383                 :          0 :                 return pRet;
    4384                 :            : 
    4385 [ +  - ][ +  + ]:        396 :             while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < rHd.GetRecEndFilePos() ) )
                 [ +  + ]
    4386                 :            :             {
    4387                 :        360 :                 DffRecordHeader aRecHd2;
    4388         [ +  - ]:        360 :                 rSt >> aRecHd2;
    4389         [ -  + ]:        360 :                 if ( aRecHd2.nRecType == DFF_msofbtSpgrContainer )
    4390                 :            :                 {
    4391 [ #  # ][ #  # ]:          0 :                     Rectangle aGroupClientAnchor, aGroupChildAnchor;
    4392         [ #  # ]:          0 :                     GetGroupAnchors( aRecHd2, rSt, aGroupClientAnchor, aGroupChildAnchor, aClientRect, aGlobalChildRect );
    4393 [ #  # ][ #  # ]:          0 :                     if (!aRecHd2.SeekToBegOfRecord(rSt))
    4394                 :          0 :                         return pRet;
    4395                 :            :                     sal_Int32 nShapeId;
    4396         [ #  # ]:          0 :                     SdrObject* pTmp = ImportGroup( aRecHd2, rSt, pClientData, aGroupClientAnchor, aGroupChildAnchor, nCalledByGroup + 1, &nShapeId );
    4397 [ #  # ][ #  # ]:          0 :                     if ( pTmp && pRet && ((SdrObjGroup*)pRet)->GetSubList() )
         [ #  # ][ #  # ]
                 [ #  # ]
    4398                 :            :                     {
    4399 [ #  # ][ #  # ]:          0 :                         ((SdrObjGroup*)pRet)->GetSubList()->NbcInsertObject( pTmp );
    4400         [ #  # ]:          0 :                         if( nShapeId )
    4401         [ #  # ]:          0 :                             insertShapeId( nShapeId, pTmp );
    4402                 :            :                     }
    4403                 :            :                 }
    4404         [ +  - ]:        360 :                 else if ( aRecHd2.nRecType == DFF_msofbtSpContainer )
    4405                 :            :                 {
    4406 [ +  - ][ -  + ]:        360 :                     if (!aRecHd2.SeekToBegOfRecord(rSt))
    4407                 :          0 :                         return pRet;
    4408                 :            :                     sal_Int32 nShapeId;
    4409         [ +  - ]:        360 :                     SdrObject* pTmp = ImportShape( aRecHd2, rSt, pClientData, aClientRect, aGlobalChildRect, nCalledByGroup + 1, &nShapeId );
    4410 [ +  - ][ +  - ]:        360 :                     if ( pTmp && pRet && ((SdrObjGroup*)pRet)->GetSubList())
         [ +  - ][ +  - ]
                 [ +  - ]
    4411                 :            :                     {
    4412 [ +  - ][ +  - ]:        360 :                         ((SdrObjGroup*)pRet)->GetSubList()->NbcInsertObject( pTmp );
    4413         [ +  - ]:        360 :                         if( nShapeId )
    4414         [ +  - ]:        360 :                             insertShapeId( nShapeId, pTmp );
    4415                 :            :                     }
    4416                 :            :                 }
    4417 [ +  - ][ -  + ]:        360 :                 if (!aRecHd2.SeekToEndOfRecord(rSt))
    4418                 :        360 :                     return pRet;
    4419                 :            :             }
    4420                 :            : 
    4421         [ -  + ]:         36 :             if ( nGroupRotateAngle )
    4422                 :            :             {
    4423                 :          0 :                 double a = nGroupRotateAngle * nPi180;
    4424 [ #  # ][ #  # ]:          0 :                 pRet->NbcRotate( aClientRect.Center(), nGroupRotateAngle, sin( a ), cos( a ) );
    4425                 :            :             }
    4426         [ -  + ]:         36 :             if ( nSpFlags & SP_FFLIPV )     // Vertical flip?
    4427                 :            :             {   // BoundRect in aBoundRect
    4428                 :          0 :                 Point aLeft( aClientRect.Left(), ( aClientRect.Top() + aClientRect.Bottom() ) >> 1 );
    4429                 :          0 :                 Point aRight( aLeft.X() + 1000, aLeft.Y() );
    4430         [ #  # ]:          0 :                 pRet->NbcMirror( aLeft, aRight );
    4431                 :            :             }
    4432         [ -  + ]:         36 :             if ( nSpFlags & SP_FFLIPH )     // Horizontal flip?
    4433                 :            :             {   // BoundRect in aBoundRect
    4434                 :          0 :                 Point aTop( ( aClientRect.Left() + aClientRect.Right() ) >> 1, aClientRect.Top() );
    4435                 :          0 :                 Point aBottom( aTop.X(), aTop.Y() + 1000 );
    4436         [ #  # ]:         36 :                 pRet->NbcMirror( aTop, aBottom );
    4437                 :            :             }
    4438                 :            :         }
    4439                 :            :     }
    4440                 :         36 :     return pRet;
    4441                 :            : }
    4442                 :            : 
    4443                 :        880 : SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& rSt, void* pClientData,
    4444                 :            :                                             Rectangle& rClientRect, const Rectangle& rGlobalChildRect,
    4445                 :            :                                             int nCalledByGroup, sal_Int32* pShapeId )
    4446                 :            : {
    4447                 :        880 :     SdrObject* pRet = NULL;
    4448                 :            : 
    4449         [ +  + ]:        880 :     if( pShapeId )
    4450                 :        396 :         *pShapeId = 0;
    4451                 :            : 
    4452 [ +  - ][ -  + ]:        880 :     if (!rHd.SeekToBegOfRecord(rSt))
    4453                 :          0 :         return pRet;
    4454                 :            : 
    4455         [ +  - ]:        880 :     DffObjData aObjData( rHd, rClientRect, nCalledByGroup );
    4456         [ +  - ]:        880 :     maShapeRecords.Consume( rSt, sal_False );
    4457         [ +  - ]:        880 :     aObjData.bShapeType = maShapeRecords.SeekToContent( rSt, DFF_msofbtSp, SEEK_FROM_BEGINNING );
    4458         [ +  - ]:        880 :     if ( aObjData.bShapeType )
    4459                 :            :     {
    4460         [ +  - ]:        880 :         rSt >> aObjData.nShapeId
    4461         [ +  - ]:        880 :             >> aObjData.nSpFlags;
    4462         [ +  - ]:        880 :         aObjData.eShapeType = (MSO_SPT)maShapeRecords.Current()->nRecInstance;
    4463                 :            :     }
    4464                 :            :     else
    4465                 :            :     {
    4466                 :          0 :         aObjData.nShapeId = 0;
    4467                 :          0 :         aObjData.nSpFlags = 0;
    4468                 :          0 :         aObjData.eShapeType = mso_sptNil;
    4469                 :            :     }
    4470                 :            : 
    4471         [ +  + ]:        880 :     if( pShapeId )
    4472                 :        396 :         *pShapeId = aObjData.nShapeId;
    4473                 :            : 
    4474         [ +  - ]:        880 :     aObjData.bOpt = maShapeRecords.SeekToContent( rSt, DFF_msofbtOPT, SEEK_FROM_CURRENT_AND_RESTART );
    4475         [ +  + ]:        880 :     if ( aObjData.bOpt )
    4476                 :            :     {
    4477 [ +  - ][ +  - ]:        818 :         if (!maShapeRecords.Current()->SeekToBegOfRecord(rSt))
                 [ -  + ]
    4478                 :          0 :             return pRet;
    4479                 :            : #ifdef DBG_AUTOSHAPE
    4480                 :            :         ReadPropSet( rSt, pClientData, (sal_uInt32)aObjData.eShapeType );
    4481                 :            : #else
    4482         [ +  - ]:        818 :         ReadPropSet( rSt, pClientData );
    4483                 :            : #endif
    4484                 :            :     }
    4485                 :            :     else
    4486                 :            :     {
    4487         [ +  - ]:         62 :         InitializePropSet();    // get the default PropSet
    4488                 :         62 :         ( (DffPropertyReader*) this )->mnFix16Angle = 0;
    4489                 :            :     }
    4490                 :            : 
    4491         [ +  - ]:        880 :     aObjData.bChildAnchor = maShapeRecords.SeekToContent( rSt, DFF_msofbtChildAnchor, SEEK_FROM_CURRENT_AND_RESTART );
    4492         [ +  + ]:        880 :     if ( aObjData.bChildAnchor )
    4493                 :            :     {
    4494                 :            :         sal_Int32 l, o, r, u;
    4495 [ +  - ][ +  - ]:        360 :         rSt >> l >> o >> r >> u;
         [ +  - ][ +  - ]
    4496         [ +  - ]:        360 :         Scale( l );
    4497         [ +  - ]:        360 :         Scale( o );
    4498         [ +  - ]:        360 :         Scale( r );
    4499         [ +  - ]:        360 :         Scale( u );
    4500         [ +  - ]:        360 :         aObjData.aChildAnchor = Rectangle( l, o, r, u );
    4501 [ +  - ][ +  - ]:        360 :         if ( !rGlobalChildRect.IsEmpty() && !rClientRect.IsEmpty() && rGlobalChildRect.GetWidth() && rGlobalChildRect.GetHeight() )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    4502                 :            :         {
    4503                 :        360 :             double fl = l;
    4504                 :        360 :             double fo = o;
    4505                 :        360 :             double fWidth = r - l;
    4506                 :        360 :             double fHeight= u - o;
    4507 [ +  - ][ +  - ]:        360 :             double fXScale = (double)rClientRect.GetWidth() / (double)rGlobalChildRect.GetWidth();
    4508 [ +  - ][ +  - ]:        360 :             double fYScale = (double)rClientRect.GetHeight() / (double)rGlobalChildRect.GetHeight();
    4509                 :        360 :             fl = ( ( l - rGlobalChildRect.Left() ) * fXScale ) + rClientRect.Left();
    4510                 :        360 :             fo = ( ( o - rGlobalChildRect.Top()  ) * fYScale ) + rClientRect.Top();
    4511                 :        360 :             fWidth *= fXScale;
    4512                 :        360 :             fHeight *= fYScale;
    4513         [ +  - ]:        360 :             aObjData.aChildAnchor = Rectangle( Point( (sal_Int32)fl, (sal_Int32)fo ), Size( (sal_Int32)( fWidth + 1 ), (sal_Int32)( fHeight + 1 ) ) );
    4514                 :            :         }
    4515                 :            :     }
    4516                 :            : 
    4517         [ +  - ]:        880 :     aObjData.bClientAnchor = maShapeRecords.SeekToContent( rSt, DFF_msofbtClientAnchor, SEEK_FROM_CURRENT_AND_RESTART );
    4518         [ +  + ]:        880 :     if ( aObjData.bClientAnchor )
    4519 [ +  - ][ +  - ]:        431 :         ProcessClientAnchor2( rSt, *maShapeRecords.Current(), pClientData, aObjData );
    4520                 :            : 
    4521         [ +  + ]:        880 :     if ( aObjData.bChildAnchor )
    4522                 :        623 :         aObjData.aBoundRect = aObjData.aChildAnchor;
    4523                 :            : 
    4524         [ +  + ]:        880 :     if ( aObjData.nSpFlags & SP_FBACKGROUND )
    4525         [ +  - ]:         27 :         aObjData.aBoundRect = Rectangle( Point(), Size( 1, 1 ) );
    4526                 :            : 
    4527         [ +  - ]:        880 :     Rectangle aTextRect;
    4528 [ +  - ][ +  + ]:        880 :     if ( !aObjData.aBoundRect.IsEmpty() )
    4529                 :            :     {   // apply rotation to the BoundingBox BEFORE an object has been generated
    4530         [ -  + ]:        818 :         if( mnFix16Angle )
    4531                 :            :         {
    4532                 :          0 :             long nAngle = mnFix16Angle;
    4533 [ #  # ][ #  # ]:          0 :             if ( ( nAngle > 4500 && nAngle <= 13500 ) || ( nAngle > 22500 && nAngle <= 31500 ) )
         [ #  # ][ #  # ]
    4534                 :            :             {
    4535         [ #  # ]:          0 :                 sal_Int32 nHalfWidth = ( aObjData.aBoundRect.GetWidth() + 1 ) >> 1;
    4536         [ #  # ]:          0 :                 sal_Int32 nHalfHeight = ( aObjData.aBoundRect.GetHeight() + 1 ) >> 1;
    4537                 :          0 :                 Point aTopLeft( aObjData.aBoundRect.Left() + nHalfWidth - nHalfHeight,
    4538                 :          0 :                                 aObjData.aBoundRect.Top() + nHalfHeight - nHalfWidth );
    4539 [ #  # ][ #  # ]:          0 :                 Size aNewSize( aObjData.aBoundRect.GetHeight(), aObjData.aBoundRect.GetWidth() );
    4540         [ #  # ]:          0 :                 Rectangle aNewRect( aTopLeft, aNewSize );
    4541                 :          0 :                 aObjData.aBoundRect = aNewRect;
    4542                 :            :             }
    4543                 :            :         }
    4544                 :        818 :         aTextRect = aObjData.aBoundRect;
    4545                 :        818 :         bool bGraphic = IsProperty( DFF_Prop_pib ) ||
    4546                 :        741 :                             IsProperty( DFF_Prop_pibName ) ||
    4547         [ -  + ]:       1559 :                             IsProperty( DFF_Prop_pibFlags );
           [ +  +  +  - ]
    4548                 :            : 
    4549         [ +  + ]:        818 :         if ( aObjData.nSpFlags & SP_FGROUP )
    4550                 :            :         {
    4551 [ +  - ][ +  - ]:         36 :             pRet = new SdrObjGroup;
    4552                 :            :             /*  After CWS aw033 has been integrated, an empty group object
    4553                 :            :                 cannot store its resulting bounding rectangle anymore. We have
    4554                 :            :                 to return this rectangle via rClientRect now, but only, if
    4555                 :            :                 caller has not passed an own bounding ractangle. */
    4556 [ +  - ][ -  + ]:         36 :             if ( rClientRect.IsEmpty() )
    4557                 :          0 :                  rClientRect = aObjData.aBoundRect;
    4558                 :         36 :             nGroupShapeFlags = aObjData.nSpFlags;       // #73013#
    4559                 :            :         }
    4560 [ -  + ][ #  # ]:        782 :         else if ( ( aObjData.eShapeType != mso_sptNil ) || IsProperty( DFF_Prop_pVertices ) || bGraphic )
         [ #  # ][ +  - ]
    4561                 :            :         {
    4562         [ +  - ]:        782 :             SfxItemSet  aSet( pSdrModel->GetItemPool() );
    4563                 :            : 
    4564 [ +  + ][ -  + ]:        782 :             sal_Bool    bIsConnector = ( ( aObjData.eShapeType >= mso_sptStraightConnector1 ) && ( aObjData.eShapeType <= mso_sptCurvedConnector5 ) );
    4565                 :        782 :             sal_Int32   nObjectRotation = mnFix16Angle;
    4566                 :        782 :             sal_uInt32  nSpFlags = aObjData.nSpFlags;
    4567                 :            : 
    4568         [ +  + ]:        782 :             if ( bGraphic )
    4569                 :            :             {
    4570         [ +  - ]:         77 :                 pRet = ImportGraphic( rSt, aSet, aObjData );        // SJ: #68396# is no longer true (fixed in ppt2000)
    4571         [ +  - ]:         77 :                 ApplyAttributes( rSt, aSet, aObjData );
    4572         [ +  - ]:         77 :                 pRet->SetMergedItemSet(aSet);
    4573                 :            :             }
    4574         [ +  + ]:        705 :             else if ( aObjData.eShapeType == mso_sptLine )
    4575                 :            :             {
    4576         [ +  - ]:        258 :                 basegfx::B2DPolygon aPoly;
    4577         [ +  - ]:        258 :                 aPoly.append(basegfx::B2DPoint(aObjData.aBoundRect.Left(), aObjData.aBoundRect.Top()));
    4578         [ +  - ]:        258 :                 aPoly.append(basegfx::B2DPoint(aObjData.aBoundRect.Right(), aObjData.aBoundRect.Bottom()));
    4579 [ +  - ][ +  - ]:        258 :                 pRet = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly));
         [ +  - ][ +  - ]
    4580         [ +  - ]:        258 :                 pRet->SetModel( pSdrModel );
    4581         [ +  - ]:        258 :                 ApplyAttributes( rSt, aSet, aObjData );
    4582 [ +  - ][ +  - ]:        258 :                 pRet->SetMergedItemSet(aSet);
    4583                 :            :             }
    4584                 :            :             else
    4585                 :            :             {
    4586 [ +  - ][ +  + ]:        447 :                 if ( GetCustomShapeContent( aObjData.eShapeType ) || IsProperty( DFF_Prop_pVertices ) )
         [ +  + ][ +  + ]
    4587                 :            :                 {
    4588                 :            : 
    4589         [ +  - ]:        396 :                     ApplyAttributes( rSt, aSet, aObjData );
    4590                 :            : 
    4591 [ +  - ][ +  - ]:        396 :                     pRet = new SdrObjCustomShape();
    4592         [ +  - ]:        396 :                     pRet->SetModel( pSdrModel );
    4593                 :            : 
    4594         [ +  - ]:        396 :                     sal_Bool bIsFontwork = ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x4000 ) != 0;
    4595                 :            : 
    4596                 :            :                     // in case of a FontWork, the text is set by the escher import
    4597         [ -  + ]:        396 :                     if ( bIsFontwork )
    4598                 :            :                     {
    4599         [ #  # ]:          0 :                         String              aObjectText;
    4600         [ #  # ]:          0 :                         String              aFontName;
    4601                 :            :                         MSO_GeoTextAlign    eGeoTextAlign;
    4602                 :            : 
    4603 [ #  # ][ #  # ]:          0 :                         if ( SeekToContent( DFF_Prop_gtextFont, rSt ) )
    4604                 :            :                         {
    4605 [ #  # ][ #  # ]:          0 :                             SvxFontItem aLatin(EE_CHAR_FONTINFO), aAsian(EE_CHAR_FONTINFO_CJK), aComplex(EE_CHAR_FONTINFO_CTL);
                 [ #  # ]
    4606         [ #  # ]:          0 :                             GetDefaultFonts( aLatin, aAsian, aComplex );
    4607                 :            : 
    4608 [ #  # ][ #  # ]:          0 :                             aFontName = MSDFFReadZString( rSt, GetPropertyValue( DFF_Prop_gtextFont ), sal_True );
                 [ #  # ]
    4609                 :          0 :                             aSet.Put( SvxFontItem( aLatin.GetFamily(), aFontName, aLatin.GetStyleName(),
    4610 [ #  # ][ #  # ]:          0 :                                         PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, EE_CHAR_FONTINFO ));
                 [ #  # ]
    4611                 :          0 :                             aSet.Put( SvxFontItem( aLatin.GetFamily(), aFontName, aLatin.GetStyleName(),
    4612 [ #  # ][ #  # ]:          0 :                                         PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, EE_CHAR_FONTINFO_CJK ) );
                 [ #  # ]
    4613                 :          0 :                             aSet.Put( SvxFontItem( aLatin.GetFamily(), aFontName, aLatin.GetStyleName(),
    4614 [ #  # ][ #  # ]:          0 :                                         PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, EE_CHAR_FONTINFO_CTL ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    4615                 :            :                         }
    4616                 :            : 
    4617                 :            :                         // SJ: applying fontattributes for Fontwork :
    4618 [ #  # ][ #  # ]:          0 :                         if ( IsHardAttribute( DFF_Prop_gtextFItalic ) )
    4619 [ #  # ][ #  # ]:          0 :                             aSet.Put( SvxPostureItem( ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x0010 ) != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    4620                 :            : 
    4621 [ #  # ][ #  # ]:          0 :                         if ( IsHardAttribute( DFF_Prop_gtextFBold ) )
    4622 [ #  # ][ #  # ]:          0 :                             aSet.Put( SvxWeightItem( ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x0020 ) != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    4623                 :            : 
    4624                 :            :                         // SJ TODO: Vertical Writing is not correct, instead this should be
    4625                 :            :                         // replaced through "CharacterRotation" by 90°, therefore a new Item has to be
    4626                 :            :                         // supported by svx core, api and xml file format
    4627 [ #  # ][ #  # ]:          0 :                         ((SdrObjCustomShape*)pRet)->SetVerticalWriting( ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x2000 ) != 0 );
    4628                 :            : 
    4629 [ #  # ][ #  # ]:          0 :                         if ( SeekToContent( DFF_Prop_gtextUNICODE, rSt ) )
    4630                 :            :                         {
    4631 [ #  # ][ #  # ]:          0 :                             aObjectText = MSDFFReadZString( rSt, GetPropertyValue( DFF_Prop_gtextUNICODE ), sal_True );
                 [ #  # ]
    4632         [ #  # ]:          0 :                             ReadObjText( aObjectText, pRet );
    4633                 :            :                         }
    4634                 :            : 
    4635         [ #  # ]:          0 :                         eGeoTextAlign = ( (MSO_GeoTextAlign)GetPropertyValue( DFF_Prop_gtextAlign, mso_alignTextCenter ) );
    4636                 :            :                         {
    4637                 :            :                             SdrTextHorzAdjust eHorzAdjust;
    4638   [ #  #  #  # ]:          0 :                             switch( eGeoTextAlign )
    4639                 :            :                             {
    4640                 :            :                                 case mso_alignTextLetterJust :
    4641                 :            :                                 case mso_alignTextWordJust :
    4642                 :          0 :                                 case mso_alignTextStretch : eHorzAdjust = SDRTEXTHORZADJUST_BLOCK; break;
    4643                 :            :                                 default:
    4644                 :            :                                 case mso_alignTextInvalid :
    4645                 :          0 :                                 case mso_alignTextCenter : eHorzAdjust = SDRTEXTHORZADJUST_CENTER; break;
    4646                 :          0 :                                 case mso_alignTextLeft : eHorzAdjust = SDRTEXTHORZADJUST_LEFT; break;
    4647                 :          0 :                                 case mso_alignTextRight : eHorzAdjust = SDRTEXTHORZADJUST_RIGHT; break;
    4648                 :            :                             }
    4649 [ #  # ][ #  # ]:          0 :                             aSet.Put( SdrTextHorzAdjustItem( eHorzAdjust ) );
                 [ #  # ]
    4650                 :            : 
    4651                 :          0 :                             SdrFitToSizeType eFTS = SDRTEXTFIT_NONE;
    4652         [ #  # ]:          0 :                             if ( eGeoTextAlign == mso_alignTextStretch )
    4653                 :          0 :                                 eFTS = SDRTEXTFIT_ALLLINES;
    4654 [ #  # ][ #  # ]:          0 :                             aSet.Put( SdrTextFitToSizeTypeItem( eFTS ) );
                 [ #  # ]
    4655                 :            :                         }
    4656         [ #  # ]:          0 :                         if ( IsProperty( DFF_Prop_gtextSpacing ) )
    4657                 :            :                         {
    4658         [ #  # ]:          0 :                             sal_Int32 nTextWidth = GetPropertyValue( DFF_Prop_gtextSpacing, 100 < 16 ) / 655;
    4659         [ #  # ]:          0 :                             if ( nTextWidth != 100 )
    4660 [ #  # ][ #  # ]:          0 :                                 aSet.Put( SvxCharScaleWidthItem( (sal_uInt16)nTextWidth, EE_CHAR_FONTWIDTH ) );
                 [ #  # ]
    4661                 :            :                         }
    4662 [ #  # ][ #  # ]:          0 :                         if ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x1000 ) // SJ: Font Kerning On ?
    4663 [ #  # ][ #  # ]:          0 :                             aSet.Put( SvxKerningItem( 1, EE_CHAR_KERNING ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    4664                 :            :                     }
    4665         [ +  - ]:        396 :                     pRet->SetMergedItemSet( aSet );
    4666                 :            : 
    4667                 :            :                     // sj: taking care of rtl, ltr. In case of fontwork mso. seems not to be able to set
    4668                 :            :                     // proper text directions, instead the text default is depending to the string.
    4669                 :            :                     // so we have to calculate the a text direction from string:
    4670         [ -  + ]:        396 :                     if ( bIsFontwork )
    4671                 :            :                     {
    4672         [ #  # ]:          0 :                         OutlinerParaObject* pParaObj = ((SdrObjCustomShape*)pRet)->GetOutlinerParaObject();
    4673         [ #  # ]:          0 :                         if ( pParaObj )
    4674                 :            :                         {
    4675         [ #  # ]:          0 :                             SdrOutliner& rOutliner = ((SdrObjCustomShape*)pRet)->ImpGetDrawOutliner();
    4676         [ #  # ]:          0 :                             sal_Bool bOldUpdateMode = rOutliner.GetUpdateMode();
    4677         [ #  # ]:          0 :                             SdrModel* pModel = pRet->GetModel();
    4678         [ #  # ]:          0 :                             if ( pModel )
    4679 [ #  # ][ #  # ]:          0 :                                 rOutliner.SetStyleSheetPool( (SfxStyleSheetPool*)pModel->GetStyleSheetPool() );
    4680         [ #  # ]:          0 :                             rOutliner.SetUpdateMode( sal_False );
    4681         [ #  # ]:          0 :                             rOutliner.SetText( *pParaObj );
    4682         [ #  # ]:          0 :                             VirtualDevice aVirDev( 1 );
    4683 [ #  # ][ #  # ]:          0 :                             aVirDev.SetMapMode( MAP_100TH_MM );
                 [ #  # ]
    4684         [ #  # ]:          0 :                             sal_uInt32 i, nParagraphs = rOutliner.GetParagraphCount();
    4685         [ #  # ]:          0 :                             if ( nParagraphs )
    4686                 :            :                             {
    4687                 :          0 :                                 sal_Bool bCreateNewParaObject = sal_False;
    4688         [ #  # ]:          0 :                                 for ( i = 0; i < nParagraphs; i++ )
    4689                 :            :                                 {
    4690 [ #  # ][ #  # ]:          0 :                                     sal_Bool bIsRTL = aVirDev.GetTextIsRTL( rOutliner.GetText( rOutliner.GetParagraph( i ) ), 0, STRING_LEN );
         [ #  # ][ #  # ]
    4691         [ #  # ]:          0 :                                     if ( bIsRTL )
    4692                 :            :                                     {
    4693         [ #  # ]:          0 :                                         SfxItemSet aSet2( rOutliner.GetParaAttribs( (sal_uInt16)i ) );
    4694 [ #  # ][ #  # ]:          0 :                                         aSet2.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
                 [ #  # ]
    4695         [ #  # ]:          0 :                                         rOutliner.SetParaAttribs( (sal_uInt16)i, aSet2 );
    4696         [ #  # ]:          0 :                                         bCreateNewParaObject = sal_True;
    4697                 :            :                                     }
    4698                 :            :                                 }
    4699         [ #  # ]:          0 :                                 if  ( bCreateNewParaObject )
    4700                 :            :                                 {
    4701         [ #  # ]:          0 :                                     OutlinerParaObject* pNewText = rOutliner.CreateParaObject();
    4702         [ #  # ]:          0 :                                     rOutliner.Init( OUTLINERMODE_TEXTOBJECT );
    4703         [ #  # ]:          0 :                                     ((SdrObjCustomShape*)pRet)->NbcSetOutlinerParaObject( pNewText );
    4704                 :            :                                 }
    4705                 :            :                             }
    4706         [ #  # ]:          0 :                             rOutliner.Clear();
    4707 [ #  # ][ #  # ]:          0 :                             rOutliner.SetUpdateMode( bOldUpdateMode );
    4708                 :            :                         }
    4709                 :            :                     }
    4710                 :            : 
    4711                 :            :                     // mso_sptArc special treating:
    4712                 :            :                     // sj: since we actually can't render the arc because of its weird SnapRect settings,
    4713                 :            :                     // we will create a new CustomShape, that can be saved/loaded without problems.
    4714                 :            :                     // We will change the shape type, so this code applys only if importing arcs from msoffice.
    4715         [ -  + ]:        396 :                     if ( aObjData.eShapeType == mso_sptArc )
    4716                 :            :                     {
    4717         [ #  # ]:          0 :                         const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
    4718         [ #  # ]:          0 :                         const rtl::OUString sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
    4719         [ #  # ]:          0 :                         const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM ( "Handles" ) );
    4720         [ #  # ]:          0 :                         const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM ( "Equations" ) );
    4721         [ #  # ]:          0 :                         const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
    4722         [ #  # ]:          0 :                         const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
    4723         [ #  # ]:          0 :                         const rtl::OUString sTextFrames( RTL_CONSTASCII_USTRINGPARAM ( "TextFrames" ) );
    4724 [ #  # ][ #  # ]:          0 :                         SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)((SdrObjCustomShape*)pRet)->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
    4725         [ #  # ]:          0 :                         com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates;
    4726         [ #  # ]:          0 :                         com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues;
    4727                 :            : 
    4728                 :            :                         // before clearing the GeometryItem we have to store the current Coordinates
    4729         [ #  # ]:          0 :                         const uno::Any* pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sCoordinates );
    4730         [ #  # ]:          0 :                         Rectangle aPolyBoundRect;
    4731 [ #  # ][ #  # ]:          0 :                         if ( pAny && ( *pAny >>= seqCoordinates ) && ( seqCoordinates.getLength() >= 4 ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    4732                 :            :                         {
    4733                 :          0 :                             sal_Int32 nPtNum, nNumElemVert = seqCoordinates.getLength();
    4734         [ #  # ]:          0 :                             XPolygon aXP( (sal_uInt16)nNumElemVert );
    4735         [ #  # ]:          0 :                             for ( nPtNum = 0; nPtNum < nNumElemVert; nPtNum++ )
    4736                 :            :                             {
    4737                 :          0 :                                 Point aP;
    4738                 :          0 :                                 sal_Int32 nX = 0, nY = 0;
    4739         [ #  # ]:          0 :                                 seqCoordinates[ nPtNum ].First.Value >>= nX;
    4740         [ #  # ]:          0 :                                 seqCoordinates[ nPtNum ].Second.Value >>= nY;
    4741                 :          0 :                                 aP.X() = nX;
    4742                 :          0 :                                 aP.Y() = nY;
    4743         [ #  # ]:          0 :                                 aXP[ (sal_uInt16)nPtNum ] = aP;
    4744                 :            :                             }
    4745 [ #  # ][ #  # ]:          0 :                             aPolyBoundRect = Rectangle( aXP.GetBoundRect() );
    4746                 :            :                         }
    4747                 :            :                         else
    4748         [ #  # ]:          0 :                             aPolyBoundRect = Rectangle( -21600, 0, 21600, 43200 );  // defaulting
    4749                 :            : 
    4750                 :            :                         // clearing items, so MergeDefaultAttributes will set the corresponding defaults from EnhancedCustomShapeGeometry
    4751         [ #  # ]:          0 :                         aGeometryItem.ClearPropertyValue( sHandles );
    4752         [ #  # ]:          0 :                         aGeometryItem.ClearPropertyValue( sEquations );
    4753         [ #  # ]:          0 :                         aGeometryItem.ClearPropertyValue( sViewBox );
    4754         [ #  # ]:          0 :                         aGeometryItem.ClearPropertyValue( sPath );
    4755                 :            : 
    4756                 :          0 :                         sal_Int32 nEndAngle = 9000;
    4757                 :          0 :                         sal_Int32 nStartAngle = 0;
    4758         [ #  # ]:          0 :                         pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sAdjustmentValues );
    4759 [ #  # ][ #  # ]:          0 :                         if ( pAny && ( *pAny >>= seqAdjustmentValues ) && seqAdjustmentValues.getLength() > 1 )
         [ #  # ][ #  # ]
                 [ #  # ]
    4760                 :            :                         {
    4761                 :            :                             double fNumber;
    4762 [ #  # ][ #  # ]:          0 :                             if ( seqAdjustmentValues[ 0 ].State == com::sun::star::beans::PropertyState_DIRECT_VALUE )
    4763                 :            :                             {
    4764         [ #  # ]:          0 :                                 seqAdjustmentValues[ 0 ].Value >>= fNumber;
    4765         [ #  # ]:          0 :                                 nEndAngle = NormAngle360( - (sal_Int32)fNumber * 100 );
    4766                 :            :                             }
    4767                 :            :                             else
    4768                 :            :                             {
    4769                 :          0 :                                 fNumber = 270.0;
    4770 [ #  # ][ #  # ]:          0 :                                 seqAdjustmentValues[ 0 ].Value <<= fNumber;
    4771         [ #  # ]:          0 :                                 seqAdjustmentValues[ 0 ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;     // so this value will properly be stored
    4772                 :            :                             }
    4773                 :            : 
    4774 [ #  # ][ #  # ]:          0 :                             if ( seqAdjustmentValues[ 1 ].State == com::sun::star::beans::PropertyState_DIRECT_VALUE )
    4775                 :            :                             {
    4776         [ #  # ]:          0 :                                 seqAdjustmentValues[ 1 ].Value >>= fNumber;
    4777         [ #  # ]:          0 :                                 nStartAngle = NormAngle360( - (sal_Int32)fNumber * 100 );
    4778                 :            :                             }
    4779                 :            :                             else
    4780                 :            :                             {
    4781                 :          0 :                                 fNumber = 0.0;
    4782 [ #  # ][ #  # ]:          0 :                                 seqAdjustmentValues[ 1 ].Value <<= fNumber;
    4783         [ #  # ]:          0 :                                 seqAdjustmentValues[ 1 ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
    4784                 :            :                             }
    4785                 :            : 
    4786                 :          0 :                             PropertyValue aPropVal;
    4787                 :          0 :                             aPropVal.Name = sAdjustmentValues;
    4788         [ #  # ]:          0 :                             aPropVal.Value <<= seqAdjustmentValues;
    4789         [ #  # ]:          0 :                             aGeometryItem.SetPropertyValue( aPropVal );     // storing the angle attribute
    4790                 :            :                         }
    4791         [ #  # ]:          0 :                         if ( nStartAngle != nEndAngle )
    4792                 :            :                         {
    4793 [ #  # ][ #  # ]:          0 :                             XPolygon aXPoly( aPolyBoundRect.Center(), aPolyBoundRect.GetWidth() / 2, aPolyBoundRect.GetHeight() / 2,
    4794 [ #  # ][ #  # ]:          0 :                                 (sal_uInt16)nStartAngle / 10, (sal_uInt16)nEndAngle / 10, sal_True );
    4795         [ #  # ]:          0 :                             Rectangle aPolyPieRect( aXPoly.GetBoundRect() );
    4796                 :            : 
    4797                 :            :                             double  fYScale, fXScale;
    4798                 :            :                             double  fYOfs, fXOfs;
    4799                 :            : 
    4800         [ #  # ]:          0 :                             Point aP( aObjData.aBoundRect.Center() );
    4801         [ #  # ]:          0 :                             Size aS( aObjData.aBoundRect.GetSize() );
    4802                 :          0 :                             aP.X() -= aS.Width() / 2;
    4803                 :          0 :                             aP.Y() -= aS.Height() / 2;
    4804         [ #  # ]:          0 :                             Rectangle aLogicRect( aP, aS );
    4805                 :            : 
    4806                 :          0 :                             fYOfs = fXOfs = 0.0;
    4807                 :            : 
    4808 [ #  # ][ #  # ]:          0 :                             if ( aPolyBoundRect.GetWidth() && aPolyPieRect.GetWidth() )
         [ #  # ][ #  # ]
                 [ #  # ]
    4809                 :            :                             {
    4810 [ #  # ][ #  # ]:          0 :                                 fXScale = (double)aLogicRect.GetWidth() / (double)aPolyPieRect.GetWidth();
    4811         [ #  # ]:          0 :                                 if ( nSpFlags & SP_FFLIPH )
    4812                 :          0 :                                     fXOfs = ( (double)aPolyPieRect.Right() - (double)aPolyBoundRect.Right() ) * fXScale;
    4813                 :            :                                 else
    4814                 :          0 :                                     fXOfs = ( (double)aPolyBoundRect.Left() - (double)aPolyPieRect.Left() ) * fXScale;
    4815                 :            :                             }
    4816 [ #  # ][ #  # ]:          0 :                             if ( aPolyBoundRect.GetHeight() && aPolyPieRect.GetHeight() )
         [ #  # ][ #  # ]
                 [ #  # ]
    4817                 :            :                             {
    4818 [ #  # ][ #  # ]:          0 :                                 fYScale = (double)aLogicRect.GetHeight() / (double)aPolyPieRect.GetHeight();
    4819         [ #  # ]:          0 :                                 if ( nSpFlags & SP_FFLIPV )
    4820                 :          0 :                                     fYOfs = ( (double)aPolyPieRect.Bottom() - (double)aPolyBoundRect.Bottom() ) * fYScale;
    4821                 :            :                                 else
    4822                 :          0 :                                     fYOfs = ((double)aPolyBoundRect.Top() - (double)aPolyPieRect.Top() ) * fYScale;
    4823                 :            :                             }
    4824                 :            : 
    4825 [ #  # ][ #  # ]:          0 :                             fXScale = (double)aPolyBoundRect.GetWidth() / (double)aPolyPieRect.GetWidth();
    4826 [ #  # ][ #  # ]:          0 :                             fYScale = (double)aPolyBoundRect.GetHeight() / (double)aPolyPieRect.GetHeight();
    4827                 :            : 
    4828                 :          0 :                             Rectangle aOldBoundRect( aObjData.aBoundRect );
    4829                 :          0 :                             aObjData.aBoundRect = Rectangle( Point( aLogicRect.Left() + (sal_Int32)fXOfs, aLogicRect.Top() + (sal_Int32)fYOfs ),
    4830 [ #  # ][ #  # ]:          0 :                                  Size( (sal_Int32)( aLogicRect.GetWidth() * fXScale ), (sal_Int32)( aLogicRect.GetHeight() * fYScale ) ) );
                 [ #  # ]
    4831                 :            : 
    4832                 :            :                             // creating the text frame -> scaling into (0,0),(21600,21600) destination coordinate system
    4833         [ #  # ]:          0 :                             double fTextFrameScaleX = (double)21600 / (double)aPolyBoundRect.GetWidth();
    4834         [ #  # ]:          0 :                             double fTextFrameScaleY = (double)21600 / (double)aPolyBoundRect.GetHeight();
    4835                 :          0 :                             sal_Int32 nLeft  = (sal_Int32)(( aPolyPieRect.Left()  - aPolyBoundRect.Left() ) * fTextFrameScaleX );
    4836                 :          0 :                             sal_Int32 nTop   = (sal_Int32)(( aPolyPieRect.Top()   - aPolyBoundRect.Top() )  * fTextFrameScaleY );
    4837                 :          0 :                             sal_Int32 nRight = (sal_Int32)(( aPolyPieRect.Right() - aPolyBoundRect.Left() ) * fTextFrameScaleX );
    4838                 :          0 :                             sal_Int32 nBottom= (sal_Int32)(( aPolyPieRect.Bottom()- aPolyBoundRect.Top() )  * fTextFrameScaleY );
    4839         [ #  # ]:          0 :                             com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > aTextFrame( 1 );
    4840 [ #  # ][ #  # ]:          0 :                             EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrame[ 0 ].TopLeft.First,     nLeft );
    4841 [ #  # ][ #  # ]:          0 :                             EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrame[ 0 ].TopLeft.Second,    nTop );
    4842 [ #  # ][ #  # ]:          0 :                             EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrame[ 0 ].BottomRight.First, nRight );
    4843 [ #  # ][ #  # ]:          0 :                             EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrame[ 0 ].BottomRight.Second,nBottom );
    4844                 :          0 :                             PropertyValue aProp;
    4845                 :          0 :                             aProp.Name = sTextFrames;
    4846         [ #  # ]:          0 :                             aProp.Value <<= aTextFrame;
    4847         [ #  # ]:          0 :                             aGeometryItem.SetPropertyValue( sPath, aProp );
    4848                 :            : 
    4849                 :            :                             // sj: taking care of the different rotation points, since the new arc is having a bigger snaprect
    4850         [ #  # ]:          0 :                             if ( mnFix16Angle )
    4851                 :            :                             {
    4852                 :          0 :                                 sal_Int32 nAngle = mnFix16Angle;
    4853         [ #  # ]:          0 :                                 if ( nSpFlags & SP_FFLIPH )
    4854                 :          0 :                                     nAngle = 36000 - nAngle;
    4855         [ #  # ]:          0 :                                 if ( nSpFlags & SP_FFLIPV )
    4856                 :          0 :                                     nAngle = -nAngle;
    4857                 :          0 :                                 double a = nAngle * F_PI18000;
    4858                 :          0 :                                 double ss = sin( a );
    4859                 :          0 :                                 double cc = cos( a );
    4860                 :          0 :                                 Point aP1( aOldBoundRect.TopLeft() );
    4861         [ #  # ]:          0 :                                 Point aC1( aObjData.aBoundRect.Center() );
    4862                 :          0 :                                 Point aP2( aOldBoundRect.TopLeft() );
    4863         [ #  # ]:          0 :                                 Point aC2( aOldBoundRect.Center() );
    4864                 :          0 :                                 RotatePoint( aP1, aC1, ss, cc );
    4865                 :          0 :                                 RotatePoint( aP2, aC2, ss, cc );
    4866         [ #  # ]:          0 :                                 aObjData.aBoundRect.Move( aP2.X() - aP1.X(), aP2.Y() - aP1.Y() );
    4867 [ #  # ][ #  # ]:          0 :                             }
    4868                 :            :                         }
    4869         [ #  # ]:          0 :                         ((SdrObjCustomShape*)pRet)->SetMergedItem( aGeometryItem );
    4870         [ #  # ]:          0 :                         ((SdrObjCustomShape*)pRet)->MergeDefaultAttributes();
    4871                 :            : 
    4872                 :            :                         // now setting a new name, so the above correction is only done once when importing from ms
    4873 [ #  # ][ #  # ]:          0 :                         SdrCustomShapeGeometryItem aGeoName( (SdrCustomShapeGeometryItem&)((SdrObjCustomShape*)pRet)->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
    4874         [ #  # ]:          0 :                         const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
    4875         [ #  # ]:          0 :                         const rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM ( "mso-spt100" ) );
    4876                 :          0 :                         PropertyValue aPropVal;
    4877                 :          0 :                         aPropVal.Name = sType;
    4878         [ #  # ]:          0 :                         aPropVal.Value <<= sName;
    4879         [ #  # ]:          0 :                         aGeoName.SetPropertyValue( aPropVal );
    4880 [ #  # ][ #  # ]:          0 :                         ((SdrObjCustomShape*)pRet)->SetMergedItem( aGeoName );
         [ #  # ][ #  # ]
                 [ #  # ]
    4881                 :            :                     }
    4882                 :            :                     else
    4883         [ +  - ]:        396 :                         ((SdrObjCustomShape*)pRet)->MergeDefaultAttributes();
    4884                 :            : 
    4885         [ +  - ]:        396 :                     pRet->SetSnapRect( aObjData.aBoundRect );
    4886         [ +  - ]:        396 :                     EnhancedCustomShape2d aCustomShape2d( pRet );
    4887         [ +  - ]:        396 :                     aTextRect = aCustomShape2d.GetTextRect();
    4888                 :            : 
    4889         [ -  + ]:        396 :                     if( bIsConnector )
    4890                 :            :                     {
    4891         [ #  # ]:          0 :                         if( nObjectRotation )
    4892                 :            :                         {
    4893                 :          0 :                             double a = nObjectRotation * nPi180;
    4894 [ #  # ][ #  # ]:          0 :                             pRet->NbcRotate( aObjData.aBoundRect.Center(), nObjectRotation, sin( a ), cos( a ) );
    4895                 :            :                         }
    4896                 :            :                         // mirrored horizontally?
    4897         [ #  # ]:          0 :                         if ( nSpFlags & SP_FFLIPH )
    4898                 :            :                         {
    4899         [ #  # ]:          0 :                             Rectangle aBndRect( pRet->GetSnapRect() );
    4900                 :          0 :                             Point aTop( ( aBndRect.Left() + aBndRect.Right() ) >> 1, aBndRect.Top() );
    4901                 :          0 :                             Point aBottom( aTop.X(), aTop.Y() + 1000 );
    4902         [ #  # ]:          0 :                             pRet->NbcMirror( aTop, aBottom );
    4903                 :            :                         }
    4904                 :            :                         // mirrored vertically?
    4905         [ #  # ]:          0 :                         if ( nSpFlags & SP_FFLIPV )
    4906                 :            :                         {
    4907         [ #  # ]:          0 :                             Rectangle aBndRect( pRet->GetSnapRect() );
    4908                 :          0 :                             Point aLeft( aBndRect.Left(), ( aBndRect.Top() + aBndRect.Bottom() ) >> 1 );
    4909                 :          0 :                             Point aRight( aLeft.X() + 1000, aLeft.Y() );
    4910         [ #  # ]:          0 :                             pRet->NbcMirror( aLeft, aRight );
    4911                 :            :                         }
    4912         [ #  # ]:          0 :                         basegfx::B2DPolyPolygon aPoly( SdrObjCustomShape::GetLineGeometry( (SdrObjCustomShape*)pRet, sal_True ) );
    4913         [ #  # ]:          0 :                         SdrObject::Free( pRet );
    4914                 :            : 
    4915 [ #  # ][ #  # ]:          0 :                         pRet = new SdrEdgeObj();
    4916         [ #  # ]:          0 :                         ApplyAttributes( rSt, aSet, aObjData );
    4917         [ #  # ]:          0 :                         pRet->SetLogicRect( aObjData.aBoundRect );
    4918         [ #  # ]:          0 :                         pRet->SetMergedItemSet(aSet);
    4919                 :            : 
    4920                 :            :                         // connectors
    4921         [ #  # ]:          0 :                         MSO_ConnectorStyle eConnectorStyle = (MSO_ConnectorStyle)GetPropertyValue( DFF_Prop_cxstyle, mso_cxstyleStraight );
    4922                 :            : 
    4923         [ #  # ]:          0 :                         ((SdrEdgeObj*)pRet)->ConnectToNode(sal_True, NULL);
    4924         [ #  # ]:          0 :                         ((SdrEdgeObj*)pRet)->ConnectToNode(sal_False, NULL);
    4925                 :            : 
    4926                 :          0 :                         Point aPoint1( aObjData.aBoundRect.TopLeft() );
    4927         [ #  # ]:          0 :                         Point aPoint2( aObjData.aBoundRect.BottomRight() );
    4928                 :            : 
    4929                 :            :                         // pay attention to the rotations
    4930         [ #  # ]:          0 :                         if ( nObjectRotation )
    4931                 :            :                         {
    4932                 :          0 :                             double a = nObjectRotation * nPi180;
    4933         [ #  # ]:          0 :                             Point aCenter( aObjData.aBoundRect.Center() );
    4934                 :          0 :                             double ss = sin(a);
    4935                 :          0 :                             double cc = cos(a);
    4936                 :            : 
    4937                 :          0 :                             RotatePoint(aPoint1, aCenter, ss, cc);
    4938                 :          0 :                             RotatePoint(aPoint2, aCenter, ss, cc);
    4939                 :            :                         }
    4940                 :            : 
    4941                 :            :                         // rotate/mirror line within the area as we need it
    4942         [ #  # ]:          0 :                         if ( nSpFlags & SP_FFLIPH )
    4943                 :            :                         {
    4944                 :          0 :                             sal_Int32 n = aPoint1.X();
    4945                 :          0 :                             aPoint1.X() = aPoint2.X();
    4946                 :          0 :                             aPoint2.X() = n;
    4947                 :            :                         }
    4948         [ #  # ]:          0 :                         if ( nSpFlags & SP_FFLIPV )
    4949                 :            :                         {
    4950                 :          0 :                             sal_Int32 n = aPoint1.Y();
    4951                 :          0 :                             aPoint1.Y() = aPoint2.Y();
    4952                 :          0 :                             aPoint2.Y() = n;
    4953                 :            :                         }
    4954                 :          0 :                         nSpFlags &= ~( SP_FFLIPV | SP_FFLIPH );
    4955                 :            : 
    4956         [ #  # ]:          0 :                         pRet->NbcSetPoint(aPoint1, 0L); // start point
    4957         [ #  # ]:          0 :                         pRet->NbcSetPoint(aPoint2, 1L); // endpoint
    4958                 :            : 
    4959                 :            :                         sal_Int32 n1HorzDist, n1VertDist, n2HorzDist, n2VertDist;
    4960                 :          0 :                         n1HorzDist = n1VertDist = n2HorzDist = n2VertDist = 0;
    4961      [ #  #  # ]:          0 :                         switch( eConnectorStyle )
    4962                 :            :                         {
    4963                 :            :                             case mso_cxstyleBent:
    4964                 :            :                             {
    4965 [ #  # ][ #  # ]:          0 :                                 aSet.Put( SdrEdgeKindItem( SDREDGE_ORTHOLINES ) );
                 [ #  # ]
    4966                 :          0 :                                 n1HorzDist = n1VertDist = n2HorzDist = n2VertDist = 630;
    4967                 :            :                             }
    4968                 :          0 :                             break;
    4969                 :            :                             case mso_cxstyleCurved:
    4970 [ #  # ][ #  # ]:          0 :                                 aSet.Put( SdrEdgeKindItem( SDREDGE_BEZIER ) );
                 [ #  # ]
    4971                 :          0 :                             break;
    4972                 :            :                             default: // mso_cxstyleStraight || mso_cxstyleNone
    4973 [ #  # ][ #  # ]:          0 :                                 aSet.Put( SdrEdgeKindItem( SDREDGE_ONELINE ) );
                 [ #  # ]
    4974                 :          0 :                             break;
    4975                 :            :                         }
    4976 [ #  # ][ #  # ]:          0 :                         aSet.Put( SdrEdgeNode1HorzDistItem( n1HorzDist ) );
                 [ #  # ]
    4977 [ #  # ][ #  # ]:          0 :                         aSet.Put( SdrEdgeNode1VertDistItem( n1VertDist ) );
                 [ #  # ]
    4978 [ #  # ][ #  # ]:          0 :                         aSet.Put( SdrEdgeNode2HorzDistItem( n2HorzDist ) );
                 [ #  # ]
    4979 [ #  # ][ #  # ]:          0 :                         aSet.Put( SdrEdgeNode2VertDistItem( n2VertDist ) );
                 [ #  # ]
    4980                 :            : 
    4981         [ #  # ]:          0 :                         ((SdrEdgeObj*)pRet)->SetEdgeTrackPath( aPoly );
    4982 [ #  # ][ #  # ]:          0 :                         pRet->SetMergedItemSet( aSet );
    4983         [ +  - ]:        396 :                     }
    4984                 :            :                 }
    4985                 :            :             }
    4986                 :            : 
    4987         [ +  + ]:        782 :             if ( pRet )
    4988                 :            :             {
    4989         [ -  + ]:        731 :                 if( nObjectRotation )
    4990                 :            :                 {
    4991                 :          0 :                     double a = nObjectRotation * nPi180;
    4992 [ #  # ][ #  # ]:          0 :                     pRet->NbcRotate( aObjData.aBoundRect.Center(), nObjectRotation, sin( a ), cos( a ) );
    4993                 :            :                 }
    4994                 :            :                 // mirrored horizontally?
    4995         [ -  + ]:        731 :                 if ( nSpFlags & SP_FFLIPH )
    4996                 :            :                 {
    4997         [ #  # ]:          0 :                     Rectangle aBndRect( pRet->GetSnapRect() );
    4998                 :          0 :                     Point aTop( ( aBndRect.Left() + aBndRect.Right() ) >> 1, aBndRect.Top() );
    4999                 :          0 :                     Point aBottom( aTop.X(), aTop.Y() + 1000 );
    5000         [ #  # ]:          0 :                     pRet->NbcMirror( aTop, aBottom );
    5001                 :            :                 }
    5002                 :            :                 // mirrored vertically?
    5003         [ -  + ]:        731 :                 if ( nSpFlags & SP_FFLIPV )
    5004                 :            :                 {
    5005         [ #  # ]:          0 :                     Rectangle aBndRect( pRet->GetSnapRect() );
    5006                 :          0 :                     Point aLeft( aBndRect.Left(), ( aBndRect.Top() + aBndRect.Bottom() ) >> 1 );
    5007                 :          0 :                     Point aRight( aLeft.X() + 1000, aLeft.Y() );
    5008         [ #  # ]:          0 :                     pRet->NbcMirror( aLeft, aRight );
    5009                 :            :                 }
    5010         [ +  - ]:        782 :             }
    5011                 :            :         }
    5012                 :            :     }
    5013                 :            : 
    5014                 :            :     // #i51348# #118052# name of the shape
    5015         [ +  + ]:        880 :     if( pRet )
    5016                 :            :     {
    5017         [ +  - ]:        767 :         ::rtl::OUString aObjName = GetPropertyString( DFF_Prop_wzName, rSt );
    5018         [ +  + ]:        767 :         if( !aObjName.isEmpty() )
    5019         [ +  - ]:        767 :             pRet->SetName( aObjName );
    5020                 :            :     }
    5021                 :            : 
    5022                 :            :     pRet =
    5023         [ +  - ]:        880 :         ProcessObj( rSt, aObjData, pClientData, aTextRect, pRet);
    5024                 :            : 
    5025         [ +  + ]:        880 :     if ( pRet )
    5026                 :            :     {
    5027         [ +  - ]:        764 :         sal_Int32 nGroupProperties( GetPropertyValue( DFF_Prop_fPrint ) );
    5028         [ +  - ]:        764 :         pRet->SetVisible( ( nGroupProperties & 2 ) == 0 );
    5029         [ +  - ]:        764 :         pRet->SetPrintable( ( nGroupProperties & 1 ) != 0 );
    5030                 :            :     }
    5031                 :            : 
    5032                 :        880 :     return pRet;
    5033                 :            : }
    5034                 :            : 
    5035                 :         36 : Rectangle SvxMSDffManager::GetGlobalChildAnchor( const DffRecordHeader& rHd, SvStream& rSt, Rectangle& aClientRect )
    5036                 :            : {
    5037                 :         36 :     Rectangle aChildAnchor;
    5038         [ -  + ]:         36 :     if (!rHd.SeekToContent(rSt))
    5039                 :          0 :         return aChildAnchor;
    5040                 :            : 
    5041 [ +  - ][ +  + ]:        432 :     while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < rHd.GetRecEndFilePos() ) )
                 [ +  + ]
    5042                 :            :     {
    5043                 :        396 :         DffRecordHeader aShapeHd;
    5044         [ +  - ]:        396 :         rSt >> aShapeHd;
    5045 [ -  + ][ #  # ]:        396 :         if ( ( aShapeHd.nRecType == DFF_msofbtSpContainer ) ||
    5046                 :            :                 ( aShapeHd.nRecType == DFF_msofbtSpgrContainer ) )
    5047                 :            :         {
    5048                 :        396 :             DffRecordHeader aShapeHd2( aShapeHd );
    5049         [ -  + ]:        396 :             if ( aShapeHd.nRecType == DFF_msofbtSpgrContainer )
    5050         [ #  # ]:          0 :                 rSt >> aShapeHd2;
    5051 [ +  - ][ +  - ]:       1656 :             while( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aShapeHd2.GetRecEndFilePos() ) )
                 [ +  - ]
    5052                 :            :             {
    5053                 :       1260 :                 DffRecordHeader aShapeAtom;
    5054         [ +  - ]:       1260 :                 rSt >> aShapeAtom;
    5055                 :            : 
    5056         [ +  + ]:       1260 :                 if ( aShapeAtom.nRecType == DFF_msofbtClientAnchor )
    5057                 :            :                 {
    5058         [ -  + ]:         36 :                     if ( GetSvxMSDffSettings() & SVXMSDFF_SETTINGS_IMPORT_PPT )
    5059                 :            :                     {
    5060                 :            :                         sal_Int32 l, t, r, b;
    5061         [ #  # ]:          0 :                         if ( aShapeAtom.nRecLen == 16 )
    5062                 :            :                         {
    5063 [ #  # ][ #  # ]:          0 :                             rSt >> l >> t >> r >> b;
         [ #  # ][ #  # ]
    5064                 :            :                         }
    5065                 :            :                         else
    5066                 :            :                         {
    5067                 :            :                             sal_Int16 ls, ts, rs, bs;
    5068 [ #  # ][ #  # ]:          0 :                             rSt >> ts >> ls >> rs >> bs; // the order of coordinates is a bit strange...
         [ #  # ][ #  # ]
    5069                 :          0 :                             l = ls, t = ts, r = rs, b = bs;
    5070                 :            :                         }
    5071         [ #  # ]:          0 :                         Scale( l );
    5072         [ #  # ]:          0 :                         Scale( t );
    5073         [ #  # ]:          0 :                         Scale( r );
    5074         [ #  # ]:          0 :                         Scale( b );
    5075         [ #  # ]:          0 :                         aClientRect = Rectangle( l, t, r, b );
    5076                 :            :                     }
    5077                 :            :                     break;
    5078                 :            :                 }
    5079         [ +  + ]:       1224 :                 else if ( aShapeAtom.nRecType == DFF_msofbtChildAnchor )
    5080                 :            :                 {
    5081                 :            :                     sal_Int32 l, o, r, u;
    5082 [ +  - ][ +  - ]:        360 :                     rSt >> l >> o >> r >> u;
         [ +  - ][ +  - ]
    5083         [ +  - ]:        360 :                     Scale( l );
    5084         [ +  - ]:        360 :                     Scale( o );
    5085         [ +  - ]:        360 :                     Scale( r );
    5086         [ +  - ]:        360 :                     Scale( u );
    5087         [ +  - ]:        360 :                     Rectangle aChild( l, o, r, u );
    5088         [ +  - ]:        360 :                     aChildAnchor.Union( aChild );
    5089                 :            :                     break;
    5090                 :            :                 }
    5091 [ +  - ][ +  - ]:       1260 :                 if (!aShapeAtom.SeekToEndOfRecord(rSt))
    5092                 :            :                     break;
    5093                 :            :             }
    5094                 :            :         }
    5095 [ +  - ][ +  - ]:        396 :         if (!aShapeHd.SeekToEndOfRecord(rSt))
    5096                 :            :             break;
    5097                 :            :     }
    5098                 :         36 :     return aChildAnchor;
    5099                 :            : }
    5100                 :            : 
    5101                 :          0 : void SvxMSDffManager::GetGroupAnchors( const DffRecordHeader& rHd, SvStream& rSt,
    5102                 :            :                             Rectangle& rGroupClientAnchor, Rectangle& rGroupChildAnchor,
    5103                 :            :                                 const Rectangle& rClientRect, const Rectangle& rGlobalChildRect )
    5104                 :            : {
    5105 [ #  # ][ #  # ]:          0 :     if (!rHd.SeekToContent(rSt))
    5106                 :          0 :         return;
    5107                 :            : 
    5108                 :          0 :     sal_Bool bFirst = sal_True;
    5109                 :          0 :     DffRecordHeader aShapeHd;
    5110 [ #  # ][ #  # ]:          0 :     while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < rHd.GetRecEndFilePos() ) )
                 [ #  # ]
    5111                 :            :     {
    5112         [ #  # ]:          0 :         rSt >> aShapeHd;
    5113 [ #  # ][ #  # ]:          0 :         if ( ( aShapeHd.nRecType == DFF_msofbtSpContainer ) ||
    5114                 :            :                 ( aShapeHd.nRecType == DFF_msofbtSpgrContainer ) )
    5115                 :            :         {
    5116                 :          0 :             DffRecordHeader aShapeHd2( aShapeHd );
    5117         [ #  # ]:          0 :             if ( aShapeHd.nRecType == DFF_msofbtSpgrContainer )
    5118         [ #  # ]:          0 :                 rSt >> aShapeHd2;
    5119 [ #  # ][ #  # ]:          0 :             while( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aShapeHd2.GetRecEndFilePos() ) )
                 [ #  # ]
    5120                 :            :             {
    5121                 :          0 :                 DffRecordHeader aShapeAtom;
    5122         [ #  # ]:          0 :                 rSt >> aShapeAtom;
    5123         [ #  # ]:          0 :                 if ( aShapeAtom.nRecType == DFF_msofbtChildAnchor )
    5124                 :            :                 {
    5125                 :            :                     sal_Int32 l, o, r, u;
    5126 [ #  # ][ #  # ]:          0 :                     rSt >> l >> o >> r >> u;
         [ #  # ][ #  # ]
    5127         [ #  # ]:          0 :                     Scale( l );
    5128         [ #  # ]:          0 :                     Scale( o );
    5129         [ #  # ]:          0 :                     Scale( r );
    5130         [ #  # ]:          0 :                     Scale( u );
    5131         [ #  # ]:          0 :                     Rectangle aChild( l, o, r, u );
    5132                 :            : 
    5133         [ #  # ]:          0 :                     if ( bFirst )
    5134                 :            :                     {
    5135 [ #  # ][ #  # ]:          0 :                         if ( !rGlobalChildRect.IsEmpty() && !rClientRect.IsEmpty() && rGlobalChildRect.GetWidth() && rGlobalChildRect.GetHeight() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    5136                 :            :                         {
    5137                 :          0 :                             double fl = l;
    5138                 :          0 :                             double fo = o;
    5139                 :          0 :                             double fWidth = r - l;
    5140                 :          0 :                             double fHeight= u - o;
    5141 [ #  # ][ #  # ]:          0 :                             double fXScale = (double)rClientRect.GetWidth() / (double)rGlobalChildRect.GetWidth();
    5142 [ #  # ][ #  # ]:          0 :                             double fYScale = (double)rClientRect.GetHeight() / (double)rGlobalChildRect.GetHeight();
    5143                 :          0 :                             fl = ( ( l - rGlobalChildRect.Left() ) * fXScale ) + rClientRect.Left();
    5144                 :          0 :                             fo = ( ( o - rGlobalChildRect.Top()  ) * fYScale ) + rClientRect.Top();
    5145                 :          0 :                             fWidth *= fXScale;
    5146                 :          0 :                             fHeight *= fYScale;
    5147         [ #  # ]:          0 :                             rGroupClientAnchor = Rectangle( Point( (sal_Int32)fl, (sal_Int32)fo ), Size( (sal_Int32)( fWidth + 1 ), (sal_Int32)( fHeight + 1 ) ) );
    5148                 :            :                         }
    5149                 :          0 :                         bFirst = sal_False;
    5150                 :            :                     }
    5151                 :            :                     else
    5152         [ #  # ]:          0 :                         rGroupChildAnchor.Union( aChild );
    5153                 :            :                     break;
    5154                 :            :                 }
    5155 [ #  # ][ #  # ]:          0 :                 if (!aShapeAtom.SeekToEndOfRecord(rSt))
    5156                 :            :                     break;
    5157                 :            :             }
    5158                 :            :         }
    5159 [ #  # ][ #  # ]:          0 :         if (!aShapeHd.SeekToEndOfRecord(rSt))
    5160                 :          0 :             break;
    5161                 :            :     }
    5162                 :            : }
    5163                 :            : 
    5164                 :          0 : SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
    5165                 :            :                                        DffObjData& rObjData,
    5166                 :            :                                        void* pData,
    5167                 :            :                                        Rectangle& rTextRect,
    5168                 :            :                                        SdrObject* pObj
    5169                 :            :                                        )
    5170                 :            : {
    5171         [ #  # ]:          0 :     if( !rTextRect.IsEmpty() )
    5172                 :            :     {
    5173                 :          0 :         SvxMSDffImportData& rImportData = *(SvxMSDffImportData*)pData;
    5174         [ #  # ]:          0 :         SvxMSDffImportRec* pImpRec = new SvxMSDffImportRec;
    5175                 :          0 :         SvxMSDffImportRec* pTextImpRec = pImpRec;
    5176                 :            : 
    5177                 :            :         // fill Import Record with data
    5178                 :          0 :         pImpRec->nShapeId   = rObjData.nShapeId;
    5179                 :          0 :         pImpRec->eShapeType = rObjData.eShapeType;
    5180                 :            : 
    5181                 :            :         MSO_WrapMode eWrapMode( (MSO_WrapMode)GetPropertyValue(
    5182                 :            :                                                             DFF_Prop_WrapText,
    5183                 :          0 :                                                             mso_wrapSquare ) );
    5184                 :            :         rObjData.bClientAnchor = maShapeRecords.SeekToContent( rSt,
    5185                 :            :                                             DFF_msofbtClientAnchor,
    5186                 :          0 :                                             SEEK_FROM_CURRENT_AND_RESTART );
    5187         [ #  # ]:          0 :         if( rObjData.bClientAnchor )
    5188                 :            :             ProcessClientAnchor( rSt,
    5189                 :          0 :                     maShapeRecords.Current()->nRecLen,
    5190                 :          0 :                     pImpRec->pClientAnchorBuffer, pImpRec->nClientAnchorLen );
    5191                 :            : 
    5192                 :            :         rObjData.bClientData = maShapeRecords.SeekToContent( rSt,
    5193                 :            :                                             DFF_msofbtClientData,
    5194                 :          0 :                                             SEEK_FROM_CURRENT_AND_RESTART );
    5195         [ #  # ]:          0 :         if( rObjData.bClientData )
    5196                 :            :             ProcessClientData( rSt,
    5197                 :          0 :                     maShapeRecords.Current()->nRecLen,
    5198                 :          0 :                     pImpRec->pClientDataBuffer, pImpRec->nClientDataLen );
    5199                 :            : 
    5200                 :            : 
    5201                 :            :         // process user (== Winword) defined parameters in 0xF122 record
    5202         [ #  # ]:          0 :         if(    maShapeRecords.SeekToContent( rSt,
           [ #  #  #  # ]
    5203                 :            :                                              DFF_msofbtUDefProp,
    5204                 :          0 :                                              SEEK_FROM_CURRENT_AND_RESTART )
    5205                 :          0 :             && maShapeRecords.Current()->nRecLen )
    5206                 :            :         {
    5207         [ #  # ]:          0 :             sal_uInt32  nBytesLeft = maShapeRecords.Current()->nRecLen;
    5208                 :            :             sal_uInt32  nUDData;
    5209                 :            :             sal_uInt16  nPID;
    5210         [ #  # ]:          0 :             while( 5 < nBytesLeft )
    5211                 :            :             {
    5212         [ #  # ]:          0 :                 rSt >> nPID;
    5213         [ #  # ]:          0 :                 if ( rSt.GetError() != 0 )
    5214                 :          0 :                     break;
    5215         [ #  # ]:          0 :                 rSt >> nUDData;
    5216   [ #  #  #  #  :          0 :                 switch( nPID )
             #  #  #  # ]
    5217                 :            :                 {
    5218                 :          0 :                     case 0x038F: pImpRec->nXAlign = nUDData; break;
    5219                 :            :                     case 0x0390:
    5220         [ #  # ]:          0 :                         if (pImpRec->pXRelTo)
    5221                 :          0 :                             delete pImpRec->pXRelTo;
    5222         [ #  # ]:          0 :                         pImpRec->pXRelTo = new sal_uInt32;
    5223                 :          0 :                         *(pImpRec->pXRelTo) = nUDData;
    5224                 :          0 :                         break;
    5225                 :          0 :                     case 0x0391: pImpRec->nYAlign = nUDData; break;
    5226                 :            :                     case 0x0392:
    5227         [ #  # ]:          0 :                         if (pImpRec->pYRelTo)
    5228                 :          0 :                             delete pImpRec->pYRelTo;
    5229         [ #  # ]:          0 :                         pImpRec->pYRelTo = new sal_uInt32;
    5230                 :          0 :                         *(pImpRec->pYRelTo) = nUDData;
    5231                 :          0 :                         break;
    5232                 :          0 :                     case 0x03BF: pImpRec->nLayoutInTableCell = nUDData; break;
    5233                 :            :                     case 0x0393:
    5234                 :            :                     // This seems to correspond to o:hrpct from .docx (even including
    5235                 :            :                     // the difference that it's in 0.1% even though the .docx spec
    5236                 :            :                     // says it's in 1%).
    5237                 :          0 :                         pImpRec->relativeHorizontalWidth = nUDData;
    5238                 :          0 :                         break;
    5239                 :            :                     case 0x0394:
    5240                 :            :                     // And this is really just a guess, but a mere presence of this
    5241                 :            :                     // flag makes a horizontal rule be as wide as the page (unless
    5242                 :            :                     // overriden by something), so it probably matches o:hr from .docx.
    5243                 :          0 :                         pImpRec->isHorizontalRule = true;
    5244                 :          0 :                         break;
    5245                 :            :                 }
    5246         [ #  # ]:          0 :                 if ( rSt.GetError() != 0 )
    5247                 :          0 :                     break;
    5248                 :          0 :                 pImpRec->bHasUDefProp = sal_True;
    5249                 :          0 :                 nBytesLeft  -= 6;
    5250                 :            :             }
    5251                 :            :         }
    5252                 :            : 
    5253                 :            :         //  text frame, also Title or Outline
    5254                 :          0 :         SdrObject*  pOrgObj  = pObj;
    5255                 :          0 :         SdrRectObj* pTextObj = 0;
    5256                 :          0 :         sal_uInt32 nTextId = GetPropertyValue( DFF_Prop_lTxid, 0 );
    5257         [ #  # ]:          0 :         if( nTextId )
    5258                 :            :         {
    5259         [ #  # ]:          0 :             SfxItemSet aSet( pSdrModel->GetItemPool() );
    5260                 :            : 
    5261                 :            :             //Originally anything that as a mso_sptTextBox was created as a
    5262                 :            :             //textbox, this was changed for #88277# to be created as a simple
    5263                 :            :             //rect to keep impress happy. For the rest of us we'd like to turn
    5264                 :            :             //it back into a textbox again.
    5265                 :          0 :             bool bTextFrame = (pImpRec->eShapeType == mso_sptTextBox);
    5266         [ #  # ]:          0 :             if (!bTextFrame)
    5267                 :            :             {
    5268                 :            :                 //Either
    5269                 :            :                 //a) its a simple text object or
    5270                 :            :                 //b) its a rectangle with text and square wrapping.
    5271                 :            :                 bTextFrame =
    5272                 :            :                 (
    5273                 :            :                     (pImpRec->eShapeType == mso_sptTextSimple) ||
    5274                 :            :                     (
    5275                 :            :                         (pImpRec->eShapeType == mso_sptRectangle)
    5276                 :            :                         && (eWrapMode == mso_wrapSquare)
    5277         [ #  # ]:          0 :                         && ShapeHasText(pImpRec->nShapeId, rObjData.rSpHd.GetRecBegFilePos() )
    5278                 :            :                     )
    5279 [ #  # ][ #  # ]:          0 :                 );
         [ #  # ][ #  # ]
    5280                 :            :             }
    5281                 :            : 
    5282         [ #  # ]:          0 :             if (bTextFrame)
    5283                 :            :             {
    5284         [ #  # ]:          0 :                 SdrObject::Free( pObj );
    5285                 :          0 :                 pObj = pOrgObj = 0;
    5286                 :            :             }
    5287                 :            : 
    5288                 :            :             // Distance of Textbox to it's surrounding Customshape
    5289         [ #  # ]:          0 :             sal_Int32 nTextLeft = GetPropertyValue( DFF_Prop_dxTextLeft, 91440L);
    5290         [ #  # ]:          0 :             sal_Int32 nTextRight = GetPropertyValue( DFF_Prop_dxTextRight, 91440L );
    5291         [ #  # ]:          0 :             sal_Int32 nTextTop = GetPropertyValue( DFF_Prop_dyTextTop, 45720L  );
    5292         [ #  # ]:          0 :             sal_Int32 nTextBottom = GetPropertyValue( DFF_Prop_dyTextBottom, 45720L );
    5293                 :            : 
    5294         [ #  # ]:          0 :             ScaleEmu( nTextLeft );
    5295         [ #  # ]:          0 :             ScaleEmu( nTextRight );
    5296         [ #  # ]:          0 :             ScaleEmu( nTextTop );
    5297         [ #  # ]:          0 :             ScaleEmu( nTextBottom );
    5298                 :            : 
    5299                 :          0 :             sal_Int32 nTextRotationAngle=0;
    5300                 :          0 :             bool bVerticalText = false;
    5301         [ #  # ]:          0 :             if ( IsProperty( DFF_Prop_txflTextFlow ) )
    5302                 :            :             {
    5303                 :            :                 MSO_TextFlow eTextFlow = (MSO_TextFlow)(GetPropertyValue(
    5304         [ #  # ]:          0 :                     DFF_Prop_txflTextFlow) & 0xFFFF);
    5305   [ #  #  #  #  :          0 :                 switch( eTextFlow )
                      # ]
    5306                 :            :                 {
    5307                 :            :                     case mso_txflBtoT:
    5308                 :          0 :                         nTextRotationAngle = 9000;
    5309                 :          0 :                     break;
    5310                 :            :                     case mso_txflVertN:
    5311                 :            :                     case mso_txflTtoBN:
    5312                 :          0 :                         nTextRotationAngle = 27000;
    5313                 :          0 :                         break;
    5314                 :            :                     case mso_txflTtoBA:
    5315                 :          0 :                         bVerticalText = true;
    5316                 :          0 :                     break;
    5317                 :            :                     case mso_txflHorzA:
    5318                 :          0 :                         bVerticalText = true;
    5319                 :          0 :                         nTextRotationAngle = 9000;
    5320                 :            :                     case mso_txflHorzN:
    5321                 :            :                     default :
    5322                 :          0 :                         break;
    5323                 :            :                 }
    5324                 :            :             }
    5325                 :            : 
    5326         [ #  # ]:          0 :             if (nTextRotationAngle)
    5327                 :            :             {
    5328         [ #  # ]:          0 :                 while (nTextRotationAngle > 360000)
    5329                 :          0 :                     nTextRotationAngle-=9000;
    5330      [ #  #  # ]:          0 :                 switch (nTextRotationAngle)
    5331                 :            :                 {
    5332                 :            :                     case 9000:
    5333                 :            :                         {
    5334         [ #  # ]:          0 :                             long nWidth = rTextRect.GetWidth();
    5335         [ #  # ]:          0 :                             rTextRect.Right() = rTextRect.Left() + rTextRect.GetHeight();
    5336                 :          0 :                             rTextRect.Bottom() = rTextRect.Top() + nWidth;
    5337                 :            : 
    5338                 :          0 :                             sal_Int32 nOldTextLeft = nTextLeft;
    5339                 :          0 :                             sal_Int32 nOldTextRight = nTextRight;
    5340                 :          0 :                             sal_Int32 nOldTextTop = nTextTop;
    5341                 :          0 :                             sal_Int32 nOldTextBottom = nTextBottom;
    5342                 :            : 
    5343                 :          0 :                             nTextLeft = nOldTextBottom;
    5344                 :          0 :                             nTextRight = nOldTextTop;
    5345                 :          0 :                             nTextTop = nOldTextLeft;
    5346                 :          0 :                             nTextBottom = nOldTextRight;
    5347                 :            :                         }
    5348                 :          0 :                         break;
    5349                 :            :                     case 27000:
    5350                 :            :                         {
    5351         [ #  # ]:          0 :                             long nWidth = rTextRect.GetWidth();
    5352         [ #  # ]:          0 :                             rTextRect.Right() = rTextRect.Left() + rTextRect.GetHeight();
    5353                 :          0 :                             rTextRect.Bottom() = rTextRect.Top() + nWidth;
    5354                 :            : 
    5355                 :          0 :                             sal_Int32 nOldTextLeft = nTextLeft;
    5356                 :          0 :                             sal_Int32 nOldTextRight = nTextRight;
    5357                 :          0 :                             sal_Int32 nOldTextTop = nTextTop;
    5358                 :          0 :                             sal_Int32 nOldTextBottom = nTextBottom;
    5359                 :            : 
    5360                 :          0 :                             nTextLeft = nOldTextTop;
    5361                 :          0 :                             nTextRight = nOldTextBottom;
    5362                 :          0 :                             nTextTop = nOldTextRight;
    5363                 :          0 :                             nTextBottom = nOldTextLeft;
    5364                 :            :                         }
    5365                 :          0 :                         break;
    5366                 :            :                     default:
    5367                 :          0 :                         break;
    5368                 :            :                 }
    5369                 :            :             }
    5370                 :            : 
    5371 [ #  # ][ #  # ]:          0 :             pTextObj = new SdrRectObj(OBJ_TEXT, rTextRect);
    5372 [ #  # ][ #  # ]:          0 :             pTextImpRec = new SvxMSDffImportRec(*pImpRec);
    5373                 :            : 
    5374                 :            :             // the vertical paragraph indents are part of the BoundRect,
    5375                 :            :             // here we 'remove' them by calculating
    5376                 :          0 :             Rectangle aNewRect(rTextRect);
    5377                 :          0 :             aNewRect.Bottom() -= nTextTop + nTextBottom;
    5378                 :          0 :             aNewRect.Right() -= nTextLeft + nTextRight;
    5379                 :            : 
    5380                 :            :             // Only if it's a simple textbox may Writer replace
    5381                 :            :             // the object with a frame, otherwise
    5382         [ #  # ]:          0 :             if( bTextFrame )
    5383                 :            :             {
    5384                 :            :                 ::boost::shared_ptr<SvxMSDffShapeInfo> const pTmpRec(
    5385 [ #  # ][ #  # ]:          0 :                     new SvxMSDffShapeInfo(0, pImpRec->nShapeId));
    5386                 :            : 
    5387                 :            :                 SvxMSDffShapeInfos_ById::const_iterator const it =
    5388         [ #  # ]:          0 :                     m_pShapeInfosById->find(pTmpRec);
    5389         [ #  # ]:          0 :                 if (it != m_pShapeInfosById->end())
    5390                 :            :                 {
    5391                 :          0 :                     SvxMSDffShapeInfo& rInfo = **it;
    5392                 :          0 :                     pTextImpRec->bReplaceByFly   = rInfo.bReplaceByFly;
    5393                 :          0 :                     pTextImpRec->bLastBoxInChain = rInfo.bLastBoxInChain;
    5394         [ #  # ]:          0 :                 }
    5395                 :            :             }
    5396                 :            : 
    5397         [ #  # ]:          0 :             if( !pObj )
    5398         [ #  # ]:          0 :                 ApplyAttributes( rSt, aSet, rObjData );
    5399                 :            : 
    5400                 :          0 :             bool bFitText = false;
    5401 [ #  # ][ #  # ]:          0 :             if (GetPropertyValue(DFF_Prop_FitTextToShape) & 2)
    5402                 :            :             {
    5403 [ #  # ][ #  # ]:          0 :                 aSet.Put( SdrTextAutoGrowHeightItem( sal_True ) );
                 [ #  # ]
    5404                 :            :                 aSet.Put( SdrTextMinFrameHeightItem(
    5405 [ #  # ][ #  # ]:          0 :                     aNewRect.Bottom() - aNewRect.Top() ) );
                 [ #  # ]
    5406                 :            :                 aSet.Put( SdrTextMinFrameWidthItem(
    5407 [ #  # ][ #  # ]:          0 :                     aNewRect.Right() - aNewRect.Left() ) );
                 [ #  # ]
    5408                 :          0 :                 bFitText = true;
    5409                 :            :             }
    5410                 :            :             else
    5411                 :            :             {
    5412 [ #  # ][ #  # ]:          0 :                 aSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
                 [ #  # ]
    5413 [ #  # ][ #  # ]:          0 :                 aSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
                 [ #  # ]
    5414                 :            :             }
    5415                 :            : 
    5416      [ #  #  # ]:          0 :             switch ( (MSO_WrapMode)
    5417         [ #  # ]:          0 :                 GetPropertyValue( DFF_Prop_WrapText, mso_wrapSquare ) )
    5418                 :            :             {
    5419                 :            :                 case mso_wrapNone :
    5420 [ #  # ][ #  # ]:          0 :                     aSet.Put( SdrTextAutoGrowWidthItem( sal_True ) );
                 [ #  # ]
    5421         [ #  # ]:          0 :                     if (bFitText)
    5422                 :            :                     {
    5423                 :            :                         //can't do autowidth in flys #i107184#
    5424                 :          0 :                         pTextImpRec->bReplaceByFly = false;
    5425                 :            :                     }
    5426                 :          0 :                 break;
    5427                 :            :                 case mso_wrapByPoints :
    5428 [ #  # ][ #  # ]:          0 :                     aSet.Put( SdrTextContourFrameItem( sal_True ) );
                 [ #  # ]
    5429                 :          0 :                 break;
    5430                 :          0 :                 default: break;
    5431                 :            :             }
    5432                 :            : 
    5433                 :            :             // set margins at the border of the textbox
    5434 [ #  # ][ #  # ]:          0 :             aSet.Put( SdrTextLeftDistItem( nTextLeft ) );
                 [ #  # ]
    5435 [ #  # ][ #  # ]:          0 :             aSet.Put( SdrTextRightDistItem( nTextRight ) );
                 [ #  # ]
    5436 [ #  # ][ #  # ]:          0 :             aSet.Put( SdrTextUpperDistItem( nTextTop ) );
                 [ #  # ]
    5437 [ #  # ][ #  # ]:          0 :             aSet.Put( SdrTextLowerDistItem( nTextBottom ) );
                 [ #  # ]
    5438                 :          0 :             pTextImpRec->nDxTextLeft    = nTextLeft;
    5439                 :          0 :             pTextImpRec->nDyTextTop     = nTextTop;
    5440                 :          0 :             pTextImpRec->nDxTextRight   = nTextRight;
    5441                 :          0 :             pTextImpRec->nDyTextBottom  = nTextBottom;
    5442                 :            : 
    5443                 :            :             // read text anchor
    5444         [ #  # ]:          0 :             if ( IsProperty( DFF_Prop_anchorText ) )
    5445                 :            :             {
    5446                 :            :                 MSO_Anchor eTextAnchor =
    5447         [ #  # ]:          0 :                     (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText );
    5448                 :            : 
    5449                 :          0 :                 SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_CENTER;
    5450                 :          0 :                 sal_Bool bTVASet(sal_False);
    5451                 :          0 :                 SdrTextHorzAdjust eTHA = SDRTEXTHORZADJUST_CENTER;
    5452                 :          0 :                 sal_Bool bTHASet(sal_False);
    5453                 :            : 
    5454   [ #  #  #  #  :          0 :                 switch( eTextAnchor )
                #  #  # ]
    5455                 :            :                 {
    5456                 :            :                     case mso_anchorTop:
    5457                 :            :                     {
    5458                 :          0 :                         eTVA = SDRTEXTVERTADJUST_TOP;
    5459                 :          0 :                         bTVASet = sal_True;
    5460                 :            :                     }
    5461                 :          0 :                     break;
    5462                 :            :                     case mso_anchorTopCentered:
    5463                 :            :                     {
    5464                 :          0 :                         eTVA = SDRTEXTVERTADJUST_TOP;
    5465                 :          0 :                         bTVASet = sal_True;
    5466                 :          0 :                         bTHASet = sal_True;
    5467                 :            :                     }
    5468                 :          0 :                     break;
    5469                 :            : 
    5470                 :            :                     case mso_anchorMiddle:
    5471                 :          0 :                         bTVASet = sal_True;
    5472                 :          0 :                     break;
    5473                 :            :                     case mso_anchorMiddleCentered:
    5474                 :            :                     {
    5475                 :          0 :                         bTVASet = sal_True;
    5476                 :          0 :                         bTHASet = sal_True;
    5477                 :            :                     }
    5478                 :          0 :                     break;
    5479                 :            :                     case mso_anchorBottom:
    5480                 :            :                     {
    5481                 :          0 :                         eTVA = SDRTEXTVERTADJUST_BOTTOM;
    5482                 :          0 :                         bTVASet = sal_True;
    5483                 :            :                     }
    5484                 :          0 :                     break;
    5485                 :            :                     case mso_anchorBottomCentered:
    5486                 :            :                     {
    5487                 :          0 :                         eTVA = SDRTEXTVERTADJUST_BOTTOM;
    5488                 :          0 :                         bTVASet = sal_True;
    5489                 :          0 :                         bTHASet = sal_True;
    5490                 :            :                     }
    5491                 :          0 :                     break;
    5492                 :          0 :                     default : break;
    5493                 :            :                 }
    5494                 :            :                 // insert
    5495         [ #  # ]:          0 :                 if ( bTVASet )
    5496 [ #  # ][ #  # ]:          0 :                     aSet.Put( SdrTextVertAdjustItem( eTVA ) );
                 [ #  # ]
    5497         [ #  # ]:          0 :                 if ( bTHASet )
    5498 [ #  # ][ #  # ]:          0 :                     aSet.Put( SdrTextHorzAdjustItem( eTHA ) );
                 [ #  # ]
    5499                 :            :             }
    5500                 :            : 
    5501         [ #  # ]:          0 :             pTextObj->SetMergedItemSet(aSet);
    5502         [ #  # ]:          0 :             pTextObj->SetModel(pSdrModel);
    5503                 :            : 
    5504         [ #  # ]:          0 :             if (bVerticalText)
    5505         [ #  # ]:          0 :                 pTextObj->SetVerticalWriting(sal_True);
    5506                 :            : 
    5507         [ #  # ]:          0 :             if (nTextRotationAngle)
    5508                 :            :             {
    5509 [ #  # ][ #  # ]:          0 :                 long nMinWH = rTextRect.GetWidth() < rTextRect.GetHeight() ?
    5510 [ #  # ][ #  # ]:          0 :                     rTextRect.GetWidth() : rTextRect.GetHeight();
                 [ #  # ]
    5511                 :          0 :                 nMinWH /= 2;
    5512                 :          0 :                 Point aPivot(rTextRect.TopLeft());
    5513                 :          0 :                 aPivot.X() += nMinWH;
    5514                 :          0 :                 aPivot.Y() += nMinWH;
    5515                 :          0 :                 double a = nTextRotationAngle * nPi180;
    5516         [ #  # ]:          0 :                 pTextObj->NbcRotate(aPivot, nTextRotationAngle, sin(a), cos(a));
    5517                 :            :             }
    5518                 :            : 
    5519                 :            :             // rotate text with shape?
    5520         [ #  # ]:          0 :             if ( mnFix16Angle )
    5521                 :            :             {
    5522                 :          0 :                 double a = mnFix16Angle * nPi180;
    5523                 :          0 :                 pTextObj->NbcRotate( rObjData.aBoundRect.Center(), mnFix16Angle,
    5524 [ #  # ][ #  # ]:          0 :                     sin( a ), cos( a ) );
    5525                 :            :             }
    5526                 :            : 
    5527         [ #  # ]:          0 :             if( !pObj )
    5528                 :            :             {
    5529                 :          0 :                 pObj = pTextObj;
    5530                 :            :             }
    5531                 :            :             else
    5532                 :            :             {
    5533         [ #  # ]:          0 :                 if( pTextObj != pObj )
    5534                 :            :                 {
    5535 [ #  # ][ #  # ]:          0 :                     SdrObject* pGroup = new SdrObjGroup;
    5536 [ #  # ][ #  # ]:          0 :                     pGroup->GetSubList()->NbcInsertObject( pObj );
    5537 [ #  # ][ #  # ]:          0 :                     pGroup->GetSubList()->NbcInsertObject( pTextObj );
    5538         [ #  # ]:          0 :                     if (pOrgObj == pObj)
    5539                 :          0 :                         pOrgObj = pGroup;
    5540                 :            :                     else
    5541                 :          0 :                         pOrgObj = pObj;
    5542                 :          0 :                     pObj = pGroup;
    5543                 :            :                 }
    5544         [ #  # ]:          0 :             }
    5545                 :            :         }
    5546         [ #  # ]:          0 :         else if( !pObj )
    5547                 :            :         {
    5548                 :            :             // simple rectangular objects are ignored by ImportObj()  :-(
    5549                 :            :             // this is OK for Draw but not for Calc and Writer
    5550                 :            :             // cause here these objects have a default border
    5551 [ #  # ][ #  # ]:          0 :             pObj = new SdrRectObj(rTextRect);
    5552                 :          0 :             pOrgObj = pObj;
    5553         [ #  # ]:          0 :             pObj->SetModel( pSdrModel );
    5554         [ #  # ]:          0 :             SfxItemSet aSet( pSdrModel->GetItemPool() );
    5555         [ #  # ]:          0 :             ApplyAttributes( rSt, aSet, rObjData );
    5556                 :            : 
    5557                 :          0 :             const SfxPoolItem* pPoolItem=NULL;
    5558                 :            :             SfxItemState eState = aSet.GetItemState( XATTR_FILLCOLOR,
    5559         [ #  # ]:          0 :                                                      sal_False, &pPoolItem );
    5560         [ #  # ]:          0 :             if( SFX_ITEM_DEFAULT == eState )
    5561                 :            :                 aSet.Put( XFillColorItem( rtl::OUString(),
    5562 [ #  # ][ #  # ]:          0 :                           Color( mnDefaultColor ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    5563 [ #  # ][ #  # ]:          0 :             pObj->SetMergedItemSet(aSet);
    5564                 :            :         }
    5565                 :            : 
    5566                 :            :         //Means that fBehindDocument is set
    5567         [ #  # ]:          0 :         if (GetPropertyValue(DFF_Prop_fPrint) & 0x20)
    5568                 :          0 :             pImpRec->bDrawHell = sal_True;
    5569                 :            :         else
    5570                 :          0 :             pImpRec->bDrawHell = sal_False;
    5571         [ #  # ]:          0 :         if (GetPropertyValue(DFF_Prop_fPrint) & 0x02)
    5572                 :          0 :             pImpRec->bHidden = sal_True;
    5573                 :          0 :         pTextImpRec->bDrawHell  = pImpRec->bDrawHell;
    5574                 :          0 :         pTextImpRec->bHidden = pImpRec->bHidden;
    5575                 :          0 :         pImpRec->nNextShapeId   = GetPropertyValue( DFF_Prop_hspNext, 0 );
    5576                 :          0 :         pTextImpRec->nNextShapeId=pImpRec->nNextShapeId;
    5577                 :            : 
    5578         [ #  # ]:          0 :         if ( nTextId )
    5579                 :            :         {
    5580                 :          0 :             pTextImpRec->aTextId.nTxBxS = (sal_uInt16)( nTextId >> 16 );
    5581                 :          0 :             pTextImpRec->aTextId.nSequence = (sal_uInt16)nTextId;
    5582                 :            :         }
    5583                 :            : 
    5584                 :            :         pTextImpRec->nDxWrapDistLeft = GetPropertyValue(
    5585                 :          0 :                                     DFF_Prop_dxWrapDistLeft, 114935L ) / 635L;
    5586                 :            :         pTextImpRec->nDyWrapDistTop = GetPropertyValue(
    5587                 :          0 :                                     DFF_Prop_dyWrapDistTop, 0 ) / 635L;
    5588                 :            :         pTextImpRec->nDxWrapDistRight = GetPropertyValue(
    5589                 :          0 :                                     DFF_Prop_dxWrapDistRight, 114935L ) / 635L;
    5590                 :            :         pTextImpRec->nDyWrapDistBottom = GetPropertyValue(
    5591                 :          0 :                                     DFF_Prop_dyWrapDistBottom, 0 ) / 635L;
    5592                 :            :         // 16.16 fraction times total image width or height, as appropriate.
    5593                 :            : 
    5594         [ #  # ]:          0 :         if (SeekToContent(DFF_Prop_pWrapPolygonVertices, rSt))
    5595                 :            :         {
    5596 [ #  # ][ #  # ]:          0 :             delete pTextImpRec->pWrapPolygon;
    5597                 :            :             sal_uInt16 nNumElemVert, nNumElemMemVert, nElemSizeVert;
    5598 [ #  # ][ #  # ]:          0 :             rSt >> nNumElemVert >> nNumElemMemVert >> nElemSizeVert;
                 [ #  # ]
    5599 [ #  # ][ #  # ]:          0 :             if (nNumElemVert && ((nElemSizeVert == 8) || (nElemSizeVert == 4)))
                 [ #  # ]
    5600                 :            :             {
    5601 [ #  # ][ #  # ]:          0 :                 pTextImpRec->pWrapPolygon = new Polygon(nNumElemVert);
    5602         [ #  # ]:          0 :                 for (sal_uInt16 i = 0; i < nNumElemVert; ++i)
    5603                 :            :                 {
    5604                 :            :                     sal_Int32 nX, nY;
    5605         [ #  # ]:          0 :                     if (nElemSizeVert == 8)
    5606 [ #  # ][ #  # ]:          0 :                         rSt >> nX >> nY;
    5607                 :            :                     else
    5608                 :            :                     {
    5609                 :            :                         sal_Int16 nSmallX, nSmallY;
    5610 [ #  # ][ #  # ]:          0 :                         rSt >> nSmallX >> nSmallY;
    5611                 :          0 :                         nX = nSmallX;
    5612                 :          0 :                         nY = nSmallY;
    5613                 :            :                     }
    5614         [ #  # ]:          0 :                     (*(pTextImpRec->pWrapPolygon))[i].X() = nX;
    5615         [ #  # ]:          0 :                     (*(pTextImpRec->pWrapPolygon))[i].Y() = nY;
    5616                 :            :                 }
    5617                 :            :             }
    5618                 :            :         }
    5619                 :            : 
    5620                 :            :         pImpRec->nCropFromTop = GetPropertyValue(
    5621                 :          0 :                                     DFF_Prop_cropFromTop, 0 );
    5622                 :            :         pImpRec->nCropFromBottom = GetPropertyValue(
    5623                 :          0 :                                     DFF_Prop_cropFromBottom, 0 );
    5624                 :            :         pImpRec->nCropFromLeft = GetPropertyValue(
    5625                 :          0 :                                     DFF_Prop_cropFromLeft, 0 );
    5626                 :            :         pImpRec->nCropFromRight = GetPropertyValue(
    5627                 :          0 :                                     DFF_Prop_cropFromRight, 0 );
    5628                 :            : 
    5629                 :          0 :         pImpRec->bVFlip = (rObjData.nSpFlags & SP_FFLIPV) ? true : false;
    5630                 :          0 :         pImpRec->bHFlip = (rObjData.nSpFlags & SP_FFLIPH) ? true : false;
    5631                 :            : 
    5632                 :          0 :         sal_uInt32 nLineFlags = GetPropertyValue( DFF_Prop_fNoLineDrawDash );
    5633                 :            :         pImpRec->eLineStyle = (nLineFlags & 8)
    5634                 :            :                             ? (MSO_LineStyle)GetPropertyValue(
    5635                 :            :                                                 DFF_Prop_lineStyle,
    5636                 :          0 :                                                 mso_lineSimple )
    5637         [ #  # ]:          0 :                             : (MSO_LineStyle)USHRT_MAX;
    5638                 :          0 :         pTextImpRec->eLineStyle = pImpRec->eLineStyle;
    5639                 :            : 
    5640                 :            :         pImpRec->eLineDashing = (MSO_LineDashing)GetPropertyValue(
    5641                 :          0 :                 DFF_Prop_lineDashing, mso_lineSolid );
    5642                 :          0 :         pTextImpRec->eLineDashing = pImpRec->eLineDashing;
    5643                 :            : 
    5644         [ #  # ]:          0 :         if( pImpRec->nShapeId )
    5645                 :            :         {
    5646                 :            :             // Import-Record-Liste ergaenzen
    5647         [ #  # ]:          0 :             if( pOrgObj )
    5648                 :            :             {
    5649                 :          0 :                 pImpRec->pObj = pOrgObj;
    5650                 :          0 :                 rImportData.aRecords.insert( pImpRec );
    5651                 :            :             }
    5652                 :            : 
    5653 [ #  # ][ #  # ]:          0 :             if( pTextObj && (pOrgObj != pTextObj) )
    5654                 :            :             {
    5655                 :            :                 // Modify ShapeId (must be unique)
    5656                 :          0 :                 pImpRec->nShapeId |= 0x8000000;
    5657                 :          0 :                 pTextImpRec->pObj = pTextObj;
    5658                 :          0 :                 rImportData.aRecords.insert( pTextImpRec );
    5659                 :            :             }
    5660                 :            : 
    5661                 :            :             // entry in the z-order-list in order to complement the pointer to this object
    5662                 :            :             /*Only store objects which are not deep inside the tree*/
    5663 [ #  # ][ #  # ]:          0 :             if( ( rObjData.nCalledByGroup == 0 )
                 [ #  # ]
    5664                 :            :                 ||
    5665                 :            :                 ( (rObjData.nSpFlags & SP_FGROUP)
    5666                 :            :                  && (rObjData.nCalledByGroup < 2) )
    5667                 :            :               )
    5668                 :            :                 StoreShapeOrder( pImpRec->nShapeId,
    5669                 :            :                                 ( ( (sal_uLong)pImpRec->aTextId.nTxBxS ) << 16 )
    5670                 :          0 :                                     + pImpRec->aTextId.nSequence, pObj );
    5671                 :            :         }
    5672                 :            :         else
    5673         [ #  # ]:          0 :             delete pImpRec;
    5674                 :            :     }
    5675                 :            : 
    5676                 :          0 :     return pObj;
    5677                 :            : };
    5678                 :            : 
    5679                 :        213 : void SvxMSDffManager::StoreShapeOrder(sal_uLong         nId,
    5680                 :            :                                       sal_uLong         nTxBx,
    5681                 :            :                                       SdrObject*    pObject,
    5682                 :            :                                       SwFlyFrmFmt*  pFly,
    5683                 :            :                                       short         nHdFtSection) const
    5684                 :            : {
    5685                 :        213 :     sal_uInt16 nShpCnt = pShapeOrders->size();
    5686         [ +  + ]:       8205 :     for (sal_uInt16 nShapeNum=0; nShapeNum < nShpCnt; nShapeNum++)
    5687                 :            :     {
    5688                 :       7992 :         SvxMSDffShapeOrder& rOrder = *(*pShapeOrders)[ nShapeNum ];
    5689                 :            : 
    5690         [ +  + ]:       7992 :         if( rOrder.nShapeId == nId )
    5691                 :            :         {
    5692                 :        204 :             rOrder.nTxBxComp = nTxBx;
    5693                 :        204 :             rOrder.pObj      = pObject;
    5694                 :        204 :             rOrder.pFly      = pFly;
    5695                 :        204 :             rOrder.nHdFtSection = nHdFtSection;
    5696                 :            :         }
    5697                 :            :     }
    5698                 :        213 : }
    5699                 :            : 
    5700                 :            : 
    5701                 :          6 : void SvxMSDffManager::ExchangeInShapeOrder( SdrObject*   pOldObject,
    5702                 :            :                                             sal_uLong        nTxBx,
    5703                 :            :                                             SwFlyFrmFmt* pFly,
    5704                 :            :                                             SdrObject*   pObject) const
    5705                 :            : {
    5706                 :          6 :     sal_uInt16 nShpCnt = pShapeOrders->size();
    5707         [ +  + ]:         78 :     for (sal_uInt16 nShapeNum=0; nShapeNum < nShpCnt; nShapeNum++)
    5708                 :            :     {
    5709                 :         72 :         SvxMSDffShapeOrder& rOrder = *(*pShapeOrders)[ nShapeNum ];
    5710                 :            : 
    5711         [ +  + ]:         72 :         if( rOrder.pObj == pOldObject )
    5712                 :            :         {
    5713                 :          6 :             rOrder.pFly      = pFly;
    5714                 :          6 :             rOrder.pObj      = pObject;
    5715                 :          6 :             rOrder.nTxBxComp = nTxBx;
    5716                 :            :         }
    5717                 :            :     }
    5718                 :          6 : }
    5719                 :            : 
    5720                 :            : 
    5721                 :         42 : void SvxMSDffManager::RemoveFromShapeOrder( SdrObject* pObject ) const
    5722                 :            : {
    5723                 :         42 :     sal_uInt16 nShpCnt = pShapeOrders->size();
    5724         [ +  + ]:       2301 :     for (sal_uInt16 nShapeNum=0; nShapeNum < nShpCnt; nShapeNum++)
    5725                 :            :     {
    5726                 :       2259 :         SvxMSDffShapeOrder& rOrder = *(*pShapeOrders)[ nShapeNum ];
    5727                 :            : 
    5728         [ +  + ]:       2259 :         if( rOrder.pObj == pObject )
    5729                 :            :         {
    5730                 :         42 :             rOrder.pObj      = 0;
    5731                 :         42 :             rOrder.pFly      = 0;
    5732                 :         42 :             rOrder.nTxBxComp = 0;
    5733                 :            :         }
    5734                 :            :     }
    5735                 :         42 : }
    5736                 :            : 
    5737                 :            : 
    5738                 :            : 
    5739                 :            : 
    5740                 :            : //---------------------------------------------------------------------------
    5741                 :            : //  exported class: Public Methods
    5742                 :            : //---------------------------------------------------------------------------
    5743                 :            : 
    5744                 :         59 : SvxMSDffManager::SvxMSDffManager(SvStream& rStCtrl_,
    5745                 :            :                                  const String& rBaseURL,
    5746                 :            :                                  sal_uInt32 nOffsDgg_,
    5747                 :            :                                  SvStream* pStData_,
    5748                 :            :                                  SdrModel* pSdrModel_,// see SetModel() below
    5749                 :            :                                  long      nApplicationScale,
    5750                 :            :                                  ColorData mnDefaultColor_,
    5751                 :            :                                  sal_uLong     nDefaultFontHeight_,
    5752                 :            :                                  SvStream* pStData2_ )
    5753                 :            :     :DffPropertyReader( *this ),
    5754                 :            :      pFormModel( NULL ),
    5755         [ +  - ]:         59 :      pBLIPInfos( new SvxMSDffBLIPInfos  ),
    5756         [ +  - ]:         59 :      m_pShapeInfosByTxBxComp( new SvxMSDffShapeInfos_ByTxBxComp ),
    5757         [ +  - ]:         59 :      pShapeOrders( new SvxMSDffShapeOrders ),
    5758                 :            :      nDefaultFontHeight( nDefaultFontHeight_),
    5759                 :            :      nOffsDgg( nOffsDgg_ ),
    5760                 :            :      nBLIPCount(  USHRT_MAX ),              // initialize with error, since we fist check if the
    5761                 :            :      nShapeCount( USHRT_MAX ),              // control stream has correct data
    5762                 :            :      nGroupShapeFlags(0),                   // ensure initialization here, as some corrupted
    5763                 :            :                                             // files may yield to this being unitialized
    5764                 :            :      maBaseURL( rBaseURL ),
    5765                 :            :      rStCtrl(  rStCtrl_  ),
    5766                 :            :      pStData(  pStData_  ),
    5767                 :            :      pStData2( pStData2_ ),
    5768                 :            :      nSvxMSDffSettings( 0 ),
    5769                 :            :      nSvxMSDffOLEConvFlags( 0 ),
    5770                 :            :      mnDefaultColor( mnDefaultColor_),
    5771 [ +  - ][ +  - ]:        236 :      mbTracing( sal_False )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    5772                 :            : {
    5773         [ +  - ]:         59 :     SetModel( pSdrModel_, nApplicationScale );
    5774                 :            : 
    5775                 :            :     // remember FilePos of the stream(s)
    5776                 :         59 :     sal_uLong nOldPosCtrl = rStCtrl.Tell();
    5777         [ +  + ]:         59 :     sal_uLong nOldPosData = pStData ? pStData->Tell() : nOldPosCtrl;
    5778                 :            : 
    5779                 :            :     // if no data stream is given we assume that the BLIPs
    5780                 :            :     // are in the control stream
    5781         [ +  + ]:         59 :     if( !pStData )
    5782                 :         17 :         pStData = &rStCtrl;
    5783                 :            : 
    5784         [ +  - ]:         59 :     SetDefaultPropSet( rStCtrl, nOffsDgg );
    5785                 :            : 
    5786                 :            :     // read control stream, if successful set nBLIPCount
    5787         [ +  - ]:         59 :     GetCtrlData( nOffsDgg );
    5788                 :            : 
    5789                 :            :     // check Text-Box-Story-Chain-Infos
    5790         [ +  - ]:         59 :     CheckTxBxStoryChain();
    5791                 :            : 
    5792                 :            :     // restore old FilePos of the stream(s)
    5793         [ +  - ]:         59 :     rStCtrl.Seek( nOldPosCtrl );
    5794         [ +  + ]:         59 :     if( &rStCtrl != pStData )
    5795         [ +  - ]:         42 :         pStData->Seek( nOldPosData );
    5796                 :         59 : }
    5797                 :            : 
    5798                 :         15 : SvxMSDffManager::SvxMSDffManager( SvStream& rStCtrl_, const String& rBaseURL )
    5799                 :            :     :DffPropertyReader( *this ),
    5800                 :            :      pFormModel( NULL ),
    5801         [ +  - ]:         15 :      pBLIPInfos(   new SvxMSDffBLIPInfos  ),
    5802         [ +  - ]:         15 :      m_pShapeInfosByTxBxComp( new SvxMSDffShapeInfos_ByTxBxComp ),
    5803         [ +  - ]:         15 :      pShapeOrders( new SvxMSDffShapeOrders ),
    5804                 :            :      nDefaultFontHeight( 24 ),
    5805                 :            :      nOffsDgg( 0 ),
    5806                 :            :      nBLIPCount(  USHRT_MAX ),              // initialize with error, since we first have to check
    5807                 :            :      nShapeCount( USHRT_MAX ),              // whether the control stream contains the correct data
    5808                 :            :      maBaseURL( rBaseURL ),
    5809                 :            :      rStCtrl(  rStCtrl_  ),
    5810                 :            :      pStData( 0 ),
    5811                 :            :      pStData2( 0 ),
    5812                 :            :      nSvxMSDffSettings( 0 ),
    5813                 :            :      nSvxMSDffOLEConvFlags( 0 ),
    5814                 :            :      mnDefaultColor( COL_DEFAULT ),
    5815 [ +  - ][ +  - ]:         60 :      mbTracing( sal_False )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    5816                 :            : {
    5817         [ +  - ]:         15 :     SetModel( NULL, 0 );
    5818                 :         15 : }
    5819                 :            : 
    5820 [ +  - ][ +  - ]:         74 : SvxMSDffManager::~SvxMSDffManager()
         [ +  - ][ +  - ]
    5821                 :            : {
    5822 [ +  - ][ +  - ]:         74 :     delete pBLIPInfos;
    5823 [ +  - ][ +  - ]:         74 :     delete pShapeOrders;
    5824 [ -  + ][ #  # ]:         74 :     delete pFormModel;
    5825         [ -  + ]:         74 : }
    5826                 :            : 
    5827                 :         12 : void SvxMSDffManager::InitSvxMSDffManager( sal_uInt32 nOffsDgg_, SvStream* pStData_, sal_uInt32 nOleConvFlags )
    5828                 :            : {
    5829                 :         12 :     nOffsDgg = nOffsDgg_;
    5830                 :         12 :     pStData = pStData_;
    5831                 :         12 :     nSvxMSDffOLEConvFlags = nOleConvFlags;
    5832                 :            : 
    5833                 :            :     // remember FilePos of the stream(s)
    5834                 :         12 :     sal_uLong nOldPosCtrl = rStCtrl.Tell();
    5835                 :            : 
    5836                 :         12 :     SetDefaultPropSet( rStCtrl, nOffsDgg );
    5837                 :            : 
    5838                 :            :     // insert fidcl cluster table
    5839                 :         12 :     GetFidclData( nOffsDgg );
    5840                 :            : 
    5841                 :            :     // read control stream, if successful, set nBLIPCount
    5842                 :         12 :     GetCtrlData( nOffsDgg );
    5843                 :            : 
    5844                 :            :     // check Text-Box-Story-Chain-Infos
    5845                 :         12 :     CheckTxBxStoryChain();
    5846                 :            : 
    5847                 :            :     // restore old FilePos of the stream(s)
    5848                 :         12 :     rStCtrl.Seek( nOldPosCtrl );
    5849                 :         12 : }
    5850                 :            : 
    5851                 :         39 : void SvxMSDffManager::SetDgContainer( SvStream& rSt )
    5852                 :            : {
    5853                 :         39 :     sal_uInt32 nFilePos = rSt.Tell();
    5854                 :         39 :     DffRecordHeader aDgContHd;
    5855         [ +  - ]:         39 :     rSt >> aDgContHd;
    5856                 :            :     // insert this container only if there is also a DgAtom
    5857 [ +  - ][ +  - ]:         39 :     if ( SeekToRec( rSt, DFF_msofbtDg, aDgContHd.GetRecEndFilePos() ) )
    5858                 :            :     {
    5859                 :         39 :         DffRecordHeader aRecHd;
    5860         [ +  - ]:         39 :         rSt >> aRecHd;
    5861                 :         39 :         sal_uInt32 nDrawingId = aRecHd.nRecInstance;
    5862         [ +  - ]:         39 :         maDgOffsetTable[ nDrawingId ] = nFilePos;
    5863         [ +  - ]:         39 :         rSt.Seek( nFilePos );
    5864                 :            :     }
    5865                 :         39 : }
    5866                 :            : 
    5867                 :         12 : void SvxMSDffManager::GetFidclData( sal_uInt32 nOffsDggL )
    5868                 :            : {
    5869         [ +  - ]:         12 :     if (!nOffsDggL)
    5870                 :         12 :         return;
    5871                 :            : 
    5872                 :         12 :     sal_uInt32 nDummy, nMerk = rStCtrl.Tell();
    5873                 :            : 
    5874 [ +  - ][ +  - ]:         12 :     if (nOffsDggL == rStCtrl.Seek(nOffsDggL))
    5875                 :            :     {
    5876                 :         12 :         DffRecordHeader aRecHd;
    5877         [ +  - ]:         12 :         rStCtrl >> aRecHd;
    5878                 :            : 
    5879                 :         12 :         DffRecordHeader aDggAtomHd;
    5880 [ +  - ][ +  - ]:         12 :         if ( SeekToRec( rStCtrl, DFF_msofbtDgg, aRecHd.GetRecEndFilePos(), &aDggAtomHd ) )
    5881                 :            :         {
    5882         [ +  - ]:         12 :             aDggAtomHd.SeekToContent( rStCtrl );
    5883         [ +  - ]:         12 :             rStCtrl >> mnCurMaxShapeId
    5884         [ +  - ]:         12 :                     >> mnIdClusters
    5885         [ +  - ]:         12 :                     >> nDummy
    5886         [ +  - ]:         12 :                     >> mnDrawingsSaved;
    5887                 :            : 
    5888         [ +  - ]:         12 :             if ( mnIdClusters-- > 2 )
    5889                 :            :             {
    5890                 :         12 :                 const sal_Size nFIDCLsize = sizeof(sal_uInt32) * 2;
    5891         [ +  - ]:         12 :                 if ( aDggAtomHd.nRecLen == ( mnIdClusters * nFIDCLsize + 16 ) )
    5892                 :            :                 {
    5893         [ +  - ]:         12 :                     sal_Size nMaxEntriesPossible = rStCtrl.remainingSize() / nFIDCLsize;
    5894                 :            :                     SAL_WARN_IF(nMaxEntriesPossible < mnIdClusters,
    5895                 :            :                         "escher", "FIDCL list longer than remaining bytes, ppt or parser is wrong");
    5896         [ +  - ]:         12 :                     mnIdClusters = std::min(nMaxEntriesPossible, static_cast<sal_Size>(mnIdClusters));
    5897                 :            : 
    5898         [ +  - ]:         12 :                     maFidcls.resize(mnIdClusters);
    5899         [ +  + ]:         54 :                     for (sal_uInt32 i = 0; i < mnIdClusters; ++i)
    5900                 :            :                     {
    5901         [ +  - ]:         42 :                         rStCtrl >> maFidcls[ i ].dgid
    5902         [ +  - ]:         84 :                                 >> maFidcls[ i ].cspidCur;
    5903                 :            :                     }
    5904                 :            :                 }
    5905                 :            :             }
    5906                 :            :         }
    5907                 :            :     }
    5908         [ +  - ]:         12 :     rStCtrl.Seek( nMerk );
    5909                 :            : }
    5910                 :            : 
    5911                 :         71 : void SvxMSDffManager::CheckTxBxStoryChain()
    5912                 :            : {
    5913         [ +  - ]:         71 :     m_pShapeInfosById.reset(new SvxMSDffShapeInfos_ById);
    5914                 :            :     // mangle old Info array, sorted by nTxBxComp
    5915                 :         71 :     sal_uLong nChain    = ULONG_MAX;
    5916                 :         71 :     sal_Bool bSetReplaceFALSE = sal_False;
    5917         [ +  + ]:       1300 :     for (SvxMSDffShapeInfos_ByTxBxComp::iterator iter =
    5918                 :         71 :                 m_pShapeInfosByTxBxComp->begin(),
    5919                 :         71 :             mark = m_pShapeInfosByTxBxComp->begin();
    5920                 :        650 :          iter != m_pShapeInfosByTxBxComp->end(); ++iter)
    5921                 :            :     {
    5922         [ +  - ]:        579 :         boost::shared_ptr<SvxMSDffShapeInfo> const pObj = *iter;
    5923         [ +  + ]:        579 :         if( pObj->nTxBxComp )
    5924                 :            :         {
    5925                 :        147 :             pObj->bLastBoxInChain = sal_False;
    5926                 :            :             // group change?
    5927                 :            :             // #156763#
    5928                 :            :             // the text id also contains an internal drawing container id
    5929                 :            :             // to distinguish between text id of drawing objects in different
    5930                 :            :             // drawing containers.
    5931         [ +  - ]:        147 :             if( nChain != pObj->nTxBxComp )
    5932                 :            :             {
    5933                 :            :                 // previous was last of its group
    5934         [ +  - ]:        147 :                 if (iter != m_pShapeInfosByTxBxComp->begin())
    5935                 :            :                 {
    5936                 :        147 :                     SvxMSDffShapeInfos_ByTxBxComp::iterator prev(iter);
    5937                 :        147 :                     --prev;
    5938                 :        147 :                     (*prev)->bLastBoxInChain = true;
    5939                 :            :                 }
    5940                 :            :                 // reset mark and helper flag
    5941                 :        147 :                 mark = iter;
    5942                 :        147 :                 nChain = pObj->nTxBxComp;
    5943                 :        147 :                 bSetReplaceFALSE = !pObj->bReplaceByFly;
    5944                 :            :             }
    5945                 :            :             else
    5946         [ #  # ]:          0 :             if( !pObj->bReplaceByFly )
    5947                 :            :             {
    5948                 :            :                 // object that must NOT be replaced by frame?
    5949                 :          0 :                 bSetReplaceFALSE = sal_True;
    5950                 :            :                 // maybe reset flags in start of group
    5951         [ #  # ]:          0 :                 for (SvxMSDffShapeInfos_ByTxBxComp::iterator itemp = mark;
    5952                 :            :                         itemp != iter; ++itemp)
    5953                 :            :                 {
    5954                 :          0 :                     (*itemp)->bReplaceByFly = false;
    5955                 :            :                 }
    5956                 :            :             }
    5957                 :            : 
    5958         [ -  + ]:        147 :             if( bSetReplaceFALSE )
    5959                 :            :             {
    5960                 :          0 :                 pObj->bReplaceByFly = sal_False;
    5961                 :            :             }
    5962                 :            :         }
    5963                 :            :         // copy all Shape Info objects to m_pShapeInfosById, sorted by nShapeId
    5964                 :        579 :         pObj->nTxBxComp = pObj->nTxBxComp & 0xFFFF0000;
    5965         [ +  - ]:        579 :         m_pShapeInfosById->insert( pObj );
    5966         [ +  - ]:        579 :     }
    5967                 :            :     // last one was last of its group
    5968         [ +  + ]:         71 :     if (!m_pShapeInfosByTxBxComp->empty())
    5969                 :            :     {
    5970                 :         33 :         (*m_pShapeInfosByTxBxComp->rbegin())->bLastBoxInChain = true;
    5971                 :            :     }
    5972                 :            :     // free original array but don't free its elements
    5973                 :         71 :     m_pShapeInfosByTxBxComp.reset();
    5974                 :         71 : }
    5975                 :            : 
    5976                 :            : 
    5977                 :            : /*****************************************************************************
    5978                 :            : 
    5979                 :            :     Reading the Shape-Infos in the Ctor:
    5980                 :            :     ---------------------------------
    5981                 :            :     remembering the Shape-Ids and the associated Blip-Numbers und TextBox-Infos
    5982                 :            :                     =========                    ============     =============
    5983                 :            :     and remebering the File-Offsets for each Blip
    5984                 :            :                        ============
    5985                 :            : ******************************************************************************/
    5986                 :         71 : void SvxMSDffManager::GetCtrlData( sal_uInt32 nOffsDgg_ )
    5987                 :            : {
    5988                 :            :     // absolutely remember Start Offset, in case we have to position again
    5989                 :         71 :     sal_uInt32 nOffsDggL = nOffsDgg_;
    5990                 :            : 
    5991                 :            :     // position control stream
    5992 [ +  - ][ +  - ]:         71 :     if (nOffsDggL != rStCtrl.Seek(nOffsDggL))
    5993                 :            :         return;
    5994                 :            : 
    5995                 :            :     sal_uInt8   nVer;
    5996                 :            :     sal_uInt16 nInst;
    5997                 :            :     sal_uInt16 nFbt;
    5998                 :            :     sal_uInt32  nLength;
    5999 [ +  - ][ +  - ]:         71 :     if( !this->ReadCommonRecordHeader( rStCtrl, nVer, nInst, nFbt, nLength ) ) return;
    6000                 :            : 
    6001                 :            :     sal_Bool bOk;
    6002                 :         71 :     sal_uLong nPos = nOffsDggL + DFF_COMMON_RECORD_HEADER_SIZE;
    6003                 :            : 
    6004                 :            :     // case A: first Drawing Group Container, then n times Drawing Container
    6005         [ +  + ]:         71 :     if( DFF_msofbtDggContainer == nFbt )
    6006                 :            :     {
    6007         [ +  - ]:         62 :         GetDrawingGroupContainerData( rStCtrl, nLength );
    6008                 :            : 
    6009         [ +  - ]:         62 :         rStCtrl.Seek( STREAM_SEEK_TO_END );
    6010                 :         62 :         sal_uInt32 nMaxStrPos = rStCtrl.Tell();
    6011                 :            : 
    6012                 :         62 :         nPos += nLength;
    6013                 :         62 :         unsigned long nDrawingContainerId = 1;
    6014 [ +  + ][ +  + ]:        113 :         do
                 [ +  + ]
    6015                 :            :         {
    6016 [ +  - ][ -  + ]:        104 :             if (nPos != rStCtrl.Seek(nPos))
    6017                 :          0 :                 break;
    6018                 :            : 
    6019 [ +  - ][ +  + ]:        104 :             bOk = ReadCommonRecordHeader( rStCtrl, nVer, nInst, nFbt, nLength ) && ( DFF_msofbtDgContainer == nFbt );
                 [ -  + ]
    6020                 :            : 
    6021         [ +  - ]:        104 :             if( !bOk )
    6022                 :            :             {
    6023                 :        104 :                 nPos++;
    6024 [ +  - ][ -  + ]:        104 :                 if (nPos != rStCtrl.Seek(nPos))
    6025                 :          0 :                     break;
    6026         [ +  - ]:        104 :                 bOk = ReadCommonRecordHeader( rStCtrl, nVer, nInst, nFbt, nLength )
    6027 [ +  + ][ +  + ]:        104 :                         && ( DFF_msofbtDgContainer == nFbt );
    6028                 :            :             }
    6029         [ +  + ]:        104 :             if( bOk )
    6030                 :            :             {
    6031         [ +  - ]:         42 :                 GetDrawingContainerData( rStCtrl, nLength, nDrawingContainerId );
    6032                 :            :             }
    6033                 :        104 :             nPos += DFF_COMMON_RECORD_HEADER_SIZE + nLength;
    6034                 :        104 :             ++nDrawingContainerId;
    6035                 :            :         }
    6036                 :            :         while( nPos < nMaxStrPos && bOk );
    6037                 :            :     }
    6038                 :            : }
    6039                 :            : 
    6040                 :            : 
    6041                 :            : // from here on: Drawing Group Container  i.e. Ddocument-wide valid data
    6042                 :            : //                      =======================           ========
    6043                 :            : //
    6044                 :         62 : void SvxMSDffManager::GetDrawingGroupContainerData( SvStream& rSt, sal_uLong nLenDgg )
    6045                 :            : {
    6046                 :            :     sal_uInt8   nVer;
    6047                 :            :     sal_uInt16 nInst;
    6048                 :            :     sal_uInt16 nFbt;
    6049                 :            :     sal_uInt32 nLength;
    6050                 :            : 
    6051                 :         62 :     sal_uLong nLenBStoreCont = 0, nLenFBSE = 0, nRead = 0;
    6052                 :            : 
    6053                 :            :     // search for a  BStore Container
    6054         [ +  + ]:         95 :     do
    6055                 :            :     {
    6056 [ +  - ][ +  - ]:        136 :         if(!this->ReadCommonRecordHeader( rSt, nVer, nInst, nFbt, nLength)) return;
    6057                 :        136 :         nRead += DFF_COMMON_RECORD_HEADER_SIZE + nLength;
    6058         [ +  + ]:        136 :         if( DFF_msofbtBstoreContainer == nFbt )
    6059                 :            :         {
    6060                 :         41 :             nLenBStoreCont = nLength;       break;
    6061                 :            :         }
    6062         [ +  - ]:         95 :         rSt.SeekRel( nLength );
    6063                 :            :     }
    6064                 :            :     while( nRead < nLenDgg );
    6065                 :            : 
    6066         [ +  + ]:         62 :     if( !nLenBStoreCont ) return;
    6067                 :            : 
    6068                 :            :     // Im BStore Container alle Header der Container und Atome auslesen und die
    6069                 :            :     // relevanten Daten aller enthaltenen FBSEs in unserem Pointer Array ablegen.
    6070                 :            :     // Dabei zaehlen wir die gefundenen FBSEs im Member nBLIPCount mit.
    6071                 :            : 
    6072                 :         41 :     const sal_uLong nSkipBLIPLen = 20;  // bis zu nBLIPLen zu ueberspringende Bytes
    6073                 :         41 :     const sal_uLong nSkipBLIPPos =  4;  // dahinter bis zu nBLIPPos zu skippen
    6074                 :            : 
    6075                 :         41 :     sal_uInt32 nBLIPLen = 0, nBLIPPos = 0;
    6076                 :            : 
    6077                 :         41 :     nRead = 0;
    6078         [ +  + ]:        100 :     do
    6079                 :            :     {
    6080 [ +  - ][ +  - ]:         79 :         if(!this->ReadCommonRecordHeader( rSt, nVer, nInst, nFbt, nLength)) return;
    6081                 :         79 :         nRead += DFF_COMMON_RECORD_HEADER_SIZE + nLength;
    6082         [ +  - ]:         79 :         if( DFF_msofbtBSE == nFbt )
    6083                 :            :         {
    6084                 :         79 :             nLenFBSE = nLength;
    6085                 :            :             // is FBSE big enough for our data
    6086                 :         79 :             sal_Bool bOk = ( nSkipBLIPLen + 4 + nSkipBLIPPos + 4 <= nLenFBSE );
    6087                 :            : 
    6088         [ +  - ]:         79 :             if( bOk )
    6089                 :            :             {
    6090         [ +  - ]:         79 :                 rSt.SeekRel( nSkipBLIPLen );
    6091         [ +  - ]:         79 :                 rSt >> nBLIPLen;
    6092         [ +  - ]:         79 :                 rSt.SeekRel( nSkipBLIPPos );
    6093         [ +  - ]:         79 :                 rSt >> nBLIPPos;
    6094                 :         79 :                 bOk = rSt.GetError() == 0;
    6095                 :            : 
    6096                 :         79 :                 nLength -= nSkipBLIPLen+ 4 + nSkipBLIPPos + 4;
    6097                 :            :             }
    6098                 :            : 
    6099         [ +  - ]:         79 :             if( bOk )
    6100                 :            :             {
    6101                 :            :                 // Besonderheit:
    6102                 :            :                 // Falls nBLIPLen kleiner ist als nLenFBSE UND nBLIPPos Null ist,
    6103                 :            :                 // nehmen wir an, dass das Bild IM FBSE drin steht!
    6104 [ +  + ][ +  + ]:         79 :                 if( (!nBLIPPos) && (nBLIPLen < nLenFBSE) )
    6105                 :         22 :                     nBLIPPos = rSt.Tell() + 4;
    6106                 :            : 
    6107                 :            :                 // That worked great!
    6108                 :            :                 // Wir merken uns, dass wir einen FBSE mehr im Pointer Array haben.
    6109         [ +  - ]:         79 :                 nBLIPPos = Calc_nBLIPPos(nBLIPPos, rSt.Tell());
    6110                 :            : 
    6111         [ +  + ]:         79 :                 if( USHRT_MAX == nBLIPCount )
    6112                 :         41 :                     nBLIPCount = 1;
    6113                 :            :                 else
    6114                 :         38 :                     nBLIPCount++;
    6115                 :            : 
    6116                 :            :                 // now save the info for later access
    6117 [ +  - ][ +  - ]:         79 :                 pBLIPInfos->push_back( new SvxMSDffBLIPInfo( nInst, nBLIPPos, nBLIPLen ) );
    6118                 :            :             }
    6119                 :            :         }
    6120         [ +  - ]:         79 :         rSt.SeekRel( nLength );
    6121                 :            :     }
    6122                 :            :     while( nRead < nLenBStoreCont );
    6123                 :            : }
    6124                 :            : 
    6125                 :            : 
    6126                 :            : // ab hier: Drawing Container  d.h. Seiten (Blatt, Dia) - weit gueltige Daten
    6127                 :            : //                      =================               ======
    6128                 :            : //
    6129                 :         42 : void SvxMSDffManager::GetDrawingContainerData( SvStream& rSt, sal_uLong nLenDg,
    6130                 :            :                                                const unsigned long nDrawingContainerId )
    6131                 :            : {
    6132                 :            :     sal_uInt8 nVer;sal_uInt16 nInst;sal_uInt16 nFbt;sal_uInt32 nLength;
    6133                 :            : 
    6134                 :         42 :     sal_uLong nReadDg = 0;
    6135                 :            : 
    6136                 :            :     // Wir stehen in einem Drawing Container (je einer pro Seite)
    6137                 :            :     // und muessen nun
    6138                 :            :     // alle enthaltenen Shape Group Container abklappern
    6139         [ +  + ]:        123 :     do
    6140                 :            :     {
    6141 [ +  - ][ +  - ]:        123 :         if(!this->ReadCommonRecordHeader( rSt, nVer, nInst, nFbt, nLength)) return;
    6142                 :        123 :         nReadDg += DFF_COMMON_RECORD_HEADER_SIZE;
    6143                 :            :         // Patriarch gefunden (der oberste Shape Group Container) ?
    6144         [ +  + ]:        123 :         if( DFF_msofbtSpgrContainer == nFbt )
    6145                 :            :         {
    6146 [ +  - ][ +  - ]:         42 :             if(!this->GetShapeGroupContainerData( rSt, nLength, sal_True, nDrawingContainerId )) return;
    6147                 :            :         }
    6148                 :            :         else
    6149                 :            :         // blanker Shape Container ? (ausserhalb vom Shape Group Container)
    6150         [ +  + ]:         81 :         if( DFF_msofbtSpContainer == nFbt )
    6151                 :            :         {
    6152 [ +  - ][ +  - ]:         33 :             if(!this->GetShapeContainerData( rSt, nLength, ULONG_MAX, nDrawingContainerId )) return;
    6153                 :            :         }
    6154                 :            :         else
    6155         [ +  - ]:         48 :             rSt.SeekRel( nLength );
    6156                 :        123 :         nReadDg += nLength;
    6157                 :            :     }
    6158                 :            :     while( nReadDg < nLenDg );
    6159                 :            : }
    6160                 :            : 
    6161                 :         78 : sal_Bool SvxMSDffManager::GetShapeGroupContainerData( SvStream& rSt,
    6162                 :            :                                                   sal_uLong nLenShapeGroupCont,
    6163                 :            :                                                   sal_Bool bPatriarch,
    6164                 :            :                                                   const unsigned long nDrawingContainerId )
    6165                 :            : {
    6166                 :            :     sal_uInt8 nVer;sal_uInt16 nInst;sal_uInt16 nFbt;sal_uInt32 nLength;
    6167                 :         78 :     long nStartShapeGroupCont = rSt.Tell();
    6168                 :            :     // Wir stehen in einem Shape Group Container (ggfs. mehrere pro Seite)
    6169                 :            :     // und muessen nun
    6170                 :            :     // alle enthaltenen Shape Container abklappern
    6171                 :         78 :     sal_Bool  bFirst = !bPatriarch;
    6172                 :         78 :     sal_uLong nReadSpGrCont = 0;
    6173         [ +  + ]:        582 :     do
    6174                 :            :     {
    6175 [ +  - ][ -  + ]:        582 :         if( !this->ReadCommonRecordHeader( rSt, nVer, nInst, nFbt, nLength ) )
    6176                 :          0 :             return sal_False;
    6177                 :        582 :         nReadSpGrCont += DFF_COMMON_RECORD_HEADER_SIZE;
    6178                 :            :         // Shape Container?
    6179         [ +  + ]:        582 :         if( DFF_msofbtSpContainer == nFbt )
    6180                 :            :         {
    6181         [ +  + ]:        546 :             sal_uLong nGroupOffs = bFirst ? nStartShapeGroupCont - DFF_COMMON_RECORD_HEADER_SIZE : ULONG_MAX;
    6182 [ +  - ][ -  + ]:        546 :             if ( !this->GetShapeContainerData( rSt, nLength, nGroupOffs, nDrawingContainerId ) )
    6183                 :          0 :                 return sal_False;
    6184                 :        546 :             bFirst = sal_False;
    6185                 :            :         }
    6186                 :            :         else
    6187                 :            :         // eingeschachtelter Shape Group Container ?
    6188         [ +  - ]:         36 :         if( DFF_msofbtSpgrContainer == nFbt )
    6189                 :            :         {
    6190 [ +  - ][ -  + ]:         36 :             if ( !this->GetShapeGroupContainerData( rSt, nLength, sal_False, nDrawingContainerId ) )
    6191                 :          0 :                 return sal_False;
    6192                 :            :         }
    6193                 :            :         else
    6194         [ #  # ]:          0 :             rSt.SeekRel( nLength );
    6195                 :        582 :         nReadSpGrCont += nLength;
    6196                 :            :     }
    6197                 :            :     while( nReadSpGrCont < nLenShapeGroupCont );
    6198                 :            :     // den Stream wieder korrekt positionieren
    6199         [ +  - ]:         78 :     rSt.Seek( nStartShapeGroupCont + nLenShapeGroupCont );
    6200                 :         78 :     return sal_True;
    6201                 :            : }
    6202                 :            : 
    6203                 :        579 : sal_Bool SvxMSDffManager::GetShapeContainerData( SvStream& rSt,
    6204                 :            :                                              sal_uLong nLenShapeCont,
    6205                 :            :                                              sal_uLong nPosGroup,
    6206                 :            :                                              const unsigned long nDrawingContainerId )
    6207                 :            : {
    6208                 :            :     sal_uInt8 nVer;sal_uInt16 nInst;sal_uInt16 nFbt;sal_uInt32 nLength;
    6209                 :        579 :     long  nStartShapeCont = rSt.Tell();
    6210                 :            :     // Wir stehen in einem Shape Container (ggfs. mehrere pro Sh. Group)
    6211                 :            :     // und muessen nun
    6212                 :            :     // die Shape Id und File-Pos (fuer spaetere, erneute Zugriffe)
    6213                 :            :     // und den ersten BStore Verweis (falls vorhanden) entnehmen
    6214                 :        579 :     sal_uLong nLenShapePropTbl = 0;
    6215                 :        579 :     sal_uLong nReadSpCont = 0;
    6216                 :            : 
    6217                 :            :     // File Offset des Shape-Containers bzw. der Gruppe(!) vermerken
    6218                 :            :     //
    6219                 :            :     sal_uLong nStartOffs = (ULONG_MAX > nPosGroup) ?
    6220         [ +  + ]:        579 :                             nPosGroup : nStartShapeCont - DFF_COMMON_RECORD_HEADER_SIZE;
    6221                 :        579 :     SvxMSDffShapeInfo aInfo( nStartOffs );
    6222                 :            : 
    6223                 :            :     // duerfte das Shape durch einen Rahmen ersetzt werden ?
    6224                 :            :     // (vorausgesetzt, es zeigt sich, dass es eine TextBox ist,
    6225                 :            :     //  und der Text nicht gedreht ist)
    6226                 :        579 :     sal_Bool bCanBeReplaced = (ULONG_MAX > nPosGroup) ? sal_False : sal_True;
    6227                 :            : 
    6228                 :            :     // we don't knwo yet whether it's a TextBox
    6229                 :        579 :     MSO_SPT         eShapeType      = mso_sptNil;
    6230                 :            : 
    6231                 :            :     // analyze Shape
    6232                 :            :     //
    6233         [ +  + ]:       2652 :     do
    6234                 :            :     {
    6235 [ +  - ][ -  + ]:       2652 :         if(!this->ReadCommonRecordHeader( rSt, nVer, nInst, nFbt, nLength)) return sal_False;
    6236                 :       2652 :         nReadSpCont += DFF_COMMON_RECORD_HEADER_SIZE;
    6237                 :            :         // FSP ?
    6238 [ +  + ][ +  - ]:       2652 :         if( ( DFF_msofbtSp == nFbt ) && ( 4 <= nLength ) )
    6239                 :            :         {
    6240                 :            :             // we've found the FSP gefunden: note Shape Type and Id!
    6241                 :        579 :             eShapeType = (MSO_SPT)nInst;
    6242         [ +  - ]:        579 :             rSt >> aInfo.nShapeId;
    6243         [ +  - ]:        579 :             rSt.SeekRel( nLength - 4 );
    6244                 :        579 :             nReadSpCont += nLength;
    6245                 :            :         }
    6246         [ +  + ]:       2073 :         else if( DFF_msofbtOPT == nFbt ) // Shape Property Table ?
    6247                 :            :         {
    6248                 :            :             // We've found the Property Table:
    6249                 :            :             // search for the Blip Property!
    6250                 :        537 :             sal_uLong  nPropRead = 0;
    6251                 :            :             sal_uInt16 nPropId;
    6252                 :            :             sal_uInt32  nPropVal;
    6253                 :        537 :             nLenShapePropTbl = nLength;
    6254                 :        537 :             long nStartShapePropTbl = rSt.Tell();
    6255         [ +  + ]:       3204 :             do
    6256                 :            :             {
    6257         [ +  - ]:       3204 :                 rSt >> nPropId
    6258         [ +  - ]:       3204 :                     >> nPropVal;
    6259                 :       3204 :                 nPropRead += 6;
    6260                 :            : 
    6261   [ -  -  -  -  :       3204 :                 switch( nPropId )
                +  +  + ]
    6262                 :            :                 {
    6263                 :            :                     case DFF_Prop_txflTextFlow :
    6264                 :            :                         //Writer can now handle vertical textflows in its
    6265                 :            :                         //native frames, to only need to do this for the
    6266                 :            :                         //other two formats
    6267                 :            : 
    6268                 :            :                         //Writer will handle all textflow except BtoT
    6269         [ #  # ]:          0 :                         if (GetSvxMSDffSettings() &
    6270                 :            :                             (SVXMSDFF_SETTINGS_IMPORT_PPT |
    6271                 :            :                              SVXMSDFF_SETTINGS_IMPORT_EXCEL))
    6272                 :            :                         {
    6273         [ #  # ]:          0 :                             if( 0 != nPropVal )
    6274                 :          0 :                                 bCanBeReplaced = false;
    6275                 :            :                         }
    6276 [ #  # ][ #  # ]:          0 :                         else if (
    6277                 :            :                             (nPropVal != mso_txflHorzN) &&
    6278                 :            :                             (nPropVal != mso_txflTtoBA)
    6279                 :            :                                 )
    6280                 :            :                         {
    6281                 :          0 :                             bCanBeReplaced = false;
    6282                 :            :                         }
    6283                 :          0 :                     break;
    6284                 :            :                     case DFF_Prop_cdirFont :
    6285                 :            :                         //Writer can now handle right to left and left
    6286                 :            :                         //to right in its native frames, so only do
    6287                 :            :                         //this for the other two formats.
    6288         [ #  # ]:          0 :                         if (GetSvxMSDffSettings() &
    6289                 :            :                             (SVXMSDFF_SETTINGS_IMPORT_PPT |
    6290                 :            :                              SVXMSDFF_SETTINGS_IMPORT_EXCEL))
    6291                 :            :                         {
    6292         [ #  # ]:          0 :                             if( 0 != nPropVal )
    6293                 :          0 :                                 bCanBeReplaced = sal_False;
    6294                 :            :                         }
    6295                 :          0 :                     break;
    6296                 :            :                     case DFF_Prop_Rotation :
    6297         [ #  # ]:          0 :                         if( 0 != nPropVal )
    6298                 :          0 :                             bCanBeReplaced = sal_False;
    6299                 :          0 :                     break;
    6300                 :            : 
    6301                 :            :                     case DFF_Prop_gtextFStrikethrough :
    6302         [ #  # ]:          0 :                         if( ( 0x20002000 & nPropVal )  == 0x20002000 )
    6303                 :          0 :                             bCanBeReplaced = sal_False;
    6304                 :          0 :                     break;
    6305                 :            : 
    6306                 :            :                     case DFF_Prop_fc3DLightFace :
    6307         [ -  + ]:        216 :                         if( ( 0x00080008 & nPropVal ) == 0x00080008 )
    6308                 :          0 :                             bCanBeReplaced = sal_False;
    6309                 :        216 :                     break;
    6310                 :            : 
    6311                 :            :                     case DFF_Prop_WrapText :
    6312                 :            :                         //TODO: eWrapMode = (MSO_WrapMode)nPropVal;
    6313                 :          3 :                     break;
    6314                 :            : 
    6315                 :            :                     default:
    6316                 :            :                     {
    6317                 :            :                         // is the Bit set and valid?
    6318         [ +  + ]:       2985 :                         if( 0x4000 == ( nPropId & 0xC000 ) )
    6319                 :            :                         {
    6320                 :            :                             // Blip Property found: remember BStore Idx!
    6321                 :         45 :                             nPropRead = nLenShapePropTbl;
    6322                 :            :                         }
    6323         [ +  + ]:       2940 :                         else if( 0x8000 & nPropId )
    6324                 :            :                         {
    6325                 :            :                             // complex Prop found:
    6326                 :            :                             // Laenge ist immer 6, nur die Laenge der nach der
    6327                 :            :                             // eigentlichen Prop-Table anhaengenden Extra-Daten
    6328                 :            :                             // ist unterschiedlich
    6329                 :          3 :                             nPropVal = 6;
    6330                 :            :                         }
    6331                 :            :                     }
    6332                 :       2985 :                     break;
    6333                 :            :                 }
    6334                 :            :             }
    6335                 :            :             while( nPropRead < nLenShapePropTbl );
    6336         [ +  - ]:        537 :             rSt.Seek( nStartShapePropTbl + nLenShapePropTbl );
    6337                 :        537 :             nReadSpCont += nLenShapePropTbl;
    6338                 :            :         }
    6339 [ +  + ][ +  - ]:       1536 :         else if( ( DFF_msofbtClientTextbox == nFbt ) && ( 4 == nLength ) )  // Text-Box-Story-Entry found
    6340                 :            :         {
    6341         [ +  - ]:        147 :             rSt >> aInfo.nTxBxComp;
    6342                 :            :             // Add internal drawing container id to text id.
    6343                 :            :             // Note: The text id uses the first two bytes, while the internal
    6344                 :            :             // drawing container id used the second two bytes.
    6345                 :            :             aInfo.nTxBxComp = ( aInfo.nTxBxComp & 0xFFFF0000 ) +
    6346                 :        147 :                               nDrawingContainerId;
    6347                 :        147 :             DBG_ASSERT( (aInfo.nTxBxComp & 0x0000FFFF) == nDrawingContainerId,
    6348                 :            :                         "<SvxMSDffManager::GetShapeContainerData(..)> - internal drawing container Id could not be correctly merged into DFF_msofbtClientTextbox value." );
    6349                 :            :         }
    6350                 :            :         else
    6351                 :            :         {
    6352         [ +  - ]:       1389 :             rSt.SeekRel( nLength );
    6353                 :       1389 :             nReadSpCont += nLength;
    6354                 :            :         }
    6355                 :            :     }
    6356                 :            :     while( nReadSpCont < nLenShapeCont );
    6357                 :            : 
    6358                 :            :     //
    6359                 :            :     // Jetzt ggfs. die Infos fuer spaetere Zugriffe auf das Shape speichern
    6360                 :            :     //
    6361         [ +  - ]:        579 :     if( aInfo.nShapeId )
    6362                 :            :     {
    6363                 :            :         // fuer Textboxen ggfs. ersetzen durch Rahmen erlauben
    6364 [ +  + ][ +  + ]:        579 :         if(     bCanBeReplaced
         [ +  - ][ +  + ]
         [ -  + ][ #  # ]
    6365                 :            :              && aInfo.nTxBxComp
    6366                 :            :              && (
    6367                 :            :                     ( eShapeType == mso_sptTextSimple )
    6368                 :            :                  || ( eShapeType == mso_sptTextBox    )
    6369                 :            :                  || (    (    ( eShapeType == mso_sptRectangle      )
    6370                 :            :                            || ( eShapeType == mso_sptRoundRectangle )
    6371                 :            :                          )
    6372                 :            :                 ) ) )
    6373                 :            :         {
    6374                 :        147 :             aInfo.bReplaceByFly = sal_True;
    6375                 :            :         }
    6376                 :            :         m_pShapeInfosByTxBxComp->insert(::boost::shared_ptr<SvxMSDffShapeInfo>(
    6377 [ +  - ][ +  - ]:        579 :                     new SvxMSDffShapeInfo(aInfo)));
         [ +  - ][ +  - ]
    6378 [ +  - ][ +  - ]:        579 :         pShapeOrders->push_back( new SvxMSDffShapeOrder( aInfo.nShapeId ) );
    6379                 :            :     }
    6380                 :            : 
    6381                 :            :     // and position the Stream correctly again
    6382         [ +  - ]:        579 :     rSt.Seek( nStartShapeCont + nLenShapeCont );
    6383                 :        579 :     return sal_True;
    6384                 :            : }
    6385                 :            : 
    6386                 :            : 
    6387                 :            : 
    6388                 :            : /*****************************************************************************
    6389                 :            : 
    6390                 :            :     Access to a shape at runtime (via the Shape-Id)
    6391                 :            :     ----------------------------
    6392                 :            : ******************************************************************************/
    6393                 :        159 : sal_Bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*&         rpShape,
    6394                 :            :                                           SvxMSDffImportData& rData)
    6395                 :            : {
    6396                 :            :     ::boost::shared_ptr<SvxMSDffShapeInfo> const pTmpRec(
    6397 [ +  - ][ +  - ]:        159 :         new SvxMSDffShapeInfo(0, nId));
    6398                 :            : 
    6399                 :            :     SvxMSDffShapeInfos_ById::const_iterator const it =
    6400         [ +  - ]:        159 :         m_pShapeInfosById->find(pTmpRec);
    6401         [ +  - ]:        159 :     if (it != m_pShapeInfosById->end())
    6402                 :            :     {
    6403                 :            :         // eventuell altes Errorflag loeschen
    6404         [ -  + ]:        159 :         if( rStCtrl.GetError() )
    6405         [ #  # ]:          0 :             rStCtrl.ResetError();
    6406                 :            :         // FilePos des/der Stream(s) merken
    6407                 :        159 :         sal_uLong nOldPosCtrl = rStCtrl.Tell();
    6408         [ +  - ]:        159 :         sal_uLong nOldPosData = pStData ? pStData->Tell() : nOldPosCtrl;
    6409                 :            :         // das Shape im Steuer Stream anspringen
    6410                 :        159 :         sal_uLong const nFilePos((*it)->nFilePos);
    6411         [ +  - ]:        159 :         bool bSeeked = (nFilePos == rStCtrl.Seek(nFilePos));
    6412                 :            : 
    6413                 :            :         // if it failed, reset error statusF
    6414 [ +  - ][ -  + ]:        159 :         if (!bSeeked || rStCtrl.GetError())
                 [ -  + ]
    6415         [ #  # ]:          0 :             rStCtrl.ResetError();
    6416                 :            :         else
    6417         [ +  - ]:        159 :             rpShape = ImportObj( rStCtrl, &rData, rData.aParentRect, rData.aParentRect );
    6418                 :            : 
    6419                 :            :         // restore old alte FilePos of the stream(s)
    6420         [ +  - ]:        159 :         rStCtrl.Seek( nOldPosCtrl );
    6421         [ +  - ]:        159 :         if( &rStCtrl != pStData )
    6422         [ +  - ]:        159 :             pStData->Seek( nOldPosData );
    6423                 :        159 :         return ( 0 != rpShape );
    6424                 :            :     }
    6425         [ +  - ]:        159 :     return sal_False;
    6426                 :            : }
    6427                 :            : 
    6428                 :            : 
    6429                 :            : 
    6430                 :            : /*      access to a BLIP at runtime (if the Blip-Number is already known)
    6431                 :            :         ---------------------------
    6432                 :            : ******************************************************************************/
    6433                 :         77 : sal_Bool SvxMSDffManager::GetBLIP( sal_uLong nIdx_, Graphic& rData, Rectangle* pVisArea )
    6434                 :            : {
    6435                 :         77 :     sal_Bool bOk = sal_False;       // initialize result variable
    6436         [ +  - ]:         77 :     if ( pStData )
    6437                 :            :     {
    6438                 :            :         // check if a graphic for this blipId is already imported
    6439         [ +  - ]:         77 :         if ( nIdx_)
    6440                 :            :         {
    6441         [ +  - ]:         77 :             std::map<sal_uInt32,rtl::OString>::iterator iter = aEscherBlipCache.find(nIdx_);
    6442                 :            : 
    6443         [ +  + ]:         77 :             if (iter != aEscherBlipCache.end())
    6444                 :            :             {
    6445                 :            :                 /* if this entry is available, then it should be possible
    6446                 :            :                 to get the Graphic via GraphicObject */
    6447         [ +  - ]:          6 :                 GraphicObject aGraphicObject( iter->second );
    6448 [ +  - ][ +  - ]:          6 :                 rData = aGraphicObject.GetGraphic();
    6449 [ +  - ][ +  - ]:          6 :                 if ( rData.GetType() != GRAPHIC_NONE )
    6450                 :          6 :                     bOk = sal_True;
    6451                 :            :                 else
    6452 [ #  # ][ +  - ]:         77 :                     aEscherBlipCache.erase(iter);
    6453                 :            :             }
    6454                 :            :         }
    6455         [ +  + ]:         77 :         if ( !bOk )
    6456                 :            :         {
    6457                 :         71 :             sal_uInt16 nIdx = sal_uInt16( nIdx_ );
    6458 [ +  - ][ -  + ]:         71 :             if( !nIdx || (pBLIPInfos->size() < nIdx) ) return sal_False;
                 [ -  + ]
    6459                 :            : 
    6460                 :            :             // eventuell alte(s) Errorflag(s) loeschen
    6461         [ -  + ]:         71 :             if( rStCtrl.GetError() )
    6462                 :          0 :                 rStCtrl.ResetError();
    6463   [ +  +  -  + ]:        128 :             if(    ( &rStCtrl != pStData )
                 [ -  + ]
    6464                 :         57 :                 && pStData->GetError() )
    6465                 :          0 :                 pStData->ResetError();
    6466                 :            : 
    6467                 :            :             // remember FilePos of the stream(s)
    6468                 :         71 :             sal_uLong nOldPosCtrl = rStCtrl.Tell();
    6469         [ +  - ]:         71 :             sal_uLong nOldPosData = pStData ? pStData->Tell() : nOldPosCtrl;
    6470                 :            : 
    6471                 :            :             // passende Info-Struct aus unserem Pointer Array nehmen
    6472                 :         71 :             SvxMSDffBLIPInfo& rInfo = (*pBLIPInfos)[ nIdx-1 ];
    6473                 :            :             // das BLIP Atom im Daten Stream anspringen
    6474                 :         71 :             pStData->Seek( rInfo.nFilePos );
    6475                 :            :             // ggfs. Fehlerstatus zuruecksetzen
    6476         [ -  + ]:         71 :             if( pStData->GetError() )
    6477                 :          0 :                 pStData->ResetError();
    6478                 :            :             else
    6479                 :         71 :                 bOk = GetBLIPDirect( *pStData, rData, pVisArea );
    6480 [ +  + ][ +  + ]:         71 :             if( pStData2 && !bOk )
    6481                 :            :             {
    6482                 :            :                 // Fehler, aber zweite Chance: es gibt noch einen zweiten
    6483                 :            :                 //         Datenstream, in dem die Grafik liegen koennte!
    6484         [ -  + ]:         33 :                 if( pStData2->GetError() )
    6485                 :          0 :                     pStData2->ResetError();
    6486                 :         33 :                 sal_uLong nOldPosData2 = pStData2->Tell();
    6487                 :            :                 // das BLIP Atom im zweiten Daten Stream anspringen
    6488                 :         33 :                 pStData2->Seek( rInfo.nFilePos );
    6489                 :            :                 // ggfs. Fehlerstatus zuruecksetzen
    6490         [ -  + ]:         33 :                 if( pStData2->GetError() )
    6491                 :          0 :                     pStData2->ResetError();
    6492                 :            :                 else
    6493                 :         33 :                     bOk = GetBLIPDirect( *pStData2, rData, pVisArea );
    6494                 :            :                 // restore olf FilePos of the second data stream
    6495                 :         33 :                 pStData2->Seek( nOldPosData2 );
    6496                 :            :             }
    6497                 :            :             // alte FilePos des/der Stream(s) restaurieren
    6498                 :         71 :             rStCtrl.Seek( nOldPosCtrl );
    6499         [ +  + ]:         71 :             if( &rStCtrl != pStData )
    6500                 :         57 :               pStData->Seek( nOldPosData );
    6501                 :            : 
    6502         [ +  + ]:         71 :             if ( bOk )
    6503                 :            :             {
    6504                 :            :                 // create new BlipCacheEntry for this graphic
    6505         [ +  - ]:         32 :                 GraphicObject aGraphicObject( rData );
    6506 [ +  - ][ +  - ]:         32 :                 aEscherBlipCache.insert(std::make_pair(nIdx_,aGraphicObject.GetUniqueID()));
                 [ +  - ]
    6507                 :            :             }
    6508                 :            :         }
    6509                 :            :     }
    6510                 :         77 :     return bOk;
    6511                 :            : }
    6512                 :            : 
    6513                 :            : /*      access to a BLIP at runtime (with correctly positioned stream)
    6514                 :            :     ---------------------------------
    6515                 :            : ******************************************************************************/
    6516                 :        110 : sal_Bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, Rectangle* pVisArea ) const
    6517                 :            : {
    6518                 :        110 :     sal_uLong nOldPos = rBLIPStream.Tell();
    6519                 :            : 
    6520                 :        110 :     int nRes = GRFILTER_OPENERROR;  // initialize error variable
    6521                 :            : 
    6522                 :            :     // check whether it's really a BLIP
    6523                 :            :     sal_uInt32 nLength;
    6524                 :        110 :     sal_uInt16 nInst, nFbt( 0 );
    6525                 :            :     sal_uInt8   nVer;
    6526 [ +  - ][ +  + ]:        110 :     if( ReadCommonRecordHeader( rBLIPStream, nVer, nInst, nFbt, nLength) && ( 0xF018 <= nFbt ) && ( 0xF117 >= nFbt ) )
         [ +  - ][ +  + ]
                 [ +  - ]
    6527                 :            :     {
    6528                 :         71 :         Size        aMtfSize100;
    6529                 :         71 :         sal_Bool        bMtfBLIP = sal_False;
    6530                 :         71 :         sal_Bool        bZCodecCompression = sal_False;
    6531                 :            :         // now position it exactly at the beinning of the embedded graphic
    6532         [ -  + ]:         71 :         sal_uLong nSkip = ( nInst & 0x0001 ) ? 32 : 16;
    6533                 :            : 
    6534      [ +  +  - ]:         71 :         switch( nInst & 0xFFFE )
    6535                 :            :         {
    6536                 :            :             case 0x216 :            // Metafile header then compressed WMF
    6537                 :            :             case 0x3D4 :            // Metafile header then compressed EMF
    6538                 :            :             case 0x542 :            // Metafile hd. then compressed PICT
    6539                 :            :             {
    6540         [ +  - ]:         53 :                 rBLIPStream.SeekRel( nSkip + 20 );
    6541                 :            : 
    6542                 :            :                 // read in size of metafile in EMUS
    6543                 :            :                 sal_Int32 width, height;
    6544 [ +  - ][ +  - ]:         53 :                 rBLIPStream >> width >> height;
    6545                 :         53 :                 aMtfSize100.Width() = width;
    6546                 :         53 :                 aMtfSize100.Height() = height;
    6547                 :            : 
    6548                 :            :                 // scale to 1/100mm
    6549                 :         53 :                 aMtfSize100.Width() /= 360, aMtfSize100.Height() /= 360;
    6550                 :            : 
    6551         [ +  - ]:         53 :                 if ( pVisArea )     // seem that we currently are skipping the visarea position
    6552         [ +  - ]:         53 :                     *pVisArea = Rectangle( Point(), aMtfSize100 );
    6553                 :            : 
    6554                 :            :                 // skip rest of header
    6555                 :         53 :                 nSkip = 6;
    6556                 :         53 :                 bMtfBLIP = bZCodecCompression = sal_True;
    6557                 :            :             }
    6558                 :         53 :             break;
    6559                 :            :             case 0x46A :            // One byte tag then JPEG (= JFIF) data
    6560                 :            :             case 0x6E0 :            // One byte tag then PNG data
    6561                 :            :             case 0x7A8 :
    6562                 :         18 :                 nSkip += 1;         // One byte tag then DIB data
    6563                 :         18 :             break;
    6564                 :            :         }
    6565         [ +  - ]:         71 :         rBLIPStream.SeekRel( nSkip );
    6566                 :            : 
    6567                 :         71 :         SvStream* pGrStream = &rBLIPStream;
    6568                 :         71 :         SvMemoryStream* pOut = NULL;
    6569         [ +  + ]:         71 :         if( bZCodecCompression )
    6570                 :            :         {
    6571 [ +  - ][ +  - ]:         53 :             pOut = new SvMemoryStream( 0x8000, 0x4000 );
    6572         [ +  - ]:         53 :             ZCodec aZCodec( 0x8000, 0x8000 );
    6573         [ +  - ]:         53 :             aZCodec.BeginCompression();
    6574         [ +  - ]:         53 :             aZCodec.Decompress( rBLIPStream, *pOut );
    6575         [ +  - ]:         53 :             aZCodec.EndCompression();
    6576         [ +  - ]:         53 :             pOut->Seek( STREAM_SEEK_TO_BEGIN );
    6577                 :         53 :             pOut->SetResizeOffset( 0 ); // sj: #i102257# setting ResizeOffset of 0 prevents from seeking
    6578                 :            :                                         // behind the stream end (allocating too much memory)
    6579         [ +  - ]:         53 :             pGrStream = pOut;
    6580                 :            :         }
    6581                 :            : 
    6582                 :            : #if OSL_DEBUG_LEVEL > 2
    6583                 :            :         // extract graphics from ole storage into "dbggfxNNN.*"
    6584                 :            :         static sal_Int32 nGrfCount;
    6585                 :            : 
    6586                 :            :         String aFileName( String( RTL_CONSTASCII_USTRINGPARAM( "dbggfx" ) ) );
    6587                 :            :         aFileName.Append( String::CreateFromInt32( nGrfCount++ ) );
    6588                 :            :         switch( nInst &~ 1 )
    6589                 :            :         {
    6590                 :            :             case 0x216 : aFileName.Append( String( RTL_CONSTASCII_USTRINGPARAM( ".wmf" ) ) ); break;
    6591                 :            :             case 0x3d4 : aFileName.Append( String( RTL_CONSTASCII_USTRINGPARAM( ".emf" ) ) ); break;
    6592                 :            :             case 0x542 : aFileName.Append( String( RTL_CONSTASCII_USTRINGPARAM( ".pct" ) ) ); break;
    6593                 :            :             case 0x46a : aFileName.Append( String( RTL_CONSTASCII_USTRINGPARAM( ".jpg" ) ) ); break;
    6594                 :            :             case 0x6e0 : aFileName.Append( String( RTL_CONSTASCII_USTRINGPARAM( ".png" ) ) ); break;
    6595                 :            :             case 0x7a8 : aFileName.Append( String( RTL_CONSTASCII_USTRINGPARAM( ".bmp" ) ) ); break;
    6596                 :            :         }
    6597                 :            : 
    6598                 :            :         rtl::OUString aURLStr;
    6599                 :            :         if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( Application::GetAppFileName(), aURLStr ) )
    6600                 :            :         {
    6601                 :            :             INetURLObject aURL( aURLStr );
    6602                 :            : 
    6603                 :            :             aURL.removeSegment();
    6604                 :            :             aURL.removeFinalSlash();
    6605                 :            :             aURL.Append( aFileName );
    6606                 :            : 
    6607                 :            :             aURLStr = aURL.GetMainURL( INetURLObject::NO_DECODE );
    6608                 :            : 
    6609                 :            :             SAL_INFO("filter.ms", "dumping " << aURLStr);
    6610                 :            : 
    6611                 :            :             SvStream* pDbgOut = ::utl::UcbStreamHelper::CreateStream(aURLStr, STREAM_TRUNC | STREAM_WRITE);
    6612                 :            : 
    6613                 :            :             if( pDbgOut )
    6614                 :            :             {
    6615                 :            :                 if ( bZCodecCompression )
    6616                 :            :                 {
    6617                 :            :                     pOut->Seek( STREAM_SEEK_TO_END );
    6618                 :            :                     pDbgOut->Write( pOut->GetData(), pOut->Tell() );
    6619                 :            :                     pOut->Seek( STREAM_SEEK_TO_BEGIN );
    6620                 :            :                 }
    6621                 :            :                 else
    6622                 :            :                 {
    6623                 :            :                     sal_Int32 nDbgLen = nLength - nSkip;
    6624                 :            :                     if ( nDbgLen )
    6625                 :            :                     {
    6626                 :            :                         sal_Char* pDat = new sal_Char[ nDbgLen ];
    6627                 :            :                         pGrStream->Read( pDat, nDbgLen );
    6628                 :            :                         pDbgOut->Write( pDat, nDbgLen );
    6629                 :            :                         pGrStream->SeekRel( -nDbgLen );
    6630                 :            :                         delete[] pDat;
    6631                 :            :                     }
    6632                 :            :                 }
    6633                 :            : 
    6634                 :            :                 delete pDbgOut;
    6635                 :            :             }
    6636                 :            :         }
    6637                 :            : #endif
    6638                 :            : 
    6639         [ -  + ]:         71 :         if( ( nInst & 0xFFFE ) == 0x7A8 )
    6640                 :            :         {   // getting the DIBs immediately
    6641         [ #  # ]:          0 :             Bitmap aNew;
    6642 [ #  # ][ #  # ]:          0 :             if( aNew.Read( *pGrStream, sal_False ) )
    6643                 :            :             {
    6644 [ #  # ][ #  # ]:          0 :                 rData = Graphic( aNew );
                 [ #  # ]
    6645                 :          0 :                 nRes = GRFILTER_OK;
    6646         [ #  # ]:          0 :             }
    6647                 :            :         }
    6648                 :            :         else
    6649                 :            :         {   // and unleash our filter
    6650         [ +  - ]:         71 :             GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
    6651         [ +  - ]:         71 :             String aEmptyStr;
    6652         [ +  - ]:         71 :             nRes = rGF.ImportGraphic( rData, aEmptyStr, *pGrStream, GRFILTER_FORMAT_DONTKNOW );
    6653                 :            : 
    6654                 :            :             // SJ: I40472, sometimes the aspect ratio (aMtfSize100) does not match and we get scaling problems,
    6655                 :            :             // then it is better to use the prefsize that is stored within the metafile. Bug #72846# for what the
    6656                 :            :             // scaling has been implemented does not happen anymore.
    6657                 :            :             //
    6658                 :            :             // For pict graphics we will furthermore scale the metafile, because font scaling leads to error if the
    6659                 :            :             // dxarray is empty (this has been solved in wmf/emf but not for pict)
    6660 [ +  + ][ +  + ]:         71 :             if( bMtfBLIP && ( GRFILTER_OK == nRes ) && ( rData.GetType() == GRAPHIC_GDIMETAFILE ) && ( ( nInst & 0xFFFE ) == 0x542 ) )
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
    6661                 :            :             {
    6662 [ #  # ][ #  # ]:          0 :                 if ( ( aMtfSize100.Width() >= 1000 ) && ( aMtfSize100.Height() >= 1000 ) )
                 [ #  # ]
    6663                 :            :                 {   // #75956#, scaling does not work properly, if the graphic is less than 1cm
    6664 [ #  # ][ #  # ]:          0 :                     GDIMetaFile aMtf( rData.GetGDIMetaFile() );
    6665                 :          0 :                     const Size  aOldSize( aMtf.GetPrefSize() );
    6666                 :            : 
    6667   [ #  #  #  #  :          0 :                     if( aOldSize.Width() && ( aOldSize.Width() != aMtfSize100.Width() ) &&
           #  # ][ #  # ]
                 [ #  # ]
    6668                 :          0 :                         aOldSize.Height() && ( aOldSize.Height() != aMtfSize100.Height() ) )
    6669                 :            :                     {
    6670                 :          0 :                         aMtf.Scale( (double) aMtfSize100.Width() / aOldSize.Width(),
    6671         [ #  # ]:          0 :                                     (double) aMtfSize100.Height() / aOldSize.Height() );
    6672                 :          0 :                         aMtf.SetPrefSize( aMtfSize100 );
    6673 [ #  # ][ #  # ]:          0 :                         aMtf.SetPrefMapMode( MAP_100TH_MM );
                 [ #  # ]
    6674 [ #  # ][ #  # ]:          0 :                         rData = aMtf;
                 [ #  # ]
    6675         [ #  # ]:          0 :                     }
    6676                 :            :                 }
    6677         [ +  - ]:         71 :             }
    6678                 :            :         }
    6679                 :            :         // ggfs. Fehlerstatus zuruecksetzen
    6680         [ -  + ]:         71 :         if ( ERRCODE_IO_PENDING == pGrStream->GetError() )
    6681         [ #  # ]:          0 :           pGrStream->ResetError();
    6682 [ +  + ][ +  - ]:         71 :         delete pOut;
    6683                 :            :     }
    6684         [ +  - ]:        110 :     rBLIPStream.Seek( nOldPos );    // restore old FilePos of the strem
    6685                 :            : 
    6686                 :        110 :     return ( GRFILTER_OK == nRes ); // Ergebniss melden
    6687                 :            : }
    6688                 :            : 
    6689                 :            : /* static */
    6690                 :          0 : bool SvxMSDffManager::ReadCommonRecordHeader(DffRecordHeader& rRec,
    6691                 :            :     SvStream& rIn)
    6692                 :            : {
    6693                 :          0 :     rRec.nFilePos = rIn.Tell();
    6694                 :            :     return SvxMSDffManager::ReadCommonRecordHeader(rIn,rRec.nRecVer,
    6695                 :          0 :         rRec.nRecInstance, rRec.nRecType, rRec.nRecLen);
    6696                 :            : }
    6697                 :            : 
    6698                 :            : /* also static */
    6699                 :       3961 : bool SvxMSDffManager::ReadCommonRecordHeader(SvStream& rSt,
    6700                 :            :     sal_uInt8& rVer, sal_uInt16& rInst, sal_uInt16& rFbt, sal_uInt32& rLength)
    6701                 :            : {
    6702                 :       3961 :     sal_uInt16 nTmp(0);
    6703 [ +  - ][ +  - ]:       3961 :     rSt >> nTmp >> rFbt >> rLength;
                 [ +  - ]
    6704                 :       3961 :     rVer = sal::static_int_cast< sal_uInt8 >(nTmp & 15);
    6705                 :       3961 :     rInst = nTmp >> 4;
    6706         [ +  + ]:       3961 :     if (!rSt.good())
    6707                 :         34 :         return false;
    6708         [ -  + ]:       3927 :     if (rLength > nMaxLegalDffRecordLength)
    6709                 :          0 :         return false;
    6710                 :       3961 :     return true;
    6711                 :            : }
    6712                 :            : 
    6713                 :        168 : sal_Bool SvxMSDffManager::ProcessClientAnchor(SvStream& rStData, sal_uInt32 nDatLen,
    6714                 :            :                                           char*& rpBuff, sal_uInt32& rBuffLen ) const
    6715                 :            : {
    6716         [ +  - ]:        168 :     if( nDatLen )
    6717                 :            :     {
    6718 [ +  - ][ +  - ]:        168 :         rBuffLen = std::min(rStData.remainingSize(), static_cast<sal_Size>(nDatLen));
    6719                 :        168 :         rpBuff = new char[rBuffLen];
    6720                 :        168 :         rBuffLen = rStData.Read(rpBuff, rBuffLen);
    6721                 :            :     }
    6722                 :        168 :     return sal_True;
    6723                 :            : }
    6724                 :            : 
    6725                 :        519 : sal_Bool SvxMSDffManager::ProcessClientData(SvStream& rStData, sal_uInt32 nDatLen,
    6726                 :            :                                         char*& rpBuff, sal_uInt32& rBuffLen ) const
    6727                 :            : {
    6728         [ +  - ]:        519 :     if( nDatLen )
    6729                 :            :     {
    6730 [ +  - ][ +  - ]:        519 :         rBuffLen = std::min(rStData.remainingSize(), static_cast<sal_Size>(nDatLen));
    6731                 :        519 :         rpBuff = new char[rBuffLen];
    6732                 :        519 :         rBuffLen = rStData.Read(rpBuff, rBuffLen);
    6733                 :            :     }
    6734                 :        519 :     return sal_True;
    6735                 :            : }
    6736                 :            : 
    6737                 :            : 
    6738                 :        168 : void SvxMSDffManager::ProcessClientAnchor2( SvStream& /* rSt */, DffRecordHeader& /* rHd */ , void* /* pData */, DffObjData& /* rObj */ )
    6739                 :            : {
    6740                 :        168 :     return;  // wird von SJ im Draw ueberladen
    6741                 :            : }
    6742                 :            : 
    6743                 :         79 : sal_uLong SvxMSDffManager::Calc_nBLIPPos( sal_uLong nOrgVal, sal_uLong /* nStreamPos */ ) const
    6744                 :            : {
    6745                 :         79 :     return nOrgVal;
    6746                 :            : }
    6747                 :            : 
    6748                 :         11 : sal_Bool SvxMSDffManager::GetOLEStorageName( long /* nOLEId */, String&, SvStorageRef&, uno::Reference < embed::XStorage >& ) const
    6749                 :            : {
    6750                 :         11 :     return sal_False;
    6751                 :            : }
    6752                 :            : 
    6753                 :          0 : sal_Bool SvxMSDffManager::ShapeHasText( sal_uLong /* nShapeId */, sal_uLong /* nFilePos */ ) const
    6754                 :            : {
    6755                 :          0 :     return sal_True;
    6756                 :            : }
    6757                 :            : 
    6758                 :            : // #i32596# - add new parameter <_nCalledByGroup>
    6759                 :         11 : SdrObject* SvxMSDffManager::ImportOLE( long nOLEId,
    6760                 :            :                                        const Graphic& rGrf,
    6761                 :            :                                        const Rectangle& rBoundRect,
    6762                 :            :                                        const Rectangle& rVisArea,
    6763                 :            :                                        const int /* _nCalledByGroup */,
    6764                 :            :                                        sal_Int64 nAspect ) const
    6765                 :            : {
    6766                 :         11 :     SdrObject* pRet = 0;
    6767         [ +  - ]:         11 :     String sStorageName;
    6768                 :         11 :     SvStorageRef xSrcStg;
    6769                 :         11 :     ErrCode nError = ERRCODE_NONE;
    6770                 :         11 :     uno::Reference < embed::XStorage > xDstStg;
    6771 [ -  + ][ +  - ]:         11 :     if( GetOLEStorageName( nOLEId, sStorageName, xSrcStg, xDstStg ))
    6772                 :            :         pRet = CreateSdrOLEFromStorage( sStorageName, xSrcStg, xDstStg,
    6773                 :            :                                         rGrf, rBoundRect, rVisArea, pStData, nError,
    6774         [ #  # ]:          0 :                                         nSvxMSDffOLEConvFlags, nAspect );
    6775 [ +  - ][ +  - ]:         11 :     return pRet;
    6776                 :            : }
    6777                 :            : 
    6778                 :          0 : sal_Bool SvxMSDffManager::MakeContentStream( SotStorage * pStor, const GDIMetaFile & rMtf )
    6779                 :            : {
    6780 [ #  # ][ #  # ]:          0 :     SotStorageStreamRef xStm = pStor->OpenSotStream(rtl::OUString(SVEXT_PERSIST_STREAM));
                 [ #  # ]
    6781                 :          0 :     xStm->SetVersion( pStor->GetVersion() );
    6782         [ #  # ]:          0 :     xStm->SetBufferSize( 8192 );
    6783                 :            : 
    6784                 :          0 :     sal_uInt16 nAspect = ASPECT_CONTENT;
    6785                 :          0 :     sal_uLong nAdviseModes = 2;
    6786                 :            : 
    6787                 :          0 :     Impl_OlePres aEle( FORMAT_GDIMETAFILE );
    6788                 :            :     // Die Groesse in 1/100 mm umrechnen
    6789                 :            :     // Falls eine nicht anwendbare MapUnit (Device abhaengig) verwendet wird,
    6790                 :            :     // versucht SV einen BestMatchden richtigen Wert zu raten.
    6791                 :          0 :     Size aSize = rMtf.GetPrefSize();
    6792         [ #  # ]:          0 :     MapMode aMMSrc = rMtf.GetPrefMapMode();
    6793         [ #  # ]:          0 :     MapMode aMMDst( MAP_100TH_MM );
    6794         [ #  # ]:          0 :     aSize = OutputDevice::LogicToLogic( aSize, aMMSrc, aMMDst );
    6795                 :          0 :     aEle.SetSize( aSize );
    6796                 :          0 :      aEle.SetAspect( nAspect );
    6797                 :          0 :     aEle.SetAdviseFlags( nAdviseModes );
    6798         [ #  # ]:          0 :     aEle.SetMtf( rMtf );
    6799         [ #  # ]:          0 :     aEle.Write( *xStm );
    6800                 :            : 
    6801         [ #  # ]:          0 :     xStm->SetBufferSize( 0 );
    6802 [ #  # ][ #  # ]:          0 :     return xStm->GetError() == SVSTREAM_OK;
         [ #  # ][ #  # ]
    6803                 :            : }
    6804                 :            : 
    6805                 :            : struct ClsIDs {
    6806                 :            :     sal_uInt32      nId;
    6807                 :            :     const sal_Char* pSvrName;
    6808                 :            :     const sal_Char* pDspName;
    6809                 :            : };
    6810                 :            : static ClsIDs aClsIDs[] = {
    6811                 :            : 
    6812                 :            :     { 0x000212F0, "MSWordArt",          "Microsoft Word Art"            },
    6813                 :            :     { 0x000212F0, "MSWordArt.2",        "Microsoft Word Art 2.0"        },
    6814                 :            : 
    6815                 :            :     // MS Apps
    6816                 :            :     { 0x00030000, "ExcelWorksheet",     "Microsoft Excel Worksheet"     },
    6817                 :            :     { 0x00030001, "ExcelChart",         "Microsoft Excel Chart"         },
    6818                 :            :     { 0x00030002, "ExcelMacrosheet",    "Microsoft Excel Macro"         },
    6819                 :            :     { 0x00030003, "WordDocument",       "Microsoft Word Document"       },
    6820                 :            :     { 0x00030004, "MSPowerPoint",       "Microsoft PowerPoint"          },
    6821                 :            :     { 0x00030005, "MSPowerPointSho",    "Microsoft PowerPoint Slide Show"},
    6822                 :            :     { 0x00030006, "MSGraph",            "Microsoft Graph"               },
    6823                 :            :     { 0x00030007, "MSDraw",             "Microsoft Draw"                },
    6824                 :            :     { 0x00030008, "Note-It",            "Microsoft Note-It"             },
    6825                 :            :     { 0x00030009, "WordArt",            "Microsoft Word Art"            },
    6826                 :            :     { 0x0003000a, "PBrush",             "Microsoft PaintBrush Picture"  },
    6827                 :            :     { 0x0003000b, "Equation",           "Microsoft Equation Editor"     },
    6828                 :            :     { 0x0003000c, "Package",            "Package"                       },
    6829                 :            :     { 0x0003000d, "SoundRec",           "Sound"                         },
    6830                 :            :     { 0x0003000e, "MPlayer",            "Media Player"                  },
    6831                 :            :     // MS Demos
    6832                 :            :     { 0x0003000f, "ServerDemo",         "OLE 1.0 Server Demo"           },
    6833                 :            :     { 0x00030010, "Srtest",             "OLE 1.0 Test Demo"             },
    6834                 :            :     { 0x00030011, "SrtInv",             "OLE 1.0 Inv Demo"              },
    6835                 :            :     { 0x00030012, "OleDemo",            "OLE 1.0 Demo"                  },
    6836                 :            : 
    6837                 :            :     // Coromandel / Dorai Swamy / 718-793-7963
    6838                 :            :     { 0x00030013, "CoromandelIntegra",  "Coromandel Integra"            },
    6839                 :            :     { 0x00030014, "CoromandelObjServer","Coromandel Object Server"      },
    6840                 :            : 
    6841                 :            :     // 3-d Visions Corp / Peter Hirsch / 310-325-1339
    6842                 :            :     { 0x00030015, "StanfordGraphics",   "Stanford Graphics"             },
    6843                 :            : 
    6844                 :            :     // Deltapoint / Nigel Hearne / 408-648-4000
    6845                 :            :     { 0x00030016, "DGraphCHART",        "DeltaPoint Graph Chart"        },
    6846                 :            :     { 0x00030017, "DGraphDATA",         "DeltaPoint Graph Data"         },
    6847                 :            : 
    6848                 :            :     // Corel / Richard V. Woodend / 613-728-8200 x1153
    6849                 :            :     { 0x00030018, "PhotoPaint",         "Corel PhotoPaint"              },
    6850                 :            :     { 0x00030019, "CShow",              "Corel Show"                    },
    6851                 :            :     { 0x0003001a, "CorelChart",         "Corel Chart"                   },
    6852                 :            :     { 0x0003001b, "CDraw",              "Corel Draw"                    },
    6853                 :            : 
    6854                 :            :     // Inset Systems / Mark Skiba / 203-740-2400
    6855                 :            :     { 0x0003001c, "HJWIN1.0",           "Inset Systems"                 },
    6856                 :            : 
    6857                 :            :     // Mark V Systems / Mark McGraw / 818-995-7671
    6858                 :            :     { 0x0003001d, "ObjMakerOLE",        "MarkV Systems Object Maker"    },
    6859                 :            : 
    6860                 :            :     // IdentiTech / Mike Gilger / 407-951-9503
    6861                 :            :     { 0x0003001e, "FYI",                "IdentiTech FYI"                },
    6862                 :            :     { 0x0003001f, "FYIView",            "IdentiTech FYI Viewer"         },
    6863                 :            : 
    6864                 :            :     // Inventa Corporation / Balaji Varadarajan / 408-987-0220
    6865                 :            :     { 0x00030020, "Stickynote",         "Inventa Sticky Note"           },
    6866                 :            : 
    6867                 :            :     // ShapeWare Corp. / Lori Pearce / 206-467-6723
    6868                 :            :     { 0x00030021, "ShapewareVISIO10",   "Shapeware Visio 1.0"           },
    6869                 :            :     { 0x00030022, "ImportServer",       "Spaheware Import Server"       },
    6870                 :            : 
    6871                 :            :     // test app SrTest
    6872                 :            :     { 0x00030023, "SrvrTest",           "OLE 1.0 Server Test"           },
    6873                 :            : 
    6874                 :            :     // test app ClTest.  Doesn't really work as a server but is in reg db
    6875                 :            :     { 0x00030025, "Cltest",             "OLE 1.0 Client Test"           },
    6876                 :            : 
    6877                 :            :     // Microsoft ClipArt Gallery   Sherry Larsen-Holmes
    6878                 :            :     { 0x00030026, "MS_ClipArt_Gallery", "Microsoft ClipArt Gallery"     },
    6879                 :            :     // Microsoft Project  Cory Reina
    6880                 :            :     { 0x00030027, "MSProject",          "Microsoft Project"             },
    6881                 :            : 
    6882                 :            :     // Microsoft Works Chart
    6883                 :            :     { 0x00030028, "MSWorksChart",       "Microsoft Works Chart"         },
    6884                 :            : 
    6885                 :            :     // Microsoft Works Spreadsheet
    6886                 :            :     { 0x00030029, "MSWorksSpreadsheet", "Microsoft Works Spreadsheet"   },
    6887                 :            : 
    6888                 :            :     // AFX apps - Dean McCrory
    6889                 :            :     { 0x0003002A, "MinSvr",             "AFX Mini Server"               },
    6890                 :            :     { 0x0003002B, "HierarchyList",      "AFX Hierarchy List"            },
    6891                 :            :     { 0x0003002C, "BibRef",             "AFX BibRef"                    },
    6892                 :            :     { 0x0003002D, "MinSvrMI",           "AFX Mini Server MI"            },
    6893                 :            :     { 0x0003002E, "TestServ",           "AFX Test Server"               },
    6894                 :            : 
    6895                 :            :     // Ami Pro
    6896                 :            :     { 0x0003002F, "AmiProDocument",     "Ami Pro Document"              },
    6897                 :            : 
    6898                 :            :     // WordPerfect Presentations For Windows
    6899                 :            :     { 0x00030030, "WPGraphics",         "WordPerfect Presentation"      },
    6900                 :            :     { 0x00030031, "WPCharts",           "WordPerfect Chart"             },
    6901                 :            : 
    6902                 :            :     // MicroGrafx Charisma
    6903                 :            :     { 0x00030032, "Charisma",           "MicroGrafx Charisma"           },
    6904                 :            :     { 0x00030033, "Charisma_30",        "MicroGrafx Charisma 3.0"       },
    6905                 :            :     { 0x00030034, "CharPres_30",        "MicroGrafx Charisma 3.0 Pres"  },
    6906                 :            :     // MicroGrafx Draw
    6907                 :            :     { 0x00030035, "Draw",               "MicroGrafx Draw"               },
    6908                 :            :     // MicroGrafx Designer
    6909                 :            :     { 0x00030036, "Designer_40",        "MicroGrafx Designer 4.0"       },
    6910                 :            : 
    6911                 :            :     // STAR DIVISION
    6912                 :            :     { 0x00043AD2, "FontWork",           "Star FontWork"                 },
    6913                 :            : 
    6914                 :            :     { 0, "", "" } };
    6915                 :            : 
    6916                 :            : 
    6917                 :          0 : sal_Bool SvxMSDffManager::ConvertToOle2( SvStream& rStm, sal_uInt32 nReadLen,
    6918                 :            :                     const GDIMetaFile * pMtf, const SotStorageRef& rDest )
    6919                 :            : {
    6920                 :          0 :     sal_Bool bMtfRead = sal_False;
    6921                 :            :     SotStorageStreamRef xOle10Stm = rDest->OpenSotStream( rtl::OUString("\1Ole10Native"),
    6922 [ #  # ][ #  # ]:          0 :                                                     STREAM_WRITE| STREAM_SHARE_DENYALL );
                 [ #  # ]
    6923         [ #  # ]:          0 :     if( xOle10Stm->GetError() )
    6924                 :          0 :         return sal_False;
    6925                 :            : 
    6926                 :            :     sal_uInt32 nType;
    6927                 :            :     sal_uInt32 nRecType;
    6928                 :            :     sal_uInt32 nStrLen;
    6929         [ #  # ]:          0 :     String aSvrName;
    6930                 :            :     sal_uInt32 nDummy0;
    6931                 :            :     sal_uInt32 nDummy1;
    6932                 :            :     sal_uInt32 nDataLen;
    6933                 :            :     sal_uInt8 * pData;
    6934                 :          0 :     sal_uInt32 nBytesRead = 0;
    6935 [ #  # ][ #  # ]:          0 :     do
                 [ #  # ]
    6936                 :            :     {
    6937         [ #  # ]:          0 :         rStm >> nType;
    6938         [ #  # ]:          0 :         rStm >> nRecType;
    6939         [ #  # ]:          0 :         rStm >> nStrLen;
    6940         [ #  # ]:          0 :         if( nStrLen )
    6941                 :            :         {
    6942         [ #  # ]:          0 :             if( 0x10000L > nStrLen )
    6943                 :            :             {
    6944         [ #  # ]:          0 :                 sal_Char * pBuf = new sal_Char[ nStrLen ];
    6945         [ #  # ]:          0 :                 rStm.Read( pBuf, nStrLen );
    6946 [ #  # ][ #  # ]:          0 :                 aSvrName.Assign( String( pBuf, (sal_uInt16) nStrLen-1, osl_getThreadTextEncoding() ) );
         [ #  # ][ #  # ]
    6947         [ #  # ]:          0 :                 delete[] pBuf;
    6948                 :            :             }
    6949                 :            :             else
    6950                 :          0 :                 break;
    6951                 :            :         }
    6952         [ #  # ]:          0 :         rStm >> nDummy0;
    6953         [ #  # ]:          0 :         rStm >> nDummy1;
    6954         [ #  # ]:          0 :         rStm >> nDataLen;
    6955                 :            : 
    6956                 :          0 :         nBytesRead += 6 * sizeof( sal_uInt32 ) + nStrLen + nDataLen;
    6957                 :            : 
    6958 [ #  # ][ #  # ]:          0 :         if( !rStm.IsEof() && nReadLen > nBytesRead && nDataLen )
         [ #  # ][ #  # ]
    6959                 :            :         {
    6960         [ #  # ]:          0 :             if( xOle10Stm.Is() )
    6961                 :            :             {
    6962         [ #  # ]:          0 :                 pData = new sal_uInt8[ nDataLen ];
    6963         [ #  # ]:          0 :                 if( !pData )
    6964                 :          0 :                     return sal_False;
    6965                 :            : 
    6966         [ #  # ]:          0 :                 rStm.Read( pData, nDataLen );
    6967                 :            : 
    6968                 :            :                 // write to ole10 stream
    6969         [ #  # ]:          0 :                 *xOle10Stm << nDataLen;
    6970         [ #  # ]:          0 :                 xOle10Stm->Write( pData, nDataLen );
    6971 [ #  # ][ #  # ]:          0 :                 xOle10Stm = SotStorageStreamRef();
    6972                 :            : 
    6973                 :            :                 // set the compobj stream
    6974                 :            :                 ClsIDs* pIds;
    6975         [ #  # ]:          0 :                 for( pIds = aClsIDs; pIds->nId; pIds++ )
    6976                 :            :                 {
    6977 [ #  # ][ #  # ]:          0 :                     if( COMPARE_EQUAL == aSvrName.CompareToAscii( pIds->pSvrName ) )
    6978                 :          0 :                         break;
    6979                 :            :                 }
    6980                 :            : 
    6981 [ #  # ][ #  # ]:          0 :                 String aShort, aFull;
    6982         [ #  # ]:          0 :                 if( pIds->nId )
    6983                 :            :                 {
    6984                 :            :                     // found!
    6985         [ #  # ]:          0 :                     sal_uLong nCbFmt = SotExchange::RegisterFormatName( aSvrName );
    6986                 :          0 :                     rDest->SetClass( SvGlobalName( pIds->nId, 0, 0, 0xc0,0,0,0,0,0,0,0x46 ), nCbFmt,
    6987 [ #  # ][ #  # ]:          0 :                                     String( pIds->pDspName, RTL_TEXTENCODING_ASCII_US ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    6988                 :            :                 }
    6989                 :            :                 else
    6990                 :            :                 {
    6991         [ #  # ]:          0 :                     sal_uLong nCbFmt = SotExchange::RegisterFormatName( aSvrName );
    6992 [ #  # ][ #  # ]:          0 :                     rDest->SetClass( SvGlobalName(), nCbFmt, aSvrName );
                 [ #  # ]
    6993                 :            :                 }
    6994                 :            : 
    6995 [ #  # ][ #  # ]:          0 :                 delete[] pData;
                 [ #  # ]
    6996                 :            :             }
    6997 [ #  # ][ #  # ]:          0 :             else if( nRecType == 5 && !pMtf )
    6998                 :            :             {
    6999                 :          0 :                 sal_uLong nPos = rStm.Tell();
    7000                 :            :                 sal_uInt16 sz[4];
    7001         [ #  # ]:          0 :                 rStm.Read( sz, 8 );
    7002         [ #  # ]:          0 :                 Graphic aGraphic;
    7003 [ #  # ][ #  # ]:          0 :                 if( ERRCODE_NONE == GraphicConverter::Import( rStm, aGraphic ) && aGraphic.GetType() )
         [ #  # ][ #  # ]
                 [ #  # ]
    7004                 :            :                 {
    7005         [ #  # ]:          0 :                     const GDIMetaFile& rMtf = aGraphic.GetGDIMetaFile();
    7006         [ #  # ]:          0 :                     MakeContentStream( rDest, rMtf );
    7007                 :          0 :                     bMtfRead = sal_True;
    7008                 :            :                 }
    7009                 :            :                 // set behind the data
    7010 [ #  # ][ #  # ]:          0 :                 rStm.Seek( nPos + nDataLen );
    7011                 :            :             }
    7012                 :            :             else
    7013         [ #  # ]:          0 :                 rStm.SeekRel( nDataLen );
    7014                 :            :         }
    7015                 :          0 :     } while( !rStm.IsEof() && nReadLen >= nBytesRead );
    7016                 :            : 
    7017 [ #  # ][ #  # ]:          0 :     if( !bMtfRead && pMtf )
    7018                 :            :     {
    7019         [ #  # ]:          0 :         MakeContentStream( rDest, *pMtf );
    7020                 :          0 :         return sal_True;
    7021                 :            :     }
    7022                 :            : 
    7023 [ #  # ][ #  # ]:          0 :     return sal_False;
    7024                 :            : }
    7025                 :            : 
    7026                 :          9 : const char* GetInternalServerName_Impl( const SvGlobalName& aGlobName )
    7027                 :            : {
    7028 [ +  - ][ +  - ]:         27 :     if ( aGlobName == SvGlobalName( SO3_SW_OLE_EMBED_CLASSID_60 )
         [ +  - ][ -  + ]
                 [ +  - ]
           [ -  +  #  # ]
    7029 [ +  - ][ +  - ]:         18 :       || aGlobName == SvGlobalName( SO3_SW_OLE_EMBED_CLASSID_8 ) )
         [ +  - ][ +  - ]
                 [ #  # ]
    7030                 :          0 :         return "swriter";
    7031 [ +  - ][ +  - ]:         27 :     else if ( aGlobName == SvGlobalName( SO3_SC_OLE_EMBED_CLASSID_60 )
         [ +  - ][ -  + ]
                 [ +  - ]
           [ -  +  #  # ]
    7032 [ +  - ][ +  - ]:         18 :       || aGlobName == SvGlobalName( SO3_SC_OLE_EMBED_CLASSID_8 ) )
         [ +  - ][ +  - ]
                 [ #  # ]
    7033                 :          0 :         return "scalc";
    7034 [ +  - ][ +  - ]:         27 :     else if ( aGlobName == SvGlobalName( SO3_SIMPRESS_OLE_EMBED_CLASSID_60 )
         [ +  - ][ -  + ]
                 [ +  - ]
           [ -  +  #  # ]
    7035 [ +  - ][ +  - ]:         18 :       || aGlobName == SvGlobalName( SO3_SIMPRESS_OLE_EMBED_CLASSID_8 ) )
         [ +  - ][ +  - ]
                 [ #  # ]
    7036                 :          0 :         return "simpress";
    7037 [ +  - ][ +  - ]:         27 :     else if ( aGlobName == SvGlobalName( SO3_SDRAW_OLE_EMBED_CLASSID_60 )
         [ +  - ][ -  + ]
                 [ +  - ]
           [ -  +  #  # ]
    7038 [ +  - ][ +  - ]:         18 :       || aGlobName == SvGlobalName( SO3_SDRAW_OLE_EMBED_CLASSID_8 ) )
         [ +  - ][ +  - ]
                 [ #  # ]
    7039                 :          0 :         return "sdraw";
    7040 [ +  - ][ +  - ]:         27 :     else if ( aGlobName == SvGlobalName( SO3_SM_OLE_EMBED_CLASSID_60 )
         [ +  - ][ -  + ]
                 [ +  - ]
           [ -  +  #  # ]
    7041 [ +  - ][ +  - ]:         18 :       || aGlobName == SvGlobalName( SO3_SM_OLE_EMBED_CLASSID_8 ) )
         [ +  - ][ +  - ]
                 [ #  # ]
    7042                 :          0 :         return "smath";
    7043 [ +  - ][ +  - ]:         27 :     else if ( aGlobName == SvGlobalName( SO3_SCH_OLE_EMBED_CLASSID_60 )
         [ +  - ][ +  - ]
                 [ +  - ]
           [ +  -  #  # ]
    7044 [ +  - ][ +  - ]:         18 :       || aGlobName == SvGlobalName( SO3_SCH_OLE_EMBED_CLASSID_8 ) )
         [ +  - ][ +  - ]
                 [ #  # ]
    7045                 :          9 :         return "schart";
    7046                 :          9 :     return 0;
    7047                 :            : }
    7048                 :            : 
    7049                 :          9 : ::rtl::OUString GetFilterNameFromClassID_Impl( const SvGlobalName& aGlobName )
    7050                 :            : {
    7051 [ +  - ][ -  + ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SW_OLE_EMBED_CLASSID_60 ) )
    7052                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StarOffice XML (Writer)" ) );
    7053                 :            : 
    7054 [ +  - ][ -  + ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SW_OLE_EMBED_CLASSID_8 ) )
    7055                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "writer8" ) );
    7056                 :            : 
    7057 [ +  - ][ -  + ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SC_OLE_EMBED_CLASSID_60 ) )
    7058                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StarOffice XML (Calc)" ) );
    7059                 :            : 
    7060 [ +  - ][ -  + ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SC_OLE_EMBED_CLASSID_8 ) )
    7061                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "calc8" ) );
    7062                 :            : 
    7063 [ +  - ][ -  + ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SIMPRESS_OLE_EMBED_CLASSID_60 ) )
    7064                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StarOffice XML (Impress)" ) );
    7065                 :            : 
    7066 [ +  - ][ -  + ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SIMPRESS_OLE_EMBED_CLASSID_8 ) )
    7067                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "impress8" ) );
    7068                 :            : 
    7069 [ +  - ][ -  + ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SDRAW_OLE_EMBED_CLASSID_60 ) )
    7070                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StarOffice XML (Draw)" ) );
    7071                 :            : 
    7072 [ +  - ][ -  + ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SDRAW_OLE_EMBED_CLASSID_8 ) )
    7073                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "draw8" ) );
    7074                 :            : 
    7075 [ +  - ][ -  + ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SM_OLE_EMBED_CLASSID_60 ) )
    7076                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StarOffice XML (Math)" ) );
    7077                 :            : 
    7078 [ +  - ][ -  + ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SM_OLE_EMBED_CLASSID_8 ) )
    7079                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "math8" ) );
    7080                 :            : 
    7081 [ +  - ][ -  + ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SCH_OLE_EMBED_CLASSID_60 ) )
    7082                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StarOffice XML (Chart)" ) );
    7083                 :            : 
    7084 [ +  - ][ +  - ]:          9 :     if ( aGlobName == SvGlobalName( SO3_SCH_OLE_EMBED_CLASSID_8 ) )
    7085                 :          9 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "chart8" ) );
    7086                 :            : 
    7087                 :          9 :     return ::rtl::OUString();
    7088                 :            : }
    7089                 :            : 
    7090                 :          9 : com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >  SvxMSDffManager::CheckForConvertToSOObj( sal_uInt32 nConvertFlags,
    7091                 :            :                         SotStorage& rSrcStg, const uno::Reference < embed::XStorage >& rDestStorage,
    7092                 :            :                         const Graphic& rGrf,
    7093                 :            :                         const Rectangle& rVisArea )
    7094                 :            : {
    7095                 :          9 :     uno::Reference < embed::XEmbeddedObject > xObj;
    7096         [ +  - ]:          9 :     SvGlobalName aStgNm = rSrcStg.GetClassName();
    7097         [ +  - ]:          9 :     const char* pName = GetInternalServerName_Impl( aStgNm );
    7098         [ +  - ]:          9 :     String sStarName;
    7099         [ +  - ]:          9 :     if ( pName )
    7100         [ +  - ]:          9 :         sStarName = rtl::OUString::createFromAscii( pName );
    7101         [ #  # ]:          0 :     else if ( nConvertFlags )
    7102                 :            :     {
    7103                 :            :         static struct _ObjImpType
    7104                 :            :         {
    7105                 :            :             sal_uInt32 nFlag;
    7106                 :            :             const char* pFactoryNm;
    7107                 :            :             // GlobalNameId
    7108                 :            :             sal_uInt32 n1;
    7109                 :            :             sal_uInt16 n2, n3;
    7110                 :            :             sal_uInt8 b8, b9, b10, b11, b12, b13, b14, b15;
    7111                 :            :         } aArr[] = {
    7112                 :            :             { OLE_MATHTYPE_2_STARMATH, "smath",
    7113                 :            :                 0x0002ce02L, 0x0000, 0x0000,
    7114                 :            :                 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 },
    7115                 :            :             { OLE_MATHTYPE_2_STARMATH, "smath",
    7116                 :            :                 0x00021700L, 0x0000, 0x0000,
    7117                 :            :                 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 },
    7118                 :            :             { OLE_WINWORD_2_STARWRITER, "swriter",
    7119                 :            :                 0x00020906L, 0x0000, 0x0000,
    7120                 :            :                 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 },
    7121                 :            :             { OLE_EXCEL_2_STARCALC, "scalc",                // Excel table
    7122                 :            :                 0x00020810L, 0x0000, 0x0000,
    7123                 :            :                 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 },
    7124                 :            :             { OLE_EXCEL_2_STARCALC, "scalc",                // Excel chart
    7125                 :            :                 0x00020820L, 0x0000, 0x0000,
    7126                 :            :                 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 },
    7127                 :            :             // 114465: additional Excel OLE chart classId to above.
    7128                 :            :             { OLE_EXCEL_2_STARCALC, "scalc",
    7129                 :            :                 0x00020821L, 0x0000, 0x0000,
    7130                 :            :                 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 },
    7131                 :            :             { OLE_POWERPOINT_2_STARIMPRESS, "simpress",     // PowerPoint presentation
    7132                 :            :                 0x64818d10L, 0x4f9b, 0x11cf,
    7133                 :            :                 0x86,0xea,0x00,0xaa,0x00,0xb9,0x29,0xe8 },
    7134                 :            :             { OLE_POWERPOINT_2_STARIMPRESS, "simpress",     // PowerPoint slide
    7135                 :            :                 0x64818d11L, 0x4f9b, 0x11cf,
    7136                 :            :                 0x86,0xea,0x00,0xaa,0x00,0xb9,0x29,0xe8 },
    7137                 :            :             { 0, 0,
    7138                 :            :               0, 0, 0,
    7139                 :            :               0, 0, 0, 0, 0, 0, 0, 0 }
    7140                 :            :         };
    7141                 :            : 
    7142         [ #  # ]:          0 :         for( const _ObjImpType* pArr = aArr; pArr->nFlag; ++pArr )
    7143                 :            :         {
    7144         [ #  # ]:          0 :             if( nConvertFlags & pArr->nFlag )
    7145                 :            :             {
    7146                 :            :                 SvGlobalName aTypeName( pArr->n1, pArr->n2, pArr->n3,
    7147                 :            :                                 pArr->b8, pArr->b9, pArr->b10, pArr->b11,
    7148         [ #  # ]:          0 :                                 pArr->b12, pArr->b13, pArr->b14, pArr->b15 );
    7149                 :            : 
    7150 [ #  # ][ #  # ]:          0 :                 if ( aStgNm == aTypeName )
    7151                 :            :                 {
    7152         [ #  # ]:          0 :                     sStarName = rtl::OUString::createFromAscii( pArr->pFactoryNm );
    7153                 :            :                     break;
    7154 [ #  # ][ #  # ]:          0 :                 }
    7155                 :            :             }
    7156                 :            :         }
    7157                 :            :     }
    7158                 :            : 
    7159         [ +  - ]:          9 :     if ( sStarName.Len() )
    7160                 :            :     {
    7161                 :            :         //TODO/MBA: check if (and when) storage and stream will be destroyed!
    7162                 :          9 :         const SfxFilter* pFilter = 0;
    7163 [ +  - ][ +  - ]:          9 :         SvMemoryStream* pStream = new SvMemoryStream;
    7164         [ +  - ]:          9 :         if ( pName )
    7165                 :            :         {
    7166                 :            :             // TODO/LATER: perhaps we need to retrieve VisArea and Metafile from the storage also
    7167 [ +  - ][ +  - ]:          9 :             SotStorageStreamRef xStr = rSrcStg.OpenSotStream( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "package_stream" ) ), STREAM_STD_READ );
         [ +  - ][ +  - ]
    7168 [ +  - ][ +  - ]:          9 :             *xStr >> *pStream;
    7169                 :            :         }
    7170                 :            :         else
    7171                 :            :         {
    7172         [ #  # ]:          0 :             SfxFilterMatcher aMatch( sStarName );
    7173 [ #  # ][ #  # ]:          0 :             SotStorageRef xStorage = new SotStorage( sal_False, *pStream );
    7174         [ #  # ]:          0 :             rSrcStg.CopyTo( xStorage );
    7175         [ #  # ]:          0 :             xStorage->Commit();
    7176         [ #  # ]:          0 :             xStorage.Clear();
    7177         [ #  # ]:          0 :             String aType = SfxFilter::GetTypeFromStorage( rSrcStg );
    7178         [ #  # ]:          0 :             if ( aType.Len() )
    7179 [ #  # ][ #  # ]:          0 :                 pFilter = aMatch.GetFilter4EA( aType );
         [ #  # ][ #  # ]
    7180                 :            :         }
    7181                 :            : 
    7182                 :            : #if OSL_DEBUG_LEVEL > 2
    7183                 :            :         // extract embedded ole streams into "/tmp/embedded_stream_NNN"
    7184                 :            :         static sal_Int32 nOleCount(0);
    7185                 :            :         String aTmpName(RTL_CONSTASCII_USTRINGPARAM("/tmp/embedded_stream_"));
    7186                 :            :         aTmpName += String::CreateFromInt32(nOleCount++);
    7187                 :            :         aTmpName += rtl::OUString(".bin");
    7188                 :            :         SvFileStream aTmpStream(aTmpName,STREAM_READ|STREAM_WRITE|STREAM_TRUNC);
    7189                 :            :         pStream->Seek(0);
    7190                 :            :         *pStream >> aTmpStream;
    7191                 :            :         aTmpStream.Close();
    7192                 :            : #endif
    7193 [ -  + ][ #  # ]:          9 :         if ( pName || pFilter )
    7194                 :            :         {
    7195                 :            :             //Reuse current ole name
    7196                 :          9 :             rtl::OUString aDstStgName(MSO_OLE_Obj);
    7197 [ +  - ][ +  - ]:          9 :             aDstStgName += String::CreateFromInt32(nMSOleObjCntr);
                 [ +  - ]
    7198                 :            : 
    7199                 :          9 :             ::rtl::OUString aFilterName;
    7200         [ -  + ]:          9 :             if ( pFilter )
    7201         [ #  # ]:          0 :                 aFilterName = pFilter->GetName();
    7202                 :            :             else
    7203         [ +  - ]:          9 :                 aFilterName = GetFilterNameFromClassID_Impl( aStgNm );
    7204                 :            : 
    7205 [ -  + ][ +  - ]:          9 :             uno::Sequence < beans::PropertyValue > aMedium( aFilterName.isEmpty() ? 2 : 3);
    7206 [ +  - ][ +  - ]:          9 :             aMedium[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InputStream" ) );
    7207 [ +  - ][ +  - ]:          9 :             uno::Reference < io::XInputStream > xStream = new ::utl::OSeekableInputStreamWrapper( *pStream );
                 [ +  - ]
    7208 [ +  - ][ +  - ]:          9 :             aMedium[0].Value <<= xStream;
    7209 [ +  - ][ +  - ]:          9 :             aMedium[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
    7210 [ +  - ][ +  - ]:          9 :             aMedium[1].Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:stream" ) );
                 [ +  - ]
    7211                 :            : 
    7212         [ +  - ]:          9 :             if ( !aFilterName.isEmpty() )
    7213                 :            :             {
    7214 [ +  - ][ +  - ]:          9 :                 aMedium[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" ) );
    7215 [ +  - ][ +  - ]:          9 :                 aMedium[2].Value <<= aFilterName;
    7216                 :            :             }
    7217                 :            : 
    7218                 :          9 :             ::rtl::OUString aName( aDstStgName );
    7219         [ +  - ]:          9 :             comphelper::EmbeddedObjectContainer aCnt( rDestStorage );
    7220 [ +  - ][ +  - ]:          9 :             xObj = aCnt.InsertEmbeddedObject( aMedium, aName );
    7221                 :            : 
    7222         [ +  - ]:          9 :             if ( !xObj.is() )
    7223                 :            :             {
    7224         [ +  - ]:          9 :                 if( !aFilterName.isEmpty() )
    7225                 :            :                 {
    7226                 :            :                     // throw the filter parameter away as workaround
    7227         [ +  - ]:          9 :                     aMedium.realloc( 2 );
    7228 [ +  - ][ +  - ]:          9 :                     xObj = aCnt.InsertEmbeddedObject( aMedium, aName );
    7229                 :            :                 }
    7230                 :            : 
    7231         [ +  - ]:          9 :                 if ( !xObj.is() )
    7232                 :            :                      return xObj;
    7233                 :            :             }
    7234                 :            : 
    7235                 :            :             // TODO/LATER: ViewAspect must be passed from outside!
    7236                 :          0 :             sal_Int64 nViewAspect = embed::Aspects::MSOLE_CONTENT;
    7237                 :            : 
    7238                 :            :             // JP 26.10.2001: Bug 93374 / 91928 the writer
    7239                 :            :             // objects need the correct visarea needs the
    7240                 :            :             // correct visarea, but this is not true for
    7241                 :            :             // PowerPoint (see bugdoc 94908b)
    7242                 :            :             // SJ: 19.11.2001 bug 94908, also chart objects
    7243                 :            :             // needs the correct visarea
    7244                 :            : 
    7245                 :            :             // If pName is set this is an own embedded object, it should have the correct size internally
    7246                 :            :             // TODO/LATER: it might make sence in future to set the size stored in internal object
    7247 [ #  # ][ #  # ]:          0 :             if( !pName && ( sStarName.EqualsAscii( "swriter" ) || sStarName.EqualsAscii( "scalc" ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    7248                 :            :             {
    7249 [ #  # ][ #  # ]:          0 :                 MapMode aMapMode( VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nViewAspect ) ) );
         [ #  # ][ #  # ]
    7250                 :          0 :                 Size aSz;
    7251 [ #  # ][ #  # ]:          0 :                 if ( rVisArea.IsEmpty() )
    7252 [ #  # ][ #  # ]:          0 :                     aSz = lcl_GetPrefSize(rGrf, aMapMode );
                 [ #  # ]
    7253                 :            :                 else
    7254                 :            :                 {
    7255         [ #  # ]:          0 :                     aSz = rVisArea.GetSize();
    7256 [ #  # ][ #  # ]:          0 :                     aSz = OutputDevice::LogicToLogic( aSz, MapMode( MAP_100TH_MM ), aMapMode );
                 [ #  # ]
    7257                 :            :                 }
    7258                 :            : 
    7259                 :            :                 // don't modify the object
    7260                 :            :                 //TODO/LATER: remove those hacks, that needs to be done differently!
    7261                 :            :                 //xIPObj->EnableSetModified( sal_False );
    7262                 :          0 :                 awt::Size aSize;
    7263                 :          0 :                 aSize.Width = aSz.Width();
    7264                 :          0 :                 aSize.Height = aSz.Height();
    7265 [ #  # ][ #  # ]:          0 :                 xObj->setVisualAreaSize( nViewAspect, aSize );
                 [ #  # ]
    7266                 :            :                 //xIPObj->EnableSetModified( sal_True );
    7267                 :            :             }
    7268         [ #  # ]:          0 :             else if ( sStarName.EqualsAscii( "smath" ) )
    7269                 :            :             {   // SJ: force the object to recalc its visarea
    7270                 :            :                 //TODO/LATER: wait for PrinterChangeNotification
    7271                 :            :                 //xIPObj->OnDocumentPrinterChanged( NULL );
    7272 [ +  - ][ +  - ]:          9 :             }
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
    7273                 :            :         }
    7274                 :            :     }
    7275                 :            : 
    7276 [ +  - ][ +  - ]:          9 :     return xObj;
    7277                 :            : }
    7278                 :            : 
    7279                 :            : // TODO/MBA: code review and testing!
    7280                 :          0 : SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage(
    7281                 :            :                 const String& rStorageName,
    7282                 :            :                 SotStorageRef& rSrcStorage,
    7283                 :            :                 const uno::Reference < embed::XStorage >& xDestStorage,
    7284                 :            :                 const Graphic& rGrf,
    7285                 :            :                 const Rectangle& rBoundRect,
    7286                 :            :                 const Rectangle& rVisArea,
    7287                 :            :                 SvStream* pDataStrm,
    7288                 :            :                 ErrCode& rError,
    7289                 :            :                 sal_uInt32 nConvertFlags,
    7290                 :            :                 sal_Int64 nRecommendedAspect )
    7291                 :            : {
    7292                 :          0 :     sal_Int64 nAspect = nRecommendedAspect;
    7293                 :          0 :     SdrOle2Obj* pRet = 0;
    7294 [ #  # ][ #  # ]:          0 :     if( rSrcStorage.Is() && xDestStorage.is() && rStorageName.Len() )
         [ #  # ][ #  # ]
    7295                 :            :     {
    7296         [ #  # ]:          0 :         comphelper::EmbeddedObjectContainer aCnt( xDestStorage );
    7297                 :            :         // does the 01Ole-Stream exist at all?
    7298                 :            :         // (that's not the case for e.g. Fontwork )
    7299                 :            :         // If that's not the case -> include it as graphic
    7300                 :          0 :         sal_Bool bValidStorage = sal_False;
    7301                 :          0 :         rtl::OUString aDstStgName(MSO_OLE_Obj);
    7302                 :            : 
    7303 [ #  # ][ #  # ]:          0 :         aDstStgName += String::CreateFromInt32( ++nMSOleObjCntr );
                 [ #  # ]
    7304                 :            : 
    7305                 :            :         {
    7306                 :            :             SvStorageRef xObjStg = rSrcStorage->OpenSotStorage( rStorageName,
    7307         [ #  # ]:          0 :                                 STREAM_READWRITE| STREAM_SHARE_DENYALL );
    7308         [ #  # ]:          0 :             if( xObjStg.Is()  )
    7309                 :            :             {
    7310                 :            :                 {
    7311                 :            :                     sal_uInt8 aTestA[10];   // exist the \1CompObj-Stream ?
    7312                 :            :                     SvStorageStreamRef xSrcTst = xObjStg->OpenSotStream(
    7313                 :            :                                 String(RTL_CONSTASCII_STRINGPARAM("\1CompObj"),
    7314 [ #  # ][ #  # ]:          0 :                                         RTL_TEXTENCODING_MS_1252 ));
                 [ #  # ]
    7315                 :          0 :                     bValidStorage = xSrcTst.Is() && sizeof( aTestA ) ==
    7316 [ #  # ][ #  # ]:          0 :                                     xSrcTst->Read( aTestA, sizeof( aTestA ) );
                 [ #  # ]
    7317         [ #  # ]:          0 :                     if( !bValidStorage )
    7318                 :            :                     {
    7319                 :            :                         // or the \1Ole-Stream ?
    7320                 :            :                         xSrcTst = xObjStg->OpenSotStream(
    7321                 :            :                                     String(RTL_CONSTASCII_STRINGPARAM("\1Ole"),
    7322 [ #  # ][ #  # ]:          0 :                                             RTL_TEXTENCODING_MS_1252 ));
         [ #  # ][ #  # ]
    7323                 :          0 :                         bValidStorage = xSrcTst.Is() && sizeof(aTestA) ==
    7324 [ #  # ][ #  # ]:          0 :                                         xSrcTst->Read(aTestA, sizeof(aTestA));
                 [ #  # ]
    7325         [ #  # ]:          0 :                     }
    7326                 :            :                 }
    7327                 :            : 
    7328         [ #  # ]:          0 :                 if( bValidStorage )
    7329                 :            :                 {
    7330         [ #  # ]:          0 :                     if ( nAspect != embed::Aspects::MSOLE_ICON )
    7331                 :            :                     {
    7332                 :            :                         // check whether the object is iconified one
    7333                 :            :                         // usually this information is already known, the only exception
    7334                 :            :                         // is a kind of embedded objects in Word documents
    7335                 :            :                         // TODO/LATER: should the caller be notified if the aspect changes in future?
    7336                 :            : 
    7337                 :            :                         SvStorageStreamRef xObjInfoSrc = xObjStg->OpenSotStream(
    7338                 :            :                             String( RTL_CONSTASCII_USTRINGPARAM( "\3ObjInfo" ) ),
    7339 [ #  # ][ #  # ]:          0 :                             STREAM_STD_READ | STREAM_NOCREATE );
                 [ #  # ]
    7340 [ #  # ][ #  # ]:          0 :                         if ( xObjInfoSrc.Is() && !xObjInfoSrc->GetError() )
                 [ #  # ]
    7341                 :            :                         {
    7342                 :          0 :                             sal_uInt8 nByte = 0;
    7343         [ #  # ]:          0 :                             *xObjInfoSrc >> nByte;
    7344         [ #  # ]:          0 :                             if ( ( nByte >> 4 ) & embed::Aspects::MSOLE_ICON )
    7345                 :          0 :                                 nAspect = embed::Aspects::MSOLE_ICON;
    7346         [ #  # ]:          0 :                         }
    7347                 :            :                     }
    7348                 :            : 
    7349                 :            :                     uno::Reference < embed::XEmbeddedObject > xObj( CheckForConvertToSOObj(
    7350         [ #  # ]:          0 :                                 nConvertFlags, *xObjStg, xDestStorage, rGrf, rVisArea ));
    7351         [ #  # ]:          0 :                     if ( xObj.is() )
    7352                 :            :                     {
    7353         [ #  # ]:          0 :                         svt::EmbeddedObjectRef aObj( xObj, nAspect );
    7354                 :            : 
    7355                 :            :                         // TODO/LATER: need MediaType
    7356         [ #  # ]:          0 :                         aObj.SetGraphic( rGrf, ::rtl::OUString() );
    7357                 :            : 
    7358                 :            :                         // TODO/MBA: check setting of PersistName
    7359 [ #  # ][ #  # ]:          0 :                         pRet = new SdrOle2Obj( aObj, String(), rBoundRect, false);
         [ #  # ][ #  # ]
    7360                 :            :                         // we have the Object, don't create another
    7361         [ #  # ]:          0 :                         bValidStorage = false;
    7362                 :          0 :                     }
    7363                 :            :                 }
    7364         [ #  # ]:          0 :             }
    7365                 :            :         }
    7366                 :            : 
    7367         [ #  # ]:          0 :         if( bValidStorage )
    7368                 :            :         {
    7369                 :            :             // object is not an own object
    7370 [ #  # ][ #  # ]:          0 :             SotStorageRef xObjStor = SotStorage::OpenOLEStorage( xDestStorage, aDstStgName, STREAM_READWRITE );
                 [ #  # ]
    7371                 :            : 
    7372         [ #  # ]:          0 :             if ( xObjStor.Is() )
    7373                 :            :             {
    7374         [ #  # ]:          0 :                 SotStorageRef xSrcStor = rSrcStorage->OpenSotStorage( rStorageName, STREAM_READ );
    7375         [ #  # ]:          0 :                 xSrcStor->CopyTo( xObjStor );
    7376                 :            : 
    7377         [ #  # ]:          0 :                 if( !xObjStor->GetError() )
    7378         [ #  # ]:          0 :                     xObjStor->Commit();
    7379                 :            : 
    7380         [ #  # ]:          0 :                 if( xObjStor->GetError() )
    7381                 :            :                 {
    7382                 :          0 :                     rError = xObjStor->GetError();
    7383                 :          0 :                     bValidStorage = sal_False;
    7384                 :            :                 }
    7385         [ #  # ]:          0 :                 else if( !xObjStor.Is() )
    7386         [ #  # ]:          0 :                     bValidStorage = sal_False;
    7387         [ #  # ]:          0 :             }
    7388                 :            :         }
    7389         [ #  # ]:          0 :         else if( pDataStrm )
    7390                 :            :         {
    7391                 :            :             sal_uInt32 nLen, nDummy;
    7392 [ #  # ][ #  # ]:          0 :             *pDataStrm >> nLen >> nDummy;
    7393 [ #  # ][ #  # ]:          0 :             if( SVSTREAM_OK != pDataStrm->GetError() ||
                 [ #  # ]
    7394                 :            :                 // Id in BugDoc - exist there other Ids?
    7395                 :            :                 // The ConvertToOle2 - does not check for consistent
    7396                 :            :                 0x30008 != nDummy )
    7397                 :          0 :                 bValidStorage = sal_False;
    7398                 :            :             else
    7399                 :            :             {
    7400                 :            :                 // or is it an OLE-1 Stream in the DataStream?
    7401 [ #  # ][ #  # ]:          0 :                 SvStorageRef xObjStor = SotStorage::OpenOLEStorage( xDestStorage, aDstStgName );
                 [ #  # ]
    7402                 :            :                 //TODO/MBA: remove metafile conversion from ConvertToOle2
    7403                 :            :                 //when is this code used?!
    7404         [ #  # ]:          0 :                 GDIMetaFile aMtf;
    7405         [ #  # ]:          0 :                 bValidStorage = ConvertToOle2( *pDataStrm, nLen, &aMtf, xObjStor );
    7406 [ #  # ][ #  # ]:          0 :                 xObjStor->Commit();
                 [ #  # ]
    7407                 :            :             }
    7408                 :            :         }
    7409                 :            : 
    7410         [ #  # ]:          0 :         if( bValidStorage )
    7411                 :            :         {
    7412         [ #  # ]:          0 :             uno::Reference < embed::XEmbeddedObject > xObj = aCnt.GetEmbeddedObject( aDstStgName );
    7413         [ #  # ]:          0 :             if( xObj.is() )
    7414                 :            :             {
    7415                 :            :                 // the visual area must be retrieved from the metafile (object doesn't know it so far)
    7416                 :            : 
    7417         [ #  # ]:          0 :                 if ( nAspect != embed::Aspects::MSOLE_ICON )
    7418                 :            :                 {
    7419                 :            :                     // working with visual area can switch the object to running state
    7420                 :          0 :                     awt::Size aAwtSz;
    7421                 :            :                     try
    7422                 :            :                     {
    7423                 :            :                         // the provided visual area should be used, if there is any
    7424 [ #  # ][ #  # ]:          0 :                         if ( rVisArea.IsEmpty() )
    7425                 :            :                         {
    7426 [ #  # ][ #  # ]:          0 :                             MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
                 [ #  # ]
    7427 [ #  # ][ #  # ]:          0 :                             Size aSz(lcl_GetPrefSize(rGrf, MapMode(aMapUnit)));
           [ #  #  #  # ]
    7428                 :          0 :                             aAwtSz.Width = aSz.Width();
    7429                 :          0 :                             aAwtSz.Height = aSz.Height();
    7430                 :            :                         }
    7431                 :            :                         else
    7432                 :            :                         {
    7433         [ #  # ]:          0 :                             aAwtSz.Width = rVisArea.GetWidth();
    7434         [ #  # ]:          0 :                             aAwtSz.Height = rVisArea.GetHeight();
    7435                 :            :                         }
    7436                 :            :                         //xInplaceObj->EnableSetModified( sal_False );
    7437 [ #  # ][ #  # ]:          0 :                         xObj->setVisualAreaSize( nAspect, aAwtSz );
    7438                 :            :                         //xInplaceObj->EnableSetModified( sal_True );
    7439                 :            :                     }
    7440         [ #  # ]:          0 :                     catch( const uno::Exception& )
    7441                 :            :                     {
    7442                 :            :                         OSL_FAIL( "Could not set visual area of the object!\n" );
    7443                 :            :                     }
    7444                 :            :                 }
    7445                 :            : 
    7446         [ #  # ]:          0 :                 svt::EmbeddedObjectRef aObj( xObj, nAspect );
    7447                 :            : 
    7448                 :            :                 // TODO/LATER: need MediaType
    7449         [ #  # ]:          0 :                 aObj.SetGraphic( rGrf, ::rtl::OUString() );
    7450                 :            : 
    7451 [ #  # ][ #  # ]:          0 :                 pRet = new SdrOle2Obj( aObj, aDstStgName, rBoundRect, false);
         [ #  # ][ #  # ]
                 [ #  # ]
    7452                 :          0 :             }
    7453         [ #  # ]:          0 :         }
    7454                 :            :     }
    7455                 :            : 
    7456                 :          0 :     return pRet;
    7457                 :            : }
    7458                 :            : 
    7459                 :          0 : sal_Bool SvxMSDffManager::SetPropValue( const uno::Any& rAny, const uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
    7460                 :            :             const String& rPropName, sal_Bool bTestPropertyAvailability )
    7461                 :            : {
    7462                 :          0 :     sal_Bool bRetValue = sal_True;
    7463         [ #  # ]:          0 :     if ( bTestPropertyAvailability )
    7464                 :            :     {
    7465                 :          0 :         bRetValue = sal_False;
    7466                 :            :         try
    7467                 :            :         {
    7468                 :            :             uno::Reference< beans::XPropertySetInfo >
    7469 [ #  # ][ #  # ]:          0 :                 aXPropSetInfo( rXPropSet->getPropertySetInfo() );
    7470         [ #  # ]:          0 :             if ( aXPropSetInfo.is() )
    7471 [ #  # ][ #  # ]:          0 :                 bRetValue = aXPropSetInfo->hasPropertyByName( rPropName );
         [ #  # ][ #  # ]
    7472                 :            :         }
    7473                 :          0 :         catch( const uno::Exception& )
    7474                 :            :         {
    7475                 :          0 :             bRetValue = sal_False;
    7476                 :            :         }
    7477                 :            :     }
    7478         [ #  # ]:          0 :     if ( bRetValue )
    7479                 :            :     {
    7480                 :            :         try
    7481                 :            :         {
    7482 [ #  # ][ #  # ]:          0 :             rXPropSet->setPropertyValue( rPropName, rAny );
         [ #  # ][ #  # ]
    7483                 :          0 :             bRetValue = sal_True;
    7484                 :            :         }
    7485                 :          0 :         catch( const uno::Exception& )
    7486                 :            :         {
    7487                 :          0 :             bRetValue = sal_False;
    7488                 :            :         }
    7489                 :            :     }
    7490                 :          0 :     return bRetValue;
    7491                 :            : }
    7492                 :            : 
    7493                 :        681 : SvxMSDffImportRec::SvxMSDffImportRec()
    7494                 :            :     : pObj( 0 ),
    7495                 :            :       pWrapPolygon(0),
    7496                 :            :       pClientAnchorBuffer( 0 ),
    7497                 :            :       nClientAnchorLen(  0 ),
    7498                 :            :       pClientDataBuffer( 0 ),
    7499                 :            :       nClientDataLen(    0 ),
    7500                 :            :       nXAlign( 0 ), // position n cm from left
    7501                 :            :       pXRelTo( NULL ), //   relative to column
    7502                 :            :       nYAlign( 0 ), // position n cm below
    7503                 :            :       pYRelTo( NULL ), //   relative to paragraph
    7504                 :            :       nLayoutInTableCell( 0 ), // element is laid out in table cell
    7505                 :            :       nTextRotationAngle( 0 ),
    7506                 :            :       nDxTextLeft( 144 ),
    7507                 :            :       nDyTextTop( 72 ),
    7508                 :            :       nDxTextRight( 144 ),
    7509                 :            :       nDyTextBottom( 72 ),
    7510                 :            :       nDxWrapDistLeft( 0 ),
    7511                 :            :       nDyWrapDistTop( 0 ),
    7512                 :            :       nDxWrapDistRight( 0 ),
    7513                 :            :       nDyWrapDistBottom(0 ),
    7514                 :            :       nCropFromTop( 0 ),
    7515                 :            :       nCropFromBottom( 0 ),
    7516                 :            :       nCropFromLeft( 0 ),
    7517                 :            :       nCropFromRight( 0 ),
    7518                 :            :       aTextId( 0, 0 ),
    7519                 :            :       nNextShapeId( 0 ),
    7520                 :            :       nShapeId( 0 ),
    7521                 :            :       eShapeType( mso_sptNil ),
    7522                 :            :       relativeHorizontalWidth( -1 ),
    7523                 :        681 :       isHorizontalRule( false )
    7524                 :            : {
    7525                 :        681 :       eLineStyle      = mso_lineSimple; // GPF-Bug #66227#
    7526                 :        681 :       eLineDashing    = mso_lineSolid;
    7527                 :        681 :       bDrawHell       = sal_False;
    7528                 :        681 :       bHidden         = sal_False;
    7529                 :            : 
    7530                 :        681 :       bReplaceByFly   = sal_False;
    7531                 :        681 :       bLastBoxInChain = sal_True;
    7532                 :        681 :       bHasUDefProp    = sal_False; // was the DFF_msofbtUDefProp record set?
    7533                 :        681 :       bVFlip = sal_False;
    7534                 :        681 :       bHFlip = sal_False;
    7535                 :        681 :       bAutoWidth      = sal_False;
    7536                 :        681 : }
    7537                 :            : 
    7538                 :          0 : SvxMSDffImportRec::SvxMSDffImportRec(const SvxMSDffImportRec& rCopy)
    7539                 :            :     : pObj( rCopy.pObj ),
    7540                 :            :       nXAlign( rCopy.nXAlign ),
    7541                 :            :       pXRelTo( NULL ),
    7542                 :            :       nYAlign( rCopy.nYAlign ),
    7543                 :            :       pYRelTo( NULL ),
    7544                 :            :       nLayoutInTableCell( rCopy.nLayoutInTableCell ),
    7545                 :            :       nTextRotationAngle( rCopy.nTextRotationAngle ),
    7546                 :            :       nDxTextLeft( rCopy.nDxTextLeft    ),
    7547                 :            :       nDyTextTop( rCopy.nDyTextTop ),
    7548                 :            :       nDxTextRight( rCopy.nDxTextRight ),
    7549                 :            :       nDyTextBottom( rCopy.nDyTextBottom ),
    7550                 :            :       nDxWrapDistLeft( rCopy.nDxWrapDistLeft ),
    7551                 :            :       nDyWrapDistTop( rCopy.nDyWrapDistTop ),
    7552                 :            :       nDxWrapDistRight( rCopy.nDxWrapDistRight ),
    7553                 :            :       nDyWrapDistBottom(rCopy.nDyWrapDistBottom ),
    7554                 :            :       nCropFromTop( rCopy.nCropFromTop ),
    7555                 :            :       nCropFromBottom( rCopy.nCropFromBottom ),
    7556                 :            :       nCropFromLeft( rCopy.nCropFromLeft ),
    7557                 :            :       nCropFromRight( rCopy.nCropFromRight ),
    7558                 :            :       aTextId( rCopy.aTextId ),
    7559                 :            :       nNextShapeId( rCopy.nNextShapeId ),
    7560                 :            :       nShapeId( rCopy.nShapeId ),
    7561                 :            :       eShapeType( rCopy.eShapeType ),
    7562                 :            :       relativeHorizontalWidth( rCopy.relativeHorizontalWidth ),
    7563                 :          0 :       isHorizontalRule( rCopy.isHorizontalRule )
    7564                 :            : {
    7565         [ #  # ]:          0 :     if (rCopy.pXRelTo)
    7566                 :            :     {
    7567                 :          0 :        pXRelTo = new sal_uInt32;
    7568                 :          0 :        *pXRelTo = *(rCopy.pXRelTo);
    7569                 :            :     }
    7570         [ #  # ]:          0 :     if (rCopy.pYRelTo)
    7571                 :            :     {
    7572                 :          0 :        pYRelTo = new sal_uInt32;
    7573                 :          0 :        *pYRelTo = *(rCopy.pYRelTo);
    7574                 :            :     }
    7575                 :          0 :     eLineStyle       = rCopy.eLineStyle; // GPF-Bug #66227#
    7576                 :          0 :     eLineDashing     = rCopy.eLineDashing;
    7577                 :          0 :     bDrawHell        = rCopy.bDrawHell;
    7578                 :          0 :     bHidden          = rCopy.bHidden;
    7579                 :          0 :     bReplaceByFly    = rCopy.bReplaceByFly;
    7580                 :          0 :     bAutoWidth       = rCopy.bAutoWidth;
    7581                 :          0 :     bLastBoxInChain  = rCopy.bLastBoxInChain;
    7582                 :          0 :     bHasUDefProp     = rCopy.bHasUDefProp;
    7583                 :          0 :     bVFlip = rCopy.bVFlip;
    7584                 :          0 :     bHFlip = rCopy.bHFlip;
    7585                 :          0 :     nClientAnchorLen = rCopy.nClientAnchorLen;
    7586         [ #  # ]:          0 :     if( rCopy.nClientAnchorLen )
    7587                 :            :     {
    7588                 :          0 :         pClientAnchorBuffer = new char[ nClientAnchorLen ];
    7589                 :            :         memcpy( pClientAnchorBuffer,
    7590                 :            :                 rCopy.pClientAnchorBuffer,
    7591                 :          0 :                 nClientAnchorLen );
    7592                 :            :     }
    7593                 :            :     else
    7594                 :          0 :         pClientAnchorBuffer = 0;
    7595                 :            : 
    7596                 :          0 :     nClientDataLen = rCopy.nClientDataLen;
    7597         [ #  # ]:          0 :     if( rCopy.nClientDataLen )
    7598                 :            :     {
    7599                 :          0 :         pClientDataBuffer = new char[ nClientDataLen ];
    7600                 :            :         memcpy( pClientDataBuffer,
    7601                 :            :                 rCopy.pClientDataBuffer,
    7602                 :          0 :                 nClientDataLen );
    7603                 :            :     }
    7604                 :            :     else
    7605                 :          0 :         pClientDataBuffer = 0;
    7606                 :            : 
    7607         [ #  # ]:          0 :     if (rCopy.pWrapPolygon)
    7608         [ #  # ]:          0 :         pWrapPolygon = new Polygon(*rCopy.pWrapPolygon);
    7609                 :            :     else
    7610                 :          0 :         pWrapPolygon = 0;
    7611                 :          0 : }
    7612                 :            : 
    7613                 :        681 : SvxMSDffImportRec::~SvxMSDffImportRec()
    7614                 :            : {
    7615         [ +  + ]:        681 :     if (pClientAnchorBuffer)
    7616         [ +  - ]:        168 :         delete[] pClientAnchorBuffer;
    7617         [ +  + ]:        681 :     if (pClientDataBuffer)
    7618         [ +  - ]:        519 :         delete[] pClientDataBuffer;
    7619         [ -  + ]:        681 :     if (pWrapPolygon)
    7620         [ #  # ]:          0 :         delete pWrapPolygon;
    7621         [ +  + ]:        681 :     if (pXRelTo)
    7622                 :        150 :         delete pXRelTo;
    7623         [ +  + ]:        681 :     if (pYRelTo)
    7624                 :        150 :         delete pYRelTo;
    7625                 :        681 : }
    7626                 :            : 
    7627                 :        375 : void SvxMSDffManager::insertShapeId( sal_Int32 nShapeId, SdrObject* pShape )
    7628                 :            : {
    7629                 :        375 :     maShapeIdContainer[nShapeId] = pShape;
    7630                 :        375 : }
    7631                 :            : 
    7632                 :          0 : void SvxMSDffManager::removeShapeId( SdrObject* pShape )
    7633                 :            : {
    7634                 :          0 :     SvxMSDffShapeIdContainer::iterator aIter( maShapeIdContainer.begin() );
    7635                 :          0 :     const SvxMSDffShapeIdContainer::iterator aEnd( maShapeIdContainer.end() );
    7636 [ #  # ][ #  # ]:          0 :     while( aIter != aEnd )
    7637                 :            :     {
    7638 [ #  # ][ #  # ]:          0 :         if( (*aIter).second == pShape )
    7639                 :            :         {
    7640         [ #  # ]:          0 :             maShapeIdContainer.erase( aIter );
    7641                 :          0 :             break;
    7642                 :            :         }
    7643         [ #  # ]:          0 :         ++aIter;
    7644                 :            :     }
    7645                 :          0 : }
    7646                 :            : 
    7647                 :          0 : SdrObject* SvxMSDffManager::getShapeForId( sal_Int32 nShapeId )
    7648                 :            : {
    7649         [ #  # ]:          0 :     SvxMSDffShapeIdContainer::iterator aIter( maShapeIdContainer.find(nShapeId) );
    7650 [ #  # ][ #  # ]:          0 :     return aIter != maShapeIdContainer.end() ? (*aIter).second : 0;
                 [ #  # ]
    7651                 :            : }
    7652                 :            : 
    7653                 :         74 : SvxMSDffShapeOrders::~SvxMSDffShapeOrders()
    7654                 :            : {
    7655 [ +  - ][ +  - ]:        653 :     for( const_iterator it = begin(); it != end(); ++it )
                 [ +  + ]
    7656                 :        579 :         delete *it;
    7657                 :         74 : }
    7658                 :            : 
    7659                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10