1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26
27
28
29 // INCLUDE ---------------------------------------------------------------
30
31 #include <tools/debug.hxx>
32
33 #include "detdata.hxx"
34 #include "refupdat.hxx"
35 #include "rechead.hxx"
36
37 //------------------------------------------------------------------------
38
39 SV_IMPL_PTRARR( ScDetOpArr_Impl, ScDetOpDataPtr );
40
41 //------------------------------------------------------------------------
42
ScDetOpList(const ScDetOpList & rList)43 ScDetOpList::ScDetOpList(const ScDetOpList& rList) :
44 ScDetOpArr_Impl(),
45 bHasAddError( sal_False )
46 {
47 sal_uInt16 nCount = rList.Count();
48
49 for (sal_uInt16 i=0; i<nCount; i++)
50 Append( new ScDetOpData(*rList[i]) );
51 }
52
DeleteOnTab(SCTAB nTab)53 void ScDetOpList::DeleteOnTab( SCTAB nTab )
54 {
55 sal_uInt16 nPos = 0;
56 while ( nPos < Count() )
57 {
58 // look for operations on the deleted sheet
59
60 if ( (*this)[nPos]->GetPos().Tab() == nTab )
61 Remove(nPos);
62 else
63 ++nPos;
64 }
65 }
66
UpdateReference(ScDocument * pDoc,UpdateRefMode eUpdateRefMode,const ScRange & rRange,SCsCOL nDx,SCsROW nDy,SCsTAB nDz)67 void ScDetOpList::UpdateReference( ScDocument* pDoc, UpdateRefMode eUpdateRefMode,
68 const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
69 {
70 sal_uInt16 nCount = Count();
71 for (sal_uInt16 i=0; i<nCount; i++)
72 {
73 ScAddress aPos = (*this)[i]->GetPos();
74 SCCOL nCol1 = aPos.Col();
75 SCROW nRow1 = aPos.Row();
76 SCTAB nTab1 = aPos.Tab();
77 SCCOL nCol2 = nCol1;
78 SCROW nRow2 = nRow1;
79 SCTAB nTab2 = nTab1;
80
81 ScRefUpdateRes eRes =
82 ScRefUpdate::Update( pDoc, eUpdateRefMode,
83 rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
84 rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), nDx, nDy, nDz,
85 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
86 if ( eRes != UR_NOTHING )
87 (*this)[i]->SetPos( ScAddress( nCol1, nRow1, nTab1 ) );
88 }
89 }
90
Append(ScDetOpData * pDetOpData)91 void ScDetOpList::Append( ScDetOpData* pDetOpData )
92 {
93 if ( pDetOpData->GetOperation() == SCDETOP_ADDERROR )
94 bHasAddError = sal_True;
95
96 Insert( pDetOpData, Count() );
97 }
98
99
operator ==(const ScDetOpList & r) const100 sal_Bool ScDetOpList::operator==( const ScDetOpList& r ) const
101 {
102 // fuer Ref-Undo
103
104 sal_uInt16 nCount = Count();
105 sal_Bool bEqual = ( nCount == r.Count() );
106 for (sal_uInt16 i=0; i<nCount && bEqual; i++) // Reihenfolge muss auch gleich sein
107 if ( !(*(*this)[i] == *r[i]) ) // Eintraege unterschiedlich ?
108 bEqual = sal_False;
109
110 return bEqual;
111 }
112
113
114
115