LCOV - code coverage report
Current view: top level - sc/source/ui/undo - undoolk.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 25 28 89.3 %
Date: 2014-11-03 Functions: 7 7 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 <svx/svdundo.hxx>
      21             : 
      22             : #include "document.hxx"
      23             : #include "drwlayer.hxx"
      24             : #include "undoolk.hxx"
      25             : 
      26         438 : SdrUndoAction* GetSdrUndoAction( ScDocument* pDoc )
      27             : {
      28         438 :     ScDrawLayer* pLayer = pDoc->GetDrawLayer();
      29         438 :     if (pLayer)
      30         344 :         return pLayer->GetCalcUndo();               // must exist
      31             :     else
      32          94 :         return NULL;
      33             : }
      34             : 
      35          86 : void DoSdrUndoAction( SdrUndoAction* pUndoAction, ScDocument* pDoc )
      36             : {
      37          86 :     if ( pUndoAction )
      38           2 :         pUndoAction->Undo();
      39             :     else
      40             :     {
      41             :         // if no drawing layer existed when the action was created,
      42             :         // but it was created after that, there is no draw undo action,
      43             :         // and after undo there might be a drawing layer with a wrong page count.
      44             :         // The drawing layer must have been empty in that case, so any missing
      45             :         // pages can just be created now.
      46             : 
      47          84 :         ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
      48          84 :         if ( pDrawLayer )
      49             :         {
      50           4 :             SCTAB nTabCount = pDoc->GetTableCount();
      51           4 :             SCTAB nPages = static_cast<SCTAB>(pDrawLayer->GetPageCount());
      52           8 :             while ( nPages < nTabCount )
      53             :             {
      54           0 :                 pDrawLayer->ScAddPage( nPages );
      55           0 :                 ++nPages;
      56             :             }
      57             :         }
      58             :     }
      59          86 : }
      60             : 
      61          16 : void RedoSdrUndoAction( SdrUndoAction* pUndoAction )
      62             : {
      63             :     // DoSdrUndoAction/RedoSdrUndoAction is called even if the pointer is null
      64          16 :     if ( pUndoAction )
      65           0 :         pUndoAction->Redo();
      66          16 : }
      67             : 
      68         630 : void DeleteSdrUndoAction( SdrUndoAction* pUndoAction )
      69             : {
      70         630 :     delete pUndoAction;
      71         630 : }
      72             : 
      73         184 : void EnableDrawAdjust( ScDocument* pDoc, bool bEnable )
      74             : {
      75         184 :     ScDrawLayer* pLayer = pDoc->GetDrawLayer();
      76         184 :     if (pLayer)
      77          16 :         pLayer->EnableAdjust(bEnable);
      78         412 : }
      79             : 
      80             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10