LibreOffice Module sc (master) 1
detdata.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 <algorithm>
21#include <detdata.hxx>
22#include <refupdat.hxx>
23
25 bHasAddError( false ),
26 aDetOpDataVector( rList.aDetOpDataVector )
27{
28}
29
31{
32 aDetOpDataVector.erase(std::remove_if(aDetOpDataVector.begin(), aDetOpDataVector.end(),
33 [&nTab](const ScDetOpData& rxDetOpData) {
34 return rxDetOpData.GetPos().Tab() == nTab; // look for operations on the deleted sheet
35 }),
36 aDetOpDataVector.end());
37}
38
39void ScDetOpList::UpdateReference( const ScDocument* pDoc, UpdateRefMode eUpdateRefMode,
40 const ScRange& rRange, SCCOL nDx, SCROW nDy, SCTAB nDz )
41{
42 for (auto& rxDetOpData : aDetOpDataVector )
43 {
44 ScAddress aPos = rxDetOpData.GetPos();
45 SCCOL nCol1 = aPos.Col();
46 SCROW nRow1 = aPos.Row();
47 SCTAB nTab1 = aPos.Tab();
48 SCCOL nCol2 = nCol1;
49 SCROW nRow2 = nRow1;
50 SCTAB nTab2 = nTab1;
51
52 ScRefUpdateRes eRes =
53 ScRefUpdate::Update( pDoc, eUpdateRefMode,
54 rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
55 rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), nDx, nDy, nDz,
56 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
57 if ( eRes != UR_NOTHING )
58 rxDetOpData.SetPos( ScAddress( nCol1, nRow1, nTab1 ) );
59 }
60}
61
62void ScDetOpList::Append( const ScDetOpData& rDetOpData )
63{
64 if ( rDetOpData.GetOperation() == SCDETOP_ADDERROR )
65 bHasAddError = true;
66
67 aDetOpDataVector.push_back( rDetOpData );
68}
69
71{
72 // for Ref-Undo
73
74 size_t nCount = Count();
75 bool bEqual = ( nCount == r.Count() );
76 for (size_t i=0; i<nCount && bEqual; i++) // order has to be the same
77 if ( !(aDetOpDataVector[i] == r.aDetOpDataVector[i]) ) // entries are different ?
78 bEqual = false;
79
80 return bEqual;
81}
82
83const ScDetOpData& ScDetOpList::GetObject( size_t nPos ) const
84{
85 return aDetOpDataVector[nPos];
86}
87
88/* 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
ScDetOpType GetOperation() const
Definition: detdata.hxx:45
void UpdateReference(const ScDocument *pDoc, UpdateRefMode eUpdateRefMode, const ScRange &rRange, SCCOL nDx, SCROW nDy, SCTAB nDz)
Definition: detdata.cxx:39
bool bHasAddError
Definition: detdata.hxx:60
size_t Count() const
Definition: detdata.hxx:78
void DeleteOnTab(SCTAB nTab)
Definition: detdata.cxx:30
bool operator==(const ScDetOpList &r) const
Definition: detdata.cxx:70
const ScDetOpData & GetObject(size_t nPos) const
Definition: detdata.cxx:83
ScDetOpDataVector aDetOpDataVector
Definition: detdata.hxx:61
void Append(const ScDetOpData &)
Definition: detdata.cxx:62
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
static ScRefUpdateRes Update(const ScDocument *pDoc, UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCCOL nDx, SCROW nDy, SCTAB nDz, SCCOL &theCol1, SCROW &theRow1, SCTAB &theTab1, SCCOL &theCol2, SCROW &theRow2, SCTAB &theTab2)
Definition: refupdat.cxx:188
int nCount
@ SCDETOP_ADDERROR
Definition: detdata.hxx:32
UpdateRefMode
Definition: global.hxx:300
sal_uInt16 nPos
int i
ScRefUpdateRes
Definition: refupdat.hxx:30
@ UR_NOTHING
Reference not affected, no change at all.
Definition: refupdat.hxx:31
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17