xref: /aoo4110/main/svl/inc/svl/nranges.hxx (revision b1cdbd2c)
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 #ifdef MACOSX
24 // We need an empty block in here. Otherwise, if the #ifndef _SFXNRANGES_HXX
25 // line is the first line, the Mac OS X version of the gcc preprocessor will
26 // incorrectly optimize the inclusion process and will never include this file
27 // a second time
28 #endif
29 
30 #ifndef _SFXNRANGES_HXX
31 
32 #ifndef NUMTYPE
33 
34 #define NUMTYPE	sal_uInt16
35 #define SfxNumRanges SfxUShortRanges
36 #include <svl/nranges.hxx>
37 
38 #undef NUMTYPE
39 #define NUMTYPE	sal_uLong
40 #define SfxNumRanges SfxULongRanges
41 #include <svl/nranges.hxx>
42 
43 #define _SFXNRANGES_HXX
44 
45 #else
46 #include <tools/solar.h>
47 
48 //========================================================================
49 
50 #define NUMTYPE_ARG	int
51 
52 class SfxNumRanges
53 {
54 	NUMTYPE*                 	_pRanges; // 0-terminated array of NUMTYPE-pairs
55 
56 public:
SfxNumRanges()57 								SfxNumRanges() : _pRanges( 0 ) {}
58 								SfxNumRanges( const SfxNumRanges &rOrig );
59 								SfxNumRanges( NUMTYPE nWhich1, NUMTYPE nWhich2 );
60 								SfxNumRanges( NUMTYPE_ARG nWh1, NUMTYPE_ARG nWh2, NUMTYPE_ARG nNull, ... );
61 								SfxNumRanges( const NUMTYPE* nNumTable );
~SfxNumRanges()62 								~SfxNumRanges()
63 								{ delete [] _pRanges; }
64 
65 	sal_Bool						operator == ( const SfxNumRanges & ) const;
operator !=(const SfxNumRanges & rRanges) const66 	sal_Bool						operator != ( const SfxNumRanges & rRanges ) const
67 								{ return !( *this == rRanges ); }
68 
69 	SfxNumRanges&				operator = ( const SfxNumRanges & );
70 
71 	SfxNumRanges&				operator += ( const SfxNumRanges & );
72 	SfxNumRanges&				operator -= ( const SfxNumRanges & );
73 	SfxNumRanges&				operator /= ( const SfxNumRanges & );
74 
75 	NUMTYPE 					Count() const;
IsEmpty() const76 	sal_Bool						IsEmpty() const
77 								{ return !_pRanges || 0 == *_pRanges; }
78 	sal_Bool						Contains( NUMTYPE n ) const;
79 	sal_Bool						Intersects( const SfxNumRanges & ) const;
80 
81 								operator const NUMTYPE* () const
82 								{ return _pRanges; }
83 };
84 
85 #undef NUMTYPE
86 #undef SfxNumRanges
87 
88 #endif
89 
90 #endif
91