xref: /trunk/main/sw/inc/edimp.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 
28 #ifndef _EDIMP_HXX
29 #define _EDIMP_HXX
30 
31 #include <tools/solar.h>
32 #include <svl/svarray.hxx>
33 
34 class SwPaM;
35 class SwNodeIndex;
36 
37 /*
38  * MACROS um ueber alle Bereiche zu iterieren
39  */
40 #define PCURCRSR (_pStartCrsr)
41 
42 #define FOREACHPAM_START(pCURSH) \
43     {\
44         SwPaM *_pStartCrsr = (pCURSH)->GetCrsr(), *__pStartCrsr = _pStartCrsr; \
45         do {
46 
47 #define FOREACHPAM_END() \
48         } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != __pStartCrsr ); \
49     }
50 
51 
52 
53 struct SwPamRange
54 {
55     sal_uLong nStart, nEnd;
56 
57     SwPamRange() : nStart( 0 ), nEnd( 0 )   {}
58     SwPamRange( sal_uLong nS, sal_uLong nE ) : nStart( nS ), nEnd( nE ) {}
59 
60     sal_Bool operator==( const SwPamRange& rRg )
61         { return nStart == rRg.nStart ? sal_True : sal_False; }
62     sal_Bool operator<( const SwPamRange& rRg )
63         { return nStart < rRg.nStart ? sal_True : sal_False; }
64 };
65 
66 SV_DECL_VARARR_SORT( _SwPamRanges, SwPamRange, 0, 1 )
67 
68 class SwPamRanges : private _SwPamRanges
69 {
70 public:
71     SwPamRanges( const SwPaM& rRing );
72 
73     void Insert( const SwNodeIndex& rIdx1, const SwNodeIndex& rIdx2 );
74     SwPaM& SetPam( sal_uInt16 nArrPos, SwPaM& rPam );
75 
76     sal_uInt16 Count() const
77                 {   return _SwPamRanges::Count(); }
78     SwPamRange operator[]( sal_uInt16 nPos ) const
79                 { return _SwPamRanges::operator[](nPos); }
80 };
81 
82 
83 #endif
84