LibreOffice Module sc (master) 1
undoutil.cxx
Go to the documentation of this file.
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
32 SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
33 SCCOL nEndX, SCROW nEndY, SCTAB nEndZ )
34{
35 if ( pDocShell->IsPaintLocked() )
36 return;
37
39 if (!pViewShell)
40 return;
41
42 SCTAB nViewTab = pViewShell->GetViewData().GetTabNo();
43 if ( nViewTab < nStartZ || nViewTab > nEndZ )
44 pViewShell->SetTabNo( nStartZ );
45
46 const ScRange aMarkRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ);
47 pViewShell->DoneBlockMode();
48 pViewShell->MoveCursorAbs( nStartX, nStartY, SC_FOLLOW_JUMP, false, false );
49 pViewShell->InitOwnBlockMode( aMarkRange );
50 pViewShell->GetViewData().GetMarkData().SetMarkArea( aMarkRange );
51 pViewShell->MarkDataChanged();
52}
53
55 const ScAddress& rBlockStart,
56 const ScAddress& rBlockEnd )
57{
58 MarkSimpleBlock( pDocShell, rBlockStart.Col(), rBlockStart.Row(), rBlockStart.Tab(),
59 rBlockEnd.Col(), rBlockEnd.Row(), rBlockEnd.Tab() );
60}
61
63 const ScRange& rRange )
64{
65 MarkSimpleBlock( pDocShell, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
66 rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab() );
67}
68
70 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
71{
72 ScDBData* pRet = pDoc->GetDBAtArea( nTab, nCol1, nRow1, nCol2, nRow2 );
73
74 if (!pRet)
75 {
76 bool bWasTemp = false;
77 if ( pUndoData )
78 {
79 const OUString& aName = pUndoData->GetName();
81 bWasTemp = true;
82 }
83 OSL_ENSURE(bWasTemp, "Undo: didn't find database range");
84 pRet = pDoc->GetAnonymousDBData(nTab);
85 if (!pRet)
86 {
87 pRet = new ScDBData( STR_DB_LOCAL_NONAME, nTab,
88 nCol1,nRow1, nCol2,nRow2, true,
89 pDoc->HasColHeader( nCol1,nRow1,nCol2,nRow2,nTab ) );
90 pDoc->SetAnonymousDBData(nTab, std::unique_ptr<ScDBData>(pRet));
91 }
92 }
93
94 return pRet;
95}
96
98 const ScRange& rRange )
99{
100 SCCOL nCol1 = rRange.aStart.Col();
101 SCROW nRow1 = rRange.aStart.Row();
102 SCCOL nCol2 = rRange.aEnd.Col();
103 SCROW nRow2 = rRange.aEnd.Row();
104 ScDocument& rDoc = pDocShell->GetDocument();
105 if (nCol1 > 0) --nCol1;
106 if (nRow1 > 0) --nRow1;
107 if (nCol2<rDoc.MaxCol()) ++nCol2;
108 if (nRow2<rDoc.MaxRow()) ++nRow2;
109
110 pDocShell->PostPaint( nCol1,nRow1,rRange.aStart.Tab(),
111 nCol2,nRow2,rRange.aEnd.Tab(), PaintPartFlags::Grid );
112}
113
114/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SCTAB Tab() const
Definition: address.hxx:283
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
const OUString & GetName() const
Definition: dbdata.hxx:127
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:101
bool IsPaintLocked() const
Definition: docsh.hxx:326
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
SC_DLLPUBLIC const ScDBData * GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
Definition: documen3.cxx:338
SC_DLLPUBLIC bool HasColHeader(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
Definition: documen3.cxx:1526
SC_DLLPUBLIC ScDBData * GetAnonymousDBData(SCTAB nTab)
Definition: document.cxx:290
SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr< ScDBData > pDBData)
Definition: document.cxx:302
void SetMarkArea(const ScRange &rRange)
Definition: markdata.cxx:92
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
static ScTabViewShell * GetActiveViewShell()
Definition: tabvwsh4.cxx:1076
void DoneBlockMode(bool bContinue=false)
Definition: tabview2.cxx:509
SC_DLLPUBLIC void MoveCursorAbs(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, bool bShift, bool bControl, bool bKeepOld=false, bool bKeepSel=false)
Definition: tabview3.cxx:1191
ScViewData & GetViewData()
Definition: tabview.hxx:344
void MarkDataChanged()
Definition: tabview3.cxx:1767
void InitOwnBlockMode(const ScRange &rMarkRange)
Definition: tabview2.cxx:432
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1819
static void PaintMore(ScDocShell *pDocShell, const ScRange &rRange)
Definition: undoutil.cxx:97
static ScDBData * GetOldDBData(const ScDBData *pUndoData, ScDocument *pDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Search for Data base range in Document ("untitled" or by region) create new if not found.
Definition: undoutil.cxx:69
static void MarkSimpleBlock(const ScDocShell *pDocShell, SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, SCCOL nEndX, SCROW nEndY, SCTAB nEndZ)
Mark Block (invisible - has to be repainted)
Definition: undoutil.cxx:31
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3146
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
constexpr OUStringLiteral STR_DB_LOCAL_NONAME
Definition: globalnames.hxx:14
OUString aName
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
@ SC_FOLLOW_JUMP
Definition: viewdata.hxx:52