1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/request.hxx>
21 #include <svl/eitem.hxx>
22 #include <basic/sbxvar.hxx>
23 #include <sfx2/viewfrm.hxx>
24 #include <sfx2/bindings.hxx>
31 #include <crsskip.hxx>
37 #include <globals.hrc>
39 #include <svx/svdouno.hxx>
40 #include <svx/fmshell.hxx>
41 #include <svx/sdrobjectfilter.hxx>
43 using namespace ::com::sun::star
;
45 void SwTextShell::ExecBasicMove(SfxRequest
&rReq
)
47 SwWrtShell
&rSh
= GetShell();
48 GetView().GetEditWin().FlushInBuffer();
49 const SfxItemSet
*pArgs
= rReq
.GetArgs();
50 sal_Bool bSelect
= sal_False
;
51 sal_uInt16 nCount
= 1;
54 const SfxPoolItem
*pItem
;
55 if(SFX_ITEM_SET
== pArgs
->GetItemState(FN_PARAM_MOVE_COUNT
, sal_True
, &pItem
))
56 nCount
= ((const SfxInt16Item
*)pItem
)->GetValue();
57 if(SFX_ITEM_SET
== pArgs
->GetItemState(FN_PARAM_MOVE_SELECTION
, sal_True
, &pItem
))
58 bSelect
= ((const SfxBoolItem
*)pItem
)->GetValue();
60 switch(rReq
.GetSlot())
62 case FN_CHAR_LEFT_SEL
: rReq
.SetSlot( FN_CHAR_LEFT
); bSelect
= sal_True
; break;
63 case FN_CHAR_RIGHT_SEL
: rReq
.SetSlot( FN_CHAR_RIGHT
); bSelect
= sal_True
; break;
64 case FN_LINE_UP_SEL
: rReq
.SetSlot( FN_LINE_UP
); bSelect
= sal_True
; break;
65 case FN_LINE_DOWN_SEL
: rReq
.SetSlot( FN_LINE_DOWN
); bSelect
= sal_True
; break;
68 uno::Reference
< frame::XDispatchRecorder
> xRecorder
=
69 GetView().GetViewFrame()->GetBindings().GetRecorder();
72 rReq
.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT
, nCount
) );
73 rReq
.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION
, bSelect
) );
75 sal_uInt16 nSlot
= rReq
.GetSlot();
77 // Get EditWin before calling the move functions (shell change may occur!)
78 SwEditWin
& rTmpEditWin
= GetView().GetEditWin();
79 for( sal_uInt16 i
= 0; i
< nCount
; i
++ )
83 case FN_CHAR_LEFT
: rSh
.Left( CRSR_SKIP_CELLS
, bSelect
, 1, sal_False
, sal_True
); break;
84 case FN_CHAR_RIGHT
: rSh
.Right( CRSR_SKIP_CELLS
, bSelect
, 1, sal_False
, sal_True
); break;
85 case FN_LINE_UP
: rSh
.Up ( bSelect
, 1 ); break;
86 case FN_LINE_DOWN
: rSh
.Down ( bSelect
, 1 ); break;
87 default: OSL_FAIL("wrong Dispatcher"); return;
91 //#i42732# - notify the edit window that from now on we do not use the input language
92 rTmpEditWin
.SetUseInputLanguage( sal_False
);
95 void SwTextShell::ExecMove(SfxRequest
&rReq
)
97 SwWrtShell
&rSh
= GetShell();
98 SwEditWin
& rTmpEditWin
= GetView().GetEditWin();
99 rTmpEditWin
.FlushInBuffer();
101 sal_uInt16 nSlot
= rReq
.GetSlot();
102 sal_Bool bRet
= sal_False
;
105 case FN_START_OF_LINE_SEL
:
106 case FN_START_OF_LINE
: bRet
= rSh
.LeftMargin ( FN_START_OF_LINE_SEL
== nSlot
, sal_False
);
109 case FN_END_OF_LINE_SEL
:
110 case FN_END_OF_LINE
: bRet
= rSh
.RightMargin( FN_END_OF_LINE_SEL
== nSlot
, sal_False
);
113 case FN_START_OF_DOCUMENT_SEL
:
114 case FN_START_OF_DOCUMENT
: bRet
= rSh
.SttDoc ( FN_START_OF_DOCUMENT_SEL
== nSlot
);
117 case FN_END_OF_DOCUMENT_SEL
:
118 case FN_END_OF_DOCUMENT
: bRet
= rSh
.EndDoc( FN_END_OF_DOCUMENT_SEL
== nSlot
);
121 case FN_SELECT_WORD
: bRet
= rSh
.SelNearestWrd(); break;
123 case SID_SELECTALL
: bRet
= 0 != rSh
.SelAll(); break;
124 default: OSL_FAIL("wrong dispatcher"); return;
132 //#i42732# - notify the edit window that from now on we do not use the input language
133 rTmpEditWin
.SetUseInputLanguage( sal_False
);
136 void SwTextShell::ExecMovePage(SfxRequest
&rReq
)
138 SwWrtShell
&rSh
= GetShell();
139 GetView().GetEditWin().FlushInBuffer();
141 sal_uInt16 nSlot
= rReq
.GetSlot();
144 case FN_START_OF_NEXT_PAGE_SEL
:
145 case FN_START_OF_NEXT_PAGE
: rSh
.SttNxtPg( FN_START_OF_NEXT_PAGE_SEL
== nSlot
); break;
147 case FN_END_OF_NEXT_PAGE_SEL
:
148 case FN_END_OF_NEXT_PAGE
: rSh
.EndNxtPg( FN_END_OF_NEXT_PAGE_SEL
== nSlot
); break;
150 case FN_START_OF_PREV_PAGE_SEL
:
151 case FN_START_OF_PREV_PAGE
: rSh
.SttPrvPg( FN_START_OF_PREV_PAGE_SEL
== nSlot
); break;
153 case FN_END_OF_PREV_PAGE_SEL
:
154 case FN_END_OF_PREV_PAGE
: rSh
.EndPrvPg( FN_END_OF_PREV_PAGE_SEL
== nSlot
); break;
156 case FN_START_OF_PAGE_SEL
:
157 case FN_START_OF_PAGE
: rSh
.SttPg ( FN_START_OF_PAGE_SEL
== nSlot
); break;
159 case FN_END_OF_PAGE_SEL
:
160 case FN_END_OF_PAGE
: rSh
.EndPg ( FN_END_OF_PAGE_SEL
== nSlot
); break;
161 default: OSL_FAIL("wrong dispatcher"); return;
166 void SwTextShell::ExecMoveCol(SfxRequest
&rReq
)
168 SwWrtShell
&rSh
= GetShell();
169 switch ( rReq
.GetSlot() )
171 case FN_START_OF_COLUMN
: rSh
.StartOfColumn ( sal_False
); break;
172 case FN_END_OF_COLUMN
: rSh
.EndOfColumn ( sal_False
); break;
173 case FN_START_OF_NEXT_COLUMN
: rSh
.StartOfNextColumn( sal_False
) ; break;
174 case FN_END_OF_NEXT_COLUMN
: rSh
.EndOfNextColumn ( sal_False
); break;
175 case FN_START_OF_PREV_COLUMN
: rSh
.StartOfPrevColumn( sal_False
); break;
176 case FN_END_OF_PREV_COLUMN
: rSh
.EndOfPrevColumn ( sal_False
); break;
177 default: OSL_FAIL("wrong dispatcher"); return;
182 void SwTextShell::ExecMoveLingu(SfxRequest
&rReq
)
184 SwWrtShell
&rSh
= GetShell();
185 GetView().GetEditWin().FlushInBuffer();
187 sal_uInt16 nSlot
= rReq
.GetSlot();
190 case FN_NEXT_WORD_SEL
:
191 case FN_NEXT_WORD
: rSh
.NxtWrd( FN_NEXT_WORD_SEL
== nSlot
);
194 case FN_START_OF_PARA_SEL
:
195 case FN_START_OF_PARA
: rSh
.SttPara( FN_START_OF_PARA_SEL
== nSlot
);
198 case FN_END_OF_PARA_SEL
:
199 case FN_END_OF_PARA
: rSh
.EndPara( FN_END_OF_PARA_SEL
== nSlot
);
202 case FN_PREV_WORD_SEL
:
203 case FN_PREV_WORD
: rSh
.PrvWrd( FN_PREV_WORD_SEL
== nSlot
);
206 case FN_NEXT_SENT_SEL
:
207 case FN_NEXT_SENT
: rSh
.FwdSentence( FN_NEXT_SENT_SEL
== nSlot
);
210 case FN_PREV_SENT_SEL
:
211 case FN_PREV_SENT
: rSh
.BwdSentence( FN_PREV_SENT_SEL
== nSlot
);
214 case FN_NEXT_PARA
: rSh
.FwdPara ( sal_False
);
217 case FN_PREV_PARA
: rSh
.BwdPara ( sal_False
);
219 default: OSL_FAIL("wrong dispatcher"); return;
224 void SwTextShell::ExecMoveMisc(SfxRequest
&rReq
)
226 SwWrtShell
&rSh
= GetShell();
227 sal_uInt16 nSlot
= rReq
.GetSlot();
228 sal_Bool bSetRetVal
= sal_True
, bRet
= sal_True
;
231 case SID_FM_TOGGLECONTROLFOCUS
:
233 const SwDoc
* pDoc
= rSh
.GetDoc();
234 const SwDocShell
* pDocShell
= pDoc
? pDoc
->GetDocShell() : NULL
;
235 const SwView
* pView
= pDocShell
? pDocShell
->GetView() : NULL
;
236 const FmFormShell
* pFormShell
= pView
? pView
->GetFormShell() : NULL
;
237 SdrView
* pDrawView
= pView
? pView
->GetDrawView() : NULL
;
238 Window
* pWindow
= pView
? pView
->GetWrtShell().GetWin() : NULL
;
240 OSL_ENSURE( pFormShell
&& pDrawView
&& pWindow
, "SwXTextView::ExecMoveMisc: no chance!" );
241 if ( !pFormShell
|| !pDrawView
|| !pWindow
)
244 ::std::auto_ptr
< ::svx::ISdrObjectFilter
> pFilter( pFormShell
->CreateFocusableControlFilter(
245 *pDrawView
, *pWindow
) );
246 if ( !pFilter
.get() )
249 const SdrObject
* pNearestControl
= rSh
.GetBestObject( sal_True
, GOTOOBJ_DRAW_CONTROL
, sal_False
, pFilter
.get() );
250 if ( !pNearestControl
)
253 const SdrUnoObj
* pUnoObject
= dynamic_cast< const SdrUnoObj
* >( pNearestControl
);
254 OSL_ENSURE( pUnoObject
, "SwTextShell::ExecMoveMisc: GetBestObject returned nonsense!" );
258 pFormShell
->ToggleControlFocus( *pUnoObject
, *pDrawView
, *pWindow
);
261 case FN_CNTNT_TO_NEXT_FRAME
:
262 bRet
= rSh
.GotoObj(sal_True
, GOTOOBJ_GOTO_ANY
);
266 rSh
.EnterSelFrmMode();
269 case FN_NEXT_FOOTNOTE
:
271 bRet
= rSh
.GotoNextFtnAnchor();
273 case FN_PREV_FOOTNOTE
:
275 bRet
= rSh
.GotoPrevFtnAnchor();
279 if ( FRMTYPE_HEADER
& rSh
.GetFrmType(0,sal_False
) )
283 bool bMoved
= rSh
.GotoHeaderTxt();
287 bSetRetVal
= sal_False
;
291 if ( FRMTYPE_FOOTER
& rSh
.GetFrmType(0,sal_False
) )
295 bool bMoved
= rSh
.GotoFooterTxt();
299 bSetRetVal
= sal_False
;
301 case FN_FOOTNOTE_TO_ANCHOR
:
303 if ( FRMTYPE_FOOTNOTE
& rSh
.GetFrmType(0,sal_False
) )
307 bSetRetVal
= sal_False
;
309 case FN_TO_FOOTNOTE_AREA
:
313 bRet
= rSh
.MoveTable( fnTablePrev
, fnTableStart
);
316 bRet
= rSh
.MoveTable(fnTableNext
, fnTableStart
);
318 case FN_GOTO_NEXT_REGION
:
319 bRet
= rSh
.MoveRegion(fnRegionNext
, fnRegionStart
);
321 case FN_GOTO_PREV_REGION
:
322 bRet
= rSh
.MoveRegion(fnRegionPrev
, fnRegionStart
);
325 case FN_NEXT_TOXMARK
:
326 bRet
= rSh
.GotoNxtPrvTOXMark( sal_True
);
328 case FN_PREV_TOXMARK
:
329 bRet
= rSh
.GotoNxtPrvTOXMark( sal_False
);
332 bRet
= rSh
.GotoNxtPrvTblFormula( sal_True
, sal_False
);
335 bRet
= rSh
.GotoNxtPrvTblFormula( sal_False
, sal_False
);
337 case FN_NEXT_TBLFML_ERR
:
338 bRet
= rSh
.GotoNxtPrvTblFormula( sal_True
, sal_True
);
340 case FN_PREV_TBLFML_ERR
:
341 bRet
= rSh
.GotoNxtPrvTblFormula( sal_False
, sal_True
);
345 OSL_FAIL("wrong dispatcher");
350 rReq
.SetReturnValue(SfxBoolItem( nSlot
, bRet
));
353 sal_Bool bInHeader
= sal_True
;
354 if ( rSh
.IsInHeaderFooter( &bInHeader
) )
358 rSh
.SetShowHeaderFooterSeparator( Footer
, true );
359 rSh
.SetShowHeaderFooterSeparator( Header
, false );
363 rSh
.SetShowHeaderFooterSeparator( Header
, true );
364 rSh
.SetShowHeaderFooterSeparator( Footer
, false );
368 rSh
.GetWin()->Invalidate();
370 if ( rSh
.IsInHeaderFooter() != rSh
.IsHeaderFooterEdit() )
371 rSh
.ToggleHeaderFooterEdit();
374 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */