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 "undoutil.hxx"
21 :
22 : #include "docsh.hxx"
23 : #include "tabvwsh.hxx"
24 : #include "document.hxx"
25 : #include "dbdata.hxx"
26 : #include "globstr.hrc"
27 : #include "globalnames.hxx"
28 : #include "global.hxx"
29 : #include "markdata.hxx"
30 :
31 0 : void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell,
32 : SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
33 : SCCOL nEndX, SCROW nEndY, SCTAB nEndZ )
34 : {
35 0 : if ( pDocShell->IsPaintLocked() )
36 0 : return;
37 :
38 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
39 0 : if (pViewShell)
40 : {
41 0 : SCTAB nViewTab = pViewShell->GetViewData()->GetTabNo();
42 0 : if ( nViewTab < nStartZ || nViewTab > nEndZ )
43 0 : pViewShell->SetTabNo( nStartZ );
44 :
45 0 : pViewShell->DoneBlockMode();
46 0 : pViewShell->MoveCursorAbs( nStartX, nStartY, SC_FOLLOW_JUMP, false, false );
47 0 : pViewShell->InitOwnBlockMode();
48 0 : pViewShell->GetViewData()->GetMarkData().
49 0 : SetMarkArea( ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ) );
50 0 : pViewShell->MarkDataChanged();
51 : }
52 : }
53 :
54 :
55 0 : void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell,
56 : const ScAddress& rBlockStart,
57 : const ScAddress& rBlockEnd )
58 : {
59 0 : MarkSimpleBlock( pDocShell, rBlockStart.Col(), rBlockStart.Row(), rBlockStart.Tab(),
60 0 : rBlockEnd.Col(), rBlockEnd.Row(), rBlockEnd.Tab() );
61 0 : }
62 :
63 :
64 0 : void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell,
65 : const ScRange& rRange )
66 : {
67 0 : MarkSimpleBlock( pDocShell, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
68 0 : rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab() );
69 0 : }
70 :
71 0 : ScDBData* ScUndoUtil::GetOldDBData( ScDBData* pUndoData, ScDocument* pDoc, SCTAB nTab,
72 : SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
73 : {
74 0 : ScDBData* pRet = pDoc->GetDBAtArea( nTab, nCol1, nRow1, nCol2, nRow2 );
75 :
76 0 : if (!pRet)
77 : {
78 0 : bool bWasTemp = false;
79 0 : if ( pUndoData )
80 : {
81 0 : const OUString& aName = pUndoData->GetName();
82 0 : if ( aName == STR_DB_LOCAL_NONAME )
83 0 : bWasTemp = true;
84 : }
85 : OSL_ENSURE(bWasTemp, "Undo: didn't find database range");
86 : (void)bWasTemp;
87 0 : pRet = pDoc->GetAnonymousDBData(nTab);
88 0 : if (!pRet)
89 : {
90 : pRet = new ScDBData( OUString(STR_DB_LOCAL_NONAME), nTab,
91 : nCol1,nRow1, nCol2,nRow2, true,
92 0 : pDoc->HasColHeader( nCol1,nRow1,nCol2,nRow2,nTab ) );
93 0 : pDoc->SetAnonymousDBData(nTab,pRet);
94 : }
95 : }
96 :
97 0 : return pRet;
98 : }
99 :
100 :
101 0 : void ScUndoUtil::PaintMore( ScDocShell* pDocShell,
102 : const ScRange& rRange )
103 : {
104 0 : SCCOL nCol1 = rRange.aStart.Col();
105 0 : SCROW nRow1 = rRange.aStart.Row();
106 0 : SCCOL nCol2 = rRange.aEnd.Col();
107 0 : SCROW nRow2 = rRange.aEnd.Row();
108 0 : if (nCol1 > 0) --nCol1;
109 0 : if (nRow1 > 0) --nRow1;
110 0 : if (nCol2<MAXCOL) ++nCol2;
111 0 : if (nRow2<MAXROW) ++nRow2;
112 :
113 0 : pDocShell->PostPaint( nCol1,nRow1,rRange.aStart.Tab(),
114 0 : nCol2,nRow2,rRange.aEnd.Tab(), PAINT_GRID );
115 0 : }
116 :
117 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|