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

Generated by: LCOV version 1.10