LCOV - code coverage report
Current view: top level - libreoffice/sd/source/filter/eppt - escherex.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 138 0.0 %
Date: 2012-12-27 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 rtl::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 << (sal_uInt32)( 0xf | ( 1035 << 16 ) )     // EPP_PPDrawingGroup
      44           0 :         << (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 << (sal_uInt32)( 0xf | ( ESCHER_DggContainer << 16 ) )
      69           0 :             << (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 )
      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 << (sal_uInt32)( ( ESCHER_OPT << 16 ) | ( ESCHER_OPT_COUNT << 4 ) | 0x3 )
      97           0 :             << (sal_uInt32)( nSize - 8 )
      98           0 :             << (sal_uInt16)ESCHER_Prop_fillColor            << (sal_uInt32)0xffb800
      99           0 :             << (sal_uInt16)ESCHER_Prop_fillBackColor        << (sal_uInt32)0
     100           0 :             << (sal_uInt16)ESCHER_Prop_fNoFillHitTest       << (sal_uInt32)0x00100010
     101           0 :             << (sal_uInt16)ESCHER_Prop_lineColor            << (sal_uInt32)0x8000001
     102           0 :             << (sal_uInt16)ESCHER_Prop_fNoLineDrawDash      << (sal_uInt32)0x00080008
     103           0 :             << (sal_uInt16)ESCHER_Prop_shadowColor          << (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 )
     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 << (sal_uInt32)( ( ESCHER_SplitMenuColors << 16 ) | ( ESCHER_SPLIT_MENU_COLORS_COUNT << 4 ) )
     125           0 :             << (sal_uInt32)( nSize - 8 )
     126           0 :             << (sal_uInt32)0x08000004
     127           0 :             << (sal_uInt32)0x08000001
     128           0 :             << (sal_uInt32)0x08000002
     129           0 :             << (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 << (sal_uInt16)( ( nRecInstance << 4 ) | 0xf  ) << n_EscherContainer << (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 = sal_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 << (sal_uInt32)0     // The number of shapes in this drawing
     159           0 :                            << (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 = sal_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 << nSize;
     192             : 
     193           0 :         switch( mRecTypes.back() )
     194             :         {
     195             :             case ESCHER_DgContainer :
     196             :             {
     197           0 :                 if ( mbEscherDg )
     198             :                 {
     199           0 :                     mbEscherDg = sal_False;
     200           0 :                     if ( DoSeek( ESCHER_Persist_Dg | mnCurrentDg ) )
     201           0 :                         *mpOutStrm << mxGlobal->GetDrawingShapeCount( mnCurrentDg ) << mxGlobal->GetLastShapeId( mnCurrentDg );
     202             :                 }
     203             :             }
     204           0 :             break;
     205             : 
     206             :             case ESCHER_SpgrContainer :
     207             :             {
     208           0 :                 if ( mbEscherSpgr )
     209             :                 {
     210           0 :                     mbEscherSpgr = sal_False;
     211             : 
     212             :                 }
     213             :             }
     214           0 :             break;
     215             : 
     216             :             default:
     217           0 :             break;
     218             :         }
     219           0 :         mOffsets.pop_back();
     220           0 :         mRecTypes.pop_back();
     221           0 :         mpOutStrm->Seek( nPos );
     222             :     }
     223           0 : }
     224             : 
     225             : // ---------------------------------------------------------------------------------------------
     226             : 
     227           0 : sal_uInt32 PptEscherEx::EnterGroup( Rectangle* pBoundRect, SvMemoryStream* pClientData )
     228             : {
     229           0 :     sal_uInt32 nShapeId = 0;
     230             :     /* SJ: #Issue 26747#
     231             :        not creating group objects with a depth higher than 16, because then
     232             :        PPT is having a big performance problem when starting a slide show
     233             :     */
     234           0 :     if ( mnGroupLevel < 12 )
     235             :     {
     236           0 :         Rectangle aRect;
     237           0 :         if ( pBoundRect )
     238           0 :             aRect = *pBoundRect;
     239             : 
     240           0 :         OpenContainer( ESCHER_SpgrContainer );
     241           0 :         OpenContainer( ESCHER_SpContainer );
     242           0 :         AddAtom( 16, ESCHER_Spgr, 1 );
     243           0 :         PtReplaceOrInsert( ESCHER_Persist_Grouping_Snap | mnGroupLevel, mpOutStrm->Tell() );
     244           0 :         *mpOutStrm  << (sal_Int32)aRect.Left()  // Bounding box fuer die Gruppierten shapes an die sie attached werden
     245           0 :                     << (sal_Int32)aRect.Top()
     246           0 :                     << (sal_Int32)aRect.Right()
     247           0 :                     << (sal_Int32)aRect.Bottom();
     248             : 
     249           0 :         nShapeId = GenerateShapeId();
     250           0 :         if ( !mnGroupLevel )
     251           0 :             AddShape( ESCHER_ShpInst_Min, 5, nShapeId );                    // Flags: Group | Patriarch
     252             :         else
     253             :         {
     254           0 :             AddShape( ESCHER_ShpInst_Min, 0x201, nShapeId );                // Flags: Group | HaveAnchor
     255           0 :             if ( mnGroupLevel == 1 )
     256             :             {
     257           0 :                 AddAtom( 8, ESCHER_ClientAnchor );
     258           0 :                 PtReplaceOrInsert( ESCHER_Persist_Grouping_Logic | mnGroupLevel, mpOutStrm->Tell() );
     259           0 :                 *mpOutStrm << (sal_Int16)aRect.Top() << (sal_Int16)aRect.Left() << (sal_Int16)aRect.Right() << (sal_Int16)aRect.Bottom();
     260             :             }
     261             :             else
     262             :             {
     263           0 :                 AddAtom( 16, ESCHER_ChildAnchor );
     264           0 :                 PtReplaceOrInsert( ESCHER_Persist_Grouping_Snap | mnGroupLevel, mpOutStrm->Tell() );
     265           0 :                 *mpOutStrm  << (sal_Int32)aRect.Left()
     266           0 :                             << (sal_Int32)aRect.Top()
     267           0 :                             << (sal_Int32)aRect.Right()
     268           0 :                             << (sal_Int32)aRect.Bottom();
     269             :             }
     270             :         }
     271           0 :         if ( pClientData )
     272             :         {
     273           0 :             pClientData->Seek( STREAM_SEEK_TO_END );
     274           0 :             sal_uInt32 nSize = pClientData->Tell();
     275           0 :             if ( nSize )
     276             :             {
     277           0 :                 *mpOutStrm << (sal_uInt32)( ( ESCHER_ClientData << 16 ) | 0xf )
     278           0 :                         << nSize;
     279           0 :                 mpOutStrm->Write( pClientData->GetData(), nSize );
     280             :             }
     281             :         }
     282           0 :         CloseContainer();                                               // ESCHER_SpContainer
     283             :     }
     284           0 :     mnGroupLevel++;
     285           0 :     return nShapeId;
     286             : }
     287             : 
     288             : // ---------------------------------------------------------------------------------------------
     289             : 
     290             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10