1efeef26fSAndrew Rist /**************************************************************
2efeef26fSAndrew Rist *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir #include <editeng/protitem.hxx>
30cdf0e10cSrcweir #include <cntfrm.hxx>
31cdf0e10cSrcweir #include <pagefrm.hxx>
32cdf0e10cSrcweir #include <doc.hxx>
33cdf0e10cSrcweir #include <docary.hxx>
34cdf0e10cSrcweir #include <pam.hxx>
35cdf0e10cSrcweir #include <pamtyp.hxx>
36cdf0e10cSrcweir #include <txtfrm.hxx>
37cdf0e10cSrcweir #include <section.hxx>
38cdf0e10cSrcweir #include <fmtcntnt.hxx>
39cdf0e10cSrcweir #include <frmatr.hxx>
40cdf0e10cSrcweir #include <swtable.hxx>
41cdf0e10cSrcweir #include <crsskip.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir // --> FME 2004-06-29 #114856# Formular view
44cdf0e10cSrcweir #include <flyfrm.hxx>
45cdf0e10cSrcweir #include <fmteiro.hxx>
46cdf0e10cSrcweir #include <section.hxx>
47cdf0e10cSrcweir #include <sectfrm.hxx>
48cdf0e10cSrcweir // <--
49cdf0e10cSrcweir #include <ndtxt.hxx> // #111827#
50cdf0e10cSrcweir
51cdf0e10cSrcweir #include <IMark.hxx>
52cdf0e10cSrcweir #include <hints.hxx>
53cdf0e10cSrcweir
54cdf0e10cSrcweir // fuer den dummen ?MSC-? Compiler
GetSttOrEnd(sal_Bool bCondition,const SwCntntNode & rNd)55cdf0e10cSrcweir inline xub_StrLen GetSttOrEnd( sal_Bool bCondition, const SwCntntNode& rNd )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir return bCondition ? 0 : rNd.Len();
58cdf0e10cSrcweir }
59cdf0e10cSrcweir
60cdf0e10cSrcweir /*************************************************************************
61cdf0e10cSrcweir |*
62cdf0e10cSrcweir |* SwPosition
63cdf0e10cSrcweir |*
64cdf0e10cSrcweir |* Beschreibung PAM.DOC
65cdf0e10cSrcweir |* Ersterstellung VB 4.3.91
66cdf0e10cSrcweir |* Letzte Aenderung VB 4.3.91
67cdf0e10cSrcweir |*
68cdf0e10cSrcweir *************************************************************************/
69cdf0e10cSrcweir
70cdf0e10cSrcweir
SwPosition(const SwNodeIndex & rNodeIndex,const SwIndex & rCntnt)71cdf0e10cSrcweir SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, const SwIndex & rCntnt )
72cdf0e10cSrcweir : nNode( rNodeIndex ), nContent( rCntnt )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
SwPosition(const SwNodeIndex & rNodeIndex)76cdf0e10cSrcweir SwPosition::SwPosition( const SwNodeIndex & rNodeIndex )
77cdf0e10cSrcweir : nNode( rNodeIndex ), nContent( nNode.GetNode().GetCntntNode() )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
SwPosition(const SwNode & rNode)81cdf0e10cSrcweir SwPosition::SwPosition( const SwNode& rNode )
82cdf0e10cSrcweir : nNode( rNode ), nContent( nNode.GetNode().GetCntntNode() )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
SwPosition(SwCntntNode & rNode,const xub_StrLen nOffset)86cdf0e10cSrcweir SwPosition::SwPosition( SwCntntNode & rNode, const xub_StrLen nOffset )
87cdf0e10cSrcweir : nNode( rNode ), nContent( &rNode, nOffset )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
91cdf0e10cSrcweir
SwPosition(const SwPosition & rPos)92cdf0e10cSrcweir SwPosition::SwPosition( const SwPosition & rPos )
93cdf0e10cSrcweir : nNode( rPos.nNode ), nContent( rPos.nContent )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
operator =(const SwPosition & rPos)97cdf0e10cSrcweir SwPosition &SwPosition::operator=(const SwPosition &rPos)
98cdf0e10cSrcweir {
99cdf0e10cSrcweir nNode = rPos.nNode;
100cdf0e10cSrcweir nContent = rPos.nContent;
101cdf0e10cSrcweir return *this;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir
operator <(const SwPosition & rPos) const105cdf0e10cSrcweir sal_Bool SwPosition::operator<(const SwPosition &rPos) const
106cdf0e10cSrcweir {
107cdf0e10cSrcweir if( nNode < rPos.nNode )
108cdf0e10cSrcweir return sal_True;
109cdf0e10cSrcweir if( nNode == rPos.nNode )
110cdf0e10cSrcweir return ( nContent < rPos.nContent );
111cdf0e10cSrcweir return sal_False;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir
operator >(const SwPosition & rPos) const115cdf0e10cSrcweir sal_Bool SwPosition::operator>(const SwPosition &rPos) const
116cdf0e10cSrcweir {
117cdf0e10cSrcweir if(nNode > rPos.nNode )
118cdf0e10cSrcweir return sal_True;
119cdf0e10cSrcweir if( nNode == rPos.nNode )
120cdf0e10cSrcweir return ( nContent > rPos.nContent );
121cdf0e10cSrcweir return sal_False;
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
124cdf0e10cSrcweir
operator <=(const SwPosition & rPos) const125cdf0e10cSrcweir sal_Bool SwPosition::operator<=(const SwPosition &rPos) const
126cdf0e10cSrcweir {
127cdf0e10cSrcweir if(nNode < rPos.nNode )
128cdf0e10cSrcweir return sal_True;
129cdf0e10cSrcweir if( nNode == rPos.nNode )
130cdf0e10cSrcweir return ( nContent <= rPos.nContent );
131cdf0e10cSrcweir return sal_False;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
134cdf0e10cSrcweir
operator >=(const SwPosition & rPos) const135cdf0e10cSrcweir sal_Bool SwPosition::operator>=(const SwPosition &rPos) const
136cdf0e10cSrcweir {
137cdf0e10cSrcweir if(nNode > rPos.nNode )
138cdf0e10cSrcweir return sal_True;
139cdf0e10cSrcweir if( nNode == rPos.nNode )
140cdf0e10cSrcweir return ( nContent >= rPos.nContent );
141cdf0e10cSrcweir return sal_False;
142cdf0e10cSrcweir }
143cdf0e10cSrcweir
144cdf0e10cSrcweir
operator ==(const SwPosition & rPos) const145cdf0e10cSrcweir sal_Bool SwPosition::operator==(const SwPosition &rPos) const
146cdf0e10cSrcweir {
147cdf0e10cSrcweir return
148cdf0e10cSrcweir ( ( nNode == rPos.nNode ) && ( nContent == rPos.nContent ) ?
149cdf0e10cSrcweir sal_True: sal_False);
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
152cdf0e10cSrcweir
operator !=(const SwPosition & rPos) const153cdf0e10cSrcweir sal_Bool SwPosition::operator!=(const SwPosition &rPos) const
154cdf0e10cSrcweir {
155cdf0e10cSrcweir if( nNode != rPos.nNode )
156cdf0e10cSrcweir return sal_True;
157cdf0e10cSrcweir return ( nContent != rPos.nContent );
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
GetDoc() const160cdf0e10cSrcweir SwDoc * SwPosition::GetDoc() const
161cdf0e10cSrcweir {
162cdf0e10cSrcweir return nNode.GetNode().GetDoc();
163cdf0e10cSrcweir }
164cdf0e10cSrcweir
ComparePosition(const SwPosition & rStt1,const SwPosition & rEnd1,const SwPosition & rStt2,const SwPosition & rEnd2)165cdf0e10cSrcweir SwComparePosition ComparePosition(
166cdf0e10cSrcweir const SwPosition& rStt1, const SwPosition& rEnd1,
167cdf0e10cSrcweir const SwPosition& rStt2, const SwPosition& rEnd2 )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir SwComparePosition nRet;
170cdf0e10cSrcweir if( rStt1 < rStt2 )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir if( rEnd1 > rStt2 )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir if( rEnd1 >= rEnd2 )
175cdf0e10cSrcweir nRet = POS_OUTSIDE;
176cdf0e10cSrcweir else
177cdf0e10cSrcweir nRet = POS_OVERLAP_BEFORE;
178cdf0e10cSrcweir
179cdf0e10cSrcweir }
180cdf0e10cSrcweir else if( rEnd1 == rStt2 )
181cdf0e10cSrcweir nRet = POS_COLLIDE_END;
182cdf0e10cSrcweir else
183cdf0e10cSrcweir nRet = POS_BEFORE;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir else if( rEnd2 > rStt1 )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir if( rEnd2 >= rEnd1 )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir if( rEnd2 == rEnd1 && rStt2 == rStt1 )
190cdf0e10cSrcweir nRet = POS_EQUAL;
191cdf0e10cSrcweir else
192cdf0e10cSrcweir nRet = POS_INSIDE;
193cdf0e10cSrcweir }
194cdf0e10cSrcweir else
195cdf0e10cSrcweir {
196cdf0e10cSrcweir if (rStt1 == rStt2)
197cdf0e10cSrcweir nRet = POS_OUTSIDE;
198cdf0e10cSrcweir else
199cdf0e10cSrcweir nRet = POS_OVERLAP_BEHIND;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir }
202cdf0e10cSrcweir else if( rEnd2 == rStt1 )
203cdf0e10cSrcweir nRet = POS_COLLIDE_START;
204cdf0e10cSrcweir else
205cdf0e10cSrcweir nRet = POS_BEHIND;
206cdf0e10cSrcweir return nRet;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir
ComparePosition(const unsigned long nStt1,const unsigned long nEnd1,const unsigned long nStt2,const unsigned long nEnd2)209cdf0e10cSrcweir SwComparePosition ComparePosition(
210cdf0e10cSrcweir const unsigned long nStt1, const unsigned long nEnd1,
211cdf0e10cSrcweir const unsigned long nStt2, const unsigned long nEnd2 )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir SwComparePosition nRet;
214cdf0e10cSrcweir if( nStt1 < nStt2 )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir if( nEnd1 > nStt2 )
217cdf0e10cSrcweir {
218cdf0e10cSrcweir if( nEnd1 >= nEnd2 )
219cdf0e10cSrcweir nRet = POS_OUTSIDE;
220cdf0e10cSrcweir else
221cdf0e10cSrcweir nRet = POS_OVERLAP_BEFORE;
222cdf0e10cSrcweir
223cdf0e10cSrcweir }
224cdf0e10cSrcweir else if( nEnd1 == nStt2 )
225cdf0e10cSrcweir nRet = POS_COLLIDE_END;
226cdf0e10cSrcweir else
227cdf0e10cSrcweir nRet = POS_BEFORE;
228cdf0e10cSrcweir }
229cdf0e10cSrcweir else if( nEnd2 > nStt1 )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir if( nEnd2 >= nEnd1 )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir if( nEnd2 == nEnd1 && nStt2 == nStt1 )
234cdf0e10cSrcweir nRet = POS_EQUAL;
235cdf0e10cSrcweir else
236cdf0e10cSrcweir nRet = POS_INSIDE;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir else
239cdf0e10cSrcweir {
240cdf0e10cSrcweir if (nStt1 == nStt2)
241cdf0e10cSrcweir nRet = POS_OUTSIDE;
242cdf0e10cSrcweir else
243cdf0e10cSrcweir nRet = POS_OVERLAP_BEHIND;
244cdf0e10cSrcweir }
245cdf0e10cSrcweir }
246cdf0e10cSrcweir else if( nEnd2 == nStt1 )
247cdf0e10cSrcweir nRet = POS_COLLIDE_START;
248cdf0e10cSrcweir else
249cdf0e10cSrcweir nRet = POS_BEHIND;
250cdf0e10cSrcweir return nRet;
251cdf0e10cSrcweir }
252cdf0e10cSrcweir
253cdf0e10cSrcweir /* */
254cdf0e10cSrcweir
255cdf0e10cSrcweir enum CHKSECTION { Chk_Both, Chk_One, Chk_None };
256cdf0e10cSrcweir
257cdf0e10cSrcweir
lcl_TstIdx(sal_uLong nSttIdx,sal_uLong nEndIdx,const SwNode & rEndNd)258cdf0e10cSrcweir CHKSECTION lcl_TstIdx( sal_uLong nSttIdx, sal_uLong nEndIdx, const SwNode& rEndNd )
259cdf0e10cSrcweir {
260cdf0e10cSrcweir sal_uLong nStt = rEndNd.StartOfSectionIndex(), nEnd = rEndNd.GetIndex();
261cdf0e10cSrcweir CHKSECTION eSec = nStt < nSttIdx && nEnd >= nSttIdx ? Chk_One : Chk_None;
262cdf0e10cSrcweir if( nStt < nEndIdx && nEnd >= nEndIdx )
263cdf0e10cSrcweir return( eSec == Chk_One ? Chk_Both : Chk_One );
264cdf0e10cSrcweir return eSec;
265cdf0e10cSrcweir }
266cdf0e10cSrcweir
267cdf0e10cSrcweir
lcl_ChkOneRange(CHKSECTION eSec,sal_Bool bChkSections,const SwNode & rBaseEnd,sal_uLong nStt,sal_uLong nEnd)268cdf0e10cSrcweir sal_Bool lcl_ChkOneRange( CHKSECTION eSec, sal_Bool bChkSections,
269cdf0e10cSrcweir const SwNode& rBaseEnd, sal_uLong nStt, sal_uLong nEnd )
270cdf0e10cSrcweir {
271cdf0e10cSrcweir if( eSec != Chk_Both )
272cdf0e10cSrcweir return sal_False;
273cdf0e10cSrcweir
274cdf0e10cSrcweir if( !bChkSections )
275cdf0e10cSrcweir return sal_True;
276cdf0e10cSrcweir
277cdf0e10cSrcweir // suche die umspannende Section
278cdf0e10cSrcweir const SwNodes& rNds = rBaseEnd.GetNodes();
279cdf0e10cSrcweir const SwNode *pTmp, *pNd = rNds[ nStt ];
280cdf0e10cSrcweir if( !pNd->IsStartNode() )
281cdf0e10cSrcweir pNd = pNd->StartOfSectionNode();
282cdf0e10cSrcweir
283cdf0e10cSrcweir if( pNd == rNds[ nEnd ]->StartOfSectionNode() )
284cdf0e10cSrcweir return sal_True; // der gleiche StartNode, die selbe Section
285cdf0e10cSrcweir
286cdf0e10cSrcweir // steht schon auf einem GrundSection Node ? Fehler !!!
287cdf0e10cSrcweir if( !pNd->StartOfSectionIndex() )
288cdf0e10cSrcweir return sal_False;
289cdf0e10cSrcweir
290cdf0e10cSrcweir while( ( pTmp = pNd->StartOfSectionNode())->EndOfSectionNode() !=
291cdf0e10cSrcweir &rBaseEnd )
292cdf0e10cSrcweir pNd = pTmp;
293cdf0e10cSrcweir
294cdf0e10cSrcweir sal_uLong nSttIdx = pNd->GetIndex(), nEndIdx = pNd->EndOfSectionIndex();
295cdf0e10cSrcweir return nSttIdx <= nStt && nStt <= nEndIdx &&
296cdf0e10cSrcweir nSttIdx <= nEnd && nEnd <= nEndIdx ? sal_True : sal_False;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir
299cdf0e10cSrcweir
CheckNodesRange(const SwNodeIndex & rStt,const SwNodeIndex & rEnd,sal_Bool bChkSection)300cdf0e10cSrcweir sal_Bool CheckNodesRange( const SwNodeIndex& rStt,
301cdf0e10cSrcweir const SwNodeIndex& rEnd, sal_Bool bChkSection )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir const SwNodes& rNds = rStt.GetNodes();
304cdf0e10cSrcweir sal_uLong nStt = rStt.GetIndex(), nEnd = rEnd.GetIndex();
305cdf0e10cSrcweir CHKSECTION eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfContent() );
306cdf0e10cSrcweir if( Chk_None != eSec ) return eSec == Chk_Both ? sal_True : sal_False;
307cdf0e10cSrcweir
308cdf0e10cSrcweir eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfAutotext() );
309cdf0e10cSrcweir if( Chk_None != eSec )
310cdf0e10cSrcweir return lcl_ChkOneRange( eSec, bChkSection,
311cdf0e10cSrcweir rNds.GetEndOfAutotext(), nStt, nEnd );
312cdf0e10cSrcweir
313cdf0e10cSrcweir eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfPostIts() );
314cdf0e10cSrcweir if( Chk_None != eSec )
315cdf0e10cSrcweir return lcl_ChkOneRange( eSec, bChkSection,
316cdf0e10cSrcweir rNds.GetEndOfPostIts(), nStt, nEnd );
317cdf0e10cSrcweir
318cdf0e10cSrcweir eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfInserts() );
319cdf0e10cSrcweir if( Chk_None != eSec )
320cdf0e10cSrcweir return lcl_ChkOneRange( eSec, bChkSection,
321cdf0e10cSrcweir rNds.GetEndOfInserts(), nStt, nEnd );
322cdf0e10cSrcweir
323cdf0e10cSrcweir eSec = lcl_TstIdx( nStt, nEnd, rNds.GetEndOfRedlines() );
324cdf0e10cSrcweir if( Chk_None != eSec )
325cdf0e10cSrcweir return lcl_ChkOneRange( eSec, bChkSection,
326cdf0e10cSrcweir rNds.GetEndOfRedlines(), nStt, nEnd );
327cdf0e10cSrcweir
328cdf0e10cSrcweir return sal_False; // liegt irgendwo dazwischen, FEHLER
329cdf0e10cSrcweir }
330cdf0e10cSrcweir
331cdf0e10cSrcweir
GoNext(SwNode * pNd,SwIndex * pIdx,sal_uInt16 nMode)332cdf0e10cSrcweir sal_Bool GoNext(SwNode* pNd, SwIndex * pIdx, sal_uInt16 nMode )
333cdf0e10cSrcweir {
334cdf0e10cSrcweir if( pNd->IsCntntNode() )
335cdf0e10cSrcweir return ((SwCntntNode*)pNd)->GoNext( pIdx, nMode );
336cdf0e10cSrcweir return sal_False;
337cdf0e10cSrcweir }
338cdf0e10cSrcweir
339cdf0e10cSrcweir
GoPrevious(SwNode * pNd,SwIndex * pIdx,sal_uInt16 nMode)340cdf0e10cSrcweir sal_Bool GoPrevious( SwNode* pNd, SwIndex * pIdx, sal_uInt16 nMode )
341cdf0e10cSrcweir {
342cdf0e10cSrcweir if( pNd->IsCntntNode() )
343cdf0e10cSrcweir return ((SwCntntNode*)pNd)->GoPrevious( pIdx, nMode );
344cdf0e10cSrcweir return sal_False;
345cdf0e10cSrcweir }
346cdf0e10cSrcweir
347cdf0e10cSrcweir
GoNextNds(SwNodeIndex * pIdx,sal_Bool bChk)348cdf0e10cSrcweir SwCntntNode* GoNextNds( SwNodeIndex* pIdx, sal_Bool bChk )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir SwNodeIndex aIdx( *pIdx );
351cdf0e10cSrcweir SwCntntNode* pNd = aIdx.GetNodes().GoNext( &aIdx );
352cdf0e10cSrcweir if( pNd )
353cdf0e10cSrcweir {
354cdf0e10cSrcweir if( bChk && 1 != aIdx.GetIndex() - pIdx->GetIndex() &&
355cdf0e10cSrcweir !CheckNodesRange( *pIdx, aIdx, sal_True ) )
356cdf0e10cSrcweir pNd = 0;
357cdf0e10cSrcweir else
358cdf0e10cSrcweir *pIdx = aIdx;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir return pNd;
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
363cdf0e10cSrcweir
GoPreviousNds(SwNodeIndex * pIdx,sal_Bool bChk)364cdf0e10cSrcweir SwCntntNode* GoPreviousNds( SwNodeIndex * pIdx, sal_Bool bChk )
365cdf0e10cSrcweir {
366cdf0e10cSrcweir SwNodeIndex aIdx( *pIdx );
367cdf0e10cSrcweir SwCntntNode* pNd = aIdx.GetNodes().GoPrevious( &aIdx );
368cdf0e10cSrcweir if( pNd )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir if( bChk && 1 != pIdx->GetIndex() - aIdx.GetIndex() &&
371cdf0e10cSrcweir !CheckNodesRange( *pIdx, aIdx, sal_True ) )
372cdf0e10cSrcweir pNd = 0;
373cdf0e10cSrcweir else
374cdf0e10cSrcweir *pIdx = aIdx;
375cdf0e10cSrcweir }
376cdf0e10cSrcweir return pNd;
377cdf0e10cSrcweir }
378cdf0e10cSrcweir
379cdf0e10cSrcweir // ----------------------------------------------------------------------
380cdf0e10cSrcweir
381cdf0e10cSrcweir /*************************************************************************
382cdf0e10cSrcweir |*
383cdf0e10cSrcweir |* SwPointAndMark
384cdf0e10cSrcweir |*
385cdf0e10cSrcweir |* Beschreibung PAM.DOC
386cdf0e10cSrcweir |* Ersterstellung VB 4.3.91
387cdf0e10cSrcweir |* Letzte Aenderung JP 6.5.91
388cdf0e10cSrcweir |*
389cdf0e10cSrcweir *************************************************************************/
390cdf0e10cSrcweir
SwPaM(const SwPosition & rPos,SwPaM * pRing)391cdf0e10cSrcweir SwPaM::SwPaM( const SwPosition& rPos, SwPaM* pRing )
392cdf0e10cSrcweir : Ring( pRing )
393cdf0e10cSrcweir , m_Bound1( rPos )
394cdf0e10cSrcweir , m_Bound2( rPos.nNode.GetNode().GetNodes() ) // default initialize
395cdf0e10cSrcweir , m_pPoint( &m_Bound1 )
396cdf0e10cSrcweir , m_pMark( m_pPoint )
397cdf0e10cSrcweir , m_bIsInFrontOfLabel( false )
398cdf0e10cSrcweir {
399cdf0e10cSrcweir }
400cdf0e10cSrcweir
SwPaM(const SwPosition & rMark,const SwPosition & rPoint,SwPaM * pRing)401cdf0e10cSrcweir SwPaM::SwPaM( const SwPosition& rMark, const SwPosition& rPoint, SwPaM* pRing )
402cdf0e10cSrcweir : Ring( pRing )
403cdf0e10cSrcweir , m_Bound1( rMark )
404cdf0e10cSrcweir , m_Bound2( rPoint )
405cdf0e10cSrcweir , m_pPoint( &m_Bound2 )
406cdf0e10cSrcweir , m_pMark( &m_Bound1 )
407cdf0e10cSrcweir , m_bIsInFrontOfLabel( false )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir }
410cdf0e10cSrcweir
SwPaM(const SwNodeIndex & rMark,const SwNodeIndex & rPoint,long nMarkOffset,long nPointOffset,SwPaM * pRing)411cdf0e10cSrcweir SwPaM::SwPaM( const SwNodeIndex& rMark, const SwNodeIndex& rPoint,
412cdf0e10cSrcweir long nMarkOffset, long nPointOffset, SwPaM* pRing )
413cdf0e10cSrcweir : Ring( pRing )
414cdf0e10cSrcweir , m_Bound1( rMark )
415cdf0e10cSrcweir , m_Bound2( rPoint )
416cdf0e10cSrcweir , m_pPoint( &m_Bound2 )
417cdf0e10cSrcweir , m_pMark( &m_Bound1 )
418cdf0e10cSrcweir , m_bIsInFrontOfLabel( false )
419cdf0e10cSrcweir {
420cdf0e10cSrcweir if ( nMarkOffset )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir m_pMark->nNode += nMarkOffset;
423cdf0e10cSrcweir }
424cdf0e10cSrcweir if ( nPointOffset )
425cdf0e10cSrcweir {
426cdf0e10cSrcweir m_pPoint->nNode += nPointOffset;
427cdf0e10cSrcweir }
428cdf0e10cSrcweir
429cdf0e10cSrcweir m_Bound1.nContent.Assign( m_Bound1.nNode.GetNode().GetCntntNode(), 0 );
430cdf0e10cSrcweir m_Bound2.nContent.Assign( m_Bound2.nNode.GetNode().GetCntntNode(), 0 );
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
SwPaM(const SwNode & rMark,const SwNode & rPoint,long nMarkOffset,long nPointOffset,SwPaM * pRing)433cdf0e10cSrcweir SwPaM::SwPaM( const SwNode& rMark, const SwNode& rPoint,
434cdf0e10cSrcweir long nMarkOffset, long nPointOffset, SwPaM* pRing )
435cdf0e10cSrcweir : Ring( pRing )
436cdf0e10cSrcweir , m_Bound1( rMark )
437cdf0e10cSrcweir , m_Bound2( rPoint )
438cdf0e10cSrcweir , m_pPoint( &m_Bound2 )
439cdf0e10cSrcweir , m_pMark( &m_Bound1 )
440cdf0e10cSrcweir , m_bIsInFrontOfLabel( false )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir if ( nMarkOffset )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir m_pMark->nNode += nMarkOffset;
445cdf0e10cSrcweir }
446cdf0e10cSrcweir if ( nPointOffset )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir m_pPoint->nNode += nPointOffset;
449cdf0e10cSrcweir }
450cdf0e10cSrcweir
451cdf0e10cSrcweir m_Bound1.nContent.Assign( m_Bound1.nNode.GetNode().GetCntntNode(), 0 );
452cdf0e10cSrcweir m_Bound2.nContent.Assign( m_Bound2.nNode.GetNode().GetCntntNode(), 0 );
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
SwPaM(const SwNodeIndex & rMark,xub_StrLen nMarkCntnt,const SwNodeIndex & rPoint,xub_StrLen nPointCntnt,SwPaM * pRing)455cdf0e10cSrcweir SwPaM::SwPaM( const SwNodeIndex& rMark , xub_StrLen nMarkCntnt,
456cdf0e10cSrcweir const SwNodeIndex& rPoint, xub_StrLen nPointCntnt, SwPaM* pRing )
457cdf0e10cSrcweir : Ring( pRing )
458cdf0e10cSrcweir , m_Bound1( rMark )
459cdf0e10cSrcweir , m_Bound2( rPoint )
460cdf0e10cSrcweir , m_pPoint( &m_Bound2 )
461cdf0e10cSrcweir , m_pMark( &m_Bound1 )
462cdf0e10cSrcweir , m_bIsInFrontOfLabel( false )
463cdf0e10cSrcweir {
464cdf0e10cSrcweir m_pPoint->nContent.Assign( rPoint.GetNode().GetCntntNode(), nPointCntnt);
465cdf0e10cSrcweir m_pMark ->nContent.Assign( rMark .GetNode().GetCntntNode(), nMarkCntnt );
466cdf0e10cSrcweir }
467cdf0e10cSrcweir
SwPaM(const SwNode & rMark,xub_StrLen nMarkCntnt,const SwNode & rPoint,xub_StrLen nPointCntnt,SwPaM * pRing)468cdf0e10cSrcweir SwPaM::SwPaM( const SwNode& rMark , xub_StrLen nMarkCntnt,
469cdf0e10cSrcweir const SwNode& rPoint, xub_StrLen nPointCntnt, SwPaM* pRing )
470cdf0e10cSrcweir : Ring( pRing )
471cdf0e10cSrcweir , m_Bound1( rMark )
472cdf0e10cSrcweir , m_Bound2( rPoint )
473cdf0e10cSrcweir , m_pPoint( &m_Bound2 )
474cdf0e10cSrcweir , m_pMark( &m_Bound1 )
475cdf0e10cSrcweir , m_bIsInFrontOfLabel( false )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir m_pPoint->nContent.Assign( m_pPoint->nNode.GetNode().GetCntntNode(),
478cdf0e10cSrcweir nPointCntnt);
479cdf0e10cSrcweir m_pMark ->nContent.Assign( m_pMark ->nNode.GetNode().GetCntntNode(),
480cdf0e10cSrcweir nMarkCntnt );
481cdf0e10cSrcweir }
482cdf0e10cSrcweir
SwPaM(const SwNode & rNode,xub_StrLen nCntnt,SwPaM * pRing)483cdf0e10cSrcweir SwPaM::SwPaM( const SwNode& rNode, xub_StrLen nCntnt, SwPaM* pRing )
484cdf0e10cSrcweir : Ring( pRing )
485cdf0e10cSrcweir , m_Bound1( rNode )
486cdf0e10cSrcweir , m_Bound2( m_Bound1.nNode.GetNode().GetNodes() ) // default initialize
487cdf0e10cSrcweir , m_pPoint( &m_Bound1 )
488cdf0e10cSrcweir , m_pMark( &m_Bound1 )
489cdf0e10cSrcweir , m_bIsInFrontOfLabel( false )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir m_pPoint->nContent.Assign( m_pPoint->nNode.GetNode().GetCntntNode(),
492cdf0e10cSrcweir nCntnt );
493cdf0e10cSrcweir }
494cdf0e10cSrcweir
SwPaM(const SwNodeIndex & rNodeIdx,xub_StrLen nCntnt,SwPaM * pRing)495cdf0e10cSrcweir SwPaM::SwPaM( const SwNodeIndex& rNodeIdx, xub_StrLen nCntnt, SwPaM* pRing )
496cdf0e10cSrcweir : Ring( pRing )
497cdf0e10cSrcweir , m_Bound1( rNodeIdx )
498cdf0e10cSrcweir , m_Bound2( rNodeIdx.GetNode().GetNodes() ) // default initialize
499cdf0e10cSrcweir , m_pPoint( &m_Bound1 )
500cdf0e10cSrcweir , m_pMark( &m_Bound1 )
501cdf0e10cSrcweir , m_bIsInFrontOfLabel( false )
502cdf0e10cSrcweir {
503cdf0e10cSrcweir m_pPoint->nContent.Assign( rNodeIdx.GetNode().GetCntntNode(), nCntnt );
504cdf0e10cSrcweir }
505cdf0e10cSrcweir
~SwPaM()506cdf0e10cSrcweir SwPaM::~SwPaM() {}
507cdf0e10cSrcweir
508cdf0e10cSrcweir // @@@ semantic: no copy ctor.
SwPaM(SwPaM & rPam)509cdf0e10cSrcweir SwPaM::SwPaM( SwPaM &rPam )
510cdf0e10cSrcweir : Ring( &rPam )
511cdf0e10cSrcweir , m_Bound1( *(rPam.m_pPoint) )
512cdf0e10cSrcweir , m_Bound2( *(rPam.m_pMark) )
513cdf0e10cSrcweir , m_pPoint( &m_Bound1 ), m_pMark( rPam.HasMark() ? &m_Bound2 : m_pPoint )
514cdf0e10cSrcweir , m_bIsInFrontOfLabel( false )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir }
517cdf0e10cSrcweir
518cdf0e10cSrcweir // @@@ semantic: no copy assignment for super class Ring.
operator =(const SwPaM & rPam)519cdf0e10cSrcweir SwPaM &SwPaM::operator=( const SwPaM &rPam )
520cdf0e10cSrcweir {
521cdf0e10cSrcweir *m_pPoint = *( rPam.m_pPoint );
522cdf0e10cSrcweir if ( rPam.HasMark() )
523cdf0e10cSrcweir {
524cdf0e10cSrcweir SetMark();
525cdf0e10cSrcweir *m_pMark = *( rPam.m_pMark );
526cdf0e10cSrcweir }
527cdf0e10cSrcweir else
528cdf0e10cSrcweir {
529cdf0e10cSrcweir DeleteMark();
530cdf0e10cSrcweir }
531cdf0e10cSrcweir return *this;
532cdf0e10cSrcweir }
533cdf0e10cSrcweir
SetMark()534cdf0e10cSrcweir void SwPaM::SetMark()
535cdf0e10cSrcweir {
536cdf0e10cSrcweir if (m_pPoint == &m_Bound1)
537cdf0e10cSrcweir {
538cdf0e10cSrcweir m_pMark = &m_Bound2;
539cdf0e10cSrcweir }
540cdf0e10cSrcweir else
541cdf0e10cSrcweir {
542cdf0e10cSrcweir m_pMark = &m_Bound1;
543cdf0e10cSrcweir }
544cdf0e10cSrcweir (*m_pMark) = (*m_pPoint);
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
547cdf0e10cSrcweir #ifdef DBG_UTIL
548cdf0e10cSrcweir
Exchange()549cdf0e10cSrcweir void SwPaM::Exchange()
550cdf0e10cSrcweir {
551cdf0e10cSrcweir if (m_pPoint != m_pMark)
552cdf0e10cSrcweir {
553cdf0e10cSrcweir SwPosition *pTmp = m_pPoint;
554cdf0e10cSrcweir m_pPoint = m_pMark;
555cdf0e10cSrcweir m_pMark = pTmp;
556cdf0e10cSrcweir }
557cdf0e10cSrcweir }
558cdf0e10cSrcweir #endif
559cdf0e10cSrcweir
560cdf0e10cSrcweir // Bewegen des Cursors
561cdf0e10cSrcweir
562cdf0e10cSrcweir
Move(SwMoveFn fnMove,SwGoInDoc fnGo)563cdf0e10cSrcweir sal_Bool SwPaM::Move( SwMoveFn fnMove, SwGoInDoc fnGo )
564cdf0e10cSrcweir {
565cdf0e10cSrcweir sal_Bool bRet = (*fnGo)( *this, fnMove );
566cdf0e10cSrcweir
567cdf0e10cSrcweir m_bIsInFrontOfLabel = false;
568cdf0e10cSrcweir
569cdf0e10cSrcweir return bRet;
570cdf0e10cSrcweir }
571cdf0e10cSrcweir
572cdf0e10cSrcweir
573cdf0e10cSrcweir /*************************************************************************
574cdf0e10cSrcweir |*
575cdf0e10cSrcweir |* void SwPaM::MakeRegion( SwMoveFn, SwPaM*, const SwPaM* )
576cdf0e10cSrcweir |*
577cdf0e10cSrcweir |* Beschreibung Setzt den 1. SwPaM auf den uebergebenen SwPaM
578cdf0e10cSrcweir |* oder setzt auf den Anfang oder Ende vom Document.
579cdf0e10cSrcweir |* SPoint bleibt auf der Position stehen, GetMark aendert
580cdf0e10cSrcweir |* sich entsprechend !
581cdf0e10cSrcweir |*
582cdf0e10cSrcweir |* Parameter SwDirection gibt an, ob an Anfang / Ende
583cdf0e10cSrcweir |* SwPaM * der zu setzende Bereich
584cdf0e10cSrcweir |* const SwPaM& der enventuell vorgegeben Bereich
585cdf0e10cSrcweir |* Return-Werte SwPaM* der entsprehend neu gesetzte Bereich
586cdf0e10cSrcweir |*
587cdf0e10cSrcweir |* Ersterstellung JP 26.04.91
588cdf0e10cSrcweir |* Letzte Aenderung JP 26.04.91
589cdf0e10cSrcweir |*
590cdf0e10cSrcweir *************************************************************************/
591cdf0e10cSrcweir
592cdf0e10cSrcweir
MakeRegion(SwMoveFn fnMove,const SwPaM * pOrigRg)593cdf0e10cSrcweir SwPaM* SwPaM::MakeRegion( SwMoveFn fnMove, const SwPaM * pOrigRg )
594cdf0e10cSrcweir {
595cdf0e10cSrcweir SwPaM* pPam;
596cdf0e10cSrcweir if( pOrigRg == 0 )
597cdf0e10cSrcweir {
598cdf0e10cSrcweir pPam = new SwPaM( *m_pPoint );
599cdf0e10cSrcweir pPam->SetMark(); // setze Anfang fest
600cdf0e10cSrcweir pPam->Move( fnMove, fnGoSection); // an Anfang / Ende vom Node
601cdf0e10cSrcweir
602cdf0e10cSrcweir // stelle SPoint wieder auf alte Position, GetMark auf das "Ende"
603cdf0e10cSrcweir pPam->Exchange();
604cdf0e10cSrcweir }
605cdf0e10cSrcweir else
606cdf0e10cSrcweir {
607cdf0e10cSrcweir pPam = new SwPaM( *(SwPaM*)pOrigRg ); // die Suchregion ist vorgegeben
608cdf0e10cSrcweir // sorge dafuer, dass SPoint auf dem "echten" StartPunkt steht
609cdf0e10cSrcweir // FORWARD --> SPoint immer kleiner als GetMark
610cdf0e10cSrcweir // BACKWARD --> SPoint immer groesser als GetMark
611cdf0e10cSrcweir if( (pPam->GetMark()->*fnMove->fnCmpOp)( *pPam->GetPoint() ) )
612cdf0e10cSrcweir pPam->Exchange();
613cdf0e10cSrcweir }
614cdf0e10cSrcweir return pPam;
615cdf0e10cSrcweir }
616cdf0e10cSrcweir
Normalize(sal_Bool bPointFirst)617cdf0e10cSrcweir SwPaM & SwPaM::Normalize(sal_Bool bPointFirst)
618cdf0e10cSrcweir {
619cdf0e10cSrcweir if (HasMark())
620cdf0e10cSrcweir if ( ( bPointFirst && *m_pPoint > *m_pMark) ||
621cdf0e10cSrcweir (!bPointFirst && *m_pPoint < *m_pMark) )
622cdf0e10cSrcweir {
623cdf0e10cSrcweir Exchange();
624cdf0e10cSrcweir }
625cdf0e10cSrcweir
626cdf0e10cSrcweir return *this;
627cdf0e10cSrcweir }
628cdf0e10cSrcweir
GetPageNum(sal_Bool bAtPoint,const Point * pLayPos)629cdf0e10cSrcweir sal_uInt16 SwPaM::GetPageNum( sal_Bool bAtPoint, const Point* pLayPos )
630cdf0e10cSrcweir {
631cdf0e10cSrcweir // return die Seitennummer am Cursor
632cdf0e10cSrcweir // (fuer Reader + Seitengebundene Rahmen)
633cdf0e10cSrcweir const SwCntntFrm* pCFrm;
634cdf0e10cSrcweir const SwPageFrm *pPg;
635cdf0e10cSrcweir const SwCntntNode *pNd ;
636cdf0e10cSrcweir const SwPosition* pPos = bAtPoint ? m_pPoint : m_pMark;
637cdf0e10cSrcweir
638cdf0e10cSrcweir if( 0 != ( pNd = pPos->nNode.GetNode().GetCntntNode() ) &&
639cdf0e10cSrcweir 0 != ( pCFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout(), pLayPos, pPos, sal_False )) &&
640cdf0e10cSrcweir 0 != ( pPg = pCFrm->FindPageFrm() ))
641cdf0e10cSrcweir return pPg->GetPhyPageNum();
642cdf0e10cSrcweir return 0;
643cdf0e10cSrcweir }
644cdf0e10cSrcweir
645cdf0e10cSrcweir // --> FME 2004-06-29 #114856# Formular view
646cdf0e10cSrcweir // See also SwCrsrShell::IsCrsrReadonly()
lcl_FindEditInReadonlyFrm(const SwFrm & rFrm)647cdf0e10cSrcweir const SwFrm* lcl_FindEditInReadonlyFrm( const SwFrm& rFrm )
648cdf0e10cSrcweir {
649cdf0e10cSrcweir const SwFrm* pRet = 0;
650cdf0e10cSrcweir
651cdf0e10cSrcweir const SwFlyFrm* pFly;
652cdf0e10cSrcweir const SwSectionFrm* pSectionFrm;
653cdf0e10cSrcweir
654cdf0e10cSrcweir if( rFrm.IsInFly() &&
655cdf0e10cSrcweir (pFly = rFrm.FindFlyFrm())->GetFmt()->GetEditInReadonly().GetValue() &&
656cdf0e10cSrcweir pFly->Lower() &&
657cdf0e10cSrcweir !pFly->Lower()->IsNoTxtFrm() )
658cdf0e10cSrcweir {
659cdf0e10cSrcweir pRet = pFly;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir else if ( rFrm.IsInSct() &&
662cdf0e10cSrcweir 0 != ( pSectionFrm = rFrm.FindSctFrm() )->GetSection() &&
663cdf0e10cSrcweir pSectionFrm->GetSection()->IsEditInReadonlyFlag() )
664cdf0e10cSrcweir {
665cdf0e10cSrcweir pRet = pSectionFrm;
666cdf0e10cSrcweir }
667cdf0e10cSrcweir
668cdf0e10cSrcweir return pRet;
669cdf0e10cSrcweir }
670cdf0e10cSrcweir // <--
671cdf0e10cSrcweir
672cdf0e10cSrcweir // steht in etwas geschuetztem oder in die Selektion umspannt
673cdf0e10cSrcweir // etwas geschuetztes.
HasReadonlySel(const bool bFormView) const674*23d8f725SOliver-Rainer Wittmann sal_Bool SwPaM::HasReadonlySel( const bool bFormView ) const
675cdf0e10cSrcweir {
676cdf0e10cSrcweir sal_Bool bRet = sal_False;
677cdf0e10cSrcweir
678*23d8f725SOliver-Rainer Wittmann const SwCntntNode* pNd = GetPoint()->nNode.GetNode().GetCntntNode();
679*23d8f725SOliver-Rainer Wittmann const SwCntntFrm *pFrm = NULL;
680*23d8f725SOliver-Rainer Wittmann if ( pNd != NULL )
681*23d8f725SOliver-Rainer Wittmann {
682*23d8f725SOliver-Rainer Wittmann Point aTmpPt;
683cdf0e10cSrcweir pFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout(), &aTmpPt, GetPoint(), sal_False );
684*23d8f725SOliver-Rainer Wittmann }
685*23d8f725SOliver-Rainer Wittmann
686*23d8f725SOliver-Rainer Wittmann // Will be set if point are inside edit-in-readonly environment
687*23d8f725SOliver-Rainer Wittmann const SwFrm* pPointEditInReadonlyFrm = NULL;
688*23d8f725SOliver-Rainer Wittmann if ( pFrm != NULL
689*23d8f725SOliver-Rainer Wittmann && ( pFrm->IsProtected()
690*23d8f725SOliver-Rainer Wittmann || ( bFormView
691*23d8f725SOliver-Rainer Wittmann && 0 == ( pPointEditInReadonlyFrm = lcl_FindEditInReadonlyFrm( *pFrm ) ) ) ) )
692*23d8f725SOliver-Rainer Wittmann {
693cdf0e10cSrcweir bRet = sal_True;
694*23d8f725SOliver-Rainer Wittmann }
695*23d8f725SOliver-Rainer Wittmann else if( pNd != NULL )
696cdf0e10cSrcweir {
697cdf0e10cSrcweir const SwSectionNode* pSNd = pNd->GetSectionNode();
698*23d8f725SOliver-Rainer Wittmann if ( pSNd != NULL
699*23d8f725SOliver-Rainer Wittmann && ( pSNd->GetSection().IsProtectFlag()
700*23d8f725SOliver-Rainer Wittmann || ( bFormView
701*23d8f725SOliver-Rainer Wittmann && !pSNd->GetSection().IsEditInReadonlyFlag()) ) )
702*23d8f725SOliver-Rainer Wittmann {
703cdf0e10cSrcweir bRet = sal_True;
704*23d8f725SOliver-Rainer Wittmann }
705cdf0e10cSrcweir }
706cdf0e10cSrcweir
707*23d8f725SOliver-Rainer Wittmann if ( !bRet
708*23d8f725SOliver-Rainer Wittmann && HasMark()
709*23d8f725SOliver-Rainer Wittmann && GetPoint()->nNode != GetMark()->nNode )
710cdf0e10cSrcweir {
711*23d8f725SOliver-Rainer Wittmann pNd = GetMark()->nNode.GetNode().GetCntntNode();
712*23d8f725SOliver-Rainer Wittmann pFrm = NULL;
713*23d8f725SOliver-Rainer Wittmann if ( pNd != NULL )
714*23d8f725SOliver-Rainer Wittmann {
715*23d8f725SOliver-Rainer Wittmann Point aTmpPt;
716cdf0e10cSrcweir pFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout(), &aTmpPt, GetMark(), sal_False );
717*23d8f725SOliver-Rainer Wittmann }
718cdf0e10cSrcweir
719*23d8f725SOliver-Rainer Wittmann const SwFrm* pMarkEditInReadonlyFrm = NULL;
720*23d8f725SOliver-Rainer Wittmann if ( pFrm != NULL
721*23d8f725SOliver-Rainer Wittmann && ( pFrm->IsProtected()
722*23d8f725SOliver-Rainer Wittmann || ( bFormView
723*23d8f725SOliver-Rainer Wittmann && 0 == ( pMarkEditInReadonlyFrm = lcl_FindEditInReadonlyFrm( *pFrm ) ) ) ) )
724*23d8f725SOliver-Rainer Wittmann {
725cdf0e10cSrcweir bRet = sal_True;
726*23d8f725SOliver-Rainer Wittmann }
727*23d8f725SOliver-Rainer Wittmann else if( pNd != NULL )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir const SwSectionNode* pSNd = pNd->GetSectionNode();
730*23d8f725SOliver-Rainer Wittmann if ( pSNd != NULL
731*23d8f725SOliver-Rainer Wittmann && ( pSNd->GetSection().IsProtectFlag()
732*23d8f725SOliver-Rainer Wittmann || ( bFormView
733*23d8f725SOliver-Rainer Wittmann && !pSNd->GetSection().IsEditInReadonlyFlag()) ) )
734*23d8f725SOliver-Rainer Wittmann {
735cdf0e10cSrcweir bRet = sal_True;
736*23d8f725SOliver-Rainer Wittmann }
737cdf0e10cSrcweir }
738cdf0e10cSrcweir
739cdf0e10cSrcweir if ( !bRet && bFormView )
740cdf0e10cSrcweir {
741cdf0e10cSrcweir // Check if start and end frame are inside the _same_
742cdf0e10cSrcweir // edit-in-readonly-environment. Otherwise we better return 'true'
743*23d8f725SOliver-Rainer Wittmann if ( pPointEditInReadonlyFrm != pMarkEditInReadonlyFrm )
744cdf0e10cSrcweir bRet = sal_True;
745cdf0e10cSrcweir }
746cdf0e10cSrcweir
747*23d8f725SOliver-Rainer Wittmann // check for protected section inside the selection
748cdf0e10cSrcweir if( !bRet )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir sal_uLong nSttIdx = GetMark()->nNode.GetIndex(),
751cdf0e10cSrcweir nEndIdx = GetPoint()->nNode.GetIndex();
752cdf0e10cSrcweir if( nEndIdx <= nSttIdx )
753cdf0e10cSrcweir {
754cdf0e10cSrcweir sal_uLong nTmp = nSttIdx;
755cdf0e10cSrcweir nSttIdx = nEndIdx;
756cdf0e10cSrcweir nEndIdx = nTmp;
757cdf0e10cSrcweir }
758cdf0e10cSrcweir
759cdf0e10cSrcweir // wenn ein geschuetzter Bereich zwischen den Nodes stehen soll,
760cdf0e10cSrcweir // muss die Selektion selbst schon x Nodes umfassen.
761cdf0e10cSrcweir // (TxtNd, SectNd, TxtNd, EndNd, TxtNd )
762cdf0e10cSrcweir if( nSttIdx + 3 < nEndIdx )
763cdf0e10cSrcweir {
764cdf0e10cSrcweir const SwSectionFmts& rFmts = GetDoc()->GetSections();
765cdf0e10cSrcweir for( sal_uInt16 n = rFmts.Count(); n; )
766cdf0e10cSrcweir {
767cdf0e10cSrcweir const SwSectionFmt* pFmt = rFmts[ --n ];
768cdf0e10cSrcweir if( pFmt->GetProtect().IsCntntProtected() )
769cdf0e10cSrcweir {
770cdf0e10cSrcweir const SwFmtCntnt& rCntnt = pFmt->GetCntnt(sal_False);
771cdf0e10cSrcweir ASSERT( rCntnt.GetCntntIdx(), "wo ist der SectionNode?" );
772cdf0e10cSrcweir sal_uLong nIdx = rCntnt.GetCntntIdx()->GetIndex();
773cdf0e10cSrcweir if( nSttIdx <= nIdx && nEndIdx >= nIdx &&
774cdf0e10cSrcweir rCntnt.GetCntntIdx()->GetNode().GetNodes().IsDocNodes() )
775cdf0e10cSrcweir {
776cdf0e10cSrcweir bRet = sal_True;
777cdf0e10cSrcweir break;
778cdf0e10cSrcweir }
779cdf0e10cSrcweir }
780cdf0e10cSrcweir }
781cdf0e10cSrcweir
782cdf0e10cSrcweir #ifdef CHECK_CELL_READONLY
783cdf0e10cSrcweir //JP 22.01.99: bisher wurden Tabelle, die in der Text-Selektion standen
784cdf0e10cSrcweir // nicht beachtet. Wollte man das haben, dann muss dieser
785cdf0e10cSrcweir // Code freigeschaltet werden
786cdf0e10cSrcweir
787cdf0e10cSrcweir if( !bRet )
788cdf0e10cSrcweir {
789cdf0e10cSrcweir // dann noch ueber alle Tabellen
790cdf0e10cSrcweir const SwFrmFmts& rFmts = *GetDoc()->GetTblFrmFmts();
791cdf0e10cSrcweir for( n = rFmts.Count(); n ; )
792cdf0e10cSrcweir {
793cdf0e10cSrcweir SwFrmFmt* pFmt = (SwFrmFmt*)rFmts[ --n ];
794cdf0e10cSrcweir const SwTable* pTbl = SwTable::FindTable( pFmt );
795cdf0e10cSrcweir sal_uLong nIdx = pTbl ? pTbl->GetTabSortBoxes()[0]->GetSttIdx()
796cdf0e10cSrcweir : 0;
797cdf0e10cSrcweir if( nSttIdx <= nIdx && nEndIdx >= nIdx )
798cdf0e10cSrcweir {
799cdf0e10cSrcweir // dann teste mal alle Boxen
800cdf0e10cSrcweir const SwTableSortBoxes& rBoxes = pTbl->GetTabSortBoxes();
801cdf0e10cSrcweir
802cdf0e10cSrcweir for( sal_uInt16 i = rBoxes.Count(); i; )
803cdf0e10cSrcweir if( rBoxes[ --i ]->GetFrmFmt()->GetProtect().
804cdf0e10cSrcweir IsCntntProtected() )
805cdf0e10cSrcweir {
806cdf0e10cSrcweir bRet = sal_True;
807cdf0e10cSrcweir break;
808cdf0e10cSrcweir }
809cdf0e10cSrcweir
810cdf0e10cSrcweir if( bRet )
811cdf0e10cSrcweir break;
812cdf0e10cSrcweir }
813cdf0e10cSrcweir }
814cdf0e10cSrcweir }
815cdf0e10cSrcweir #endif
816cdf0e10cSrcweir }
817cdf0e10cSrcweir }
818cdf0e10cSrcweir }
819*23d8f725SOliver-Rainer Wittmann
820cdf0e10cSrcweir //FIXME FieldBk
821cdf0e10cSrcweir // TODO: Form Protection when Enhanced Fields are enabled
822*23d8f725SOliver-Rainer Wittmann if (!bRet)
823*23d8f725SOliver-Rainer Wittmann {
824cdf0e10cSrcweir const SwDoc *pDoc = GetDoc();
825cdf0e10cSrcweir sw::mark::IMark* pA = NULL;
826cdf0e10cSrcweir sw::mark::IMark* pB = NULL;
827cdf0e10cSrcweir if ( pDoc )
828cdf0e10cSrcweir {
829cdf0e10cSrcweir const IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess( );
830cdf0e10cSrcweir pA = GetPoint() ? pMarksAccess->getFieldmarkFor( *GetPoint( ) ) : NULL;
831cdf0e10cSrcweir pB = GetMark( ) ? pMarksAccess->getFieldmarkFor( *GetMark( ) ) : pA;
832cdf0e10cSrcweir bRet = ( pA != pB );
833cdf0e10cSrcweir }
834cdf0e10cSrcweir bool bProtectForm = pDoc->get( IDocumentSettingAccess::PROTECT_FORM );
835cdf0e10cSrcweir if ( bProtectForm )
836cdf0e10cSrcweir bRet |= ( pA == NULL || pB == NULL );
837cdf0e10cSrcweir }
838*23d8f725SOliver-Rainer Wittmann
839cdf0e10cSrcweir return bRet;
840cdf0e10cSrcweir }
841cdf0e10cSrcweir
842cdf0e10cSrcweir //-------------------- Suche nach Formaten( FormatNamen ) -----------------
843cdf0e10cSrcweir
844cdf0e10cSrcweir // die Funktion gibt in Suchrichtung den folgenden Node zurueck.
845cdf0e10cSrcweir // Ist in der Richtung keiner mehr vorhanden oder ist dieser ausserhalb
846cdf0e10cSrcweir // des Bereiches, wird ein 0 Pointer returnt.
847cdf0e10cSrcweir // Das rbFirst gibt an, ob es man zu erstenmal einen Node holt. Ist das der
848cdf0e10cSrcweir // Fall, darf die Position vom Pam nicht veraendert werden!
849cdf0e10cSrcweir
850cdf0e10cSrcweir
GetNode(SwPaM & rPam,sal_Bool & rbFirst,SwMoveFn fnMove,sal_Bool bInReadOnly)851cdf0e10cSrcweir SwCntntNode* GetNode( SwPaM & rPam, sal_Bool& rbFirst, SwMoveFn fnMove,
852cdf0e10cSrcweir sal_Bool bInReadOnly )
853cdf0e10cSrcweir {
854cdf0e10cSrcweir SwCntntNode * pNd = 0;
855cdf0e10cSrcweir SwCntntFrm* pFrm;
856cdf0e10cSrcweir if( ((*rPam.GetPoint()).*fnMove->fnCmpOp)( *rPam.GetMark() ) ||
857cdf0e10cSrcweir ( *rPam.GetPoint() == *rPam.GetMark() && rbFirst ) )
858cdf0e10cSrcweir {
859cdf0e10cSrcweir if( rbFirst )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir rbFirst = sal_False;
862cdf0e10cSrcweir pNd = rPam.GetCntntNode();
863cdf0e10cSrcweir if( pNd )
864cdf0e10cSrcweir {
865cdf0e10cSrcweir if(
866cdf0e10cSrcweir (
867cdf0e10cSrcweir 0 == ( pFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout() ) ) ||
868cdf0e10cSrcweir ( !bInReadOnly && pFrm->IsProtected() ) ||
869cdf0e10cSrcweir (pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsHiddenNow())
870cdf0e10cSrcweir ) ||
871cdf0e10cSrcweir ( !bInReadOnly && pNd->FindSectionNode() &&
872cdf0e10cSrcweir pNd->FindSectionNode()->GetSection().IsProtect()
873cdf0e10cSrcweir )
874cdf0e10cSrcweir )
875cdf0e10cSrcweir {
876cdf0e10cSrcweir pNd = 0;
877cdf0e10cSrcweir }
878cdf0e10cSrcweir }
879cdf0e10cSrcweir }
880cdf0e10cSrcweir
881cdf0e10cSrcweir if( !pNd ) // steht Cursor auf keinem ContentNode ?
882cdf0e10cSrcweir {
883cdf0e10cSrcweir SwPosition aPos( *rPam.GetPoint() );
884cdf0e10cSrcweir sal_Bool bSrchForward = fnMove == fnMoveForward;
885cdf0e10cSrcweir SwNodes& rNodes = aPos.nNode.GetNodes();
886cdf0e10cSrcweir
887cdf0e10cSrcweir // zum naechsten / vorherigen ContentNode
888cdf0e10cSrcweir // Funktioniert noch alles, wenn die Uerbpruefung vom ueberspringen der
889cdf0e10cSrcweir // Sektions herausgenommen wird ??
890cdf0e10cSrcweir // if( (*fnMove->fnNds)( rNodes, &aPos.nNode ) )
891cdf0e10cSrcweir while( sal_True )
892cdf0e10cSrcweir {
893cdf0e10cSrcweir pNd = bSrchForward
894cdf0e10cSrcweir ? rNodes.GoNextSection( &aPos.nNode, sal_True, !bInReadOnly )
895cdf0e10cSrcweir : rNodes.GoPrevSection( &aPos.nNode, sal_True, !bInReadOnly );
896cdf0e10cSrcweir if( pNd )
897cdf0e10cSrcweir {
898cdf0e10cSrcweir aPos.nContent.Assign( pNd, ::GetSttOrEnd( bSrchForward,*pNd ));
899cdf0e10cSrcweir // liegt Position immer noch im Bereich ?
900cdf0e10cSrcweir if( (aPos.*fnMove->fnCmpOp)( *rPam.GetMark() ) )
901cdf0e10cSrcweir {
902cdf0e10cSrcweir // nur in der AutoTextSection koennen Node stehen, die
903cdf0e10cSrcweir // nicht angezeigt werden !!
904cdf0e10cSrcweir if( 0 == ( pFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout() ) ) ||
905cdf0e10cSrcweir ( !bInReadOnly && pFrm->IsProtected() ) ||
906cdf0e10cSrcweir ( pFrm->IsTxtFrm() &&
907cdf0e10cSrcweir ((SwTxtFrm*)pFrm)->IsHiddenNow() ) )
908cdf0e10cSrcweir
909cdf0e10cSrcweir // rNodes[ rNodes.EndOfAutotext ]->StartOfSection().GetIndex()
910cdf0e10cSrcweir // < aPos.nNode.GetIndex() && aPos.nNode.GetIndex()
911cdf0e10cSrcweir // < rNodes.EndOfAutotext.GetIndex() &&
912cdf0e10cSrcweir // 0 == ( pFrm = pNd->GetFrm()) &&
913cdf0e10cSrcweir // pFrm->IsProtected() )
914cdf0e10cSrcweir {
915cdf0e10cSrcweir pNd = 0;
916cdf0e10cSrcweir continue; // suche weiter
917cdf0e10cSrcweir }
918cdf0e10cSrcweir *(SwPosition*)rPam.GetPoint() = aPos;
919cdf0e10cSrcweir }
920cdf0e10cSrcweir else
921cdf0e10cSrcweir pNd = 0; // kein gueltiger Node
922cdf0e10cSrcweir break;
923cdf0e10cSrcweir }
924cdf0e10cSrcweir break;
925cdf0e10cSrcweir }
926cdf0e10cSrcweir }
927cdf0e10cSrcweir }
928cdf0e10cSrcweir return pNd;
929cdf0e10cSrcweir }
930cdf0e10cSrcweir
931cdf0e10cSrcweir // ----------------------------------------------------------------------
932cdf0e10cSrcweir
933cdf0e10cSrcweir // hier folgen die Move-Methoden ( Foward, Backward; Content, Node, Doc )
934cdf0e10cSrcweir
935cdf0e10cSrcweir
GoStartDoc(SwPosition * pPos)936cdf0e10cSrcweir void GoStartDoc( SwPosition * pPos )
937cdf0e10cSrcweir {
938cdf0e10cSrcweir SwNodes& rNodes = pPos->nNode.GetNodes();
939cdf0e10cSrcweir pPos->nNode = *rNodes.GetEndOfContent().StartOfSectionNode();
940cdf0e10cSrcweir // es muss immer ein ContentNode gefunden werden !!
941cdf0e10cSrcweir SwCntntNode* pCNd = rNodes.GoNext( &pPos->nNode );
942cdf0e10cSrcweir if( pCNd )
943cdf0e10cSrcweir pCNd->MakeStartIndex( &pPos->nContent );
944cdf0e10cSrcweir }
945cdf0e10cSrcweir
946cdf0e10cSrcweir
GoEndDoc(SwPosition * pPos)947cdf0e10cSrcweir void GoEndDoc( SwPosition * pPos )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir SwNodes& rNodes = pPos->nNode.GetNodes();
950cdf0e10cSrcweir pPos->nNode = rNodes.GetEndOfContent();
951cdf0e10cSrcweir SwCntntNode* pCNd = GoPreviousNds( &pPos->nNode, sal_True );
952cdf0e10cSrcweir if( pCNd )
953cdf0e10cSrcweir pCNd->MakeEndIndex( &pPos->nContent );
954cdf0e10cSrcweir }
955cdf0e10cSrcweir
956cdf0e10cSrcweir
GoStartSection(SwPosition * pPos)957cdf0e10cSrcweir void GoStartSection( SwPosition * pPos )
958cdf0e10cSrcweir {
959cdf0e10cSrcweir // springe zum Anfang der Section
960cdf0e10cSrcweir SwNodes& rNodes = pPos->nNode.GetNodes();
961cdf0e10cSrcweir sal_uInt16 nLevel = rNodes.GetSectionLevel( pPos->nNode );
962cdf0e10cSrcweir if( pPos->nNode < rNodes.GetEndOfContent().StartOfSectionIndex() )
963cdf0e10cSrcweir nLevel--;
964cdf0e10cSrcweir do { rNodes.GoStartOfSection( &pPos->nNode ); } while( nLevel-- );
965cdf0e10cSrcweir
966cdf0e10cSrcweir // steht jetzt schon auf einem CntntNode
967cdf0e10cSrcweir pPos->nNode.GetNode().GetCntntNode()->MakeStartIndex( &pPos->nContent );
968cdf0e10cSrcweir }
969cdf0e10cSrcweir
970cdf0e10cSrcweir // gehe an das Ende der akt. Grund-Section
971cdf0e10cSrcweir
972cdf0e10cSrcweir
GoEndSection(SwPosition * pPos)973cdf0e10cSrcweir void GoEndSection( SwPosition * pPos )
974cdf0e10cSrcweir {
975cdf0e10cSrcweir // springe zum Anfang/Ende der Section
976cdf0e10cSrcweir SwNodes& rNodes = pPos->nNode.GetNodes();
977cdf0e10cSrcweir sal_uInt16 nLevel = rNodes.GetSectionLevel( pPos->nNode );
978cdf0e10cSrcweir if( pPos->nNode < rNodes.GetEndOfContent().StartOfSectionIndex() )
979cdf0e10cSrcweir nLevel--;
980cdf0e10cSrcweir do { rNodes.GoEndOfSection( &pPos->nNode ); } while( nLevel-- );
981cdf0e10cSrcweir
982cdf0e10cSrcweir // steht jetzt auf einem EndNode, also zum vorherigen CntntNode
983cdf0e10cSrcweir if( GoPreviousNds( &pPos->nNode, sal_True ) )
984cdf0e10cSrcweir pPos->nNode.GetNode().GetCntntNode()->MakeEndIndex( &pPos->nContent );
985cdf0e10cSrcweir }
986cdf0e10cSrcweir
987cdf0e10cSrcweir
988cdf0e10cSrcweir
GoInDoc(SwPaM & rPam,SwMoveFn fnMove)989cdf0e10cSrcweir sal_Bool GoInDoc( SwPaM & rPam, SwMoveFn fnMove )
990cdf0e10cSrcweir {
991cdf0e10cSrcweir (*fnMove->fnDoc)( rPam.GetPoint() );
992cdf0e10cSrcweir return sal_True;
993cdf0e10cSrcweir }
994cdf0e10cSrcweir
995cdf0e10cSrcweir
GoInSection(SwPaM & rPam,SwMoveFn fnMove)996cdf0e10cSrcweir sal_Bool GoInSection( SwPaM & rPam, SwMoveFn fnMove )
997cdf0e10cSrcweir {
998cdf0e10cSrcweir (*fnMove->fnSections)( (SwPosition*)rPam.GetPoint() );
999cdf0e10cSrcweir return sal_True;
1000cdf0e10cSrcweir }
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir
GoInNode(SwPaM & rPam,SwMoveFn fnMove)1003cdf0e10cSrcweir sal_Bool GoInNode( SwPaM & rPam, SwMoveFn fnMove )
1004cdf0e10cSrcweir {
1005cdf0e10cSrcweir SwCntntNode *pNd = (*fnMove->fnNds)( &rPam.GetPoint()->nNode, sal_True );
1006cdf0e10cSrcweir if( pNd )
1007cdf0e10cSrcweir rPam.GetPoint()->nContent.Assign( pNd,
1008cdf0e10cSrcweir ::GetSttOrEnd( fnMove == fnMoveForward, *pNd ) );
1009cdf0e10cSrcweir return 0 != pNd;
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir
1012cdf0e10cSrcweir
GoInCntnt(SwPaM & rPam,SwMoveFn fnMove)1013cdf0e10cSrcweir sal_Bool GoInCntnt( SwPaM & rPam, SwMoveFn fnMove )
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir if( (*fnMove->fnNd)( &rPam.GetPoint()->nNode.GetNode(),
1016cdf0e10cSrcweir &rPam.GetPoint()->nContent, CRSR_SKIP_CHARS ))
1017cdf0e10cSrcweir return sal_True;
1018cdf0e10cSrcweir return GoInNode( rPam, fnMove );
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir
GoInCntntCells(SwPaM & rPam,SwMoveFn fnMove)1021cdf0e10cSrcweir sal_Bool GoInCntntCells( SwPaM & rPam, SwMoveFn fnMove )
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir if( (*fnMove->fnNd)( &rPam.GetPoint()->nNode.GetNode(),
1024cdf0e10cSrcweir &rPam.GetPoint()->nContent, CRSR_SKIP_CELLS ))
1025cdf0e10cSrcweir return sal_True;
1026cdf0e10cSrcweir return GoInNode( rPam, fnMove );
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir
GoInCntntSkipHidden(SwPaM & rPam,SwMoveFn fnMove)1029cdf0e10cSrcweir sal_Bool GoInCntntSkipHidden( SwPaM & rPam, SwMoveFn fnMove )
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir if( (*fnMove->fnNd)( &rPam.GetPoint()->nNode.GetNode(),
1032cdf0e10cSrcweir &rPam.GetPoint()->nContent, CRSR_SKIP_CHARS | CRSR_SKIP_HIDDEN ) )
1033cdf0e10cSrcweir return sal_True;
1034cdf0e10cSrcweir return GoInNode( rPam, fnMove );
1035cdf0e10cSrcweir }
1036cdf0e10cSrcweir
GoInCntntCellsSkipHidden(SwPaM & rPam,SwMoveFn fnMove)1037cdf0e10cSrcweir sal_Bool GoInCntntCellsSkipHidden( SwPaM & rPam, SwMoveFn fnMove )
1038cdf0e10cSrcweir {
1039cdf0e10cSrcweir if( (*fnMove->fnNd)( &rPam.GetPoint()->nNode.GetNode(),
1040cdf0e10cSrcweir &rPam.GetPoint()->nContent, CRSR_SKIP_CELLS | CRSR_SKIP_HIDDEN ) )
1041cdf0e10cSrcweir return sal_True;
1042cdf0e10cSrcweir return GoInNode( rPam, fnMove );
1043cdf0e10cSrcweir }
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir // --------- Funktionsdefinitionen fuer die SwCrsrShell --------------
1048cdf0e10cSrcweir
1049cdf0e10cSrcweir
GoPrevPara(SwPaM & rPam,SwPosPara aPosPara)1050cdf0e10cSrcweir sal_Bool GoPrevPara( SwPaM & rPam, SwPosPara aPosPara )
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir if( rPam.Move( fnMoveBackward, fnGoNode ) )
1053cdf0e10cSrcweir {
1054cdf0e10cSrcweir // steht immer auf einem ContentNode !
1055cdf0e10cSrcweir SwPosition& rPos = *rPam.GetPoint();
1056cdf0e10cSrcweir SwCntntNode * pNd = rPos.nNode.GetNode().GetCntntNode();
1057cdf0e10cSrcweir rPos.nContent.Assign( pNd,
1058cdf0e10cSrcweir ::GetSttOrEnd( aPosPara == fnMoveForward, *pNd ) );
1059cdf0e10cSrcweir return sal_True;
1060cdf0e10cSrcweir }
1061cdf0e10cSrcweir return sal_False;
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir
1064cdf0e10cSrcweir
GoCurrPara(SwPaM & rPam,SwPosPara aPosPara)1065cdf0e10cSrcweir sal_Bool GoCurrPara( SwPaM & rPam, SwPosPara aPosPara )
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir SwPosition& rPos = *rPam.GetPoint();
1068cdf0e10cSrcweir SwCntntNode * pNd = rPos.nNode.GetNode().GetCntntNode();
1069cdf0e10cSrcweir if( pNd )
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir xub_StrLen nOld = rPos.nContent.GetIndex(),
1072cdf0e10cSrcweir nNew = aPosPara == fnMoveForward ? 0 : pNd->Len();
1073cdf0e10cSrcweir // stand er schon auf dem Anfang/Ende dann zum naechsten/vorherigen
1074cdf0e10cSrcweir if( nOld != nNew )
1075cdf0e10cSrcweir {
1076cdf0e10cSrcweir rPos.nContent.Assign( pNd, nNew );
1077cdf0e10cSrcweir return sal_True;
1078cdf0e10cSrcweir }
1079cdf0e10cSrcweir }
1080cdf0e10cSrcweir // den Node noch etwas bewegen ( auf den naechsten/vorh. CntntNode)
1081cdf0e10cSrcweir if( ( aPosPara==fnParaStart && 0 != ( pNd =
1082cdf0e10cSrcweir GoPreviousNds( &rPos.nNode, sal_True ))) ||
1083cdf0e10cSrcweir ( aPosPara==fnParaEnd && 0 != ( pNd =
1084cdf0e10cSrcweir GoNextNds( &rPos.nNode, sal_True ))) )
1085cdf0e10cSrcweir {
1086cdf0e10cSrcweir rPos.nContent.Assign( pNd,
1087cdf0e10cSrcweir ::GetSttOrEnd( aPosPara == fnMoveForward, *pNd ));
1088cdf0e10cSrcweir return sal_True;
1089cdf0e10cSrcweir }
1090cdf0e10cSrcweir return sal_False;
1091cdf0e10cSrcweir }
1092cdf0e10cSrcweir
1093cdf0e10cSrcweir
GoNextPara(SwPaM & rPam,SwPosPara aPosPara)1094cdf0e10cSrcweir sal_Bool GoNextPara( SwPaM & rPam, SwPosPara aPosPara )
1095cdf0e10cSrcweir {
1096cdf0e10cSrcweir if( rPam.Move( fnMoveForward, fnGoNode ) )
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir // steht immer auf einem ContentNode !
1099cdf0e10cSrcweir SwPosition& rPos = *rPam.GetPoint();
1100cdf0e10cSrcweir SwCntntNode * pNd = rPos.nNode.GetNode().GetCntntNode();
1101cdf0e10cSrcweir rPos.nContent.Assign( pNd,
1102cdf0e10cSrcweir ::GetSttOrEnd( aPosPara == fnMoveForward, *pNd ) );
1103cdf0e10cSrcweir return sal_True;
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir return sal_False;
1106cdf0e10cSrcweir }
1107cdf0e10cSrcweir
1108cdf0e10cSrcweir
1109cdf0e10cSrcweir
GoCurrSection(SwPaM & rPam,SwMoveFn fnMove)1110cdf0e10cSrcweir sal_Bool GoCurrSection( SwPaM & rPam, SwMoveFn fnMove )
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir SwPosition& rPos = *rPam.GetPoint();
1113cdf0e10cSrcweir SwPosition aSavePos( rPos ); // eine Vergleichsposition
1114cdf0e10cSrcweir SwNodes& rNds = aSavePos.nNode.GetNodes();
1115cdf0e10cSrcweir (rNds.*fnMove->fnSection)( &rPos.nNode );
1116cdf0e10cSrcweir SwCntntNode *pNd;
1117cdf0e10cSrcweir if( 0 == ( pNd = rPos.nNode.GetNode().GetCntntNode()) &&
1118cdf0e10cSrcweir 0 == ( pNd = (*fnMove->fnNds)( &rPos.nNode, sal_True )) )
1119cdf0e10cSrcweir {
1120cdf0e10cSrcweir rPos = aSavePos; // Cusror nicht veraendern
1121cdf0e10cSrcweir return sal_False;
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir
1124cdf0e10cSrcweir rPos.nContent.Assign( pNd,
1125cdf0e10cSrcweir ::GetSttOrEnd( fnMove == fnMoveForward, *pNd ) );
1126cdf0e10cSrcweir return aSavePos != rPos;
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir
1129cdf0e10cSrcweir
GoNextSection(SwPaM & rPam,SwMoveFn fnMove)1130cdf0e10cSrcweir sal_Bool GoNextSection( SwPaM & rPam, SwMoveFn fnMove )
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir SwPosition& rPos = *rPam.GetPoint();
1133cdf0e10cSrcweir SwPosition aSavePos( rPos ); // eine Vergleichsposition
1134cdf0e10cSrcweir SwNodes& rNds = aSavePos.nNode.GetNodes();
1135cdf0e10cSrcweir rNds.GoEndOfSection( &rPos.nNode );
1136cdf0e10cSrcweir
1137cdf0e10cSrcweir // kein weiterer ContentNode vorhanden ?
1138cdf0e10cSrcweir if( !GoInCntnt( rPam, fnMoveForward ) )
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir rPos = aSavePos; // Cusror nicht veraendern
1141cdf0e10cSrcweir return sal_False;
1142cdf0e10cSrcweir }
1143cdf0e10cSrcweir (rNds.*fnMove->fnSection)( &rPos.nNode );
1144cdf0e10cSrcweir SwCntntNode *pNd = rPos.nNode.GetNode().GetCntntNode();
1145cdf0e10cSrcweir rPos.nContent.Assign( pNd,
1146cdf0e10cSrcweir ::GetSttOrEnd( fnMove == fnMoveForward, *pNd ) );
1147cdf0e10cSrcweir return sal_True;
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir
GoPrevSection(SwPaM & rPam,SwMoveFn fnMove)1151cdf0e10cSrcweir sal_Bool GoPrevSection( SwPaM & rPam, SwMoveFn fnMove )
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir SwPosition& rPos = *rPam.GetPoint();
1154cdf0e10cSrcweir SwPosition aSavePos( rPos ); // eine Vergleichsposition
1155cdf0e10cSrcweir SwNodes& rNds = aSavePos.nNode.GetNodes();
1156cdf0e10cSrcweir rNds.GoStartOfSection( &rPos.nNode );
1157cdf0e10cSrcweir
1158cdf0e10cSrcweir // kein weiterer ContentNode vorhanden ?
1159cdf0e10cSrcweir if( !GoInCntnt( rPam, fnMoveBackward ))
1160cdf0e10cSrcweir {
1161cdf0e10cSrcweir rPos = aSavePos; // Cusror nicht veraendern
1162cdf0e10cSrcweir return sal_False;
1163cdf0e10cSrcweir }
1164cdf0e10cSrcweir (rNds.*fnMove->fnSection)( &rPos.nNode );
1165cdf0e10cSrcweir SwCntntNode *pNd = rPos.nNode.GetNode().GetCntntNode();
1166cdf0e10cSrcweir rPos.nContent.Assign( pNd,
1167cdf0e10cSrcweir ::GetSttOrEnd( fnMove == fnMoveForward, *pNd ));
1168cdf0e10cSrcweir return sal_True;
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir
1171cdf0e10cSrcweir // #111827#
GetTxt() const1172cdf0e10cSrcweir String SwPaM::GetTxt() const
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir String aResult;
1175cdf0e10cSrcweir
1176cdf0e10cSrcweir SwNodeIndex aNodeIndex = Start()->nNode;
1177cdf0e10cSrcweir
1178cdf0e10cSrcweir /* The first node can be the end node. A first end node must be
1179cdf0e10cSrcweir handled, too. There fore do ... while and no incrementing of
1180cdf0e10cSrcweir aNodeIndex in the first pass.
1181cdf0e10cSrcweir */
1182cdf0e10cSrcweir bool bFirst = true;
1183cdf0e10cSrcweir do
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir if (! bFirst)
1186cdf0e10cSrcweir {
1187cdf0e10cSrcweir aNodeIndex++;
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir
1190cdf0e10cSrcweir bFirst = false;
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir SwTxtNode * pTxtNode = aNodeIndex.GetNode().GetTxtNode();
1193cdf0e10cSrcweir
1194cdf0e10cSrcweir if (pTxtNode != NULL)
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir const String & aTmpStr = pTxtNode->GetTxt();
1197cdf0e10cSrcweir
1198cdf0e10cSrcweir if (aNodeIndex == Start()->nNode)
1199cdf0e10cSrcweir {
1200cdf0e10cSrcweir xub_StrLen nEnd;
1201cdf0e10cSrcweir if (End()->nNode == aNodeIndex)
1202cdf0e10cSrcweir nEnd = End()->nContent.GetIndex();
1203cdf0e10cSrcweir else
1204cdf0e10cSrcweir nEnd = aTmpStr.Len();
1205cdf0e10cSrcweir
1206cdf0e10cSrcweir aResult += aTmpStr.Copy(Start()->nContent.GetIndex(),
1207cdf0e10cSrcweir nEnd - Start()->nContent.GetIndex()) ;
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir else if (aNodeIndex == End()->nNode)
1210cdf0e10cSrcweir aResult += aTmpStr.Copy(0, End()->nContent.GetIndex());
1211cdf0e10cSrcweir else
1212cdf0e10cSrcweir aResult += aTmpStr;
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir }
1215cdf0e10cSrcweir while (aNodeIndex != End()->nNode);
1216cdf0e10cSrcweir
1217cdf0e10cSrcweir return aResult;
1218cdf0e10cSrcweir }
1219cdf0e10cSrcweir
Overlap(const SwPaM & a,const SwPaM & b)1220cdf0e10cSrcweir sal_Bool SwPaM::Overlap(const SwPaM & a, const SwPaM & b)
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir return !(*b.End() <= *a.Start() || *a.End() <= *b.End());
1223cdf0e10cSrcweir }
1224cdf0e10cSrcweir
InvalidatePaM()1225cdf0e10cSrcweir void SwPaM::InvalidatePaM()
1226cdf0e10cSrcweir {
1227cdf0e10cSrcweir const SwNode *_pNd=this->GetNode();
1228cdf0e10cSrcweir const SwTxtNode *_pTxtNd=(_pNd!=NULL?_pNd->GetTxtNode():NULL);
1229cdf0e10cSrcweir if (_pTxtNd!=NULL)
1230cdf0e10cSrcweir {
1231cdf0e10cSrcweir // pretent that the PaM marks inserted text to recalc the portion...
1232cdf0e10cSrcweir SwInsTxt aHint( Start()->nContent.GetIndex(),
1233cdf0e10cSrcweir End()->nContent.GetIndex() - Start()->nContent.GetIndex() + 1 );
1234cdf0e10cSrcweir SwModify *_pModify=(SwModify*)_pTxtNd;
1235cdf0e10cSrcweir _pModify->ModifyNotification( 0, &aHint);
1236cdf0e10cSrcweir }
1237cdf0e10cSrcweir }
1238cdf0e10cSrcweir
LessThan(const SwPaM & a,const SwPaM & b)1239cdf0e10cSrcweir sal_Bool SwPaM::LessThan(const SwPaM & a, const SwPaM & b)
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir return (*a.Start() < *b.Start()) || (*a.Start() == *b.Start() && *a.End() < *b.End());
1242cdf0e10cSrcweir }
1243