1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10*efeef26fSAndrew Rist *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19*efeef26fSAndrew Rist *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <sfx2/bindings.hxx>
29cdf0e10cSrcweir #include <wrtsh.hxx>
30cdf0e10cSrcweir #ifndef _VIEW_HXX
31cdf0e10cSrcweir #include <view.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #include <viewopt.hxx>
34cdf0e10cSrcweir #include <crsskip.hxx>
35cdf0e10cSrcweir
36cdf0e10cSrcweir /* Immer:
37cdf0e10cSrcweir - Zuruecksetzen des Cursorstacks
38cdf0e10cSrcweir - Timer nachtriggern
39cdf0e10cSrcweir - gfs. GCAttr
40cdf0e10cSrcweir
41cdf0e10cSrcweir bei Selektion
42cdf0e10cSrcweir - SttSelect()
43cdf0e10cSrcweir
44cdf0e10cSrcweir sonst
45cdf0e10cSrcweir - EndSelect()
46cdf0e10cSrcweir */
47cdf0e10cSrcweir
48cdf0e10cSrcweir const long nReadOnlyScrollOfst = 10;
49cdf0e10cSrcweir
50cdf0e10cSrcweir class ShellMoveCrsr
51cdf0e10cSrcweir {
52cdf0e10cSrcweir SwWrtShell* pSh;
53cdf0e10cSrcweir sal_Bool bAct;
54cdf0e10cSrcweir public:
ShellMoveCrsr(SwWrtShell * pWrtSh,sal_Bool bSel)55cdf0e10cSrcweir inline ShellMoveCrsr( SwWrtShell* pWrtSh, sal_Bool bSel )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir bAct = !pWrtSh->ActionPend() && (pWrtSh->GetFrmType(0,sal_False) & FRMTYPE_FLY_ANY);
58cdf0e10cSrcweir ( pSh = pWrtSh )->MoveCrsr( sal_Bool(bSel) );
59cdf0e10cSrcweir pWrtSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_HYPERLINK_GETLINK);
60cdf0e10cSrcweir }
~ShellMoveCrsr()61cdf0e10cSrcweir inline ~ShellMoveCrsr()
62cdf0e10cSrcweir {
63cdf0e10cSrcweir if( bAct )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir //Die Action wird fuer das Scrollen in "einabsaetzigen" Rahmen mit
66cdf0e10cSrcweir //fester Hoehe gebraucht.
67cdf0e10cSrcweir pSh->StartAllAction();
68cdf0e10cSrcweir pSh->EndAllAction();
69cdf0e10cSrcweir }
70cdf0e10cSrcweir }
71cdf0e10cSrcweir };
72cdf0e10cSrcweir
MoveCrsr(sal_Bool bWithSelect)73cdf0e10cSrcweir void SwWrtShell::MoveCrsr( sal_Bool bWithSelect )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir ResetCursorStack();
76cdf0e10cSrcweir if ( IsGCAttr() )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir GCAttr();
79cdf0e10cSrcweir ClearGCAttr();
80cdf0e10cSrcweir }
81cdf0e10cSrcweir if ( bWithSelect )
82cdf0e10cSrcweir SttSelect();
83cdf0e10cSrcweir else
84cdf0e10cSrcweir {
85cdf0e10cSrcweir EndSelect();
86cdf0e10cSrcweir (this->*fnKillSel)( 0, sal_False );
87cdf0e10cSrcweir }
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
SimpleMove(FNSimpleMove FnSimpleMove,sal_Bool bSelect)90cdf0e10cSrcweir sal_Bool SwWrtShell::SimpleMove( FNSimpleMove FnSimpleMove, sal_Bool bSelect )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir sal_Bool nRet;
93cdf0e10cSrcweir if( bSelect )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir SttCrsrMove();
96cdf0e10cSrcweir MoveCrsr( sal_True );
97cdf0e10cSrcweir nRet = (this->*FnSimpleMove)();
98cdf0e10cSrcweir EndCrsrMove();
99cdf0e10cSrcweir }
100cdf0e10cSrcweir else if( 0 != ( nRet = (this->*FnSimpleMove)() ) )
101cdf0e10cSrcweir MoveCrsr( sal_False );
102cdf0e10cSrcweir return nRet;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
105cdf0e10cSrcweir
Left(sal_uInt16 nMode,sal_Bool bSelect,sal_uInt16 nCount,sal_Bool bBasicCall,sal_Bool bVisual)106cdf0e10cSrcweir sal_Bool SwWrtShell::Left( sal_uInt16 nMode, sal_Bool bSelect,
107cdf0e10cSrcweir sal_uInt16 nCount, sal_Bool bBasicCall, sal_Bool bVisual )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly())
110cdf0e10cSrcweir {
111cdf0e10cSrcweir Point aTmp( VisArea().Pos() );
112cdf0e10cSrcweir aTmp.X() -= VisArea().Width() * nReadOnlyScrollOfst / 100;
113cdf0e10cSrcweir rView.SetVisArea( aTmp );
114cdf0e10cSrcweir return sal_True;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir else
117cdf0e10cSrcweir {
118cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
119cdf0e10cSrcweir return SwCrsrShell::Left( nCount, nMode, bVisual );
120cdf0e10cSrcweir }
121cdf0e10cSrcweir }
122cdf0e10cSrcweir
123cdf0e10cSrcweir
124cdf0e10cSrcweir
Right(sal_uInt16 nMode,sal_Bool bSelect,sal_uInt16 nCount,sal_Bool bBasicCall,sal_Bool bVisual)125cdf0e10cSrcweir sal_Bool SwWrtShell::Right( sal_uInt16 nMode, sal_Bool bSelect,
126cdf0e10cSrcweir sal_uInt16 nCount, sal_Bool bBasicCall, sal_Bool bVisual )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly() )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir Point aTmp( VisArea().Pos() );
131cdf0e10cSrcweir aTmp.X() += VisArea().Width() * nReadOnlyScrollOfst / 100;
132cdf0e10cSrcweir aTmp.X() = rView.SetHScrollMax( aTmp.X() );
133cdf0e10cSrcweir rView.SetVisArea( aTmp );
134cdf0e10cSrcweir return sal_True;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir else
137cdf0e10cSrcweir {
138cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
139cdf0e10cSrcweir return SwCrsrShell::Right( nCount, nMode, bVisual );
140cdf0e10cSrcweir }
141cdf0e10cSrcweir }
142cdf0e10cSrcweir
143cdf0e10cSrcweir
144cdf0e10cSrcweir
Up(sal_Bool bSelect,sal_uInt16 nCount,sal_Bool bBasicCall)145cdf0e10cSrcweir sal_Bool SwWrtShell::Up( sal_Bool bSelect, sal_uInt16 nCount, sal_Bool bBasicCall )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly())
148cdf0e10cSrcweir {
149cdf0e10cSrcweir Point aTmp( VisArea().Pos() );
150cdf0e10cSrcweir aTmp.Y() -= VisArea().Height() * nReadOnlyScrollOfst / 100;
151cdf0e10cSrcweir rView.SetVisArea( aTmp );
152cdf0e10cSrcweir return sal_True;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir else
155cdf0e10cSrcweir {
156cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
157cdf0e10cSrcweir return SwCrsrShell::Up( nCount );
158cdf0e10cSrcweir }
159cdf0e10cSrcweir }
160cdf0e10cSrcweir
161cdf0e10cSrcweir
162cdf0e10cSrcweir
Down(sal_Bool bSelect,sal_uInt16 nCount,sal_Bool bBasicCall)163cdf0e10cSrcweir sal_Bool SwWrtShell::Down( sal_Bool bSelect, sal_uInt16 nCount, sal_Bool bBasicCall )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() && !GetViewOptions()->IsSelectionInReadonly())
166cdf0e10cSrcweir {
167cdf0e10cSrcweir Point aTmp( VisArea().Pos() );
168cdf0e10cSrcweir aTmp.Y() += VisArea().Height() * nReadOnlyScrollOfst / 100;
169cdf0e10cSrcweir aTmp.Y() = rView.SetVScrollMax( aTmp.Y() );
170cdf0e10cSrcweir rView.SetVisArea( aTmp );
171cdf0e10cSrcweir return sal_True;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir else
174cdf0e10cSrcweir {
175cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
176cdf0e10cSrcweir return SwCrsrShell::Down( nCount );
177cdf0e10cSrcweir }
178cdf0e10cSrcweir }
179cdf0e10cSrcweir
180cdf0e10cSrcweir
181cdf0e10cSrcweir
LeftMargin(sal_Bool bSelect,sal_Bool bBasicCall)182cdf0e10cSrcweir sal_Bool SwWrtShell::LeftMargin( sal_Bool bSelect, sal_Bool bBasicCall )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir Point aTmp( VisArea().Pos() );
187cdf0e10cSrcweir aTmp.X() = DOCUMENTBORDER;
188cdf0e10cSrcweir rView.SetVisArea( aTmp );
189cdf0e10cSrcweir return sal_True;
190cdf0e10cSrcweir }
191cdf0e10cSrcweir else
192cdf0e10cSrcweir {
193cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
194cdf0e10cSrcweir return SwCrsrShell::LeftMargin();
195cdf0e10cSrcweir }
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir
199cdf0e10cSrcweir
RightMargin(sal_Bool bSelect,sal_Bool bBasicCall)200cdf0e10cSrcweir sal_Bool SwWrtShell::RightMargin( sal_Bool bSelect, sal_Bool bBasicCall )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir if ( !bSelect && !bBasicCall && IsCrsrReadonly() )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir Point aTmp( VisArea().Pos() );
205cdf0e10cSrcweir aTmp.X() = GetDocSize().Width() - VisArea().Width() + DOCUMENTBORDER;
206cdf0e10cSrcweir if( DOCUMENTBORDER > aTmp.X() )
207cdf0e10cSrcweir aTmp.X() = DOCUMENTBORDER;
208cdf0e10cSrcweir rView.SetVisArea( aTmp );
209cdf0e10cSrcweir return sal_True;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir else
212cdf0e10cSrcweir {
213cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
214cdf0e10cSrcweir return SwCrsrShell::RightMargin(bBasicCall);
215cdf0e10cSrcweir }
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
218cdf0e10cSrcweir
219cdf0e10cSrcweir
GoStart(sal_Bool bKeepArea,sal_Bool * pMoveTable,sal_Bool bSelect,sal_Bool bDontMoveRegion)220cdf0e10cSrcweir sal_Bool SwWrtShell::GoStart( sal_Bool bKeepArea, sal_Bool *pMoveTable,
221cdf0e10cSrcweir sal_Bool bSelect, sal_Bool bDontMoveRegion )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir if ( IsCrsrInTbl() )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir const sal_Bool bBoxSelection = HasBoxSelection();
226cdf0e10cSrcweir if( !bBlockMode )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir if ( !bSelect )
229cdf0e10cSrcweir EnterStdMode();
230cdf0e10cSrcweir else
231cdf0e10cSrcweir SttSelect();
232cdf0e10cSrcweir }
233cdf0e10cSrcweir // Tabellenzelle?
234cdf0e10cSrcweir if ( !bBoxSelection && (MoveSection( fnSectionCurr, fnSectionStart)
235cdf0e10cSrcweir || bDontMoveRegion))
236cdf0e10cSrcweir {
237cdf0e10cSrcweir if ( pMoveTable )
238cdf0e10cSrcweir *pMoveTable = sal_False;
239cdf0e10cSrcweir return sal_True;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir if( MoveTable( fnTableCurr, fnTableStart ) || bDontMoveRegion )
242cdf0e10cSrcweir {
243cdf0e10cSrcweir if ( pMoveTable )
244cdf0e10cSrcweir *pMoveTable = sal_True;
245cdf0e10cSrcweir return sal_True;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir else if( bBoxSelection && pMoveTable )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir // JP 09.01.96: wir haben eine Boxselektion (oder leere Zelle)
250cdf0e10cSrcweir // und wollen selektieren (pMoveTable wird im
251cdf0e10cSrcweir // SelAll gesetzt). Dann darf die Tabelle nicht
252cdf0e10cSrcweir // verlassen werden; sonst ist keine Selektion der
253cdf0e10cSrcweir // gesamten Tabelle moeglich!
254cdf0e10cSrcweir *pMoveTable = sal_True;
255cdf0e10cSrcweir return sal_True;
256cdf0e10cSrcweir }
257cdf0e10cSrcweir }
258cdf0e10cSrcweir
259cdf0e10cSrcweir if( !bBlockMode )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir if ( !bSelect )
262cdf0e10cSrcweir EnterStdMode();
263cdf0e10cSrcweir else
264cdf0e10cSrcweir SttSelect();
265cdf0e10cSrcweir }
266cdf0e10cSrcweir const sal_uInt16 nFrmType = GetFrmType(0,sal_False);
267cdf0e10cSrcweir if ( FRMTYPE_FLY_ANY & nFrmType )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir if( MoveSection( fnSectionCurr, fnSectionStart ) )
270cdf0e10cSrcweir return sal_True;
271cdf0e10cSrcweir else if ( FRMTYPE_FLY_FREE & nFrmType || bDontMoveRegion )
272cdf0e10cSrcweir return sal_False;
273cdf0e10cSrcweir }
274cdf0e10cSrcweir if(( FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FOOTNOTE ) & nFrmType )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir if ( MoveSection( fnSectionCurr, fnSectionStart ) )
277cdf0e10cSrcweir return sal_True;
278cdf0e10cSrcweir else if ( bKeepArea )
279cdf0e10cSrcweir return sal_True;
280cdf0e10cSrcweir }
281cdf0e10cSrcweir // Bereiche ???
282cdf0e10cSrcweir return SwCrsrShell::MoveRegion( fnRegionCurrAndSkip, fnRegionStart ) ||
283cdf0e10cSrcweir SwCrsrShell::SttEndDoc(sal_True);
284cdf0e10cSrcweir }
285cdf0e10cSrcweir
286cdf0e10cSrcweir
287cdf0e10cSrcweir
GoEnd(sal_Bool bKeepArea,sal_Bool * pMoveTable)288cdf0e10cSrcweir sal_Bool SwWrtShell::GoEnd(sal_Bool bKeepArea, sal_Bool *pMoveTable)
289cdf0e10cSrcweir {
290cdf0e10cSrcweir if ( pMoveTable && *pMoveTable )
291cdf0e10cSrcweir return MoveTable( fnTableCurr, fnTableEnd );
292cdf0e10cSrcweir
293cdf0e10cSrcweir if ( IsCrsrInTbl() )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir if ( MoveSection( fnSectionCurr, fnSectionEnd ) ||
296cdf0e10cSrcweir MoveTable( fnTableCurr, fnTableEnd ) )
297cdf0e10cSrcweir return sal_True;
298cdf0e10cSrcweir }
299cdf0e10cSrcweir else
300cdf0e10cSrcweir {
301cdf0e10cSrcweir const sal_uInt16 nFrmType = GetFrmType(0,sal_False);
302cdf0e10cSrcweir if ( FRMTYPE_FLY_ANY & nFrmType )
303cdf0e10cSrcweir {
304cdf0e10cSrcweir if ( MoveSection( fnSectionCurr, fnSectionEnd ) )
305cdf0e10cSrcweir return sal_True;
306cdf0e10cSrcweir else if ( FRMTYPE_FLY_FREE & nFrmType )
307cdf0e10cSrcweir return sal_False;
308cdf0e10cSrcweir }
309cdf0e10cSrcweir if(( FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FOOTNOTE ) & nFrmType )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir if ( MoveSection( fnSectionCurr, fnSectionEnd) )
312cdf0e10cSrcweir return sal_True;
313cdf0e10cSrcweir else if ( bKeepArea )
314cdf0e10cSrcweir return sal_True;
315cdf0e10cSrcweir }
316cdf0e10cSrcweir }
317cdf0e10cSrcweir // Bereiche ???
318cdf0e10cSrcweir return SwCrsrShell::MoveRegion( fnRegionCurrAndSkip, fnRegionEnd ) ||
319cdf0e10cSrcweir SwCrsrShell::SttEndDoc(sal_False);
320cdf0e10cSrcweir }
321cdf0e10cSrcweir
322cdf0e10cSrcweir
323cdf0e10cSrcweir
SttDoc(sal_Bool bSelect)324cdf0e10cSrcweir sal_Bool SwWrtShell::SttDoc( sal_Bool bSelect )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
327cdf0e10cSrcweir return GoStart(sal_False, 0, bSelect );
328cdf0e10cSrcweir }
329cdf0e10cSrcweir
330cdf0e10cSrcweir
331cdf0e10cSrcweir
EndDoc(sal_Bool bSelect)332cdf0e10cSrcweir sal_Bool SwWrtShell::EndDoc( sal_Bool bSelect)
333cdf0e10cSrcweir {
334cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
335cdf0e10cSrcweir return GoEnd();
336cdf0e10cSrcweir }
337cdf0e10cSrcweir
338cdf0e10cSrcweir
SttNxtPg(sal_Bool bSelect)339cdf0e10cSrcweir sal_Bool SwWrtShell::SttNxtPg( sal_Bool bSelect )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
342cdf0e10cSrcweir return MovePage( fnPageNext, fnPageStart );
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
345cdf0e10cSrcweir
346cdf0e10cSrcweir
SttPrvPg(sal_Bool bSelect)347cdf0e10cSrcweir sal_Bool SwWrtShell::SttPrvPg( sal_Bool bSelect )
348cdf0e10cSrcweir {
349cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
350cdf0e10cSrcweir return MovePage( fnPagePrev, fnPageStart );
351cdf0e10cSrcweir }
352cdf0e10cSrcweir
353cdf0e10cSrcweir
354cdf0e10cSrcweir
EndNxtPg(sal_Bool bSelect)355cdf0e10cSrcweir sal_Bool SwWrtShell::EndNxtPg( sal_Bool bSelect )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
358cdf0e10cSrcweir return MovePage( fnPageNext, fnPageEnd );
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
361cdf0e10cSrcweir
362cdf0e10cSrcweir
EndPrvPg(sal_Bool bSelect)363cdf0e10cSrcweir sal_Bool SwWrtShell::EndPrvPg( sal_Bool bSelect )
364cdf0e10cSrcweir {
365cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
366cdf0e10cSrcweir return MovePage( fnPagePrev, fnPageEnd );
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
369cdf0e10cSrcweir
370cdf0e10cSrcweir
SttPg(sal_Bool bSelect)371cdf0e10cSrcweir sal_Bool SwWrtShell::SttPg( sal_Bool bSelect )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
374cdf0e10cSrcweir return MovePage( fnPageCurr, fnPageStart );
375cdf0e10cSrcweir }
376cdf0e10cSrcweir
377cdf0e10cSrcweir
378cdf0e10cSrcweir
EndPg(sal_Bool bSelect)379cdf0e10cSrcweir sal_Bool SwWrtShell::EndPg( sal_Bool bSelect )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
382cdf0e10cSrcweir return MovePage( fnPageCurr, fnPageEnd );
383cdf0e10cSrcweir }
384cdf0e10cSrcweir
385cdf0e10cSrcweir
386cdf0e10cSrcweir
SttPara(sal_Bool bSelect)387cdf0e10cSrcweir sal_Bool SwWrtShell::SttPara( sal_Bool bSelect )
388cdf0e10cSrcweir {
389cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
390cdf0e10cSrcweir return MovePara( fnParaCurr, fnParaStart );
391cdf0e10cSrcweir }
392cdf0e10cSrcweir
393cdf0e10cSrcweir
394cdf0e10cSrcweir
EndPara(sal_Bool bSelect)395cdf0e10cSrcweir sal_Bool SwWrtShell::EndPara( sal_Bool bSelect )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
398cdf0e10cSrcweir return MovePara(fnParaCurr,fnParaEnd);
399cdf0e10cSrcweir }
400cdf0e10cSrcweir
401cdf0e10cSrcweir
402cdf0e10cSrcweir /*------------------------------------------------------------------------
403cdf0e10cSrcweir Beschreibung: Spaltenweises Springen
404cdf0e10cSrcweir Parameter: mit oder ohne SSelection
405cdf0e10cSrcweir Return: Erfolg oder Misserfolg
406cdf0e10cSrcweir ------------------------------------------------------------------------*/
407cdf0e10cSrcweir
408cdf0e10cSrcweir
409cdf0e10cSrcweir
StartOfColumn(sal_Bool bSelect)410cdf0e10cSrcweir sal_Bool SwWrtShell::StartOfColumn( sal_Bool bSelect )
411cdf0e10cSrcweir {
412cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect);
413cdf0e10cSrcweir return MoveColumn(fnColumnCurr, fnColumnStart);
414cdf0e10cSrcweir }
415cdf0e10cSrcweir
416cdf0e10cSrcweir
417cdf0e10cSrcweir
EndOfColumn(sal_Bool bSelect)418cdf0e10cSrcweir sal_Bool SwWrtShell::EndOfColumn( sal_Bool bSelect )
419cdf0e10cSrcweir {
420cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect);
421cdf0e10cSrcweir return MoveColumn(fnColumnCurr, fnColumnEnd);
422cdf0e10cSrcweir }
423cdf0e10cSrcweir
424cdf0e10cSrcweir
425cdf0e10cSrcweir
StartOfNextColumn(sal_Bool bSelect)426cdf0e10cSrcweir sal_Bool SwWrtShell::StartOfNextColumn( sal_Bool bSelect )
427cdf0e10cSrcweir {
428cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect);
429cdf0e10cSrcweir return MoveColumn( fnColumnNext, fnColumnStart);
430cdf0e10cSrcweir }
431cdf0e10cSrcweir
432cdf0e10cSrcweir
433cdf0e10cSrcweir
EndOfNextColumn(sal_Bool bSelect)434cdf0e10cSrcweir sal_Bool SwWrtShell::EndOfNextColumn( sal_Bool bSelect )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect);
437cdf0e10cSrcweir return MoveColumn(fnColumnNext, fnColumnEnd);
438cdf0e10cSrcweir }
439cdf0e10cSrcweir
440cdf0e10cSrcweir
441cdf0e10cSrcweir
StartOfPrevColumn(sal_Bool bSelect)442cdf0e10cSrcweir sal_Bool SwWrtShell::StartOfPrevColumn( sal_Bool bSelect )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect);
445cdf0e10cSrcweir return MoveColumn(fnColumnPrev, fnColumnStart);
446cdf0e10cSrcweir }
447cdf0e10cSrcweir
448cdf0e10cSrcweir
449cdf0e10cSrcweir
EndOfPrevColumn(sal_Bool bSelect)450cdf0e10cSrcweir sal_Bool SwWrtShell::EndOfPrevColumn( sal_Bool bSelect )
451cdf0e10cSrcweir {
452cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect);
453cdf0e10cSrcweir return MoveColumn(fnColumnPrev, fnColumnEnd);
454cdf0e10cSrcweir }
455cdf0e10cSrcweir
456cdf0e10cSrcweir
457cdf0e10cSrcweir
PushCrsr(SwTwips lOffset,sal_Bool bSelect)458cdf0e10cSrcweir sal_Bool SwWrtShell::PushCrsr(SwTwips lOffset, sal_Bool bSelect)
459cdf0e10cSrcweir {
460cdf0e10cSrcweir sal_Bool bDiff = sal_False;
461cdf0e10cSrcweir SwRect aOldRect( GetCharRect() ), aTmpArea( VisArea() );
462cdf0e10cSrcweir
463cdf0e10cSrcweir //bDestOnStack besagt, ob ich den Cursor nicht an die aktuelle Position
464cdf0e10cSrcweir //setzen konnte, da in diesem Bereich kein Inhalt vorhanden ist.
465cdf0e10cSrcweir if( !bDestOnStack )
466cdf0e10cSrcweir {
467cdf0e10cSrcweir Point aPt( aOldRect.Center() );
468cdf0e10cSrcweir
469cdf0e10cSrcweir if( !IsCrsrVisible() )
470cdf0e10cSrcweir // set CrsrPos to top-/bottom left pos. So the pagescroll is not
471cdf0e10cSrcweir // be dependent on the current cursor, but on the visarea.
472cdf0e10cSrcweir aPt.Y() = aTmpArea.Top() + aTmpArea.Height() / 2;
473cdf0e10cSrcweir
474cdf0e10cSrcweir aPt.Y() += lOffset;
475cdf0e10cSrcweir aDest = GetCntntPos(aPt,lOffset > 0);
476cdf0e10cSrcweir aDest.X() = aPt.X();
477cdf0e10cSrcweir bDestOnStack = sal_True;
478cdf0e10cSrcweir }
479cdf0e10cSrcweir
480cdf0e10cSrcweir //falls wir eine Rahmenselektion hatten, muss diese nach dem
481cdf0e10cSrcweir //fnSetCrsr entfernt werden und damit wir da wieder hinkommen
482cdf0e10cSrcweir //auf dem Stack gemerkt werden.
483cdf0e10cSrcweir sal_Bool bIsFrmSel = sal_False;
484cdf0e10cSrcweir
485cdf0e10cSrcweir sal_Bool bIsObjSel = sal_False;
486cdf0e10cSrcweir
487cdf0e10cSrcweir //Zielposition liegt jetzt innerhalb des sichtbaren Bereiches -->
488cdf0e10cSrcweir //Cursor an die Zielposition setzen; merken, dass keine Ziel-
489cdf0e10cSrcweir //position mehr auf dem Stack steht.
490cdf0e10cSrcweir //Der neue sichtbare Bereich wird zuvor ermittelt.
491cdf0e10cSrcweir aTmpArea.Pos().Y() += lOffset;
492cdf0e10cSrcweir if( aTmpArea.IsInside(aDest) )
493cdf0e10cSrcweir {
494cdf0e10cSrcweir if( bSelect )
495cdf0e10cSrcweir SttSelect();
496cdf0e10cSrcweir else
497cdf0e10cSrcweir EndSelect();
498cdf0e10cSrcweir
499cdf0e10cSrcweir bIsFrmSel = IsFrmSelected();
500cdf0e10cSrcweir bIsObjSel = 0 != IsObjSelected();
501cdf0e10cSrcweir
502cdf0e10cSrcweir // Rahmenselektion aufheben
503cdf0e10cSrcweir if( bIsFrmSel || bIsObjSel )
504cdf0e10cSrcweir {
505cdf0e10cSrcweir UnSelectFrm();
506cdf0e10cSrcweir LeaveSelFrmMode();
507cdf0e10cSrcweir if ( bIsObjSel )
508cdf0e10cSrcweir {
509cdf0e10cSrcweir GetView().SetDrawFuncPtr( NULL );
510cdf0e10cSrcweir GetView().LeaveDrawCreate();
511cdf0e10cSrcweir }
512cdf0e10cSrcweir
513cdf0e10cSrcweir CallChgLnk();
514cdf0e10cSrcweir }
515cdf0e10cSrcweir
516cdf0e10cSrcweir (this->*fnSetCrsr)( &aDest, sal_True );
517cdf0e10cSrcweir
518cdf0e10cSrcweir bDiff = aOldRect != GetCharRect();
519cdf0e10cSrcweir
520cdf0e10cSrcweir if( bIsFrmSel )
521cdf0e10cSrcweir {
522cdf0e10cSrcweir // CallChgLnk();
523cdf0e10cSrcweir // bei Frames immer nur die obere Ecke nehmen, damit dieser
524cdf0e10cSrcweir // wieder selektiert werden kann
525cdf0e10cSrcweir aOldRect.SSize( 5, 5 );
526cdf0e10cSrcweir }
527cdf0e10cSrcweir
528cdf0e10cSrcweir // Zuruecksetzen des Dest. SPoint Flags
529cdf0e10cSrcweir bDestOnStack = sal_False;
530cdf0e10cSrcweir }
531cdf0e10cSrcweir
532cdf0e10cSrcweir // Position auf den Stack; bDiff besagt, ob ein Unterschied zwischen
533cdf0e10cSrcweir // der alten und der neuen Cursorposition besteht.
534cdf0e10cSrcweir pCrsrStack = new CrsrStack( bDiff, bIsFrmSel, aOldRect.Center(),
535cdf0e10cSrcweir lOffset, pCrsrStack );
536cdf0e10cSrcweir return !bDestOnStack && bDiff;
537cdf0e10cSrcweir }
538cdf0e10cSrcweir
539cdf0e10cSrcweir
540cdf0e10cSrcweir
PopCrsr(sal_Bool bUpdate,sal_Bool bSelect)541cdf0e10cSrcweir sal_Bool SwWrtShell::PopCrsr(sal_Bool bUpdate, sal_Bool bSelect)
542cdf0e10cSrcweir {
543cdf0e10cSrcweir if( 0 == pCrsrStack)
544cdf0e10cSrcweir return sal_False;
545cdf0e10cSrcweir
546cdf0e10cSrcweir const sal_Bool bValidPos = pCrsrStack->bValidCurPos;
547cdf0e10cSrcweir if( bUpdate && bValidPos )
548cdf0e10cSrcweir {
549cdf0e10cSrcweir // falls ein Vorgaenger auf dem Stack steht, dessen Flag fuer eine
550cdf0e10cSrcweir // gueltige Position verwenden.
551cdf0e10cSrcweir SwRect aTmpArea(VisArea());
552cdf0e10cSrcweir aTmpArea.Pos().Y() -= pCrsrStack->lOffset;
553cdf0e10cSrcweir if( aTmpArea.IsInside( pCrsrStack->aDocPos ) )
554cdf0e10cSrcweir {
555cdf0e10cSrcweir if( bSelect )
556cdf0e10cSrcweir SttSelect();
557cdf0e10cSrcweir else
558cdf0e10cSrcweir EndSelect();
559cdf0e10cSrcweir
560cdf0e10cSrcweir (this->*fnSetCrsr)(&pCrsrStack->aDocPos, !pCrsrStack->bIsFrmSel);
561cdf0e10cSrcweir if( pCrsrStack->bIsFrmSel && IsObjSelectable(pCrsrStack->aDocPos))
562cdf0e10cSrcweir {
563cdf0e10cSrcweir HideCrsr();
564cdf0e10cSrcweir SelectObj( pCrsrStack->aDocPos );
565cdf0e10cSrcweir EnterSelFrmMode( &pCrsrStack->aDocPos );
566cdf0e10cSrcweir }
567cdf0e10cSrcweir }
568cdf0e10cSrcweir // Falls eine Verschiebung zwischen dem sichtbaren Bereich
569cdf0e10cSrcweir // und der gemerkten Cursorpositionen auftritt, werden
570cdf0e10cSrcweir // alle gemerkten Positionen weggeschmissen
571cdf0e10cSrcweir else
572cdf0e10cSrcweir {
573cdf0e10cSrcweir _ResetCursorStack();
574cdf0e10cSrcweir return sal_False;
575cdf0e10cSrcweir }
576cdf0e10cSrcweir }
577cdf0e10cSrcweir CrsrStack *pTmp = pCrsrStack;
578cdf0e10cSrcweir pCrsrStack = pCrsrStack->pNext;
579cdf0e10cSrcweir delete pTmp;
580cdf0e10cSrcweir if( 0 == pCrsrStack )
581cdf0e10cSrcweir {
582cdf0e10cSrcweir ePageMove = MV_NO;
583cdf0e10cSrcweir bDestOnStack = sal_False;
584cdf0e10cSrcweir }
585cdf0e10cSrcweir return bValidPos;
586cdf0e10cSrcweir }
587cdf0e10cSrcweir
588cdf0e10cSrcweir /*
589cdf0e10cSrcweir * Zuruecksetzen aller gepushten Cursorpositionen; dieser werden nicht
590cdf0e10cSrcweir * zur Anzeige gebracht ( --> Kein Start-/EndAction!!)
591cdf0e10cSrcweir */
592cdf0e10cSrcweir
593cdf0e10cSrcweir
594cdf0e10cSrcweir
_ResetCursorStack()595cdf0e10cSrcweir void SwWrtShell::_ResetCursorStack()
596cdf0e10cSrcweir {
597cdf0e10cSrcweir CrsrStack *pTmp = pCrsrStack;
598cdf0e10cSrcweir while(pCrsrStack)
599cdf0e10cSrcweir {
600cdf0e10cSrcweir pTmp = pCrsrStack->pNext;
601cdf0e10cSrcweir delete pCrsrStack;
602cdf0e10cSrcweir pCrsrStack = pTmp;
603cdf0e10cSrcweir }
604cdf0e10cSrcweir ePageMove = MV_NO;
605cdf0e10cSrcweir bDestOnStack = sal_False;
606cdf0e10cSrcweir }
607cdf0e10cSrcweir /**************
608cdf0e10cSrcweir
609cdf0e10cSrcweir falls kein Stack existiert --> Selektionen aufheben
610cdf0e10cSrcweir falls Stack && Richtungswechsel
611cdf0e10cSrcweir --> Cursor poppen und return
612cdf0e10cSrcweir sonst
613cdf0e10cSrcweir --> Cursor pushen
614cdf0e10cSrcweir Cursor umsetzen
615cdf0e10cSrcweir
616cdf0e10cSrcweir ***************/
617cdf0e10cSrcweir
618cdf0e10cSrcweir
619cdf0e10cSrcweir
PageCrsr(SwTwips lOffset,sal_Bool bSelect)620cdf0e10cSrcweir sal_Bool SwWrtShell::PageCrsr(SwTwips lOffset, sal_Bool bSelect)
621cdf0e10cSrcweir {
622cdf0e10cSrcweir // nichts tun, wenn ein Offset von 0 angegeben wurde
623cdf0e10cSrcweir if(!lOffset) return sal_False;
624cdf0e10cSrcweir // Diente mal dazu, eine Neuformatierung fuer das Layout
625cdf0e10cSrcweir // zu erzwingen.
626cdf0e10cSrcweir // Hat so nicht funktioniert, da der Cursor nicht gesetzt
627cdf0e10cSrcweir // wurde, da dies innerhalb einer Start- / EndActionklammerung
628cdf0e10cSrcweir // nicht geschieht.
629cdf0e10cSrcweir // Da am Ende nur ViewShell::EndAction() gerufen wird,
630cdf0e10cSrcweir // findet auch hier keine Aktualisierung der Anzeige
631cdf0e10cSrcweir // der Cursorposition statt.
632cdf0e10cSrcweir // Die CrsrShell- Actionklammerung kann nicht verwendet werden,
633cdf0e10cSrcweir // da sie immer zu einer Anzeige des Cursors fuehrt, also auch,
634cdf0e10cSrcweir // wenn nach dem Blaettern in einen Bereich ohne gueltige Position
635cdf0e10cSrcweir // geblaettert wurde.
636cdf0e10cSrcweir // ViewShell::StartAction();
637cdf0e10cSrcweir PageMove eDir = lOffset > 0? MV_PAGE_DOWN: MV_PAGE_UP;
638cdf0e10cSrcweir // Richtungswechsel und Stack vorhanden
639cdf0e10cSrcweir if( eDir != ePageMove && ePageMove != MV_NO && PopCrsr( sal_True, bSelect ))
640cdf0e10cSrcweir return sal_True;
641cdf0e10cSrcweir
642cdf0e10cSrcweir const sal_Bool bRet = PushCrsr(lOffset, bSelect);
643cdf0e10cSrcweir ePageMove = eDir;
644cdf0e10cSrcweir return bRet;
645cdf0e10cSrcweir }
646cdf0e10cSrcweir
647cdf0e10cSrcweir
648cdf0e10cSrcweir
GotoPage(sal_uInt16 nPage,sal_Bool bRecord)649cdf0e10cSrcweir sal_Bool SwWrtShell::GotoPage(sal_uInt16 nPage, sal_Bool bRecord)
650cdf0e10cSrcweir {
651cdf0e10cSrcweir ShellMoveCrsr aTmp( this, sal_False);
652cdf0e10cSrcweir if( SwCrsrShell::GotoPage(nPage) && bRecord)
653cdf0e10cSrcweir {
654cdf0e10cSrcweir if(IsSelFrmMode())
655cdf0e10cSrcweir {
656cdf0e10cSrcweir UnSelectFrm();
657cdf0e10cSrcweir LeaveSelFrmMode();
658cdf0e10cSrcweir }
659cdf0e10cSrcweir return sal_True;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir return sal_False;
662cdf0e10cSrcweir }
663cdf0e10cSrcweir
664cdf0e10cSrcweir
665cdf0e10cSrcweir
GotoMark(const::sw::mark::IMark * const pMark,sal_Bool bSelect,sal_Bool bStart)666cdf0e10cSrcweir sal_Bool SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark, sal_Bool bSelect, sal_Bool bStart )
667cdf0e10cSrcweir {
668cdf0e10cSrcweir ShellMoveCrsr aTmp( this, bSelect );
669cdf0e10cSrcweir return SwCrsrShell::GotoMark( pMark, bStart );
670cdf0e10cSrcweir }
671cdf0e10cSrcweir
672cdf0e10cSrcweir
673cdf0e10cSrcweir
SelectTxtAttr(sal_uInt16 nWhich,const SwTxtAttr * pAttr)674cdf0e10cSrcweir sal_Bool SwWrtShell::SelectTxtAttr( sal_uInt16 nWhich, const SwTxtAttr* pAttr )
675cdf0e10cSrcweir {
676cdf0e10cSrcweir sal_Bool bRet;
677cdf0e10cSrcweir {
678cdf0e10cSrcweir MV_KONTEXT(this);
679cdf0e10cSrcweir SttSelect();
680cdf0e10cSrcweir bRet = SwCrsrShell::SelectTxtAttr( nWhich, sal_False, pAttr );
681cdf0e10cSrcweir }
682cdf0e10cSrcweir EndSelect();
683cdf0e10cSrcweir return bRet;
684cdf0e10cSrcweir }
685cdf0e10cSrcweir
686cdf0e10cSrcweir
687cdf0e10cSrcweir
688