LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdoutlinercache.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 36 38 94.7 %
Date: 2014-04-11 Functions: 4 4 100.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 "svdoutlinercache.hxx"
      21             : #include <svx/svdoutl.hxx>
      22             : #include <svx/svdmodel.hxx>
      23             : 
      24             : extern SdrOutliner* SdrMakeOutliner( sal_uInt16 nOutlinerMode, SdrModel* pModel );
      25             : 
      26         460 : SdrOutlinerCache::SdrOutlinerCache( SdrModel* pModel )
      27             : :   mpModel( pModel ),
      28             :     mpModeOutline( NULL ),
      29         460 :     mpModeText( NULL )
      30             : {
      31         460 : }
      32             : 
      33       16173 : SdrOutliner* SdrOutlinerCache::createOutliner( sal_uInt16 nOutlinerMode )
      34             : {
      35       16173 :     SdrOutliner* pOutliner = NULL;
      36             : 
      37       16173 :     if( (OUTLINERMODE_OUTLINEOBJECT == nOutlinerMode) && mpModeOutline )
      38             :     {
      39           0 :         pOutliner = mpModeOutline;
      40           0 :         mpModeOutline = NULL;
      41             :     }
      42       16173 :     else if( (OUTLINERMODE_TEXTOBJECT == nOutlinerMode) && mpModeText )
      43             :     {
      44        4323 :         pOutliner = mpModeText;
      45        4323 :         mpModeText = NULL;
      46             :     }
      47             :     else
      48             :     {
      49       11850 :         pOutliner = SdrMakeOutliner( nOutlinerMode, mpModel );
      50       11850 :         Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
      51       11850 :         pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
      52             :     }
      53             : 
      54       16173 :     return pOutliner;
      55             : }
      56             : 
      57         350 : SdrOutlinerCache::~SdrOutlinerCache()
      58             : {
      59         350 :     if( mpModeOutline )
      60             :     {
      61          15 :         delete mpModeOutline;
      62          15 :         mpModeOutline = NULL;
      63             :     }
      64             : 
      65         350 :     if( mpModeText )
      66             :     {
      67         350 :         delete mpModeText;
      68         350 :         mpModeText = NULL;
      69             :     }
      70         350 : }
      71             : 
      72       14855 : void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner )
      73             : {
      74       14855 :     if( pOutliner )
      75             :     {
      76       14855 :         sal_uInt16 nOutlMode = pOutliner->GetOutlinerMode();
      77             : 
      78       14855 :         if( (OUTLINERMODE_OUTLINEOBJECT == nOutlMode) && (NULL == mpModeOutline) )
      79             :         {
      80          15 :             mpModeOutline = pOutliner;
      81          15 :             pOutliner->Clear();
      82          15 :             pOutliner->SetVertical( false );
      83             : 
      84             :             // Deregister on outliner, might be reused from outliner cache
      85          15 :             pOutliner->SetNotifyHdl( Link() );
      86             :         }
      87       14840 :         else if( (OUTLINERMODE_TEXTOBJECT == nOutlMode) && (NULL == mpModeText) )
      88             :         {
      89        4687 :             mpModeText = pOutliner;
      90        4687 :             pOutliner->Clear();
      91        4687 :             pOutliner->SetVertical( false );
      92             : 
      93             :             // Deregister on outliner, might be reused from outliner cache
      94        4687 :             pOutliner->SetNotifyHdl( Link() );
      95             :         }
      96             :         else
      97             :         {
      98       10153 :             delete pOutliner;
      99             :         }
     100             :     }
     101       14855 : }
     102             : 
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10