xref: /aoo41x/main/sw/source/core/bastyp/tabcol.cxx (revision efeef26f)
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_sw.hxx"
26 
27 
28 
29 #include "tabcol.hxx"
30 #include <errhdl.hxx>		// fuer Create-Methoden
31 
32 
SwTabCols(sal_uInt16 nSize)33 SwTabCols::SwTabCols( sal_uInt16 nSize ) :
34     nLeftMin( 0 ),
35 	nLeft( 0 ),
36 	nRight( 0 ),
37     nRightMax( 0 ),
38     bLastRowAllowedToChange( true )
39 {
40     if ( nSize )
41         aData.reserve( nSize );
42 }
43 
SwTabCols(const SwTabCols & rCpy)44 SwTabCols::SwTabCols( const SwTabCols& rCpy ) :
45     nLeftMin( rCpy.GetLeftMin() ),
46     nLeft( rCpy.GetLeft() ),
47     nRight( rCpy.GetRight() ),
48     nRightMax( rCpy.GetRightMax() ),
49     bLastRowAllowedToChange( rCpy.IsLastRowAllowedToChange() ),
50     aData( rCpy.GetData() )
51 {
52 #if OSL_DEBUG_LEVEL > 1
53 	for ( sal_uInt16 i = 0; i < Count(); ++i )
54     {
55         SwTabColsEntry aEntry1 = aData[i];
56         SwTabColsEntry aEntry2 = rCpy.GetData()[i];
57         (void) aEntry1;
58         (void) aEntry2;
59         ASSERT( aEntry1.nPos == aEntry2.nPos &&
60                 aEntry1.nMin == aEntry2.nMin &&
61                 aEntry1.nMax == aEntry2.nMax &&
62                 aEntry1.bHidden == aEntry2.bHidden,
63                 "CopyContructor of SwTabColsEntries did not succeed!" )
64     }
65 #endif
66 }
67 
operator =(const SwTabCols & rCpy)68 SwTabCols &SwTabCols::operator=( const SwTabCols& rCpy )
69 {
70 	nLeftMin = rCpy.GetLeftMin();
71 	nLeft	 = rCpy.GetLeft();
72 	nRight	 = rCpy.GetRight();
73 	nRightMax= rCpy.GetRightMax();
74     bLastRowAllowedToChange = rCpy.IsLastRowAllowedToChange();
75 
76 	Remove( 0, Count() );
77     aData = rCpy.GetData();
78 
79     return *this;
80 }
81 
operator ==(const SwTabCols & rCmp) const82 sal_Bool SwTabCols::operator==( const SwTabCols& rCmp ) const
83 {
84 	sal_uInt16 i;
85 
86 	if ( !(nLeftMin == rCmp.GetLeftMin() &&
87 		   nLeft	== rCmp.GetLeft()	 &&
88 		   nRight	== rCmp.GetRight()	 &&
89 		   nRightMax== rCmp.GetRightMax()&&
90            bLastRowAllowedToChange== rCmp.IsLastRowAllowedToChange() &&
91            Count()== rCmp.Count()) )
92 		return sal_False;
93 
94 	for ( i = 0; i < Count(); ++i )
95     {
96         SwTabColsEntry aEntry1 = aData[i];
97         SwTabColsEntry aEntry2 = rCmp.GetData()[i];
98         if ( aEntry1.nPos != aEntry2.nPos || aEntry1.bHidden != aEntry2.bHidden  )
99 			return sal_False;
100     }
101 
102     return sal_True;
103 }
104 
Insert(long nValue,long nMin,long nMax,sal_Bool bValue,sal_uInt16 nPos)105 void SwTabCols::Insert( long nValue, long nMin, long nMax, sal_Bool bValue, sal_uInt16 nPos )
106 {
107     SwTabColsEntry aEntry;
108     aEntry.nPos = nValue;
109     aEntry.nMin = nMin;
110     aEntry.nMax = nMax;
111     aEntry.bHidden = bValue;
112     aData.insert( aData.begin() + nPos, aEntry );
113 }
114 
Insert(long nValue,sal_Bool bValue,sal_uInt16 nPos)115 void SwTabCols::Insert( long nValue, sal_Bool bValue, sal_uInt16 nPos )
116 {
117     SwTabColsEntry aEntry;
118     aEntry.nPos = nValue;
119     aEntry.nMin = 0;
120     aEntry.nMax = LONG_MAX;
121     aEntry.bHidden = bValue;
122     aData.insert( aData.begin() + nPos, aEntry );
123 
124 #if OSL_DEBUG_LEVEL > 1
125     SwTabColsEntries::iterator aPos = aData.begin();
126     for ( ; aPos != aData.end(); ++aPos )
127     {
128         aEntry =(*aPos);
129     }
130 #endif
131 }
132 
Remove(sal_uInt16 nPos,sal_uInt16 nAnz)133 void SwTabCols::Remove( sal_uInt16 nPos, sal_uInt16 nAnz )
134 {
135     SwTabColsEntries::iterator aStart = aData.begin() + nPos;
136     aData.erase( aStart, aStart + nAnz );
137 }
138 
139