LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/shells - txtcrsr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 190 0.5 %
Date: 2012-12-27 Functions: 2 8 25.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      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>
      25             : 
      26             : #include <view.hxx>
      27             : #include <wrtsh.hxx>
      28             : #include <textsh.hxx>
      29             : #include <num.hxx>
      30             : #include <edtwin.hxx>
      31             : #include <crsskip.hxx>
      32             : #include <doc.hxx>
      33             : #include <docsh.hxx>
      34             : 
      35             : #include <cmdid.h>
      36             : #include <globals.h>
      37             : #include <globals.hrc>
      38             : 
      39             : #include <svx/svdouno.hxx>
      40             : #include <svx/fmshell.hxx>
      41             : #include <svx/sdrobjectfilter.hxx>
      42             : 
      43             : using namespace ::com::sun::star;
      44             : 
      45           0 : void SwTextShell::ExecBasicMove(SfxRequest &rReq)
      46             : {
      47           0 :     SwWrtShell &rSh = GetShell();
      48           0 :     GetView().GetEditWin().FlushInBuffer();
      49           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
      50           0 :     sal_Bool bSelect = sal_False;
      51           0 :     sal_uInt16 nCount = 1;
      52           0 :     if(pArgs)
      53             :     {
      54             :         const SfxPoolItem *pItem;
      55           0 :         if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_MOVE_COUNT, sal_True, &pItem))
      56           0 :             nCount = ((const SfxInt16Item *)pItem)->GetValue();
      57           0 :         if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_MOVE_SELECTION, sal_True, &pItem))
      58           0 :             bSelect = ((const SfxBoolItem *)pItem)->GetValue();
      59             :     }
      60           0 :     switch(rReq.GetSlot())
      61             :     {
      62           0 :         case FN_CHAR_LEFT_SEL:  rReq.SetSlot( FN_CHAR_LEFT );  bSelect = sal_True; break;
      63           0 :         case FN_CHAR_RIGHT_SEL: rReq.SetSlot( FN_CHAR_RIGHT ); bSelect = sal_True; break;
      64           0 :         case FN_LINE_UP_SEL:    rReq.SetSlot( FN_LINE_UP );    bSelect = sal_True; break;
      65           0 :         case FN_LINE_DOWN_SEL:  rReq.SetSlot( FN_LINE_DOWN );  bSelect = sal_True; break;
      66             :     }
      67             : 
      68             :     uno::Reference< frame::XDispatchRecorder > xRecorder =
      69           0 :             GetView().GetViewFrame()->GetBindings().GetRecorder();
      70           0 :     if ( xRecorder.is() )
      71             :     {
      72           0 :         rReq.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT, nCount) );
      73           0 :         rReq.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, bSelect) );
      74             :     }
      75           0 :     sal_uInt16 nSlot = rReq.GetSlot();
      76           0 :     rReq.Done();
      77             :     // Get EditWin before calling the move functions (shell change may occur!)
      78           0 :     SwEditWin& rTmpEditWin = GetView().GetEditWin();
      79           0 :     for( sal_uInt16 i = 0; i < nCount; i++ )
      80             :     {
      81           0 :         switch(nSlot)
      82             :         {
      83           0 :         case FN_CHAR_LEFT:  rSh.Left( CRSR_SKIP_CELLS,  bSelect, 1, sal_False, sal_True ); break;
      84           0 :         case FN_CHAR_RIGHT: rSh.Right( CRSR_SKIP_CELLS, bSelect, 1, sal_False, sal_True ); break;
      85           0 :         case FN_LINE_UP:    rSh.Up   ( bSelect, 1 ); break;
      86           0 :         case FN_LINE_DOWN:  rSh.Down ( bSelect, 1 ); break;
      87           0 :         default: OSL_FAIL("wrong Dispatcher"); return;
      88             :         }
      89             :     }
      90             : 
      91             :     //#i42732# - notify the edit window that from now on we do not use the input language
      92           0 :     rTmpEditWin.SetUseInputLanguage( sal_False );
      93             : }
      94             : 
      95           0 : void SwTextShell::ExecMove(SfxRequest &rReq)
      96             : {
      97           0 :     SwWrtShell &rSh = GetShell();
      98           0 :     SwEditWin& rTmpEditWin = GetView().GetEditWin();
      99           0 :     rTmpEditWin.FlushInBuffer();
     100             : 
     101           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     102           0 :     sal_Bool bRet = sal_False;
     103           0 :     switch ( nSlot )
     104             :     {
     105             :         case FN_START_OF_LINE_SEL:
     106           0 :         case FN_START_OF_LINE:      bRet = rSh.LeftMargin ( FN_START_OF_LINE_SEL == nSlot, sal_False );
     107           0 :         break;
     108             : 
     109             :         case FN_END_OF_LINE_SEL:
     110           0 :         case FN_END_OF_LINE:        bRet = rSh.RightMargin( FN_END_OF_LINE_SEL == nSlot, sal_False );
     111           0 :         break;
     112             : 
     113             :         case FN_START_OF_DOCUMENT_SEL:
     114           0 :         case FN_START_OF_DOCUMENT:  bRet = rSh.SttDoc      ( FN_START_OF_DOCUMENT_SEL == nSlot);
     115           0 :         break;
     116             : 
     117             :         case FN_END_OF_DOCUMENT_SEL:
     118           0 :         case FN_END_OF_DOCUMENT:    bRet = rSh.EndDoc( FN_END_OF_DOCUMENT_SEL == nSlot );
     119           0 :         break;
     120             : 
     121           0 :         case FN_SELECT_WORD:            bRet = rSh.SelNearestWrd(); break;
     122             : 
     123           0 :         case SID_SELECTALL:             bRet = 0 != rSh.SelAll();   break;
     124           0 :         default: OSL_FAIL("wrong dispatcher"); return;
     125             :     }
     126             : 
     127           0 :     if ( bRet )
     128           0 :         rReq.Done();
     129             :     else
     130           0 :         rReq.Ignore();
     131             : 
     132             :     //#i42732# - notify the edit window that from now on we do not use the input language
     133           0 :     rTmpEditWin.SetUseInputLanguage( sal_False );
     134             : }
     135             : 
     136           0 : void SwTextShell::ExecMovePage(SfxRequest &rReq)
     137             : {
     138           0 :     SwWrtShell &rSh = GetShell();
     139           0 :     GetView().GetEditWin().FlushInBuffer();
     140             : 
     141           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     142           0 :     switch( nSlot )
     143             :     {
     144             :         case FN_START_OF_NEXT_PAGE_SEL :
     145           0 :         case FN_START_OF_NEXT_PAGE: rSh.SttNxtPg( FN_START_OF_NEXT_PAGE_SEL == nSlot ); break;
     146             : 
     147             :         case FN_END_OF_NEXT_PAGE_SEL:
     148           0 :         case FN_END_OF_NEXT_PAGE:   rSh.EndNxtPg( FN_END_OF_NEXT_PAGE_SEL == nSlot ); break;
     149             : 
     150             :         case FN_START_OF_PREV_PAGE_SEL:
     151           0 :         case FN_START_OF_PREV_PAGE: rSh.SttPrvPg( FN_START_OF_PREV_PAGE_SEL == nSlot ); break;
     152             : 
     153             :         case FN_END_OF_PREV_PAGE_SEL:
     154           0 :         case FN_END_OF_PREV_PAGE:   rSh.EndPrvPg( FN_END_OF_PREV_PAGE_SEL == nSlot ); break;
     155             : 
     156             :         case FN_START_OF_PAGE_SEL:
     157           0 :         case FN_START_OF_PAGE:      rSh.SttPg   ( FN_START_OF_PAGE_SEL == nSlot ); break;
     158             : 
     159             :         case FN_END_OF_PAGE_SEL:
     160           0 :         case FN_END_OF_PAGE:        rSh.EndPg   ( FN_END_OF_PAGE_SEL == nSlot ); break;
     161           0 :         default: OSL_FAIL("wrong dispatcher"); return;
     162             :     }
     163           0 :     rReq.Done();
     164             : }
     165             : 
     166             : 
     167           0 : void SwTextShell::ExecMoveCol(SfxRequest &rReq)
     168             : {
     169           0 :     SwWrtShell &rSh = GetShell();
     170           0 :     switch ( rReq.GetSlot() )
     171             :     {
     172           0 :         case FN_START_OF_COLUMN:      rSh.StartOfColumn    ( sal_False ); break;
     173           0 :         case FN_END_OF_COLUMN:        rSh.EndOfColumn      ( sal_False ); break;
     174           0 :         case FN_START_OF_NEXT_COLUMN: rSh.StartOfNextColumn( sal_False ) ; break;
     175           0 :         case FN_END_OF_NEXT_COLUMN:   rSh.EndOfNextColumn  ( sal_False ); break;
     176           0 :         case FN_START_OF_PREV_COLUMN: rSh.StartOfPrevColumn( sal_False ); break;
     177           0 :         case FN_END_OF_PREV_COLUMN:   rSh.EndOfPrevColumn  ( sal_False ); break;
     178           0 :         default: OSL_FAIL("wrong dispatcher"); return;
     179             :     }
     180           0 :     rReq.Done();
     181             : }
     182             : 
     183           0 : void SwTextShell::ExecMoveLingu(SfxRequest &rReq)
     184             : {
     185           0 :     SwWrtShell &rSh = GetShell();
     186           0 :     GetView().GetEditWin().FlushInBuffer();
     187             : 
     188           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     189           0 :     switch ( nSlot )
     190             :     {
     191             :         case FN_NEXT_WORD_SEL:
     192           0 :         case FN_NEXT_WORD:      rSh.NxtWrd( FN_NEXT_WORD_SEL == nSlot );
     193           0 :         break;
     194             : 
     195             :         case FN_START_OF_PARA_SEL:
     196           0 :         case FN_START_OF_PARA:  rSh.SttPara( FN_START_OF_PARA_SEL == nSlot );
     197           0 :         break;
     198             : 
     199             :         case FN_END_OF_PARA_SEL:
     200           0 :         case FN_END_OF_PARA:    rSh.EndPara( FN_END_OF_PARA_SEL == nSlot );
     201           0 :         break;
     202             : 
     203             :         case FN_PREV_WORD_SEL:
     204           0 :         case FN_PREV_WORD:      rSh.PrvWrd( FN_PREV_WORD_SEL == nSlot );
     205           0 :         break;
     206             : 
     207             :         case FN_NEXT_SENT_SEL:
     208           0 :         case FN_NEXT_SENT:      rSh.FwdSentence( FN_NEXT_SENT_SEL == nSlot );
     209           0 :         break;
     210             : 
     211             :         case FN_PREV_SENT_SEL:
     212           0 :         case FN_PREV_SENT:      rSh.BwdSentence( FN_PREV_SENT_SEL == nSlot );
     213           0 :         break;
     214             : 
     215           0 :         case FN_NEXT_PARA:      rSh.FwdPara    ( sal_False );
     216           0 :         break;
     217             : 
     218           0 :         case FN_PREV_PARA:      rSh.BwdPara    ( sal_False );
     219           0 :         break;
     220           0 :         default: OSL_FAIL("wrong dispatcher"); return;
     221             :     }
     222           0 :     rReq.Done();
     223             : }
     224             : 
     225           0 : void SwTextShell::ExecMoveMisc(SfxRequest &rReq)
     226             : {
     227           0 :     SwWrtShell &rSh = GetShell();
     228           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     229           0 :     sal_Bool bSetRetVal = sal_True, bRet = sal_True;
     230           0 :     switch ( nSlot )
     231             :     {
     232             :         case SID_FM_TOGGLECONTROLFOCUS:
     233             :             {
     234           0 :                 const SwDoc* pDoc = rSh.GetDoc();
     235           0 :                 const SwDocShell* pDocShell = pDoc ? pDoc->GetDocShell() : NULL;
     236           0 :                 const SwView* pView = pDocShell ? pDocShell->GetView() : NULL;
     237           0 :                 const FmFormShell* pFormShell = pView ? pView->GetFormShell() : NULL;
     238           0 :                 SdrView* pDrawView = pView ? pView->GetDrawView() : NULL;
     239           0 :                 Window* pWindow = pView ? pView->GetWrtShell().GetWin() : NULL;
     240             : 
     241             :                 OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::ExecMoveMisc: no chance!" );
     242           0 :                 if ( !pFormShell || !pDrawView || !pWindow )
     243             :                     break;
     244             : 
     245             :                 ::std::auto_ptr< ::svx::ISdrObjectFilter > pFilter( pFormShell->CreateFocusableControlFilter(
     246           0 :                     *pDrawView, *pWindow ) );
     247           0 :                 if ( !pFilter.get() )
     248             :                     break;
     249             : 
     250           0 :                 const SdrObject* pNearestControl = rSh.GetBestObject( sal_True, GOTOOBJ_DRAW_CONTROL, sal_False, pFilter.get() );
     251           0 :                 if ( !pNearestControl )
     252             :                     break;
     253             : 
     254           0 :                 const SdrUnoObj* pUnoObject = dynamic_cast< const SdrUnoObj* >( pNearestControl );
     255             :                 OSL_ENSURE( pUnoObject, "SwTextShell::ExecMoveMisc: GetBestObject returned nonsense!" );
     256           0 :                 if ( !pUnoObject )
     257             :                     break;
     258             : 
     259           0 :                 pFormShell->ToggleControlFocus( *pUnoObject, *pDrawView, *pWindow );
     260             :             }
     261           0 :             break;
     262             :         case FN_CNTNT_TO_NEXT_FRAME:
     263           0 :             bRet = rSh.GotoObj(sal_True, GOTOOBJ_GOTO_ANY);
     264           0 :             if(bRet)
     265             :             {
     266           0 :                 rSh.HideCrsr();
     267           0 :                 rSh.EnterSelFrmMode();
     268             :             }
     269           0 :         break;
     270             :         case FN_NEXT_FOOTNOTE:
     271           0 :             rSh.MoveCrsr();
     272           0 :             bRet = rSh.GotoNextFtnAnchor();
     273           0 :             break;
     274             :         case FN_PREV_FOOTNOTE:
     275           0 :             rSh.MoveCrsr();
     276           0 :             bRet = rSh.GotoPrevFtnAnchor();
     277           0 :             break;
     278             :         case FN_TO_HEADER:
     279           0 :             rSh.MoveCrsr();
     280           0 :             if ( FRMTYPE_HEADER & rSh.GetFrmType(0,sal_False) )
     281           0 :                 rSh.SttPg();
     282             :             else
     283             :             {
     284           0 :                 bool bMoved = rSh.GotoHeaderTxt();
     285           0 :                 if ( !bMoved )
     286           0 :                     rSh.SttPg();
     287             :             }
     288           0 :             bSetRetVal = sal_False;
     289           0 :             break;
     290             :         case FN_TO_FOOTER:
     291           0 :             rSh.MoveCrsr();
     292           0 :             if ( FRMTYPE_FOOTER & rSh.GetFrmType(0,sal_False) )
     293           0 :                 rSh.EndPg();
     294             :             else
     295             :             {
     296           0 :                 bool bMoved = rSh.GotoFooterTxt();
     297           0 :                 if ( !bMoved )
     298           0 :                     rSh.EndPg();
     299             :             }
     300           0 :             bSetRetVal = sal_False;
     301           0 :             break;
     302             :         case FN_FOOTNOTE_TO_ANCHOR:
     303           0 :             rSh.MoveCrsr();
     304           0 :             if ( FRMTYPE_FOOTNOTE & rSh.GetFrmType(0,sal_False) )
     305           0 :                 rSh.GotoFtnAnchor();
     306             :             else
     307           0 :                 rSh.GotoFtnTxt();
     308           0 :             bSetRetVal = sal_False;
     309           0 :             break;
     310             :         case FN_TO_FOOTNOTE_AREA :
     311           0 :             rSh.GotoFtnTxt();
     312           0 :         break;
     313             :         case FN_PREV_TABLE:
     314           0 :             bRet = rSh.MoveTable( fnTablePrev, fnTableStart);
     315           0 :             break;
     316             :         case FN_NEXT_TABLE:
     317           0 :             bRet = rSh.MoveTable(fnTableNext, fnTableStart);
     318           0 :             break;
     319             :         case FN_GOTO_NEXT_REGION :
     320           0 :             bRet = rSh.MoveRegion(fnRegionNext, fnRegionStart);
     321           0 :         break;
     322             :         case FN_GOTO_PREV_REGION :
     323           0 :             bRet = rSh.MoveRegion(fnRegionPrev, fnRegionStart);
     324           0 :         break;
     325             : 
     326             :         case FN_NEXT_TOXMARK:
     327           0 :             bRet = rSh.GotoNxtPrvTOXMark( sal_True );
     328           0 :             break;
     329             :         case FN_PREV_TOXMARK:
     330           0 :             bRet = rSh.GotoNxtPrvTOXMark( sal_False );
     331           0 :             break;
     332             :         case FN_NEXT_TBLFML:
     333           0 :             bRet = rSh.GotoNxtPrvTblFormula( sal_True, sal_False );
     334           0 :             break;
     335             :         case FN_PREV_TBLFML:
     336           0 :             bRet = rSh.GotoNxtPrvTblFormula( sal_False, sal_False );
     337           0 :             break;
     338             :         case FN_NEXT_TBLFML_ERR:
     339           0 :             bRet = rSh.GotoNxtPrvTblFormula( sal_True, sal_True );
     340           0 :             break;
     341             :         case FN_PREV_TBLFML_ERR:
     342           0 :             bRet = rSh.GotoNxtPrvTblFormula( sal_False, sal_True );
     343           0 :             break;
     344             : 
     345             :         default:
     346             :             OSL_FAIL("wrong dispatcher");
     347           0 :             return;
     348             :     }
     349             : 
     350           0 :     if( bSetRetVal )
     351           0 :         rReq.SetReturnValue(SfxBoolItem( nSlot, bRet ));
     352           0 :     rReq.Done();
     353             : 
     354           0 :     sal_Bool bInHeader = sal_True;
     355           0 :     if ( rSh.IsInHeaderFooter( &bInHeader ) )
     356             :     {
     357           0 :         if ( !bInHeader )
     358             :         {
     359           0 :             rSh.SetShowHeaderFooterSeparator( Footer, true );
     360           0 :             rSh.SetShowHeaderFooterSeparator( Header, false );
     361             :         }
     362             :         else
     363             :         {
     364           0 :             rSh.SetShowHeaderFooterSeparator( Header, true );
     365           0 :             rSh.SetShowHeaderFooterSeparator( Footer, false );
     366             :         }
     367             : 
     368             :         // Force repaint
     369           0 :         rSh.GetWin()->Invalidate();
     370             :     }
     371           0 :     if ( rSh.IsInHeaderFooter() != rSh.IsHeaderFooterEdit() )
     372           0 :         rSh.ToggleHeaderFooterEdit();
     373          30 : }
     374             : 
     375             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10