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: txtcrsr.cxx,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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <sfx2/request.hxx>
36 #include <svtools/eitem.hxx>
37 #ifndef __SBX_SBXVARIABLE_HXX //autogen
38 #include <basic/sbxvar.hxx>
40 #include <sfx2/viewfrm.hxx>
41 #include <sfx2/bindings.hxx>
52 #include <crsskip.hxx>
59 #include <globals.hrc>
62 using namespace ::com::sun::star
;
64 void SwTextShell::ExecBasicMove(SfxRequest
&rReq
)
66 SwWrtShell
&rSh
= GetShell();
67 GetView().GetEditWin().FlushInBuffer();
68 const SfxItemSet
*pArgs
= rReq
.GetArgs();
73 const SfxPoolItem
*pItem
;
74 if(SFX_ITEM_SET
== pArgs
->GetItemState(FN_PARAM_MOVE_COUNT
, TRUE
, &pItem
))
75 nCount
= ((const SfxInt16Item
*)pItem
)->GetValue();
76 if(SFX_ITEM_SET
== pArgs
->GetItemState(FN_PARAM_MOVE_SELECTION
, TRUE
, &pItem
))
77 bSelect
= ((const SfxBoolItem
*)pItem
)->GetValue();
79 switch(rReq
.GetSlot())
81 case FN_CHAR_LEFT_SEL
: rReq
.SetSlot( FN_CHAR_LEFT
); bSelect
= TRUE
; break;
82 case FN_CHAR_RIGHT_SEL
: rReq
.SetSlot( FN_CHAR_RIGHT
); bSelect
= TRUE
; break;
83 case FN_LINE_UP_SEL
: rReq
.SetSlot( FN_LINE_UP
); bSelect
= TRUE
; break;
84 case FN_LINE_DOWN_SEL
: rReq
.SetSlot( FN_LINE_DOWN
); bSelect
= TRUE
; break;
87 uno::Reference
< frame::XDispatchRecorder
> xRecorder
=
88 GetView().GetViewFrame()->GetBindings().GetRecorder();
91 rReq
.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT
, nCount
) );
92 rReq
.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION
, bSelect
) );
94 USHORT nSlot
= rReq
.GetSlot();
96 // Get EditWin before calling the move functions (shell change may occur!)
97 SwEditWin
& rTmpEditWin
= GetView().GetEditWin();
98 for( USHORT i
= 0; i
< nCount
; i
++ )
102 case FN_CHAR_LEFT
: rSh
.Left( CRSR_SKIP_CELLS
, bSelect
, 1, FALSE
, TRUE
); break;
103 case FN_CHAR_RIGHT
: rSh
.Right( CRSR_SKIP_CELLS
, bSelect
, 1, FALSE
, TRUE
); break;
104 case FN_LINE_UP
: rSh
.Up ( bSelect
, 1 ); break;
105 case FN_LINE_DOWN
: rSh
.Down ( bSelect
, 1 ); break;
106 default: ASSERT(FALSE
, falscher Dispatcher
); return;
110 //#i42732# - notify the edit window that from now on we do not use the input language
111 rTmpEditWin
.SetUseInputLanguage( sal_False
);
114 void SwTextShell::ExecMove(SfxRequest
&rReq
)
116 SwWrtShell
&rSh
= GetShell();
117 SwEditWin
& rTmpEditWin
= GetView().GetEditWin();
118 rTmpEditWin
.FlushInBuffer();
120 USHORT nSlot
= rReq
.GetSlot();
124 case FN_START_OF_LINE_SEL
:
125 case FN_START_OF_LINE
: bRet
= rSh
.LeftMargin ( FN_START_OF_LINE_SEL
== nSlot
, FALSE
);
128 case FN_END_OF_LINE_SEL
:
129 case FN_END_OF_LINE
: bRet
= rSh
.RightMargin( FN_END_OF_LINE_SEL
== nSlot
, FALSE
);
132 case FN_START_OF_DOCUMENT_SEL
:
133 case FN_START_OF_DOCUMENT
: bRet
= rSh
.SttDoc ( FN_START_OF_DOCUMENT_SEL
== nSlot
);
136 case FN_END_OF_DOCUMENT_SEL
:
137 case FN_END_OF_DOCUMENT
: bRet
= rSh
.EndDoc( FN_END_OF_DOCUMENT_SEL
== nSlot
);
140 case FN_SELECT_WORD
: bRet
= rSh
.SelNearestWrd(); break;
142 case SID_SELECTALL
: bRet
= 0 != rSh
.SelAll(); break;
143 default: ASSERT(FALSE
, falscher Dispatcher
); return;
151 //#i42732# - notify the edit window that from now on we do not use the input language
152 rTmpEditWin
.SetUseInputLanguage( sal_False
);
155 void SwTextShell::ExecMovePage(SfxRequest
&rReq
)
157 SwWrtShell
&rSh
= GetShell();
158 GetView().GetEditWin().FlushInBuffer();
160 USHORT nSlot
= rReq
.GetSlot();
163 case FN_START_OF_NEXT_PAGE_SEL
:
164 case FN_START_OF_NEXT_PAGE
: rSh
.SttNxtPg( FN_START_OF_NEXT_PAGE_SEL
== nSlot
); break;
166 case FN_END_OF_NEXT_PAGE_SEL
:
167 case FN_END_OF_NEXT_PAGE
: rSh
.EndNxtPg( FN_END_OF_NEXT_PAGE_SEL
== nSlot
); break;
169 case FN_START_OF_PREV_PAGE_SEL
:
170 case FN_START_OF_PREV_PAGE
: rSh
.SttPrvPg( FN_START_OF_PREV_PAGE_SEL
== nSlot
); break;
172 case FN_END_OF_PREV_PAGE_SEL
:
173 case FN_END_OF_PREV_PAGE
: rSh
.EndPrvPg( FN_END_OF_PREV_PAGE_SEL
== nSlot
); break;
175 case FN_START_OF_PAGE_SEL
:
176 case FN_START_OF_PAGE
: rSh
.SttPg ( FN_START_OF_PAGE_SEL
== nSlot
); break;
178 case FN_END_OF_PAGE_SEL
:
179 case FN_END_OF_PAGE
: rSh
.EndPg ( FN_END_OF_PAGE_SEL
== nSlot
); break;
180 default: ASSERT(FALSE
, falscher Dispatcher
); return;
186 void SwTextShell::ExecMoveCol(SfxRequest
&rReq
)
188 SwWrtShell
&rSh
= GetShell();
189 switch ( rReq
.GetSlot() )
191 case FN_START_OF_COLUMN
: rSh
.StartOfColumn ( FALSE
); break;
192 case FN_END_OF_COLUMN
: rSh
.EndOfColumn ( FALSE
); break;
193 case FN_START_OF_NEXT_COLUMN
: rSh
.StartOfNextColumn( FALSE
) ; break;
194 case FN_END_OF_NEXT_COLUMN
: rSh
.EndOfNextColumn ( FALSE
); break;
195 case FN_START_OF_PREV_COLUMN
: rSh
.StartOfPrevColumn( FALSE
); break;
196 case FN_END_OF_PREV_COLUMN
: rSh
.EndOfPrevColumn ( FALSE
); break;
197 default: ASSERT(FALSE
, falscher Dispatcher
); return;
202 void SwTextShell::ExecMoveLingu(SfxRequest
&rReq
)
204 SwWrtShell
&rSh
= GetShell();
205 GetView().GetEditWin().FlushInBuffer();
207 USHORT nSlot
= rReq
.GetSlot();
211 case FN_NEXT_WORD_SEL
:
212 case FN_NEXT_WORD
: bRet
= rSh
.NxtWrd( FN_NEXT_WORD_SEL
== nSlot
);
215 case FN_START_OF_PARA_SEL
:
216 case FN_START_OF_PARA
: bRet
= rSh
.SttPara( FN_START_OF_PARA_SEL
== nSlot
);
219 case FN_END_OF_PARA_SEL
:
220 case FN_END_OF_PARA
: bRet
= rSh
.EndPara( FN_END_OF_PARA_SEL
== nSlot
);
223 case FN_PREV_WORD_SEL
:
224 case FN_PREV_WORD
: bRet
= rSh
.PrvWrd( FN_PREV_WORD_SEL
== nSlot
);
227 case FN_NEXT_SENT_SEL
:
228 case FN_NEXT_SENT
: bRet
= rSh
.FwdSentence( FN_NEXT_SENT_SEL
== nSlot
);
231 case FN_PREV_SENT_SEL
:
232 case FN_PREV_SENT
: bRet
= rSh
.BwdSentence( FN_PREV_SENT_SEL
== nSlot
);
235 case FN_NEXT_PARA
: bRet
= rSh
.FwdPara ( FALSE
);
238 case FN_PREV_PARA
: bRet
= rSh
.BwdPara ( FALSE
);
240 default: ASSERT(FALSE
, falscher Dispatcher
); return;
245 void SwTextShell::ExecMoveMisc(SfxRequest
&rReq
)
247 SwWrtShell
&rSh
= GetShell();
248 USHORT nSlot
= rReq
.GetSlot();
249 BOOL bSetRetVal
= TRUE
, bRet
= TRUE
;
252 case FN_CNTNT_TO_NEXT_FRAME
:
253 bRet
= rSh
.GotoObj(TRUE
, GOTOOBJ_GOTO_ANY
);
257 rSh
.EnterSelFrmMode();
260 case FN_NEXT_FOOTNOTE
:
262 bRet
= rSh
.GotoNextFtnAnchor();
264 case FN_PREV_FOOTNOTE
:
266 bRet
= rSh
.GotoPrevFtnAnchor();
270 if ( FRMTYPE_HEADER
& rSh
.GetFrmType(0,FALSE
) )
278 if ( FRMTYPE_FOOTER
& rSh
.GetFrmType(0,FALSE
) )
284 case FN_FOOTNOTE_TO_ANCHOR
:
286 if ( FRMTYPE_FOOTNOTE
& rSh
.GetFrmType(0,FALSE
) )
292 case FN_TO_FOOTNOTE_AREA
:
296 bRet
= rSh
.MoveTable( fnTablePrev
, fnTableStart
);
299 bRet
= rSh
.MoveTable(fnTableNext
, fnTableStart
);
301 case FN_GOTO_NEXT_REGION
:
302 bRet
= rSh
.MoveRegion(fnRegionNext
, fnRegionStart
);
304 case FN_GOTO_PREV_REGION
:
305 bRet
= rSh
.MoveRegion(fnRegionPrev
, fnRegionStart
);
308 case FN_NEXT_TOXMARK
:
309 bRet
= rSh
.GotoNxtPrvTOXMark( TRUE
);
311 case FN_PREV_TOXMARK
:
312 bRet
= rSh
.GotoNxtPrvTOXMark( FALSE
);
315 bRet
= rSh
.GotoNxtPrvTblFormula( TRUE
, FALSE
);
318 bRet
= rSh
.GotoNxtPrvTblFormula( FALSE
, FALSE
);
320 case FN_NEXT_TBLFML_ERR
:
321 bRet
= rSh
.GotoNxtPrvTblFormula( TRUE
, TRUE
);
323 case FN_PREV_TBLFML_ERR
:
324 bRet
= rSh
.GotoNxtPrvTblFormula( FALSE
, TRUE
);
328 ASSERT(FALSE
, falscher Dispatcher
);
333 rReq
.SetReturnValue(SfxBoolItem( nSlot
, bRet
));