update dev300-m58
[ooovba.git] / sw / source / ui / shells / txtcrsr.cxx
blob66d48d6f3f3844e6fb8d9ec7984a047063382f3a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtcrsr.cxx,v $
10 * $Revision: 1.19 $
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>
39 #endif
40 #include <sfx2/viewfrm.hxx>
41 #include <sfx2/bindings.hxx>
43 #ifndef _VIEW_HXX
44 #include <view.hxx>
45 #endif
46 #include <wrtsh.hxx>
47 #ifndef _TEXTSH_HXX
48 #include <textsh.hxx>
49 #endif
50 #include <num.hxx>
51 #include <edtwin.hxx>
52 #include <crsskip.hxx>
54 #ifndef _CMDID_H
55 #include <cmdid.h>
56 #endif
57 #include <globals.h>
58 #ifndef _GLOBALS_HRC
59 #include <globals.hrc>
60 #endif
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();
69 BOOL bSelect = FALSE;
70 USHORT nCount = 1;
71 if(pArgs)
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();
89 if ( xRecorder.is() )
91 rReq.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT, nCount) );
92 rReq.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, bSelect) );
94 USHORT nSlot = rReq.GetSlot();
95 rReq.Done();
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++ )
100 switch(nSlot)
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();
121 BOOL bRet = FALSE;
122 switch ( nSlot )
124 case FN_START_OF_LINE_SEL:
125 case FN_START_OF_LINE: bRet = rSh.LeftMargin ( FN_START_OF_LINE_SEL == nSlot, FALSE );
126 break;
128 case FN_END_OF_LINE_SEL:
129 case FN_END_OF_LINE: bRet = rSh.RightMargin( FN_END_OF_LINE_SEL == nSlot, FALSE );
130 break;
132 case FN_START_OF_DOCUMENT_SEL:
133 case FN_START_OF_DOCUMENT: bRet = rSh.SttDoc ( FN_START_OF_DOCUMENT_SEL == nSlot);
134 break;
136 case FN_END_OF_DOCUMENT_SEL:
137 case FN_END_OF_DOCUMENT: bRet = rSh.EndDoc( FN_END_OF_DOCUMENT_SEL == nSlot );
138 break;
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;
146 if ( bRet )
147 rReq.Done();
148 else
149 rReq.Ignore();
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();
161 switch( nSlot )
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;
182 rReq.Done();
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;
199 rReq.Done();
202 void SwTextShell::ExecMoveLingu(SfxRequest &rReq)
204 SwWrtShell &rSh = GetShell();
205 GetView().GetEditWin().FlushInBuffer();
207 USHORT nSlot = rReq.GetSlot();
208 BOOL bRet = FALSE;
209 switch ( nSlot )
211 case FN_NEXT_WORD_SEL:
212 case FN_NEXT_WORD: bRet = rSh.NxtWrd( FN_NEXT_WORD_SEL == nSlot );
213 break;
215 case FN_START_OF_PARA_SEL:
216 case FN_START_OF_PARA: bRet = rSh.SttPara( FN_START_OF_PARA_SEL == nSlot );
217 break;
219 case FN_END_OF_PARA_SEL:
220 case FN_END_OF_PARA: bRet = rSh.EndPara( FN_END_OF_PARA_SEL == nSlot );
221 break;
223 case FN_PREV_WORD_SEL:
224 case FN_PREV_WORD: bRet = rSh.PrvWrd( FN_PREV_WORD_SEL == nSlot );
225 break;
227 case FN_NEXT_SENT_SEL:
228 case FN_NEXT_SENT: bRet = rSh.FwdSentence( FN_NEXT_SENT_SEL == nSlot );
229 break;
231 case FN_PREV_SENT_SEL:
232 case FN_PREV_SENT: bRet = rSh.BwdSentence( FN_PREV_SENT_SEL == nSlot );
233 break;
235 case FN_NEXT_PARA: bRet = rSh.FwdPara ( FALSE );
236 break;
238 case FN_PREV_PARA: bRet = rSh.BwdPara ( FALSE );
239 break;
240 default: ASSERT(FALSE, falscher Dispatcher); return;
242 rReq.Done();
245 void SwTextShell::ExecMoveMisc(SfxRequest &rReq)
247 SwWrtShell &rSh = GetShell();
248 USHORT nSlot = rReq.GetSlot();
249 BOOL bSetRetVal = TRUE, bRet = TRUE;
250 switch ( nSlot )
252 case FN_CNTNT_TO_NEXT_FRAME:
253 bRet = rSh.GotoObj(TRUE, GOTOOBJ_GOTO_ANY);
254 if(bRet)
256 rSh.HideCrsr();
257 rSh.EnterSelFrmMode();
259 break;
260 case FN_NEXT_FOOTNOTE:
261 rSh.MoveCrsr();
262 bRet = rSh.GotoNextFtnAnchor();
263 break;
264 case FN_PREV_FOOTNOTE:
265 rSh.MoveCrsr();
266 bRet = rSh.GotoPrevFtnAnchor();
267 break;
268 case FN_TO_HEADER:
269 rSh.MoveCrsr();
270 if ( FRMTYPE_HEADER & rSh.GetFrmType(0,FALSE) )
271 rSh.SttPg();
272 else
273 rSh.GotoHeaderTxt();
274 bSetRetVal = FALSE;
275 break;
276 case FN_TO_FOOTER:
277 rSh.MoveCrsr();
278 if ( FRMTYPE_FOOTER & rSh.GetFrmType(0,FALSE) )
279 rSh.EndPg();
280 else
281 rSh.GotoFooterTxt();
282 bSetRetVal = FALSE;
283 break;
284 case FN_FOOTNOTE_TO_ANCHOR:
285 rSh.MoveCrsr();
286 if ( FRMTYPE_FOOTNOTE & rSh.GetFrmType(0,FALSE) )
287 rSh.GotoFtnAnchor();
288 else
289 rSh.GotoFtnTxt();
290 bSetRetVal = FALSE;
291 break;
292 case FN_TO_FOOTNOTE_AREA :
293 rSh.GotoFtnTxt();
294 break;
295 case FN_PREV_TABLE:
296 bRet = rSh.MoveTable( fnTablePrev, fnTableStart);
297 break;
298 case FN_NEXT_TABLE:
299 bRet = rSh.MoveTable(fnTableNext, fnTableStart);
300 break;
301 case FN_GOTO_NEXT_REGION :
302 bRet = rSh.MoveRegion(fnRegionNext, fnRegionStart);
303 break;
304 case FN_GOTO_PREV_REGION :
305 bRet = rSh.MoveRegion(fnRegionPrev, fnRegionStart);
306 break;
308 case FN_NEXT_TOXMARK:
309 bRet = rSh.GotoNxtPrvTOXMark( TRUE );
310 break;
311 case FN_PREV_TOXMARK:
312 bRet = rSh.GotoNxtPrvTOXMark( FALSE );
313 break;
314 case FN_NEXT_TBLFML:
315 bRet = rSh.GotoNxtPrvTblFormula( TRUE, FALSE );
316 break;
317 case FN_PREV_TBLFML:
318 bRet = rSh.GotoNxtPrvTblFormula( FALSE, FALSE );
319 break;
320 case FN_NEXT_TBLFML_ERR:
321 bRet = rSh.GotoNxtPrvTblFormula( TRUE, TRUE );
322 break;
323 case FN_PREV_TBLFML_ERR:
324 bRet = rSh.GotoNxtPrvTblFormula( FALSE, TRUE );
325 break;
327 default:
328 ASSERT(FALSE, falscher Dispatcher);
329 return;
332 if( bSetRetVal )
333 rReq.SetReturnValue(SfxBoolItem( nSlot, bRet ));
334 rReq.Done();