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

Generated by: LCOV version 1.10