1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pam.hxx,v $
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 ************************************************************************/
33 #include <stddef.h> // fuer MemPool
34 #ifndef _GEN_HXX //autogen
35 #include <tools/gen.hxx>
37 #ifndef _SVMEMPOOL_HXX //autogen
38 #include <tools/mempool.hxx>
42 #include <cshtyp.hxx> // fuer die Funktions-Definitionen
45 #include <ring.hxx> // Superklasse
48 #include <index.hxx> // fuer SwIndex
51 #include <ndindex.hxx> // fuer SwNodeIndex
53 namespace com
{ namespace sun
{ namespace star
{ namespace util
{
69 //STRIP008 namespace com { namespace sun { namespace star { namespace util {
70 //STRIP008 struct SearchOptions;
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
;
127 class SwPaM
: public Ring
137 SwPaM( const SwPosition
& rPos
, SwPaM
* pRing
= 0 );
138 SwPaM( const SwPosition
& rMk
, const SwPosition
& rPt
, SwPaM
* pRing
= 0 );
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 );
148 // Bewegen des Cursors
149 FASTBOOL
Move( SwMoveFn fnMove
= fnMoveForward
,
150 SwGoInDoc fnGo
= fnGoCntnt
);
154 virtual void SetMark();
155 void DeleteMark() { pMark
= pPoint
; }
161 SwPosition
*pTmp
= pPoint
;
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
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
; }
185 { return (*pPoint
) <= (*pMark
)? pPoint
: pMark
; }
186 const SwPosition
*End() const
187 { return (*pPoint
) > (*pMark
)? pPoint
: pMark
; }
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