LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdoutlinercache.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 38 38 100.0 %
Date: 2012-08-25 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 24 32 75.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 "svdoutlinercache.hxx"
      30                 :            : #include <svx/svdoutl.hxx>
      31                 :            : #include <svx/svdmodel.hxx>
      32                 :            : 
      33                 :            : extern SdrOutliner* SdrMakeOutliner( sal_uInt16 nOutlinerMode, SdrModel* pModel );
      34                 :            : 
      35                 :        155 : SdrOutlinerCache::SdrOutlinerCache( SdrModel* pModel )
      36                 :            : :   mpModel( pModel ),
      37                 :            :     mpModeOutline( NULL ),
      38                 :        155 :     mpModeText( NULL )
      39                 :            : {
      40                 :        155 : }
      41                 :            : 
      42                 :      23101 : SdrOutliner* SdrOutlinerCache::createOutliner( sal_uInt16 nOutlinerMode )
      43                 :            : {
      44                 :      23101 :     SdrOutliner* pOutliner = NULL;
      45                 :            : 
      46 [ +  + ][ +  + ]:      23101 :     if( (OUTLINERMODE_OUTLINEOBJECT == nOutlinerMode) && mpModeOutline )
      47                 :            :     {
      48                 :          2 :         pOutliner = mpModeOutline;
      49                 :          2 :         mpModeOutline = NULL;
      50                 :            :     }
      51 [ +  + ][ +  + ]:      23099 :     else if( (OUTLINERMODE_TEXTOBJECT == nOutlinerMode) && mpModeText )
      52                 :            :     {
      53                 :       6981 :         pOutliner = mpModeText;
      54                 :       6981 :         mpModeText = NULL;
      55                 :            :     }
      56                 :            :     else
      57                 :            :     {
      58                 :      16118 :         pOutliner = SdrMakeOutliner( nOutlinerMode, mpModel );
      59                 :      16118 :         Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
      60                 :      16118 :         pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
      61                 :            :     }
      62                 :            : 
      63                 :      23101 :     return pOutliner;
      64                 :            : }
      65                 :            : 
      66                 :        149 : SdrOutlinerCache::~SdrOutlinerCache()
      67                 :            : {
      68         [ +  + ]:        149 :     if( mpModeOutline )
      69                 :            :     {
      70         [ +  - ]:          2 :         delete mpModeOutline;
      71                 :          2 :         mpModeOutline = NULL;
      72                 :            :     }
      73                 :            : 
      74         [ +  - ]:        149 :     if( mpModeText )
      75                 :            :     {
      76         [ +  - ]:        149 :         delete mpModeText;
      77                 :        149 :         mpModeText = NULL;
      78                 :            :     }
      79                 :        149 : }
      80                 :            : 
      81                 :      23101 : void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner )
      82                 :            : {
      83         [ +  - ]:      23101 :     if( pOutliner )
      84                 :            :     {
      85                 :      23101 :         sal_uInt16 nOutlMode = pOutliner->GetOutlinerMode();
      86                 :            : 
      87 [ +  - ][ +  + ]:      23101 :         if( (OUTLINERMODE_OUTLINEOBJECT == nOutlMode) && (NULL == mpModeOutline) )
      88                 :            :         {
      89                 :          7 :             mpModeOutline = pOutliner;
      90                 :          7 :             pOutliner->Clear();
      91                 :          7 :             pOutliner->SetVertical( false );
      92                 :            : 
      93                 :            :             // Deregister on outliner, might be reused from outliner cache
      94         [ +  - ]:          7 :             pOutliner->SetNotifyHdl( Link() );
      95                 :            :         }
      96 [ +  + ][ +  + ]:      23094 :         else if( (OUTLINERMODE_TEXTOBJECT == nOutlMode) && (NULL == mpModeText) )
      97                 :            :         {
      98                 :       7136 :             mpModeText = pOutliner;
      99                 :       7136 :             pOutliner->Clear();
     100                 :       7136 :             pOutliner->SetVertical( false );
     101                 :            : 
     102                 :            :             // Deregister on outliner, might be reused from outliner cache
     103         [ +  - ]:       7136 :             pOutliner->SetNotifyHdl( Link() );
     104                 :            :         }
     105                 :            :         else
     106                 :            :         {
     107         [ +  - ]:      23101 :             delete pOutliner;
     108                 :            :         }
     109                 :            :     }
     110                 :      23101 : }
     111                 :            : 
     112                 :            : 
     113                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10