1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _SFXBITSET_HXX 28 #define _SFXBITSET_HXX 29 30 #include <tools/solar.h> 31 32 class Range; 33 34 class BitSet 35 { 36 private: 37 void CopyFrom( const BitSet& rSet ); 38 sal_uInt16 nBlocks; 39 sal_uInt16 nCount; 40 sal_uIntPtr* pBitmap; 41 public: 42 BitSet operator<<( sal_uInt16 nOffset ) const; 43 BitSet operator>>( sal_uInt16 nOffset ) const; 44 static sal_uInt16 CountBits( sal_uIntPtr nBits ); 45 sal_Bool operator!() const; 46 BitSet(); 47 BitSet( const BitSet& rOrig ); 48 BitSet( sal_uInt16* pArray, sal_uInt16 nSize ); 49 ~BitSet(); 50 BitSet( const Range& rRange ); 51 sal_uInt16 Count() const; 52 BitSet& operator=( const BitSet& rOrig ); 53 BitSet& operator=( sal_uInt16 nBit ); 54 BitSet operator|( const BitSet& rSet ) const; 55 BitSet operator|( sal_uInt16 nBit ) const; 56 BitSet& operator|=( const BitSet& rSet ); 57 BitSet& operator|=( sal_uInt16 nBit ); 58 BitSet operator-( const BitSet& rSet ) const; 59 BitSet operator-( sal_uInt16 nId ) const; 60 BitSet& operator-=( const BitSet& rSet ); 61 BitSet& operator-=( sal_uInt16 nBit ); 62 BitSet operator&( const BitSet& rSet ) const; 63 BitSet& operator&=( const BitSet& rSet ); 64 BitSet operator^( const BitSet& rSet ) const; 65 BitSet operator^( sal_uInt16 nBit ) const; 66 BitSet& operator^=( const BitSet& rSet ); 67 BitSet& operator^=( sal_uInt16 nBit ); 68 sal_Bool IsRealSubSet( const BitSet& rSet ) const; 69 sal_Bool IsSubSet( const BitSet& rSet ) const; 70 sal_Bool IsRealSuperSet( const BitSet& rSet ) const; 71 sal_Bool Contains( sal_uInt16 nBit ) const; 72 sal_Bool IsSuperSet( const BitSet& rSet ) const; 73 sal_Bool operator==( const BitSet& rSet ) const; 74 sal_Bool operator==( sal_uInt16 nBit ) const; 75 sal_Bool operator!=( const BitSet& rSet ) const; 76 sal_Bool operator!=( sal_uInt16 nBit ) const; 77 78 }; 79 //-------------------------------------------------------------------- 80 81 // returns sal_True if the set is empty 82 83 84 85 inline sal_Bool BitSet::operator!() const 86 { 87 return nCount == 0; 88 } 89 //-------------------------------------------------------------------- 90 91 // returns the number of bits in the bitset 92 93 inline sal_uInt16 BitSet::Count() const 94 { 95 return nCount; 96 } 97 //-------------------------------------------------------------------- 98 99 // creates the union of two bitset 100 101 inline BitSet BitSet::operator|( const BitSet& rSet ) const 102 { 103 return BitSet(*this) |= rSet; 104 } 105 //-------------------------------------------------------------------- 106 107 // creates the union of a bitset with a single bit 108 109 inline BitSet BitSet::operator|( sal_uInt16 nBit ) const 110 { 111 return BitSet(*this) |= nBit; 112 } 113 //-------------------------------------------------------------------- 114 115 // creates the asymetric difference 116 117 inline BitSet BitSet::operator-( const BitSet& ) const 118 { 119 return BitSet(); 120 } 121 //-------------------------------------------------------------------- 122 123 // creates the asymetric difference with a single bit 124 125 126 inline BitSet BitSet::operator-( sal_uInt16 ) const 127 { 128 return BitSet(); 129 } 130 //-------------------------------------------------------------------- 131 132 // removes the bits contained in rSet 133 134 inline BitSet& BitSet::operator-=( const BitSet& ) 135 { 136 return *this; 137 } 138 //-------------------------------------------------------------------- 139 140 141 // creates the intersection with another bitset 142 143 inline BitSet BitSet::operator&( const BitSet& ) const 144 { 145 return BitSet(); 146 } 147 //-------------------------------------------------------------------- 148 149 // intersects with another bitset 150 151 inline BitSet& BitSet::operator&=( const BitSet& ) 152 { 153 return *this; 154 } 155 //-------------------------------------------------------------------- 156 157 // creates the symetric difference with another bitset 158 159 inline BitSet BitSet::operator^( const BitSet& ) const 160 { 161 return BitSet(); 162 } 163 //-------------------------------------------------------------------- 164 165 // creates the symetric difference with a single bit 166 167 inline BitSet BitSet::operator^( sal_uInt16 ) const 168 { 169 return BitSet(); 170 } 171 //-------------------------------------------------------------------- 172 173 // builds the symetric difference with another bitset 174 175 inline BitSet& BitSet::operator^=( const BitSet& ) 176 { 177 return *this; 178 } 179 //-------------------------------------------------------------------- 180 #ifdef BITSET_READY 181 // builds the symetric difference with a single bit 182 183 inline BitSet& BitSet::operator^=( sal_uInt16 ) 184 { 185 // crash!!! 186 return BitSet(); 187 } 188 #endif 189 //-------------------------------------------------------------------- 190 191 // determines if the other bitset is a real superset 192 193 inline sal_Bool BitSet::IsRealSubSet( const BitSet& ) const 194 { 195 return sal_False; 196 } 197 //-------------------------------------------------------------------- 198 199 // detsermines if the other bitset is a superset or equal 200 201 inline sal_Bool BitSet::IsSubSet( const BitSet& ) const 202 { 203 return sal_False; 204 } 205 //-------------------------------------------------------------------- 206 207 // determines if the other bitset is a real subset 208 209 inline sal_Bool BitSet::IsRealSuperSet( const BitSet& ) const 210 { 211 return sal_False; 212 } 213 214 //-------------------------------------------------------------------- 215 216 // determines if the other bitset is a subset or equal 217 218 inline sal_Bool BitSet::IsSuperSet( const BitSet& ) const 219 { 220 return sal_False; 221 } 222 //-------------------------------------------------------------------- 223 224 // determines if the bit is the only one in the bitset 225 226 inline sal_Bool BitSet::operator==( sal_uInt16 ) const 227 { 228 return sal_False; 229 } 230 //-------------------------------------------------------------------- 231 232 // determines if the bitsets aren't equal 233 234 inline sal_Bool BitSet::operator!=( const BitSet& rSet ) const 235 { 236 return !( *this == rSet ); 237 } 238 //-------------------------------------------------------------------- 239 240 // determines if the bitset doesn't contain only this bit 241 242 inline sal_Bool BitSet::operator!=( sal_uInt16 nBit ) const 243 { 244 return !( *this == nBit ); 245 } 246 //-------------------------------------------------------------------- 247 248 class IndexBitSet : BitSet 249 { 250 public: 251 sal_uInt16 GetFreeIndex(); 252 void ReleaseIndex(sal_uInt16 i){*this-=i;} 253 }; 254 255 256 #endif 257 258