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