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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "escherex.hxx"
      21             : 
      22             : 
      23             : 
      24             : 
      25             : 
      26           0 : PptEscherEx::PptEscherEx( SvStream& rOutStrm, const OUString& rBaseURI ) :
      27           0 :     EscherEx( EscherExGlobalRef( new EscherExGlobal ), &rOutStrm )
      28             : {
      29           0 :     mxGlobal->SetBaseURI( rBaseURI );
      30           0 :     mnCurrentDg = 0;
      31           0 : }
      32             : 
      33             : 
      34             : 
      35           0 : sal_uInt32 PptEscherEx::DrawingGroupContainerSize()
      36             : {
      37           0 :     return ImplDggContainerSize() + 8;
      38             : }
      39             : 
      40           0 : void PptEscherEx::WriteDrawingGroupContainer( SvStream& rSt )
      41             : {
      42           0 :     sal_uInt32 nSize = DrawingGroupContainerSize();
      43           0 :     rSt.WriteUInt32( (sal_uInt32)( 0xf | ( 1035 << 16 ) ) )     // EPP_PPDrawingGroup
      44           0 :        .WriteUInt32( (sal_uInt32)( nSize - 8 ) );
      45             : 
      46           0 :     ImplWriteDggContainer( rSt );
      47           0 : }
      48             : 
      49             : 
      50             : 
      51           0 : sal_uInt32 PptEscherEx::ImplDggContainerSize()
      52             : {
      53             :     sal_uInt32 nSize;
      54             : 
      55           0 :     nSize  = mxGlobal->GetDggAtomSize();
      56           0 :     nSize += mxGlobal->GetBlibStoreContainerSize();
      57           0 :     nSize += ImplOptAtomSize();
      58           0 :     nSize += ImplSplitMenuColorsAtomSize();
      59             : 
      60           0 :     return nSize + 8;
      61             : }
      62             : 
      63           0 : void PptEscherEx::ImplWriteDggContainer( SvStream& rSt )
      64             : {
      65           0 :     sal_uInt32 nSize = ImplDggContainerSize();
      66           0 :     if ( nSize )
      67             :     {
      68           0 :         rSt.WriteUInt32( (sal_uInt32)( 0xf | ( ESCHER_DggContainer << 16 ) ) )
      69           0 :            .WriteUInt32( (sal_uInt32)( nSize - 8 ) );
      70             : 
      71           0 :         mxGlobal->SetDggContainer();
      72           0 :         mxGlobal->WriteDggAtom( rSt );
      73           0 :         mxGlobal->WriteBlibStoreContainer( rSt );
      74           0 :         ImplWriteOptAtom( rSt );
      75           0 :         ImplWriteSplitMenuColorsAtom( rSt );
      76             :     }
      77           0 : }
      78             : 
      79             : 
      80             : 
      81             : #define ESCHER_OPT_COUNT 6
      82             : 
      83           0 : sal_uInt32 PptEscherEx::ImplOptAtomSize()
      84             : {
      85           0 :     sal_uInt32 nSize = 0;
      86             :     if ( ESCHER_OPT_COUNT != 0 )
      87           0 :         nSize = ( ESCHER_OPT_COUNT * 6 ) + 8;
      88           0 :     return nSize;
      89             : }
      90             : 
      91           0 : void PptEscherEx::ImplWriteOptAtom( SvStream& rSt )
      92             : {
      93           0 :     sal_uInt32 nSize = ImplOptAtomSize();
      94           0 :     if ( nSize )
      95             :     {
      96           0 :         rSt.WriteUInt32( (sal_uInt32)( ( ESCHER_OPT << 16 ) | ( ESCHER_OPT_COUNT << 4 ) | 0x3 ) )
      97           0 :            .WriteUInt32( (sal_uInt32)( nSize - 8 ) )
      98           0 :            .WriteUInt16( (sal_uInt16)ESCHER_Prop_fillColor )           .WriteUInt32( (sal_uInt32)0xffb800 )
      99           0 :            .WriteUInt16( (sal_uInt16)ESCHER_Prop_fillBackColor )       .WriteUInt32( (sal_uInt32)0 )
     100           0 :            .WriteUInt16( (sal_uInt16)ESCHER_Prop_fNoFillHitTest )      .WriteUInt32( (sal_uInt32)0x00100010 )
     101           0 :            .WriteUInt16( (sal_uInt16)ESCHER_Prop_lineColor )           .WriteUInt32( (sal_uInt32)0x8000001 )
     102           0 :            .WriteUInt16( (sal_uInt16)ESCHER_Prop_fNoLineDrawDash )     .WriteUInt32( (sal_uInt32)0x00080008 )
     103           0 :            .WriteUInt16( (sal_uInt16)ESCHER_Prop_shadowColor )         .WriteUInt32( (sal_uInt32)0x8000002 );
     104             :     }
     105           0 : }
     106             : 
     107             : 
     108             : 
     109             : #define ESCHER_SPLIT_MENU_COLORS_COUNT  4
     110             : 
     111           0 : sal_uInt32 PptEscherEx::ImplSplitMenuColorsAtomSize()
     112             : {
     113           0 :     sal_uInt32 nSize = 0;
     114             :     if ( ESCHER_SPLIT_MENU_COLORS_COUNT != 0 )
     115           0 :         nSize = ( ESCHER_SPLIT_MENU_COLORS_COUNT << 2 ) + 8;
     116           0 :     return nSize;
     117             : }
     118             : 
     119           0 : void PptEscherEx::ImplWriteSplitMenuColorsAtom( SvStream& rSt )
     120             : {
     121           0 :     sal_uInt32 nSize = ImplSplitMenuColorsAtomSize();
     122           0 :     if ( nSize )
     123             :     {
     124           0 :         rSt.WriteUInt32( (sal_uInt32)( ( ESCHER_SplitMenuColors << 16 ) | ( ESCHER_SPLIT_MENU_COLORS_COUNT << 4 ) ) )
     125           0 :            .WriteUInt32( (sal_uInt32)( nSize - 8 ) )
     126           0 :            .WriteUInt32( (sal_uInt32)0x08000004 )
     127           0 :            .WriteUInt32( (sal_uInt32)0x08000001 )
     128           0 :            .WriteUInt32( (sal_uInt32)0x08000002 )
     129           0 :            .WriteUInt32( (sal_uInt32)0x100000f7 );
     130             :     }
     131             : 
     132           0 : }
     133             : 
     134             : 
     135             : 
     136           0 : PptEscherEx::~PptEscherEx()
     137             : {
     138           0 : }
     139             : 
     140             : 
     141             : 
     142           0 : void PptEscherEx::OpenContainer( sal_uInt16 n_EscherContainer, int nRecInstance )
     143             : {
     144           0 :     mpOutStrm->WriteUInt16( (sal_uInt16)( ( nRecInstance << 4 ) | 0xf  ) ).WriteUInt16( n_EscherContainer ).WriteUInt32( (sal_uInt32)0 );
     145           0 :     mOffsets.push_back( mpOutStrm->Tell() - 4 );
     146           0 :     mRecTypes.push_back( n_EscherContainer );
     147             : 
     148           0 :     switch( n_EscherContainer )
     149             :     {
     150             :         case ESCHER_DgContainer :
     151             :         {
     152           0 :             if ( !mbEscherDg )
     153             :             {
     154           0 :                 mbEscherDg = true;
     155           0 :                 mnCurrentDg = mxGlobal->GenerateDrawingId();
     156           0 :                 AddAtom( 8, ESCHER_Dg, 0, mnCurrentDg );
     157           0 :                 PtReplaceOrInsert( ESCHER_Persist_Dg | mnCurrentDg, mpOutStrm->Tell() );
     158           0 :                 mpOutStrm->WriteUInt32( (sal_uInt32)0 )     // The number of shapes in this drawing
     159           0 :                           .WriteUInt32( (sal_uInt32)0 );    // The last MSOSPID given to an SP in this DG
     160             :             }
     161             :         }
     162           0 :         break;
     163             : 
     164             :         case ESCHER_SpgrContainer :
     165             :         {
     166           0 :             if ( mbEscherDg )
     167             :             {
     168           0 :                 mbEscherSpgr = true;
     169             :             }
     170             :         }
     171           0 :         break;
     172             : 
     173             :         default:
     174           0 :         break;
     175             :     }
     176           0 : }
     177             : 
     178             : 
     179             : 
     180           0 : void PptEscherEx::CloseContainer()
     181             : {
     182             :     /* SJ: #Issue 26747#
     183             :        not creating group objects with a depth higher than 16, because then
     184             :        PPT is having a big performance problem when starting a slide show
     185             :     */
     186           0 :     if ( ( mRecTypes.back() != ESCHER_SpgrContainer ) || ( mnGroupLevel < 12 ) )
     187             :     {
     188           0 :         sal_uInt32 nSize, nPos = mpOutStrm->Tell();
     189           0 :         nSize = ( nPos - mOffsets.back() ) - 4;
     190           0 :         mpOutStrm->Seek( mOffsets.back() );
     191           0 :         mpOutStrm->WriteUInt32( nSize );
     192             : 
     193           0 :         switch( mRecTypes.back() )
     194             :         {
     195             :             case ESCHER_DgContainer :
     196             :             {
     197           0 :                 if ( mbEscherDg )
     198             :                 {
     199           0 :                     mbEscherDg = false;
     200           0 :                     if ( DoSeek( ESCHER_Persist_Dg | mnCurrentDg ) )
     201           0 :                         mpOutStrm->WriteUInt32( mxGlobal->GetDrawingShapeCount( mnCurrentDg ) ).WriteUInt32( mxGlobal->GetLastShapeId( mnCurrentDg ) );
     202             :                 }
     203             :             }
     204           0 :             break;
     205             : 
     206             :             case ESCHER_SpgrContainer :
     207             :             {
     208           0 :                 if ( mbEscherSpgr )
     209             :                 {
     210           0 :                     mbEscherSpgr = false;
     211             :                 }
     212             :             }
     213           0 :             break;
     214             : 
     215             :             default:
     216           0 :             break;
     217             :         }
     218           0 :         mOffsets.pop_back();
     219           0 :         mRecTypes.pop_back();
     220           0 :         mpOutStrm->Seek( nPos );
     221             :     }
     222           0 : }
     223             : 
     224             : 
     225             : 
     226           0 : sal_uInt32 PptEscherEx::EnterGroup( Rectangle* pBoundRect, SvMemoryStream* pClientData )
     227             : {
     228           0 :     sal_uInt32 nShapeId = 0;
     229             :     /* SJ: #Issue 26747#
     230             :        not creating group objects with a depth higher than 16, because then
     231             :        PPT is having a big performance problem when starting a slide show
     232             :     */
     233           0 :     if ( mnGroupLevel < 12 )
     234             :     {
     235           0 :         Rectangle aRect;
     236           0 :         if ( pBoundRect )
     237           0 :             aRect = *pBoundRect;
     238             : 
     239           0 :         OpenContainer( ESCHER_SpgrContainer );
     240           0 :         OpenContainer( ESCHER_SpContainer );
     241           0 :         AddAtom( 16, ESCHER_Spgr, 1 );
     242           0 :         PtReplaceOrInsert( ESCHER_Persist_Grouping_Snap | mnGroupLevel, mpOutStrm->Tell() );
     243           0 :         mpOutStrm ->WriteInt32( (sal_Int32)aRect.Left() )  // bounding box for the grouped shapes to which they are attached
     244           0 :                    .WriteInt32( (sal_Int32)aRect.Top() )
     245           0 :                    .WriteInt32( (sal_Int32)aRect.Right() )
     246           0 :                    .WriteInt32( (sal_Int32)aRect.Bottom() );
     247             : 
     248           0 :         nShapeId = GenerateShapeId();
     249           0 :         if ( !mnGroupLevel )
     250           0 :             AddShape( ESCHER_ShpInst_Min, 5, nShapeId );                    // Flags: Group | Patriarch
     251             :         else
     252             :         {
     253           0 :             AddShape( ESCHER_ShpInst_Min, 0x201, nShapeId );                // Flags: Group | HaveAnchor
     254           0 :             if ( mnGroupLevel == 1 )
     255             :             {
     256           0 :                 AddAtom( 8, ESCHER_ClientAnchor );
     257           0 :                 PtReplaceOrInsert( ESCHER_Persist_Grouping_Logic | mnGroupLevel, mpOutStrm->Tell() );
     258           0 :                 mpOutStrm->WriteInt16( (sal_Int16)aRect.Top() ).WriteInt16( (sal_Int16)aRect.Left() ).WriteInt16( (sal_Int16)aRect.Right() ).WriteInt16( (sal_Int16)aRect.Bottom() );
     259             :             }
     260             :             else
     261             :             {
     262           0 :                 AddAtom( 16, ESCHER_ChildAnchor );
     263           0 :                 PtReplaceOrInsert( ESCHER_Persist_Grouping_Snap | mnGroupLevel, mpOutStrm->Tell() );
     264           0 :                 mpOutStrm ->WriteInt32( (sal_Int32)aRect.Left() )
     265           0 :                            .WriteInt32( (sal_Int32)aRect.Top() )
     266           0 :                            .WriteInt32( (sal_Int32)aRect.Right() )
     267           0 :                            .WriteInt32( (sal_Int32)aRect.Bottom() );
     268             :             }
     269             :         }
     270           0 :         if ( pClientData )
     271             :         {
     272           0 :             pClientData->Seek( STREAM_SEEK_TO_END );
     273           0 :             sal_uInt32 nSize = pClientData->Tell();
     274           0 :             if ( nSize )
     275             :             {
     276           0 :                 mpOutStrm->WriteUInt32( (sal_uInt32)( ( ESCHER_ClientData << 16 ) | 0xf ) )
     277           0 :                        .WriteUInt32( nSize );
     278           0 :                 mpOutStrm->Write( pClientData->GetData(), nSize );
     279             :             }
     280             :         }
     281           0 :         CloseContainer();                                               // ESCHER_SpContainer
     282             :     }
     283           0 :     mnGroupLevel++;
     284           0 :     return nShapeId;
     285             : }
     286             : 
     287             : 
     288             : 
     289             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10