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 
39 void 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 
62 void ScDetOpList::Append( const ScDetOpData& rDetOpData )
63 {
64  if ( rDetOpData.GetOperation() == SCDETOP_ADDERROR )
65  bHasAddError = true;
66 
67  aDetOpDataVector.push_back( rDetOpData );
68 }
69 
70 bool ScDetOpList::operator==( const ScDetOpList& r ) const
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 
83 const ScDetOpData& ScDetOpList::GetObject( size_t nPos ) const
84 {
85  return aDetOpDataVector[nPos];
86 }
87 
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScDetOpDataVector aDetOpDataVector
Definition: detdata.hxx:61
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
ScAddress aStart
Definition: address.hxx:497
SCROW Row() const
Definition: address.hxx:274
ScAddress aEnd
Definition: address.hxx:498
size_t Count() const
Definition: detdata.hxx:78
int nCount
SCTAB Tab() const
Definition: address.hxx:283
void Append(const ScDetOpData &)
Definition: detdata.cxx:62
int i
sal_Int16 SCCOL
Definition: types.hxx:21
Reference not affected, no change at all.
Definition: refupdat.hxx:31
SCCOL Col() const
Definition: address.hxx:279
bool operator==(const ScDetOpList &r) const
Definition: detdata.cxx:70
UpdateRefMode
Definition: global.hxx:298
sal_Int32 SCROW
Definition: types.hxx:17
ScDetOpType GetOperation() const
Definition: detdata.hxx:45
void DeleteOnTab(SCTAB nTab)
Definition: detdata.cxx:30
void UpdateReference(const ScDocument *pDoc, UpdateRefMode eUpdateRefMode, const ScRange &rRange, SCCOL nDx, SCROW nDy, SCTAB nDz)
Definition: detdata.cxx:39
const ScDetOpData & GetObject(size_t nPos) const
Definition: detdata.cxx:83
ScRefUpdateRes
Definition: refupdat.hxx:30
bool bHasAddError
Definition: detdata.hxx:60
sal_Int16 SCTAB
Definition: types.hxx:22
bool m_bDetectedRangeSegmentation false