LCOV - code coverage report
Current view: top level - sw/source/ui/shells - txtcrsr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 179 0.0 %
Date: 2012-08-25 Functions: 0 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 161 0.0 %

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

Generated by: LCOV version 1.10