LCOV - code coverage report
Current view: top level - sd/source/filter/eppt - escherex.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 138 0.0 %
Date: 2012-08-25 Functions: 0 14 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 108 0.0 %

           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                 :            : #include "escherex.hxx"
      30                 :            : 
      31                 :            : // ---------------------------------------------------------------------------------------------
      32                 :            : // ---------------------------------------------------------------------------------------------
      33                 :            : // ---------------------------------------------------------------------------------------------
      34                 :            : 
      35                 :          0 : PptEscherEx::PptEscherEx( SvStream& rOutStrm, const rtl::OUString& rBaseURI ) :
      36 [ #  # ][ #  # ]:          0 :     EscherEx( EscherExGlobalRef( new EscherExGlobal ), &rOutStrm )
      37                 :            : {
      38                 :          0 :     mxGlobal->SetBaseURI( rBaseURI );
      39                 :          0 :     mnCurrentDg = 0;
      40                 :          0 : }
      41                 :            : 
      42                 :            : // ---------------------------------------------------------------------------------------------
      43                 :            : 
      44                 :          0 : sal_uInt32 PptEscherEx::DrawingGroupContainerSize()
      45                 :            : {
      46                 :          0 :     return ImplDggContainerSize() + 8;
      47                 :            : }
      48                 :            : 
      49                 :          0 : void PptEscherEx::WriteDrawingGroupContainer( SvStream& rSt )
      50                 :            : {
      51                 :          0 :     sal_uInt32 nSize = DrawingGroupContainerSize();
      52                 :          0 :     rSt << (sal_uInt32)( 0xf | ( 1035 << 16 ) )     // EPP_PPDrawingGroup
      53                 :          0 :         << (sal_uInt32)( nSize - 8 );
      54                 :            : 
      55                 :          0 :     ImplWriteDggContainer( rSt );
      56                 :          0 : }
      57                 :            : 
      58                 :            : // ---------------------------------------------------------------------------------------------
      59                 :            : 
      60                 :          0 : sal_uInt32 PptEscherEx::ImplDggContainerSize()
      61                 :            : {
      62                 :            :     sal_uInt32 nSize;
      63                 :            : 
      64                 :          0 :     nSize  = mxGlobal->GetDggAtomSize();
      65                 :          0 :     nSize += mxGlobal->GetBlibStoreContainerSize();
      66                 :          0 :     nSize += ImplOptAtomSize();
      67                 :          0 :     nSize += ImplSplitMenuColorsAtomSize();
      68                 :            : 
      69                 :          0 :     return nSize + 8;
      70                 :            : }
      71                 :            : 
      72                 :          0 : void PptEscherEx::ImplWriteDggContainer( SvStream& rSt )
      73                 :            : {
      74                 :          0 :     sal_uInt32 nSize = ImplDggContainerSize();
      75         [ #  # ]:          0 :     if ( nSize )
      76                 :            :     {
      77                 :          0 :         rSt << (sal_uInt32)( 0xf | ( ESCHER_DggContainer << 16 ) )
      78                 :          0 :             << (sal_uInt32)( nSize - 8 );
      79                 :            : 
      80                 :          0 :         mxGlobal->SetDggContainer();
      81                 :          0 :         mxGlobal->WriteDggAtom( rSt );
      82                 :          0 :         mxGlobal->WriteBlibStoreContainer( rSt );
      83                 :          0 :         ImplWriteOptAtom( rSt );
      84                 :          0 :         ImplWriteSplitMenuColorsAtom( rSt );
      85                 :            :     }
      86                 :          0 : }
      87                 :            : 
      88                 :            : // ---------------------------------------------------------------------------------------------
      89                 :            : 
      90                 :            : #define ESCHER_OPT_COUNT 6
      91                 :            : 
      92                 :          0 : sal_uInt32 PptEscherEx::ImplOptAtomSize()
      93                 :            : {
      94                 :          0 :     sal_uInt32 nSize = 0;
      95                 :            :     if ( ESCHER_OPT_COUNT )
      96                 :          0 :         nSize = ( ESCHER_OPT_COUNT * 6 ) + 8;
      97                 :          0 :     return nSize;
      98                 :            : }
      99                 :            : 
     100                 :          0 : void PptEscherEx::ImplWriteOptAtom( SvStream& rSt )
     101                 :            : {
     102                 :          0 :     sal_uInt32 nSize = ImplOptAtomSize();
     103         [ #  # ]:          0 :     if ( nSize )
     104                 :            :     {
     105                 :          0 :         rSt << (sal_uInt32)( ( ESCHER_OPT << 16 ) | ( ESCHER_OPT_COUNT << 4 ) | 0x3 )
     106                 :          0 :             << (sal_uInt32)( nSize - 8 )
     107                 :          0 :             << (sal_uInt16)ESCHER_Prop_fillColor            << (sal_uInt32)0xffb800
     108                 :          0 :             << (sal_uInt16)ESCHER_Prop_fillBackColor        << (sal_uInt32)0
     109                 :          0 :             << (sal_uInt16)ESCHER_Prop_fNoFillHitTest       << (sal_uInt32)0x00100010
     110                 :          0 :             << (sal_uInt16)ESCHER_Prop_lineColor            << (sal_uInt32)0x8000001
     111                 :          0 :             << (sal_uInt16)ESCHER_Prop_fNoLineDrawDash      << (sal_uInt32)0x00080008
     112                 :          0 :             << (sal_uInt16)ESCHER_Prop_shadowColor          << (sal_uInt32)0x8000002;
     113                 :            :     }
     114                 :          0 : }
     115                 :            : 
     116                 :            : // ---------------------------------------------------------------------------------------------
     117                 :            : 
     118                 :            : #define ESCHER_SPLIT_MENU_COLORS_COUNT  4
     119                 :            : 
     120                 :          0 : sal_uInt32 PptEscherEx::ImplSplitMenuColorsAtomSize()
     121                 :            : {
     122                 :          0 :     sal_uInt32 nSize = 0;
     123                 :            :     if ( ESCHER_SPLIT_MENU_COLORS_COUNT )
     124                 :          0 :         nSize = ( ESCHER_SPLIT_MENU_COLORS_COUNT << 2 ) + 8;
     125                 :          0 :     return nSize;
     126                 :            : }
     127                 :            : 
     128                 :          0 : void PptEscherEx::ImplWriteSplitMenuColorsAtom( SvStream& rSt )
     129                 :            : {
     130                 :          0 :     sal_uInt32 nSize = ImplSplitMenuColorsAtomSize();
     131         [ #  # ]:          0 :     if ( nSize )
     132                 :            :     {
     133                 :          0 :         rSt << (sal_uInt32)( ( ESCHER_SplitMenuColors << 16 ) | ( ESCHER_SPLIT_MENU_COLORS_COUNT << 4 ) )
     134                 :          0 :             << (sal_uInt32)( nSize - 8 )
     135                 :          0 :             << (sal_uInt32)0x08000004
     136                 :          0 :             << (sal_uInt32)0x08000001
     137                 :          0 :             << (sal_uInt32)0x08000002
     138                 :          0 :             << (sal_uInt32)0x100000f7;
     139                 :            :     }
     140                 :            : 
     141                 :          0 : }
     142                 :            : 
     143                 :            : // ---------------------------------------------------------------------------------------------
     144                 :            : 
     145                 :          0 : PptEscherEx::~PptEscherEx()
     146                 :            : {
     147         [ #  # ]:          0 : }
     148                 :            : 
     149                 :            : // ---------------------------------------------------------------------------------------------
     150                 :            : 
     151                 :          0 : void PptEscherEx::OpenContainer( sal_uInt16 n_EscherContainer, int nRecInstance )
     152                 :            : {
     153                 :          0 :     *mpOutStrm << (sal_uInt16)( ( nRecInstance << 4 ) | 0xf  ) << n_EscherContainer << (sal_uInt32)0;
     154         [ #  # ]:          0 :     mOffsets.push_back( mpOutStrm->Tell() - 4 );
     155                 :          0 :     mRecTypes.push_back( n_EscherContainer );
     156                 :            : 
     157      [ #  #  # ]:          0 :     switch( n_EscherContainer )
     158                 :            :     {
     159                 :            :         case ESCHER_DgContainer :
     160                 :            :         {
     161         [ #  # ]:          0 :             if ( !mbEscherDg )
     162                 :            :             {
     163                 :          0 :                 mbEscherDg = sal_True;
     164                 :          0 :                 mnCurrentDg = mxGlobal->GenerateDrawingId();
     165                 :          0 :                 AddAtom( 8, ESCHER_Dg, 0, mnCurrentDg );
     166                 :          0 :                 PtReplaceOrInsert( ESCHER_Persist_Dg | mnCurrentDg, mpOutStrm->Tell() );
     167                 :          0 :                 *mpOutStrm << (sal_uInt32)0     // The number of shapes in this drawing
     168                 :          0 :                            << (sal_uInt32)0;    // The last MSOSPID given to an SP in this DG
     169                 :            :             }
     170                 :            :         }
     171                 :          0 :         break;
     172                 :            : 
     173                 :            :         case ESCHER_SpgrContainer :
     174                 :            :         {
     175         [ #  # ]:          0 :             if ( mbEscherDg )
     176                 :            :             {
     177                 :          0 :                 mbEscherSpgr = sal_True;
     178                 :            :             }
     179                 :            :         }
     180                 :          0 :         break;
     181                 :            : 
     182                 :            :         default:
     183                 :          0 :         break;
     184                 :            :     }
     185                 :          0 : }
     186                 :            : 
     187                 :            : // ---------------------------------------------------------------------------------------------
     188                 :            : 
     189                 :          0 : void PptEscherEx::CloseContainer()
     190                 :            : {
     191                 :            :     /* SJ: #Issue 26747#
     192                 :            :        not creating group objects with a depth higher than 16, because then
     193                 :            :        PPT is having a big performance problem when starting a slide show
     194                 :            :     */
     195 [ #  # ][ #  # ]:          0 :     if ( ( mRecTypes.back() != ESCHER_SpgrContainer ) || ( mnGroupLevel < 12 ) )
                 [ #  # ]
     196                 :            :     {
     197                 :          0 :         sal_uInt32 nSize, nPos = mpOutStrm->Tell();
     198                 :          0 :         nSize = ( nPos - mOffsets.back() ) - 4;
     199                 :          0 :         mpOutStrm->Seek( mOffsets.back() );
     200                 :          0 :         *mpOutStrm << nSize;
     201                 :            : 
     202      [ #  #  # ]:          0 :         switch( mRecTypes.back() )
     203                 :            :         {
     204                 :            :             case ESCHER_DgContainer :
     205                 :            :             {
     206         [ #  # ]:          0 :                 if ( mbEscherDg )
     207                 :            :                 {
     208                 :          0 :                     mbEscherDg = sal_False;
     209         [ #  # ]:          0 :                     if ( DoSeek( ESCHER_Persist_Dg | mnCurrentDg ) )
     210                 :          0 :                         *mpOutStrm << mxGlobal->GetDrawingShapeCount( mnCurrentDg ) << mxGlobal->GetLastShapeId( mnCurrentDg );
     211                 :            :                 }
     212                 :            :             }
     213                 :          0 :             break;
     214                 :            : 
     215                 :            :             case ESCHER_SpgrContainer :
     216                 :            :             {
     217         [ #  # ]:          0 :                 if ( mbEscherSpgr )
     218                 :            :                 {
     219                 :          0 :                     mbEscherSpgr = sal_False;
     220                 :            : 
     221                 :            :                 }
     222                 :            :             }
     223                 :          0 :             break;
     224                 :            : 
     225                 :            :             default:
     226                 :          0 :             break;
     227                 :            :         }
     228                 :          0 :         mOffsets.pop_back();
     229                 :          0 :         mRecTypes.pop_back();
     230                 :          0 :         mpOutStrm->Seek( nPos );
     231                 :            :     }
     232                 :          0 : }
     233                 :            : 
     234                 :            : // ---------------------------------------------------------------------------------------------
     235                 :            : 
     236                 :          0 : sal_uInt32 PptEscherEx::EnterGroup( Rectangle* pBoundRect, SvMemoryStream* pClientData )
     237                 :            : {
     238                 :          0 :     sal_uInt32 nShapeId = 0;
     239                 :            :     /* SJ: #Issue 26747#
     240                 :            :        not creating group objects with a depth higher than 16, because then
     241                 :            :        PPT is having a big performance problem when starting a slide show
     242                 :            :     */
     243         [ #  # ]:          0 :     if ( mnGroupLevel < 12 )
     244                 :            :     {
     245         [ #  # ]:          0 :         Rectangle aRect;
     246         [ #  # ]:          0 :         if ( pBoundRect )
     247                 :          0 :             aRect = *pBoundRect;
     248                 :            : 
     249         [ #  # ]:          0 :         OpenContainer( ESCHER_SpgrContainer );
     250         [ #  # ]:          0 :         OpenContainer( ESCHER_SpContainer );
     251         [ #  # ]:          0 :         AddAtom( 16, ESCHER_Spgr, 1 );
     252         [ #  # ]:          0 :         PtReplaceOrInsert( ESCHER_Persist_Grouping_Snap | mnGroupLevel, mpOutStrm->Tell() );
     253         [ #  # ]:          0 :         *mpOutStrm  << (sal_Int32)aRect.Left()  // Bounding box fuer die Gruppierten shapes an die sie attached werden
     254         [ #  # ]:          0 :                     << (sal_Int32)aRect.Top()
     255         [ #  # ]:          0 :                     << (sal_Int32)aRect.Right()
     256         [ #  # ]:          0 :                     << (sal_Int32)aRect.Bottom();
     257                 :            : 
     258         [ #  # ]:          0 :         nShapeId = GenerateShapeId();
     259         [ #  # ]:          0 :         if ( !mnGroupLevel )
     260         [ #  # ]:          0 :             AddShape( ESCHER_ShpInst_Min, 5, nShapeId );                    // Flags: Group | Patriarch
     261                 :            :         else
     262                 :            :         {
     263         [ #  # ]:          0 :             AddShape( ESCHER_ShpInst_Min, 0x201, nShapeId );                // Flags: Group | HaveAnchor
     264         [ #  # ]:          0 :             if ( mnGroupLevel == 1 )
     265                 :            :             {
     266         [ #  # ]:          0 :                 AddAtom( 8, ESCHER_ClientAnchor );
     267         [ #  # ]:          0 :                 PtReplaceOrInsert( ESCHER_Persist_Grouping_Logic | mnGroupLevel, mpOutStrm->Tell() );
     268 [ #  # ][ #  # ]:          0 :                 *mpOutStrm << (sal_Int16)aRect.Top() << (sal_Int16)aRect.Left() << (sal_Int16)aRect.Right() << (sal_Int16)aRect.Bottom();
         [ #  # ][ #  # ]
     269                 :            :             }
     270                 :            :             else
     271                 :            :             {
     272         [ #  # ]:          0 :                 AddAtom( 16, ESCHER_ChildAnchor );
     273         [ #  # ]:          0 :                 PtReplaceOrInsert( ESCHER_Persist_Grouping_Snap | mnGroupLevel, mpOutStrm->Tell() );
     274         [ #  # ]:          0 :                 *mpOutStrm  << (sal_Int32)aRect.Left()
     275         [ #  # ]:          0 :                             << (sal_Int32)aRect.Top()
     276         [ #  # ]:          0 :                             << (sal_Int32)aRect.Right()
     277         [ #  # ]:          0 :                             << (sal_Int32)aRect.Bottom();
     278                 :            :             }
     279                 :            :         }
     280         [ #  # ]:          0 :         if ( pClientData )
     281                 :            :         {
     282         [ #  # ]:          0 :             pClientData->Seek( STREAM_SEEK_TO_END );
     283                 :          0 :             sal_uInt32 nSize = pClientData->Tell();
     284         [ #  # ]:          0 :             if ( nSize )
     285                 :            :             {
     286         [ #  # ]:          0 :                 *mpOutStrm << (sal_uInt32)( ( ESCHER_ClientData << 16 ) | 0xf )
     287         [ #  # ]:          0 :                         << nSize;
     288 [ #  # ][ #  # ]:          0 :                 mpOutStrm->Write( pClientData->GetData(), nSize );
     289                 :            :             }
     290                 :            :         }
     291         [ #  # ]:          0 :         CloseContainer();                                               // ESCHER_SpContainer
     292                 :            :     }
     293                 :          0 :     mnGroupLevel++;
     294                 :          0 :     return nShapeId;
     295                 :            : }
     296                 :            : 
     297                 :            : // ---------------------------------------------------------------------------------------------
     298                 :            : 
     299                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10