Update ooo320-m1
[ooovba.git] / sw / source / core / bastyp / tabcol.cxx
blobaa9da2df61bb4fb35d7fa0fd66825a5f1cbdc8b4
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: tabcol.cxx,v $
10 * $Revision: 1.9 $
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_sw.hxx"
36 #include "tabcol.hxx"
37 #include <errhdl.hxx> // fuer Create-Methoden
40 SwTabCols::SwTabCols( USHORT nSize ) :
41 nLeftMin( 0 ),
42 nLeft( 0 ),
43 nRight( 0 ),
44 nRightMax( 0 ),
45 bLastRowAllowedToChange( true )
47 if ( nSize )
48 aData.reserve( nSize );
51 SwTabCols::SwTabCols( const SwTabCols& rCpy ) :
52 nLeftMin( rCpy.GetLeftMin() ),
53 nLeft( rCpy.GetLeft() ),
54 nRight( rCpy.GetRight() ),
55 nRightMax( rCpy.GetRightMax() ),
56 bLastRowAllowedToChange( rCpy.IsLastRowAllowedToChange() ),
57 aData( rCpy.GetData() )
59 #if OSL_DEBUG_LEVEL > 1
60 for ( USHORT i = 0; i < Count(); ++i )
62 SwTabColsEntry aEntry1 = aData[i];
63 SwTabColsEntry aEntry2 = rCpy.GetData()[i];
64 (void) aEntry1;
65 (void) aEntry2;
66 ASSERT( aEntry1.nPos == aEntry2.nPos &&
67 aEntry1.nMin == aEntry2.nMin &&
68 aEntry1.nMax == aEntry2.nMax &&
69 aEntry1.bHidden == aEntry2.bHidden,
70 "CopyContructor of SwTabColsEntries did not succeed!" )
72 #endif
75 SwTabCols &SwTabCols::operator=( const SwTabCols& rCpy )
77 nLeftMin = rCpy.GetLeftMin();
78 nLeft = rCpy.GetLeft();
79 nRight = rCpy.GetRight();
80 nRightMax= rCpy.GetRightMax();
81 bLastRowAllowedToChange = rCpy.IsLastRowAllowedToChange();
83 Remove( 0, Count() );
84 aData = rCpy.GetData();
86 return *this;
89 BOOL SwTabCols::operator==( const SwTabCols& rCmp ) const
91 USHORT i;
93 if ( !(nLeftMin == rCmp.GetLeftMin() &&
94 nLeft == rCmp.GetLeft() &&
95 nRight == rCmp.GetRight() &&
96 nRightMax== rCmp.GetRightMax()&&
97 bLastRowAllowedToChange== rCmp.IsLastRowAllowedToChange() &&
98 Count()== rCmp.Count()) )
99 return FALSE;
101 for ( i = 0; i < Count(); ++i )
103 SwTabColsEntry aEntry1 = aData[i];
104 SwTabColsEntry aEntry2 = rCmp.GetData()[i];
105 if ( aEntry1.nPos != aEntry2.nPos || aEntry1.bHidden != aEntry2.bHidden )
106 return FALSE;
109 return TRUE;
112 void SwTabCols::Insert( long nValue, long nMin, long nMax, BOOL bValue, USHORT nPos )
114 SwTabColsEntry aEntry;
115 aEntry.nPos = nValue;
116 aEntry.nMin = nMin;
117 aEntry.nMax = nMax;
118 aEntry.bHidden = bValue;
119 aData.insert( aData.begin() + nPos, aEntry );
122 void SwTabCols::Insert( long nValue, BOOL bValue, USHORT nPos )
124 SwTabColsEntry aEntry;
125 aEntry.nPos = nValue;
126 aEntry.nMin = 0;
127 aEntry.nMax = LONG_MAX;
128 aEntry.bHidden = bValue;
129 aData.insert( aData.begin() + nPos, aEntry );
131 #if OSL_DEBUG_LEVEL > 1
132 SwTabColsEntries::iterator aPos = aData.begin();
133 for ( ; aPos != aData.end(); ++aPos )
135 aEntry =(*aPos);
137 #endif
140 void SwTabCols::Remove( USHORT nPos, USHORT nAnz )
142 SwTabColsEntries::iterator aStart = aData.begin() + nPos;
143 aData.erase( aStart, aStart + nAnz );