merge the formfield patch from ooo-build
[ooovba.git] / sc / source / core / tool / detdata.cxx
blob4838e15901c2aeea315155bb7c0628d74f31ffec
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: detdata.cxx,v $
10 * $Revision: 1.8.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include <tools/debug.hxx>
40 #include "detdata.hxx"
41 #include "refupdat.hxx"
42 #include "rechead.hxx"
44 //------------------------------------------------------------------------
46 SV_IMPL_PTRARR( ScDetOpArr_Impl, ScDetOpDataPtr );
48 //------------------------------------------------------------------------
50 ScDetOpList::ScDetOpList(const ScDetOpList& rList) :
51 ScDetOpArr_Impl(),
52 bHasAddError( FALSE )
54 USHORT nCount = rList.Count();
56 for (USHORT i=0; i<nCount; i++)
57 Append( new ScDetOpData(*rList[i]) );
60 void ScDetOpList::DeleteOnTab( SCTAB nTab )
62 USHORT nPos = 0;
63 while ( nPos < Count() )
65 // look for operations on the deleted sheet
67 if ( (*this)[nPos]->GetPos().Tab() == nTab )
68 Remove(nPos);
69 else
70 ++nPos;
74 void ScDetOpList::UpdateReference( ScDocument* pDoc, UpdateRefMode eUpdateRefMode,
75 const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
77 USHORT nCount = Count();
78 for (USHORT i=0; i<nCount; i++)
80 ScAddress aPos = (*this)[i]->GetPos();
81 SCCOL nCol1 = aPos.Col();
82 SCROW nRow1 = aPos.Row();
83 SCTAB nTab1 = aPos.Tab();
84 SCCOL nCol2 = nCol1;
85 SCROW nRow2 = nRow1;
86 SCTAB nTab2 = nTab1;
88 ScRefUpdateRes eRes =
89 ScRefUpdate::Update( pDoc, eUpdateRefMode,
90 rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
91 rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), nDx, nDy, nDz,
92 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
93 if ( eRes != UR_NOTHING )
94 (*this)[i]->SetPos( ScAddress( nCol1, nRow1, nTab1 ) );
98 void ScDetOpList::Append( ScDetOpData* pDetOpData )
100 if ( pDetOpData->GetOperation() == SCDETOP_ADDERROR )
101 bHasAddError = TRUE;
103 Insert( pDetOpData, Count() );
107 BOOL ScDetOpList::operator==( const ScDetOpList& r ) const
109 // fuer Ref-Undo
111 USHORT nCount = Count();
112 BOOL bEqual = ( nCount == r.Count() );
113 for (USHORT i=0; i<nCount && bEqual; i++) // Reihenfolge muss auch gleich sein
114 if ( !(*(*this)[i] == *r[i]) ) // Eintraege unterschiedlich ?
115 bEqual = FALSE;
117 return bEqual;