1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sc.hxx" 26 27 28 29 // INCLUDE --------------------------------------------------------------- 30 31 #include <svx/svdundo.hxx> 32 33 #include "document.hxx" 34 #include "drwlayer.hxx" 35 36 37 // STATIC DATA ----------------------------------------------------------- 38 39 // ----------------------------------------------------------------------- 40 41 SdrUndoAction* GetSdrUndoAction( ScDocument* pDoc ) 42 { 43 ScDrawLayer* pLayer = pDoc->GetDrawLayer(); 44 if (pLayer) 45 return pLayer->GetCalcUndo(); // muss vorhanden sein 46 else 47 return NULL; 48 } 49 50 void DoSdrUndoAction( SdrUndoAction* pUndoAction, ScDocument* pDoc ) 51 { 52 if ( pUndoAction ) 53 pUndoAction->Undo(); 54 else 55 { 56 // #125875# if no drawing layer existed when the action was created, 57 // but it was created after that, there is no draw undo action, 58 // and after undo there might be a drawing layer with a wrong page count. 59 // The drawing layer must have been empty in that case, so any missing 60 // pages can just be created now. 61 62 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); 63 if ( pDrawLayer ) 64 { 65 SCTAB nTabCount = pDoc->GetTableCount(); 66 SCTAB nPages = static_cast<SCTAB>(pDrawLayer->GetPageCount()); 67 while ( nPages < nTabCount ) 68 { 69 pDrawLayer->ScAddPage( nPages ); 70 ++nPages; 71 } 72 } 73 } 74 } 75 76 77 void RedoSdrUndoAction( SdrUndoAction* pUndoAction ) 78 { 79 // #125875# DoSdrUndoAction/RedoSdrUndoAction is called even if the pointer is null 80 81 if ( pUndoAction ) 82 pUndoAction->Redo(); 83 } 84 85 void DeleteSdrUndoAction( SdrUndoAction* pUndoAction ) 86 { 87 delete pUndoAction; 88 } 89 90 void EnableDrawAdjust( ScDocument* pDoc, sal_Bool bEnable ) 91 { 92 ScDrawLayer* pLayer = pDoc->GetDrawLayer(); 93 if (pLayer) 94 pLayer->EnableAdjust(bEnable); 95 } 96 97 98 99