1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <undoutil.hxx>
23 #include <tabvwsh.hxx>
24 #include <document.hxx>
26 #include <globalnames.hxx>
28 #include <markdata.hxx>
29 #include <osl/diagnose.h>
31 void ScUndoUtil::MarkSimpleBlock( const ScDocShell
* pDocShell
,
32 SCCOL nStartX
, SCROW nStartY
, SCTAB nStartZ
,
33 SCCOL nEndX
, SCROW nEndY
, SCTAB nEndZ
)
35 if ( pDocShell
->IsPaintLocked() )
38 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
42 SCTAB nViewTab
= pViewShell
->GetViewData().GetTabNo();
43 if ( nViewTab
< nStartZ
|| nViewTab
> nEndZ
)
44 pViewShell
->SetTabNo( nStartZ
);
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();
54 void ScUndoUtil::MarkSimpleBlock( const ScDocShell
* pDocShell
,
55 const ScAddress
& rBlockStart
,
56 const ScAddress
& rBlockEnd
)
58 MarkSimpleBlock( pDocShell
, rBlockStart
.Col(), rBlockStart
.Row(), rBlockStart
.Tab(),
59 rBlockEnd
.Col(), rBlockEnd
.Row(), rBlockEnd
.Tab() );
62 void ScUndoUtil::MarkSimpleBlock( const ScDocShell
* pDocShell
,
63 const ScRange
& rRange
)
65 MarkSimpleBlock( pDocShell
, rRange
.aStart
.Col(), rRange
.aStart
.Row(), rRange
.aStart
.Tab(),
66 rRange
.aEnd
.Col(), rRange
.aEnd
.Row(), rRange
.aEnd
.Tab() );
69 ScDBData
* ScUndoUtil::GetOldDBData( const ScDBData
* pUndoData
, ScDocument
* pDoc
, SCTAB nTab
,
70 SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
)
72 ScDBData
* pRet
= pDoc
->GetDBAtArea( nTab
, nCol1
, nRow1
, nCol2
, nRow2
);
76 bool bWasTemp
= false;
79 const OUString
& aName
= pUndoData
->GetName();
80 if ( aName
== STR_DB_LOCAL_NONAME
)
83 OSL_ENSURE(bWasTemp
, "Undo: didn't find database range");
84 pRet
= pDoc
->GetAnonymousDBData(nTab
);
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
));
97 void ScUndoUtil::PaintMore( ScDocShell
* pDocShell
,
98 const ScRange
& rRange
)
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
;
110 pDocShell
->PostPaint( nCol1
,nRow1
,rRange
.aStart
.Tab(),
111 nCol2
,nRow2
,rRange
.aEnd
.Tab(), PaintPartFlags::Grid
);
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */