LCOV - code coverage report
Current view: top level - sw/source/ui/wrtsh - select.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 61 508 12.0 %
Date: 2012-08-25 Functions: 7 49 14.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 27 595 4.5 %

           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 <limits.h>
      30                 :            : #include <hintids.hxx>
      31                 :            : #include <sfx2/bindings.hxx>
      32                 :            : #include <svl/eitem.hxx>
      33                 :            : #include <svl/macitem.hxx>
      34                 :            : #include <unotools/charclass.hxx>
      35                 :            : #include <editeng/scripttypeitem.hxx>
      36                 :            : #include <cmdid.h>
      37                 :            : #include <view.hxx>
      38                 :            : #include <basesh.hxx>
      39                 :            : #include <wrtsh.hxx>
      40                 :            : #include <frmatr.hxx>
      41                 :            : #include <initui.hxx>
      42                 :            : #include <mdiexp.hxx>
      43                 :            : #include <fmtcol.hxx>
      44                 :            : #include <frmfmt.hxx>
      45                 :            : #include <swundo.hxx>                   // fuer Undo-Ids
      46                 :            : #include <swevent.hxx>
      47                 :            : #include <swdtflvr.hxx>
      48                 :            : #include <crsskip.hxx>
      49                 :            : #include <wordcountdialog.hxx>
      50                 :            : 
      51                 :            : 
      52                 :            : namespace com { namespace sun { namespace star { namespace util {
      53                 :            :     struct SearchOptions;
      54                 :            : } } } }
      55                 :            : 
      56                 :            : using namespace ::com::sun::star::util;
      57                 :            : 
      58                 :            : 
      59                 :            : static long nStartDragX = 0, nStartDragY = 0;
      60                 :            : static sal_Bool  bStartDrag = sal_False;
      61                 :            : 
      62                 :        104 : void SwWrtShell::Invalidate()
      63                 :            : {
      64                 :            :     // to avoid making the slot volatile, invalidate it everytime if something could have been changed
      65                 :            :     // this is still much cheaper than asking for the state every 200 ms (and avoid background processing)
      66                 :        104 :     GetView().GetViewFrame()->GetBindings().Invalidate( FN_STAT_SELMODE );
      67                 :        104 :     SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
      68         [ -  + ]:        104 :     if (pWrdCnt)
      69                 :          0 :         pWrdCnt->UpdateCounts();
      70                 :        104 : }
      71                 :            : 
      72                 :          0 : sal_Bool SwWrtShell::SelNearestWrd()
      73                 :            : {
      74         [ #  # ]:          0 :     MV_KONTEXT(this);
      75 [ #  # ][ #  # ]:          0 :     if( !IsInWrd() && !IsEndWrd() && !IsSttWrd() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      76         [ #  # ]:          0 :         PrvWrd();
      77 [ #  # ][ #  # ]:          0 :     if( IsEndWrd() )
      78         [ #  # ]:          0 :         Left(CRSR_SKIP_CELLS, sal_False, 1, sal_False );
      79 [ #  # ][ #  # ]:          0 :     return SelWrd();
      80                 :            : }
      81                 :            : 
      82                 :            : 
      83                 :            : 
      84                 :          0 : sal_Bool SwWrtShell::SelWrd(const Point *pPt, sal_Bool )
      85                 :            : {
      86                 :            :     sal_Bool bRet;
      87                 :            :     {
      88         [ #  # ]:          0 :         MV_KONTEXT(this);
      89         [ #  # ]:          0 :         SttSelect();
      90 [ #  # ][ #  # ]:          0 :         bRet = SwCrsrShell::SelectWord( pPt );
      91                 :            :     }
      92                 :          0 :     EndSelect();
      93         [ #  # ]:          0 :     if( bRet )
      94                 :            :     {
      95                 :          0 :         bSelWrd = sal_True;
      96         [ #  # ]:          0 :         if(pPt)
      97                 :          0 :             aStart = *pPt;
      98                 :            :     }
      99                 :          0 :     return bRet;
     100                 :            : }
     101                 :            : 
     102                 :          0 : void SwWrtShell::SelSentence(const Point *pPt, sal_Bool )
     103                 :            : {
     104                 :            :     {
     105         [ #  # ]:          0 :         MV_KONTEXT(this);
     106         [ #  # ]:          0 :         ClearMark();
     107         [ #  # ]:          0 :         SwCrsrShell::GoStartSentence();
     108         [ #  # ]:          0 :         SttSelect();
     109 [ #  # ][ #  # ]:          0 :         SwCrsrShell::GoEndSentence();
     110                 :            :     }
     111                 :          0 :     EndSelect();
     112         [ #  # ]:          0 :     if(pPt)
     113                 :          0 :         aStart = *pPt;
     114                 :          0 :     bSelLn = sal_True;
     115                 :          0 :     bSelWrd = sal_False;    // SelWord abschalten, sonst geht kein SelLine weiter
     116                 :          0 : }
     117                 :            : 
     118                 :          0 : void SwWrtShell::SelPara(const Point *pPt, sal_Bool )
     119                 :            : {
     120                 :            :     {
     121         [ #  # ]:          0 :         MV_KONTEXT(this);
     122         [ #  # ]:          0 :         ClearMark();
     123         [ #  # ]:          0 :         SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
     124         [ #  # ]:          0 :         SttSelect();
     125 [ #  # ][ #  # ]:          0 :         SwCrsrShell::MovePara( fnParaCurr, fnParaEnd );
     126                 :            :     }
     127                 :          0 :     EndSelect();
     128         [ #  # ]:          0 :     if(pPt)
     129                 :          0 :         aStart = *pPt;
     130                 :          0 :     bSelLn = sal_False;
     131                 :          0 :     bSelWrd = sal_False;    // SelWord abschalten, sonst geht kein SelLine weiter
     132                 :          0 : }
     133                 :            : 
     134                 :            : 
     135                 :          0 : long SwWrtShell::SelAll()
     136                 :            : {
     137                 :          0 :     const sal_Bool bLockedView = IsViewLocked();
     138                 :          0 :     LockView( sal_True );
     139                 :            :     {
     140         [ #  # ]:          0 :         if(bBlockMode)
     141         [ #  # ]:          0 :             LeaveBlockMode();
     142         [ #  # ]:          0 :         MV_KONTEXT(this);
     143                 :          0 :         sal_Bool bMoveTable = sal_False;
     144                 :          0 :         SwPosition *pStartPos = 0;
     145                 :          0 :         SwPosition *pEndPos = 0;
     146                 :          0 :         SwShellCrsr* pTmpCrsr = 0;
     147 [ #  # ][ #  # ]:          0 :         if( !HasWholeTabSelection() )
     148                 :            :         {
     149 [ #  # ][ #  # ]:          0 :             if ( IsSelection() && IsCrsrPtAtEnd() )
         [ #  # ][ #  # ]
     150         [ #  # ]:          0 :                 SwapPam();
     151         [ #  # ]:          0 :             pTmpCrsr = getShellCrsr( false );
     152         [ #  # ]:          0 :             if( pTmpCrsr )
     153                 :            :             {
     154 [ #  # ][ #  # ]:          0 :                 pStartPos = new SwPosition( *pTmpCrsr->GetPoint() );
     155 [ #  # ][ #  # ]:          0 :                 pEndPos = new SwPosition( *pTmpCrsr->GetMark() );
     156                 :            :             }
     157         [ #  # ]:          0 :             Push();
     158         [ #  # ]:          0 :             sal_Bool bIsFullSel = !MoveSection( fnSectionCurr, fnSectionStart);
     159         [ #  # ]:          0 :             SwapPam();
     160         [ #  # ]:          0 :             bIsFullSel &= !MoveSection( fnSectionCurr, fnSectionEnd);
     161         [ #  # ]:          0 :             Pop(sal_False);
     162         [ #  # ]:          0 :             GoStart(sal_True, &bMoveTable, sal_False, !bIsFullSel);
     163                 :            :         }
     164                 :            :         else
     165                 :            :         {
     166         [ #  # ]:          0 :             EnterStdMode();
     167         [ #  # ]:          0 :             SttEndDoc(sal_True);
     168                 :            :         }
     169         [ #  # ]:          0 :         SttSelect();
     170         [ #  # ]:          0 :         GoEnd(sal_True, &bMoveTable);
     171         [ #  # ]:          0 :         if( pStartPos )
     172                 :            :         {
     173         [ #  # ]:          0 :             pTmpCrsr = getShellCrsr( false );
     174         [ #  # ]:          0 :             if( pTmpCrsr )
     175                 :            :             {
     176                 :            :                 // Some special handling for sections (e.g. TOC) at the beginning of the document body
     177                 :            :                 // to avoid the selection of the first section
     178                 :            :                 // if the last selection was behind the first section or
     179                 :            :                 // if the last selection was already the first section
     180                 :            :                 // In this both cases we select to the end of document
     181 [ #  # ][ #  # ]:          0 :                 if( *pTmpCrsr->GetPoint() < *pEndPos ||
         [ #  # ][ #  # ]
                 [ #  # ]
     182         [ #  # ]:          0 :                     ( *pStartPos == *pTmpCrsr->GetMark() &&
     183         [ #  # ]:          0 :                       *pEndPos == *pTmpCrsr->GetPoint() ) )
     184         [ #  # ]:          0 :                     SwCrsrShell::SttEndDoc(sal_False);
     185                 :            :             }
     186 [ #  # ][ #  # ]:          0 :             delete pStartPos;
     187 [ #  # ][ #  # ]:          0 :             delete pEndPos;
     188         [ #  # ]:          0 :         }
     189                 :            :     }
     190                 :          0 :     EndSelect();
     191                 :          0 :     LockView( bLockedView );
     192                 :          0 :     return 1;
     193                 :            : }
     194                 :            : 
     195                 :            : /*------------------------------------------------------------------------
     196                 :            :  Beschreibung:  Textsuche
     197                 :            : ------------------------------------------------------------------------*/
     198                 :            : 
     199                 :            : 
     200                 :          0 : sal_uLong SwWrtShell::SearchPattern( const SearchOptions& rSearchOpt, sal_Bool bSearchInNotes,
     201                 :            :                                 SwDocPositions eStt, SwDocPositions eEnd,
     202                 :            :                                 FindRanges eFlags, int bReplace )
     203                 :            : {
     204                 :            :         // keine Erweiterung bestehender Selektionen
     205         [ #  # ]:          0 :     if(!(eFlags & FND_IN_SEL))
     206         [ #  # ]:          0 :         ClearMark();
     207                 :          0 :     sal_Bool bCancel = sal_False;
     208         [ #  # ]:          0 :     sal_uLong nRet = Find( rSearchOpt, bSearchInNotes, eStt, eEnd, bCancel, eFlags, bReplace );
     209         [ #  # ]:          0 :     if(bCancel)
     210                 :            :     {
     211         [ #  # ]:          0 :         Undo(1);
     212                 :          0 :         nRet = ULONG_MAX;
     213                 :            :     }
     214                 :          0 :     return nRet;
     215                 :            : }
     216                 :            : /*------------------------------------------------------------------------
     217                 :            :  Beschreibung:  Suche nach Vorlagen
     218                 :            : ------------------------------------------------------------------------*/
     219                 :            : 
     220                 :            : 
     221                 :            : 
     222                 :          0 : sal_uLong SwWrtShell::SearchTempl( const String &rTempl,
     223                 :            :                                SwDocPositions eStt, SwDocPositions eEnd,
     224                 :            :                                FindRanges eFlags, const String* pReplTempl )
     225                 :            : {
     226                 :            :         // keine Erweiterung bestehender Selektionen
     227         [ #  # ]:          0 :     if(!(eFlags & FND_IN_SEL))
     228         [ #  # ]:          0 :         ClearMark();
     229         [ #  # ]:          0 :     SwTxtFmtColl *pColl = GetParaStyle(rTempl, SwWrtShell::GETSTYLE_CREATESOME);
     230                 :          0 :     SwTxtFmtColl *pReplaceColl = 0;
     231         [ #  # ]:          0 :     if( pReplTempl )
     232         [ #  # ]:          0 :         pReplaceColl = GetParaStyle(*pReplTempl, SwWrtShell::GETSTYLE_CREATESOME );
     233                 :            : 
     234                 :          0 :     sal_Bool bCancel = sal_False;
     235                 :          0 :     sal_uLong nRet = Find(pColl? *pColl: GetDfltTxtFmtColl(),
     236 [ #  # ][ #  # ]:          0 :                                eStt,eEnd, bCancel, eFlags, pReplaceColl);
                 [ #  # ]
     237         [ #  # ]:          0 :     if(bCancel)
     238                 :            :     {
     239         [ #  # ]:          0 :         Undo(1);
     240                 :          0 :         nRet = ULONG_MAX;
     241                 :            :     }
     242                 :          0 :     return nRet;
     243                 :            : }
     244                 :            : 
     245                 :            : // Suche nach Attributen ----------------------------------------------------
     246                 :            : 
     247                 :            : 
     248                 :            : 
     249                 :          0 : sal_uLong SwWrtShell::SearchAttr( const SfxItemSet& rFindSet, sal_Bool bNoColls,
     250                 :            :                                 SwDocPositions eStart, SwDocPositions eEnde,
     251                 :            :                                 FindRanges eFlags, const SearchOptions* pSearchOpt,
     252                 :            :                                 const SfxItemSet* pReplaceSet )
     253                 :            : {
     254                 :            :     // Keine Erweiterung bestehender Selektionen
     255         [ #  # ]:          0 :     if (!(eFlags & FND_IN_SEL))
     256         [ #  # ]:          0 :         ClearMark();
     257                 :            : 
     258                 :            :     // Suchen
     259                 :          0 :     sal_Bool bCancel = sal_False;
     260         [ #  # ]:          0 :     sal_uLong nRet = Find( rFindSet, bNoColls, eStart, eEnde, bCancel, eFlags, pSearchOpt, pReplaceSet);
     261                 :            : 
     262         [ #  # ]:          0 :     if(bCancel)
     263                 :            :     {
     264         [ #  # ]:          0 :         Undo(1);
     265                 :          0 :         nRet = ULONG_MAX;
     266                 :            :     }
     267                 :          0 :     return nRet;
     268                 :            : }
     269                 :            : 
     270                 :            : // ---------- Selektionsmodi ----------
     271                 :            : 
     272                 :            : 
     273                 :            : 
     274                 :          0 : void SwWrtShell::PushMode()
     275                 :            : {
     276                 :          0 :     pModeStack = new ModeStack( pModeStack, bIns, bExtMode, bAddMode, bBlockMode );
     277                 :          0 : }
     278                 :            : 
     279                 :            : 
     280                 :            : 
     281                 :          0 : void SwWrtShell::PopMode()
     282                 :            : {
     283         [ #  # ]:          0 :     if ( 0 == pModeStack )
     284                 :          0 :         return;
     285                 :            : 
     286 [ #  # ][ #  # ]:          0 :     if ( bExtMode && !pModeStack->bExt )
     287                 :          0 :         LeaveExtMode();
     288 [ #  # ][ #  # ]:          0 :     if ( bAddMode && !pModeStack->bAdd )
     289                 :          0 :         LeaveAddMode();
     290 [ #  # ][ #  # ]:          0 :     if ( bBlockMode && !pModeStack->bBlock )
     291                 :          0 :         LeaveBlockMode();
     292                 :          0 :     bIns = pModeStack->bIns;
     293                 :            : 
     294                 :          0 :     ModeStack *pTmp = pModeStack->pNext;
     295                 :          0 :     delete pModeStack;
     296                 :          0 :     pModeStack = pTmp;
     297                 :            : }
     298                 :            : 
     299                 :            : /*
     300                 :            :  * Zwei Methoden fuer das Cursorsetzen; die erste mappt auf die
     301                 :            :  * gleichnamige Methoden an der CursorShell, die zweite hebt
     302                 :            :  * zuerst alle Selektionen auf.
     303                 :            :  */
     304                 :            : 
     305                 :            : 
     306                 :            : 
     307                 :          0 : long SwWrtShell::SetCrsr(const Point *pPt, sal_Bool bTextOnly)
     308                 :            : {
     309                 :            :         /*
     310                 :            :         * eine gfs.  bestehende Selektion an der Position des
     311                 :            :         * Mausklicks aufheben
     312                 :            :         */
     313 [ #  # ][ #  # ]:          0 :     if(!IsInSelect() && ChgCurrPam(*pPt)) {
                 [ #  # ]
     314                 :          0 :         ClearMark();
     315                 :            :     }
     316                 :            : 
     317                 :          0 :     return SwCrsrShell::SetCrsr(*pPt, bTextOnly);
     318                 :            : }
     319                 :            : 
     320                 :            : 
     321                 :          0 : long SwWrtShell::SetCrsrKillSel(const Point *pPt, sal_Bool bTextOnly )
     322                 :            : {
     323         [ #  # ]:          0 :     ACT_KONTEXT(this);
     324         [ #  # ]:          0 :     ResetSelect(pPt,sal_False);
     325 [ #  # ][ #  # ]:          0 :     return SwCrsrShell::SetCrsr(*pPt, bTextOnly);
     326                 :            : }
     327                 :            : 
     328                 :            : 
     329                 :            : 
     330                 :          0 : void SwWrtShell::UnSelectFrm()
     331                 :            : {
     332                 :            :     // Rahmenselektion aufheben mit garantiert ungueltiger Position
     333                 :          0 :     Point aPt(LONG_MIN, LONG_MIN);
     334         [ #  # ]:          0 :     SelectObj(aPt, 0);
     335         [ #  # ]:          0 :     SwTransferable::ClearSelection( *this );
     336                 :          0 : }
     337                 :            : 
     338                 :            : /*
     339                 :            :  * Aufheben aller Selektionen
     340                 :            :  */
     341                 :            : 
     342                 :            : 
     343                 :            : 
     344                 :         31 : long SwWrtShell::ResetSelect(const Point *,sal_Bool)
     345                 :            : {
     346         [ -  + ]:         31 :     if(IsSelFrmMode())
     347                 :            :     {
     348                 :          0 :         UnSelectFrm();
     349                 :          0 :         LeaveSelFrmMode();
     350                 :            :     }
     351                 :            :     else
     352                 :            :     {
     353                 :            :         /*  ACT_KONTEXT() macht eine Action auf -
     354                 :            :             um im Basicablauf keine Probleme mit der
     355                 :            :             Shellumschaltung zu bekommen, darf
     356                 :            :             GetChgLnk().Call() erst nach
     357                 :            :             EndAction() gerufen werden.
     358                 :            :         */
     359                 :            :         {
     360         [ +  - ]:         31 :             ACT_KONTEXT(this);
     361                 :         31 :             bSelWrd = bSelLn = sal_False;
     362         [ +  - ]:         31 :             KillPams();
     363         [ +  - ]:         31 :             ClearMark();
     364                 :         31 :             fnKillSel = &SwWrtShell::Ignore;
     365         [ +  - ]:         31 :             fnSetCrsr = &SwWrtShell::SetCrsr;
     366                 :            :         }
     367                 :            :         /*
     368                 :            :             * nach dem Aufheben aller Selektionen koennte ein Update der
     369                 :            :             * Attr-Controls notwendig sein.
     370                 :            :         */
     371                 :         31 :         GetChgLnk().Call(this);
     372                 :            :     }
     373                 :         31 :     Invalidate();
     374                 :         31 :     SwTransferable::ClearSelection( *this );
     375                 :         31 :     return 1;
     376                 :            : }
     377                 :            : 
     378                 :            : 
     379                 :            : 
     380                 :            : /*
     381                 :            :  * tue nichts
     382                 :            :  */
     383                 :         16 : long SwWrtShell::Ignore(const Point *, sal_Bool ) {
     384                 :         16 :     return 1;
     385                 :            : }
     386                 :            : 
     387                 :            : /*
     388                 :            :  * Start eines Selektionsvorganges.
     389                 :            :  */
     390                 :            : 
     391                 :            : 
     392                 :            : 
     393                 :         46 : void SwWrtShell::SttSelect()
     394                 :            : {
     395         [ +  + ]:         46 :     if(bInSelect)
     396                 :         46 :         return;
     397         [ +  - ]:         20 :     if(!HasMark())
     398                 :         20 :         SetMark();
     399         [ -  + ]:         20 :     if( bBlockMode )
     400                 :            :     {
     401                 :          0 :         SwShellCrsr* pTmp = getShellCrsr( true );
     402         [ #  # ]:          0 :         if( !pTmp->HasMark() )
     403                 :          0 :             pTmp->SetMark();
     404                 :            :     }
     405                 :         20 :     fnKillSel = &SwWrtShell::Ignore;
     406                 :         20 :     fnSetCrsr = &SwWrtShell::SetCrsr;
     407                 :         20 :     bInSelect = sal_True;
     408                 :         20 :     Invalidate();
     409                 :         20 :     SwTransferable::CreateSelection( *this );
     410                 :            : }
     411                 :            : /*
     412                 :            :  * Ende eines Selektionsvorganges.
     413                 :            :  */
     414                 :            : 
     415                 :            : 
     416                 :            : 
     417                 :         47 : void SwWrtShell::EndSelect()
     418                 :            : {
     419 [ +  + ][ +  - ]:         47 :     if(bInSelect && !bExtMode)
     420                 :            :     {
     421                 :         10 :         bInSelect = sal_False;
     422         [ -  + ]:         10 :         if (bAddMode)
     423                 :            :         {
     424                 :          0 :             AddLeaveSelect(0, sal_False);
     425                 :            :         }
     426                 :            :         else
     427                 :            :         {
     428                 :         10 :             SttLeaveSelect(0, sal_False);
     429                 :         10 :             fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
     430                 :         10 :             fnKillSel = &SwWrtShell::ResetSelect;
     431                 :            :         }
     432                 :            :     }
     433                 :         47 :     SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
     434         [ -  + ]:         47 :     if (pWrdCnt)
     435                 :          0 :         pWrdCnt->UpdateCounts();
     436                 :         47 : }
     437                 :            : /* Methode, um eine bestehende wortweise oder zeilenweise Selektion
     438                 :            :  * zu erweitern.
     439                 :            :  */
     440                 :            : 
     441                 :            : inline sal_Bool operator<(const Point &rP1,const Point &rP2)
     442                 :            : {
     443                 :            :     return rP1.Y() < rP2.Y() || (rP1.Y() == rP2.Y() && rP1.X() < rP2.X());
     444                 :            : }
     445                 :            : 
     446                 :            : 
     447                 :            : 
     448                 :          0 : long SwWrtShell::ExtSelWrd(const Point *pPt, sal_Bool )
     449                 :            : {
     450         [ #  # ]:          0 :     MV_KONTEXT(this);
     451         [ #  # ]:          0 :     if( IsTableMode() )
     452                 :          0 :         return 1;
     453                 :            : 
     454                 :            :     // Bug 66823: actual crsr has in additional mode no selection?
     455                 :            :     // Then destroy the actual an go to prev, this will be expand
     456 [ #  # ][ #  # ]:          0 :     if( !HasMark() && GoPrevCrsr() )
         [ #  # ][ #  # ]
     457                 :            :     {
     458                 :          0 :         sal_Bool bHasMark = HasMark(); // thats wrong!
     459         [ #  # ]:          0 :         GoNextCrsr();
     460         [ #  # ]:          0 :         if( bHasMark )
     461                 :            :         {
     462         [ #  # ]:          0 :             DestroyCrsr();
     463         [ #  # ]:          0 :             GoPrevCrsr();
     464                 :            :         }
     465                 :            :     }
     466                 :            : 
     467                 :            :     // check the direction of the selection with the new point
     468                 :          0 :     sal_Bool bRet = sal_False, bMoveCrsr = sal_True, bToTop = sal_False;
     469         [ #  # ]:          0 :     SwCrsrShell::SelectWord( &aStart );     // select the startword
     470         [ #  # ]:          0 :     SwCrsrShell::Push();                    // save the cursor
     471         [ #  # ]:          0 :     SwCrsrShell::SetCrsr( *pPt );           // and check the direction
     472                 :            : 
     473         [ #  # ]:          0 :     switch( SwCrsrShell::CompareCursor( StackMkCurrPt ))
              [ #  #  # ]
     474                 :            :     {
     475                 :          0 :     case -1:    bToTop = sal_False;     break;
     476                 :          0 :     case 1:     bToTop = sal_True;      break;
     477                 :          0 :     default:    bMoveCrsr = sal_False;  break;
     478                 :            :     }
     479                 :            : 
     480         [ #  # ]:          0 :     SwCrsrShell::Pop( sal_False );              // retore the saved cursor
     481                 :            : 
     482         [ #  # ]:          0 :     if( bMoveCrsr )
     483                 :            :     {
     484                 :            :         // select to Top but cursor select to Bottom? or
     485                 :            :         // select to Bottom but cursor select to Top?       --> swap the cursor
     486         [ #  # ]:          0 :         if( bToTop )
     487         [ #  # ]:          0 :             SwapPam();
     488                 :            : 
     489         [ #  # ]:          0 :         SwCrsrShell::Push();                // save cur cursor
     490 [ #  # ][ #  # ]:          0 :         if( SwCrsrShell::SelectWord( pPt )) // select the current word
     491                 :            :         {
     492         [ #  # ]:          0 :             if( bToTop )
     493         [ #  # ]:          0 :                 SwapPam();
     494         [ #  # ]:          0 :             Combine();
     495                 :          0 :             bRet = sal_True;
     496                 :            :         }
     497                 :            :         else
     498                 :            :         {
     499         [ #  # ]:          0 :             SwCrsrShell::Pop( sal_False );
     500         [ #  # ]:          0 :             if( bToTop )
     501         [ #  # ]:          0 :                 SwapPam();
     502                 :            :         }
     503                 :            :     }
     504                 :            :     else
     505                 :          0 :         bRet = sal_True;
     506         [ #  # ]:          0 :     return bRet;
     507                 :            : }
     508                 :            : 
     509                 :            : 
     510                 :          0 : long SwWrtShell::ExtSelLn(const Point *pPt, sal_Bool )
     511                 :            : {
     512         [ #  # ]:          0 :     MV_KONTEXT(this);
     513         [ #  # ]:          0 :     SwCrsrShell::SetCrsr(*pPt);
     514         [ #  # ]:          0 :     if( IsTableMode() )
     515                 :          0 :         return 1;
     516                 :            : 
     517                 :            :     // Bug 66823: actual crsr has in additional mode no selection?
     518                 :            :     // Then destroy the actual an go to prev, this will be expand
     519 [ #  # ][ #  # ]:          0 :     if( !HasMark() && GoPrevCrsr() )
         [ #  # ][ #  # ]
     520                 :            :     {
     521                 :          0 :         sal_Bool bHasMark = HasMark(); // thats wrong!
     522         [ #  # ]:          0 :         GoNextCrsr();
     523         [ #  # ]:          0 :         if( bHasMark )
     524                 :            :         {
     525         [ #  # ]:          0 :             DestroyCrsr();
     526         [ #  # ]:          0 :             GoPrevCrsr();
     527                 :            :         }
     528                 :            :     }
     529                 :            : 
     530                 :            :     // ggfs. den Mark der Selektion anpassen
     531         [ #  # ]:          0 :     sal_Bool bToTop = !IsCrsrPtAtEnd();
     532         [ #  # ]:          0 :     SwapPam();
     533                 :            : 
     534                 :            :     // der "Mark" muss am Zeilenende/-anfang stehen
     535 [ #  # ][ #  # ]:          0 :     if( bToTop ? !IsEndSentence() : !IsStartSentence() )
         [ #  # ][ #  # ]
     536                 :            :     {
     537         [ #  # ]:          0 :         if( bToTop )
     538                 :            :         {
     539 [ #  # ][ #  # ]:          0 :             if( !IsEndPara() )
     540         [ #  # ]:          0 :                 SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
     541         [ #  # ]:          0 :             SwCrsrShell::GoEndSentence();
     542                 :            :         }
     543                 :            :         else
     544         [ #  # ]:          0 :             SwCrsrShell::GoStartSentence();
     545                 :            :     }
     546         [ #  # ]:          0 :     SwapPam();
     547                 :            : 
     548 [ #  # ][ #  # ]:          0 :     return bToTop ? SwCrsrShell::GoStartSentence() : SwCrsrShell::GoEndSentence();
         [ #  # ][ #  # ]
     549                 :            : }
     550                 :            : 
     551                 :            : 
     552                 :            : /*
     553                 :            :  * zurueck in den Standard Mode: kein Mode, keine Selektionen.
     554                 :            :  */
     555                 :            : 
     556                 :         53 : void SwWrtShell::EnterStdMode()
     557                 :            : {
     558         [ -  + ]:         53 :     if(bAddMode)
     559                 :          0 :         LeaveAddMode();
     560         [ -  + ]:         53 :     if(bBlockMode)
     561                 :          0 :         LeaveBlockMode();
     562                 :         53 :     bBlockMode = sal_False;
     563                 :         53 :     bExtMode = sal_False;
     564                 :         53 :     bInSelect = sal_False;
     565         [ -  + ]:         53 :     if(IsSelFrmMode())
     566                 :            :     {
     567                 :          0 :         UnSelectFrm();
     568                 :          0 :         LeaveSelFrmMode();
     569                 :            :     }
     570                 :            :     else
     571                 :            :     {
     572                 :            :         /*  ACT_KONTEXT() opens and action which has to be
     573                 :            :             closed prior to the call of
     574                 :            :             GetChgLnk().Call()
     575                 :            :         */
     576                 :            :         {
     577         [ +  - ]:         53 :             ACT_KONTEXT(this);
     578                 :         53 :             bSelWrd = bSelLn = sal_False;
     579         [ +  - ]:         53 :             if( !IsRetainSelection() )
     580         [ +  - ]:         53 :                 KillPams();
     581         [ +  - ]:         53 :             ClearMark();
     582                 :         53 :             fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
     583         [ +  - ]:         53 :             fnKillSel = &SwWrtShell::ResetSelect;
     584                 :            :         }
     585                 :            :     }
     586                 :         53 :     Invalidate();
     587                 :         53 :     SwTransferable::ClearSelection( *this );
     588                 :         53 : }
     589                 :            : 
     590                 :            : /*
     591                 :            :  * Extended Mode
     592                 :            :  */
     593                 :            : 
     594                 :            : 
     595                 :            : 
     596                 :          0 : void SwWrtShell::EnterExtMode()
     597                 :            : {
     598         [ #  # ]:          0 :     if(bBlockMode)
     599                 :            :     {
     600                 :          0 :         LeaveBlockMode();
     601                 :          0 :         KillPams();
     602                 :          0 :         ClearMark();
     603                 :            :     }
     604                 :          0 :     bExtMode = sal_True;
     605                 :          0 :     bAddMode = sal_False;
     606                 :          0 :     bBlockMode = sal_False;
     607                 :          0 :     SttSelect();
     608                 :          0 : }
     609                 :            : 
     610                 :            : 
     611                 :            : 
     612                 :          0 : void SwWrtShell::LeaveExtMode()
     613                 :            : {
     614                 :          0 :     bExtMode = sal_False;
     615                 :          0 :     EndSelect();
     616                 :          0 : }
     617                 :            : /*
     618                 :            :  * Ende einer Selektion; falls die Selektion leer ist,
     619                 :            :  * ClearMark().
     620                 :            :  */
     621                 :            : 
     622                 :            : 
     623                 :            : 
     624                 :         10 : long SwWrtShell::SttLeaveSelect(const Point *, sal_Bool )
     625                 :            : {
     626 [ +  - ][ +  - ]:         10 :     if(SwCrsrShell::HasSelection() && !IsSelTblCells() && bClearMark) {
         [ +  - ][ +  - ]
     627                 :         10 :         return 0;
     628                 :            :     }
     629                 :          0 :     ClearMark();
     630                 :         10 :     return 1;
     631                 :            : }
     632                 :            : /*
     633                 :            :  * Verlassen des Selektionsmodus in Additional Mode
     634                 :            :  */
     635                 :            : 
     636                 :            : 
     637                 :            : 
     638                 :          0 : long SwWrtShell::AddLeaveSelect(const Point *, sal_Bool )
     639                 :            : {
     640         [ #  # ]:          0 :     if(IsTableMode()) LeaveAddMode();
     641         [ #  # ]:          0 :     else if(SwCrsrShell::HasSelection())
     642                 :          0 :         CreateCrsr();
     643                 :          0 :     return 1;
     644                 :            : }
     645                 :            : /*
     646                 :            :  * Additional Mode
     647                 :            :  */
     648                 :            : 
     649                 :            : 
     650                 :            : 
     651                 :          0 : void SwWrtShell::EnterAddMode()
     652                 :            : {
     653         [ #  # ]:          0 :     if(IsTableMode()) return;
     654         [ #  # ]:          0 :     if(bBlockMode)
     655                 :          0 :         LeaveBlockMode();
     656                 :          0 :     fnKillSel = &SwWrtShell::Ignore;
     657                 :          0 :     fnSetCrsr = &SwWrtShell::SetCrsr;
     658                 :          0 :     bAddMode = sal_True;
     659                 :          0 :     bBlockMode = sal_False;
     660                 :          0 :     bExtMode = sal_False;
     661         [ #  # ]:          0 :     if(SwCrsrShell::HasSelection())
     662                 :          0 :         CreateCrsr();
     663                 :          0 :     Invalidate();
     664                 :            : }
     665                 :            : 
     666                 :            : 
     667                 :            : 
     668                 :          0 : void SwWrtShell::LeaveAddMode()
     669                 :            : {
     670                 :          0 :     fnKillSel = &SwWrtShell::ResetSelect;
     671                 :          0 :     fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
     672                 :          0 :     bAddMode = sal_False;
     673                 :          0 :     Invalidate();
     674                 :          0 : }
     675                 :            : 
     676                 :            : /*
     677                 :            :  * Block Mode
     678                 :            :  */
     679                 :            : 
     680                 :          0 : void SwWrtShell::EnterBlockMode()
     681                 :            : {
     682                 :          0 :     bBlockMode = sal_False;
     683                 :          0 :     EnterStdMode();
     684                 :          0 :     bBlockMode = sal_True;
     685                 :          0 :     CrsrToBlockCrsr();
     686                 :          0 :     Invalidate();
     687                 :          0 : }
     688                 :            : 
     689                 :            : 
     690                 :            : 
     691                 :          0 : void SwWrtShell::LeaveBlockMode()
     692                 :            : {
     693                 :          0 :     bBlockMode = sal_False;
     694                 :          0 :     BlockCrsrToCrsr();
     695                 :          0 :     EndSelect();
     696                 :          0 :     Invalidate();
     697                 :          0 : }
     698                 :            : 
     699                 :            : // Einfuegemodus
     700                 :            : 
     701                 :            : 
     702                 :            : 
     703                 :          0 : void SwWrtShell::SetInsMode( sal_Bool bOn )
     704                 :            : {
     705                 :          0 :     bIns = bOn;
     706                 :          0 :     SwCrsrShell::SetOverwriteCrsr( !bIns );
     707         [ #  # ]:          0 :     const SfxBoolItem aTmp( SID_ATTR_INSERT, bIns );
     708         [ #  # ]:          0 :     GetView().GetViewFrame()->GetBindings().SetState( aTmp );
     709         [ #  # ]:          0 :     StartAction();
     710         [ #  # ]:          0 :     EndAction();
     711 [ #  # ][ #  # ]:          0 :     Invalidate();
     712                 :          0 : }
     713                 :            : //Overwrite mode is incompatible with red-lining
     714                 :          0 : void SwWrtShell::SetRedlineModeAndCheckInsMode( sal_uInt16 eMode )
     715                 :            : {
     716                 :          0 :    SetRedlineMode( eMode );
     717         [ #  # ]:          0 :    if (IsRedlineOn())
     718                 :          0 :        SetInsMode( true );
     719                 :          0 : }
     720                 :            : 
     721                 :            : /*
     722                 :            :  * Rahmen bearbeiten
     723                 :            :  */
     724                 :            : 
     725                 :            : 
     726                 :          0 : long SwWrtShell::BeginFrmDrag(const Point *pPt, sal_Bool)
     727                 :            : {
     728                 :          0 :     fnDrag = &SwFEShell::Drag;
     729         [ #  # ]:          0 :     if(bStartDrag)
     730                 :            :     {
     731                 :          0 :         Point aTmp( nStartDragX, nStartDragY );
     732         [ #  # ]:          0 :         SwFEShell::BeginDrag( &aTmp, sal_False );
     733                 :            :     }
     734                 :            :     else
     735                 :          0 :         SwFEShell::BeginDrag( pPt, sal_False );
     736                 :          0 :     return 1;
     737                 :            : }
     738                 :            : 
     739                 :            : 
     740                 :            : 
     741                 :          0 : void SwWrtShell::EnterSelFrmMode(const Point *pPos)
     742                 :            : {
     743         [ #  # ]:          0 :     if(pPos)
     744                 :            :     {
     745                 :          0 :         nStartDragX = pPos->X();
     746                 :          0 :         nStartDragY = pPos->Y();
     747                 :          0 :         bStartDrag = sal_True;
     748                 :            :     }
     749                 :          0 :     bNoEdit = bLayoutMode = sal_True;
     750                 :          0 :     HideCrsr();
     751                 :            : 
     752                 :            :         // gleicher Aufruf von BeginDrag an der SwFEShell
     753                 :          0 :     fnDrag          = &SwWrtShell::BeginFrmDrag;
     754                 :          0 :     fnEndDrag       = &SwWrtShell::UpdateLayoutFrm;
     755                 :          0 :     SwBaseShell::SetFrmMode( FLY_DRAG_START, this );
     756                 :          0 :     Invalidate();
     757                 :          0 : }
     758                 :            : 
     759                 :            : 
     760                 :            : 
     761                 :          0 : void SwWrtShell::LeaveSelFrmMode()
     762                 :            : {
     763                 :          0 :     fnDrag          = &SwWrtShell::BeginDrag;
     764                 :          0 :     fnEndDrag       = &SwWrtShell::EndDrag;
     765                 :          0 :     bLayoutMode = sal_False;
     766                 :          0 :     bStartDrag = sal_False;
     767                 :          0 :     Edit();
     768                 :          0 :     SwBaseShell::SetFrmMode( FLY_DRAG_END, this );
     769                 :          0 :     Invalidate();
     770                 :          0 : }
     771                 :            : /*------------------------------------------------------------------------
     772                 :            :  Beschreibung:  Rahmengebundenes Macro ausfuehren
     773                 :            : ------------------------------------------------------------------------*/
     774                 :            : 
     775                 :            : 
     776                 :            : 
     777                 :          0 : IMPL_LINK( SwWrtShell, ExecFlyMac, void *, pFlyFmt )
     778                 :            : {
     779         [ #  # ]:          0 :     const SwFrmFmt *pFmt = pFlyFmt ? (SwFrmFmt*)pFlyFmt : GetFlyFrmFmt();
     780                 :            :     OSL_ENSURE(pFmt, "no frame format");
     781                 :          0 :     const SvxMacroItem &rFmtMac = pFmt->GetMacro();
     782                 :            : 
     783         [ #  # ]:          0 :     if(rFmtMac.HasMacro(SW_EVENT_OBJECT_SELECT))
     784                 :            :     {
     785                 :          0 :         const SvxMacro &rMac = rFmtMac.GetMacro(SW_EVENT_OBJECT_SELECT);
     786         [ #  # ]:          0 :         if( IsFrmSelected() )
     787                 :          0 :             bLayoutMode = sal_True;
     788                 :          0 :         CallChgLnk();
     789                 :          0 :         ExecMacro( rMac );
     790                 :            :     }
     791                 :          0 :     return 0;
     792                 :            : }
     793                 :            : 
     794                 :            : 
     795                 :            : 
     796                 :          0 : long SwWrtShell::UpdateLayoutFrm(const Point *pPt, sal_Bool )
     797                 :            : {
     798                 :            :         // voerst Dummy
     799                 :          0 :     SwFEShell::EndDrag( pPt, sal_False );
     800                 :          0 :     fnDrag = &SwWrtShell::BeginFrmDrag;
     801                 :          0 :     return 1;
     802                 :            : }
     803                 :            : 
     804                 :            : /*
     805                 :            :  * Handler fuer das Togglen der Modi. Liefern alten Mode zurueck.
     806                 :            :  */
     807                 :            : 
     808                 :            : 
     809                 :            : 
     810                 :          0 : long SwWrtShell::ToggleAddMode()
     811                 :            : {
     812         [ #  # ]:          0 :     bAddMode ? LeaveAddMode(): EnterAddMode();
     813                 :          0 :     Invalidate();
     814                 :          0 :     return !bAddMode;
     815                 :            : }
     816                 :            : 
     817                 :            : 
     818                 :          0 : long SwWrtShell::ToggleBlockMode()
     819                 :            : {
     820         [ #  # ]:          0 :     bBlockMode ? LeaveBlockMode(): EnterBlockMode();
     821                 :          0 :     Invalidate();
     822                 :          0 :     return !bBlockMode;
     823                 :            : }
     824                 :            : 
     825                 :            : 
     826                 :          0 : long SwWrtShell::ToggleExtMode()
     827                 :            : {
     828         [ #  # ]:          0 :     bExtMode ? LeaveExtMode() : EnterExtMode();
     829                 :          0 :     Invalidate();
     830                 :          0 :     return !bExtMode;
     831                 :            : }
     832                 :            : /*
     833                 :            :  * Draggen im Standard Modus (Selektieren von Inhalt)
     834                 :            :  */
     835                 :            : 
     836                 :            : 
     837                 :            : 
     838                 :          0 : long SwWrtShell::BeginDrag(const Point * /*pPt*/, sal_Bool )
     839                 :            : {
     840         [ #  # ]:          0 :     if(bSelWrd)
     841                 :            :     {
     842                 :          0 :         bInSelect = sal_True;
     843         [ #  # ]:          0 :         if( !IsCrsrPtAtEnd() )
     844                 :          0 :             SwapPam();
     845                 :            : 
     846                 :          0 :         fnDrag = &SwWrtShell::ExtSelWrd;
     847                 :          0 :         fnSetCrsr = &SwWrtShell::Ignore;
     848                 :            :     }
     849         [ #  # ]:          0 :     else if(bSelLn)
     850                 :            :     {
     851                 :          0 :         bInSelect = sal_True;
     852                 :          0 :         fnDrag = &SwWrtShell::ExtSelLn;
     853                 :          0 :         fnSetCrsr = &SwWrtShell::Ignore;
     854                 :            :     }
     855                 :            :     else
     856                 :            :     {
     857                 :          0 :         fnDrag = &SwWrtShell::Drag;
     858                 :          0 :         SttSelect();
     859                 :            :     }
     860                 :            : 
     861                 :          0 :     return 1;
     862                 :            : }
     863                 :            : 
     864                 :            : 
     865                 :            : 
     866                 :          0 : long SwWrtShell::Drag(const Point *, sal_Bool )
     867                 :            : {
     868         [ #  # ]:          0 :     if( IsSelTblCells() )
     869                 :          0 :         aSelTblLink.Call(this);
     870                 :            : 
     871                 :          0 :     return 1;
     872                 :            : }
     873                 :            : 
     874                 :            : 
     875                 :            : 
     876                 :          0 : long SwWrtShell::EndDrag(const Point * /*pPt*/, sal_Bool )
     877                 :            : {
     878                 :          0 :     fnDrag = &SwWrtShell::BeginDrag;
     879         [ #  # ]:          0 :     if( IsExtSel() )
     880                 :          0 :         LeaveExtSel();
     881                 :            : 
     882         [ #  # ]:          0 :     if( IsSelTblCells() )
     883                 :          0 :         aSelTblLink.Call(this);
     884                 :          0 :     EndSelect();
     885                 :          0 :     return 1;
     886                 :            : }
     887                 :            : 
     888                 :            : // #i32329# Enhanced table selection
     889                 :          0 : sal_Bool SwWrtShell::SelectTableRowCol( const Point& rPt, const Point* pEnd, bool bRowDrag )
     890                 :            : {
     891         [ #  # ]:          0 :     MV_KONTEXT(this);
     892         [ #  # ]:          0 :     SttSelect();
     893 [ #  # ][ #  # ]:          0 :     if(SelTblRowCol( rPt, pEnd, bRowDrag ))
     894                 :            :     {
     895                 :          0 :         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
     896                 :          0 :         fnKillSel = &SwWrtShell::ResetSelect;
     897                 :          0 :         return sal_True;
     898                 :            :     }
     899         [ #  # ]:          0 :     return sal_False;
     900                 :            : }
     901                 :            : 
     902                 :            : /*------------------------------------------------------------------------
     903                 :            :  Beschreibung:  Selektion einer Tabellenzeile / Spalte
     904                 :            : ------------------------------------------------------------------------*/
     905                 :            : 
     906                 :          0 : sal_Bool SwWrtShell::SelectTableRow()
     907                 :            : {
     908         [ #  # ]:          0 :     if ( SelTblRow() )
     909                 :            :     {
     910                 :          0 :         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
     911                 :          0 :         fnKillSel = &SwWrtShell::ResetSelect;
     912                 :          0 :         return sal_True;
     913                 :            :     }
     914                 :          0 :     return sal_False;
     915                 :            : }
     916                 :            : 
     917                 :            : 
     918                 :            : 
     919                 :          0 : sal_Bool SwWrtShell::SelectTableCol()
     920                 :            : {
     921         [ #  # ]:          0 :     if ( SelTblCol() )
     922                 :            :     {
     923                 :          0 :         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
     924                 :          0 :         fnKillSel = &SwWrtShell::ResetSelect;
     925                 :          0 :         return sal_True;
     926                 :            :     }
     927                 :          0 :     return sal_False;
     928                 :            : }
     929                 :            : 
     930                 :          0 : sal_Bool SwWrtShell::SelectTableCell()
     931                 :            : {
     932         [ #  # ]:          0 :     if ( SelTblBox() )
     933                 :            :     {
     934                 :          0 :         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
     935                 :          0 :         fnKillSel = &SwWrtShell::ResetSelect;
     936                 :          0 :         return sal_True;
     937                 :            :     }
     938                 :          0 :     return sal_False;
     939                 :            : }
     940                 :            : /*------------------------------------------------------------------------
     941                 :            :  Beschreibung:    Prueft, ob eine Wortselektion vorliegt.
     942                 :            :                   Gemaess den Regeln fuer intelligentes Cut / Paste
     943                 :            :                   werden umgebende Spaces rausgeschnitten.
     944                 :            :  Return:          Liefert Art der Wortselektion zurueck.
     945                 :            : ------------------------------------------------------------------------*/
     946                 :            : 
     947                 :            : 
     948                 :            : 
     949                 :          0 : int SwWrtShell::IntelligentCut(int nSelection, sal_Bool bCut)
     950                 :            : {
     951                 :            :         // kein intelligentes Drag and Drop bei Mehrfachselektion
     952                 :            :         // es existieren mehrere Cursor, da ein zweiter bereits
     953                 :            :         // an die Zielposition gesetzt wurde
     954 [ #  # ][ #  # ]:          0 :     if( IsAddMode() || !(nSelection & nsSelectionType::SEL_TXT) )
                 [ #  # ]
     955                 :          0 :         return sal_False;
     956                 :            : 
     957         [ #  # ]:          0 :     String sTxt;
     958         [ #  # ]:          0 :     CharClass& rCC = GetAppCharClass();
     959                 :            : 
     960                 :            :         // wenn das erste und das letzte Zeichen kein Wortzeichen ist,
     961                 :            :         // ist kein Wort selektiert.
     962         [ #  # ]:          0 :     sal_Unicode cPrev = GetChar(sal_False);
     963         [ #  # ]:          0 :     sal_Unicode cNext = GetChar(sal_True, -1);
     964 [ #  # ][ #  # ]:          0 :     if( !cPrev || !cNext ||
         [ #  # ][ #  # ]
                 [ #  # ]
     965 [ #  # ][ #  # ]:          0 :         !rCC.isLetterNumeric( ( sTxt = cPrev), 0 ) ||
     966 [ #  # ][ #  # ]:          0 :         !rCC.isLetterNumeric( ( sTxt = cNext), 0 ) )
     967                 :          0 :         return NO_WORD;
     968                 :            : 
     969         [ #  # ]:          0 :     cPrev = GetChar(sal_False, -1);
     970         [ #  # ]:          0 :     cNext = GetChar(sal_True);
     971                 :            : 
     972                 :          0 :     int cWord = NO_WORD;
     973                 :            :         // ist ein Wort selektiert?
     974 [ #  # ][ #  # ]:          0 :     if(!cWord && cPrev && cNext &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     975                 :            :         CH_TXTATR_BREAKWORD != cPrev && CH_TXTATR_INWORD != cPrev &&
     976                 :            :         CH_TXTATR_BREAKWORD != cNext && CH_TXTATR_INWORD != cNext &&
     977 [ #  # ][ #  # ]:          0 :         !rCC.isLetterNumeric( ( sTxt = cPrev), 0 ) &&
     978 [ #  # ][ #  # ]:          0 :         !rCC.isLetterNumeric( ( sTxt = cNext), 0 ) )
     979                 :          0 :        cWord = WORD_NO_SPACE;
     980                 :            : 
     981 [ #  # ][ #  # ]:          0 :     if(cWord == WORD_NO_SPACE && ' ' == cPrev )
     982                 :            :     {
     983                 :          0 :         cWord = WORD_SPACE_BEFORE;
     984                 :            :             // Space davor loeschen
     985         [ #  # ]:          0 :         if(bCut)
     986                 :            :         {
     987         [ #  # ]:          0 :             Push();
     988 [ #  # ][ #  # ]:          0 :             if(IsCrsrPtAtEnd())
     989         [ #  # ]:          0 :                 SwapPam();
     990         [ #  # ]:          0 :             ClearMark();
     991         [ #  # ]:          0 :             SetMark();
     992         [ #  # ]:          0 :             SwCrsrShell::Left(1,CRSR_SKIP_CHARS);
     993         [ #  # ]:          0 :             SwFEShell::Delete();
     994         [ #  # ]:          0 :             Pop( sal_False );
     995                 :            :         }
     996                 :            :     }
     997 [ #  # ][ #  # ]:          0 :     else if(cWord == WORD_NO_SPACE && cNext == ' ')
     998                 :            :     {
     999                 :          0 :         cWord = WORD_SPACE_AFTER;
    1000                 :            :             // Space dahinter loeschen
    1001         [ #  # ]:          0 :         if(bCut) {
    1002         [ #  # ]:          0 :             Push();
    1003 [ #  # ][ #  # ]:          0 :             if(!IsCrsrPtAtEnd()) SwapPam();
                 [ #  # ]
    1004         [ #  # ]:          0 :             ClearMark();
    1005         [ #  # ]:          0 :             SetMark();
    1006         [ #  # ]:          0 :             SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
    1007         [ #  # ]:          0 :             SwFEShell::Delete();
    1008         [ #  # ]:          0 :             Pop( sal_False );
    1009                 :            :         }
    1010                 :            :     }
    1011         [ #  # ]:          0 :     return cWord;
    1012                 :            : }
    1013                 :            : 
    1014                 :            : 
    1015                 :            : 
    1016                 :            :     // jump to the next / previous hyperlink - inside text and also
    1017                 :            :     // on graphics
    1018                 :          0 : sal_Bool SwWrtShell::SelectNextPrevHyperlink( sal_Bool bNext )
    1019                 :            : {
    1020                 :          0 :     StartAction();
    1021                 :          0 :     sal_Bool bRet = SwCrsrShell::SelectNxtPrvHyperlink( bNext );
    1022         [ #  # ]:          0 :     if( !bRet )
    1023                 :            :     {
    1024                 :            :         // will we have this feature?
    1025                 :          0 :         EnterStdMode();
    1026         [ #  # ]:          0 :         if( bNext )
    1027                 :          0 :             SttEndDoc(sal_True);
    1028                 :            :         else
    1029                 :          0 :             SttEndDoc(sal_False);
    1030                 :          0 :         bRet = SwCrsrShell::SelectNxtPrvHyperlink( bNext );
    1031                 :            :     }
    1032                 :          0 :     EndAction();
    1033                 :            : 
    1034                 :          0 :     sal_Bool bCreateXSelection = sal_False;
    1035 [ #  # ][ #  # ]:          0 :     const sal_Bool bFrmSelected = IsFrmSelected() || IsObjSelected();
    1036         [ #  # ]:          0 :     if( IsSelection() )
    1037                 :            :     {
    1038         [ #  # ]:          0 :         if ( bFrmSelected )
    1039                 :          0 :             UnSelectFrm();
    1040                 :            : 
    1041                 :            :         // Funktionspointer fuer das Aufheben der Selektion setzen
    1042                 :            :         // bei Cursor setzen
    1043                 :          0 :         fnKillSel = &SwWrtShell::ResetSelect;
    1044                 :          0 :         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
    1045                 :          0 :         bCreateXSelection = sal_True;
    1046                 :            :     }
    1047         [ #  # ]:          0 :     else if( bFrmSelected )
    1048                 :            :     {
    1049                 :          0 :         EnterSelFrmMode();
    1050                 :          0 :         bCreateXSelection = sal_True;
    1051                 :            :     }
    1052         [ #  # ]:          0 :     else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
    1053                 :            :     {
    1054                 :          0 :         SelectObj( GetCharRect().Pos() );
    1055                 :          0 :         EnterSelFrmMode();
    1056                 :          0 :         bCreateXSelection = sal_True;
    1057                 :            :     }
    1058                 :            : 
    1059         [ #  # ]:          0 :     if( bCreateXSelection )
    1060                 :          0 :         SwTransferable::CreateSelection( *this );
    1061                 :            : 
    1062                 :          0 :     return bRet;
    1063                 :            : }
    1064                 :            : 
    1065                 :            : 
    1066                 :            : /* fuer den Erhalt der Selektion wird nach SetMark() der Cursor
    1067                 :            :  * nach links bewegt, damit er durch das Einfuegen von Text nicht
    1068                 :            :  * verschoben wird.  Da auf der CORE-Seite am aktuellen Cursor
    1069                 :            :  * eine bestehende Selektion aufgehoben wird, wird der Cursor auf
    1070                 :            :  * den Stack gepushed. Nach dem Verschieben werden sie wieder
    1071                 :            :  * zusammengefasst. */
    1072                 :            : 
    1073                 :            : 
    1074                 :            : 
    1075                 :            : 
    1076                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10