1*b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b3f79822SAndrew Rist * distributed with this work for additional information 6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10*b3f79822SAndrew Rist * 11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*b3f79822SAndrew Rist * 13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b3f79822SAndrew Rist * software distributed under the License is distributed on an 15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17*b3f79822SAndrew Rist * specific language governing permissions and limitations 18*b3f79822SAndrew Rist * under the License. 19*b3f79822SAndrew Rist * 20*b3f79822SAndrew Rist *************************************************************/ 21*b3f79822SAndrew Rist 22*b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir // System - Includes ----------------------------------------------------- 28cdf0e10cSrcweir 29cdf0e10cSrcweir 30cdf0e10cSrcweir 31cdf0e10cSrcweir // INCLUDE --------------------------------------------------------------- 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include "undoutil.hxx" 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include "docsh.hxx" 36cdf0e10cSrcweir #include "tabvwsh.hxx" 37cdf0e10cSrcweir #include "document.hxx" 38cdf0e10cSrcweir #include "dbcolect.hxx" 39cdf0e10cSrcweir #include "globstr.hrc" 40cdf0e10cSrcweir #include "global.hxx" 41cdf0e10cSrcweir 42cdf0e10cSrcweir void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell, 43cdf0e10cSrcweir SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, 44cdf0e10cSrcweir SCCOL nEndX, SCROW nEndY, SCTAB nEndZ ) 45cdf0e10cSrcweir { 46cdf0e10cSrcweir if ( pDocShell->IsPaintLocked() ) 47cdf0e10cSrcweir return; 48cdf0e10cSrcweir 49cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 50cdf0e10cSrcweir if (pViewShell) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir SCTAB nViewTab = pViewShell->GetViewData()->GetTabNo(); 53cdf0e10cSrcweir if ( nViewTab < nStartZ || nViewTab > nEndZ ) 54cdf0e10cSrcweir pViewShell->SetTabNo( nStartZ ); 55cdf0e10cSrcweir 56cdf0e10cSrcweir pViewShell->DoneBlockMode(); 57cdf0e10cSrcweir pViewShell->MoveCursorAbs( nStartX, nStartY, SC_FOLLOW_JUMP, sal_False, sal_False ); 58cdf0e10cSrcweir pViewShell->InitOwnBlockMode(); 59cdf0e10cSrcweir pViewShell->GetViewData()->GetMarkData(). 60cdf0e10cSrcweir SetMarkArea( ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ) ); 61cdf0e10cSrcweir pViewShell->MarkDataChanged(); 62cdf0e10cSrcweir } 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir 66cdf0e10cSrcweir void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell, 67cdf0e10cSrcweir const ScAddress& rBlockStart, 68cdf0e10cSrcweir const ScAddress& rBlockEnd ) 69cdf0e10cSrcweir { 70cdf0e10cSrcweir MarkSimpleBlock( pDocShell, rBlockStart.Col(), rBlockStart.Row(), rBlockStart.Tab(), 71cdf0e10cSrcweir rBlockEnd.Col(), rBlockEnd.Row(), rBlockEnd.Tab() ); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir 75cdf0e10cSrcweir void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell, 76cdf0e10cSrcweir const ScRange& rRange ) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir MarkSimpleBlock( pDocShell, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(), 79cdf0e10cSrcweir rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab() ); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir 83cdf0e10cSrcweir 84cdf0e10cSrcweir ScDBData* ScUndoUtil::GetOldDBData( ScDBData* pUndoData, ScDocument* pDoc, SCTAB nTab, 85cdf0e10cSrcweir SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir ScDBData* pRet = pDoc->GetDBAtArea( nTab, nCol1, nRow1, nCol2, nRow2 ); 88cdf0e10cSrcweir 89cdf0e10cSrcweir if (!pRet) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir sal_Bool bWasTemp = sal_False; 92cdf0e10cSrcweir if ( pUndoData ) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir String aName; 95cdf0e10cSrcweir pUndoData->GetName( aName ); 96cdf0e10cSrcweir if ( aName == ScGlobal::GetRscString( STR_DB_NONAME ) ) 97cdf0e10cSrcweir bWasTemp = sal_True; 98cdf0e10cSrcweir } 99cdf0e10cSrcweir DBG_ASSERT(bWasTemp, "Undo: didn't find database range"); 100cdf0e10cSrcweir 101cdf0e10cSrcweir sal_uInt16 nIndex; 102cdf0e10cSrcweir ScDBCollection* pColl = pDoc->GetDBCollection(); 103cdf0e10cSrcweir if (pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nIndex )) 104cdf0e10cSrcweir pRet = (*pColl)[nIndex]; 105cdf0e10cSrcweir else 106cdf0e10cSrcweir { 107cdf0e10cSrcweir pRet = new ScDBData( ScGlobal::GetRscString( STR_DB_NONAME ), nTab, 108cdf0e10cSrcweir nCol1,nRow1, nCol2,nRow2, sal_True, 109cdf0e10cSrcweir pDoc->HasColHeader( nCol1,nRow1,nCol2,nRow2,nTab ) ); 110cdf0e10cSrcweir pColl->Insert( pRet ); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir return pRet; 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir 118cdf0e10cSrcweir void ScUndoUtil::PaintMore( ScDocShell* pDocShell, 119cdf0e10cSrcweir const ScRange& rRange ) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir SCCOL nCol1 = rRange.aStart.Col(); 122cdf0e10cSrcweir SCROW nRow1 = rRange.aStart.Row(); 123cdf0e10cSrcweir SCCOL nCol2 = rRange.aEnd.Col(); 124cdf0e10cSrcweir SCROW nRow2 = rRange.aEnd.Row(); 125cdf0e10cSrcweir if (nCol1 > 0) --nCol1; 126cdf0e10cSrcweir if (nRow1 > 0) --nRow1; 127cdf0e10cSrcweir if (nCol2<MAXCOL) ++nCol2; 128cdf0e10cSrcweir if (nRow2<MAXROW) ++nRow2; 129cdf0e10cSrcweir 130cdf0e10cSrcweir pDocShell->PostPaint( nCol1,nRow1,rRange.aStart.Tab(), 131cdf0e10cSrcweir nCol2,nRow2,rRange.aEnd.Tab(), PAINT_GRID ); 132cdf0e10cSrcweir } 133