LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/shells - txtcrsr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 193 0.5 %
Date: 2013-07-09 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           0 : void SwTextShell::ExecMoveCol(SfxRequest &rReq)
     167             : {
     168           0 :     SwWrtShell &rSh = GetShell();
     169           0 :     switch ( rReq.GetSlot() )
     170             :     {
     171           0 :         case FN_START_OF_COLUMN:      rSh.StartOfColumn    ( sal_False ); break;
     172           0 :         case FN_END_OF_COLUMN:        rSh.EndOfColumn      ( sal_False ); break;
     173           0 :         case FN_START_OF_NEXT_COLUMN: rSh.StartOfNextColumn( sal_False ) ; break;
     174           0 :         case FN_END_OF_NEXT_COLUMN:   rSh.EndOfNextColumn  ( sal_False ); break;
     175           0 :         case FN_START_OF_PREV_COLUMN: rSh.StartOfPrevColumn( sal_False ); break;
     176           0 :         case FN_END_OF_PREV_COLUMN:   rSh.EndOfPrevColumn  ( sal_False ); break;
     177           0 :         default: OSL_FAIL("wrong dispatcher"); return;
     178             :     }
     179           0 :     rReq.Done();
     180             : }
     181             : 
     182           0 : void SwTextShell::ExecMoveLingu(SfxRequest &rReq)
     183             : {
     184           0 :     SwWrtShell &rSh = GetShell();
     185           0 :     GetView().GetEditWin().FlushInBuffer();
     186             : 
     187           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     188           0 :     switch ( nSlot )
     189             :     {
     190             :         case FN_NEXT_WORD_SEL:
     191           0 :         case FN_NEXT_WORD:      rSh.NxtWrd( FN_NEXT_WORD_SEL == nSlot );
     192           0 :         break;
     193             : 
     194             :         case FN_START_OF_PARA_SEL:
     195           0 :         case FN_START_OF_PARA:  rSh.SttPara( FN_START_OF_PARA_SEL == nSlot );
     196           0 :         break;
     197             : 
     198             :         case FN_END_OF_PARA_SEL:
     199           0 :         case FN_END_OF_PARA:    rSh.EndPara( FN_END_OF_PARA_SEL == nSlot );
     200           0 :         break;
     201             : 
     202             :         case FN_PREV_WORD_SEL:
     203           0 :         case FN_PREV_WORD:      rSh.PrvWrd( FN_PREV_WORD_SEL == nSlot );
     204           0 :         break;
     205             : 
     206             :         case FN_NEXT_SENT_SEL:
     207           0 :         case FN_NEXT_SENT:      rSh.FwdSentence( FN_NEXT_SENT_SEL == nSlot );
     208           0 :         break;
     209             : 
     210             :         case FN_PREV_SENT_SEL:
     211           0 :         case FN_PREV_SENT:      rSh.BwdSentence( FN_PREV_SENT_SEL == nSlot );
     212           0 :         break;
     213             : 
     214           0 :         case FN_NEXT_PARA:      rSh.FwdPara    ( sal_False );
     215           0 :         break;
     216             : 
     217           0 :         case FN_PREV_PARA:      rSh.BwdPara    ( sal_False );
     218           0 :         break;
     219           0 :         default: OSL_FAIL("wrong dispatcher"); return;
     220             :     }
     221           0 :     rReq.Done();
     222             : }
     223             : 
     224           0 : void SwTextShell::ExecMoveMisc(SfxRequest &rReq)
     225             : {
     226           0 :     SwWrtShell &rSh = GetShell();
     227           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     228           0 :     sal_Bool bSetRetVal = sal_True, bRet = sal_True;
     229           0 :     switch ( nSlot )
     230             :     {
     231             :         case SID_FM_TOGGLECONTROLFOCUS:
     232             :             {
     233           0 :                 const SwDoc* pDoc = rSh.GetDoc();
     234           0 :                 const SwDocShell* pDocShell = pDoc ? pDoc->GetDocShell() : NULL;
     235           0 :                 const SwView* pView = pDocShell ? pDocShell->GetView() : NULL;
     236           0 :                 const FmFormShell* pFormShell = pView ? pView->GetFormShell() : NULL;
     237           0 :                 SdrView* pDrawView = pView ? pView->GetDrawView() : NULL;
     238           0 :                 Window* pWindow = pView ? pView->GetWrtShell().GetWin() : NULL;
     239             : 
     240             :                 OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::ExecMoveMisc: no chance!" );
     241           0 :                 if ( !pFormShell || !pDrawView || !pWindow )
     242             :                     break;
     243             : 
     244             :                 ::std::auto_ptr< ::svx::ISdrObjectFilter > pFilter( pFormShell->CreateFocusableControlFilter(
     245           0 :                     *pDrawView, *pWindow ) );
     246           0 :                 if ( !pFilter.get() )
     247           0 :                     break;
     248             : 
     249           0 :                 const SdrObject* pNearestControl = rSh.GetBestObject( sal_True, GOTOOBJ_DRAW_CONTROL, sal_False, pFilter.get() );
     250           0 :                 if ( !pNearestControl )
     251           0 :                     break;
     252             : 
     253           0 :                 const SdrUnoObj* pUnoObject = dynamic_cast< const SdrUnoObj* >( pNearestControl );
     254             :                 OSL_ENSURE( pUnoObject, "SwTextShell::ExecMoveMisc: GetBestObject returned nonsense!" );
     255           0 :                 if ( !pUnoObject )
     256           0 :                     break;
     257             : 
     258           0 :                 pFormShell->ToggleControlFocus( *pUnoObject, *pDrawView, *pWindow );
     259             :             }
     260           0 :             break;
     261             :         case FN_CNTNT_TO_NEXT_FRAME:
     262           0 :             bRet = rSh.GotoObj(sal_True, GOTOOBJ_GOTO_ANY);
     263           0 :             if(bRet)
     264             :             {
     265           0 :                 rSh.HideCrsr();
     266           0 :                 rSh.EnterSelFrmMode();
     267             :             }
     268           0 :         break;
     269             :         case FN_NEXT_FOOTNOTE:
     270           0 :             rSh.MoveCrsr();
     271           0 :             bRet = rSh.GotoNextFtnAnchor();
     272           0 :             break;
     273             :         case FN_PREV_FOOTNOTE:
     274           0 :             rSh.MoveCrsr();
     275           0 :             bRet = rSh.GotoPrevFtnAnchor();
     276           0 :             break;
     277             :         case FN_TO_HEADER:
     278           0 :             rSh.MoveCrsr();
     279           0 :             if ( FRMTYPE_HEADER & rSh.GetFrmType(0,sal_False) )
     280           0 :                 rSh.SttPg();
     281             :             else
     282             :             {
     283           0 :                 bool bMoved = rSh.GotoHeaderTxt();
     284           0 :                 if ( !bMoved )
     285           0 :                     rSh.SttPg();
     286             :             }
     287           0 :             bSetRetVal = sal_False;
     288           0 :             break;
     289             :         case FN_TO_FOOTER:
     290           0 :             rSh.MoveCrsr();
     291           0 :             if ( FRMTYPE_FOOTER & rSh.GetFrmType(0,sal_False) )
     292           0 :                 rSh.EndPg();
     293             :             else
     294             :             {
     295           0 :                 bool bMoved = rSh.GotoFooterTxt();
     296           0 :                 if ( !bMoved )
     297           0 :                     rSh.EndPg();
     298             :             }
     299           0 :             bSetRetVal = sal_False;
     300           0 :             break;
     301             :         case FN_FOOTNOTE_TO_ANCHOR:
     302           0 :             rSh.MoveCrsr();
     303           0 :             if ( FRMTYPE_FOOTNOTE & rSh.GetFrmType(0,sal_False) )
     304           0 :                 rSh.GotoFtnAnchor();
     305             :             else
     306           0 :                 rSh.GotoFtnTxt();
     307           0 :             bSetRetVal = sal_False;
     308           0 :             break;
     309             :         case FN_TO_FOOTNOTE_AREA :
     310           0 :             rSh.GotoFtnTxt();
     311           0 :         break;
     312             :         case FN_PREV_TABLE:
     313           0 :             bRet = rSh.MoveTable( fnTablePrev, fnTableStart);
     314           0 :             break;
     315             :         case FN_NEXT_TABLE:
     316           0 :             bRet = rSh.MoveTable(fnTableNext, fnTableStart);
     317           0 :             break;
     318             :         case FN_GOTO_NEXT_REGION :
     319           0 :             bRet = rSh.MoveRegion(fnRegionNext, fnRegionStart);
     320           0 :         break;
     321             :         case FN_GOTO_PREV_REGION :
     322           0 :             bRet = rSh.MoveRegion(fnRegionPrev, fnRegionStart);
     323           0 :         break;
     324             : 
     325             :         case FN_NEXT_TOXMARK:
     326           0 :             bRet = rSh.GotoNxtPrvTOXMark( sal_True );
     327           0 :             break;
     328             :         case FN_PREV_TOXMARK:
     329           0 :             bRet = rSh.GotoNxtPrvTOXMark( sal_False );
     330           0 :             break;
     331             :         case FN_NEXT_TBLFML:
     332           0 :             bRet = rSh.GotoNxtPrvTblFormula( sal_True, sal_False );
     333           0 :             break;
     334             :         case FN_PREV_TBLFML:
     335           0 :             bRet = rSh.GotoNxtPrvTblFormula( sal_False, sal_False );
     336           0 :             break;
     337             :         case FN_NEXT_TBLFML_ERR:
     338           0 :             bRet = rSh.GotoNxtPrvTblFormula( sal_True, sal_True );
     339           0 :             break;
     340             :         case FN_PREV_TBLFML_ERR:
     341           0 :             bRet = rSh.GotoNxtPrvTblFormula( sal_False, sal_True );
     342           0 :             break;
     343             : 
     344             :         default:
     345             :             OSL_FAIL("wrong dispatcher");
     346           0 :             return;
     347             :     }
     348             : 
     349           0 :     if( bSetRetVal )
     350           0 :         rReq.SetReturnValue(SfxBoolItem( nSlot, bRet ));
     351           0 :     rReq.Done();
     352             : 
     353           0 :     sal_Bool bInHeader = sal_True;
     354           0 :     if ( rSh.IsInHeaderFooter( &bInHeader ) )
     355             :     {
     356           0 :         if ( !bInHeader )
     357             :         {
     358           0 :             rSh.SetShowHeaderFooterSeparator( Footer, true );
     359           0 :             rSh.SetShowHeaderFooterSeparator( Header, false );
     360             :         }
     361             :         else
     362             :         {
     363           0 :             rSh.SetShowHeaderFooterSeparator( Header, true );
     364           0 :             rSh.SetShowHeaderFooterSeparator( Footer, false );
     365             :         }
     366             : 
     367             :         // Force repaint
     368           0 :         rSh.GetWin()->Invalidate();
     369             :     }
     370           0 :     if ( rSh.IsInHeaderFooter() != rSh.IsHeaderFooterEdit() )
     371           0 :         rSh.ToggleHeaderFooterEdit();
     372          99 : }
     373             : 
     374             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10