Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sw / pam.hxx
blob8bda80b3253f2123cf6c33bd2cc3526153fa310b
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: pam.hxx,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 ************************************************************************/
30 #ifndef _PAM_HXX
31 #define _PAM_HXX
33 #include <stddef.h> // fuer MemPool
34 #ifndef _GEN_HXX //autogen
35 #include <tools/gen.hxx>
36 #endif
37 #ifndef _SVMEMPOOL_HXX //autogen
38 #include <tools/mempool.hxx>
39 #endif
41 #ifndef _CSHTYP_HXX
42 #include <cshtyp.hxx> // fuer die Funktions-Definitionen
43 #endif
44 #ifndef _RING_HXX
45 #include <ring.hxx> // Superklasse
46 #endif
47 #ifndef _INDEX_HXX
48 #include <index.hxx> // fuer SwIndex
49 #endif
50 #ifndef _NDINDEX_HXX
51 #include <ndindex.hxx> // fuer SwNodeIndex
52 #endif
53 namespace com { namespace sun { namespace star { namespace util {
54 struct SearchOptions;
55 } } } }
56 namespace binfilter {
57 class SfxPoolItem;
58 class SfxItemSet;
61 class SwFmt;
63 class SwDoc;
64 class SwNode;
65 class SwCntntNode;
66 class SwNodes;
67 class SwPaM;
69 //STRIP008 namespace com { namespace sun { namespace star { namespace util {
70 //STRIP008 struct SearchOptions;
71 //STRIP008 } } } }
73 namespace utl {
74 class TextSearch;
75 }//STRIP008 ;
77 struct SwPosition
79 SwNodeIndex nNode;
80 SwIndex nContent;
82 SwPosition( );
83 SwPosition( const SwNode& rNode );
84 SwPosition( const SwNodeIndex &rNode );
85 SwPosition( const SwNodeIndex &rNode, const SwIndex &rCntnt );
86 SwPosition( const SwPosition & );
88 SwPosition &operator=(const SwPosition &);
90 FASTBOOL operator < (const SwPosition &) const;
91 FASTBOOL operator > (const SwPosition &) const;
92 FASTBOOL operator <=(const SwPosition &) const;
93 FASTBOOL operator >=(const SwPosition &) const;
94 FASTBOOL operator ==(const SwPosition &) const;
95 FASTBOOL operator !=(const SwPosition &) const;
99 // das Ergebnis eines Positions Vergleiches
100 enum SwComparePosition {
101 POS_BEFORE, // Pos1 liegt vor Pos2
102 POS_BEHIND, // Pos1 liegt hinter Pos2
103 POS_INSIDE, // Pos1 liegt vollstaendig in Pos2
104 POS_OUTSIDE, // Pos2 liegt vollstaendig in Pos1
105 POS_EQUAL, // Pos1 ist genauso gross wie Pos2
106 POS_OVERLAP_BEFORE, // Pos1 ueberlappt Pos2 am Anfang
107 POS_OVERLAP_BEHIND, // Pos1 ueberlappt Pos2 am Ende
108 POS_COLLIDE_START, // Pos1 Start stoesst an Pos2 Ende
109 POS_COLLIDE_END // Pos1 End stoesst an Pos2 Start
111 SwComparePosition ComparePosition(
112 const SwPosition& rStt1, const SwPosition& rEnd1,
113 const SwPosition& rStt2, const SwPosition& rEnd2 );
117 // SwPointAndMark / SwPaM
118 struct SwMoveFnCollection;
119 typedef SwMoveFnCollection* SwMoveFn;
120 extern SwMoveFn fnMoveForward, fnMoveBackward;
122 typedef FASTBOOL (*SwGoInDoc)( SwPaM& rPam, SwMoveFn fnMove );
123 extern SwGoInDoc fnGoDoc, fnGoSection, fnGoNode, fnGoCntnt, fnGoCntntCells;
125 void _InitPam();
127 class SwPaM : public Ring
129 SwPosition aBound1;
130 SwPosition aBound2;
131 SwPosition *pPoint;
132 SwPosition *pMark;
135 public:
136 SwPaM(){};
137 SwPaM( const SwPosition& rPos, SwPaM* pRing = 0 );
138 SwPaM( const SwPosition& rMk, const SwPosition& rPt, SwPaM* pRing = 0 );
139 SwPaM( SwPaM & );
140 SwPaM( const SwNode& rMk, const SwNode& rPt,
141 long nMkOffset = 0, long nPtOffset = 0, SwPaM* pRing = 0 );
142 SwPaM( const SwNode& rMk, xub_StrLen nMkCntnt,
143 const SwNode& rPt, xub_StrLen nPtCntnt, SwPaM* pRing = 0 );
144 SwPaM( const SwNode& rNd, xub_StrLen nCntnt = 0, SwPaM* pRing = 0 );
145 SwPaM( const SwNodeIndex& rNd, xub_StrLen nCntnt = 0, SwPaM* pRing = 0 );
146 virtual ~SwPaM();
148 // Bewegen des Cursors
149 FASTBOOL Move( SwMoveFn fnMove = fnMoveForward,
150 SwGoInDoc fnGo = fnGoCntnt );
152 // Suchen
154 virtual void SetMark();
155 void DeleteMark() { pMark = pPoint; }
156 #ifdef PRODUCT
157 void Exchange()
159 if(pPoint != pMark)
161 SwPosition *pTmp = pPoint;
162 pPoint = pMark;
163 pMark = pTmp;
166 #else
167 void Exchange();
168 #endif
170 * Undokumented Feature: Liefert zurueck, ob das Pam ueber
171 * eine Selektion verfuegt oder nicht. Definition einer
172 * Selektion: Point und Mark zeigen auf unterschiedliche
173 * Puffer.
175 FASTBOOL HasMark() const { return pPoint == pMark? FALSE : TRUE; }
177 const SwPosition *GetPoint() const { return pPoint; }
178 SwPosition *GetPoint() { return pPoint; }
179 const SwPosition *GetMark() const { return pMark; }
180 SwPosition *GetMark() { return pMark; }
182 const SwPosition *Start() const
183 { return (*pPoint) <= (*pMark)? pPoint: pMark; }
184 SwPosition *Start()
185 { return (*pPoint) <= (*pMark)? pPoint: pMark; }
186 const SwPosition *End() const
187 { return (*pPoint) > (*pMark)? pPoint: pMark; }
188 SwPosition *End()
189 { return (*pPoint) > (*pMark)? pPoint: pMark; }
191 SwPaM& operator=( SwPaM & );
193 // erfrage vom SwPaM den aktuellen Node/ContentNode am SPoint / Mark
194 SwNode* GetNode( BOOL bPoint = TRUE ) const
196 return &( bPoint ? pPoint->nNode : pMark->nNode ).GetNode();
198 SwCntntNode* GetCntntNode( BOOL bPoint = TRUE ) const
200 return ( bPoint ? pPoint->nNode : pMark->nNode ).GetNode().GetCntntNode();
204 Normalizes PaM, i.e. sort point and mark.
206 @param bPointFirst TRUE: If the point is behind the mark then swap.
207 FALSE: If the mark is behind the point then swap.
209 SwPaM & Normalize(BOOL bPointFirst = TRUE);
211 // erfrage vom SwPaM das Dokument, in dem er angemeldet ist
212 SwDoc* GetDoc() const { return pPoint->nNode.GetNode().GetDoc(); }
213 SwPosition& GetBound( BOOL bOne = TRUE )
214 { return bOne ? aBound1 : aBound2; }
215 const SwPosition& GetBound( BOOL bOne = TRUE ) const
216 { return bOne ? aBound1 : aBound2; }
218 // erfrage die Seitennummer auf der der Cursor steht
219 USHORT GetPageNum( BOOL bAtPoint = TRUE, const Point* pLayPos = 0 );
221 DECL_FIXEDMEMPOOL_NEWDEL(SwPaM)
225 FASTBOOL CheckNodesRange( const SwNodeIndex&, const SwNodeIndex&, FASTBOOL );
226 FASTBOOL GoInCntnt( SwPaM & rPam, SwMoveFn fnMove );
229 } //namespace binfilter
230 #endif // _PAM_HXX