Line data Source code
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 "detdata.hxx"
21 : #include "refupdat.hxx"
22 : #include "rechead.hxx"
23 :
24 : //------------------------------------------------------------------------
25 :
26 0 : ScDetOpList::ScDetOpList(const ScDetOpList& rList) :
27 0 : bHasAddError( false )
28 : {
29 0 : size_t nCount = rList.Count();
30 :
31 0 : for (size_t i=0; i<nCount; i++)
32 0 : Append( new ScDetOpData(rList.aDetOpDataVector[i]) );
33 0 : }
34 :
35 0 : void ScDetOpList::DeleteOnTab( SCTAB nTab )
36 : {
37 0 : for (ScDetOpDataVector::iterator it = aDetOpDataVector.begin(); it != aDetOpDataVector.end(); /*noop*/ )
38 : {
39 : // look for operations on the deleted sheet
40 0 : if (it->GetPos().Tab() == nTab)
41 0 : it = aDetOpDataVector.erase( it);
42 : else
43 0 : ++it;
44 : }
45 0 : }
46 :
47 0 : void ScDetOpList::UpdateReference( ScDocument* pDoc, UpdateRefMode eUpdateRefMode,
48 : const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
49 : {
50 0 : for (ScDetOpDataVector::iterator it = aDetOpDataVector.begin(); it != aDetOpDataVector.end(); ++it )
51 : {
52 0 : ScAddress aPos = it->GetPos();
53 0 : SCCOL nCol1 = aPos.Col();
54 0 : SCROW nRow1 = aPos.Row();
55 0 : SCTAB nTab1 = aPos.Tab();
56 0 : SCCOL nCol2 = nCol1;
57 0 : SCROW nRow2 = nRow1;
58 0 : SCTAB nTab2 = nTab1;
59 :
60 : ScRefUpdateRes eRes =
61 : ScRefUpdate::Update( pDoc, eUpdateRefMode,
62 0 : rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
63 0 : rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), nDx, nDy, nDz,
64 0 : nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
65 0 : if ( eRes != UR_NOTHING )
66 0 : it->SetPos( ScAddress( nCol1, nRow1, nTab1 ) );
67 : }
68 0 : }
69 :
70 0 : void ScDetOpList::Append( ScDetOpData* pDetOpData )
71 : {
72 0 : if ( pDetOpData->GetOperation() == SCDETOP_ADDERROR )
73 0 : bHasAddError = sal_True;
74 :
75 0 : aDetOpDataVector.push_back( pDetOpData );
76 0 : }
77 :
78 :
79 0 : sal_Bool ScDetOpList::operator==( const ScDetOpList& r ) const
80 : {
81 : // for Ref-Undo
82 :
83 0 : size_t nCount = Count();
84 0 : sal_Bool bEqual = ( nCount == r.Count() );
85 0 : for (size_t i=0; i<nCount && bEqual; i++) // order has to be the same
86 0 : if ( !(aDetOpDataVector[i] == r.aDetOpDataVector[i]) ) // entries are different ?
87 0 : bEqual = false;
88 :
89 0 : return bEqual;
90 : }
91 :
92 0 : const ScDetOpData* ScDetOpList::GetObject( size_t nPos ) const
93 : {
94 0 : return &aDetOpDataVector[nPos];
95 : }
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|