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

Generated by: LCOV version 1.11