LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/docvw - edtwin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 102 3011 3.4 %
Date: 2012-12-27 Functions: 14 74 18.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <swtypes.hxx>
      22             : #include <hintids.hxx>
      23             : #include <com/sun/star/accessibility/XAccessible.hpp>
      24             : #include <comphelper/processfactory.hxx>
      25             : #include <comphelper/string.hxx>
      26             : #include <com/sun/star/i18n/XBreakIterator.hpp>
      27             : #include <com/sun/star/i18n/ScriptType.hpp>
      28             : #include <com/sun/star/i18n/InputSequenceCheckMode.hpp>
      29             : 
      30             : #include <com/sun/star/i18n/UnicodeScript.hpp>
      31             : 
      32             : #include <vcl/help.hxx>
      33             : #include <vcl/graph.hxx>
      34             : #include <vcl/msgbox.hxx>
      35             : #include <vcl/cmdevt.h>
      36             : #include <sot/storage.hxx>
      37             : #include <svl/macitem.hxx>
      38             : #include <unotools/securityoptions.hxx>
      39             : #include <basic/sbxvar.hxx>
      40             : #include <svl/ctloptions.hxx>
      41             : #include <basic/sbx.hxx>
      42             : #include <svl/eitem.hxx>
      43             : #include <svl/stritem.hxx>
      44             : #include <sfx2/ipclient.hxx>
      45             : #include <sfx2/viewfrm.hxx>
      46             : #include <sfx2/request.hxx>
      47             : #include <sfx2/bindings.hxx>
      48             : #include <sfx2/dispatch.hxx>
      49             : #include <svl/ptitem.hxx>
      50             : #include <editeng/sizeitem.hxx>
      51             : #include <editeng/langitem.hxx>
      52             : #include <svx/htmlmode.hxx>
      53             : #include <svx/svdview.hxx>
      54             : #include <svx/svdhdl.hxx>
      55             : #include <svx/svdoutl.hxx>
      56             : #include <editeng/editeng.hxx>
      57             : #include <editeng/svxacorr.hxx>
      58             : #include <editeng/scripttypeitem.hxx>
      59             : #include <editeng/flditem.hxx>
      60             : #include <editeng/colritem.hxx>
      61             : #include <editeng/brshitem.hxx>
      62             : #include <editeng/wghtitem.hxx>
      63             : #include <editeng/udlnitem.hxx>
      64             : #include <editeng/postitem.hxx>
      65             : #include <editeng/protitem.hxx>
      66             : #include <unotools/charclass.hxx>
      67             : #include <basegfx/color/bcolortools.hxx>
      68             : #include <basegfx/polygon/b2dpolygon.hxx>
      69             : 
      70             : #include <editeng/acorrcfg.hxx>
      71             : #include <SwSmartTagMgr.hxx>
      72             : #include <edtwin.hxx>
      73             : #include <view.hxx>
      74             : #include <wrtsh.hxx>
      75             : #include <IDocumentSettingAccess.hxx>
      76             : #include <fldbas.hxx>
      77             : #include <swmodule.hxx>
      78             : #include <docsh.hxx>
      79             : #include <viewopt.hxx>
      80             : #include <drawbase.hxx>
      81             : #include <dselect.hxx>
      82             : #include <textsh.hxx>
      83             : #include <shdwcrsr.hxx>
      84             : #include <fmtanchr.hxx>
      85             : #include <fmtornt.hxx>
      86             : #include <fmtfsize.hxx>
      87             : #include <fmtclds.hxx>
      88             : #include <fmthdft.hxx>
      89             : #include <frmfmt.hxx>
      90             : #include <modcfg.hxx>
      91             : #include <fmtcol.hxx>
      92             : #include <wview.hxx>
      93             : #include <listsh.hxx>
      94             : #include <gloslst.hxx>
      95             : #include <inputwin.hxx>
      96             : #include <gloshdl.hxx>
      97             : #include <swundo.hxx>
      98             : #include <drwtxtsh.hxx>
      99             : #include <fchrfmt.hxx>
     100             : #include <fmturl.hxx>
     101             : #include <romenu.hxx>
     102             : #include <initui.hxx>
     103             : #include <frmatr.hxx>
     104             : #include <extinput.hxx>
     105             : #include <acmplwrd.hxx>
     106             : #include <swcalwrp.hxx>
     107             : #include <swdtflvr.hxx>
     108             : #include <wdocsh.hxx>
     109             : #include <crsskip.hxx>
     110             : #include <breakit.hxx>
     111             : #include <checkit.hxx>
     112             : #include <pagefrm.hxx>
     113             : #include <HeaderFooterWin.hxx>
     114             : 
     115             : #include <helpid.h>
     116             : #include <cmdid.h>
     117             : #include <docvw.hrc>
     118             : #include <uitool.hxx>
     119             : #include <fmtfollowtextflow.hxx>
     120             : #include <toolkit/helper/vclunohelper.hxx>
     121             : #include <charfmt.hxx>
     122             : #include <numrule.hxx>
     123             : #include <pagedesc.hxx>
     124             : #include <svtools/ruler.hxx>
     125             : #include "formatclipboard.hxx"
     126             : #include <osl/mutex.hxx>
     127             : #include <vcl/svapp.hxx>
     128             : #include <docstat.hxx>
     129             : #include <wordcountdialog.hxx>
     130             : #include <swwait.hxx>
     131             : 
     132             : #include <IMark.hxx>
     133             : #include <doc.hxx>
     134             : #include <xmloff/odffields.hxx>
     135             : 
     136             : #include <PostItMgr.hxx>
     137             : 
     138             : #include <algorithm>
     139             : #include <vector>
     140             : 
     141             : #include "../../core/inc/rootfrm.hxx"
     142             : 
     143             : #include <unotools/syslocaleoptions.hxx>
     144             : 
     145             : using namespace sw::mark;
     146             : using namespace ::com::sun::star;
     147             : 
     148             : /*--------------------------------------------------------------------
     149             :     Description:   Globals
     150             :  --------------------------------------------------------------------*/
     151             : 
     152             : static bool bInputLanguageSwitched = false;
     153             : extern sal_Bool bNoInterrupt;       // in mainwn.cxx
     154             : 
     155             : // Usually in MouseButtonUp a selection is revoked when the selection is
     156             : // not currently being pulled open. Unfortunately in MouseButtonDown there
     157             : // is being selected at double/triple click. That selection is completely
     158             : // finished in the Handler and thus can't be distinguished in the Up.
     159             : // To resolve this bHoldSelection is set in Down at evaluated in Up.
     160             : static sal_Bool bHoldSelection      = sal_False;
     161             : 
     162             : sal_Bool bFrmDrag                   = sal_False;
     163             : sal_Bool bValidCrsrPos              = sal_False;
     164             : sal_Bool bModePushed                = sal_False;
     165             : sal_Bool bDDTimerStarted            = sal_False;
     166             : sal_Bool bFlushCharBuffer           = sal_False;
     167             : sal_Bool SwEditWin::bReplaceQuote   = sal_False;
     168             : sal_Bool bDDINetAttr                = sal_False;
     169             : SdrHdlKind eSdrMoveHdl          = HDL_USER;
     170             : 
     171             : QuickHelpData* SwEditWin::pQuickHlpData = 0;
     172             : 
     173             : long    SwEditWin::nDDStartPosY = 0;
     174             : long    SwEditWin::nDDStartPosX = 0;
     175             : /* Note:
     176             :    The initial color shown on the button is set in /core/svx/source/tbxctrls/tbxcolorupdate.cxx
     177             :    (ToolboxButtonColorUpdater::ToolboxButtonColorUpdater()) .
     178             :    The initial color used by the button is set in /core/svx/source/tbxcntrls/tbcontrl.cxx
     179             :    (SvxColorExtToolBoxControl::SvxColorExtToolBoxControl())
     180             :    and in case of writer for text(background)color also in /core/sw/source/ui/docvw/edtwin.cxx
     181             :    (SwEditWin::aTextBackColor and SwEditWin::aTextBackColor)
     182             :  */
     183          10 : Color   SwEditWin::aTextBackColor(COL_YELLOW);
     184          10 : Color   SwEditWin::aTextColor(COL_RED);
     185             : sal_Bool SwEditWin::bTransparentBackColor = sal_False; // background not transparent
     186             : 
     187             : extern sal_Bool     bExecuteDrag;
     188             : 
     189             : static SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType );
     190             : 
     191             : DBG_NAME(edithdl)
     192             : 
     193             : class SwAnchorMarker
     194             : {
     195             :     SdrHdl* pHdl;
     196             :     Point aHdlPos;
     197             :     Point aLastPos;
     198             :     bool bTopRightHandle;
     199             : public:
     200           0 :     SwAnchorMarker( SdrHdl* pH )
     201             :         : pHdl( pH )
     202           0 :         , aHdlPos( pH->GetPos() )
     203           0 :         , aLastPos( pH->GetPos() )
     204           0 :         , bTopRightHandle( pH->GetKind() == HDL_ANCHOR_TR )
     205           0 :     {}
     206           0 :     const Point& GetLastPos() const { return aLastPos; }
     207           0 :     void SetLastPos( const Point& rNew ) { aLastPos = rNew; }
     208           0 :     void SetPos( const Point& rNew ) { pHdl->SetPos( rNew ); }
     209           0 :     const Point& GetPos() { return pHdl->GetPos(); }
     210           0 :     const Point& GetHdlPos() { return aHdlPos; }
     211           0 :     void ChgHdl( SdrHdl* pNew )
     212             :     {
     213           0 :         pHdl = pNew;
     214           0 :         if ( pHdl )
     215             :         {
     216           0 :             bTopRightHandle = (pHdl->GetKind() == HDL_ANCHOR_TR);
     217             :         }
     218           0 :     }
     219           0 :     const Point GetPosForHitTest( const OutputDevice& rOut )
     220             :     {
     221           0 :         Point aHitTestPos( GetPos() );
     222           0 :         aHitTestPos = rOut.LogicToPixel( aHitTestPos );
     223           0 :         if ( bTopRightHandle )
     224             :         {
     225           0 :             aHitTestPos += Point( -1, 1 );
     226             :         }
     227             :         else
     228             :         {
     229           0 :             aHitTestPos += Point( 1, 1 );
     230             :         }
     231           0 :         aHitTestPos = rOut.PixelToLogic( aHitTestPos );
     232             : 
     233           0 :         return aHitTestPos;
     234             :     }
     235             : };
     236             : 
     237             : /// Assists with auto-completion of AutoComplete words and AutoText names.
     238          10 : struct QuickHelpData
     239             : {
     240             :     /// Strings that at least partially match an input word.
     241             :     std::vector<String> m_aHelpStrings;
     242             :     /// Index of the current help string.
     243             :     sal_uInt16 nCurArrPos;
     244             :     /// Length of the input word associated with the help data.
     245             :     sal_uInt16 nLen;
     246             : 
     247             :     /// Help data stores AutoText names rather than AutoComplete words.
     248             :     bool m_bIsAutoText;
     249             :     /// Display help string as a tip rather than inline.
     250             :     bool m_bIsTip;
     251             :     /// Tip ID when a help string is displayed as a tip.
     252             :     sal_uLong nTipId;
     253             :     /// Append a space character to the displayed help string (if appropriate).
     254             :     bool m_bAppendSpace;
     255             : 
     256             :     /// Help string is currently displayed.
     257             :     bool m_bIsDisplayed;
     258             : 
     259          10 :     QuickHelpData() { ClearCntnt(); }
     260             : 
     261             :     void Move( QuickHelpData& rCpy );
     262             :     void ClearCntnt();
     263             :     void Start( SwWrtShell& rSh, sal_uInt16 nWrdLen );
     264             :     void Stop( SwWrtShell& rSh );
     265             : 
     266           0 :     sal_Bool HasCntnt() const { return !m_aHelpStrings.empty() && 0 != nLen; }
     267             : 
     268             :     /// Next help string.
     269           0 :     void Next( sal_Bool bEndLess )
     270             :     {
     271           0 :         if( ++nCurArrPos >= m_aHelpStrings.size() )
     272           0 :             nCurArrPos = (bEndLess && !m_bIsAutoText ) ? 0 : nCurArrPos-1;
     273           0 :     }
     274             :     /// Previous help string.
     275           0 :     void Previous( sal_Bool bEndLess )
     276             :     {
     277           0 :         if( 0 == nCurArrPos-- )
     278           0 :             nCurArrPos = (bEndLess && !m_bIsAutoText ) ? m_aHelpStrings.size()-1 : 0;
     279           0 :     }
     280             : 
     281             :     // Fills internal structures with hopefully helpful information.
     282             :     void FillStrArr( SwWrtShell& rSh, const String& rWord, bool bIgnoreCurrentPos );
     283             :     void SortAndFilter();
     284             : };
     285             : 
     286             : /*--------------------------------------------------------------------
     287             :     Description:   avoid minimal movement shiver
     288             :  --------------------------------------------------------------------*/
     289             : 
     290             : #define HIT_PIX  2 /* hit tolerance in pixel  */
     291             : #define MIN_MOVE 4
     292             : 
     293           0 : inline sal_Bool IsMinMove(const Point &rStartPos, const Point &rLPt)
     294             : {
     295           0 :     return Abs(rStartPos.X() - rLPt.X()) > MIN_MOVE ||
     296           0 :            Abs(rStartPos.Y() - rLPt.Y()) > MIN_MOVE;
     297             : }
     298             : 
     299             : /*--------------------------------------------------------------------
     300             :                 for MouseButtonDown - determine whether a DrawObject
     301             :                 an NO SwgFrame was hit! Shift/Ctrl should only result
     302             :                 in selecting, with DrawObjects; at SwgFlys to trigger
     303             :                 hyperlinks if applicable (DownLoad/NewWindow!)
     304             :  --------------------------------------------------------------------*/
     305           0 : inline sal_Bool IsDrawObjSelectable( const SwWrtShell& rSh, const Point& rPt )
     306             : {
     307           0 :     sal_Bool bRet = sal_True;
     308             :     SdrObject* pObj;
     309           0 :     switch( rSh.GetObjCntType( rPt, pObj ))
     310             :     {
     311             :     case OBJCNT_NONE:
     312             :     case OBJCNT_FLY:
     313             :     case OBJCNT_GRF:
     314             :     case OBJCNT_OLE:
     315           0 :         bRet = sal_False;
     316           0 :         break;
     317             :     default:; //prevent warning
     318             :     }
     319           0 :     return bRet;
     320             : }
     321             : 
     322             : /*--------------------------------------------------------------------
     323             :     Description:   switch pointer
     324             :  --------------------------------------------------------------------*/
     325             : 
     326         238 : void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier )
     327             : {
     328         238 :     SwWrtShell &rSh = rView.GetWrtShell();
     329         238 :     if( pApplyTempl )
     330             :     {
     331           0 :         PointerStyle eStyle = POINTER_FILL;
     332           0 :         if( rSh.IsOverReadOnlyPos( rLPt ))
     333             :         {
     334           0 :             delete pUserMarker;
     335           0 :             pUserMarker = 0L;
     336             : 
     337           0 :             eStyle = POINTER_NOTALLOWED;
     338             :         }
     339             :         else
     340             :         {
     341           0 :             SwRect aRect;
     342           0 :             SwRect* pRect = &aRect;
     343           0 :             const SwFrmFmt* pFmt = 0;
     344             : 
     345           0 :             bool bFrameIsValidTarget = false;
     346           0 :             if( pApplyTempl->pFormatClipboard )
     347           0 :                 bFrameIsValidTarget = pApplyTempl->pFormatClipboard->HasContentForThisType( nsSelectionType::SEL_FRM );
     348           0 :             else if( !pApplyTempl->nColor )
     349           0 :                 bFrameIsValidTarget = ( pApplyTempl->eType == SFX_STYLE_FAMILY_FRAME );
     350             : 
     351           0 :             if( bFrameIsValidTarget &&
     352           0 :                         0 !=(pFmt = rSh.GetFmtFromObj( rLPt, &pRect )) &&
     353           0 :                         PTR_CAST(SwFlyFrmFmt, pFmt))
     354             :             {
     355             :                 //turn on highlight for frame
     356           0 :                 Rectangle aTmp( pRect->SVRect() );
     357             : 
     358           0 :                 if ( !pUserMarker )
     359             :                 {
     360           0 :                     pUserMarker = new SdrDropMarkerOverlay( *rSh.GetDrawView(), aTmp );
     361             :                 }
     362             :             }
     363             :             else
     364             :             {
     365           0 :                 delete pUserMarker;
     366           0 :                 pUserMarker = 0L;
     367             :             }
     368             : 
     369           0 :             rSh.SwCrsrShell::SetVisCrsr( rLPt );
     370             :         }
     371           0 :         SetPointer( eStyle );
     372             :         return;
     373             :     }
     374             : 
     375         238 :     if( !rSh.VisArea().Width() )
     376             :         return;
     377             : 
     378         144 :     SET_CURR_SHELL(&rSh);
     379             : 
     380         144 :     if ( IsChainMode() )
     381             :     {
     382           0 :         SwRect aRect;
     383           0 :         int nChainable = rSh.Chainable( aRect, *rSh.GetFlyFrmFmt(), rLPt );
     384             :         PointerStyle eStyle = nChainable
     385           0 :                 ? POINTER_CHAIN_NOTALLOWED : POINTER_CHAIN;
     386           0 :         if ( !nChainable )
     387             :         {
     388           0 :             Rectangle aTmp( aRect.SVRect() );
     389             : 
     390           0 :             if ( !pUserMarker )
     391             :             {
     392           0 :                 pUserMarker = new SdrDropMarkerOverlay( *rSh.GetDrawView(), aTmp );
     393             :             }
     394             :         }
     395             :         else
     396             :         {
     397           0 :             delete pUserMarker;
     398           0 :             pUserMarker = 0L;
     399             :         }
     400             : 
     401           0 :         SetPointer( eStyle );
     402             :         return;
     403             :     }
     404             : 
     405         144 :     sal_Bool bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
     406         144 :     if ( !bExecHyperlinks )
     407             :     {
     408         144 :         SvtSecurityOptions aSecOpts;
     409         144 :         const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
     410         144 :         if ( (  bSecureOption && nModifier == KEY_MOD1 ) ||
     411             :              ( !bSecureOption && nModifier != KEY_MOD1 ) )
     412           0 :             bExecHyperlinks = sal_True;
     413             :     }
     414             : 
     415         144 :     const sal_Bool bExecSmarttags  = nModifier == KEY_MOD1;
     416             : 
     417         144 :     SdrView *pSdrView = rSh.GetDrawView();
     418         144 :     sal_Bool bPrefSdrPointer = sal_False;
     419         144 :     sal_Bool bHitHandle = sal_False;
     420         144 :     sal_Bool bCntAtPos = sal_False;
     421         144 :     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
     422         144 :                           rSh.IsCrsrReadonly();
     423         144 :     aActHitType = SDRHIT_NONE;
     424         144 :     PointerStyle eStyle = POINTER_TEXT;
     425         144 :     if ( !pSdrView )
     426           0 :         bCntAtPos = sal_True;
     427         144 :     else if ( sal_True == (bHitHandle = pSdrView->PickHandle( rLPt ) != 0) )
     428             :     {
     429           0 :         aActHitType = SDRHIT_OBJECT;
     430           0 :         bPrefSdrPointer = sal_True;
     431             :     }
     432             :     else
     433             :     {
     434         144 :         const sal_Bool bNotInSelObj = !rSh.IsInsideSelectedObj( rLPt );
     435         144 :         if ( rView.GetDrawFuncPtr() && !bInsDraw && bNotInSelObj )
     436             :         {
     437           0 :             aActHitType = SDRHIT_OBJECT;
     438           0 :             if (IsObjectSelect())
     439           0 :                 eStyle = POINTER_ARROW;
     440             :             else
     441           0 :                 bPrefSdrPointer = sal_True;
     442             :         }
     443             :         else
     444             :         {
     445             :             SdrObject* pObj; SdrPageView* pPV;
     446         144 :             pSdrView->SetHitTolerancePixel( HIT_PIX );
     447         144 :             if ( bNotInSelObj && bExecHyperlinks &&
     448           0 :                  pSdrView->PickObj( rLPt, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO ))
     449             :             {
     450           0 :                 SdrObjMacroHitRec aTmp;
     451           0 :                 aTmp.aPos = rLPt;
     452           0 :                 aTmp.pPageView = pPV;
     453           0 :                 SetPointer( pObj->GetMacroPointer( aTmp ) );
     454             :                 return;
     455             :             }
     456             :             else
     457             :             {
     458             :                 // dvo: IsObjSelectable() eventually calls SdrView::PickObj, so
     459             :                 // apparently this is used to determine whether this is a
     460             :                 // drawling layer object or not.
     461         144 :                 if ( rSh.IsObjSelectable( rLPt ) )
     462             :                 {
     463           0 :                     if (pSdrView->IsTextEdit())
     464             :                     {
     465           0 :                         aActHitType = SDRHIT_NONE;
     466           0 :                         bPrefSdrPointer = sal_True;
     467             :                     }
     468             :                     else
     469             :                     {
     470           0 :                         SdrViewEvent aVEvt;
     471           0 :                         SdrHitKind eHit = pSdrView->PickAnything(rLPt, aVEvt);
     472             : 
     473           0 :                         if (eHit == SDRHIT_URLFIELD && bExecHyperlinks)
     474             :                         {
     475           0 :                             aActHitType = SDRHIT_OBJECT;
     476           0 :                             bPrefSdrPointer = sal_True;
     477             :                         }
     478             :                         else
     479             :                         {
     480             :                             // if we're over a selected object, we show an
     481             :                             // ARROW by default. We only show a MOVE if 1) the
     482             :                             // object is selected, and 2) it may be moved
     483             :                             // (i.e., position is not protected).
     484             :                             bool bMovable =
     485             :                                 (!bNotInSelObj) &&
     486           0 :                                 (rSh.IsObjSelected() || rSh.IsFrmSelected()) &&
     487           0 :                                 (!rSh.IsSelObjProtected(FLYPROTECT_POS));
     488             : 
     489           0 :                             SdrObject* pSelectableObj = rSh.GetObjAt(rLPt);
     490             :                             // Don't update pointer if this is a background image only.
     491           0 :                             if (pSelectableObj->GetLayer() != rSh.GetDoc()->GetHellId())
     492           0 :                                 eStyle = bMovable ? POINTER_MOVE : POINTER_ARROW;
     493           0 :                             aActHitType = SDRHIT_OBJECT;
     494           0 :                         }
     495             :                     }
     496             :                 }
     497             :                 else
     498             :                 {
     499         144 :                     if ( rSh.IsFrmSelected() && !bNotInSelObj )
     500             :                     {
     501             :                         // dvo: this branch appears to be dead and should be
     502             :                         // removed in a future version. Reason: The condition
     503             :                         // !bNotInSelObj means that this branch will only be
     504             :                         // executed in the cursor points inside a selected
     505             :                         // object. However, if this is the case, the previous
     506             :                         // if( rSh.IsObjSelectable(rLPt) ) must always be true:
     507             :                         // rLPt is inside a selected object, then obviously
     508             :                         // rLPt is over a selectable object.
     509           0 :                         if (rSh.IsSelObjProtected(FLYPROTECT_SIZE))
     510           0 :                             eStyle = POINTER_NOTALLOWED;
     511             :                         else
     512           0 :                             eStyle = POINTER_MOVE;
     513           0 :                         aActHitType = SDRHIT_OBJECT;
     514             :                     }
     515             :                     else
     516             :                     {
     517         144 :                         if ( rView.GetDrawFuncPtr() )
     518           0 :                             bPrefSdrPointer = sal_True;
     519             :                         else
     520         144 :                             bCntAtPos = sal_True;
     521             :                     }
     522             :                 }
     523             :             }
     524             :         }
     525             :     }
     526         144 :     if ( bPrefSdrPointer )
     527             :     {
     528           0 :         if (bIsDocReadOnly || (rSh.IsObjSelected() && rSh.IsSelObjProtected(FLYPROTECT_CONTENT)))
     529           0 :             SetPointer( POINTER_NOTALLOWED );
     530             :         else
     531             :         {
     532           0 :             if (rView.GetDrawFuncPtr() && rView.GetDrawFuncPtr()->IsInsertForm() && !bHitHandle)
     533           0 :                 SetPointer( POINTER_DRAW_RECT );
     534             :             else
     535           0 :                 SetPointer( pSdrView->GetPreferedPointer( rLPt, rSh.GetOut() ) );
     536             :         }
     537             :     }
     538             :     else
     539             :     {
     540         144 :         if( !rSh.IsPageAtPos( rLPt ) || pAnchorMarker )
     541         144 :             eStyle = POINTER_ARROW;
     542             :         else
     543             :         {
     544             :             // Even if we already have something, prefer URLs if possible.
     545           0 :             SwContentAtPos aUrlPos(SwContentAtPos::SW_INETATTR);
     546           0 :             if (bCntAtPos || rSh.GetContentAtPos(rLPt, aUrlPos))
     547             :             {
     548             :                 SwContentAtPos aSwContentAtPos(
     549             :                     SwContentAtPos::SW_CLICKFIELD|
     550             :                     SwContentAtPos::SW_INETATTR|
     551             :                     SwContentAtPos::SW_FTN |
     552           0 :                     SwContentAtPos::SW_SMARTTAG );
     553           0 :                 if( rSh.GetContentAtPos( rLPt, aSwContentAtPos) )
     554             :                 {
     555             :                     const bool bClickToFollow = SwContentAtPos::SW_INETATTR == aSwContentAtPos.eCntntAtPos ||
     556           0 :                                                 SwContentAtPos::SW_SMARTTAG == aSwContentAtPos.eCntntAtPos;
     557             : 
     558           0 :                      if( !bClickToFollow ||
     559             :                          (SwContentAtPos::SW_INETATTR == aSwContentAtPos.eCntntAtPos && bExecHyperlinks) ||
     560             :                          (SwContentAtPos::SW_SMARTTAG == aSwContentAtPos.eCntntAtPos && bExecSmarttags) )
     561           0 :                         eStyle = POINTER_REFHAND;
     562           0 :                 }
     563           0 :             }
     564             :         }
     565             : 
     566             :         // which kind of text pointer have we to show - horz / vert - ?
     567         144 :         if( POINTER_TEXT == eStyle && rSh.IsInVerticalText( &rLPt ))
     568           0 :             eStyle = POINTER_TEXT_VERTICAL;
     569             : 
     570         144 :         SetPointer( eStyle );
     571         144 :     }
     572             : }
     573             : 
     574             : /*--------------------------------------------------------------------
     575             :     Description: increase timer for selection
     576             :  --------------------------------------------------------------------*/
     577             : 
     578           0 : IMPL_LINK_NOARG(SwEditWin, TimerHandler)
     579             : {
     580             :     DBG_PROFSTART(edithdl);
     581             : 
     582           0 :     SwWrtShell &rSh = rView.GetWrtShell();
     583           0 :     Point aModPt( aMovePos );
     584           0 :     const SwRect aOldVis( rSh.VisArea() );
     585           0 :     sal_Bool bDone = sal_False;
     586             : 
     587           0 :     if ( !rSh.VisArea().IsInside( aModPt ) )
     588             :     {
     589           0 :         if ( bInsDraw )
     590             :         {
     591           0 :             const int nMaxScroll = 40;
     592           0 :             rView.Scroll( Rectangle(aModPt,Size(1,1)), nMaxScroll, nMaxScroll);
     593           0 :             bDone = sal_True;
     594             :         }
     595           0 :         else if ( bFrmDrag )
     596             :         {
     597           0 :             rSh.Drag(&aModPt, false);
     598           0 :             bDone = sal_True;
     599             :         }
     600           0 :         if ( !bDone )
     601           0 :             aModPt = rSh.GetCntntPos( aModPt,aModPt.Y() > rSh.VisArea().Bottom() );
     602             :     }
     603           0 :     if ( !bDone && !(bFrmDrag || bInsDraw) )
     604             :     {
     605           0 :         if ( pRowColumnSelectionStart )
     606             :         {
     607           0 :             Point aPos( aModPt );
     608           0 :             rSh.SelectTableRowCol( *pRowColumnSelectionStart, &aPos, bIsRowDrag );
     609             :         }
     610             :         else
     611           0 :             rSh.SetCursor( &aModPt, false );
     612             : 
     613             :         // It can be that a "jump" over a table cannot be accomplished like
     614             :         // that. So we jump over the table by Up/Down here.
     615           0 :         const SwRect& rVisArea = rSh.VisArea();
     616           0 :         if( aOldVis == rVisArea && !rSh.IsStartOfDoc() && !rSh.IsEndOfDoc() )
     617             :         {
     618             :             // take the center point of VisArea to
     619             :             // decide in which direction the user want.
     620           0 :             if( aModPt.Y() < ( rVisArea.Top() + rVisArea.Height() / 2 ) )
     621           0 :                 rSh.Up( sal_True, 1 );
     622             :             else
     623           0 :                 rSh.Down( sal_True, 1 );
     624             :         }
     625             :     }
     626             : 
     627           0 :     aMovePos += rSh.VisArea().Pos() - aOldVis.Pos();
     628           0 :     JustifyAreaTimer();
     629             :     DBG_PROFSTOP(edithdl);
     630           0 :     return 0;
     631             : }
     632             : 
     633           0 : void SwEditWin::JustifyAreaTimer()
     634             : {
     635           0 :     const Rectangle &rVisArea = GetView().GetVisArea();
     636             : #ifdef UNX
     637           0 :     const long coMinLen = 100;
     638             : #else
     639             :     const long coMinLen = 50;
     640             : #endif
     641           0 :     long nTimeout = 800,
     642             :          nDiff = Max(
     643           0 :          Max( aMovePos.Y() - rVisArea.Bottom(), rVisArea.Top() - aMovePos.Y() ),
     644           0 :          Max( aMovePos.X() - rVisArea.Right(),  rVisArea.Left() - aMovePos.X()));
     645           0 :     aTimer.SetTimeout( Max( coMinLen, nTimeout - nDiff*2L) );
     646           0 : }
     647             : 
     648           0 : void SwEditWin::LeaveArea(const Point &rPos)
     649             : {
     650           0 :     aMovePos = rPos;
     651           0 :     JustifyAreaTimer();
     652           0 :     if( !aTimer.IsActive() )
     653           0 :         aTimer.Start();
     654           0 :     delete pShadCrsr, pShadCrsr = 0;
     655           0 : }
     656             : 
     657           0 : inline void SwEditWin::EnterArea()
     658             : {
     659           0 :     aTimer.Stop();
     660           0 : }
     661             : 
     662             : /*------------------------------------------------------------------------
     663             :  Description:  insert mode for frames
     664             : ------------------------------------------------------------------------*/
     665             : 
     666           0 : void SwEditWin::InsFrm(sal_uInt16 nCols)
     667             : {
     668           0 :     StdDrawMode( OBJ_NONE, sal_False );
     669           0 :     bInsFrm = sal_True;
     670           0 :     nInsFrmColCount = nCols;
     671           0 : }
     672             : 
     673           0 : void SwEditWin::StdDrawMode( SdrObjKind eSdrObjectKind, sal_Bool bObjSelect )
     674             : {
     675           0 :     SetSdrDrawMode( eSdrObjectKind );
     676             : 
     677           0 :     if (bObjSelect)
     678           0 :         rView.SetDrawFuncPtr(new DrawSelection( &rView.GetWrtShell(), this, &rView ));
     679             :     else
     680           0 :         rView.SetDrawFuncPtr(new SwDrawBase( &rView.GetWrtShell(), this, &rView ));
     681             : 
     682           0 :     rView.SetSelDrawSlot();
     683           0 :     SetSdrDrawMode( eSdrObjectKind );
     684           0 :     if (bObjSelect)
     685           0 :         rView.GetDrawFuncPtr()->Activate( SID_OBJECT_SELECT );
     686             :     else
     687           0 :         rView.GetDrawFuncPtr()->Activate( sal::static_int_cast< sal_uInt16 >(eSdrObjectKind) );
     688           0 :     bInsFrm = sal_False;
     689           0 :     nInsFrmColCount = 1;
     690           0 : }
     691             : 
     692           0 : void SwEditWin::StopInsFrm()
     693             : {
     694           0 :     if (rView.GetDrawFuncPtr())
     695             :     {
     696           0 :         rView.GetDrawFuncPtr()->Deactivate();
     697           0 :         rView.SetDrawFuncPtr(NULL);
     698             :     }
     699           0 :     rView.LeaveDrawCreate();    // leave construction mode
     700           0 :     bInsFrm = sal_False;
     701           0 :     nInsFrmColCount = 1;
     702           0 : }
     703             : 
     704             : 
     705             : 
     706           0 : sal_Bool SwEditWin::IsInputSequenceCheckingRequired( const String &rText, const SwPaM& rCrsr ) const
     707             : {
     708           0 :     const SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions();
     709           0 :     if ( !rCTLOptions.IsCTLFontEnabled() ||
     710           0 :          !rCTLOptions.IsCTLSequenceChecking() )
     711           0 :          return sal_False;
     712             : 
     713           0 :     const xub_StrLen nFirstPos = rCrsr.Start()->nContent.GetIndex();
     714           0 :     if ( 0 == nFirstPos ) /* first char needs not to be checked */
     715           0 :         return sal_False;
     716             : 
     717           0 :     SwBreakIt *pBreakIter = SwBreakIt::Get();
     718           0 :     uno::Reference < i18n::XBreakIterator > xBI = pBreakIter->GetBreakIter();
     719           0 :     long nCTLScriptPos = -1;
     720             : 
     721           0 :     if (xBI.is())
     722             :     {
     723           0 :         if (xBI->getScriptType( rText, 0 ) == i18n::ScriptType::COMPLEX)
     724           0 :             nCTLScriptPos = 0;
     725             :         else
     726           0 :             nCTLScriptPos = xBI->nextScript( rText, 0, i18n::ScriptType::COMPLEX );
     727             :     }
     728             : 
     729           0 :     return (0 <= nCTLScriptPos && nCTLScriptPos <= rText.Len());
     730             : }
     731             : 
     732             : //return INVALID_HINT if language should not be explictly overridden, the correct
     733             : //HintId to use for the eBufferLanguage otherwise
     734           0 : static sal_uInt16 lcl_isNonDefaultLanguage(LanguageType eBufferLanguage, SwView& rView,
     735             :     const String &rInBuffer)
     736             : {
     737           0 :     sal_uInt16 nWhich = INVALID_HINT;
     738             : 
     739             :     //If the option to IgnoreLanguageChange is set, short-circuit this method
     740             :     //which results in the document/paragraph language remaining the same
     741             :     //despite a change to the keyboard/input language
     742           0 :     SvtSysLocaleOptions aSysLocaleOptions;
     743           0 :     if(aSysLocaleOptions.IsIgnoreLanguageChange())
     744             :     {
     745           0 :         return INVALID_HINT;
     746             :     }
     747             : 
     748           0 :     bool bLang = true;
     749           0 :     if(eBufferLanguage != LANGUAGE_DONTKNOW)
     750             :     {
     751           0 :         switch( GetI18NScriptTypeOfLanguage( eBufferLanguage ))
     752             :         {
     753           0 :             case  i18n::ScriptType::ASIAN:     nWhich = RES_CHRATR_CJK_LANGUAGE; break;
     754           0 :             case  i18n::ScriptType::COMPLEX:   nWhich = RES_CHRATR_CTL_LANGUAGE; break;
     755           0 :             case  i18n::ScriptType::LATIN:     nWhich = RES_CHRATR_LANGUAGE; break;
     756           0 :             default: bLang = false;
     757             :         }
     758           0 :         if(bLang)
     759             :         {
     760           0 :             SfxItemSet aLangSet(rView.GetPool(), nWhich, nWhich);
     761           0 :             SwWrtShell& rSh = rView.GetWrtShell();
     762           0 :             rSh.GetCurAttr(aLangSet);
     763           0 :             if(SFX_ITEM_DEFAULT <= aLangSet.GetItemState(nWhich, sal_True))
     764             :             {
     765           0 :                 LanguageType eLang = static_cast<const SvxLanguageItem&>(aLangSet.Get(nWhich)).GetLanguage();
     766           0 :                 if ( eLang == eBufferLanguage )
     767             :                 {
     768             :                     // current language attribute equal to language reported from system
     769           0 :                     bLang = false;
     770             :                 }
     771           0 :                 else if ( !bInputLanguageSwitched && RES_CHRATR_LANGUAGE == nWhich )
     772             :                 {
     773             :                     // special case: switching between two "LATIN" languages
     774             :                     // In case the current keyboard setting might be suitable
     775             :                     // for both languages we can't safely assume that the user
     776             :                     // wants to use the language reported from the system,
     777             :                     // except if we knew that it was explicitly switched (thus
     778             :                     // the check for "bInputLangeSwitched").
     779             :                     //
     780             :                     // The language reported by the system could be just the
     781             :                     // system default language that the user is not even aware
     782             :                     // of, because no language selection tool is installed at
     783             :                     // all. In this case the OOo language should get preference
     784             :                     // as it might have been selected by the user explicitly.
     785             :                     //
     786             :                     // Usually this case happens if the OOo language is
     787             :                     // different to the system language but the system keyboard
     788             :                     // is still suitable for the OOo language (e.g. writing
     789             :                     // English texts with a German keyboard).
     790             :                     //
     791             :                     // For non-latin keyboards overwriting the attribute is
     792             :                     // still valid. We do this for kyrillic and greek ATM.  In
     793             :                     // future versions of OOo this should be replaced by a
     794             :                     // configuration switch that allows to give the preference
     795             :                     // to the OOo setting or the system setting explicitly
     796             :                     // and/or a better handling of the script type.
     797           0 :                     i18n::UnicodeScript eType = rInBuffer.Len() ?
     798           0 :                         (i18n::UnicodeScript)GetAppCharClass().getScript( rInBuffer, 0 ) :
     799           0 :                         i18n::UnicodeScript_kScriptCount;
     800             : 
     801           0 :                     bool bSystemIsNonLatin = false, bOOoLangIsNonLatin = false;
     802           0 :                     switch ( eType )
     803             :                     {
     804             :                         case i18n::UnicodeScript_kGreek:
     805             :                         case i18n::UnicodeScript_kCyrillic:
     806             :                             // in case other UnicodeScripts require special
     807             :                             // keyboards they can be added here
     808           0 :                             bSystemIsNonLatin = true;
     809           0 :                             break;
     810             :                         default:
     811           0 :                             break;
     812             :                     }
     813             : 
     814           0 :                     switch ( eLang )
     815             :                     {
     816             :                         case LANGUAGE_AZERI_CYRILLIC:
     817             :                         case LANGUAGE_BOSNIAN_CYRILLIC_BOSNIA_HERZEGOVINA:
     818             :                         case LANGUAGE_BULGARIAN:
     819             :                         case LANGUAGE_GREEK:
     820             :                         case LANGUAGE_RUSSIAN:
     821             :                         case LANGUAGE_RUSSIAN_MOLDOVA:
     822             :                         case LANGUAGE_SERBIAN_CYRILLIC:
     823             :                         case LANGUAGE_SERBIAN_CYRILLIC_BOSNIA_HERZEGOVINA:
     824             :                         case LANGUAGE_UZBEK_CYRILLIC:
     825             :                         case LANGUAGE_UKRAINIAN:
     826             :                         case LANGUAGE_BELARUSIAN:
     827           0 :                             bOOoLangIsNonLatin = true;
     828           0 :                             break;
     829             :                         default:
     830           0 :                             break;
     831             :                     }
     832             : 
     833           0 :                     bLang = (bSystemIsNonLatin != bOOoLangIsNonLatin);
     834             :                 }
     835           0 :             }
     836             :         }
     837             :     }
     838           0 :     return bLang ? nWhich : INVALID_HINT;
     839             : }
     840             : 
     841             : /*--------------------------------------------------------------------
     842             :      Description:  character buffer is inserted into the document
     843             :  --------------------------------------------------------------------*/
     844             : 
     845           0 : void SwEditWin::FlushInBuffer()
     846             : {
     847           0 :     if ( aInBuffer.Len() )
     848             :     {
     849           0 :         SwWrtShell& rSh = rView.GetWrtShell();
     850             : 
     851             :         // generate new sequence input checker if not already done
     852           0 :         if ( !pCheckIt )
     853           0 :             pCheckIt = new SwCheckIt;
     854             : 
     855           0 :         uno::Reference < i18n::XExtendedInputSequenceChecker > xISC = pCheckIt->xCheck;
     856           0 :         if ( xISC.is() && IsInputSequenceCheckingRequired( aInBuffer, *rSh.GetCrsr() ) )
     857             :         {
     858             :             //
     859             :             // apply (Thai) input sequence checking/correction
     860             :             //
     861             : 
     862           0 :             rSh.Push(); // push current cursor to stack
     863             : 
     864             :             // get text from the beginning (i.e left side) of current selection
     865             :             // to the start of the paragraph
     866           0 :             rSh.NormalizePam();     // make point be the first (left) one
     867           0 :             if (!rSh.GetCrsr()->HasMark())
     868           0 :                 rSh.GetCrsr()->SetMark();
     869           0 :             rSh.GetCrsr()->GetMark()->nContent = 0;
     870           0 :             String aLeftText( rSh.GetCrsr()->GetTxt() );
     871             : 
     872           0 :             SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions();
     873             : 
     874           0 :             xub_StrLen nExpandSelection = 0;
     875           0 :             if (aLeftText.Len() > 0)
     876             :             {
     877           0 :                 sal_Unicode cChar = '\0';
     878             : 
     879           0 :                 xub_StrLen nTmpPos = aLeftText.Len();
     880           0 :                 sal_Int16 nCheckMode = rCTLOptions.IsCTLSequenceCheckingRestricted() ?
     881           0 :                         i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC;
     882             : 
     883           0 :                 rtl::OUString aOldText( aLeftText );
     884           0 :                 rtl::OUString aNewText( aOldText );
     885           0 :                 if (rCTLOptions.IsCTLSequenceCheckingTypeAndReplace())
     886             :                 {
     887           0 :                     for (xub_StrLen k = 0;  k < aInBuffer.Len();  ++k)
     888             :                     {
     889           0 :                         cChar = aInBuffer.GetChar(k);
     890           0 :                         const xub_StrLen nPrevPos = static_cast<xub_StrLen>(xISC->correctInputSequence( aNewText, nTmpPos - 1, cChar, nCheckMode ));
     891             : 
     892             :                         // valid sequence or sequence could be corrected:
     893           0 :                         if (nPrevPos != aNewText.getLength())
     894           0 :                             nTmpPos = nPrevPos + 1;
     895             :                     }
     896             : 
     897             :                     // find position of first character that has changed
     898           0 :                     sal_Int32 nOldLen = aOldText.getLength();
     899           0 :                     sal_Int32 nNewLen = aNewText.getLength();
     900           0 :                     const sal_Unicode *pOldTxt = aOldText.getStr();
     901           0 :                     const sal_Unicode *pNewTxt = aNewText.getStr();
     902           0 :                     sal_Int32 nChgPos = 0;
     903           0 :                     while ( nChgPos < nOldLen && nChgPos < nNewLen &&
     904           0 :                             pOldTxt[nChgPos] == pNewTxt[nChgPos] )
     905           0 :                         ++nChgPos;
     906             : 
     907           0 :                     xub_StrLen nChgLen = static_cast< xub_StrLen >(nNewLen - nChgPos);
     908           0 :                     String aChgText( aNewText.copy( static_cast< xub_StrLen >(nChgPos), nChgLen ) );
     909             : 
     910           0 :                     if (aChgText.Len())
     911             :                     {
     912           0 :                         aInBuffer = aChgText;
     913           0 :                         nExpandSelection = aLeftText.Len() - static_cast< xub_StrLen >(nChgPos);
     914             :                     }
     915             :                     else
     916           0 :                         aInBuffer.Erase();
     917             :                 }
     918             :                 else
     919             :                 {
     920           0 :                     for (xub_StrLen k = 0;  k < aInBuffer.Len();  ++k)
     921             :                     {
     922           0 :                         cChar = aInBuffer.GetChar(k);
     923           0 :                         if (xISC->checkInputSequence( aNewText, nTmpPos - 1, cChar, nCheckMode ))
     924             :                         {
     925             :                             // character can be inserted:
     926           0 :                             aNewText += rtl::OUString( (sal_Unicode) cChar );
     927           0 :                             ++nTmpPos;
     928             :                         }
     929             :                     }
     930           0 :                     aInBuffer = aNewText.copy( aOldText.getLength() );  // copy new text to be inserted to buffer
     931           0 :                 }
     932             :             }
     933             : 
     934             :             // at this point now we will insert the buffer text 'normally' some lines below...
     935             : 
     936           0 :             rSh.Pop( sal_False );  // pop old cursor from stack
     937             : 
     938           0 :             if (!aInBuffer.Len())
     939           0 :                 return;
     940             : 
     941             :             // if text prior to the original selection needs to be changed
     942             :             // as well, we now expand the selection accordingly.
     943           0 :             SwPaM &rCrsr = *rSh.GetCrsr();
     944           0 :             xub_StrLen nCrsrStartPos = rCrsr.Start()->nContent.GetIndex();
     945             :             OSL_ENSURE( nCrsrStartPos >= nExpandSelection, "cannot expand selection as specified!!" );
     946           0 :             if (nExpandSelection && nCrsrStartPos >= nExpandSelection)
     947             :             {
     948           0 :                 if (!rCrsr.HasMark())
     949           0 :                     rCrsr.SetMark();
     950           0 :                 rCrsr.Start()->nContent -= nExpandSelection;
     951           0 :             }
     952             :         }
     953             : 
     954             :         uno::Reference< frame::XDispatchRecorder > xRecorder =
     955           0 :                 rView.GetViewFrame()->GetBindings().GetRecorder();
     956           0 :         if ( xRecorder.is() )
     957             :         {
     958             :             // determine shell
     959           0 :             SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) );
     960             :             // generate request and record
     961           0 :             if (pSfxShell)
     962             :             {
     963           0 :                 SfxRequest aReq( rView.GetViewFrame(), FN_INSERT_STRING );
     964           0 :                 aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, aInBuffer ) );
     965           0 :                 aReq.Done();
     966             :             }
     967             :         }
     968             : 
     969           0 :         sal_uInt16 nWhich = lcl_isNonDefaultLanguage(eBufferLanguage, rView, aInBuffer);
     970           0 :         if (nWhich != INVALID_HINT )
     971             :         {
     972           0 :             SvxLanguageItem aLangItem( eBufferLanguage, nWhich );
     973           0 :             rSh.SetAttr( aLangItem );
     974             :         }
     975             : 
     976           0 :         rSh.Insert( aInBuffer );
     977           0 :         eBufferLanguage = LANGUAGE_DONTKNOW;
     978           0 :         aInBuffer.Erase();
     979           0 :         bFlushCharBuffer = sal_False;
     980             :     }
     981             : }
     982             : 
     983             : #define MOVE_LEFT_SMALL     0
     984             : #define MOVE_UP_SMALL       1
     985             : #define MOVE_RIGHT_BIG      2
     986             : #define MOVE_DOWN_BIG       3
     987             : #define MOVE_LEFT_BIG       4
     988             : #define MOVE_UP_BIG         5
     989             : #define MOVE_RIGHT_SMALL    6
     990             : #define MOVE_DOWN_SMALL     7
     991             : 
     992           0 : void SwEditWin::ChangeFly( sal_uInt8 nDir, sal_Bool bWeb )
     993             : {
     994           0 :     SwWrtShell &rSh = rView.GetWrtShell();
     995           0 :     SwRect aTmp = rSh.GetFlyRect();
     996           0 :     if( aTmp.HasArea() &&
     997             :         // IsSelObjProtected() seems to be the correct condition, not
     998             :         // !HasReadonlySel(), otherwise frame is not moveable if content is
     999             :         // protected.
    1000           0 :         !rSh.IsSelObjProtected( FLYPROTECT_POS|FLYPROTECT_SIZE ) )
    1001             :     {
    1002           0 :         SfxItemSet aSet(rSh.GetAttrPool(),
    1003             :                         RES_FRM_SIZE, RES_FRM_SIZE,
    1004             :                         RES_VERT_ORIENT, RES_ANCHOR,
    1005             :                         RES_COL, RES_COL,
    1006             :                         RES_PROTECT, RES_PROTECT,
    1007           0 :                         RES_FOLLOW_TEXT_FLOW, RES_FOLLOW_TEXT_FLOW, 0);
    1008           0 :         rSh.GetFlyFrmAttr( aSet );
    1009           0 :         RndStdIds eAnchorId = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
    1010           0 :         Size aSnap;
    1011           0 :         if(MOVE_LEFT_SMALL == nDir ||
    1012             :             MOVE_UP_SMALL == nDir ||
    1013             :             MOVE_RIGHT_SMALL == nDir ||
    1014             :             MOVE_DOWN_SMALL == nDir )
    1015           0 :             aSnap = PixelToLogic(Size(1,1));
    1016             :         else
    1017             :         {
    1018           0 :             aSnap = rSh.GetViewOptions()->GetSnapSize();
    1019           0 :             short nDiv = rSh.GetViewOptions()->GetDivisionX();
    1020           0 :             if ( nDiv > 0 )
    1021           0 :                 aSnap.Width() = Max( (sal_uLong)1, (sal_uLong)aSnap.Width() / nDiv );
    1022           0 :             nDiv = rSh.GetViewOptions()->GetDivisionY();
    1023           0 :             if ( nDiv > 0 )
    1024           0 :                 aSnap.Height() = Max( (sal_uLong)1, (sal_uLong)aSnap.Height() / nDiv );
    1025             :         }
    1026             : 
    1027           0 :         SwRect aBoundRect;
    1028           0 :         Point aRefPoint;
    1029             :         // adjustment for allowing vertical position
    1030             :         // aligned to page for fly frame anchored to paragraph or to character.
    1031             :         {
    1032           0 :             SwFmtVertOrient aVert( (SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT) );
    1033             :             const bool bFollowTextFlow =
    1034           0 :                     static_cast<const SwFmtFollowTextFlow&>(aSet.Get(RES_FOLLOW_TEXT_FLOW)).GetValue();
    1035           0 :             const SwPosition* pToCharCntntPos = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetCntntAnchor();
    1036             :             rSh.CalcBoundRect( aBoundRect, eAnchorId,
    1037           0 :                                text::RelOrientation::FRAME, aVert.GetRelationOrient(),
    1038             :                                pToCharCntntPos, bFollowTextFlow,
    1039           0 :                                false, &aRefPoint );
    1040             :         }
    1041           0 :         long nLeft = Min( aTmp.Left() - aBoundRect.Left(), aSnap.Width() );
    1042           0 :         long nRight = Min( aBoundRect.Right() - aTmp.Right(), aSnap.Width() );
    1043           0 :         long nUp = Min( aTmp.Top() - aBoundRect.Top(), aSnap.Height() );
    1044           0 :         long nDown = Min( aBoundRect.Bottom() - aTmp.Bottom(), aSnap.Height() );
    1045             : 
    1046           0 :         switch ( nDir )
    1047             :         {
    1048             :             case MOVE_LEFT_BIG:
    1049           0 :             case MOVE_LEFT_SMALL: aTmp.Left( aTmp.Left() - nLeft ); break;
    1050             :             case MOVE_UP_BIG:
    1051           0 :             case MOVE_UP_SMALL: aTmp.Top( aTmp.Top() - nUp ); break;
    1052           0 :             case MOVE_RIGHT_SMALL: if( aTmp.Width() < aSnap.Width() + MINFLY ) break;
    1053           0 :                     nRight = aSnap.Width(); // no break
    1054           0 :             case MOVE_RIGHT_BIG: aTmp.Left( aTmp.Left() + nRight ); break;
    1055           0 :             case MOVE_DOWN_SMALL: if( aTmp.Height() < aSnap.Height() + MINFLY ) break;
    1056           0 :                     nDown = aSnap.Height(); // no break
    1057           0 :             case MOVE_DOWN_BIG: aTmp.Top( aTmp.Top() + nDown ); break;
    1058             :             default: OSL_ENSURE(true, "ChangeFly: Unknown direction." );
    1059             :         }
    1060           0 :         sal_Bool bSet = sal_False;
    1061           0 :         if ((FLY_AS_CHAR == eAnchorId) && ( nDir % 2 ))
    1062             :         {
    1063           0 :             long aDiff = aTmp.Top() - aRefPoint.Y();
    1064           0 :             if( aDiff > 0 )
    1065           0 :                 aDiff = 0;
    1066           0 :             else if ( aDiff < -aTmp.Height() )
    1067           0 :                 aDiff = -aTmp.Height();
    1068           0 :             SwFmtVertOrient aVert( (SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT) );
    1069             :             sal_Int16 eNew;
    1070           0 :             if( bWeb )
    1071             :             {
    1072           0 :                 eNew = aVert.GetVertOrient();
    1073           0 :                 sal_Bool bDown = 0 != ( nDir & 0x02 );
    1074           0 :                 switch( eNew )
    1075             :                 {
    1076             :                     case text::VertOrientation::CHAR_TOP:
    1077           0 :                         if( bDown ) eNew = text::VertOrientation::CENTER;
    1078           0 :                     break;
    1079             :                     case text::VertOrientation::CENTER:
    1080           0 :                         eNew = bDown ? text::VertOrientation::TOP : text::VertOrientation::CHAR_TOP;
    1081           0 :                     break;
    1082             :                     case text::VertOrientation::TOP:
    1083           0 :                         if( !bDown ) eNew = text::VertOrientation::CENTER;
    1084           0 :                     break;
    1085             :                     case text::VertOrientation::LINE_TOP:
    1086           0 :                         if( bDown ) eNew = text::VertOrientation::LINE_CENTER;
    1087           0 :                     break;
    1088             :                     case text::VertOrientation::LINE_CENTER:
    1089           0 :                         eNew = bDown ? text::VertOrientation::LINE_BOTTOM : text::VertOrientation::LINE_TOP;
    1090           0 :                     break;
    1091             :                     case text::VertOrientation::LINE_BOTTOM:
    1092           0 :                         if( !bDown ) eNew = text::VertOrientation::LINE_CENTER;
    1093           0 :                     break;
    1094             :                     default:; //prevent warning
    1095             :                 }
    1096             :             }
    1097             :             else
    1098             :             {
    1099           0 :                 aVert.SetPos( aDiff );
    1100           0 :                 eNew = text::VertOrientation::NONE;
    1101             :             }
    1102           0 :             aVert.SetVertOrient( eNew );
    1103           0 :             aSet.Put( aVert );
    1104           0 :             bSet = sal_True;
    1105             :         }
    1106           0 :         if (bWeb && (FLY_AT_PARA == eAnchorId)
    1107             :             && ( nDir==MOVE_LEFT_SMALL || nDir==MOVE_RIGHT_BIG ))
    1108             :         {
    1109           0 :             SwFmtHoriOrient aHori( (SwFmtHoriOrient&)aSet.Get(RES_HORI_ORIENT) );
    1110             :             sal_Int16 eNew;
    1111           0 :             eNew = aHori.GetHoriOrient();
    1112           0 :             switch( eNew )
    1113             :             {
    1114             :                 case text::HoriOrientation::RIGHT:
    1115           0 :                     if( nDir==MOVE_LEFT_SMALL )
    1116           0 :                         eNew = text::HoriOrientation::LEFT;
    1117           0 :                 break;
    1118             :                 case text::HoriOrientation::LEFT:
    1119           0 :                     if( nDir==MOVE_RIGHT_BIG )
    1120           0 :                         eNew = text::HoriOrientation::RIGHT;
    1121           0 :                 break;
    1122             :                 default:; //prevent warning
    1123             :             }
    1124           0 :             if( eNew != aHori.GetHoriOrient() )
    1125             :             {
    1126           0 :                 aHori.SetHoriOrient( eNew );
    1127           0 :                 aSet.Put( aHori );
    1128           0 :                 bSet = sal_True;
    1129           0 :             }
    1130             :         }
    1131           0 :         rSh.StartAllAction();
    1132           0 :         if( bSet )
    1133           0 :             rSh.SetFlyFrmAttr( aSet );
    1134           0 :         sal_Bool bSetPos = (FLY_AS_CHAR != eAnchorId);
    1135           0 :         if(bSetPos && bWeb)
    1136             :         {
    1137           0 :             if (FLY_AT_PAGE != eAnchorId)
    1138             :             {
    1139           0 :                 bSetPos = sal_False;
    1140             :             }
    1141             :             else
    1142             :             {
    1143           0 :                 bSetPos = sal_True;
    1144             :             }
    1145             :         }
    1146           0 :         if( bSetPos )
    1147           0 :             rSh.SetFlyPos( aTmp.Pos() );
    1148           0 :         rSh.EndAllAction();
    1149             :     }
    1150           0 : }
    1151             : 
    1152           0 : void SwEditWin::ChangeDrawing( sal_uInt8 nDir )
    1153             : {
    1154             :     // start undo action in order to get only one
    1155             :     // undo action for this change.
    1156           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    1157           0 :     rSh.StartUndo();
    1158             : 
    1159           0 :     long nX = 0;
    1160           0 :     long nY = 0;
    1161           0 :     sal_Bool bOnePixel = sal_False;
    1162           0 :     sal_uInt16 nAnchorDir = SW_MOVE_UP;
    1163           0 :     switch(nDir)
    1164             :     {
    1165             :         case MOVE_LEFT_SMALL:
    1166           0 :             bOnePixel = sal_True;
    1167             :             //no break;
    1168             :         case MOVE_LEFT_BIG:
    1169           0 :             nX = -1;
    1170           0 :             nAnchorDir = SW_MOVE_LEFT;
    1171           0 :         break;
    1172             :         case MOVE_UP_SMALL:
    1173           0 :             bOnePixel = sal_True;
    1174             :             //no break;
    1175             :         case MOVE_UP_BIG:
    1176           0 :             nY = -1;
    1177           0 :         break;
    1178             :         case MOVE_RIGHT_SMALL:
    1179           0 :             bOnePixel = sal_True;
    1180             :             //no break;
    1181             :         case MOVE_RIGHT_BIG:
    1182           0 :             nX = +1;
    1183           0 :             nAnchorDir = SW_MOVE_RIGHT;
    1184           0 :         break;
    1185             :         case MOVE_DOWN_SMALL:
    1186           0 :             bOnePixel = sal_True;
    1187             :             //no break;
    1188             :         case MOVE_DOWN_BIG:
    1189           0 :             nY = +1;
    1190           0 :             nAnchorDir = SW_MOVE_DOWN;
    1191           0 :         break;
    1192             :     }
    1193             : 
    1194           0 :     if(0 != nX || 0 != nY)
    1195             :     {
    1196           0 :         sal_uInt8 nProtect = rSh.IsSelObjProtected( FLYPROTECT_POS|FLYPROTECT_SIZE );
    1197           0 :         Size aSnap( rSh.GetViewOptions()->GetSnapSize() );
    1198           0 :         short nDiv = rSh.GetViewOptions()->GetDivisionX();
    1199           0 :         if ( nDiv > 0 )
    1200           0 :             aSnap.Width() = Max( (sal_uLong)1, (sal_uLong)aSnap.Width() / nDiv );
    1201           0 :         nDiv = rSh.GetViewOptions()->GetDivisionY();
    1202           0 :         if ( nDiv > 0 )
    1203           0 :             aSnap.Height() = Max( (sal_uLong)1, (sal_uLong)aSnap.Height() / nDiv );
    1204             : 
    1205           0 :         if(bOnePixel)
    1206           0 :             aSnap = PixelToLogic(Size(1,1));
    1207             : 
    1208           0 :         nX *= aSnap.Width();
    1209           0 :         nY *= aSnap.Height();
    1210             : 
    1211           0 :         SdrView *pSdrView = rSh.GetDrawView();
    1212           0 :         const SdrHdlList& rHdlList = pSdrView->GetHdlList();
    1213           0 :         SdrHdl* pHdl = rHdlList.GetFocusHdl();
    1214           0 :         rSh.StartAllAction();
    1215           0 :         if(0L == pHdl)
    1216             :         {
    1217             :             // now move the selected draw objects
    1218             :             // if the object's position is not protected
    1219           0 :             if(0 == (nProtect&FLYPROTECT_POS))
    1220             :             {
    1221             :                 // Check if object is anchored as character and move direction
    1222             :                 sal_Bool bDummy1, bDummy2;
    1223           0 :                 const bool bVertAnchor = rSh.IsFrmVertical( sal_True, bDummy1, bDummy2 );
    1224           0 :                 bool bHoriMove = !bVertAnchor == !( nDir % 2 );
    1225             :                 bool bMoveAllowed =
    1226           0 :                     !bHoriMove || (rSh.GetAnchorId() != FLY_AS_CHAR);
    1227           0 :                 if ( bMoveAllowed )
    1228             :                 {
    1229           0 :                     pSdrView->MoveAllMarked(Size(nX, nY));
    1230           0 :                     rSh.SetModified();
    1231             :                 }
    1232             :             }
    1233             :         }
    1234             :         else
    1235             :         {
    1236             :             // move handle with index nHandleIndex
    1237           0 :             if(pHdl && (nX || nY))
    1238             :             {
    1239           0 :                 if( HDL_ANCHOR == pHdl->GetKind() ||
    1240           0 :                     HDL_ANCHOR_TR == pHdl->GetKind() )
    1241             :                 {
    1242             :                     // anchor move cannot be allowed when position is protected
    1243           0 :                     if(0 == (nProtect&FLYPROTECT_POS))
    1244           0 :                         rSh.MoveAnchor( nAnchorDir );
    1245             :                 }
    1246             :                 //now resize if size is protected
    1247           0 :                 else if(0 == (nProtect&FLYPROTECT_SIZE))
    1248             :                 {
    1249             :                     // now move the Handle (nX, nY)
    1250           0 :                     Point aStartPoint(pHdl->GetPos());
    1251           0 :                     Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
    1252           0 :                     const SdrDragStat& rDragStat = pSdrView->GetDragStat();
    1253             : 
    1254             :                     // start dragging
    1255           0 :                     pSdrView->BegDragObj(aStartPoint, 0, pHdl, 0);
    1256             : 
    1257           0 :                     if(pSdrView->IsDragObj())
    1258             :                     {
    1259           0 :                         sal_Bool bWasNoSnap = static_cast< sal_Bool >(rDragStat.IsNoSnap());
    1260           0 :                         sal_Bool bWasSnapEnabled = pSdrView->IsSnapEnabled();
    1261             : 
    1262             :                         // switch snapping off
    1263           0 :                         if(!bWasNoSnap)
    1264           0 :                             ((SdrDragStat&)rDragStat).SetNoSnap(sal_True);
    1265           0 :                         if(bWasSnapEnabled)
    1266           0 :                             pSdrView->SetSnapEnabled(sal_False);
    1267             : 
    1268           0 :                         pSdrView->MovAction(aEndPoint);
    1269           0 :                         pSdrView->EndDragObj();
    1270           0 :                         rSh.SetModified();
    1271             : 
    1272             :                         // restore snap
    1273           0 :                         if(!bWasNoSnap)
    1274           0 :                             ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
    1275           0 :                         if(bWasSnapEnabled)
    1276           0 :                             pSdrView->SetSnapEnabled(bWasSnapEnabled);
    1277             :                     }
    1278             :                 }
    1279             :             }
    1280             :         }
    1281           0 :         rSh.EndAllAction();
    1282             :     }
    1283             : 
    1284           0 :     rSh.EndUndo();
    1285           0 : }
    1286             : 
    1287             : /*--------------------------------------------------------------------
    1288             :     Description:   KeyEvents
    1289             :  --------------------------------------------------------------------*/
    1290             : 
    1291           0 : void SwEditWin::KeyInput(const KeyEvent &rKEvt)
    1292             : {
    1293           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    1294             : 
    1295           0 :     if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
    1296             :         pApplyTempl && pApplyTempl->pFormatClipboard )
    1297             :     {
    1298           0 :         pApplyTempl->pFormatClipboard->Erase();
    1299           0 :         SetApplyTemplate(SwApplyTemplate());
    1300           0 :         rView.GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
    1301             :     }
    1302           0 :     else if ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
    1303           0 :             rSh.IsHeaderFooterEdit( ) )
    1304             :     {
    1305           0 :         bool bHeader = FRMTYPE_HEADER & rSh.GetFrmType(0,sal_False);
    1306           0 :         if ( bHeader )
    1307           0 :             rSh.SttPg();
    1308             :         else
    1309           0 :             rSh.EndPg();
    1310           0 :         rSh.ToggleHeaderFooterEdit();
    1311             :     }
    1312             : 
    1313           0 :     SfxObjectShell *pObjSh = (SfxObjectShell*)rView.GetViewFrame()->GetObjectShell();
    1314           0 :     if ( bLockInput || (pObjSh && pObjSh->GetProgress()) )
    1315             :         // When the progress bar is active or a progress is
    1316             :         // running on a document, no order is being taken
    1317             :         return;
    1318             : 
    1319           0 :     delete pShadCrsr, pShadCrsr = 0;
    1320           0 :     aKeyInputFlushTimer.Stop();
    1321             : 
    1322           0 :     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
    1323           0 :                           rSh.IsCrsrReadonly();
    1324             : 
    1325             :     //if the language changes the buffer must be flushed
    1326           0 :     LanguageType eNewLanguage = GetInputLanguage();
    1327           0 :     if(!bIsDocReadOnly && eBufferLanguage != eNewLanguage && aInBuffer.Len())
    1328             :     {
    1329           0 :         FlushInBuffer();
    1330             :     }
    1331           0 :     eBufferLanguage = eNewLanguage;
    1332             : 
    1333           0 :     QuickHelpData aTmpQHD;
    1334           0 :     if( pQuickHlpData->m_bIsDisplayed )
    1335             :     {
    1336           0 :         aTmpQHD.Move( *pQuickHlpData );
    1337           0 :         pQuickHlpData->Stop( rSh );
    1338             :     }
    1339             : 
    1340             :     // OS:the DrawView also needs a readonly-Flag as well
    1341           0 :     if ( !bIsDocReadOnly && rSh.GetDrawView() && rSh.GetDrawView()->KeyInput( rKEvt, this ) )
    1342             :     {
    1343           0 :         rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll( sal_False );
    1344           0 :         rSh.SetModified();
    1345             :         return; // Event evaluated by SdrView
    1346             :     }
    1347             : 
    1348           0 :     if ( rView.GetDrawFuncPtr() && bInsFrm )
    1349             :     {
    1350           0 :         StopInsFrm();
    1351           0 :         rSh.Edit();
    1352             :     }
    1353             : 
    1354           0 :     sal_Bool bFlushBuffer = sal_False;
    1355           0 :     sal_Bool bNormalChar = sal_False;
    1356           0 :     bool bAppendSpace = pQuickHlpData->m_bAppendSpace;
    1357           0 :     pQuickHlpData->m_bAppendSpace = false;
    1358             : 
    1359           0 :     if ( getenv("SW_DEBUG") && rKEvt.GetKeyCode().GetCode() == KEY_F12 )
    1360             :     {
    1361           0 :         if( rKEvt.GetKeyCode().IsShift())
    1362             :         {
    1363           0 :             GetView().GetDocShell()->GetDoc()->dumpAsXml();
    1364             :             return;
    1365             :         }
    1366             :         else
    1367             :         {
    1368           0 :             SwRootFrm* pLayout = GetView().GetDocShell()->GetWrtShell()->GetLayout();
    1369           0 :             pLayout->dumpAsXml( );
    1370             :             return;
    1371             :         }
    1372             :     }
    1373             : 
    1374           0 :     KeyEvent aKeyEvent( rKEvt );
    1375             :     // look for vertical mappings
    1376           0 :     if( !bIsDocReadOnly && !rSh.IsSelFrmMode() && !rSh.IsObjSelected() )
    1377             :     {
    1378             :         // must changed from switch to if, because the Linux
    1379             :         // compiler has problem with the code. Has to remove if the new general
    1380             :         // handler exist.
    1381           0 :         sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
    1382             : 
    1383           0 :         if( KEY_UP == nKey || KEY_DOWN == nKey ||
    1384             :             KEY_LEFT == nKey || KEY_RIGHT == nKey )
    1385             :         {
    1386             :             // In general, we want to map the direction keys if we are inside
    1387             :             // some vertical formatted text.
    1388             :             // 1. Exception: For a table cursor in a horizontal table, the
    1389             :             //               directions should never be mapped.
    1390             :             // 2. Exception: For a table cursor in a vertical table, the
    1391             :             //               directions should always be mapped.
    1392           0 :             const bool bVertText = rSh.IsInVerticalText();
    1393           0 :             const bool bTblCrsr = rSh.GetTableCrsr();
    1394           0 :             const bool bVertTable = rSh.IsTableVertical();
    1395           0 :             if( ( bVertText && ( !bTblCrsr || bVertTable ) ) ||
    1396             :                 ( bTblCrsr && bVertTable ) )
    1397             :             {
    1398             :                 // Attempt to integrate cursor travelling for mongolian layout does not work.
    1399             :                 // Thus, back to previous mapping of cursor keys to direction keys.
    1400           0 :                 if( KEY_UP == nKey ) nKey = KEY_LEFT;
    1401           0 :                 else if( KEY_DOWN == nKey ) nKey = KEY_RIGHT;
    1402           0 :                 else if( KEY_LEFT == nKey ) nKey = KEY_DOWN;
    1403           0 :                 else if( KEY_RIGHT == nKey ) nKey = KEY_UP;
    1404             :             }
    1405             : 
    1406           0 :             if ( rSh.IsInRightToLeftText() )
    1407             :             {
    1408           0 :                 if( KEY_LEFT == nKey ) nKey = KEY_RIGHT;
    1409           0 :                 else if( KEY_RIGHT == nKey ) nKey = KEY_LEFT;
    1410             :             }
    1411             : 
    1412           0 :             aKeyEvent = KeyEvent( rKEvt.GetCharCode(),
    1413           0 :                                   KeyCode( nKey, rKEvt.GetKeyCode().GetModifier() ),
    1414           0 :                                   rKEvt.GetRepeat() );
    1415             :         }
    1416             :     }
    1417             : 
    1418           0 :     const KeyCode& rKeyCode = aKeyEvent.GetKeyCode();
    1419           0 :     sal_Unicode aCh = aKeyEvent.GetCharCode();
    1420             : 
    1421             :     // enable switching to notes ankor with Ctrl - Alt - Page Up/Down
    1422             :     // pressing this inside a note will switch to next/previous note
    1423           0 :     if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((rKeyCode.GetCode() == KEY_PAGEUP) || (rKeyCode.GetCode() == KEY_PAGEDOWN)))
    1424             :     {
    1425           0 :         bool bNext = rKeyCode.GetCode()==KEY_PAGEDOWN ? true : false;
    1426           0 :         SwFieldType* pFldType = rSh.GetFldType(0, RES_POSTITFLD);
    1427           0 :         rSh.MoveFldType( pFldType, bNext );
    1428             :         return;
    1429             :     }
    1430             : 
    1431           0 :     const SwFrmFmt* pFlyFmt = rSh.GetFlyFrmFmt();
    1432           0 :     if( pFlyFmt )
    1433             :     {
    1434             :         sal_uInt16 nEvent;
    1435             : 
    1436           0 :         if( 32 <= aCh &&
    1437           0 :             0 == (( KEY_MOD1 | KEY_MOD2 ) & rKeyCode.GetModifier() ))
    1438           0 :             nEvent = SW_EVENT_FRM_KEYINPUT_ALPHA;
    1439             :         else
    1440           0 :             nEvent = SW_EVENT_FRM_KEYINPUT_NOALPHA;
    1441             : 
    1442           0 :         const SvxMacro* pMacro = pFlyFmt->GetMacro().GetMacroTable().Get( nEvent );
    1443           0 :         if( pMacro )
    1444             :         {
    1445           0 :             String sRet;
    1446           0 :             SbxArrayRef xArgs = new SbxArray;
    1447           0 :             SbxVariableRef xVar = new SbxVariable;
    1448           0 :             xVar->PutString( pFlyFmt->GetName() );
    1449           0 :             xArgs->Put( &xVar, 1 );
    1450             : 
    1451           0 :             xVar = new SbxVariable;
    1452           0 :             if( SW_EVENT_FRM_KEYINPUT_ALPHA == nEvent )
    1453           0 :                 xVar->PutChar( aCh );
    1454             :             else
    1455           0 :                 xVar->PutUShort( rKeyCode.GetModifier() | rKeyCode.GetCode() );
    1456           0 :             xArgs->Put( &xVar, 2 );
    1457             : 
    1458           0 :             rSh.ExecMacro( *pMacro, &sRet, &xArgs );
    1459           0 :             if( sRet.Len() && 0 != sRet.ToInt32() )
    1460           0 :                 return ;
    1461             :         }
    1462             :     }
    1463             :     int nLclSelectionType;
    1464             :     //A is converted to 1
    1465           0 :     if( rKeyCode.GetFullCode() == (KEY_A | KEY_MOD1 |KEY_SHIFT)
    1466           0 :         && rSh.HasDrawView() &&
    1467             :         (0 != (nLclSelectionType = rSh.GetSelectionType()) &&
    1468             :         ((nLclSelectionType & (nsSelectionType::SEL_FRM|nsSelectionType::SEL_GRF)) ||
    1469             :         ((nLclSelectionType & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) &&
    1470           0 :                 rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1))))
    1471             :     {
    1472           0 :         SdrHdlList& rHdlList = (SdrHdlList&)rSh.GetDrawView()->GetHdlList();
    1473           0 :         SdrHdl* pAnchor = rHdlList.GetHdl(HDL_ANCHOR);
    1474           0 :         if ( ! pAnchor )
    1475           0 :             pAnchor = rHdlList.GetHdl(HDL_ANCHOR_TR);
    1476           0 :         if(pAnchor)
    1477           0 :             rHdlList.SetFocusHdl(pAnchor);
    1478             :         return;
    1479             :     }
    1480             : 
    1481           0 :     SvxAutoCorrCfg* pACfg = 0;
    1482           0 :     SvxAutoCorrect* pACorr = 0;
    1483             : 
    1484             :     uno::Reference< frame::XDispatchRecorder > xRecorder =
    1485           0 :             rView.GetViewFrame()->GetBindings().GetRecorder();
    1486           0 :     if ( !xRecorder.is() )
    1487             :     {
    1488           0 :         pACfg = &SvxAutoCorrCfg::Get();
    1489           0 :         pACorr = pACfg->GetAutoCorrect();
    1490             :     }
    1491             : 
    1492           0 :     SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
    1493             : 
    1494           0 :     TblChgWidthHeightType eTblChgMode = nsTblChgWidthHeightType::WH_COL_LEFT;    // initialization just for warning-free code
    1495           0 :     sal_uInt16 nTblChgSize = 0;
    1496           0 :     sal_Bool bStopKeyInputTimer = sal_True;
    1497           0 :     String sFmlEntry;
    1498             : 
    1499             :     enum SW_AutoCompleteAction { ACA_NoOp,            // No maintenance operation required for AutoComplete tree
    1500             :                                  ACA_ReturnToRoot,    // Input of a char marking the end of a word, like '.', ' ', etc.
    1501             :                                  ACA_SingleCharInput,
    1502             :                                  ACA_SingleBackspace,
    1503             :                                  ACA_Refresh };       // Refresh AutoComplete information completely.
    1504             : 
    1505             :     // Do refresh by default to gracefully handle all unimplemented special cases.
    1506           0 :     SW_AutoCompleteAction eAutoCompleteAction = ACA_Refresh;
    1507             :     // TODO: Make sure eAutoCompleteAction is set to something other than ACA_Refresh to increase performance.
    1508             : 
    1509             :     // Stores input char in case ACA_SingleCharInput is used. Defaults to aCh to avoid compiler warning.
    1510           0 :     sal_Unicode aSingleCharInput = aCh;
    1511             : 
    1512             :     enum SW_KeyState { KS_Start,
    1513             :                        KS_CheckKey, KS_InsChar, KS_InsTab,
    1514             :                        KS_NoNum, KS_NumOff, KS_NumOrNoNum, KS_NumDown, KS_NumUp,
    1515             :                        KS_NumIndentInc, KS_NumIndentDec,
    1516             : 
    1517             :                        KS_OutlineLvOff,
    1518             :                        KS_NextCell, KS_PrevCell, KS_OutlineUp, KS_OutlineDown,
    1519             :                        KS_GlossaryExpand, KS_NextPrevGlossary,
    1520             :                        KS_AutoFmtByInput,
    1521             :                        KS_NextObject, KS_PrevObject,
    1522             :                        KS_KeyToView,
    1523             :                        KS_LaunchOLEObject, KS_GoIntoFly, KS_GoIntoDrawing,
    1524             :                        KS_EnterDrawHandleMode,
    1525             :                        KS_CheckDocReadOnlyKeys,
    1526             :                        KS_CheckAutoCorrect, KS_EditFormula,
    1527             :                        KS_ColLeftBig, KS_ColRightBig,
    1528             :                        KS_ColLeftSmall, KS_ColRightSmall,
    1529             :                        KS_ColTopBig, KS_ColBottomBig,
    1530             :                        KS_ColTopSmall, KS_ColBottomSmall,
    1531             :                        KS_CellLeftBig, KS_CellRightBig,
    1532             :                        KS_CellLeftSmall, KS_CellRightSmall,
    1533             :                        KS_CellTopBig, KS_CellBottomBig,
    1534             :                        KS_CellTopSmall, KS_CellBottomSmall,
    1535             : 
    1536             :                        KS_InsDel_ColLeftBig, KS_InsDel_ColRightBig,
    1537             :                        KS_InsDel_ColLeftSmall, KS_InsDel_ColRightSmall,
    1538             :                        KS_InsDel_ColTopBig, KS_InsDel_ColBottomBig,
    1539             :                        KS_InsDel_ColTopSmall, KS_InsDel_ColBottomSmall,
    1540             :                        KS_InsDel_CellLeftBig, KS_InsDel_CellRightBig,
    1541             :                        KS_InsDel_CellLeftSmall, KS_InsDel_CellRightSmall,
    1542             :                        KS_InsDel_CellTopBig, KS_InsDel_CellBottomBig,
    1543             :                        KS_InsDel_CellTopSmall, KS_InsDel_CellBottomSmall,
    1544             :                        KS_TblColCellInsDel,
    1545             : 
    1546             :                        KS_Fly_Change, KS_Draw_Change,
    1547             :                        KS_SpecialInsert,
    1548             :                        KS_EnterCharCell,
    1549             :                        KS_GotoNextFieldMark,
    1550             :                        KS_GotoPrevFieldMark,
    1551             :                        KS_End };
    1552             : 
    1553             :     SW_KeyState eKeyState = bIsDocReadOnly ? KS_CheckDocReadOnlyKeys
    1554           0 :                                            : KS_CheckKey,
    1555           0 :                 eNextKeyState = KS_End;
    1556           0 :     sal_uInt8 nDir = 0;
    1557             : 
    1558           0 :     if (nKS_NUMDOWN_Count > 0)
    1559           0 :         nKS_NUMDOWN_Count--;
    1560             : 
    1561           0 :     if (nKS_NUMINDENTINC_Count > 0)
    1562           0 :         nKS_NUMINDENTINC_Count--;
    1563             : 
    1564           0 :     while( KS_End != eKeyState )
    1565             :     {
    1566           0 :         SW_KeyState eFlyState = KS_KeyToView;
    1567             : 
    1568           0 :         switch( eKeyState )
    1569             :         {
    1570             :         case KS_CheckKey:
    1571           0 :             eKeyState = KS_KeyToView;       // default forward to View
    1572             : 
    1573             : #if OSL_DEBUG_LEVEL > 1
    1574             : //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1575             :             // for switching curor behaviour in ReadOnly regions
    1576             :             if( 0x7210 == rKeyCode.GetFullCode() )
    1577             :                 rSh.SetReadOnlyAvailable( !rSh.IsReadOnlyAvailable() );
    1578             :             else
    1579             : //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1580             : #endif
    1581             : 
    1582           0 :             if( !rKeyCode.IsMod2() && '=' == aCh &&
    1583           0 :                 !rSh.IsTableMode() && rSh.GetTableFmt() &&
    1584           0 :                 rSh.IsSttPara() &&
    1585           0 :                 !rSh.HasReadonlySel() )
    1586             :             {
    1587             :                 // at the beginning of the table's cell a '=' ->
    1588             :                 // call EditRow (F2-functionality)
    1589           0 :                 rSh.Push();
    1590           0 :                 if( !rSh.MoveSection( fnSectionCurr, fnSectionStart) &&
    1591           0 :                     !rSh.IsTableBoxTextFormat() )
    1592             :                 {
    1593             :                     // is at the beginning of the box
    1594           0 :                     eKeyState = KS_EditFormula;
    1595           0 :                     if( rSh.HasMark() )
    1596           0 :                         rSh.SwapPam();
    1597             :                     else
    1598           0 :                         rSh.SttSelect();
    1599           0 :                     rSh.MoveSection( fnSectionCurr, fnSectionEnd );
    1600           0 :                     rSh.Pop( sal_True );
    1601           0 :                     rSh.EndSelect();
    1602           0 :                     sFmlEntry = '=';
    1603             :                 }
    1604             :                 else
    1605           0 :                     rSh.Pop( sal_False );
    1606             :             }
    1607             :             else
    1608             :             {
    1609           0 :                 if( pACorr && aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
    1610           0 :                     !rSh.HasReadonlySel() && !aTmpQHD.m_bIsAutoText &&
    1611           0 :                     pACorr->GetSwFlags().nAutoCmpltExpandKey ==
    1612           0 :                     (rKeyCode.GetModifier() | rKeyCode.GetCode()) )
    1613             :                 {
    1614           0 :                     eKeyState = KS_GlossaryExpand;
    1615           0 :                     break;
    1616             :                 }
    1617             : 
    1618           0 :                 switch( rKeyCode.GetModifier() | rKeyCode.GetCode() )
    1619             :                 {
    1620             :                 case KEY_RIGHT | KEY_MOD2:
    1621           0 :                     eKeyState = KS_ColRightBig;
    1622           0 :                     eFlyState = KS_Fly_Change;
    1623           0 :                     nDir = MOVE_RIGHT_SMALL;
    1624           0 :                     goto KEYINPUT_CHECKTABLE;
    1625             : 
    1626             :                 case KEY_LEFT | KEY_MOD2:
    1627           0 :                     eKeyState = KS_ColRightSmall;
    1628           0 :                     eFlyState = KS_Fly_Change;
    1629           0 :                     nDir = MOVE_LEFT_SMALL;
    1630           0 :                     goto KEYINPUT_CHECKTABLE;
    1631             :                 case KEY_RIGHT | KEY_MOD2 | KEY_SHIFT:
    1632           0 :                     eKeyState = KS_ColLeftSmall;
    1633           0 :                     goto KEYINPUT_CHECKTABLE;
    1634             :                 case KEY_LEFT | KEY_MOD2 | KEY_SHIFT:
    1635           0 :                     eKeyState = KS_ColLeftBig;
    1636           0 :                     goto KEYINPUT_CHECKTABLE;
    1637             : 
    1638             :                 case KEY_RIGHT | KEY_MOD2 | KEY_MOD1:
    1639           0 :                     eKeyState = KS_CellRightBig;
    1640           0 :                     goto KEYINPUT_CHECKTABLE;
    1641             :                 case KEY_LEFT | KEY_MOD2 | KEY_MOD1:
    1642           0 :                     eKeyState = KS_CellRightSmall;
    1643           0 :                     goto KEYINPUT_CHECKTABLE;
    1644             :                 case KEY_RIGHT | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
    1645           0 :                     eKeyState = KS_CellLeftSmall;
    1646           0 :                     goto KEYINPUT_CHECKTABLE;
    1647             :                 case KEY_LEFT | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
    1648           0 :                     eKeyState = KS_CellLeftBig;
    1649           0 :                     goto KEYINPUT_CHECKTABLE;
    1650             : 
    1651             :                 case KEY_UP | KEY_MOD2:
    1652           0 :                     eKeyState = KS_ColBottomSmall;
    1653           0 :                     eFlyState = KS_Fly_Change;
    1654           0 :                     nDir = MOVE_UP_SMALL;
    1655           0 :                     goto KEYINPUT_CHECKTABLE;
    1656             :                 case KEY_DOWN | KEY_MOD2:
    1657           0 :                     eKeyState = KS_ColBottomBig;
    1658           0 :                     eFlyState = KS_Fly_Change;
    1659           0 :                     nDir = MOVE_DOWN_SMALL;
    1660           0 :                     goto KEYINPUT_CHECKTABLE;
    1661             : 
    1662             :                 case KEY_UP | KEY_MOD2 | KEY_MOD1:
    1663           0 :                     eKeyState = KS_CellBottomSmall;
    1664           0 :                     goto KEYINPUT_CHECKTABLE;
    1665             :                 case KEY_DOWN | KEY_MOD2 | KEY_MOD1:
    1666           0 :                     eKeyState = KS_CellBottomBig;
    1667           0 :                     goto KEYINPUT_CHECKTABLE;
    1668             :                 case KEY_UP | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
    1669           0 :                     eKeyState = KS_CellTopBig;
    1670           0 :                     goto KEYINPUT_CHECKTABLE;
    1671             :                 case KEY_DOWN | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
    1672           0 :                     eKeyState = KS_CellTopSmall;
    1673           0 :                     goto KEYINPUT_CHECKTABLE;
    1674             : 
    1675             : KEYINPUT_CHECKTABLE:
    1676           0 :                     if( rSh.IsTableMode() || !rSh.GetTableFmt() )
    1677             :                     {
    1678           0 :                         if(KS_KeyToView != eFlyState)
    1679             :                         {
    1680           0 :                             if(!pFlyFmt && KS_KeyToView != eFlyState &&
    1681           0 :                                 (rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM))  &&
    1682           0 :                                     rSh.GetDrawView()->AreObjectsMarked())
    1683           0 :                                 eKeyState = KS_Draw_Change;
    1684             :                         }
    1685             : 
    1686           0 :                         if( pFlyFmt )
    1687           0 :                             eKeyState = eFlyState;
    1688           0 :                         else if( KS_Draw_Change != eKeyState)
    1689           0 :                             eKeyState = KS_EnterCharCell;
    1690             :                     }
    1691           0 :                     break;
    1692             : 
    1693             :                 case KEY_LEFT:
    1694             :                 {
    1695           0 :                     eAutoCompleteAction = ACA_ReturnToRoot;
    1696             :                 }
    1697             :                 // No break;
    1698             :                 case KEY_LEFT | KEY_MOD1:
    1699             :                 {
    1700           0 :                     sal_Bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
    1701           0 :                     if(!bMod1)
    1702             :                     {
    1703           0 :                         eFlyState = KS_Fly_Change;
    1704           0 :                         nDir = MOVE_LEFT_BIG;
    1705             :                     }
    1706             :                     eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
    1707             :                             ( bMod1
    1708             :                                 ? nsTblChgWidthHeightType::WH_CELL_LEFT
    1709           0 :                                 : nsTblChgWidthHeightType::WH_COL_LEFT );
    1710           0 :                     nTblChgSize = pModOpt->GetTblVInsert();
    1711             :                 }
    1712           0 :                     goto KEYINPUT_CHECKTABLE_INSDEL;
    1713             :                 case KEY_RIGHT | KEY_MOD1:
    1714             :                 {
    1715           0 :                     eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | nsTblChgWidthHeightType::WH_CELL_RIGHT;
    1716           0 :                     nTblChgSize = pModOpt->GetTblVInsert();
    1717             :                 }
    1718           0 :                     goto KEYINPUT_CHECKTABLE_INSDEL;
    1719             :                 case KEY_UP:
    1720             :                 {
    1721           0 :                     eAutoCompleteAction = ACA_ReturnToRoot;
    1722             :                 }
    1723             :                 // No break;
    1724             :                 case KEY_UP | KEY_MOD1:
    1725             :                 {
    1726           0 :                     sal_Bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
    1727           0 :                     if(!bMod1)
    1728             :                     {
    1729           0 :                         eFlyState = KS_Fly_Change;
    1730           0 :                         nDir = MOVE_UP_BIG;
    1731             :                     }
    1732             :                     eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
    1733             :                             ( bMod1
    1734             :                                 ? nsTblChgWidthHeightType::WH_CELL_TOP
    1735           0 :                                 : nsTblChgWidthHeightType::WH_ROW_TOP );
    1736           0 :                     nTblChgSize = pModOpt->GetTblHInsert();
    1737             :                 }
    1738           0 :                     goto KEYINPUT_CHECKTABLE_INSDEL;
    1739             :                 case KEY_DOWN:
    1740             :                 {
    1741           0 :                     eAutoCompleteAction = ACA_ReturnToRoot;
    1742             :                 }
    1743             :                 // No break;
    1744             :                 case KEY_DOWN | KEY_MOD1:
    1745             :                 {
    1746           0 :                     sal_Bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
    1747           0 :                     if(!bMod1)
    1748             :                     {
    1749           0 :                         eFlyState = KS_Fly_Change;
    1750           0 :                         nDir = MOVE_DOWN_BIG;
    1751             :                     }
    1752             :                     eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
    1753             :                             ( bMod1
    1754             :                                 ? nsTblChgWidthHeightType::WH_CELL_BOTTOM
    1755           0 :                                 : nsTblChgWidthHeightType::WH_ROW_BOTTOM );
    1756           0 :                     nTblChgSize = pModOpt->GetTblHInsert();
    1757             :                 }
    1758           0 :                     goto KEYINPUT_CHECKTABLE_INSDEL;
    1759             : 
    1760             : KEYINPUT_CHECKTABLE_INSDEL:
    1761           0 :                     if( rSh.IsTableMode() || !rSh.GetTableFmt() ||
    1762           0 :                         !bTblInsDelMode ||
    1763             :                         sal_False /* table protected */
    1764             :                             )
    1765             :                     {
    1766           0 :                         const int nSelectionType = rSh.GetSelectionType();
    1767             : 
    1768           0 :                         eKeyState = KS_KeyToView;
    1769           0 :                         if(KS_KeyToView != eFlyState)
    1770             :                         {
    1771           0 :                             if((nSelectionType & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM))  &&
    1772           0 :                                     rSh.GetDrawView()->AreObjectsMarked())
    1773           0 :                                 eKeyState = KS_Draw_Change;
    1774           0 :                             else if(nSelectionType & (nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF))
    1775           0 :                                 eKeyState = KS_Fly_Change;
    1776             :                         }
    1777             :                     }
    1778             :                     else
    1779             :                     {
    1780           0 :                         if( !bTblIsInsMode )
    1781           0 :                             eTblChgMode = eTblChgMode | nsTblChgWidthHeightType::WH_FLAG_BIGGER;
    1782           0 :                         eKeyState = KS_TblColCellInsDel;
    1783             :                     }
    1784           0 :                     break;
    1785             : 
    1786             :                 case KEY_DELETE:
    1787           0 :                     if ( !rSh.HasReadonlySel() )
    1788             :                     {
    1789           0 :                         if (rSh.IsInFrontOfLabel() && rSh.NumOrNoNum(sal_False))
    1790           0 :                             eKeyState = KS_NumOrNoNum;
    1791           0 :                         eAutoCompleteAction = ACA_NoOp;
    1792             :                     }
    1793             :                     else
    1794             :                     {
    1795           0 :                         InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute();
    1796           0 :                         eKeyState = KS_End;
    1797             :                     }
    1798           0 :                     break;
    1799             : 
    1800             :                 case KEY_DELETE | KEY_MOD2:
    1801           0 :                     if( !rSh.IsTableMode() && rSh.GetTableFmt() )
    1802             :                     {
    1803           0 :                         eKeyState = KS_End;
    1804           0 :                         bTblInsDelMode = sal_True;
    1805           0 :                         bTblIsInsMode = sal_False;
    1806           0 :                         bTblIsColMode = sal_True;
    1807           0 :                         aKeyInputTimer.Start();
    1808           0 :                         bStopKeyInputTimer = sal_False;
    1809           0 :                         eAutoCompleteAction = ACA_NoOp;
    1810             :                     }
    1811           0 :                     break;
    1812             :                 case KEY_INSERT | KEY_MOD2:
    1813           0 :                     if( !rSh.IsTableMode() && rSh.GetTableFmt() )
    1814             :                     {
    1815           0 :                         eKeyState = KS_End;
    1816           0 :                         bTblInsDelMode = sal_True;
    1817           0 :                         bTblIsInsMode = sal_True;
    1818           0 :                         bTblIsColMode = sal_True;
    1819           0 :                         aKeyInputTimer.Start();
    1820           0 :                         bStopKeyInputTimer = sal_False;
    1821           0 :                         eAutoCompleteAction = ACA_NoOp;
    1822             :                     }
    1823           0 :                     break;
    1824             : 
    1825             :                 case KEY_RETURN:
    1826             :                 {
    1827           0 :                     if( !rSh.HasReadonlySel() )
    1828             :                     {
    1829           0 :                         const int nSelectionType = rSh.GetSelectionType();
    1830           0 :                         if(nSelectionType & nsSelectionType::SEL_OLE)
    1831           0 :                             eKeyState = KS_LaunchOLEObject;
    1832           0 :                         else if(nSelectionType & nsSelectionType::SEL_FRM)
    1833           0 :                             eKeyState = KS_GoIntoFly;
    1834           0 :                         else if((nSelectionType & nsSelectionType::SEL_DRW) &&
    1835             :                                 0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) &&
    1836           0 :                                 rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1)
    1837           0 :                             eKeyState = KS_GoIntoDrawing;
    1838           0 :                         else if( aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
    1839             :                             aTmpQHD.m_bIsAutoText )
    1840           0 :                             eKeyState = KS_GlossaryExpand;
    1841             : 
    1842             :                         //RETURN and empty paragraph in numbering -> end numbering
    1843           0 :                         else if( !aInBuffer.Len() &&
    1844           0 :                                  rSh.GetCurNumRule() &&
    1845           0 :                                  !rSh.GetCurNumRule()->IsOutlineRule() &&
    1846           0 :                                  !rSh.HasSelection() &&
    1847           0 :                                 rSh.IsSttPara() && rSh.IsEndPara() )
    1848           0 :                             eKeyState = KS_NumOff, eNextKeyState = KS_OutlineLvOff;
    1849             : 
    1850             :                         //RETURN for new paragraph with AutoFormating
    1851           0 :                         else if( pACfg && pACfg->IsAutoFmtByInput() &&
    1852             :                                 !(nSelectionType & (nsSelectionType::SEL_GRF |
    1853             :                                     nsSelectionType::SEL_OLE | nsSelectionType::SEL_FRM |
    1854             :                                     nsSelectionType::SEL_TBL_CELLS | nsSelectionType::SEL_DRW |
    1855           0 :                                     nsSelectionType::SEL_DRW_TXT)) )
    1856           0 :                             eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_AutoFmtByInput;
    1857             :                         else
    1858           0 :                             eNextKeyState = eKeyState, eKeyState = KS_CheckAutoCorrect;
    1859             :                     }
    1860           0 :                     eAutoCompleteAction = ACA_ReturnToRoot;
    1861             :                 }
    1862           0 :                 break;
    1863             :                 case KEY_RETURN | KEY_MOD2:     // ALT-Return
    1864             :                 {
    1865           0 :                     if( !rSh.HasReadonlySel() && !rSh.IsSttPara() && rSh.GetCurNumRule() )
    1866           0 :                         eKeyState = KS_NoNum;
    1867           0 :                     else if( rSh.CanSpecialInsert() )
    1868           0 :                         eKeyState = KS_SpecialInsert;
    1869           0 :                     eAutoCompleteAction = ACA_ReturnToRoot;
    1870             :                 }
    1871           0 :                 break;
    1872             :                 case KEY_BACKSPACE:
    1873             :                 case KEY_BACKSPACE | KEY_SHIFT:
    1874           0 :                     if( !rSh.HasReadonlySel() )
    1875             :                     {
    1876           0 :                         sal_Bool bDone = sal_False;
    1877             :                         // try to add comment for code snip:
    1878             :                         // Remove the paragraph indent, if the cursor is at the
    1879             :                         // beginning of a paragraph, there is no selection
    1880             :                         // and no numbering rule found at the current paragraph
    1881             :                         // Also try to remove indent, if current paragraph
    1882             :                         // has numbering rule, but isn't counted and only
    1883             :                         // key <backspace> is hit.
    1884             :                         const bool bOnlyBackspaceKey(
    1885           0 :                                     KEY_BACKSPACE == rKeyCode.GetFullCode() );
    1886           0 :                         if ( rSh.IsSttPara() &&
    1887           0 :                              !rSh.HasSelection() &&
    1888           0 :                              ( NULL == rSh.GetCurNumRule() ||
    1889           0 :                                ( rSh.IsNoNum() && bOnlyBackspaceKey ) ) )
    1890             :                         {
    1891           0 :                             bDone = rSh.TryRemoveIndent();
    1892             :                         }
    1893             : 
    1894           0 :                         if ( bOnlyBackspaceKey )
    1895             :                         {
    1896           0 :                             eAutoCompleteAction = ACA_SingleBackspace;
    1897             :                         }
    1898             : 
    1899           0 :                         if (bDone)
    1900           0 :                             eKeyState = KS_End;
    1901             :                         else
    1902             :                         {
    1903           0 :                             if (rSh.IsSttPara() &&
    1904           0 :                                 ! rSh.IsNoNum())
    1905             :                             {
    1906           0 :                                 if (nKS_NUMDOWN_Count > 0 &&
    1907           0 :                                     0 < rSh.GetNumLevel())
    1908             :                                 {
    1909           0 :                                     eKeyState = KS_NumUp;
    1910           0 :                                     nKS_NUMDOWN_Count = 2;
    1911           0 :                                     bDone = sal_True;
    1912             :                                 }
    1913           0 :                                 else if (nKS_NUMINDENTINC_Count > 0)
    1914             :                                 {
    1915           0 :                                     eKeyState = KS_NumIndentDec;
    1916           0 :                                     nKS_NUMINDENTINC_Count = 2;
    1917           0 :                                     bDone = sal_True;
    1918             :                                 }
    1919             :                             }
    1920             : 
    1921             :                             // If the cursor is in an empty paragraph, which has
    1922             :                             // a numbering, but not the oultine numbering, and
    1923             :                             // there is no selection, the numbering has to be
    1924             :                             // deleted on key <Backspace>.
    1925             :                             // Otherwise method <SwEditShell::NumOrNoNum(..)>
    1926             :                             // should only change the <IsCounted()> state of
    1927             :                             // the current paragraph depending of the key.
    1928             :                             // On <backspace> it is set to <false>,
    1929             :                             // on <shift-backspace> it is set to <true>.
    1930             :                             // Thus, assure that method <SwEditShell::NumOrNum(..)>
    1931             :                             // is only called for the intended purpose.
    1932           0 :                             bool bCallNumOrNoNum( false );
    1933             :                             {
    1934           0 :                                 if ( !bDone )
    1935             :                                 {
    1936           0 :                                     if ( bOnlyBackspaceKey && !rSh.IsNoNum() )
    1937             :                                     {
    1938           0 :                                         bCallNumOrNoNum = true;
    1939             :                                     }
    1940           0 :                                     else if ( !bOnlyBackspaceKey && rSh.IsNoNum() )
    1941             :                                     {
    1942           0 :                                         bCallNumOrNoNum = true;
    1943             :                                     }
    1944           0 :                                     else if ( bOnlyBackspaceKey &&
    1945           0 :                                               rSh.IsSttPara() && rSh.IsEndPara() &&
    1946           0 :                                               !rSh.HasSelection() )
    1947             :                                     {
    1948           0 :                                         const SwNumRule* pCurrNumRule( rSh.GetCurNumRule() );
    1949           0 :                                         if ( pCurrNumRule &&
    1950           0 :                                              pCurrNumRule != rSh.GetOutlineNumRule() )
    1951             :                                         {
    1952           0 :                                             bCallNumOrNoNum = true;
    1953             :                                         }
    1954             :                                     }
    1955             :                                 }
    1956             :                             }
    1957           0 :                             if ( bCallNumOrNoNum &&
    1958           0 :                                  rSh.NumOrNoNum( !bOnlyBackspaceKey, true ) )
    1959             :                             {
    1960           0 :                                 eKeyState = KS_NumOrNoNum;
    1961             :                             }
    1962             :                         }
    1963             :                     }
    1964             :                     else
    1965             :                     {
    1966           0 :                         InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute();
    1967           0 :                         eKeyState = KS_End;
    1968             :                     }
    1969           0 :                     break;
    1970             : 
    1971             :                 case KEY_RIGHT:
    1972             :                     {
    1973           0 :                         eFlyState = KS_Fly_Change;
    1974           0 :                         nDir = MOVE_RIGHT_BIG;
    1975           0 :                         eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | nsTblChgWidthHeightType::WH_COL_RIGHT;
    1976           0 :                         nTblChgSize = pModOpt->GetTblVInsert();
    1977           0 :                         eAutoCompleteAction = ACA_ReturnToRoot;
    1978           0 :                         goto KEYINPUT_CHECKTABLE_INSDEL;
    1979             :                     }
    1980             :                 case KEY_TAB:
    1981             :                 {
    1982             : 
    1983           0 :                     if (rSh.IsFormProtected() || rSh.GetCurrentFieldmark() || rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT)
    1984             :                     {
    1985           0 :                         eKeyState=KS_GotoNextFieldMark;
    1986             :                     }
    1987             :                     else
    1988           0 :                     if( rSh.GetCurNumRule() && rSh.IsSttOfPara() &&
    1989           0 :                         !rSh.HasReadonlySel() )
    1990             :                     {
    1991           0 :                         if ( rSh.IsFirstOfNumRule() &&
    1992           0 :                              numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() )
    1993           0 :                             eKeyState = KS_NumIndentInc;
    1994             :                         else
    1995           0 :                             eKeyState = KS_NumDown;
    1996             :                     }
    1997           0 :                     else if ( rSh.GetTableFmt() )
    1998             :                     {
    1999           0 :                         if( rSh.HasSelection() || rSh.HasReadonlySel() )
    2000           0 :                             eKeyState = KS_NextCell;
    2001             :                         else
    2002           0 :                             eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_NextCell;
    2003             :                     }
    2004           0 :                     else if ( rSh.GetSelectionType() &
    2005             :                                 (nsSelectionType::SEL_GRF |
    2006             :                                     nsSelectionType::SEL_FRM |
    2007             :                                     nsSelectionType::SEL_OLE |
    2008             :                                     nsSelectionType::SEL_DRW |
    2009             :                                     nsSelectionType::SEL_DRW_FORM))
    2010             : 
    2011           0 :                             eKeyState = KS_NextObject;
    2012             :                     else
    2013             :                     {
    2014           0 :                         eKeyState = KS_InsTab;
    2015           0 :                         if( rSh.IsSttOfPara() && !rSh.HasReadonlySel() )
    2016             :                         {
    2017           0 :                             SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
    2018           0 :                             if( pColl &&
    2019             : 
    2020           0 :                                 pColl->IsAssignedToListLevelOfOutlineStyle()
    2021           0 :                                 && MAXLEVEL-1 > pColl->GetAssignedOutlineStyleLevel() )
    2022           0 :                                 eKeyState = KS_OutlineDown;
    2023             :                         }
    2024             :                     }
    2025             :                 }
    2026           0 :                 break;
    2027             :                 case KEY_TAB | KEY_SHIFT:
    2028             :                 {
    2029           0 :                     if (rSh.IsFormProtected() || rSh.GetCurrentFieldmark()|| rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT) {
    2030           0 :                         eKeyState=KS_GotoPrevFieldMark;
    2031             :                     }
    2032           0 :                     else if( rSh.GetCurNumRule() && rSh.IsSttOfPara() &&
    2033           0 :                          !rSh.HasReadonlySel() )
    2034             :                     {
    2035             : 
    2036           0 :                         if ( rSh.IsFirstOfNumRule() &&
    2037           0 :                              numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() )
    2038           0 :                             eKeyState = KS_NumIndentDec;
    2039             :                         else
    2040           0 :                             eKeyState = KS_NumUp;
    2041             :                     }
    2042           0 :                     else if ( rSh.GetTableFmt() )
    2043             :                     {
    2044           0 :                         if( rSh.HasSelection() || rSh.HasReadonlySel() )
    2045           0 :                             eKeyState = KS_PrevCell;
    2046             :                         else
    2047           0 :                             eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_PrevCell;
    2048             :                     }
    2049           0 :                     else if ( rSh.GetSelectionType() &
    2050             :                                 (nsSelectionType::SEL_GRF |
    2051             :                                     nsSelectionType::SEL_FRM |
    2052             :                                     nsSelectionType::SEL_OLE |
    2053             :                                     nsSelectionType::SEL_DRW |
    2054             :                                     nsSelectionType::SEL_DRW_FORM))
    2055             : 
    2056           0 :                             eKeyState = KS_PrevObject;
    2057             :                     else
    2058             :                     {
    2059           0 :                         eKeyState = KS_End;
    2060           0 :                         if( rSh.IsSttOfPara() && !rSh.HasReadonlySel() )
    2061             :                         {
    2062           0 :                             SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
    2063           0 :                             if( pColl &&
    2064           0 :                                 pColl->IsAssignedToListLevelOfOutlineStyle() &&
    2065           0 :                                 0 < pColl->GetAssignedOutlineStyleLevel())
    2066           0 :                                 eKeyState = KS_OutlineUp;
    2067             :                         }
    2068             :                     }
    2069             :                 }
    2070           0 :                 break;
    2071             :                 case KEY_TAB | KEY_MOD1:
    2072             :                 case KEY_TAB | KEY_MOD2:
    2073           0 :                     if( !rSh.HasReadonlySel() )
    2074             :                     {
    2075           0 :                         if( aTmpQHD.HasCntnt() && !rSh.HasSelection() )
    2076             :                         {
    2077             :                             // Next auto-complete suggestion
    2078             :                             aTmpQHD.Next( pACorr &&
    2079           0 :                                           pACorr->GetSwFlags().bAutoCmpltEndless );
    2080           0 :                             eKeyState = KS_NextPrevGlossary;
    2081             :                         }
    2082           0 :                         else if( rSh.GetTableFmt() )
    2083           0 :                             eKeyState = KS_InsTab;
    2084           0 :                         else if((rSh.GetSelectionType() &
    2085             :                                     (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM|
    2086             :                                         nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF))  &&
    2087           0 :                                 rSh.GetDrawView()->AreObjectsMarked())
    2088           0 :                             eKeyState = KS_EnterDrawHandleMode;
    2089             :                         else
    2090             :                         {
    2091           0 :                             eKeyState = KS_InsTab;
    2092             :                         }
    2093           0 :                         eAutoCompleteAction = ACA_NoOp;
    2094             :                     }
    2095           0 :                     break;
    2096             : 
    2097             :                     case KEY_TAB | KEY_MOD1 | KEY_SHIFT:
    2098             :                     {
    2099           0 :                         if( aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
    2100           0 :                             !rSh.HasReadonlySel() )
    2101             :                         {
    2102             :                             // Previous auto-complete suggestion.
    2103             :                             aTmpQHD.Previous( pACorr &&
    2104           0 :                                               pACorr->GetSwFlags().bAutoCmpltEndless );
    2105           0 :                             eKeyState = KS_NextPrevGlossary;
    2106             :                         }
    2107           0 :                         else if((rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM|
    2108             :                                         nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF)) &&
    2109           0 :                                 rSh.GetDrawView()->AreObjectsMarked())
    2110             :                         {
    2111           0 :                             eKeyState = KS_EnterDrawHandleMode;
    2112             :                         }
    2113           0 :                         eAutoCompleteAction = ACA_NoOp;
    2114             :                     }
    2115           0 :                     break;
    2116             :                     case KEY_F2 :
    2117           0 :                     if( !rSh.HasReadonlySel() )
    2118             :                     {
    2119           0 :                         const int nSelectionType = rSh.GetSelectionType();
    2120           0 :                         if(nSelectionType & nsSelectionType::SEL_FRM)
    2121           0 :                             eKeyState = KS_GoIntoFly;
    2122           0 :                         else if((nSelectionType & nsSelectionType::SEL_DRW))
    2123           0 :                             eKeyState = KS_GoIntoDrawing;
    2124           0 :                         eAutoCompleteAction = ACA_NoOp;
    2125             :                     }
    2126           0 :                     break;
    2127             :                 }
    2128             :             }
    2129           0 :             break;
    2130             :         case KS_CheckDocReadOnlyKeys:
    2131             :             {
    2132           0 :                 eKeyState = KS_KeyToView;
    2133           0 :                 switch( rKeyCode.GetModifier() | rKeyCode.GetCode() )
    2134             :                 {
    2135             :                     case KEY_TAB:
    2136             :                     case KEY_TAB | KEY_SHIFT:
    2137           0 :                         bNormalChar = sal_False;
    2138           0 :                         eKeyState = KS_End;
    2139           0 :                         if ( rSh.GetSelectionType() &
    2140             :                                 (nsSelectionType::SEL_GRF |
    2141             :                                     nsSelectionType::SEL_FRM |
    2142             :                                     nsSelectionType::SEL_OLE |
    2143             :                                     nsSelectionType::SEL_DRW |
    2144             :                                     nsSelectionType::SEL_DRW_FORM))
    2145             : 
    2146             :                         {
    2147           0 :                             eKeyState = rKeyCode.GetModifier() & KEY_SHIFT ?
    2148           0 :                                                 KS_PrevObject : KS_NextObject;
    2149             :                         }
    2150             :                         else
    2151             :                             rSh.SelectNextPrevHyperlink(
    2152           0 :                                             KEY_SHIFT != rKeyCode.GetModifier() );
    2153           0 :                     break;
    2154             :                     case KEY_RETURN:
    2155             :                     {
    2156           0 :                         const int nSelectionType = rSh.GetSelectionType();
    2157           0 :                         if(nSelectionType & nsSelectionType::SEL_FRM)
    2158           0 :                             eKeyState = KS_GoIntoFly;
    2159             :                         else
    2160             :                         {
    2161           0 :                             SfxItemSet aSet(rSh.GetAttrPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
    2162           0 :                             rSh.GetCurAttr(aSet);
    2163           0 :                             if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, sal_False))
    2164             :                             {
    2165           0 :                                 const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, sal_True);
    2166           0 :                                 bNormalChar = sal_False;
    2167           0 :                                 eKeyState = KS_End;
    2168           0 :                                 rSh.ClickToINetAttr((const SwFmtINetFmt&)rItem, URLLOAD_NOFILTER);
    2169           0 :                             }
    2170             :                         }
    2171             :                     }
    2172           0 :                     break;
    2173             :                 }
    2174           0 :                 eAutoCompleteAction = ACA_NoOp;
    2175             :             }
    2176           0 :             break;
    2177             : 
    2178             :         case KS_EnterCharCell:
    2179             :             {
    2180           0 :                 eKeyState = KS_KeyToView;
    2181           0 :                 switch ( rKeyCode.GetModifier() | rKeyCode.GetCode() )
    2182             :                 {
    2183             :                     case KEY_RIGHT | KEY_MOD2:
    2184           0 :                         rSh.Right( CRSR_SKIP_CHARS, sal_False, 1, sal_False );
    2185           0 :                         eKeyState = KS_End;
    2186           0 :                         FlushInBuffer();
    2187           0 :                         break;
    2188             :                     case KEY_LEFT | KEY_MOD2:
    2189           0 :                         rSh.Left( CRSR_SKIP_CHARS, sal_False, 1, sal_False );
    2190           0 :                         eKeyState = KS_End;
    2191           0 :                         FlushInBuffer();
    2192           0 :                         break;
    2193             :                 }
    2194           0 :                 eAutoCompleteAction = ACA_NoOp;
    2195             :             }
    2196           0 :             break;
    2197             : 
    2198             :         case KS_KeyToView:
    2199             :             {
    2200           0 :                 eKeyState = KS_End;
    2201             :                 bNormalChar =
    2202           0 :                     !rKeyCode.IsMod2() &&
    2203           0 :                     rKeyCode.GetModifier() != (KEY_MOD1) &&
    2204           0 :                     rKeyCode.GetModifier() != (KEY_MOD1|KEY_SHIFT) &&
    2205           0 :                     SW_ISPRINTABLE( aCh );
    2206             : 
    2207           0 :                 if( bNormalChar && rSh.IsInFrontOfLabel() )
    2208             :                 {
    2209           0 :                     rSh.NumOrNoNum(sal_False);
    2210             :                 }
    2211             : 
    2212           0 :                 if( aInBuffer.Len() && ( !bNormalChar || bIsDocReadOnly ))
    2213           0 :                     FlushInBuffer();
    2214             : 
    2215           0 :                 if( rView.KeyInput( aKeyEvent ) )
    2216           0 :                     bFlushBuffer = sal_True, bNormalChar = sal_False;
    2217             :                 else
    2218             :                 {
    2219             :                     // Because Sfx accelerators are only called when they were
    2220             :                     // enabled at the last status update, copy has to called
    2221             :                     // 'forcefully' by us if necessary.
    2222           0 :                     if( rKeyCode.GetFunction() == KEYFUNC_COPY )
    2223           0 :                         GetView().GetViewFrame()->GetBindings().Execute(SID_COPY);
    2224             : 
    2225           0 :                     if( !bIsDocReadOnly && bNormalChar )
    2226             :                     {
    2227           0 :                         const int nSelectionType = rSh.GetSelectionType();
    2228           0 :                         if((nSelectionType & nsSelectionType::SEL_DRW) &&
    2229             :                             0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) &&
    2230           0 :                             rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1)
    2231             :                         {
    2232           0 :                             SdrObject* pObj = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
    2233           0 :                             if(pObj)
    2234             :                             {
    2235           0 :                                 EnterDrawTextMode(pObj->GetLogicRect().Center());
    2236           0 :                                 if ( rView.GetCurShell()->ISA(SwDrawTextShell) )
    2237           0 :                                     ((SwDrawTextShell*)rView.GetCurShell())->Init();
    2238           0 :                                 rSh.GetDrawView()->KeyInput( rKEvt, this );
    2239             :                             }
    2240             :                         }
    2241           0 :                         else if(nSelectionType & nsSelectionType::SEL_FRM)
    2242             :                         {
    2243           0 :                             rSh.UnSelectFrm();
    2244           0 :                             rSh.LeaveSelFrmMode();
    2245           0 :                             rView.AttrChangedNotify(&rSh);
    2246           0 :                             rSh.MoveSection( fnSectionCurr, fnSectionEnd );
    2247             :                         }
    2248           0 :                         eKeyState = KS_InsChar;
    2249             :                     }
    2250             :                     else
    2251             :                     {
    2252           0 :                         bNormalChar = sal_False;
    2253           0 :                         Window::KeyInput( aKeyEvent );
    2254             :                     }
    2255             :                 }
    2256           0 :                 if( bNormalChar )
    2257             :                 {
    2258           0 :                     if ( aCh == ' ' )
    2259             :                     {
    2260           0 :                         eAutoCompleteAction = ACA_ReturnToRoot;
    2261             :                     }
    2262             :                     else
    2263             :                     {
    2264           0 :                         eAutoCompleteAction = ACA_SingleCharInput;
    2265           0 :                         aSingleCharInput = aCh;
    2266             :                     }
    2267             :                 }
    2268             :             }
    2269           0 :             break;
    2270             :         case KS_LaunchOLEObject:
    2271             :         {
    2272           0 :             rSh.LaunchOLEObj();
    2273           0 :             eKeyState = KS_End;
    2274           0 :             eAutoCompleteAction = ACA_NoOp;
    2275             :         }
    2276           0 :         break;
    2277             :         case KS_GoIntoFly:
    2278             :         {
    2279           0 :             rSh.UnSelectFrm();
    2280           0 :             rSh.LeaveSelFrmMode();
    2281           0 :             rView.AttrChangedNotify(&rSh);
    2282           0 :             rSh.MoveSection( fnSectionCurr, fnSectionEnd );
    2283           0 :             eKeyState = KS_End;
    2284           0 :             eAutoCompleteAction = ACA_NoOp;
    2285             :         }
    2286           0 :         break;
    2287             :         case KS_GoIntoDrawing:
    2288             :         {
    2289           0 :             SdrObject* pObj = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
    2290           0 :             if(pObj)
    2291             :             {
    2292           0 :                 EnterDrawTextMode(pObj->GetLogicRect().Center());
    2293           0 :                 if ( rView.GetCurShell()->ISA(SwDrawTextShell) )
    2294           0 :                     ((SwDrawTextShell*)rView.GetCurShell())->Init();
    2295             :             }
    2296           0 :             eKeyState = KS_End;
    2297           0 :             eAutoCompleteAction = ACA_NoOp;
    2298             :         }
    2299           0 :         break;
    2300             :         case KS_EnterDrawHandleMode:
    2301             :         {
    2302           0 :             const SdrHdlList& rHdlList = rSh.GetDrawView()->GetHdlList();
    2303           0 :             sal_Bool bForward(!aKeyEvent.GetKeyCode().IsShift());
    2304             : 
    2305           0 :             ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
    2306           0 :             eKeyState = KS_End;
    2307           0 :             eAutoCompleteAction = ACA_NoOp;
    2308             :         }
    2309           0 :         break;
    2310             :         case KS_InsTab:
    2311           0 :             if( rView.ISA( SwWebView ))     // no Tab for WebView
    2312             :             {
    2313             :                 // then it should be passed along
    2314           0 :                 Window::KeyInput( aKeyEvent );
    2315           0 :                 eKeyState = KS_End;
    2316           0 :                 break;
    2317             :             }
    2318           0 :             aCh = '\t';
    2319           0 :             eAutoCompleteAction = ACA_ReturnToRoot;
    2320             :             // no break!
    2321             :         case KS_InsChar:
    2322           0 :             if (rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT)
    2323             :             {
    2324             :                 ::sw::mark::ICheckboxFieldmark* pFieldmark =
    2325             :                     dynamic_cast< ::sw::mark::ICheckboxFieldmark* >
    2326           0 :                         (rSh.GetCurrentFieldmark());
    2327             :                 OSL_ENSURE(pFieldmark,
    2328             :                     "Where is my FieldMark??");
    2329           0 :                 if(pFieldmark)
    2330             :                 {
    2331           0 :                     pFieldmark->SetChecked(!pFieldmark->IsChecked());
    2332           0 :                     SwDocShell* pDocSh = rView.GetDocShell();
    2333           0 :                     SwDoc *pDoc=pDocSh->GetDoc();
    2334             :                     OSL_ENSURE(pFieldmark->IsExpanded(),
    2335             :                         "where is the otherpos?");
    2336           0 :                     if (pFieldmark->IsExpanded())
    2337             :                     {
    2338           0 :                         SwPaM aPaM(pFieldmark->GetMarkPos(), pFieldmark->GetOtherMarkPos());
    2339             :                         if(0)
    2340             :                         {
    2341             :                             rSh.StartAllAction();  //$flr TODO: understand why this not works
    2342             :                             pDoc->SetModified(aPaM);
    2343             :                             rSh.EndAllAction();
    2344             :                         }
    2345             :                         else
    2346             :                         {
    2347           0 :                             rSh.CalcLayout(); // workaround
    2348           0 :                         }
    2349             :                     }
    2350             :                 }
    2351           0 :                 eKeyState = KS_End;
    2352             :             }
    2353           0 :             else if(!rSh.HasReadonlySel())
    2354             :             {
    2355           0 :                 sal_Bool bIsNormalChar = GetAppCharClass().isLetterNumeric(
    2356           0 :                                                             rtl::OUString( aCh ), 0 );
    2357           0 :                 if( bAppendSpace && bIsNormalChar &&
    2358           0 :                     (aInBuffer.Len() || !rSh.IsSttPara() || !rSh.IsEndPara() ))
    2359             :                 {
    2360             :                     // insert a blank ahead of the character. this ends up
    2361             :                     // between the expanded text and the new "non-word-seperator".
    2362           0 :                     aInBuffer += ' ';
    2363             :                 }
    2364             : 
    2365           0 :                 sal_Bool bIsAutoCorrectChar =  SvxAutoCorrect::IsAutoCorrectChar( aCh );
    2366           0 :                 sal_Bool bRunNext = pACorr && pACorr->HasRunNext();
    2367           0 :                 if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || bRunNext ) &&
    2368           0 :                         pACfg->IsAutoFmtByInput() &&
    2369           0 :                     (( pACorr->IsAutoCorrFlag( ChgWeightUnderl ) &&
    2370             :                         ( '*' == aCh || '_' == aCh ) ) ||
    2371           0 :                      ( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))||
    2372           0 :                      ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh))))
    2373             :                 {
    2374           0 :                     FlushInBuffer();
    2375           0 :                     rSh.AutoCorrect( *pACorr, aCh );
    2376           0 :                     if( '\"' != aCh && '\'' != aCh )        // only call when "*_"!
    2377           0 :                         rSh.UpdateAttr();
    2378             :                 }
    2379           0 :                 else if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || bRunNext ) &&
    2380           0 :                         pACfg->IsAutoFmtByInput() &&
    2381             :                     pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
    2382             :                                             ChgOrdinalNumber | AddNonBrkSpace |
    2383             :                                             ChgToEnEmDash | SetINetAttr |
    2384           0 :                                             Autocorrect ) &&
    2385             :                     '\"' != aCh && '\'' != aCh && '*' != aCh && '_' != aCh
    2386             :                     )
    2387             :                 {
    2388           0 :                     FlushInBuffer();
    2389           0 :                     rSh.AutoCorrect( *pACorr, aCh );
    2390             :                 }
    2391             :                 else
    2392             :                 {
    2393           0 :                     rtl::OUStringBuffer aBuf(aInBuffer);
    2394             :                     comphelper::string::padToLength(aBuf,
    2395           0 :                         aInBuffer.Len() + aKeyEvent.GetRepeat() + 1, aCh);
    2396           0 :                     aInBuffer = aBuf.makeStringAndClear();
    2397           0 :                     bFlushCharBuffer = Application::AnyInput( VCL_INPUT_KEYBOARD );
    2398           0 :                     bFlushBuffer = !bFlushCharBuffer;
    2399           0 :                     if( bFlushCharBuffer )
    2400           0 :                         aKeyInputFlushTimer.Start();
    2401             :                 }
    2402           0 :                 eKeyState = KS_End;
    2403             :             }
    2404             :             else
    2405             :             {
    2406           0 :                 InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute();
    2407           0 :                 eKeyState = KS_End;
    2408             :             }
    2409           0 :         break;
    2410             : 
    2411             :         case KS_CheckAutoCorrect:
    2412             :         {
    2413           0 :             if( pACorr && pACfg->IsAutoFmtByInput() &&
    2414             :                 pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
    2415             :                                         ChgOrdinalNumber |
    2416             :                                         ChgToEnEmDash | SetINetAttr |
    2417           0 :                                         Autocorrect ) &&
    2418           0 :                 !rSh.HasReadonlySel() )
    2419             :             {
    2420           0 :                 FlushInBuffer();
    2421           0 :                 rSh.AutoCorrect( *pACorr, static_cast< sal_Unicode >('\0') );
    2422             :             }
    2423           0 :             eKeyState = eNextKeyState;
    2424           0 :             if ( eAutoCompleteAction == ACA_Refresh )
    2425           0 :                 eAutoCompleteAction = ACA_NoOp;
    2426             :         }
    2427           0 :         break;
    2428             : 
    2429             :         default:
    2430             :         {
    2431           0 :             sal_uInt16 nSlotId = 0;
    2432           0 :             FlushInBuffer();
    2433           0 :             switch( eKeyState )
    2434             :             {
    2435             :             case KS_SpecialInsert:
    2436           0 :                 rSh.DoSpecialInsert();
    2437           0 :                 break;
    2438             : 
    2439             :             case KS_NoNum:
    2440           0 :                 rSh.NoNum();
    2441           0 :                 break;
    2442             : 
    2443             :             case KS_NumOff:
    2444             :                 // shell change - so record in advance
    2445           0 :                 rSh.DelNumRules();
    2446           0 :                 eKeyState = eNextKeyState;
    2447           0 :                 break;
    2448             :             case KS_OutlineLvOff: // delete autofmt outlinelevel later
    2449           0 :                 break;
    2450             : 
    2451             :             case KS_NumDown:
    2452           0 :                 rSh.NumUpDown( true );
    2453           0 :                 nKS_NUMDOWN_Count = 2;
    2454           0 :                 break;
    2455             :             case KS_NumUp:
    2456           0 :                 rSh.NumUpDown( false );
    2457           0 :                 break;
    2458             : 
    2459             :             case KS_NumIndentInc:
    2460           0 :                 rSh.ChangeIndentOfAllListLevels(360);
    2461           0 :                 nKS_NUMINDENTINC_Count = 2;
    2462           0 :                 break;
    2463             : 
    2464             :             case KS_GotoNextFieldMark:
    2465             :                 {
    2466           0 :                     ::sw::mark::IFieldmark const * const pFieldmark = rSh.GetFieldmarkAfter();
    2467           0 :                     if(pFieldmark) rSh.GotoFieldmark(pFieldmark);
    2468             :                 }
    2469           0 :                 break;
    2470             : 
    2471             :             case KS_GotoPrevFieldMark:
    2472             :                 {
    2473           0 :                     ::sw::mark::IFieldmark const * const pFieldmark = rSh.GetFieldmarkBefore();
    2474           0 :                     if( pFieldmark )
    2475           0 :                         rSh.GotoFieldmark(pFieldmark);
    2476             :                 }
    2477           0 :                 break;
    2478             : 
    2479             :             case KS_NumIndentDec:
    2480           0 :                 rSh.ChangeIndentOfAllListLevels(-360);
    2481           0 :                 break;
    2482             : 
    2483             :             case KS_OutlineDown:
    2484           0 :                 rSh.OutlineUpDown( 1 );
    2485           0 :                 break;
    2486             :             case KS_OutlineUp:
    2487           0 :                 rSh.OutlineUpDown( -1 );
    2488           0 :                 break;
    2489             : 
    2490             :             case KS_NextCell:
    2491             :                 // always 'flush' in tables
    2492           0 :                 rSh.GoNextCell();
    2493           0 :                 nSlotId = FN_GOTO_NEXT_CELL;
    2494           0 :                 break;
    2495             :             case KS_PrevCell:
    2496           0 :                 rSh.GoPrevCell();
    2497           0 :                 nSlotId = FN_GOTO_PREV_CELL;
    2498           0 :                 break;
    2499             :             case KS_AutoFmtByInput:
    2500           0 :                 rSh.SplitNode( sal_True );
    2501           0 :                 break;
    2502             : 
    2503             :             case KS_NextObject:
    2504             :             case KS_PrevObject:
    2505           0 :                 if(rSh.GotoObj( KS_NextObject == eKeyState, GOTOOBJ_GOTO_ANY))
    2506             :                 {
    2507           0 :                     if( rSh.IsFrmSelected() &&
    2508           0 :                         rView.GetDrawFuncPtr() )
    2509             :                     {
    2510           0 :                         rView.GetDrawFuncPtr()->Deactivate();
    2511           0 :                         rView.SetDrawFuncPtr(NULL);
    2512           0 :                         rView.LeaveDrawCreate();
    2513           0 :                         rView.AttrChangedNotify( &rSh );
    2514             :                     }
    2515           0 :                     rSh.HideCrsr();
    2516           0 :                     rSh.EnterSelFrmMode();
    2517             :                 }
    2518           0 :             break;
    2519             :             case KS_GlossaryExpand:
    2520             :             {
    2521             :                 // replace the word or abbreviation with the auto text
    2522           0 :                 rSh.StartUndo( UNDO_START );
    2523             : 
    2524           0 :                 String sFnd( aTmpQHD.m_aHelpStrings[ aTmpQHD.nCurArrPos ] );
    2525           0 :                 if( aTmpQHD.m_bIsAutoText )
    2526             :                 {
    2527           0 :                     SwGlossaryList* pList = ::GetGlossaryList();
    2528           0 :                     String sShrtNm;
    2529           0 :                     String sGroup;
    2530           0 :                     if(pList->GetShortName( sFnd, sShrtNm, sGroup))
    2531             :                     {
    2532           0 :                         rSh.SttSelect();
    2533           0 :                         rSh.ExtendSelection( sal_False, aTmpQHD.nLen );
    2534           0 :                         SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl();
    2535           0 :                         pGlosHdl->SetCurGroup(sGroup, sal_True);
    2536           0 :                         pGlosHdl->InsertGlossary( sShrtNm);
    2537           0 :                         pQuickHlpData->m_bAppendSpace = true;
    2538           0 :                     }
    2539             :                 }
    2540             :                 else
    2541             :                 {
    2542           0 :                     rSh.Insert( sFnd.Erase( 0, aTmpQHD.nLen ));
    2543             :                     pQuickHlpData->m_bAppendSpace = !pACorr ||
    2544           0 :                             pACorr->GetSwFlags().bAutoCmpltAppendBlanc;
    2545             :                 }
    2546           0 :                 rSh.EndUndo( UNDO_END );
    2547           0 :                 eAutoCompleteAction = ACA_ReturnToRoot;
    2548             :             }
    2549           0 :             break;
    2550             : 
    2551             :             case KS_NextPrevGlossary:
    2552           0 :                 pQuickHlpData->Move( aTmpQHD );
    2553           0 :                 pQuickHlpData->Start( rSh, USHRT_MAX );
    2554           0 :                 break;
    2555             : 
    2556             :             case KS_EditFormula:
    2557             :             {
    2558           0 :                 const sal_uInt16 nId = SwInputChild::GetChildWindowId();
    2559             : 
    2560           0 :                 SfxViewFrame* pVFrame = GetView().GetViewFrame();
    2561           0 :                 pVFrame->ToggleChildWindow( nId );
    2562             :                 SwInputChild* pChildWin = (SwInputChild*)pVFrame->
    2563           0 :                                                     GetChildWindow( nId );
    2564           0 :                 if( pChildWin )
    2565           0 :                     pChildWin->SetFormula( sFmlEntry );
    2566             :             }
    2567           0 :             break;
    2568             : 
    2569           0 :             case KS_ColLeftBig:         rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() );   break;
    2570           0 :             case KS_ColRightBig:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() );  break;
    2571           0 :             case KS_ColLeftSmall:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_LEFT, pModOpt->GetTblHMove() );   break;
    2572           0 :             case KS_ColRightSmall:      rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_RIGHT, pModOpt->GetTblHMove() );  break;
    2573           0 :             case KS_ColBottomBig:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break;
    2574           0 :             case KS_ColBottomSmall:     rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_BOTTOM, pModOpt->GetTblVMove() ); break;
    2575           0 :             case KS_CellLeftBig:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() );  break;
    2576           0 :             case KS_CellRightBig:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break;
    2577           0 :             case KS_CellLeftSmall:      rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_LEFT, pModOpt->GetTblHMove() );  break;
    2578           0 :             case KS_CellRightSmall:     rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_RIGHT, pModOpt->GetTblHMove() ); break;
    2579           0 :             case KS_CellTopBig:         rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() );   break;
    2580           0 :             case KS_CellBottomBig:      rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() );    break;
    2581           0 :             case KS_CellTopSmall:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_TOP, pModOpt->GetTblVMove() );   break;
    2582           0 :             case KS_CellBottomSmall:    rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_BOTTOM, pModOpt->GetTblVMove() );    break;
    2583             : 
    2584             : //---------------
    2585           0 :             case KS_InsDel_ColLeftBig:          rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break;
    2586           0 :             case KS_InsDel_ColRightBig:         rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() );    break;
    2587           0 :             case KS_InsDel_ColLeftSmall:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_LEFT, pModOpt->GetTblHInsert() ); break;
    2588           0 :             case KS_InsDel_ColRightSmall:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_RIGHT, pModOpt->GetTblHInsert() );    break;
    2589           0 :             case KS_InsDel_ColTopBig:           rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() );  break;
    2590           0 :             case KS_InsDel_ColBottomBig:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() );   break;
    2591           0 :             case KS_InsDel_ColTopSmall:         rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_TOP, pModOpt->GetTblVInsert() );  break;
    2592           0 :             case KS_InsDel_ColBottomSmall:      rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_BOTTOM, pModOpt->GetTblVInsert() );   break;
    2593           0 :             case KS_InsDel_CellLeftBig:         rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() );    break;
    2594           0 :             case KS_InsDel_CellRightBig:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() );   break;
    2595           0 :             case KS_InsDel_CellLeftSmall:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_LEFT, pModOpt->GetTblHInsert() );    break;
    2596           0 :             case KS_InsDel_CellRightSmall:      rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_RIGHT, pModOpt->GetTblHInsert() );   break;
    2597           0 :             case KS_InsDel_CellTopBig:          rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break;
    2598           0 :             case KS_InsDel_CellBottomBig:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() );  break;
    2599           0 :             case KS_InsDel_CellTopSmall:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_TOP, pModOpt->GetTblVInsert() ); break;
    2600           0 :             case KS_InsDel_CellBottomSmall:     rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_BOTTOM, pModOpt->GetTblVInsert() );  break;
    2601             : //---------------
    2602             :             case KS_TblColCellInsDel:
    2603           0 :                 rSh.SetColRowWidthHeight( eTblChgMode, nTblChgSize );
    2604           0 :                 break;
    2605             :             case KS_Fly_Change:
    2606             :             {
    2607           0 :                 SdrView *pSdrView = rSh.GetDrawView();
    2608           0 :                 const SdrHdlList& rHdlList = pSdrView->GetHdlList();
    2609           0 :                 if(rHdlList.GetFocusHdl())
    2610           0 :                     ChangeDrawing( nDir );
    2611             :                 else
    2612           0 :                     ChangeFly( nDir, rView.ISA( SwWebView ) );
    2613             :             }
    2614           0 :             break;
    2615             :             case KS_Draw_Change :
    2616           0 :                 ChangeDrawing( nDir );
    2617           0 :                 break;
    2618             :             default:
    2619           0 :                 break;
    2620             :             }
    2621           0 :             if( nSlotId && rView.GetViewFrame()->GetBindings().GetRecorder().is() )
    2622             :             {
    2623           0 :                 SfxRequest aReq(rView.GetViewFrame(), nSlotId );
    2624           0 :                 aReq.Done();
    2625             :             }
    2626           0 :             eKeyState = KS_End;
    2627             :         }
    2628             :         }
    2629             :     }
    2630             : 
    2631           0 :     if( bStopKeyInputTimer )
    2632             :     {
    2633           0 :         aKeyInputTimer.Stop();
    2634           0 :         bTblInsDelMode = sal_False;
    2635             :     }
    2636             : 
    2637           0 :     bool bInsertBufferedChars = bFlushBuffer && aInBuffer.Len();
    2638           0 :     bool bAutoCompleteEnabled = pACfg && pACorr && ( pACfg->IsAutoTextTip() || pACorr->GetSwFlags().bAutoCompleteWords );
    2639           0 :     bool bGotWord = false;
    2640           0 :     String sPrefix;
    2641             : 
    2642             :     // in case the buffered characters are inserted
    2643           0 :     if( bInsertBufferedChars )
    2644             :     {
    2645             :         // bFlushCharBuffer was not resetted here
    2646             :         // why not?
    2647           0 :         sal_Bool bSave = bFlushCharBuffer;
    2648           0 :         FlushInBuffer();
    2649           0 :         bFlushCharBuffer = bSave;
    2650             :     }
    2651             : 
    2652             :     // maintain AutoComplete tree
    2653           0 :     if( bAutoCompleteEnabled )
    2654             :     {
    2655             :         // avoid unnecessary calls to GetPrevAutoCorrWord
    2656           0 :         if( (bInsertBufferedChars && bNormalChar) || eAutoCompleteAction == ACA_Refresh )
    2657             :         {
    2658           0 :             bGotWord = rSh.GetPrevAutoCorrWord( *pACorr, sPrefix );
    2659             :         }
    2660             : 
    2661           0 :         SwAutoCompleteWord& rACList = rSh.GetAutoCompleteWords();
    2662             : 
    2663           0 :         switch( eAutoCompleteAction )
    2664             :         {
    2665             :             case ACA_NoOp:
    2666             :                 // do nothing
    2667           0 :             break;
    2668             : 
    2669             :             case ACA_ReturnToRoot:
    2670           0 :                 rACList.returnToRoot();
    2671           0 :             break;
    2672             : 
    2673             :             case ACA_SingleCharInput:
    2674           0 :                 rACList.advance( aSingleCharInput );
    2675           0 :             break;
    2676             : 
    2677             :             case ACA_SingleBackspace:
    2678           0 :                 rACList.goBack();
    2679           0 :             break;
    2680             : 
    2681             :             case ACA_Refresh:
    2682             :             {
    2683           0 :                 if( sPrefix.Len() > 0 )
    2684           0 :                     rACList.gotoNode( sPrefix );
    2685             :                 else
    2686           0 :                     rACList.returnToRoot();
    2687             :             }
    2688           0 :             break;
    2689             :         }
    2690             :     }
    2691             : 
    2692           0 :     if( bInsertBufferedChars && bNormalChar && bAutoCompleteEnabled && bGotWord )
    2693             :     {
    2694           0 :         ShowAutoTextCorrectQuickHelp( sPrefix, pACfg, pACorr );
    2695             :     }
    2696             : 
    2697             :     // get the word count dialog to update itself
    2698           0 :     SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
    2699           0 :     if( pWrdCnt )
    2700           0 :         pWrdCnt->UpdateCounts();
    2701             : 
    2702             : }
    2703             : 
    2704             : /*--------------------------------------------------------------------
    2705             :      Description:  MouseEvents
    2706             :  --------------------------------------------------------------------*/
    2707             : 
    2708           0 : void SwEditWin::RstMBDownFlags()
    2709             : {
    2710             :     // Not on all systems a MouseButtonUp is used ahead
    2711             :     // of the modal dialog (like on WINDOWS).
    2712             :     // So reset the statuses here and release the mouse
    2713             :     // for the dialog.
    2714           0 :     bMBPressed = bNoInterrupt = sal_False;
    2715           0 :     EnterArea();
    2716           0 :     ReleaseMouse();
    2717           0 : }
    2718             : 
    2719             : /**
    2720             :  * Determines if the current position has a clickable url over a background
    2721             :  * frame. In that case, ctrl-click should select the url, not the frame.
    2722             :  */
    2723           0 : static bool lcl_urlOverBackground(SwWrtShell& rSh, const Point& rDocPos)
    2724             : {
    2725           0 :     SwContentAtPos aSwContentAtPos(SwContentAtPos::SW_INETATTR);
    2726           0 :     SdrObject* pSelectableObj = rSh.GetObjAt(rDocPos);
    2727             : 
    2728           0 :     return rSh.GetContentAtPos(rDocPos, aSwContentAtPos) && pSelectableObj->GetLayer() == rSh.GetDoc()->GetHellId();
    2729             : }
    2730             : 
    2731           0 : void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
    2732             : {
    2733           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    2734             : 
    2735             :     // We have to check if a context menu is shown and we have an UI
    2736             :     // active inplace client. In that case we have to ignore the mouse
    2737             :     // button down event. Otherwise we would crash (context menu has been
    2738             :     // opened by inplace client and we would deactivate the inplace client,
    2739             :     // the contex menu is closed by VCL asynchronously which in the end
    2740             :     // would work on deleted objects or the context menu has no parent anymore)
    2741           0 :     SfxInPlaceClient* pIPClient = rSh.GetSfxViewShell()->GetIPClient();
    2742           0 :     sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
    2743             : 
    2744           0 :     if ( bIsOleActive && PopupMenu::IsInExecute() )
    2745             :         return;
    2746             : 
    2747           0 :     MouseEvent rMEvt(_rMEvt);
    2748             : 
    2749           0 :     if (rView.GetPostItMgr()->IsHit(rMEvt.GetPosPixel()))
    2750             :         return;
    2751             : 
    2752           0 :     rView.GetPostItMgr()->SetActiveSidebarWin(0);
    2753             : 
    2754           0 :     GrabFocus();
    2755             : 
    2756             :     //ignore key modifiers for format paintbrush
    2757             :     {
    2758             :         sal_Bool bExecFormatPaintbrush = pApplyTempl && pApplyTempl->pFormatClipboard
    2759           0 :                                 &&  pApplyTempl->pFormatClipboard->HasContent();
    2760           0 :         if( bExecFormatPaintbrush )
    2761           0 :             rMEvt = MouseEvent( _rMEvt.GetPosPixel(), _rMEvt.GetClicks(),
    2762           0 :                                     _rMEvt.GetMode(), _rMEvt.GetButtons() );
    2763             :     }
    2764             : 
    2765           0 :     bWasShdwCrsr = 0 != pShadCrsr;
    2766           0 :     delete pShadCrsr, pShadCrsr = 0;
    2767             : 
    2768           0 :     const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) );
    2769             : 
    2770             :     // How many clicks do we need to select a fly frame?
    2771             :     FrameControlType eControl;
    2772           0 :     bool bOverFly = false;
    2773           0 :     bool bPageAnchored = false;
    2774           0 :     bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly, bPageAnchored );
    2775           0 :     int nNbFlyClicks = 1;
    2776             :     // !bOverHeaderFooterFly doesn't mean we have a frame to select
    2777           0 :     if ( !bPageAnchored && ( ( rSh.IsHeaderFooterEdit( ) && !bOverHeaderFooterFly && bOverFly ) ||
    2778           0 :          ( !rSh.IsHeaderFooterEdit( ) && bOverHeaderFooterFly ) ) )
    2779             :     {
    2780           0 :         nNbFlyClicks = 2;
    2781           0 :         if ( _rMEvt.GetClicks( ) < nNbFlyClicks )
    2782             :             return;
    2783             :     }
    2784             : 
    2785             :     // Are we clicking on a blank header/footer area?
    2786           0 :     if ( IsInHeaderFooter( aDocPos, eControl ) || bOverHeaderFooterFly )
    2787             :     {
    2788           0 :         const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( aDocPos );
    2789             : 
    2790             :         // Is it active?
    2791           0 :         bool bActive = true;
    2792           0 :         const SwPageDesc* pDesc = pPageFrm->GetPageDesc();
    2793             : 
    2794           0 :         const SwFrmFmt* pFmt = pDesc->GetLeftFmt();
    2795           0 :         if ( pPageFrm->OnRightPage() )
    2796           0 :              pFmt = pDesc->GetRightFmt();
    2797             : 
    2798           0 :         if ( pFmt )
    2799             :         {
    2800           0 :             if ( eControl == Header )
    2801           0 :                 bActive = pFmt->GetHeader().IsActive();
    2802             :             else
    2803           0 :                 bActive = pFmt->GetFooter().IsActive();
    2804             :         }
    2805             : 
    2806           0 :         if ( !bActive )
    2807             :         {
    2808           0 :             SwPaM aPam( *rSh.GetCurrentShellCursor().GetPoint() );
    2809           0 :             bool bWasInHeader = aPam.GetPoint( )->nNode.GetNode( ).FindHeaderStartNode( ) != NULL;
    2810           0 :             bool bWasInFooter = aPam.GetPoint( )->nNode.GetNode( ).FindFooterStartNode( ) != NULL;
    2811             : 
    2812             :             // Is the cursor in a part like similar to the one we clicked on? For example,
    2813             :             // if the cursor is in a header and we click on an empty header... don't change anything to
    2814             :             // keep consistent behaviour due to header edit mode (and the same for the footer as well).
    2815             :             //
    2816             :             // Otherwise, we hide the header/footer control if a separator is shown, and vice versa.
    2817           0 :             if ( !( bWasInHeader && eControl == Header ) &&
    2818           0 :                  !( bWasInFooter && eControl == Footer ) )
    2819             :             {
    2820           0 :                 rSh.SetShowHeaderFooterSeparator( eControl, !rSh.IsShowHeaderFooterSeparator( eControl ) );
    2821             :             }
    2822             : 
    2823             :             // Repaint everything
    2824           0 :             Invalidate();
    2825             :         }
    2826             :         else
    2827             :         {
    2828             :             // Make sure we have the proper Header/Footer separators shown
    2829             :             // as these may be changed if clicking on an empty Header/Footer
    2830           0 :             rSh.SetShowHeaderFooterSeparator( Header, eControl == Header );
    2831           0 :             rSh.SetShowHeaderFooterSeparator( Footer, eControl == Footer );
    2832             : 
    2833           0 :             if ( !rSh.IsHeaderFooterEdit() )
    2834           0 :                 rSh.ToggleHeaderFooterEdit();
    2835             : 
    2836             :             // Repaint everything
    2837           0 :             rSh.GetWin()->Invalidate();
    2838             :         }
    2839             :     }
    2840             :     else
    2841             :     {
    2842           0 :         if ( rSh.IsHeaderFooterEdit( ) )
    2843           0 :             rSh.ToggleHeaderFooterEdit( );
    2844             :         else
    2845             :         {
    2846             :             // Make sure that the separators are hidden
    2847           0 :             rSh.SetShowHeaderFooterSeparator( Header, false );
    2848           0 :             rSh.SetShowHeaderFooterSeparator( Footer, false );
    2849             : 
    2850             :             // Repaint everything
    2851           0 :             rSh.GetWin()->Invalidate();
    2852             :         }
    2853             :     }
    2854             : 
    2855             : 
    2856           0 :     if ( IsChainMode() )
    2857             :     {
    2858           0 :         SetChainMode( sal_False );
    2859           0 :         SwRect aDummy;
    2860           0 :         SwFlyFrmFmt *pFmt = (SwFlyFrmFmt*)rSh.GetFlyFrmFmt();
    2861           0 :         if ( !rSh.Chainable( aDummy, *pFmt, aDocPos ) )
    2862           0 :             rSh.Chain( *pFmt, aDocPos );
    2863           0 :         UpdatePointer( aDocPos, rMEvt.GetModifier() );
    2864             :         return;
    2865             :     }
    2866             : 
    2867             :     // After GrabFocus a shell should be pushed. That should actually
    2868             :     // work but in practice ...
    2869           0 :     rView.SelectShellForDrop();
    2870             : 
    2871           0 :     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly();
    2872           0 :     sal_Bool bCallBase = sal_True;
    2873             : 
    2874           0 :     if( pQuickHlpData->m_bIsDisplayed )
    2875           0 :         pQuickHlpData->Stop( rSh );
    2876           0 :     pQuickHlpData->m_bAppendSpace = false;
    2877             : 
    2878           0 :     if( rSh.FinishOLEObj() )
    2879             :         return; // end InPlace and the click doesn't count anymore
    2880             : 
    2881           0 :     SET_CURR_SHELL( &rSh );
    2882             : 
    2883           0 :     SdrView *pSdrView = rSh.GetDrawView();
    2884           0 :     if ( pSdrView )
    2885             :     {
    2886           0 :         if (pSdrView->MouseButtonDown( rMEvt, this ) )
    2887             :         {
    2888           0 :             rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
    2889             :             return; // SdrView's event evaluated
    2890             :         }
    2891             :     }
    2892             : 
    2893           0 :     bIsInMove = sal_False;
    2894           0 :     aStartPos = rMEvt.GetPosPixel();
    2895           0 :     aRszMvHdlPt.X() = 0, aRszMvHdlPt.Y() = 0;
    2896             : 
    2897           0 :     sal_uInt8 nMouseTabCol = 0;
    2898           0 :     const sal_Bool bTmp = !rSh.IsDrawCreate() && !pApplyTempl && !rSh.IsInSelect() &&
    2899           0 :          rMEvt.GetClicks() == 1 && MOUSE_LEFT == rMEvt.GetButtons();
    2900           0 :     if (  bTmp &&
    2901           0 :          0 != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPos ) ) &&
    2902           0 :          !rSh.IsObjSelectable( aDocPos ) )
    2903             :     {
    2904           0 :         if ( SW_TABSEL_HORI <= nMouseTabCol && SW_TABCOLSEL_VERT >= nMouseTabCol )
    2905             :         {
    2906           0 :             rSh.EnterStdMode();
    2907           0 :             rSh.SelectTableRowCol( aDocPos );
    2908           0 :             if( SW_TABSEL_HORI  != nMouseTabCol && SW_TABSEL_HORI_RTL  != nMouseTabCol)
    2909             :             {
    2910           0 :                 pRowColumnSelectionStart = new Point( aDocPos );
    2911             :                 bIsRowDrag = SW_TABROWSEL_HORI == nMouseTabCol||
    2912             :                             SW_TABROWSEL_HORI_RTL == nMouseTabCol ||
    2913           0 :                             SW_TABCOLSEL_VERT == nMouseTabCol;
    2914           0 :                 bMBPressed = sal_True;
    2915           0 :                 CaptureMouse();
    2916             :             }
    2917             :             return;
    2918             :         }
    2919             : 
    2920           0 :         if ( !rSh.IsTableMode() )
    2921             :         {
    2922             :             // comes from table columns out of the document.
    2923           0 :             if(SW_TABCOL_VERT == nMouseTabCol || SW_TABCOL_HORI == nMouseTabCol)
    2924           0 :                 rView.SetTabColFromDoc( sal_True );
    2925             :             else
    2926           0 :                 rView.SetTabRowFromDoc( sal_True );
    2927             : 
    2928           0 :             rView.SetTabColFromDocPos( aDocPos );
    2929           0 :             rView.InvalidateRulerPos();
    2930           0 :             SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
    2931           0 :             rBind.Update();
    2932           0 :             if ( RulerColumnDrag( rMEvt,
    2933           0 :                     (SW_TABCOL_VERT == nMouseTabCol || SW_TABROW_HORI == nMouseTabCol)) )
    2934             :             {
    2935           0 :                 rView.SetTabColFromDoc( sal_False );
    2936           0 :                 rView.SetTabRowFromDoc( sal_False );
    2937           0 :                 rView.InvalidateRulerPos();
    2938           0 :                 rBind.Update();
    2939           0 :                 bCallBase = sal_False;
    2940             :             }
    2941             :             else
    2942             :             {
    2943             :                 return;
    2944             :             }
    2945             :         }
    2946             :     }
    2947           0 :     else if (bTmp &&
    2948           0 :              rSh.IsNumLabel(aDocPos))
    2949             :     {
    2950           0 :         SwTxtNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPos );
    2951           0 :         rView.SetNumRuleNodeFromDoc( pNodeAtPos );
    2952           0 :         rView.InvalidateRulerPos();
    2953           0 :         SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
    2954           0 :         rBind.Update();
    2955             : 
    2956           0 :         if ( RulerMarginDrag( rMEvt,
    2957           0 :                         rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPos ) ) )
    2958             :         {
    2959           0 :             rView.SetNumRuleNodeFromDoc( NULL );
    2960           0 :             rView.InvalidateRulerPos();
    2961           0 :             rBind.Update();
    2962           0 :             bCallBase = sal_False;
    2963             :         }
    2964             :         else
    2965             :         {
    2966             :             // Make sure the pointer is set to 0,
    2967             :             // otherwise it may point to nowhere after deleting the corresponding
    2968             :             // text node.
    2969           0 :             rView.SetNumRuleNodeFromDoc( NULL );
    2970             :             return;
    2971             :         }
    2972             :     }
    2973             : 
    2974             :     // One can be in a selection state when recently the keyboard was
    2975             :     // used to select but no CURSOR_KEY was moved yet after that. In
    2976             :     // that case the previous selction has to be finished first.
    2977             :     // MA 07. Oct. 95: Not only with left mouse button but always.
    2978             :     // also see Bug: 19263
    2979           0 :     if ( rSh.IsInSelect() )
    2980           0 :         rSh.EndSelect();
    2981             : 
    2982             :     // query against LEFT because otherwise for example also a right
    2983             :     // click releases the selection.
    2984           0 :     if ( MOUSE_LEFT == rMEvt.GetButtons() )
    2985             :     {
    2986           0 :         sal_Bool bOnlyText = sal_False;
    2987           0 :         bMBPressed = bNoInterrupt = sal_True;
    2988           0 :         nKS_NUMDOWN_Count = 0;
    2989             : 
    2990           0 :         CaptureMouse();
    2991             : 
    2992             :         // reset curor position if applicable
    2993           0 :         rSh.ResetCursorStack();
    2994             : 
    2995           0 :         switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
    2996             :         {
    2997             :             case MOUSE_LEFT:
    2998             :             case MOUSE_LEFT + KEY_SHIFT:
    2999             :             case MOUSE_LEFT + KEY_MOD2:
    3000           0 :                 if( rSh.IsObjSelected() )
    3001             :                 {
    3002             :                     SdrHdl* pHdl;
    3003           0 :                     if( !bIsDocReadOnly &&
    3004           0 :                         !pAnchorMarker &&
    3005           0 :                         0 != ( pHdl = pSdrView->PickHandle(aDocPos) ) &&
    3006           0 :                             ( pHdl->GetKind() == HDL_ANCHOR ||
    3007           0 :                               pHdl->GetKind() == HDL_ANCHOR_TR ) )
    3008             :                     {
    3009           0 :                         pAnchorMarker = new SwAnchorMarker( pHdl );
    3010           0 :                         UpdatePointer( aDocPos, rMEvt.GetModifier() );
    3011             :                         return;
    3012             :                     }
    3013             :                 }
    3014           0 :                 if ( EnterDrawMode( rMEvt, aDocPos ) )
    3015             :                 {
    3016           0 :                     bNoInterrupt = sal_False;
    3017             :                     return;
    3018             :                 }
    3019           0 :                 else  if ( rView.GetDrawFuncPtr() && bInsFrm )
    3020             :                 {
    3021           0 :                     StopInsFrm();
    3022           0 :                     rSh.Edit();
    3023             :                 }
    3024             : 
    3025             :                 // Without SHIFT because otherwise Toggle doesn't work at selection
    3026           0 :                 if (rMEvt.GetClicks() == 1)
    3027             :                 {
    3028           0 :                     if ( rSh.IsSelFrmMode())
    3029             :                     {
    3030           0 :                         SdrHdl* pHdl = rSh.GetDrawView()->PickHandle(aDocPos);
    3031           0 :                         sal_Bool bHitHandle = pHdl && pHdl->GetKind() != HDL_ANCHOR &&
    3032           0 :                                                   pHdl->GetKind() != HDL_ANCHOR_TR;
    3033             : 
    3034           0 :                         if ((rSh.IsInsideSelectedObj(aDocPos) || bHitHandle) &&
    3035           0 :                             !(rMEvt.GetModifier() == KEY_SHIFT && !bHitHandle))
    3036             :                         {
    3037           0 :                             rSh.EnterSelFrmMode( &aDocPos );
    3038           0 :                             if ( !pApplyTempl )
    3039             :                             {
    3040             :                                 // only if no position to size was hit.
    3041           0 :                                 if (!bHitHandle)
    3042             :                                 {
    3043           0 :                                     StartDDTimer();
    3044           0 :                                     SwEditWin::nDDStartPosY = aDocPos.Y();
    3045           0 :                                     SwEditWin::nDDStartPosX = aDocPos.X();
    3046             :                                 }
    3047           0 :                                 bFrmDrag = sal_True;
    3048             :                             }
    3049           0 :                             bNoInterrupt = sal_False;
    3050             :                             return;
    3051             :                         }
    3052             :                     }
    3053             :                 }
    3054             :         }
    3055             : 
    3056           0 :         sal_Bool bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
    3057           0 :         if ( !bExecHyperlinks )
    3058             :         {
    3059           0 :             SvtSecurityOptions aSecOpts;
    3060           0 :             const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
    3061           0 :             if ( (  bSecureOption && rMEvt.GetModifier() == KEY_MOD1 ) ||
    3062           0 :                  ( !bSecureOption && rMEvt.GetModifier() != KEY_MOD1 ) )
    3063           0 :                 bExecHyperlinks = sal_True;
    3064             :         }
    3065             : 
    3066           0 :         sal_uInt8 nNumberOfClicks = static_cast< sal_uInt8 >(rMEvt.GetClicks() % 4);
    3067           0 :         if ( 0 == nNumberOfClicks && 0 < rMEvt.GetClicks() )
    3068           0 :             nNumberOfClicks = 4;
    3069             : 
    3070           0 :         sal_Bool bExecDrawTextLink = sal_False;
    3071             : 
    3072           0 :         switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
    3073             :         {
    3074             :             case MOUSE_LEFT:
    3075             :             case MOUSE_LEFT + KEY_MOD1:
    3076             :             case MOUSE_LEFT + KEY_MOD2:
    3077             :             {
    3078             : 
    3079           0 :                 bool bHandledFlyClick = false;
    3080           0 :                 if ( nNumberOfClicks == nNbFlyClicks )
    3081             :                 {
    3082           0 :                     bHandledFlyClick = true;
    3083             :                     // only try to select frame, if pointer already was
    3084             :                     // switched accordingly
    3085           0 :                     if ( aActHitType != SDRHIT_NONE && !rSh.IsSelFrmMode() &&
    3086           0 :                         !GetView().GetViewFrame()->GetDispatcher()->IsLocked() &&
    3087             :                         !bExecDrawTextLink)
    3088             :                     {
    3089             :                         // Test if there is a draw object at that position and if it should be selected.
    3090           0 :                         sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos);
    3091             : 
    3092           0 :                         if(bShould)
    3093             :                         {
    3094           0 :                             rView.NoRotate();
    3095           0 :                             rSh.HideCrsr();
    3096             : 
    3097           0 :                             sal_Bool bUnLockView = !rSh.IsViewLocked();
    3098           0 :                             rSh.LockView( sal_True );
    3099             :                             sal_Bool bSelObj = rSh.SelectObj( aDocPos,
    3100           0 :                                            rMEvt.IsMod1() ? SW_ENTER_GROUP : 0);
    3101           0 :                             if( bUnLockView )
    3102           0 :                                 rSh.LockView( sal_False );
    3103             : 
    3104           0 :                             if( bSelObj )
    3105             :                             {
    3106             :                                 // if the frame was deselected in the macro
    3107             :                                 // the cursor just has to be displayed again
    3108           0 :                                 if( FRMTYPE_NONE == rSh.GetSelFrmType() )
    3109           0 :                                     rSh.ShowCrsr();
    3110             :                                 else
    3111             :                                 {
    3112           0 :                                     if (rSh.IsFrmSelected() && rView.GetDrawFuncPtr())
    3113             :                                     {
    3114           0 :                                         rView.GetDrawFuncPtr()->Deactivate();
    3115           0 :                                         rView.SetDrawFuncPtr(NULL);
    3116           0 :                                         rView.LeaveDrawCreate();
    3117           0 :                                         rView.AttrChangedNotify( &rSh );
    3118             :                                     }
    3119             : 
    3120           0 :                                     rSh.EnterSelFrmMode( &aDocPos );
    3121           0 :                                     bFrmDrag = sal_True;
    3122           0 :                                     UpdatePointer( aDocPos, rMEvt.GetModifier() );
    3123             :                                 }
    3124             :                                 return;
    3125             :                             }
    3126             :                             else
    3127           0 :                                 bOnlyText = static_cast< sal_Bool >(rSh.IsObjSelectable( aDocPos ));
    3128             : 
    3129           0 :                             if (!rView.GetDrawFuncPtr())
    3130           0 :                                 rSh.ShowCrsr();
    3131             :                         }
    3132             :                         else
    3133           0 :                             bOnlyText = KEY_MOD1 != rMEvt.GetModifier();
    3134             :                     }
    3135           0 :                     else if ( rSh.IsSelFrmMode() &&
    3136             :                               (aActHitType == SDRHIT_NONE ||
    3137           0 :                                !rSh.IsInsideSelectedObj( aDocPos )))
    3138             :                     {
    3139           0 :                         rView.NoRotate();
    3140             :                         SdrHdl *pHdl;
    3141           0 :                         if( !bIsDocReadOnly && !pAnchorMarker && 0 !=
    3142           0 :                             ( pHdl = pSdrView->PickHandle(aDocPos) ) &&
    3143           0 :                                 ( pHdl->GetKind() == HDL_ANCHOR ||
    3144           0 :                                   pHdl->GetKind() == HDL_ANCHOR_TR ) )
    3145             :                         {
    3146           0 :                             pAnchorMarker = new SwAnchorMarker( pHdl );
    3147           0 :                             UpdatePointer( aDocPos, rMEvt.GetModifier() );
    3148             :                             return;
    3149             :                         }
    3150             :                         else
    3151             :                         {
    3152           0 :                             sal_Bool bUnLockView = !rSh.IsViewLocked();
    3153           0 :                             rSh.LockView( sal_True );
    3154           0 :                             sal_uInt8 nFlag = rMEvt.IsShift() ? SW_ADD_SELECT :0;
    3155           0 :                             if( rMEvt.IsMod1() )
    3156           0 :                                 nFlag = nFlag | SW_ENTER_GROUP;
    3157             : 
    3158           0 :                             if ( rSh.IsSelFrmMode() )
    3159             :                             {
    3160           0 :                                 rSh.UnSelectFrm();
    3161           0 :                                 rSh.LeaveSelFrmMode();
    3162           0 :                                 rView.AttrChangedNotify(&rSh);
    3163             :                             }
    3164             : 
    3165           0 :                             sal_Bool bSelObj = rSh.SelectObj( aDocPos, nFlag );
    3166           0 :                             if( bUnLockView )
    3167           0 :                                 rSh.LockView( sal_False );
    3168             : 
    3169           0 :                             if( !bSelObj )
    3170             :                             {
    3171             :                                 // move cursor here so that it is not drawn in the
    3172             :                                 // frame first; ShowCrsr() happens in LeaveSelFrmMode()
    3173           0 :                                 bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
    3174           0 :                                 rSh.LeaveSelFrmMode();
    3175           0 :                                 rView.AttrChangedNotify( &rSh );
    3176           0 :                                 bCallBase = sal_False;
    3177             :                             }
    3178             :                             else
    3179             :                             {
    3180           0 :                                 rSh.HideCrsr();
    3181           0 :                                 rSh.EnterSelFrmMode( &aDocPos );
    3182           0 :                                 rSh.SelFlyGrabCrsr();
    3183           0 :                                 rSh.MakeSelVisible();
    3184           0 :                                 bFrmDrag = sal_True;
    3185           0 :                                 if( rSh.IsFrmSelected() &&
    3186           0 :                                     rView.GetDrawFuncPtr() )
    3187             :                                 {
    3188           0 :                                     rView.GetDrawFuncPtr()->Deactivate();
    3189           0 :                                     rView.SetDrawFuncPtr(NULL);
    3190           0 :                                     rView.LeaveDrawCreate();
    3191           0 :                                     rView.AttrChangedNotify( &rSh );
    3192             :                                 }
    3193           0 :                                 UpdatePointer( aDocPos, rMEvt.GetModifier() );
    3194             :                                 return;
    3195             :                             }
    3196             :                         }
    3197             :                     }
    3198             :                 }
    3199             : 
    3200           0 :                 switch ( nNumberOfClicks )
    3201             :                 {
    3202             :                     case 1:
    3203             :                     {
    3204           0 :                         UpdatePointer( aDocPos, rMEvt.GetModifier() );
    3205           0 :                         SwEditWin::nDDStartPosY = aDocPos.Y();
    3206           0 :                         SwEditWin::nDDStartPosX = aDocPos.X();
    3207             : 
    3208             :                         // hit an URL in DrawText object?
    3209           0 :                         if (bExecHyperlinks && pSdrView)
    3210             :                         {
    3211           0 :                             SdrViewEvent aVEvt;
    3212           0 :                             pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
    3213             : 
    3214           0 :                             if (aVEvt.eEvent == SDREVENT_EXECUTEURL)
    3215           0 :                                 bExecDrawTextLink = sal_True;
    3216             :                         }
    3217             : 
    3218           0 :                         SwContentAtPos aFieldAtPos ( SwContentAtPos::SW_FIELD );
    3219             : 
    3220             :                         // Are we selecting a field?
    3221           0 :                         if ( rSh.GetContentAtPos( aDocPos, aFieldAtPos ) )
    3222             :                         {
    3223             :                             // select work, AdditionalMode if applicable
    3224           0 :                             if ( KEY_MOD1 == rMEvt.GetModifier() && !rSh.IsAddMode() )
    3225             :                             {
    3226           0 :                                 rSh.EnterAddMode();
    3227           0 :                                 rSh.SelWrd( &aDocPos );
    3228           0 :                                 rSh.LeaveAddMode();
    3229             :                             }
    3230             :                             else
    3231           0 :                                 rSh.SelWrd( &aDocPos );
    3232             :                         }
    3233           0 :                         break;
    3234             :                     }
    3235             :                     case 2:
    3236             :                     {
    3237           0 :                         bFrmDrag = sal_False;
    3238           0 :                         if ( !bHandledFlyClick && !bIsDocReadOnly && rSh.IsInsideSelectedObj(aDocPos) &&
    3239           0 :                              0 == rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) )
    3240             :                         {
    3241             : /* this is no good, on the one hand GetSelectionType is used as flag field (take a look into the GetSelectionType method)
    3242             :    on the other hand the return value is used in a switch without proper masking (very nice), this must lead to trouble
    3243             : */
    3244           0 :                             switch ( rSh.GetSelectionType() &~ ( nsSelectionType::SEL_FONTWORK | nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE ) )
    3245             :                             {
    3246             :                             case nsSelectionType::SEL_GRF:
    3247           0 :                                 RstMBDownFlags();
    3248           0 :                                 GetView().GetViewFrame()->GetBindings().Execute(
    3249             :                                     FN_FORMAT_GRAFIC_DLG, 0, 0,
    3250           0 :                                     SFX_CALLMODE_RECORD|SFX_CALLMODE_SLOT);
    3251             :                                 return;
    3252             : 
    3253             :                                 // double click on OLE object --> OLE-InPlace
    3254             :                             case nsSelectionType::SEL_OLE:
    3255           0 :                                 if (!rSh.IsSelObjProtected(FLYPROTECT_CONTENT))
    3256             :                                 {
    3257           0 :                                     RstMBDownFlags();
    3258           0 :                                     rSh.LaunchOLEObj();
    3259             :                                 }
    3260             :                                 return;
    3261             : 
    3262             :                             case nsSelectionType::SEL_FRM:
    3263           0 :                                 RstMBDownFlags();
    3264           0 :                                 GetView().GetViewFrame()->GetBindings().Execute(
    3265           0 :                                     FN_FORMAT_FRAME_DLG, 0, 0, SFX_CALLMODE_RECORD|SFX_CALLMODE_SLOT);
    3266             :                                 return;
    3267             : 
    3268             :                             case nsSelectionType::SEL_DRW:
    3269           0 :                                 RstMBDownFlags();
    3270           0 :                                 EnterDrawTextMode(aDocPos);
    3271           0 :                                 if ( rView.GetCurShell()->ISA(SwDrawTextShell) )
    3272           0 :                                     ((SwDrawTextShell*)rView.GetCurShell())->Init();
    3273             :                                 return;
    3274             :                             }
    3275             :                         }
    3276             : 
    3277             :                         // if the cursor position was corrected or if a Fly
    3278             :                         // was selected in ReadOnlyMode, no word selection.
    3279           0 :                         if ( !bValidCrsrPos ||
    3280           0 :                             (rSh.IsFrmSelected() && rSh.IsFrmSelected() ))
    3281             :                             return;
    3282             : 
    3283             :                         SwField *pFld;
    3284           0 :                         sal_Bool bFtn = sal_False;
    3285             : 
    3286           0 :                         if( !bIsDocReadOnly &&
    3287           0 :                             ( 0 != ( pFld = rSh.GetCurFld() ) ||
    3288           0 :                               0 != ( bFtn = rSh.GetCurFtn() )) )
    3289             :                         {
    3290           0 :                             RstMBDownFlags();
    3291           0 :                             if( bFtn )
    3292           0 :                                 GetView().GetViewFrame()->GetBindings().Execute( FN_EDIT_FOOTNOTE );
    3293             :                             else
    3294             :                             {
    3295           0 :                                 sal_uInt16 nTypeId = pFld->GetTypeId();
    3296           0 :                                 SfxViewFrame* pVFrame = GetView().GetViewFrame();
    3297           0 :                                 switch( nTypeId )
    3298             :                                 {
    3299             :                                 case TYP_POSTITFLD:
    3300             :                                 case TYP_SCRIPTFLD:
    3301             :                                 {
    3302             :                                     // if it's a Readonly region, status has to be enabled
    3303           0 :                                     sal_uInt16 nSlot = TYP_POSTITFLD == nTypeId ? FN_POSTIT : FN_JAVAEDIT;
    3304           0 :                                     SfxBoolItem aItem(nSlot, sal_True);
    3305           0 :                                     pVFrame->GetBindings().SetState(aItem);
    3306           0 :                                     pVFrame->GetBindings().Execute(nSlot);
    3307           0 :                                     break;
    3308             :                                 }
    3309             :                                 case TYP_AUTHORITY :
    3310           0 :                                     pVFrame->GetBindings().Execute(FN_EDIT_AUTH_ENTRY_DLG);
    3311           0 :                                 break;
    3312             :                                 default:
    3313           0 :                                     pVFrame->GetBindings().Execute(FN_EDIT_FIELD);
    3314             :                                 }
    3315             :                             }
    3316             :                             return;
    3317             :                         }
    3318             :                         // in extended mode double and triple
    3319             :                         // click has no effect.
    3320           0 :                         if ( rSh.IsExtMode() || rSh.IsBlockMode() )
    3321             :                             return;
    3322             : 
    3323             :                         // select work, AdditionalMode if applicable
    3324           0 :                         if ( KEY_MOD1 == rMEvt.GetModifier() && !rSh.IsAddMode() )
    3325             :                         {
    3326           0 :                             rSh.EnterAddMode();
    3327           0 :                             rSh.SelWrd( &aDocPos );
    3328           0 :                             rSh.LeaveAddMode();
    3329             :                         }
    3330             :                         else
    3331           0 :                             rSh.SelWrd( &aDocPos );
    3332           0 :                         bHoldSelection = sal_True;
    3333             :                         return;
    3334             :                     }
    3335             :                     case 3:
    3336             :                     case 4:
    3337             :                     {
    3338           0 :                         bFrmDrag = sal_False;
    3339             :                         // in extended mode double and triple
    3340             :                         // click has no effect.
    3341           0 :                         if ( rSh.IsExtMode() )
    3342             :                             return;
    3343             : 
    3344             :                         // if the cursor position was corrected or if a Fly
    3345             :                         // was selected in ReadOnlyMode, no word selection.
    3346           0 :                         if ( !bValidCrsrPos || rSh.IsFrmSelected() )
    3347             :                             return;
    3348             : 
    3349             :                         // select line, AdditionalMode if applicable
    3350           0 :                         const bool bMod = KEY_MOD1 == rMEvt.GetModifier() &&
    3351           0 :                                          !rSh.IsAddMode();
    3352             : 
    3353           0 :                         if ( bMod )
    3354           0 :                             rSh.EnterAddMode();
    3355             : 
    3356           0 :                         if ( 3 == nNumberOfClicks )
    3357           0 :                             rSh.SelSentence( &aDocPos );
    3358             :                         else
    3359           0 :                             rSh.SelPara( &aDocPos );
    3360             : 
    3361           0 :                         if ( bMod )
    3362           0 :                             rSh.LeaveAddMode();
    3363             : 
    3364           0 :                         bHoldSelection = sal_True;
    3365             :                         return;
    3366             :                     }
    3367             : 
    3368             :                     default:
    3369             :                         return;
    3370             :                 }
    3371             :             }
    3372             :                 /* no break */
    3373             :             case MOUSE_LEFT + KEY_SHIFT:
    3374             :             case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
    3375             :             {
    3376           0 :                 sal_Bool bLockView = bWasShdwCrsr;
    3377             : 
    3378           0 :                 switch ( rMEvt.GetModifier() )
    3379             :                 {
    3380             :                     case KEY_MOD1 + KEY_SHIFT:
    3381             :                     {
    3382           0 :                         if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
    3383             :                         {
    3384           0 :                             rView.NoRotate();
    3385           0 :                             rSh.HideCrsr();
    3386           0 :                             if ( rSh.IsSelFrmMode() )
    3387           0 :                                 rSh.SelectObj(aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP);
    3388             :                             else
    3389           0 :                             {   if ( rSh.SelectObj( aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP ) )
    3390             :                                 {
    3391           0 :                                     rSh.EnterSelFrmMode( &aDocPos );
    3392           0 :                                     SwEditWin::nDDStartPosY = aDocPos.Y();
    3393           0 :                                     SwEditWin::nDDStartPosX = aDocPos.X();
    3394           0 :                                     bFrmDrag = sal_True;
    3395             :                                     return;
    3396             :                                 }
    3397             :                             }
    3398             :                         }
    3399           0 :                         else if( rSh.IsSelFrmMode() &&
    3400           0 :                                  rSh.GetDrawView()->PickHandle( aDocPos ))
    3401             :                         {
    3402           0 :                             bFrmDrag = sal_True;
    3403           0 :                             bNoInterrupt = sal_False;
    3404             :                             return;
    3405             :                         }
    3406             :                     }
    3407           0 :                     break;
    3408             :                     case KEY_MOD1:
    3409           0 :                     if ( !bExecDrawTextLink )
    3410             :                     {
    3411           0 :                         if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) && !lcl_urlOverBackground( rSh, aDocPos ) )
    3412             :                         {
    3413           0 :                             rView.NoRotate();
    3414           0 :                             rSh.HideCrsr();
    3415           0 :                             if ( rSh.IsSelFrmMode() )
    3416           0 :                                 rSh.SelectObj(aDocPos, SW_ENTER_GROUP);
    3417             :                             else
    3418           0 :                             {   if ( rSh.SelectObj( aDocPos, SW_ENTER_GROUP ) )
    3419             :                                 {
    3420           0 :                                     rSh.EnterSelFrmMode( &aDocPos );
    3421           0 :                                     SwEditWin::nDDStartPosY = aDocPos.Y();
    3422           0 :                                     SwEditWin::nDDStartPosX = aDocPos.X();
    3423           0 :                                     bFrmDrag = sal_True;
    3424             :                                     return;
    3425             :                                 }
    3426             :                             }
    3427             :                         }
    3428           0 :                         else if( rSh.IsSelFrmMode() &&
    3429           0 :                                  rSh.GetDrawView()->PickHandle( aDocPos ))
    3430             :                         {
    3431           0 :                             bFrmDrag = sal_True;
    3432           0 :                             bNoInterrupt = sal_False;
    3433             :                             return;
    3434             :                         }
    3435             :                         else
    3436             :                         {
    3437           0 :                             if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
    3438             :                             {
    3439           0 :                                 rSh.PushMode();
    3440           0 :                                 bModePushed = sal_True;
    3441             : 
    3442           0 :                                 sal_Bool bUnLockView = !rSh.IsViewLocked();
    3443           0 :                                 rSh.LockView( sal_True );
    3444           0 :                                 rSh.EnterAddMode();
    3445           0 :                                 if( bUnLockView )
    3446           0 :                                     rSh.LockView( sal_False );
    3447             :                             }
    3448           0 :                             bCallBase = sal_False;
    3449             :                         }
    3450             :                     }
    3451           0 :                     break;
    3452             :                     case KEY_MOD2:
    3453             :                     {
    3454           0 :                         if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
    3455             :                         {
    3456           0 :                             rSh.PushMode();
    3457           0 :                             bModePushed = sal_True;
    3458           0 :                             sal_Bool bUnLockView = !rSh.IsViewLocked();
    3459           0 :                             rSh.LockView( sal_True );
    3460           0 :                             rSh.EnterBlockMode();
    3461           0 :                             if( bUnLockView )
    3462           0 :                                 rSh.LockView( sal_False );
    3463             :                         }
    3464           0 :                         bCallBase = sal_False;
    3465             :                     }
    3466           0 :                     break;
    3467             :                     case KEY_SHIFT:
    3468             :                     {
    3469           0 :                         if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
    3470             :                         {
    3471           0 :                             rView.NoRotate();
    3472           0 :                             rSh.HideCrsr();
    3473           0 :                             if ( rSh.IsSelFrmMode() )
    3474             :                             {
    3475           0 :                                 rSh.SelectObj(aDocPos, SW_ADD_SELECT);
    3476             : 
    3477           0 :                                 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
    3478           0 :                                 if (rMarkList.GetMark(0) == NULL)
    3479             :                                 {
    3480           0 :                                     rSh.LeaveSelFrmMode();
    3481           0 :                                     rView.AttrChangedNotify(&rSh);
    3482           0 :                                     bFrmDrag = sal_False;
    3483             :                                 }
    3484             :                             }
    3485             :                             else
    3486           0 :                             {   if ( rSh.SelectObj( aDocPos ) )
    3487             :                                 {
    3488           0 :                                     rSh.EnterSelFrmMode( &aDocPos );
    3489           0 :                                     SwEditWin::nDDStartPosY = aDocPos.Y();
    3490           0 :                                     SwEditWin::nDDStartPosX = aDocPos.X();
    3491           0 :                                     bFrmDrag = sal_True;
    3492             :                                     return;
    3493             :                                 }
    3494             :                             }
    3495             :                         }
    3496             :                         else
    3497             :                         {
    3498           0 :                             if ( rSh.IsSelFrmMode() &&
    3499           0 :                                  rSh.IsInsideSelectedObj( aDocPos ) )
    3500             :                             {
    3501           0 :                                 rSh.EnterSelFrmMode( &aDocPos );
    3502           0 :                                 SwEditWin::nDDStartPosY = aDocPos.Y();
    3503           0 :                                 SwEditWin::nDDStartPosX = aDocPos.X();
    3504           0 :                                 bFrmDrag = sal_True;
    3505             :                                 return;
    3506             :                             }
    3507           0 :                             if ( rSh.IsSelFrmMode() )
    3508             :                             {
    3509           0 :                                 rSh.UnSelectFrm();
    3510           0 :                                 rSh.LeaveSelFrmMode();
    3511           0 :                                 rView.AttrChangedNotify(&rSh);
    3512           0 :                                 bFrmDrag = sal_False;
    3513             :                             }
    3514           0 :                             if ( !rSh.IsExtMode() )
    3515             :                             {
    3516             :                                 // don't start a selection when an
    3517             :                                 // URL field or a graphic is clicked
    3518           0 :                                 sal_Bool bSttSelect = rSh.HasSelection() ||
    3519           0 :                                                 Pointer(POINTER_REFHAND) != GetPointer();
    3520             : 
    3521           0 :                                 if( !bSttSelect )
    3522             :                                 {
    3523           0 :                                     bSttSelect = sal_True;
    3524           0 :                                     if( bExecHyperlinks )
    3525             :                                     {
    3526             :                                         SwContentAtPos aCntntAtPos(
    3527             :                                             SwContentAtPos::SW_FTN |
    3528           0 :                                             SwContentAtPos::SW_INETATTR );
    3529             : 
    3530           0 :                                         if( rSh.GetContentAtPos( aDocPos, aCntntAtPos ) )
    3531             :                                         {
    3532           0 :                                             if( !rSh.IsViewLocked() &&
    3533           0 :                                                 !rSh.IsReadOnlyAvailable() &&
    3534           0 :                                                 aCntntAtPos.IsInProtectSect() )
    3535           0 :                                                     bLockView = sal_True;
    3536             : 
    3537           0 :                                             bSttSelect = sal_False;
    3538             :                                         }
    3539           0 :                                         else if( rSh.IsURLGrfAtPos( aDocPos ))
    3540           0 :                                             bSttSelect = sal_False;
    3541             :                                     }
    3542             :                                 }
    3543             : 
    3544           0 :                                 if( bSttSelect )
    3545           0 :                                     rSh.SttSelect();
    3546             :                             }
    3547             :                         }
    3548           0 :                         bCallBase = sal_False;
    3549           0 :                         break;
    3550             :                     }
    3551             :                     default:
    3552           0 :                         if( !rSh.IsViewLocked() )
    3553             :                         {
    3554             :                             SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD |
    3555           0 :                                                         SwContentAtPos::SW_INETATTR );
    3556           0 :                             if( rSh.GetContentAtPos( aDocPos, aCntntAtPos, sal_False ) &&
    3557           0 :                                 !rSh.IsReadOnlyAvailable() &&
    3558           0 :                                 aCntntAtPos.IsInProtectSect() )
    3559           0 :                                 bLockView = sal_True;
    3560             :                         }
    3561             :                 }
    3562             : 
    3563           0 :                 if ( rSh.IsGCAttr() )
    3564             :                 {
    3565           0 :                     rSh.GCAttr();
    3566           0 :                     rSh.ClearGCAttr();
    3567             :                 }
    3568             : 
    3569           0 :                 sal_Bool bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = sal_False;
    3570           0 :                 if( !bOverSelect )
    3571           0 :                     bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos );
    3572             : 
    3573           0 :                 if ( !bOverSelect )
    3574             :                 {
    3575           0 :                     const sal_Bool bTmpNoInterrupt = bNoInterrupt;
    3576           0 :                     bNoInterrupt = sal_False;
    3577             : 
    3578           0 :                     if( !rSh.IsViewLocked() && bLockView )
    3579           0 :                         rSh.LockView( sal_True );
    3580             :                     else
    3581           0 :                         bLockView = sal_False;
    3582             : 
    3583           0 :                     int nTmpSetCrsr = 0;
    3584             : 
    3585             :                     {   // only temporary generate Move-Kontext because otherwise
    3586             :                         // the query to the content form doesn't work!!!
    3587           0 :                         SwMvContext aMvContext( &rSh );
    3588           0 :                         nTmpSetCrsr = rSh.SetCursor(&aDocPos, bOnlyText);
    3589           0 :                         bValidCrsrPos = !(CRSR_POSCHG & nTmpSetCrsr);
    3590           0 :                         bCallBase = sal_False;
    3591             :                     }
    3592             : 
    3593             :                     // notify the edit window that from now on we do not use the input language
    3594           0 :                     if ( !(CRSR_POSOLD & nTmpSetCrsr) )
    3595           0 :                         SetUseInputLanguage( sal_False );
    3596             : 
    3597           0 :                     if( bLockView )
    3598           0 :                         rSh.LockView( sal_False );
    3599             : 
    3600           0 :                     bNoInterrupt = bTmpNoInterrupt;
    3601             :                 }
    3602           0 :                 if ( !bOverURLGrf && !bOnlyText )
    3603             :                 {
    3604           0 :                     const int nSelType = rSh.GetSelectionType();
    3605             :                     // Check in general, if an object is selectable at given position.
    3606             :                     // Thus, also text fly frames in background become selectable via Ctrl-Click.
    3607           0 :                     if ( ( nSelType & nsSelectionType::SEL_OLE ||
    3608             :                          nSelType & nsSelectionType::SEL_GRF ||
    3609           0 :                          rSh.IsObjSelectable( aDocPos ) ) && !lcl_urlOverBackground( rSh, aDocPos ) )
    3610             :                     {
    3611           0 :                         SwMvContext aMvContext( &rSh );
    3612           0 :                         if( !rSh.IsFrmSelected() )
    3613           0 :                             rSh.GotoNextFly();
    3614           0 :                         rSh.EnterSelFrmMode();
    3615           0 :                         bCallBase = sal_False;
    3616             :                     }
    3617             :                 }
    3618             :                 // don't reset here any longer so that, in case through MouseMove
    3619             :                 // with pressed Ctrl key a multiple-selection should happen,
    3620             :                 // the previous selection is not released in Drag.
    3621           0 :                 break;
    3622             :             }
    3623             :         }
    3624             :     }
    3625           0 :     if (bCallBase)
    3626           0 :         Window::MouseButtonDown(rMEvt);
    3627             : }
    3628             : 
    3629             : /*--------------------------------------------------------------------
    3630             :     Description:   MouseMove
    3631             :  --------------------------------------------------------------------*/
    3632             : 
    3633           0 : void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
    3634             : {
    3635           0 :     MouseEvent rMEvt(_rMEvt);
    3636             : 
    3637             :     //ignore key modifiers for format paintbrush
    3638             :     {
    3639             :         sal_Bool bExecFormatPaintbrush = pApplyTempl && pApplyTempl->pFormatClipboard
    3640           0 :                                 &&  pApplyTempl->pFormatClipboard->HasContent();
    3641           0 :         if( bExecFormatPaintbrush )
    3642           0 :             rMEvt = MouseEvent( _rMEvt.GetPosPixel(), _rMEvt.GetClicks(),
    3643           0 :                                     _rMEvt.GetMode(), _rMEvt.GetButtons() );
    3644             :     }
    3645             : 
    3646             :     // as long as an action is running the MouseMove should be disconnected
    3647             :     // otherwise bug 40102 occurs
    3648           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    3649           0 :     if( rSh.ActionPend() )
    3650             :         return ;
    3651             : 
    3652           0 :     if( pShadCrsr && 0 != (rMEvt.GetModifier() + rMEvt.GetButtons() ) )
    3653           0 :         delete pShadCrsr, pShadCrsr = 0;
    3654             : 
    3655           0 :     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly();
    3656             : 
    3657           0 :     SET_CURR_SHELL( &rSh );
    3658             : 
    3659             :     //aPixPt == Point in Pixel, relative to ChildWin
    3660             :     //aDocPt == Point in Twips, document coordinates
    3661           0 :     const Point aPixPt( rMEvt.GetPosPixel() );
    3662           0 :     const Point aDocPt( PixelToLogic( aPixPt ) );
    3663             : 
    3664           0 :     if ( IsChainMode() )
    3665             :     {
    3666           0 :         UpdatePointer( aDocPt, rMEvt.GetModifier() );
    3667             :         return;
    3668             :     }
    3669             : 
    3670           0 :     SdrView *pSdrView = rSh.GetDrawView();
    3671             : 
    3672           0 :     const SwCallMouseEvent aLastCallEvent( aSaveCallEvent );
    3673           0 :     aSaveCallEvent.Clear();
    3674             : 
    3675           0 :     if ( !bIsDocReadOnly && pSdrView && pSdrView->MouseMove(rMEvt,this) )
    3676             :     {
    3677           0 :         SetPointer( POINTER_TEXT );
    3678             :         return; // evaluate SdrView's event
    3679             :     }
    3680             : 
    3681           0 :     const Point aOldPt( rSh.VisArea().Pos() );
    3682           0 :     const sal_Bool bInsWin = rSh.VisArea().IsInside( aDocPt );
    3683             : 
    3684           0 :     if( pShadCrsr && !bInsWin )
    3685           0 :         delete pShadCrsr, pShadCrsr = 0;
    3686             : 
    3687           0 :     if( bInsWin && pRowColumnSelectionStart )
    3688             :     {
    3689           0 :         EnterArea();
    3690           0 :         Point aPos( aDocPt );
    3691           0 :         if( rSh.SelectTableRowCol( *pRowColumnSelectionStart, &aPos, bIsRowDrag ))
    3692             :             return;
    3693             :     }
    3694             : 
    3695             :     // position is necessary for OS/2 because obviously after a MB-Down
    3696             :     // a MB-Move is called immediately.
    3697           0 :     if( bDDTimerStarted )
    3698             :     {
    3699           0 :         Point aDD( SwEditWin::nDDStartPosX, SwEditWin::nDDStartPosY );
    3700           0 :         aDD = LogicToPixel( aDD );
    3701           0 :         Rectangle aRect( aDD.X()-3, aDD.Y()-3, aDD.X()+3, aDD.Y()+3 );
    3702           0 :         if ( !aRect.IsInside( aPixPt ) )
    3703           0 :             StopDDTimer( &rSh, aDocPt );
    3704             :     }
    3705             : 
    3706           0 :     if(rView.GetDrawFuncPtr())
    3707             :     {
    3708           0 :         if( bInsDraw  )
    3709             :         {
    3710           0 :             rView.GetDrawFuncPtr()->MouseMove( rMEvt );
    3711           0 :             if ( !bInsWin )
    3712             :             {
    3713           0 :                 Point aTmp( aDocPt );
    3714           0 :                 aTmp += rSh.VisArea().Pos() - aOldPt;
    3715           0 :                 LeaveArea( aTmp );
    3716             :             }
    3717             :             else
    3718           0 :                 EnterArea();
    3719             :             return;
    3720             :         }
    3721           0 :         else if(!rSh.IsFrmSelected() && !rSh.IsObjSelected())
    3722             :         {
    3723           0 :             SfxBindings &rBnd = rSh.GetView().GetViewFrame()->GetBindings();
    3724           0 :             Point aRelPos = rSh.GetRelativePagePosition(aDocPt);
    3725           0 :             if(aRelPos.X() >= 0)
    3726             :             {
    3727           0 :                 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
    3728           0 :                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
    3729           0 :                 const SfxPointItem aTmp1( SID_ATTR_POSITION, aRelPos );
    3730           0 :                 rBnd.SetState( aTmp1 );
    3731             :             }
    3732             :             else
    3733             :             {
    3734           0 :                 rBnd.Invalidate(SID_ATTR_POSITION);
    3735             :             }
    3736           0 :             rBnd.Invalidate(SID_ATTR_SIZE);
    3737           0 :             const SfxStringItem aCell( SID_TABLE_CELL, aEmptyStr );
    3738           0 :             rBnd.SetState( aCell );
    3739             :         }
    3740             :     }
    3741             : 
    3742             :     sal_uInt8 nMouseTabCol;
    3743           0 :     if( !bIsDocReadOnly && bInsWin && !pApplyTempl && !rSh.IsInSelect() )
    3744             :     {
    3745           0 :         if ( SW_TABCOL_NONE != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPt ) ) &&
    3746           0 :              !rSh.IsObjSelectable( aDocPt ) )
    3747             :         {
    3748           0 :             sal_uInt16 nPointer = USHRT_MAX;
    3749           0 :             bool bChkTblSel = false;
    3750             : 
    3751           0 :             switch ( nMouseTabCol )
    3752             :             {
    3753             :                 case SW_TABCOL_VERT :
    3754             :                 case SW_TABROW_HORI :
    3755           0 :                     nPointer = POINTER_VSIZEBAR;
    3756           0 :                     bChkTblSel = true;
    3757           0 :                     break;
    3758             :                 case SW_TABROW_VERT :
    3759             :                 case SW_TABCOL_HORI :
    3760           0 :                     nPointer = POINTER_HSIZEBAR;
    3761           0 :                     bChkTblSel = true;
    3762           0 :                     break;
    3763             :                 case SW_TABSEL_HORI :
    3764           0 :                     nPointer = POINTER_TAB_SELECT_SE;
    3765           0 :                     break;
    3766             :                 case SW_TABSEL_HORI_RTL :
    3767             :                 case SW_TABSEL_VERT :
    3768           0 :                     nPointer = POINTER_TAB_SELECT_SW;
    3769           0 :                     break;
    3770             :                 case SW_TABCOLSEL_HORI :
    3771             :                 case SW_TABROWSEL_VERT :
    3772           0 :                     nPointer = POINTER_TAB_SELECT_S;
    3773           0 :                     break;
    3774             :                 case SW_TABROWSEL_HORI :
    3775           0 :                     nPointer = POINTER_TAB_SELECT_E;
    3776           0 :                     break;
    3777             :                 case SW_TABROWSEL_HORI_RTL :
    3778             :                 case SW_TABCOLSEL_VERT :
    3779           0 :                     nPointer = POINTER_TAB_SELECT_W;
    3780           0 :                     break;
    3781             :             }
    3782             : 
    3783           0 :             if ( USHRT_MAX != nPointer &&
    3784             :                 // i#35543 - Enhanced table selection is explicitly allowed in table mode
    3785           0 :                 ( !bChkTblSel || !rSh.IsTableMode() ) )
    3786             :             {
    3787           0 :                 SetPointer( nPointer );
    3788             :             }
    3789             : 
    3790             :             return;
    3791             :         }
    3792           0 :         else if (rSh.IsNumLabel(aDocPt, RULER_MOUSE_MARGINWIDTH))
    3793             :         {
    3794             :             // i#42921 - consider vertical mode
    3795           0 :             SwTxtNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPt );
    3796             :             const sal_uInt16 nPointer =
    3797           0 :                     rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPt )
    3798             :                     ? POINTER_VSIZEBAR
    3799           0 :                     : POINTER_HSIZEBAR;
    3800           0 :             SetPointer( nPointer );
    3801             : 
    3802             :             return;
    3803             :         }
    3804             :     }
    3805             : 
    3806           0 :     sal_Bool bDelShadCrsr = sal_True;
    3807             : 
    3808           0 :     switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
    3809             :     {
    3810             :         case MOUSE_LEFT:
    3811           0 :             if( pAnchorMarker )
    3812             :             {
    3813             :                 // Now we need to refresh the SdrHdl pointer of pAnchorMarker.
    3814             :                 // This looks a little bit tricky, but it solves the following
    3815             :                 // problem: the pAnchorMarker contains a pointer to an SdrHdl,
    3816             :                 // if the FindAnchorPos-call cause a scrolling of the visible
    3817             :                 // area, it's possible that the SdrHdl will be destroyed and a
    3818             :                 // new one will initialized at the original position(GetHdlPos).
    3819             :                 // So the pAnchorMarker has to find the right SdrHdl, if it's
    3820             :                 // the old one, it will find it with position aOld, if this one
    3821             :                 // is destroyed, it will find a new one at position GetHdlPos().
    3822             : 
    3823           0 :                 const Point aOld = pAnchorMarker->GetPosForHitTest( *(rSh.GetOut()) );
    3824           0 :                 Point aNew = rSh.FindAnchorPos( aDocPt );
    3825             :                 SdrHdl* pHdl;
    3826           0 :                 if( (0!=( pHdl = pSdrView->PickHandle( aOld ) )||
    3827           0 :                     0 !=(pHdl = pSdrView->PickHandle( pAnchorMarker->GetHdlPos()) ) ) &&
    3828           0 :                         ( pHdl->GetKind() == HDL_ANCHOR ||
    3829           0 :                           pHdl->GetKind() == HDL_ANCHOR_TR ) )
    3830             :                 {
    3831           0 :                     pAnchorMarker->ChgHdl( pHdl );
    3832           0 :                     if( aNew.X() || aNew.Y() )
    3833             :                     {
    3834           0 :                         pAnchorMarker->SetPos( aNew );
    3835           0 :                         pAnchorMarker->SetLastPos( aDocPt );
    3836             :                     }
    3837             :                 }
    3838             :                 else
    3839             :                 {
    3840           0 :                     delete pAnchorMarker;
    3841           0 :                     pAnchorMarker = NULL;
    3842             :                 }
    3843             :             }
    3844           0 :             if ( bInsDraw )
    3845             :             {
    3846           0 :                 if ( !bMBPressed )
    3847           0 :                     break;
    3848           0 :                 if ( bIsInMove || IsMinMove( aStartPos, aPixPt ) )
    3849             :                 {
    3850           0 :                     if ( !bInsWin )
    3851           0 :                         LeaveArea( aDocPt );
    3852             :                     else
    3853           0 :                         EnterArea();
    3854           0 :                     if ( rView.GetDrawFuncPtr() )
    3855             :                     {
    3856           0 :                         pSdrView->SetOrtho(sal_False);
    3857           0 :                         rView.GetDrawFuncPtr()->MouseMove( rMEvt );
    3858             :                     }
    3859           0 :                     bIsInMove = sal_True;
    3860             :                 }
    3861             :                 return;
    3862             :             }
    3863             : 
    3864             :             {
    3865           0 :             SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
    3866           0 :             if (pWrdCnt)
    3867           0 :                 pWrdCnt->UpdateCounts();
    3868             :             }
    3869             : 
    3870             :         case MOUSE_LEFT + KEY_SHIFT:
    3871             :         case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
    3872           0 :             if ( !bMBPressed )
    3873           0 :                 break;
    3874             :         case MOUSE_LEFT + KEY_MOD1:
    3875           0 :             if ( bFrmDrag && rSh.IsSelFrmMode() )
    3876             :             {
    3877           0 :                 if( !bMBPressed )
    3878           0 :                     break;
    3879             : 
    3880           0 :                 if ( bIsInMove || IsMinMove( aStartPos, aPixPt ) )
    3881             :                 {
    3882             :                     // event processing for resizing
    3883           0 :                     if( pSdrView->AreObjectsMarked() )
    3884             :                     {
    3885             :                         const SwFrmFmt* pFlyFmt;
    3886             :                         const SvxMacro* pMacro;
    3887             : 
    3888           0 :                         const Point aSttPt( PixelToLogic( aStartPos ) );
    3889             : 
    3890             :                         // can we start?
    3891           0 :                         if( HDL_USER == eSdrMoveHdl )
    3892             :                         {
    3893           0 :                             SdrHdl* pHdl = pSdrView->PickHandle( aSttPt );
    3894           0 :                             eSdrMoveHdl = pHdl ? pHdl->GetKind() : HDL_MOVE;
    3895             :                         }
    3896             : 
    3897             :                         sal_uInt16 nEvent = HDL_MOVE == eSdrMoveHdl
    3898             :                                             ? SW_EVENT_FRM_MOVE
    3899           0 :                                             : SW_EVENT_FRM_RESIZE;
    3900             : 
    3901           0 :                         if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) &&
    3902           0 :                             0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable().
    3903           0 :                             Get( nEvent )) &&
    3904             : // or notify only e.g. every 20 Twip?
    3905           0 :                             aRszMvHdlPt != aDocPt )
    3906             :                         {
    3907           0 :                             aRszMvHdlPt = aDocPt;
    3908           0 :                             sal_uInt16 nPos = 0;
    3909           0 :                             String sRet;
    3910           0 :                             SbxArrayRef xArgs = new SbxArray;
    3911           0 :                             SbxVariableRef xVar = new SbxVariable;
    3912           0 :                             xVar->PutString( pFlyFmt->GetName() );
    3913           0 :                             xArgs->Put( &xVar, ++nPos );
    3914             : 
    3915           0 :                             if( SW_EVENT_FRM_RESIZE == nEvent )
    3916             :                             {
    3917           0 :                                 xVar = new SbxVariable;
    3918           0 :                                 xVar->PutUShort( static_cast< sal_uInt16 >(eSdrMoveHdl) );
    3919           0 :                                 xArgs->Put( &xVar, ++nPos );
    3920             :                             }
    3921             : 
    3922           0 :                             xVar = new SbxVariable;
    3923           0 :                             xVar->PutLong( aDocPt.X() - aSttPt.X() );
    3924           0 :                             xArgs->Put( &xVar, ++nPos );
    3925           0 :                             xVar = new SbxVariable;
    3926           0 :                             xVar->PutLong( aDocPt.Y() - aSttPt.Y() );
    3927           0 :                             xArgs->Put( &xVar, ++nPos );
    3928             : 
    3929           0 :                             ReleaseMouse();
    3930             : 
    3931           0 :                             rSh.ExecMacro( *pMacro, &sRet, &xArgs );
    3932             : 
    3933           0 :                             CaptureMouse();
    3934             : 
    3935           0 :                             if( sRet.Len() && 0 != sRet.ToInt32() )
    3936           0 :                                 return ;
    3937             :                         }
    3938             :                     }
    3939             :                     // event processing for resizing
    3940             : 
    3941           0 :                     if( bIsDocReadOnly )
    3942           0 :                         break;
    3943             : 
    3944           0 :                     if ( rMEvt.IsShift() )
    3945             :                     {
    3946           0 :                         pSdrView->SetOrtho(sal_True);
    3947           0 :                         pSdrView->SetAngleSnapEnabled(sal_True);
    3948             :                     }
    3949             :                     else
    3950             :                     {
    3951           0 :                         pSdrView->SetOrtho(sal_False);
    3952           0 :                         pSdrView->SetAngleSnapEnabled(sal_False);
    3953             :                     }
    3954             : 
    3955           0 :                     rSh.Drag( &aDocPt, rMEvt.IsShift() );
    3956           0 :                     bIsInMove = sal_True;
    3957             :                 }
    3958           0 :                 else if( bIsDocReadOnly )
    3959           0 :                     break;
    3960             : 
    3961           0 :                 if ( !bInsWin )
    3962             :                 {
    3963           0 :                     Point aTmp( aDocPt );
    3964           0 :                     aTmp += rSh.VisArea().Pos() - aOldPt;
    3965           0 :                     LeaveArea( aTmp );
    3966             :                 }
    3967           0 :                 else if(bIsInMove)
    3968           0 :                     EnterArea();
    3969             :                 return;
    3970             :             }
    3971           0 :             if ( !rSh.IsSelFrmMode() && !bDDINetAttr &&
    3972           0 :                 (IsMinMove( aStartPos,aPixPt ) || bIsInMove) &&
    3973           0 :                 (rSh.IsInSelect() || !rSh.ChgCurrPam( aDocPt )) )
    3974             :             {
    3975           0 :                 if ( pSdrView )
    3976             :                 {
    3977           0 :                     if ( rMEvt.IsShift() )
    3978           0 :                         pSdrView->SetOrtho(sal_True);
    3979             :                     else
    3980           0 :                         pSdrView->SetOrtho(sal_False);
    3981             :                 }
    3982           0 :                 if ( !bInsWin )
    3983             :                 {
    3984           0 :                     Point aTmp( aDocPt );
    3985           0 :                     aTmp += rSh.VisArea().Pos() - aOldPt;
    3986           0 :                     LeaveArea( aTmp );
    3987             :                 }
    3988             :                 else
    3989             :                 {
    3990           0 :                     if( !rMEvt.IsSynthetic() &&
    3991             :                             !(( MOUSE_LEFT + KEY_MOD1 ==
    3992           0 :                             rMEvt.GetModifier() + rMEvt.GetButtons() ) &&
    3993           0 :                             rSh.Is_FnDragEQBeginDrag() && !rSh.IsAddMode() ))
    3994             :                     {
    3995           0 :                         rSh.Drag( &aDocPt, false );
    3996             : 
    3997           0 :                         bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPt, false));
    3998           0 :                         EnterArea();
    3999             :                     }
    4000             :                 }
    4001             :             }
    4002           0 :             bDDINetAttr = sal_False;
    4003           0 :             break;
    4004             :         case 0:
    4005             :         {
    4006           0 :             if ( pApplyTempl )
    4007             :             {
    4008           0 :                 UpdatePointer(aDocPt, 0); // maybe a frame has to be marked here
    4009             :                 break;
    4010             :             }
    4011             :             // change ui if mouse is over SwPostItField
    4012             :             // TODO: do the same thing for redlines SW_REDLINE
    4013           0 :             SwRect aFldRect;
    4014           0 :             SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD);
    4015           0 :             if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_False, &aFldRect ) )
    4016             :             {
    4017           0 :                 const SwField* pFld = aCntntAtPos.aFnd.pFld;
    4018           0 :                 if (pFld->Which()== RES_POSTITFLD)
    4019             :                 {
    4020           0 :                     rView.GetPostItMgr()->SetShadowState(reinterpret_cast<const SwPostItField*>(pFld),false);
    4021             :                 }
    4022             :                 else
    4023           0 :                     rView.GetPostItMgr()->SetShadowState(0,false);
    4024             :             }
    4025             :             else
    4026           0 :                 rView.GetPostItMgr()->SetShadowState(0,false);
    4027             :         }
    4028             :         // no break;
    4029             :         case KEY_SHIFT:
    4030             :         case KEY_MOD2:
    4031             :         case KEY_MOD1:
    4032           0 :             if ( !bInsDraw )
    4033             :             {
    4034           0 :                 sal_Bool bTstShdwCrsr = sal_True;
    4035             : 
    4036           0 :                 UpdatePointer( aDocPt, rMEvt.GetModifier() );
    4037             : 
    4038           0 :                 const SwFrmFmt* pFmt = 0;
    4039           0 :                 const SwFmtINetFmt* pINet = 0;
    4040           0 :                 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
    4041           0 :                 if( rSh.GetContentAtPos( aDocPt, aCntntAtPos ) )
    4042           0 :                     pINet = (SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr;
    4043             : 
    4044           0 :                 const void* pTmp = pINet;
    4045             : 
    4046           0 :                 if( pINet ||
    4047           0 :                     0 != ( pTmp = pFmt = rSh.GetFmtFromAnyObj( aDocPt )))
    4048             :                 {
    4049           0 :                     bTstShdwCrsr = sal_False;
    4050           0 :                     if( pTmp == pINet )
    4051           0 :                         aSaveCallEvent.Set( pINet );
    4052             :                     else
    4053             :                     {
    4054           0 :                         IMapObject* pIMapObj = pFmt->GetIMapObject( aDocPt );
    4055           0 :                         if( pIMapObj )
    4056           0 :                             aSaveCallEvent.Set( pFmt, pIMapObj );
    4057             :                         else
    4058           0 :                             aSaveCallEvent.Set( EVENT_OBJECT_URLITEM, pFmt );
    4059             :                     }
    4060             : 
    4061             :                     // should be be over a InternetField with an
    4062             :                     // embedded macro?
    4063           0 :                     if( aSaveCallEvent != aLastCallEvent )
    4064             :                     {
    4065           0 :                         if( aLastCallEvent.HasEvent() )
    4066             :                             rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT,
    4067           0 :                                             aLastCallEvent, true );
    4068             :                         // 0 says that the object doesn't have any table
    4069           0 :                         if( !rSh.CallEvent( SFX_EVENT_MOUSEOVER_OBJECT,
    4070           0 :                                         aSaveCallEvent ))
    4071           0 :                             aSaveCallEvent.Clear();
    4072             :                     }
    4073             :                 }
    4074           0 :                 else if( aLastCallEvent.HasEvent() )
    4075             :                 {
    4076             :                     // cursor was on an object
    4077             :                     rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT,
    4078           0 :                                     aLastCallEvent, true );
    4079             :                 }
    4080             : 
    4081           0 :                 if( bTstShdwCrsr && bInsWin && !bIsDocReadOnly &&
    4082           0 :                     !bInsFrm &&
    4083           0 :                     !rSh.GetViewOptions()->getBrowseMode() &&
    4084           0 :                     rSh.GetViewOptions()->IsShadowCursor() &&
    4085           0 :                     !(rMEvt.GetModifier() + rMEvt.GetButtons()) &&
    4086           0 :                     !rSh.HasSelection() && !GetConnectMetaFile() )
    4087             :                 {
    4088           0 :                     SwRect aRect;
    4089             :                     sal_Int16 eOrient;
    4090           0 :                     SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode();
    4091           0 :                     if( rSh.GetShadowCrsrPos( aDocPt, eMode, aRect, eOrient ))
    4092             :                     {
    4093           0 :                         if( !pShadCrsr )
    4094             :                             pShadCrsr = new SwShadowCursor( *this,
    4095           0 :                                 SwViewOption::GetDirectCursorColor() );
    4096           0 :                         if( text::HoriOrientation::RIGHT != eOrient && text::HoriOrientation::CENTER != eOrient )
    4097           0 :                             eOrient = text::HoriOrientation::LEFT;
    4098           0 :                         pShadCrsr->SetPos( aRect.Pos(), aRect.Height(), static_cast< sal_uInt16 >(eOrient) );
    4099           0 :                         bDelShadCrsr = sal_False;
    4100             :                     }
    4101           0 :                 }
    4102             :             }
    4103           0 :             break;
    4104             :         case MOUSE_LEFT + KEY_MOD2:
    4105           0 :             if( rSh.IsBlockMode() && !rMEvt.IsSynthetic() )
    4106             :             {
    4107           0 :                 rSh.Drag( &aDocPt, false );
    4108           0 :                 bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPt, false));
    4109           0 :                 EnterArea();
    4110             :             }
    4111           0 :         break;
    4112             :     }
    4113             : 
    4114           0 :     if( bDelShadCrsr && pShadCrsr )
    4115           0 :         delete pShadCrsr, pShadCrsr = 0;
    4116           0 :     bWasShdwCrsr = sal_False;
    4117             : }
    4118             : 
    4119             : /*--------------------------------------------------------------------
    4120             :     Description:   Button Up
    4121             :  --------------------------------------------------------------------*/
    4122             : 
    4123           0 : void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
    4124             : {
    4125           0 :     sal_Bool bCallBase = sal_True;
    4126             : 
    4127           0 :     sal_Bool bCallShadowCrsr = bWasShdwCrsr;
    4128           0 :     bWasShdwCrsr = sal_False;
    4129           0 :     if( pShadCrsr )
    4130           0 :         delete pShadCrsr, pShadCrsr = 0;
    4131             : 
    4132           0 :     if( pRowColumnSelectionStart )
    4133           0 :         DELETEZ( pRowColumnSelectionStart );
    4134             : 
    4135           0 :     SdrHdlKind eOldSdrMoveHdl = eSdrMoveHdl;
    4136           0 :     eSdrMoveHdl = HDL_USER;     // for MoveEvents - reset again
    4137             : 
    4138             :     // preventively reset
    4139           0 :     rView.SetTabColFromDoc( sal_False );
    4140           0 :     rView.SetNumRuleNodeFromDoc(NULL);
    4141             : 
    4142           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    4143           0 :     SET_CURR_SHELL( &rSh );
    4144           0 :     SdrView *pSdrView = rSh.GetDrawView();
    4145           0 :     if ( pSdrView )
    4146             :     {
    4147           0 :         pSdrView->SetOrtho(sal_False);
    4148             : 
    4149           0 :         if ( pSdrView->MouseButtonUp( rMEvt,this ) )
    4150             :         {
    4151           0 :             rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
    4152             :             return; // SdrView's event evaluated
    4153             :         }
    4154             :     }
    4155             :     // only process MouseButtonUp when the Down went to that windows as well.
    4156           0 :     if ( !bMBPressed )
    4157             :     {
    4158             : // Undo for the watering can is already in CommandHdl
    4159             : // that's the way it should be!
    4160             : 
    4161             :         return;
    4162             :     }
    4163             : 
    4164           0 :     Point aDocPt( PixelToLogic( rMEvt.GetPosPixel() ) );
    4165             : 
    4166           0 :     if ( bDDTimerStarted )
    4167             :     {
    4168           0 :         StopDDTimer( &rSh, aDocPt );
    4169           0 :         bMBPressed = sal_False;
    4170           0 :         if ( rSh.IsSelFrmMode() )
    4171             :         {
    4172           0 :             rSh.EndDrag( &aDocPt, false );
    4173           0 :             bFrmDrag = sal_False;
    4174             :         }
    4175           0 :         bNoInterrupt = sal_False;
    4176           0 :         ReleaseMouse();
    4177             :         return;
    4178             :     }
    4179             : 
    4180           0 :     if( pAnchorMarker )
    4181             :     {
    4182           0 :         Point aPnt( pAnchorMarker->GetLastPos() );
    4183           0 :         DELETEZ( pAnchorMarker );
    4184           0 :         if( aPnt.X() || aPnt.Y() )
    4185           0 :             rSh.FindAnchorPos( aPnt, sal_True );
    4186             :     }
    4187           0 :     if ( bInsDraw && rView.GetDrawFuncPtr() )
    4188             :     {
    4189           0 :         if ( rView.GetDrawFuncPtr()->MouseButtonUp( rMEvt ) )
    4190             :         {
    4191           0 :             if (rView.GetDrawFuncPtr()) // could have been destroyed in MouseButtonUp
    4192             :             {
    4193           0 :                 rView.GetDrawFuncPtr()->Deactivate();
    4194             : 
    4195           0 :                 if (!rView.IsDrawMode())
    4196             :                 {
    4197           0 :                     rView.SetDrawFuncPtr(NULL);
    4198           0 :                     SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
    4199           0 :                     rBind.Invalidate( SID_ATTR_SIZE );
    4200           0 :                     rBind.Invalidate( SID_TABLE_CELL );
    4201             :                 }
    4202             :             }
    4203             : 
    4204           0 :             if ( rSh.IsObjSelected() )
    4205             :             {
    4206           0 :                 rSh.EnterSelFrmMode();
    4207           0 :                 if (!rView.GetDrawFuncPtr())
    4208           0 :                     StdDrawMode( OBJ_NONE, sal_True );
    4209             :             }
    4210           0 :             else if ( rSh.IsFrmSelected() )
    4211             :             {
    4212           0 :                 rSh.EnterSelFrmMode();
    4213           0 :                 StopInsFrm();
    4214             :             }
    4215             :             else
    4216             :             {
    4217           0 :                 const Point aDocPos( PixelToLogic( aStartPos ) );
    4218           0 :                 bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
    4219           0 :                 rSh.Edit();
    4220             :             }
    4221             : 
    4222           0 :             rView.AttrChangedNotify( &rSh );
    4223             :         }
    4224           0 :         else if (rMEvt.GetButtons() == MOUSE_RIGHT && rSh.IsDrawCreate())
    4225           0 :             rView.GetDrawFuncPtr()->BreakCreate();   // abort drawing
    4226             : 
    4227           0 :         bNoInterrupt = sal_False;
    4228           0 :         ReleaseMouse();
    4229             :         return;
    4230             :     }
    4231           0 :     sal_Bool bPopMode = sal_False;
    4232           0 :     switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
    4233             :     {
    4234             :         case MOUSE_LEFT:
    4235           0 :             if ( bInsDraw && rSh.IsDrawCreate() )
    4236             :             {
    4237           0 :                 if ( rView.GetDrawFuncPtr() && rView.GetDrawFuncPtr()->MouseButtonUp(rMEvt) == sal_True )
    4238             :                 {
    4239           0 :                     rView.GetDrawFuncPtr()->Deactivate();
    4240           0 :                     rView.AttrChangedNotify( &rSh );
    4241           0 :                     if ( rSh.IsObjSelected() )
    4242           0 :                         rSh.EnterSelFrmMode();
    4243           0 :                     if ( rView.GetDrawFuncPtr() && bInsFrm )
    4244           0 :                         StopInsFrm();
    4245             :                 }
    4246           0 :                 bCallBase = sal_False;
    4247           0 :                 break;
    4248             :             }
    4249             :         case MOUSE_LEFT + KEY_MOD1:
    4250             :         case MOUSE_LEFT + KEY_MOD2:
    4251             :         case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
    4252           0 :             if ( bFrmDrag && rSh.IsSelFrmMode() )
    4253             :             {
    4254           0 :                 if ( rMEvt.IsMod1() ) // copy and don't move.
    4255             :                 {
    4256             :                     // abort drag, use internal Copy instead
    4257           0 :                     Rectangle aRect;
    4258           0 :                     rSh.GetDrawView()->TakeActionRect( aRect );
    4259           0 :                     if (!aRect.IsEmpty())
    4260             :                     {
    4261           0 :                         rSh.BreakDrag();
    4262           0 :                         Point aEndPt, aSttPt;
    4263           0 :                         if ( rSh.GetSelFrmType() & FRMTYPE_FLY_ATCNT )
    4264             :                         {
    4265           0 :                             aEndPt = aRect.TopLeft();
    4266           0 :                             aSttPt = rSh.GetDrawView()->GetAllMarkedRect().TopLeft();
    4267             :                         }
    4268             :                         else
    4269             :                         {
    4270           0 :                             aEndPt = aRect.Center();
    4271           0 :                             aSttPt = rSh.GetDrawView()->GetAllMarkedRect().Center();
    4272             :                         }
    4273           0 :                         if ( aSttPt != aEndPt )
    4274             :                         {
    4275           0 :                             rSh.StartUndo( UNDO_UI_DRAG_AND_COPY );
    4276           0 :                             rSh.Copy(&rSh, aSttPt, aEndPt, sal_False);
    4277           0 :                             rSh.EndUndo( UNDO_UI_DRAG_AND_COPY );
    4278             :                         }
    4279             :                     }
    4280             :                     else
    4281           0 :                         rSh.EndDrag( &aDocPt, false );
    4282             :                 }
    4283             :                 else
    4284             :                 {
    4285             :                     {
    4286             :                         const SwFrmFmt* pFlyFmt;
    4287             :                         const SvxMacro* pMacro;
    4288             : 
    4289             :                         sal_uInt16 nEvent = HDL_MOVE == eOldSdrMoveHdl
    4290             :                                             ? SW_EVENT_FRM_MOVE
    4291           0 :                                             : SW_EVENT_FRM_RESIZE;
    4292             : 
    4293           0 :                         if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) &&
    4294           0 :                             0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable().
    4295           0 :                             Get( nEvent )) )
    4296             :                         {
    4297           0 :                             const Point aSttPt( PixelToLogic( aStartPos ) );
    4298           0 :                             aRszMvHdlPt = aDocPt;
    4299           0 :                             sal_uInt16 nPos = 0;
    4300           0 :                             SbxArrayRef xArgs = new SbxArray;
    4301           0 :                             SbxVariableRef xVar = new SbxVariable;
    4302           0 :                             xVar->PutString( pFlyFmt->GetName() );
    4303           0 :                             xArgs->Put( &xVar, ++nPos );
    4304             : 
    4305           0 :                             if( SW_EVENT_FRM_RESIZE == nEvent )
    4306             :                             {
    4307           0 :                                 xVar = new SbxVariable;
    4308           0 :                                 xVar->PutUShort( static_cast< sal_uInt16 >(eOldSdrMoveHdl) );
    4309           0 :                                 xArgs->Put( &xVar, ++nPos );
    4310             :                             }
    4311             : 
    4312           0 :                             xVar = new SbxVariable;
    4313           0 :                             xVar->PutLong( aDocPt.X() - aSttPt.X() );
    4314           0 :                             xArgs->Put( &xVar, ++nPos );
    4315           0 :                             xVar = new SbxVariable;
    4316           0 :                             xVar->PutLong( aDocPt.Y() - aSttPt.Y() );
    4317           0 :                             xArgs->Put( &xVar, ++nPos );
    4318             : 
    4319           0 :                             xVar = new SbxVariable;
    4320           0 :                             xVar->PutUShort( 1 );
    4321           0 :                             xArgs->Put( &xVar, ++nPos );
    4322             : 
    4323           0 :                             ReleaseMouse();
    4324             : 
    4325           0 :                             rSh.ExecMacro( *pMacro, 0, &xArgs );
    4326             : 
    4327           0 :                             CaptureMouse();
    4328             :                         }
    4329             :                     }
    4330           0 :                     rSh.EndDrag( &aDocPt, false );
    4331             :                 }
    4332           0 :                 bFrmDrag = sal_False;
    4333           0 :                 bCallBase = sal_False;
    4334           0 :                 break;
    4335             :             }
    4336           0 :             bPopMode = sal_True;
    4337             :             // no break
    4338             :         case MOUSE_LEFT + KEY_SHIFT:
    4339           0 :             if (rSh.IsSelFrmMode())
    4340             :             {
    4341             : 
    4342           0 :                 rSh.EndDrag( &aDocPt, false );
    4343           0 :                 bFrmDrag = sal_False;
    4344           0 :                 bCallBase = sal_False;
    4345           0 :                 break;
    4346             :             }
    4347             : 
    4348           0 :             if( bHoldSelection )
    4349             :             {
    4350             :                 // the EndDrag should be called in any case
    4351           0 :                 bHoldSelection = sal_False;
    4352           0 :                 rSh.EndDrag( &aDocPt, false );
    4353             :             }
    4354             :             else
    4355             :             {
    4356           0 :                 SwContentAtPos aFieldAtPos ( SwContentAtPos::SW_FIELD );
    4357           0 :                 if ( !rSh.IsInSelect() && rSh.ChgCurrPam( aDocPt ) && !rSh.GetContentAtPos( aDocPt, aFieldAtPos ) )
    4358             :                 {
    4359           0 :                     const sal_Bool bTmpNoInterrupt = bNoInterrupt;
    4360           0 :                     bNoInterrupt = sal_False;
    4361             :                     {   // create only temporary move context because otherwise
    4362             :                         // the query to the content form doesn't work!!!
    4363           0 :                         SwMvContext aMvContext( &rSh );
    4364           0 :                         const Point aDocPos( PixelToLogic( aStartPos ) );
    4365           0 :                         bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
    4366             :                     }
    4367           0 :                     bNoInterrupt = bTmpNoInterrupt;
    4368             : 
    4369             :                 }
    4370             :                 else
    4371             :                 {
    4372           0 :                     sal_Bool bInSel = rSh.IsInSelect();
    4373           0 :                     rSh.EndDrag( &aDocPt, false );
    4374             : 
    4375             :                     // Internetfield? --> call link (load doc!!)
    4376           0 :                     if( !bInSel )
    4377             :                     {
    4378           0 :                         sal_uInt16 nFilter = URLLOAD_NOFILTER;
    4379           0 :                         if( KEY_MOD1 == rMEvt.GetModifier() )
    4380           0 :                             nFilter |= URLLOAD_NEWVIEW;
    4381             : 
    4382           0 :                         sal_Bool bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
    4383           0 :                         if ( !bExecHyperlinks )
    4384             :                         {
    4385           0 :                             SvtSecurityOptions aSecOpts;
    4386           0 :                             const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
    4387           0 :                             if ( (  bSecureOption && rMEvt.GetModifier() == KEY_MOD1 ) ||
    4388           0 :                                  ( !bSecureOption && rMEvt.GetModifier() != KEY_MOD1 ) )
    4389           0 :                                 bExecHyperlinks = sal_True;
    4390             :                         }
    4391             : 
    4392           0 :                         const sal_Bool bExecSmarttags = rMEvt.GetModifier() == KEY_MOD1;
    4393             : 
    4394           0 :                         if(pApplyTempl)
    4395           0 :                             bExecHyperlinks = sal_False;
    4396             : 
    4397             :                         SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD |
    4398             :                                                     SwContentAtPos::SW_INETATTR |
    4399           0 :                                                     SwContentAtPos::SW_SMARTTAG  | SwContentAtPos::SW_FORMCTRL);
    4400             : 
    4401           0 :                         if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_False ) )
    4402             :                         {
    4403             :                             // Do it again if we're not on a field to update the cursor accordingly
    4404           0 :                             if ( SwContentAtPos::SW_FIELD != aCntntAtPos.eCntntAtPos )
    4405           0 :                                 rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_True );
    4406             : 
    4407           0 :                             sal_Bool bViewLocked = rSh.IsViewLocked();
    4408           0 :                             if( !bViewLocked && !rSh.IsReadOnlyAvailable() &&
    4409           0 :                                 aCntntAtPos.IsInProtectSect() )
    4410           0 :                                 rSh.LockView( sal_True );
    4411             : 
    4412           0 :                             ReleaseMouse();
    4413             : 
    4414           0 :                             if( SwContentAtPos::SW_FIELD == aCntntAtPos.eCntntAtPos )
    4415             :                             {
    4416           0 :                                 rSh.ClickToField( *aCntntAtPos.aFnd.pFld );
    4417             :                             }
    4418           0 :                             else if ( SwContentAtPos::SW_SMARTTAG == aCntntAtPos.eCntntAtPos )
    4419             :                             {
    4420             :                                     // execute smarttag menu
    4421           0 :                                     if ( bExecSmarttags && SwSmartTagMgr::Get().IsSmartTagsEnabled() )
    4422           0 :                                         rView.ExecSmartTagPopup( aDocPt );
    4423             :                             }
    4424           0 :                             else if ( SwContentAtPos::SW_FORMCTRL == aCntntAtPos.eCntntAtPos )
    4425             :                             {
    4426             :                                 OSL_ENSURE( aCntntAtPos.aFnd.pFldmark != NULL, "where is my field ptr???");
    4427           0 :                                 if ( aCntntAtPos.aFnd.pFldmark != NULL)
    4428             :                                 {
    4429           0 :                                     IFieldmark *fieldBM = const_cast< IFieldmark* > ( aCntntAtPos.aFnd.pFldmark );
    4430           0 :                                     if ( fieldBM->GetFieldname( ) == ODF_FORMCHECKBOX )
    4431             :                                     {
    4432           0 :                                         ICheckboxFieldmark* pCheckboxFm = dynamic_cast<ICheckboxFieldmark*>(fieldBM);
    4433           0 :                                         pCheckboxFm->SetChecked(!pCheckboxFm->IsChecked());
    4434           0 :                                         pCheckboxFm->Invalidate();
    4435           0 :                                         rSh.InvalidateWindows( rView.GetVisArea() );
    4436           0 :                                     } else if ( fieldBM->GetFieldname() == ODF_FORMDROPDOWN ) {
    4437           0 :                                         rView.ExecFieldPopup( aDocPt, fieldBM );
    4438           0 :                                         fieldBM->Invalidate();
    4439           0 :                                         rSh.InvalidateWindows( rView.GetVisArea() );
    4440             :                                     } else {
    4441             :                                         // unknown type..
    4442             :                                     }
    4443             :                                 }
    4444             :                             }
    4445             :                             else
    4446             :                             {
    4447           0 :                                 if ( bExecHyperlinks )
    4448           0 :                                     rSh.ClickToINetAttr( *(SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr, nFilter );
    4449             :                             }
    4450             : 
    4451           0 :                             rSh.LockView( bViewLocked );
    4452           0 :                             bCallShadowCrsr = sal_False;
    4453             :                         }
    4454             :                         else
    4455             :                         {
    4456           0 :                             aCntntAtPos = SwContentAtPos( SwContentAtPos::SW_FTN );
    4457           0 :                             if( !rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_True ) && bExecHyperlinks )
    4458             :                             {
    4459           0 :                                 SdrViewEvent aVEvt;
    4460             : 
    4461           0 :                                 if (pSdrView)
    4462           0 :                                     pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
    4463             : 
    4464           0 :                                 if (pSdrView && aVEvt.eEvent == SDREVENT_EXECUTEURL)
    4465             :                                 {
    4466             :                                     // hit URL field
    4467           0 :                                     const SvxURLField *pField = aVEvt.pURLField;
    4468           0 :                                     if (pField)
    4469             :                                     {
    4470           0 :                                         String sURL(pField->GetURL());
    4471           0 :                                         String sTarget(pField->GetTargetFrame());
    4472           0 :                                         ::LoadURL(rSh, sURL, nFilter, sTarget);
    4473             :                                     }
    4474           0 :                                     bCallShadowCrsr = sal_False;
    4475             :                                 }
    4476             :                                 else
    4477             :                                 {
    4478             :                                     // hit graphic
    4479           0 :                                     ReleaseMouse();
    4480           0 :                                     if( rSh.ClickToINetGrf( aDocPt, nFilter ))
    4481           0 :                                         bCallShadowCrsr = sal_False;
    4482           0 :                                 }
    4483             :                             }
    4484             :                         }
    4485             : 
    4486           0 :                         if( bCallShadowCrsr &&
    4487           0 :                             rSh.GetViewOptions()->IsShadowCursor() &&
    4488           0 :                             MOUSE_LEFT == (rMEvt.GetModifier() + rMEvt.GetButtons()) &&
    4489           0 :                             !rSh.HasSelection() &&
    4490           0 :                             !GetConnectMetaFile() &&
    4491           0 :                             rSh.VisArea().IsInside( aDocPt ))
    4492             :                         {
    4493           0 :                             SwUndoId nLastUndoId(UNDO_EMPTY);
    4494           0 :                             if (rSh.GetLastUndoInfo(0, & nLastUndoId))
    4495             :                             {
    4496           0 :                                 if (UNDO_INS_FROM_SHADOWCRSR == nLastUndoId)
    4497             :                                 {
    4498           0 :                                     rSh.Undo();
    4499             :                                 }
    4500             :                             }
    4501           0 :                             SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode();
    4502           0 :                             rSh.SetShadowCrsrPos( aDocPt, eMode );
    4503           0 :                         }
    4504             :                     }
    4505             :                 }
    4506           0 :                 bCallBase = sal_False;
    4507             : 
    4508             :             }
    4509             : 
    4510             :             // reset pushed mode in Down again if applicable
    4511           0 :             if ( bPopMode && bModePushed )
    4512             :             {
    4513           0 :                 rSh.PopMode();
    4514           0 :                 bModePushed = sal_False;
    4515           0 :                 bCallBase = sal_False;
    4516             :             }
    4517           0 :             break;
    4518             : 
    4519             :         default:
    4520           0 :             ReleaseMouse();
    4521             :             return;
    4522             :     }
    4523             : 
    4524           0 :     if( pApplyTempl )
    4525             :     {
    4526           0 :         int eSelection = rSh.GetSelectionType();
    4527           0 :         SwFormatClipboard* pFormatClipboard = pApplyTempl->pFormatClipboard;
    4528           0 :         if( pFormatClipboard )//apply format paintbrush
    4529             :         {
    4530             :             //get some parameters
    4531           0 :             SwWrtShell& rWrtShell = rView.GetWrtShell();
    4532           0 :             SfxStyleSheetBasePool* pPool=0;
    4533           0 :             bool bNoCharacterFormats = false;
    4534           0 :             bool bNoParagraphFormats = true;
    4535             :             {
    4536           0 :                 SwDocShell* pDocSh = rView.GetDocShell();
    4537           0 :                 if(pDocSh)
    4538           0 :                     pPool = pDocSh->GetStyleSheetPool();
    4539           0 :                 if( (rMEvt.GetModifier()&KEY_MOD1) && (rMEvt.GetModifier()&KEY_SHIFT) )
    4540             :                 {
    4541           0 :                     bNoCharacterFormats = true;
    4542           0 :                     bNoParagraphFormats = false;
    4543             :                 }
    4544           0 :                 else if( rMEvt.GetModifier() & KEY_MOD1 )
    4545           0 :                     bNoParagraphFormats = false;
    4546             :             }
    4547             :             //execute paste
    4548           0 :             pFormatClipboard->Paste( rWrtShell, pPool, bNoCharacterFormats, bNoParagraphFormats );
    4549             : 
    4550             :             //if the clipboard is empty after paste remove the ApplyTemplate
    4551           0 :             if(!pFormatClipboard->HasContent())
    4552           0 :                 SetApplyTemplate(SwApplyTemplate());
    4553             :         }
    4554           0 :         else if( pApplyTempl->nColor )
    4555             :         {
    4556           0 :             sal_uInt16 nId = 0;
    4557           0 :             switch( pApplyTempl->nColor )
    4558             :             {
    4559             :                 case SID_ATTR_CHAR_COLOR_EXT:
    4560             :                 case SID_ATTR_CHAR_COLOR2:
    4561           0 :                     nId = RES_CHRATR_COLOR;
    4562           0 :                     break;
    4563             :                 case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
    4564             :                 case SID_ATTR_CHAR_COLOR_BACKGROUND:
    4565           0 :                     nId = RES_CHRATR_BACKGROUND;
    4566           0 :                     break;
    4567             :             }
    4568           0 :             if( nId && (nsSelectionType::SEL_TXT|nsSelectionType::SEL_TBL) & eSelection)
    4569             :             {
    4570           0 :                 if( rSh.IsSelection() && !rSh.HasReadonlySel() )
    4571             :                 {
    4572           0 :                     if(nId == RES_CHRATR_BACKGROUND)
    4573             :                     {
    4574           0 :                         Color aColor( COL_TRANSPARENT  );
    4575           0 :                         if( !SwEditWin::bTransparentBackColor )
    4576           0 :                             aColor = SwEditWin::aTextBackColor;
    4577           0 :                         rSh.SetAttr( SvxBrushItem( aColor, nId ) );
    4578             :                     }
    4579             :                     else
    4580           0 :                         rSh.SetAttr( SvxColorItem(SwEditWin::aTextColor, nId) );
    4581           0 :                     rSh.UnSetVisCrsr();
    4582           0 :                     rSh.EnterStdMode();
    4583           0 :                     rSh.SetVisCrsr(aDocPt);
    4584             : 
    4585           0 :                     pApplyTempl->bUndo = sal_True;
    4586           0 :                     bCallBase = sal_False;
    4587           0 :                     aTemplateTimer.Stop();
    4588             :                 }
    4589           0 :                 else if(rMEvt.GetClicks() == 1)
    4590             :                 {
    4591             :                     // no selection -> so turn off watering can
    4592           0 :                     aTemplateTimer.Start();
    4593             :                 }
    4594             :             }
    4595             :         }
    4596             :         else
    4597             :         {
    4598           0 :             String aStyleName;
    4599           0 :             switch ( pApplyTempl->eType )
    4600             :             {
    4601             :                 case SFX_STYLE_FAMILY_PARA:
    4602           0 :                     if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL )
    4603           0 :                          & eSelection ) && !rSh.HasReadonlySel() )
    4604             :                     {
    4605           0 :                         rSh.SetTxtFmtColl( pApplyTempl->aColl.pTxtColl );
    4606           0 :                         pApplyTempl->bUndo = sal_True;
    4607           0 :                         bCallBase = sal_False;
    4608           0 :                         if ( pApplyTempl->aColl.pTxtColl )
    4609           0 :                             aStyleName = pApplyTempl->aColl.pTxtColl->GetName();
    4610             :                     }
    4611           0 :                     break;
    4612             :                 case SFX_STYLE_FAMILY_CHAR:
    4613           0 :                     if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL )
    4614           0 :                          & eSelection ) && !rSh.HasReadonlySel() )
    4615             :                     {
    4616           0 :                         rSh.SetAttr( SwFmtCharFmt(pApplyTempl->aColl.pCharFmt) );
    4617           0 :                         rSh.UnSetVisCrsr();
    4618           0 :                         rSh.EnterStdMode();
    4619           0 :                         rSh.SetVisCrsr(aDocPt);
    4620           0 :                         pApplyTempl->bUndo = sal_True;
    4621           0 :                         bCallBase = sal_False;
    4622           0 :                         if ( pApplyTempl->aColl.pCharFmt )
    4623           0 :                             aStyleName = pApplyTempl->aColl.pCharFmt->GetName();
    4624             :                     }
    4625           0 :                     break;
    4626             :                 case SFX_STYLE_FAMILY_FRAME :
    4627             :                 {
    4628           0 :                     const SwFrmFmt* pFmt = rSh.GetFmtFromObj( aDocPt );
    4629           0 :                     if(PTR_CAST(SwFlyFrmFmt, pFmt))
    4630             :                     {
    4631           0 :                         rSh.SetFrmFmt( pApplyTempl->aColl.pFrmFmt, false, &aDocPt );
    4632           0 :                         pApplyTempl->bUndo = sal_True;
    4633           0 :                         bCallBase = sal_False;
    4634           0 :                         if( pApplyTempl->aColl.pFrmFmt )
    4635           0 :                             aStyleName = pApplyTempl->aColl.pFrmFmt->GetName();
    4636             :                     }
    4637           0 :                     break;
    4638             :                 }
    4639             :                 case SFX_STYLE_FAMILY_PAGE:
    4640             :                             // no Undo with page templates
    4641           0 :                     rSh.ChgCurPageDesc( *pApplyTempl->aColl.pPageDesc );
    4642           0 :                     if ( pApplyTempl->aColl.pPageDesc )
    4643           0 :                         aStyleName = pApplyTempl->aColl.pPageDesc->GetName();
    4644           0 :                     bCallBase = sal_False;
    4645           0 :                     break;
    4646             :                 case SFX_STYLE_FAMILY_PSEUDO:
    4647           0 :                     if( !rSh.HasReadonlySel() )
    4648             :                     {
    4649             :                         rSh.SetCurNumRule( *pApplyTempl->aColl.pNumRule,
    4650             :                                            false,
    4651           0 :                                            pApplyTempl->aColl.pNumRule->GetDefaultListId() );
    4652           0 :                         bCallBase = sal_False;
    4653           0 :                         pApplyTempl->bUndo = sal_True;
    4654           0 :                         if( pApplyTempl->aColl.pNumRule )
    4655           0 :                             aStyleName = pApplyTempl->aColl.pNumRule->GetName();
    4656             :                     }
    4657           0 :                     break;
    4658             :             }
    4659             : 
    4660             :             uno::Reference< frame::XDispatchRecorder > xRecorder =
    4661           0 :                     rView.GetViewFrame()->GetBindings().GetRecorder();
    4662           0 :             if ( aStyleName.Len() && xRecorder.is() )
    4663             :             {
    4664           0 :                 SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) );
    4665           0 :                 if ( pSfxShell )
    4666             :                 {
    4667           0 :                     SfxRequest aReq( rView.GetViewFrame(), SID_STYLE_APPLY );
    4668           0 :                     aReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aStyleName ) );
    4669           0 :                     aReq.AppendItem( SfxUInt16Item( SID_STYLE_FAMILY, (sal_uInt16) pApplyTempl->eType ) );
    4670           0 :                     aReq.Done();
    4671             :                 }
    4672           0 :             }
    4673             :         }
    4674             : 
    4675             :     }
    4676           0 :     ReleaseMouse();
    4677             :     // Only processed MouseEvents arrive here; only at these the moduses can
    4678             :     // be resetted.
    4679           0 :     bMBPressed = sal_False;
    4680             : 
    4681             :     //sicherheitshalber aufrufen, da jetzt das Selektieren bestimmt zu Ende ist.
    4682             :     //Andernfalls koennte der Timeout des Timers Kummer machen.
    4683           0 :     EnterArea();
    4684           0 :     bNoInterrupt = sal_False;
    4685             : 
    4686           0 :     if (bCallBase)
    4687           0 :         Window::MouseButtonUp(rMEvt);
    4688             : }
    4689             : 
    4690             : /*--------------------------------------------------------------------
    4691             :     Description:   apply template
    4692             :  --------------------------------------------------------------------*/
    4693             : 
    4694           0 : void SwEditWin::SetApplyTemplate(const SwApplyTemplate &rTempl)
    4695             : {
    4696             :     static sal_Bool bIdle = sal_False;
    4697           0 :     DELETEZ(pApplyTempl);
    4698           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    4699             : 
    4700           0 :     if(rTempl.pFormatClipboard)
    4701             :     {
    4702           0 :         pApplyTempl = new SwApplyTemplate( rTempl );
    4703           0 :               SetPointer( POINTER_FILL );//@todo #i20119# maybe better a new brush pointer here in future
    4704           0 :               rSh.NoEdit( sal_False );
    4705           0 :               bIdle = rSh.GetViewOptions()->IsIdle();
    4706           0 :               ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
    4707             :     }
    4708           0 :     else if(rTempl.nColor)
    4709             :     {
    4710           0 :         pApplyTempl = new SwApplyTemplate( rTempl );
    4711           0 :         SetPointer( POINTER_FILL );
    4712           0 :         rSh.NoEdit( sal_False );
    4713           0 :         bIdle = rSh.GetViewOptions()->IsIdle();
    4714           0 :         ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
    4715             :     }
    4716           0 :     else if( rTempl.eType )
    4717             :     {
    4718           0 :         pApplyTempl = new SwApplyTemplate( rTempl );
    4719           0 :         SetPointer( POINTER_FILL  );
    4720           0 :         rSh.NoEdit( sal_False );
    4721           0 :         bIdle = rSh.GetViewOptions()->IsIdle();
    4722           0 :         ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
    4723             :     }
    4724             :     else
    4725             :     {
    4726           0 :         SetPointer( POINTER_TEXT );
    4727           0 :         rSh.UnSetVisCrsr();
    4728             : 
    4729           0 :         ((SwViewOption *)rSh.GetViewOptions())->SetIdle( bIdle );
    4730           0 :         if ( !rSh.IsSelFrmMode() )
    4731           0 :             rSh.Edit();
    4732             :     }
    4733             : 
    4734             :     static sal_uInt16 aInva[] =
    4735             :     {
    4736             :         SID_STYLE_WATERCAN,
    4737             :         SID_ATTR_CHAR_COLOR_EXT,
    4738             :         SID_ATTR_CHAR_COLOR_BACKGROUND_EXT,
    4739             :         0
    4740             :     };
    4741           0 :     rView.GetViewFrame()->GetBindings().Invalidate(aInva);
    4742           0 : }
    4743             : 
    4744             : /*--------------------------------------------------------------------
    4745             :     Description:   ctor
    4746             :  --------------------------------------------------------------------*/
    4747             : 
    4748         236 : SwEditWin::SwEditWin(Window *pParent, SwView &rMyView):
    4749             :     Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
    4750             :     DropTargetHelper( this ),
    4751             :     DragSourceHelper( this ),
    4752             : 
    4753             :     eBufferLanguage(LANGUAGE_DONTKNOW),
    4754             :     pApplyTempl(0),
    4755             :     pAnchorMarker( 0 ),
    4756             :     pUserMarker( 0 ),
    4757             :     pUserMarkerObj( 0 ),
    4758             :     pShadCrsr( 0 ),
    4759             :     pRowColumnSelectionStart( 0 ),
    4760             : 
    4761             :     rView( rMyView ),
    4762             : 
    4763             :     aActHitType(SDRHIT_NONE),
    4764             :     m_nDropFormat( 0 ),
    4765             :     m_nDropAction( 0 ),
    4766             :     m_nDropDestination( 0 ),
    4767             : 
    4768             :     nInsFrmColCount( 1 ),
    4769             :     eDrawMode(OBJ_NONE),
    4770             : 
    4771             :     bLockInput(sal_False),
    4772             :     bObjectSelect( sal_False ),
    4773             :     nKS_NUMDOWN_Count(0),
    4774             :     nKS_NUMINDENTINC_Count(0),
    4775         236 :     m_aFrameControlsManager( this )
    4776             : {
    4777         236 :     SetHelpId(HID_EDIT_WIN);
    4778         236 :     EnableChildTransparentMode();
    4779         236 :     SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS );
    4780             : 
    4781             :     bLinkRemoved = bMBPressed = bInsDraw = bInsFrm =
    4782         236 :     bIsInDrag = bOldIdle = bOldIdleSet = bChainMode = bWasShdwCrsr = sal_False;
    4783             :     // initially use the input language
    4784         236 :     bUseInputLanguage = sal_True;
    4785             : 
    4786         236 :     SetMapMode(MapMode(MAP_TWIP));
    4787             : 
    4788         236 :     SetPointer( POINTER_TEXT );
    4789         236 :     aTimer.SetTimeoutHdl(LINK(this, SwEditWin, TimerHandler));
    4790             : 
    4791         236 :     bTblInsDelMode = sal_False;
    4792         236 :     aKeyInputTimer.SetTimeout( 3000 );
    4793         236 :     aKeyInputTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputTimerHandler));
    4794             : 
    4795         236 :     aKeyInputFlushTimer.SetTimeout( 200 );
    4796         236 :     aKeyInputFlushTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputFlushHandler));
    4797             : 
    4798             :     // TemplatePointer for colors should be resetted without
    4799             :     // selection after single click
    4800         236 :     aTemplateTimer.SetTimeout(400);
    4801         236 :     aTemplateTimer.SetTimeoutHdl(LINK(this, SwEditWin, TemplateTimerHdl));
    4802             : 
    4803             :     // temporary solution!!! Should set the font of the current
    4804             :     //          insert position at every curor movement!
    4805         236 :     if( !rMyView.GetDocShell()->IsReadOnly() )
    4806             :     {
    4807         236 :         Font aFont;
    4808             :         SetInputContext( InputContext( aFont, INPUTCONTEXT_TEXT |
    4809         236 :                                             INPUTCONTEXT_EXTTEXTINPUT ) );
    4810             :     }
    4811         236 : }
    4812             : 
    4813         189 : SwEditWin::~SwEditWin()
    4814             : {
    4815          63 :     aKeyInputTimer.Stop();
    4816          63 :     delete pShadCrsr;
    4817          63 :     delete pRowColumnSelectionStart;
    4818          63 :     if( pQuickHlpData->m_bIsDisplayed && rView.GetWrtShellPtr() )
    4819           0 :         pQuickHlpData->Stop( rView.GetWrtShell() );
    4820          63 :     bExecuteDrag = sal_False;
    4821          63 :     delete pApplyTempl;
    4822          63 :     rView.SetDrawFuncPtr(NULL);
    4823             : 
    4824          63 :     delete pUserMarker;
    4825          63 :     delete pAnchorMarker;
    4826         126 : }
    4827             : 
    4828             : /******************************************************************************
    4829             :  *  Description: turn on DrawTextEditMode
    4830             :  ******************************************************************************/
    4831             : 
    4832           0 : void SwEditWin::EnterDrawTextMode( const Point& aDocPos )
    4833             : {
    4834           0 :     if ( rView.EnterDrawTextMode(aDocPos) == sal_True )
    4835             :     {
    4836           0 :         if (rView.GetDrawFuncPtr())
    4837             :         {
    4838           0 :             rView.GetDrawFuncPtr()->Deactivate();
    4839           0 :             rView.SetDrawFuncPtr(NULL);
    4840           0 :             rView.LeaveDrawCreate();
    4841             :         }
    4842           0 :         rView.NoRotate();
    4843           0 :         rView.AttrChangedNotify( &rView.GetWrtShell() );
    4844             :     }
    4845           0 : }
    4846             : 
    4847             : /******************************************************************************
    4848             :  *  Description: turn on DrawMode
    4849             :  ******************************************************************************/
    4850             : 
    4851           0 : sal_Bool SwEditWin::EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos)
    4852             : {
    4853           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    4854           0 :     SdrView *pSdrView = rSh.GetDrawView();
    4855             : 
    4856           0 :     if ( rView.GetDrawFuncPtr() )
    4857             :     {
    4858           0 :         if (rSh.IsDrawCreate())
    4859           0 :             return sal_True;
    4860             : 
    4861           0 :         sal_Bool bRet = rView.GetDrawFuncPtr()->MouseButtonDown( rMEvt );
    4862           0 :         rView.AttrChangedNotify( &rSh );
    4863           0 :         return bRet;
    4864             :     }
    4865             : 
    4866           0 :     if ( pSdrView && pSdrView->IsTextEdit() )
    4867             :     {
    4868           0 :         sal_Bool bUnLockView = !rSh.IsViewLocked();
    4869           0 :         rSh.LockView( sal_True );
    4870             : 
    4871           0 :         rSh.EndTextEdit(); // clicked aside, end Edit
    4872           0 :         rSh.SelectObj( aDocPos );
    4873           0 :         if ( !rSh.IsObjSelected() && !rSh.IsFrmSelected() )
    4874           0 :             rSh.LeaveSelFrmMode();
    4875             :         else
    4876             :         {
    4877           0 :             SwEditWin::nDDStartPosY = aDocPos.Y();
    4878           0 :             SwEditWin::nDDStartPosX = aDocPos.X();
    4879           0 :             bFrmDrag = sal_True;
    4880             :         }
    4881           0 :         if( bUnLockView )
    4882           0 :             rSh.LockView( sal_False );
    4883           0 :         rView.AttrChangedNotify( &rSh );
    4884           0 :         return sal_True;
    4885             :     }
    4886           0 :     return sal_False;
    4887             : }
    4888             : 
    4889           0 : sal_Bool SwEditWin::IsDrawSelMode()
    4890             : {
    4891           0 :     return IsObjectSelect();
    4892             : }
    4893             : 
    4894         142 : void SwEditWin::GetFocus()
    4895             : {
    4896         142 :     if ( rView.GetPostItMgr()->HasActiveSidebarWin() )
    4897             :     {
    4898           0 :         rView.GetPostItMgr()->GrabFocusOnActiveSidebarWin();
    4899             :     }
    4900             :     else
    4901             :     {
    4902         142 :         rView.GotFocus();
    4903         142 :         Window::GetFocus();
    4904         142 :         rView.GetWrtShell().InvalidateAccessibleFocus();
    4905             :     }
    4906         142 : }
    4907             : 
    4908         142 : void SwEditWin::LoseFocus()
    4909             : {
    4910         142 :     rView.GetWrtShell().InvalidateAccessibleFocus();
    4911         142 :     Window::LoseFocus();
    4912         142 :     if( pQuickHlpData->m_bIsDisplayed )
    4913           0 :         pQuickHlpData->Stop( rView.GetWrtShell() );
    4914         142 :     rView.LostFocus();
    4915         142 : }
    4916             : 
    4917           0 : void SwEditWin::Command( const CommandEvent& rCEvt )
    4918             : {
    4919           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    4920             : 
    4921           0 :     if ( !rView.GetViewFrame() )
    4922             :     {
    4923             :         // If ViewFrame dies shortly, no popup anymore!
    4924           0 :         Window::Command(rCEvt);
    4925           0 :         return;
    4926             :     }
    4927             : 
    4928             :     // The command event is send to the window after a possible context
    4929             :     // menu from an inplace client has been closed. Now we have the chance
    4930             :     // to deactivate the inplace client without any problem regarding parent
    4931             :     // windows and code on the stack.
    4932           0 :     SfxInPlaceClient* pIPClient = rSh.GetSfxViewShell()->GetIPClient();
    4933           0 :     sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
    4934           0 :     if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ))
    4935             :     {
    4936           0 :         rSh.FinishOLEObj();
    4937           0 :         return;
    4938             :     }
    4939             : 
    4940           0 :     sal_Bool bCallBase      = sal_True;
    4941             : 
    4942           0 :     switch ( rCEvt.GetCommand() )
    4943             :     {
    4944             :         case COMMAND_CONTEXTMENU:
    4945             :         {
    4946           0 :             const sal_uInt16 nId = SwInputChild::GetChildWindowId();
    4947           0 :             SwInputChild* pChildWin = (SwInputChild*)GetView().GetViewFrame()->
    4948           0 :                                                 GetChildWindow( nId );
    4949             : 
    4950           0 :             if (rView.GetPostItMgr()->IsHit(rCEvt.GetMousePosPixel()))
    4951             :                 return;
    4952             : 
    4953           0 :             Point aDocPos( PixelToLogic( rCEvt.GetMousePosPixel() ) );
    4954           0 :             if ( !rCEvt.IsMouseEvent() )
    4955           0 :                 aDocPos = rSh.GetCharRect().Center();
    4956             : 
    4957             :             // Don't trigger the command on a frame anchored to header/footer is not editing it
    4958             :             FrameControlType eControl;
    4959           0 :             bool bOverFly = false;
    4960           0 :             bool bPageAnchored = false;
    4961           0 :             bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly, bPageAnchored );
    4962             :             // !bOverHeaderFooterFly doesn't mean we have a frame to select
    4963           0 :             if ( !bPageAnchored && rCEvt.IsMouseEvent( ) &&
    4964           0 :                  ( ( rSh.IsHeaderFooterEdit( ) && !bOverHeaderFooterFly && bOverFly ) ||
    4965           0 :                    ( !rSh.IsHeaderFooterEdit( ) && bOverHeaderFooterFly ) ) )
    4966             :             {
    4967             :                 return;
    4968             :             }
    4969             : 
    4970           0 :             if((!pChildWin || pChildWin->GetView() != &rView) &&
    4971           0 :                 !rSh.IsDrawCreate() && !IsDrawAction())
    4972             :             {
    4973           0 :                 SET_CURR_SHELL( &rSh );
    4974           0 :                 if (!pApplyTempl)
    4975             :                 {
    4976           0 :                     if (bNoInterrupt == sal_True)
    4977             :                     {
    4978           0 :                         ReleaseMouse();
    4979           0 :                         bNoInterrupt = sal_False;
    4980           0 :                         bMBPressed = sal_False;
    4981             :                     }
    4982           0 :                     if ( rCEvt.IsMouseEvent() )
    4983             :                     {
    4984           0 :                         SelectMenuPosition(rSh, rCEvt.GetMousePosPixel());
    4985           0 :                         rView.StopShellTimer();
    4986             :                     }
    4987           0 :                     const Point aPixPos = LogicToPixel( aDocPos );
    4988             : 
    4989           0 :                     if ( rView.GetDocShell()->IsReadOnly() )
    4990             :                     {
    4991           0 :                         SwReadOnlyPopup* pROPopup = new SwReadOnlyPopup( aDocPos, rView );
    4992             : 
    4993           0 :                         ui::ContextMenuExecuteEvent aEvent;
    4994           0 :                         aEvent.SourceWindow = VCLUnoHelper::GetInterface( this );
    4995           0 :                         aEvent.ExecutePosition.X = aPixPos.X();
    4996           0 :                         aEvent.ExecutePosition.Y = aPixPos.Y();
    4997           0 :                         Menu* pMenu = 0;
    4998           0 :                         ::rtl::OUString sMenuName(RTL_CONSTASCII_USTRINGPARAM("private:resource/ReadonlyContextMenu"));
    4999           0 :                         if( GetView().TryContextMenuInterception( *pROPopup, sMenuName, pMenu, aEvent ) )
    5000             :                         {
    5001           0 :                             if ( pMenu )
    5002             :                             {
    5003           0 :                                 sal_uInt16 nExecId = ((PopupMenu*)pMenu)->Execute(this, aPixPos);
    5004           0 :                                 if( !::ExecuteMenuCommand( *static_cast<PopupMenu*>(pMenu), *rView.GetViewFrame(), nExecId ))
    5005           0 :                                     pROPopup->Execute(this, nExecId);
    5006             :                             }
    5007             :                             else
    5008           0 :                                 pROPopup->Execute(this, aPixPos);
    5009             :                         }
    5010           0 :                         delete pROPopup;
    5011             :                     }
    5012           0 :                     else if ( !rView.ExecSpellPopup( aDocPos ) )
    5013           0 :                         GetView().GetViewFrame()->GetDispatcher()->ExecutePopup( 0, this, &aPixPos);
    5014             :                 }
    5015           0 :                 else if (pApplyTempl->bUndo)
    5016           0 :                     rSh.Do(SwWrtShell::UNDO);
    5017           0 :                 bCallBase = sal_False;
    5018             :             }
    5019             :         }
    5020           0 :         break;
    5021             : 
    5022             :         case COMMAND_WHEEL:
    5023             :         case COMMAND_STARTAUTOSCROLL:
    5024             :         case COMMAND_AUTOSCROLL:
    5025           0 :             if( pShadCrsr )
    5026           0 :                 delete pShadCrsr, pShadCrsr = 0;
    5027           0 :             bCallBase = !rView.HandleWheelCommands( rCEvt );
    5028           0 :             break;
    5029             : 
    5030             :         case COMMAND_VOICE:
    5031             :             {
    5032             :                 // forward to Outliner if applicable
    5033           0 :                 if ( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
    5034             :                 {
    5035           0 :                     bCallBase = sal_False;
    5036           0 :                     rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
    5037           0 :                     break;
    5038             :                 }
    5039             : 
    5040           0 :                 const CommandVoiceData *pCData = rCEvt.GetVoiceData();
    5041           0 :                 if ( VOICECOMMANDTYPE_CONTROL == pCData->GetType() )
    5042           0 :                     break;
    5043             : 
    5044           0 :                 sal_uInt16 nSlotId = 0;
    5045           0 :                 SfxPoolItem *pItem = 0;
    5046             : 
    5047           0 :                 switch ( pCData->GetCommand() )
    5048             :                 {
    5049           0 :                     case DICTATIONCOMMAND_NEWPARAGRAPH: nSlotId = FN_INSERT_BREAK; break;
    5050           0 :                     case DICTATIONCOMMAND_NEWLINE:      nSlotId = FN_INSERT_LINEBREAK; break;
    5051           0 :                     case DICTATIONCOMMAND_LEFT:         nSlotId = FN_PREV_WORD; break;
    5052           0 :                     case DICTATIONCOMMAND_RIGHT:        nSlotId = FN_NEXT_WORD; break;
    5053           0 :                     case DICTATIONCOMMAND_UP:           nSlotId = FN_LINE_UP; break;
    5054           0 :                     case DICTATIONCOMMAND_DOWN:         nSlotId = FN_LINE_DOWN; break;
    5055           0 :                     case DICTATIONCOMMAND_UNDO:         nSlotId = SID_UNDO; break;
    5056           0 :                     case DICTATIONCOMMAND_REPEAT:       nSlotId = SID_REPEAT; break;
    5057           0 :                     case DICTATIONCOMMAND_DEL:          nSlotId = FN_DELETE_BACK_WORD; break;
    5058             : 
    5059           0 :                     case DICTATIONCOMMAND_BOLD_ON:      nSlotId = SID_ATTR_CHAR_WEIGHT;
    5060           0 :                                                         pItem = new SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT );
    5061           0 :                                                         break;
    5062           0 :                     case DICTATIONCOMMAND_BOLD_OFF:     nSlotId = SID_ATTR_CHAR_WEIGHT;
    5063           0 :                                                         pItem = new SvxWeightItem( WEIGHT_NORMAL, RES_CHRATR_WEIGHT );
    5064           0 :                                                         break;
    5065           0 :                     case DICTATIONCOMMAND_UNDERLINE_ON: nSlotId = SID_ATTR_CHAR_UNDERLINE;
    5066           0 :                                                         pItem = new SvxUnderlineItem( UNDERLINE_SINGLE, RES_CHRATR_WEIGHT );
    5067           0 :                                                         break;
    5068           0 :                     case DICTATIONCOMMAND_UNDERLINE_OFF:nSlotId = SID_ATTR_CHAR_UNDERLINE;
    5069           0 :                                                         pItem = new SvxUnderlineItem( UNDERLINE_NONE, RES_CHRATR_UNDERLINE );
    5070           0 :                                                         break;
    5071           0 :                     case DICTATIONCOMMAND_ITALIC_ON:    nSlotId = SID_ATTR_CHAR_POSTURE;
    5072           0 :                                                         pItem = new SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE );
    5073           0 :                                                         break;
    5074           0 :                     case DICTATIONCOMMAND_ITALIC_OFF:   nSlotId = SID_ATTR_CHAR_POSTURE;
    5075           0 :                                                         pItem = new SvxPostureItem( ITALIC_NONE, RES_CHRATR_POSTURE );
    5076           0 :                                                         break;
    5077             :                     case DICTATIONCOMMAND_NUMBERING_ON:
    5078           0 :                                     if ( !rSh.GetCurNumRule() )
    5079           0 :                                         nSlotId = FN_NUM_NUMBERING_ON;
    5080           0 :                                     break;
    5081             :                     case DICTATIONCOMMAND_NUMBERING_OFF:
    5082           0 :                                     if ( rSh.GetCurNumRule() )
    5083           0 :                                        nSlotId = FN_NUM_NUMBERING_ON;
    5084           0 :                                     break;
    5085             :                     case DICTATIONCOMMAND_TAB:
    5086             :                                     {
    5087           0 :                                        rSh.Insert( '\t' );
    5088             :                                     }
    5089           0 :                                     break;
    5090             :                     case DICTATIONCOMMAND_UNKNOWN:
    5091             :                                     {
    5092           0 :                                         rView.GetWrtShell().Insert( pCData->GetText() );
    5093             :                                     }
    5094           0 :                                     break;
    5095             : 
    5096             : #if OSL_DEBUG_LEVEL > 0
    5097             :                     default:
    5098             :                         OSL_ENSURE( !this, "unknown speech command." );
    5099             : #endif
    5100             :                 }
    5101           0 :                 if ( nSlotId )
    5102             :                 {
    5103           0 :                     bCallBase = sal_False;
    5104           0 :                     if ( pItem )
    5105             :                     {
    5106             :                         const SfxPoolItem* aArgs[2];
    5107           0 :                         aArgs[0] = pItem;
    5108           0 :                         aArgs[1] = 0;
    5109           0 :                         GetView().GetViewFrame()->GetBindings().Execute(
    5110           0 :                                     nSlotId, aArgs, 0, SFX_CALLMODE_STANDARD );
    5111           0 :                         delete pItem;
    5112             :                     }
    5113             :                     else
    5114           0 :                         GetView().GetViewFrame()->GetBindings().Execute( nSlotId );
    5115             :                 }
    5116             :             }
    5117           0 :             break;
    5118             : 
    5119             :     case COMMAND_STARTEXTTEXTINPUT:
    5120             :     {
    5121           0 :         sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
    5122           0 :                               rSh.IsCrsrReadonly();
    5123           0 :         if(!bIsDocReadOnly)
    5124             :         {
    5125           0 :             if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
    5126             :             {
    5127           0 :                 bCallBase = sal_False;
    5128           0 :                 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
    5129             :             }
    5130             :             else
    5131             :             {
    5132           0 :                 if( rSh.HasSelection() )
    5133           0 :                     rSh.DelRight();
    5134             : 
    5135           0 :                 bCallBase = sal_False;
    5136           0 :                 LanguageType eInputLanguage = GetInputLanguage();
    5137           0 :                 rSh.CreateExtTextInput(eInputLanguage);
    5138             :             }
    5139             :         }
    5140           0 :         break;
    5141             :     }
    5142             :     case COMMAND_ENDEXTTEXTINPUT:
    5143             :     {
    5144           0 :         sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
    5145           0 :                               rSh.IsCrsrReadonly();
    5146           0 :         if(!bIsDocReadOnly)
    5147             :         {
    5148           0 :             if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
    5149             :             {
    5150           0 :                 bCallBase = sal_False;
    5151           0 :                 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
    5152             :             }
    5153             :             else
    5154             :             {
    5155           0 :                 bCallBase = sal_False;
    5156           0 :                 String sRecord = rSh.DeleteExtTextInput();
    5157             :                 uno::Reference< frame::XDispatchRecorder > xRecorder =
    5158           0 :                         rView.GetViewFrame()->GetBindings().GetRecorder();
    5159             : 
    5160           0 :                 if ( sRecord.Len() )
    5161             :                 {
    5162             :                     // convert quotes in IME text
    5163             :                     // works on the last input character, this is escpecially in Korean text often done
    5164             :                     // quotes that are inside of the string are not replaced!
    5165           0 :                     const sal_Unicode aCh = sRecord.GetChar(sRecord.Len() - 1);
    5166           0 :                     SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
    5167           0 :                     SvxAutoCorrect* pACorr = rACfg.GetAutoCorrect();
    5168           0 :                     if(pACorr &&
    5169           0 :                         (( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))||
    5170           0 :                         ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh))))
    5171             :                     {
    5172           0 :                         rSh.DelLeft();
    5173           0 :                         rSh.AutoCorrect( *pACorr, aCh );
    5174             :                     }
    5175             : 
    5176           0 :                     if ( xRecorder.is() )
    5177             :                     {
    5178             :                         // determine Shell
    5179           0 :                         SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) );
    5180             :                         // generate request and record
    5181           0 :                         if (pSfxShell)
    5182             :                         {
    5183           0 :                             SfxRequest aReq( rView.GetViewFrame(), FN_INSERT_STRING );
    5184           0 :                             aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, sRecord ) );
    5185           0 :                             aReq.Done();
    5186             :                         }
    5187             :                     }
    5188           0 :                 }
    5189             :             }
    5190             :         }
    5191             :     }
    5192           0 :     break;
    5193             :     case COMMAND_EXTTEXTINPUT:
    5194             :     {
    5195           0 :         sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
    5196           0 :                               rSh.IsCrsrReadonly();
    5197           0 :         if(!bIsDocReadOnly)
    5198             :         {
    5199           0 :             if( pQuickHlpData->m_bIsDisplayed )
    5200           0 :                 pQuickHlpData->Stop( rSh );
    5201             : 
    5202           0 :             String sWord;
    5203           0 :             if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
    5204             :             {
    5205           0 :                 bCallBase = sal_False;
    5206           0 :                 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
    5207             :             }
    5208             :             else
    5209             :             {
    5210           0 :                 const CommandExtTextInputData* pData = rCEvt.GetExtTextInputData();
    5211           0 :                 if( pData )
    5212             :                 {
    5213           0 :                     sWord = pData->GetText();
    5214           0 :                     bCallBase = sal_False;
    5215           0 :                     rSh.SetExtTextInputData( *pData );
    5216             :                 }
    5217             :             }
    5218             :                 uno::Reference< frame::XDispatchRecorder > xRecorder =
    5219           0 :                         rView.GetViewFrame()->GetBindings().GetRecorder();
    5220           0 :                 if(!xRecorder.is())
    5221             :                 {
    5222           0 :                     SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
    5223           0 :                     SvxAutoCorrect* pACorr = rACfg.GetAutoCorrect();
    5224           0 :                     if( pACorr &&
    5225             :                         // If autocompletion required...
    5226           0 :                         ( rACfg.IsAutoTextTip() ||
    5227           0 :                           pACorr->GetSwFlags().bAutoCompleteWords ) &&
    5228             :                         // ... and extraction of last word from text input was successful...
    5229           0 :                         rSh.GetPrevAutoCorrWord( *pACorr, sWord ) )
    5230             :                     {
    5231             :                         // ... request for auto completion help to be shown.
    5232           0 :                         ShowAutoTextCorrectQuickHelp(sWord, &rACfg, pACorr, true);
    5233             :                     }
    5234           0 :                 }
    5235             :         }
    5236             :     }
    5237           0 :     break;
    5238             :     case COMMAND_CURSORPOS:
    5239             :         // will be handled by the base class
    5240           0 :         break;
    5241             : 
    5242             :     case COMMAND_PASTESELECTION:
    5243           0 :         if( !rView.GetDocShell()->IsReadOnly() )
    5244             :         {
    5245             :             TransferableDataHelper aDataHelper(
    5246           0 :                         TransferableDataHelper::CreateFromSelection( this ));
    5247           0 :             if( !aDataHelper.GetXTransferable().is() )
    5248             :                 break;
    5249             : 
    5250             :             sal_uLong nDropFormat;
    5251             :             sal_uInt16 nEventAction, nDropAction, nDropDestination;
    5252           0 :             nDropDestination = GetDropDestination( rCEvt.GetMousePosPixel() );
    5253           0 :             if( !nDropDestination )
    5254             :                 break;
    5255             : 
    5256             :             nDropAction = SotExchange::GetExchangeAction(
    5257           0 :                                 aDataHelper.GetDataFlavorExVector(),
    5258             :                                 nDropDestination, EXCHG_IN_ACTION_COPY,
    5259             :                                 EXCHG_IN_ACTION_COPY, nDropFormat,
    5260           0 :                                 nEventAction );
    5261           0 :             if( EXCHG_INOUT_ACTION_NONE != nDropAction )
    5262             :             {
    5263           0 :                 const Point aDocPt( PixelToLogic( rCEvt.GetMousePosPixel() ) );
    5264             :                 SwTransferable::PasteData( aDataHelper, rSh, nDropAction,
    5265             :                                     nDropFormat, nDropDestination, sal_False,
    5266             :                                     sal_False, &aDocPt, EXCHG_IN_ACTION_COPY,
    5267           0 :                                     sal_True );
    5268           0 :             }
    5269             :         }
    5270           0 :         break;
    5271             :         case COMMAND_MODKEYCHANGE :
    5272             :         {
    5273           0 :             const CommandModKeyData* pCommandData = (const CommandModKeyData*)rCEvt.GetData();
    5274           0 :             if(pCommandData->IsMod1() && !pCommandData->IsMod2())
    5275             :             {
    5276           0 :                 sal_uInt16 nSlot = 0;
    5277           0 :                 if(pCommandData->IsLeftShift() && !pCommandData->IsRightShift())
    5278           0 :                     nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT;
    5279           0 :                 else if(!pCommandData->IsLeftShift() && pCommandData->IsRightShift())
    5280           0 :                     nSlot = SID_ATTR_PARA_RIGHT_TO_LEFT;
    5281           0 :                 if(nSlot && SW_MOD()->GetCTLOptions().IsCTLFontEnabled())
    5282           0 :                     GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot);
    5283             :             }
    5284             :         }
    5285           0 :         break;
    5286             :         case COMMAND_HANGUL_HANJA_CONVERSION :
    5287           0 :             GetView().GetViewFrame()->GetDispatcher()->Execute(SID_HANGUL_HANJA_CONVERSION);
    5288           0 :         break;
    5289             :         case COMMAND_INPUTLANGUAGECHANGE :
    5290             :             // i#42732 - update state of fontname if input language changes
    5291           0 :             bInputLanguageSwitched = true;
    5292           0 :             SetUseInputLanguage( sal_True );
    5293           0 :         break;
    5294             :         case COMMAND_SELECTIONCHANGE:
    5295             :         {
    5296           0 :             const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData();
    5297           0 :             rSh.SttCrsrMove();
    5298           0 :             rSh.GoStartSentence();
    5299           0 :             rSh.GetCrsr()->GetPoint()->nContent += sal::static_int_cast<sal_uInt16, sal_uLong>(pData->GetStart());
    5300           0 :             rSh.SetMark();
    5301           0 :             rSh.GetCrsr()->GetMark()->nContent += sal::static_int_cast<sal_uInt16, sal_uLong>(pData->GetEnd() - pData->GetStart());
    5302           0 :             rSh.EndCrsrMove( sal_True );
    5303             :         }
    5304           0 :         break;
    5305             :         case COMMAND_PREPARERECONVERSION:
    5306           0 :         if( rSh.HasSelection() )
    5307             :         {
    5308           0 :             SwPaM *pCrsr = (SwPaM*)rSh.GetCrsr();
    5309             : 
    5310           0 :             if( rSh.IsMultiSelection() )
    5311             :             {
    5312           0 :                 if( pCrsr && !pCrsr->HasMark() &&
    5313           0 :                 pCrsr->GetPoint() == pCrsr->GetMark() )
    5314             :                 {
    5315           0 :                 rSh.GoPrevCrsr();
    5316           0 :                 pCrsr = (SwPaM*)rSh.GetCrsr();
    5317             :                 }
    5318             : 
    5319             :                 // Cancel all selections other than the last selected one.
    5320           0 :                 while( rSh.GetCrsr()->GetNext() != rSh.GetCrsr() )
    5321           0 :                 delete rSh.GetCrsr()->GetNext();
    5322             :             }
    5323             : 
    5324           0 :             if( pCrsr )
    5325             :             {
    5326           0 :                 sal_uLong nPosNodeIdx = pCrsr->GetPoint()->nNode.GetIndex();
    5327           0 :                 xub_StrLen nPosIdx = pCrsr->GetPoint()->nContent.GetIndex();
    5328           0 :                 sal_uLong nMarkNodeIdx = pCrsr->GetMark()->nNode.GetIndex();
    5329           0 :                 xub_StrLen nMarkIdx = pCrsr->GetMark()->nContent.GetIndex();
    5330             : 
    5331           0 :                 if( !rSh.GetCrsr()->HasMark() )
    5332           0 :                     rSh.GetCrsr()->SetMark();
    5333             : 
    5334           0 :                 rSh.SttCrsrMove();
    5335             : 
    5336           0 :                 if( nPosNodeIdx < nMarkNodeIdx )
    5337             :                 {
    5338           0 :                 rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx;
    5339           0 :                 rSh.GetCrsr()->GetPoint()->nContent = nPosIdx;
    5340           0 :                 rSh.GetCrsr()->GetMark()->nNode = nPosNodeIdx;
    5341           0 :                 rSh.GetCrsr()->GetMark()->nContent =
    5342           0 :                     rSh.GetCrsr()->GetCntntNode( sal_True )->Len();
    5343             :                 }
    5344           0 :                 else if( nPosNodeIdx == nMarkNodeIdx )
    5345             :                 {
    5346           0 :                 rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx;
    5347           0 :                 rSh.GetCrsr()->GetPoint()->nContent = nPosIdx;
    5348           0 :                 rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx;
    5349           0 :                 rSh.GetCrsr()->GetMark()->nContent = nMarkIdx;
    5350             :                 }
    5351             :                 else
    5352             :                 {
    5353           0 :                 rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx;
    5354           0 :                 rSh.GetCrsr()->GetMark()->nContent = nMarkIdx;
    5355           0 :                 rSh.GetCrsr()->GetPoint()->nNode = nMarkNodeIdx;
    5356           0 :                 rSh.GetCrsr()->GetPoint()->nContent =
    5357           0 :                     rSh.GetCrsr()->GetCntntNode( sal_False )->Len();
    5358             :                 }
    5359             : 
    5360           0 :                 rSh.EndCrsrMove( sal_True );
    5361             :             }
    5362             :         }
    5363           0 :         break;
    5364             : #if OSL_DEBUG_LEVEL > 0
    5365             :         default:
    5366             :             OSL_ENSURE( !this, "unknown command." );
    5367             : #endif
    5368             :     }
    5369           0 :     if (bCallBase)
    5370           0 :         Window::Command(rCEvt);
    5371             : }
    5372             : 
    5373             : /*  i#18686 select the object/cursor at the mouse
    5374             :     position of the context menu request */
    5375           0 : sal_Bool SwEditWin::SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos )
    5376             : {
    5377           0 :     sal_Bool bRet = sal_False;
    5378           0 :     const Point aDocPos( PixelToLogic( rMousePos ) );
    5379           0 :     const bool bIsInsideSelectedObj( rSh.IsInsideSelectedObj( aDocPos ) );
    5380             :     //create a synthetic mouse event out of the coordinates
    5381           0 :     MouseEvent aMEvt(rMousePos);
    5382           0 :     SdrView *pSdrView = rSh.GetDrawView();
    5383           0 :     if ( pSdrView )
    5384             :     {
    5385             :         // no close of insert_draw and reset of
    5386             :         // draw mode, if context menu position is inside a selected object.
    5387           0 :         if ( !bIsInsideSelectedObj && rView.GetDrawFuncPtr() )
    5388             :         {
    5389             : 
    5390           0 :             rView.GetDrawFuncPtr()->Deactivate();
    5391           0 :             rView.SetDrawFuncPtr(NULL);
    5392           0 :             rView.LeaveDrawCreate();
    5393           0 :             SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
    5394           0 :             rBind.Invalidate( SID_ATTR_SIZE );
    5395           0 :             rBind.Invalidate( SID_TABLE_CELL );
    5396             :         }
    5397             : 
    5398             :         // if draw text is active and there's a text selection
    5399             :         // at the mouse position then do nothing
    5400           0 :         if(rSh.GetSelectionType() & nsSelectionType::SEL_DRW_TXT)
    5401             :         {
    5402           0 :             OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
    5403           0 :             ESelection aSelection = pOLV->GetSelection();
    5404           0 :             if(!aSelection.IsZero())
    5405             :             {
    5406           0 :                 SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
    5407           0 :                 sal_Bool bVertical = pOutliner->IsVertical();
    5408           0 :                 const EditEngine& rEditEng = pOutliner->GetEditEngine();
    5409           0 :                 Point aEEPos(aDocPos);
    5410           0 :                 const Rectangle& rOutputArea = pOLV->GetOutputArea();
    5411             :                 // regard vertical mode
    5412           0 :                 if(bVertical)
    5413             :                 {
    5414           0 :                     aEEPos -= rOutputArea.TopRight();
    5415             :                     //invert the horizontal direction and exchange X and Y
    5416           0 :                     long nTemp = -aEEPos.X();
    5417           0 :                     aEEPos.X() = aEEPos.Y();
    5418           0 :                     aEEPos.Y() = nTemp;
    5419             :                 }
    5420             :                 else
    5421           0 :                     aEEPos -= rOutputArea.TopLeft();
    5422             : 
    5423           0 :                 EPosition aDocPosition = rEditEng.FindDocPosition(aEEPos);
    5424           0 :                 ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
    5425             :                 // make it a forward selection - otherwise the IsLess/IsGreater do not work :-(
    5426           0 :                 aSelection.Adjust();
    5427           0 :                 if(!aCompare.IsLess(aSelection)  && !aCompare.IsGreater(aSelection))
    5428             :                 {
    5429           0 :                     return sal_False;
    5430             :                 }
    5431             :             }
    5432             : 
    5433             :         }
    5434             : 
    5435           0 :         if (pSdrView->MouseButtonDown( aMEvt, this ) )
    5436             :         {
    5437           0 :             pSdrView->MouseButtonUp( aMEvt, this );
    5438           0 :             rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
    5439           0 :             return sal_True;
    5440             :         }
    5441             :     }
    5442           0 :     rSh.ResetCursorStack();
    5443             : 
    5444           0 :     if ( EnterDrawMode( aMEvt, aDocPos ) )
    5445             :     {
    5446           0 :         return sal_True;
    5447             :     }
    5448           0 :     if ( rView.GetDrawFuncPtr() && bInsFrm )
    5449             :     {
    5450           0 :         StopInsFrm();
    5451           0 :         rSh.Edit();
    5452             :     }
    5453             : 
    5454           0 :     UpdatePointer( aDocPos, 0 );
    5455             : 
    5456           0 :     if( !rSh.IsSelFrmMode() &&
    5457           0 :         !GetView().GetViewFrame()->GetDispatcher()->IsLocked() )
    5458             :     {
    5459             :         // Test if there is a draw object at that position and if it should be selected.
    5460           0 :         sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos);
    5461             : 
    5462           0 :         if(bShould)
    5463             :         {
    5464           0 :             rView.NoRotate();
    5465           0 :             rSh.HideCrsr();
    5466             : 
    5467           0 :             sal_Bool bUnLockView = !rSh.IsViewLocked();
    5468           0 :             rSh.LockView( sal_True );
    5469           0 :             sal_Bool bSelObj = rSh.SelectObj( aDocPos, 0);
    5470           0 :             if( bUnLockView )
    5471           0 :                 rSh.LockView( sal_False );
    5472             : 
    5473           0 :             if( bSelObj )
    5474             :             {
    5475           0 :                 bRet = sal_True;
    5476             :                 // in case the frame was deselected in the macro
    5477             :                 // just the cursor has to be displayed again.
    5478           0 :                 if( FRMTYPE_NONE == rSh.GetSelFrmType() )
    5479           0 :                     rSh.ShowCrsr();
    5480             :                 else
    5481             :                 {
    5482           0 :                     if (rSh.IsFrmSelected() && rView.GetDrawFuncPtr())
    5483             :                     {
    5484           0 :                         rView.GetDrawFuncPtr()->Deactivate();
    5485           0 :                         rView.SetDrawFuncPtr(NULL);
    5486           0 :                         rView.LeaveDrawCreate();
    5487           0 :                         rView.AttrChangedNotify( &rSh );
    5488             :                     }
    5489             : 
    5490           0 :                     rSh.EnterSelFrmMode( &aDocPos );
    5491           0 :                     bFrmDrag = sal_True;
    5492           0 :                     UpdatePointer( aDocPos, 0 );
    5493           0 :                     return bRet;
    5494             :                 }
    5495             :             }
    5496             : 
    5497           0 :             if (!rView.GetDrawFuncPtr())
    5498           0 :                 rSh.ShowCrsr();
    5499             :         }
    5500             :     }
    5501           0 :     else if ( rSh.IsSelFrmMode() &&
    5502             :               (aActHitType == SDRHIT_NONE ||
    5503           0 :                !bIsInsideSelectedObj))
    5504             :     {
    5505           0 :         rView.NoRotate();
    5506           0 :         sal_Bool bUnLockView = !rSh.IsViewLocked();
    5507           0 :         rSh.LockView( sal_True );
    5508           0 :         sal_uInt8 nFlag = 0;
    5509             : 
    5510           0 :         if ( rSh.IsSelFrmMode() )
    5511             :         {
    5512           0 :             rSh.UnSelectFrm();
    5513           0 :             rSh.LeaveSelFrmMode();
    5514           0 :             rView.AttrChangedNotify(&rSh);
    5515           0 :             bRet = sal_True;
    5516             :         }
    5517             : 
    5518           0 :         sal_Bool bSelObj = rSh.SelectObj( aDocPos, nFlag );
    5519           0 :         if( bUnLockView )
    5520           0 :             rSh.LockView( sal_False );
    5521             : 
    5522           0 :         if( !bSelObj )
    5523             :         {
    5524             :             // move cursor here so that it is not drawn in the
    5525             :             // frame at first; ShowCrsr() happens in LeaveSelFrmMode()
    5526           0 :             bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
    5527           0 :             rSh.LeaveSelFrmMode();
    5528           0 :             rView.LeaveDrawCreate();
    5529           0 :             rView.AttrChangedNotify( &rSh );
    5530           0 :             bRet = sal_True;
    5531             :         }
    5532             :         else
    5533             :         {
    5534           0 :             rSh.HideCrsr();
    5535           0 :             rSh.EnterSelFrmMode( &aDocPos );
    5536           0 :             rSh.SelFlyGrabCrsr();
    5537           0 :             rSh.MakeSelVisible();
    5538           0 :             bFrmDrag = sal_True;
    5539           0 :             if( rSh.IsFrmSelected() &&
    5540           0 :                 rView.GetDrawFuncPtr() )
    5541             :             {
    5542           0 :                 rView.GetDrawFuncPtr()->Deactivate();
    5543           0 :                 rView.SetDrawFuncPtr(NULL);
    5544           0 :                 rView.LeaveDrawCreate();
    5545           0 :                 rView.AttrChangedNotify( &rSh );
    5546             :             }
    5547           0 :             UpdatePointer( aDocPos, 0 );
    5548           0 :             bRet = sal_True;
    5549             :         }
    5550             :     }
    5551           0 :     else if ( rSh.IsSelFrmMode() && bIsInsideSelectedObj )
    5552             :     {
    5553             :         // ## object at the mouse cursor is already selected - do nothing
    5554           0 :         return sal_False;
    5555             :     }
    5556             : 
    5557           0 :     if ( rSh.IsGCAttr() )
    5558             :     {
    5559           0 :         rSh.GCAttr();
    5560           0 :         rSh.ClearGCAttr();
    5561             :     }
    5562             : 
    5563           0 :     sal_Bool bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = sal_False;
    5564           0 :     if( !bOverSelect )
    5565           0 :         bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos );
    5566             : 
    5567           0 :     if ( !bOverSelect )
    5568             :     {
    5569             :         {   // create only temporary move context because otherwise
    5570             :             // the query against the content form doesn't work!!!
    5571           0 :             SwMvContext aMvContext( &rSh );
    5572           0 :             rSh.SetCursor(&aDocPos, false);
    5573           0 :             bRet = sal_True;
    5574             :         }
    5575             :     }
    5576           0 :     if( !bOverURLGrf )
    5577             :     {
    5578           0 :         const int nSelType = rSh.GetSelectionType();
    5579           0 :         if( nSelType == nsSelectionType::SEL_OLE ||
    5580             :             nSelType == nsSelectionType::SEL_GRF )
    5581             :         {
    5582           0 :             SwMvContext aMvContext( &rSh );
    5583           0 :             if( !rSh.IsFrmSelected() )
    5584           0 :                 rSh.GotoNextFly();
    5585           0 :             rSh.EnterSelFrmMode();
    5586           0 :             bRet = sal_True;
    5587             :         }
    5588             :     }
    5589           0 :     return bRet;
    5590             : }
    5591             : 
    5592           0 : static SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType )
    5593             : {
    5594             :     // determine Shell
    5595             :     SfxShell* pShell;
    5596           0 :     SfxDispatcher* pDispatcher = rView.GetViewFrame()->GetDispatcher();
    5597           0 :     for(sal_uInt16  i = 0; sal_True; ++i )
    5598             :     {
    5599           0 :         pShell = pDispatcher->GetShell( i );
    5600           0 :         if( !pShell || pShell->IsA( nType ) )
    5601           0 :             break;
    5602             :     }
    5603           0 :     return pShell;
    5604             : }
    5605             : 
    5606           0 : IMPL_LINK_NOARG(SwEditWin, KeyInputFlushHandler)
    5607             : {
    5608           0 :     FlushInBuffer();
    5609           0 :     return 0;
    5610             : }
    5611             : 
    5612           0 : IMPL_LINK_NOARG(SwEditWin, KeyInputTimerHandler)
    5613             : {
    5614           0 :     bTblInsDelMode = sal_False;
    5615           0 :     return 0;
    5616             : }
    5617             : 
    5618          10 : void SwEditWin::_InitStaticData()
    5619             : {
    5620          10 :     pQuickHlpData = new QuickHelpData();
    5621          10 : }
    5622             : 
    5623          10 : void SwEditWin::_FinitStaticData()
    5624             : {
    5625          10 :     delete pQuickHlpData;
    5626          10 : }
    5627             : /* i#3370 - remove quick help to prevent saving
    5628             :  * of autocorrection suggestions */
    5629           2 : void SwEditWin::StopQuickHelp()
    5630             : {
    5631           2 :     if( HasFocus() && pQuickHlpData && pQuickHlpData->m_bIsDisplayed  )
    5632           0 :         pQuickHlpData->Stop( rView.GetWrtShell() );
    5633           2 : }
    5634             : 
    5635           0 : IMPL_LINK_NOARG(SwEditWin, TemplateTimerHdl)
    5636             : {
    5637           0 :     SetApplyTemplate(SwApplyTemplate());
    5638           0 :     return 0;
    5639             : }
    5640             : 
    5641           0 : void SwEditWin::SetChainMode( sal_Bool bOn )
    5642             : {
    5643           0 :     if ( !bChainMode )
    5644           0 :         StopInsFrm();
    5645             : 
    5646           0 :     if ( pUserMarker )
    5647             :     {
    5648           0 :         delete pUserMarker;
    5649           0 :         pUserMarker = 0L;
    5650             :     }
    5651             : 
    5652           0 :     bChainMode = bOn;
    5653             : 
    5654             :     static sal_uInt16 aInva[] =
    5655             :     {
    5656             :         FN_FRAME_CHAIN, FN_FRAME_UNCHAIN, 0
    5657             :     };
    5658           0 :     rView.GetViewFrame()->GetBindings().Invalidate(aInva);
    5659           0 : }
    5660             : 
    5661           0 : uno::Reference< ::com::sun::star::accessibility::XAccessible > SwEditWin::CreateAccessible()
    5662             : {
    5663           0 :     SolarMutexGuard aGuard;   // this should have happend already!!!
    5664           0 :     SwWrtShell *pSh = rView.GetWrtShellPtr();
    5665             :     OSL_ENSURE( pSh, "no writer shell, no accessible object" );
    5666             :     uno::Reference<
    5667           0 :         ::com::sun::star::accessibility::XAccessible > xAcc;
    5668           0 :     if( pSh )
    5669           0 :         xAcc = pSh->CreateAccessible();
    5670             : 
    5671           0 :     return xAcc;
    5672             : }
    5673             : 
    5674             : //-------------------------------------------------------------
    5675             : 
    5676           0 : void QuickHelpData::Move( QuickHelpData& rCpy )
    5677             : {
    5678           0 :     m_aHelpStrings.clear();
    5679           0 :     m_aHelpStrings.swap( rCpy.m_aHelpStrings );
    5680             : 
    5681           0 :     m_bIsDisplayed = rCpy.m_bIsDisplayed;
    5682           0 :     nLen = rCpy.nLen;
    5683           0 :     nCurArrPos = rCpy.nCurArrPos;
    5684           0 :     m_bAppendSpace = rCpy.m_bAppendSpace;
    5685           0 :     m_bIsTip = rCpy.m_bIsTip;
    5686           0 :     m_bIsAutoText = rCpy.m_bIsAutoText;
    5687           0 : }
    5688             : 
    5689          10 : void QuickHelpData::ClearCntnt()
    5690             : {
    5691          10 :     nLen = nCurArrPos = 0;
    5692          10 :     m_bIsDisplayed = m_bAppendSpace = false;
    5693          10 :     nTipId = 0;
    5694          10 :     m_aHelpStrings.clear();
    5695          10 :     m_bIsTip = true;
    5696          10 :     m_bIsAutoText = true;
    5697          10 : }
    5698             : 
    5699           0 : void QuickHelpData::Start( SwWrtShell& rSh, sal_uInt16 nWrdLen )
    5700             : {
    5701           0 :     if( USHRT_MAX != nWrdLen )
    5702             :     {
    5703           0 :         nLen = nWrdLen;
    5704           0 :         nCurArrPos = 0;
    5705             :     }
    5706           0 :     m_bIsDisplayed = true;
    5707             : 
    5708           0 :     Window& rWin = rSh.GetView().GetEditWin();
    5709           0 :     if( m_bIsTip )
    5710             :     {
    5711             :         Point aPt( rWin.OutputToScreenPixel( rWin.LogicToPixel(
    5712           0 :                     rSh.GetCharRect().Pos() )));
    5713           0 :         aPt.Y() -= 3;
    5714             :         nTipId = Help::ShowTip( &rWin, Rectangle( aPt, Size( 1, 1 )),
    5715           0 :                         m_aHelpStrings[ nCurArrPos ],
    5716           0 :                         QUICKHELP_LEFT | QUICKHELP_BOTTOM );
    5717             :     }
    5718             :     else
    5719             :     {
    5720           0 :         String sStr( m_aHelpStrings[ nCurArrPos ] );
    5721           0 :         sStr.Erase( 0, nLen );
    5722           0 :         sal_uInt16 nL = sStr.Len();
    5723             :         const sal_uInt16 nVal = EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE |
    5724           0 :                                 EXTTEXTINPUT_ATTR_HIGHLIGHT;
    5725           0 :         const std::vector<sal_uInt16> aAttrs( nL, nVal );
    5726           0 :         CommandExtTextInputData aCETID( sStr, &aAttrs[0], nL,
    5727           0 :                                         0, 0, 0, sal_False );
    5728             : 
    5729             :         //fdo#33092. If the current input language is the default
    5730             :         //language that text would appear in if typed, then don't
    5731             :         //force a language on for the ExtTextInput.
    5732           0 :         LanguageType eInputLanguage = rWin.GetInputLanguage();
    5733           0 :         if (lcl_isNonDefaultLanguage(eInputLanguage,
    5734           0 :             rSh.GetView(), sStr) == INVALID_HINT)
    5735             :         {
    5736           0 :             eInputLanguage = LANGUAGE_DONTKNOW;
    5737             :         }
    5738             : 
    5739           0 :         rSh.CreateExtTextInput(eInputLanguage);
    5740           0 :         rSh.SetExtTextInputData( aCETID );
    5741             :     }
    5742           0 : }
    5743             : 
    5744           0 : void QuickHelpData::Stop( SwWrtShell& rSh )
    5745             : {
    5746           0 :     if( !m_bIsTip )
    5747           0 :         rSh.DeleteExtTextInput( 0, sal_False );
    5748           0 :     else if( nTipId )
    5749           0 :         Help::HideTip( nTipId );
    5750           0 :     ClearCntnt();
    5751           0 : }
    5752             : 
    5753           0 : void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord, bool bIgnoreCurrentPos )
    5754             : {
    5755             :     enum Capitalization { CASE_LOWER, CASE_UPPER, CASE_SENTENCE, CASE_OTHER };
    5756             : 
    5757             :     // Determine word capitalization
    5758           0 :     const CharClass& rCC = GetAppCharClass();
    5759           0 :     const String sWordLower = rCC.lowercase( rWord );
    5760           0 :     Capitalization aWordCase = CASE_OTHER;
    5761           0 :     if ( rWord.Len() > 0 )
    5762             :     {
    5763           0 :         if ( rWord.GetChar(0) == sWordLower.GetChar(0) )
    5764             :         {
    5765           0 :             if ( rWord == sWordLower )
    5766           0 :                 aWordCase = CASE_LOWER;
    5767             :         }
    5768             :         else
    5769             :         {
    5770             :             // First character is not lower case i.e. assume upper or title case
    5771           0 :             String sWordSentence = sWordLower;
    5772           0 :             sWordSentence.SetChar( 0, rWord.GetChar(0) );
    5773           0 :             if ( rWord == sWordSentence )
    5774           0 :                 aWordCase = CASE_SENTENCE;
    5775             :             else
    5776             :             {
    5777           0 :                 if ( rWord == static_cast<String>( rCC.uppercase( rWord ) ) )
    5778           0 :                     aWordCase = CASE_UPPER;
    5779           0 :             }
    5780             :         }
    5781             :     }
    5782             : 
    5783           0 :     salhelper::SingletonRef<SwCalendarWrapper>* pCalendar = s_getCalendarWrapper();
    5784           0 :     (*pCalendar)->LoadDefaultCalendar( rSh.GetCurLang() );
    5785             : 
    5786             :     // Add matching calendar month and day names
    5787           0 :     uno::Sequence< i18n::CalendarItem2 > aNames( (*pCalendar)->getMonths() );
    5788           0 :     for ( sal_uInt16 i = 0; i < 2; ++i )
    5789             :     {
    5790           0 :         for ( long n = 0; n < aNames.getLength(); ++n )
    5791             :         {
    5792           0 :             const String& rStr( aNames[n].FullName );
    5793             :             // Check string longer than word and case insensitive match
    5794           0 :             if( rStr.Len() > rWord.Len() &&
    5795           0 :                 static_cast<String>( rCC.lowercase( rStr, 0, rWord.Len() ) )
    5796           0 :                 == sWordLower )
    5797             :             {
    5798           0 :                 if ( aWordCase == CASE_LOWER )
    5799           0 :                     m_aHelpStrings.push_back( rCC.lowercase( rStr ) );
    5800           0 :                 else if ( aWordCase == CASE_SENTENCE )
    5801             :                 {
    5802           0 :                     String sTmp = rCC.lowercase( rStr );
    5803           0 :                     sTmp.SetChar( 0, rStr.GetChar(0) );
    5804           0 :                     m_aHelpStrings.push_back( sTmp );
    5805             :                 }
    5806           0 :                 else if ( aWordCase == CASE_UPPER )
    5807           0 :                     m_aHelpStrings.push_back( rCC.uppercase( rStr ) );
    5808             :                 else // CASE_OTHER - use retrieved capitalization
    5809           0 :                     m_aHelpStrings.push_back( rStr );
    5810             :             }
    5811           0 :         }
    5812             :         // Data for second loop iteration
    5813           0 :         if ( i == 0 )
    5814           0 :             aNames = (*pCalendar)->getDays();
    5815             :     }
    5816             : 
    5817             :     // Add matching words from AutoCompleteWord list
    5818           0 :     const SwAutoCompleteWord& rACList = rSh.GetAutoCompleteWords();
    5819           0 :     std::vector<String> strings;
    5820             : 
    5821           0 :     if ( rACList.GetWordsMatching( rWord, strings, bIgnoreCurrentPos ) )
    5822             :     {
    5823           0 :         for (unsigned int i= 0; i<strings.size(); i++)
    5824             :         {
    5825           0 :             String aCompletedString = strings[i];
    5826           0 :             if ( aWordCase == CASE_LOWER )
    5827           0 :                 m_aHelpStrings.push_back( rCC.lowercase( aCompletedString ) );
    5828           0 :             else if ( aWordCase == CASE_SENTENCE )
    5829             :             {
    5830           0 :                 String sTmp = rCC.lowercase( aCompletedString );
    5831           0 :                 sTmp.SetChar( 0, aCompletedString.GetChar(0) );
    5832           0 :                 m_aHelpStrings.push_back( sTmp );
    5833             :             }
    5834           0 :             else if ( aWordCase == CASE_UPPER )
    5835           0 :                 m_aHelpStrings.push_back( rCC.uppercase( aCompletedString ) );
    5836             :             else // CASE_OTHER - use retrieved capitalization
    5837           0 :                 m_aHelpStrings.push_back( aCompletedString );
    5838           0 :         }
    5839           0 :     }
    5840             : 
    5841           0 : }
    5842             : 
    5843             : namespace {
    5844             : 
    5845             : struct CompareIgnoreCaseAscii
    5846             : {
    5847           0 :     bool operator()(const String& s1, const String& s2) const
    5848             :     {
    5849           0 :         return s1.CompareIgnoreCaseToAscii(s2) == COMPARE_LESS;
    5850             :     }
    5851             : };
    5852             : 
    5853             : struct EqualIgnoreCaseAscii
    5854             : {
    5855           0 :     bool operator()(const String& s1, const String& s2) const
    5856             :     {
    5857           0 :         return s1.CompareIgnoreCaseToAscii(s2) == COMPARE_EQUAL;
    5858             :     }
    5859             : };
    5860             : 
    5861             : } // anonymous namespace
    5862             : 
    5863             : // TODO - implement an i18n aware sort
    5864           0 : void QuickHelpData::SortAndFilter()
    5865             : {
    5866             :     std::sort( m_aHelpStrings.begin(),
    5867             :                m_aHelpStrings.end(),
    5868           0 :                CompareIgnoreCaseAscii() );
    5869             : 
    5870             :     std::vector<String>::iterator it = std::unique( m_aHelpStrings.begin(),
    5871             :                                                     m_aHelpStrings.end(),
    5872           0 :                                                     EqualIgnoreCaseAscii() );
    5873           0 :     m_aHelpStrings.erase( it, m_aHelpStrings.end() );
    5874             : 
    5875           0 :     nCurArrPos = 0;
    5876           0 : }
    5877             : 
    5878           0 : void SwEditWin::ShowAutoTextCorrectQuickHelp(
    5879             :         const String& rWord, SvxAutoCorrCfg* pACfg, SvxAutoCorrect* pACorr,
    5880             :         bool bFromIME )
    5881             : {
    5882           0 :     SwWrtShell& rSh = rView.GetWrtShell();
    5883           0 :     pQuickHlpData->ClearCntnt();
    5884           0 :     if( pACfg->IsAutoTextTip() )
    5885             :     {
    5886           0 :         SwGlossaryList* pList = ::GetGlossaryList();
    5887           0 :         pList->HasLongName( rWord, &pQuickHlpData->m_aHelpStrings );
    5888             :     }
    5889             : 
    5890           0 :     if( pQuickHlpData->m_aHelpStrings.empty() &&
    5891           0 :         pACorr->GetSwFlags().bAutoCompleteWords )
    5892             :     {
    5893           0 :         pQuickHlpData->m_bIsAutoText = false;
    5894             :         pQuickHlpData->m_bIsTip = bFromIME ||
    5895             :                     !pACorr ||
    5896           0 :                     pACorr->GetSwFlags().bAutoCmpltShowAsTip;
    5897             : 
    5898             :         // Get the neccessary data to show help text.
    5899           0 :         pQuickHlpData->FillStrArr( rSh, rWord, bFromIME );
    5900             :     }
    5901             : 
    5902             : 
    5903           0 :     if( !pQuickHlpData->m_aHelpStrings.empty() )
    5904             :     {
    5905           0 :         pQuickHlpData->SortAndFilter();
    5906           0 :         pQuickHlpData->Start( rSh, rWord.Len() );
    5907             :     }
    5908           0 : }
    5909             : 
    5910           0 : bool SwEditWin::IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const
    5911             : {
    5912           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    5913           0 :     const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( rDocPt );
    5914             : 
    5915           0 :     if ( pPageFrm && pPageFrm->IsOverHeaderFooterArea( rDocPt, rControl ) )
    5916           0 :         return true;
    5917             : 
    5918           0 :     if ( rSh.IsShowHeaderFooterSeparator( Header ) || rSh.IsShowHeaderFooterSeparator( Footer ) )
    5919             :     {
    5920           0 :         SwFrameControlsManager &rMgr = rSh.GetView().GetEditWin().GetFrameControlsManager();
    5921           0 :         Point aPoint( LogicToPixel( rDocPt ) );
    5922             : 
    5923           0 :         if ( rSh.IsShowHeaderFooterSeparator( Header ) )
    5924             :         {
    5925           0 :             SwFrameControlPtr pControl = rMgr.GetControl( Header, pPageFrm );
    5926           0 :             if ( pControl.get() && pControl->Contains( aPoint ) )
    5927             :             {
    5928           0 :                 rControl = Header;
    5929           0 :                 return true;
    5930           0 :             }
    5931             :         }
    5932             : 
    5933           0 :         if ( rSh.IsShowHeaderFooterSeparator( Footer ) )
    5934             :         {
    5935           0 :             SwFrameControlPtr pControl = rMgr.GetControl( Footer, pPageFrm );
    5936           0 :             if ( pControl.get() && pControl->Contains( aPoint ) )
    5937             :             {
    5938           0 :                 rControl = Footer;
    5939           0 :                 return true;
    5940           0 :             }
    5941             :         }
    5942             :     }
    5943             : 
    5944           0 :     return false;
    5945             : }
    5946             : 
    5947           0 : bool SwEditWin::IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const
    5948             : {
    5949           0 :     bool bRet = false;
    5950           0 :     Point aPt( rDocPos );
    5951           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    5952           0 :     SwPaM aPam( *rSh.GetCurrentShellCursor().GetPoint() );
    5953           0 :     rSh.GetLayout()->GetCrsrOfst( aPam.GetPoint(), aPt, NULL, true );
    5954             : 
    5955           0 :     const SwStartNode* pStartFly = aPam.GetPoint()->nNode.GetNode().FindFlyStartNode();
    5956           0 :     if ( pStartFly )
    5957             :     {
    5958           0 :         bOverFly = true;
    5959           0 :         SwFrmFmt* pFlyFmt = pStartFly->GetFlyFmt( );
    5960           0 :         if ( pFlyFmt )
    5961             :         {
    5962           0 :             const SwPosition* pAnchor = pFlyFmt->GetAnchor( ).GetCntntAnchor( );
    5963           0 :             if ( pAnchor )
    5964             :             {
    5965           0 :                 bool bInHeader = pAnchor->nNode.GetNode( ).FindHeaderStartNode( ) != NULL;
    5966           0 :                 bool bInFooter = pAnchor->nNode.GetNode( ).FindFooterStartNode( ) != NULL;
    5967             : 
    5968           0 :                 bRet = bInHeader || bInFooter;
    5969           0 :                 if ( bInHeader )
    5970           0 :                     rControl = Header;
    5971           0 :                 else if ( bInFooter )
    5972           0 :                     rControl = Footer;
    5973             :             }
    5974             :             else
    5975           0 :                 bPageAnchored = pFlyFmt->GetAnchor( ).GetAnchorId( ) == FLY_AT_PAGE;
    5976             :         }
    5977             :     }
    5978             :     else
    5979           0 :         bOverFly = false;
    5980           0 :     return bRet;
    5981             : }
    5982             : 
    5983           0 : void SwEditWin::SetUseInputLanguage( sal_Bool bNew )
    5984             : {
    5985           0 :     if ( bNew || bUseInputLanguage )
    5986             :     {
    5987           0 :         SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
    5988           0 :         rBind.Invalidate( SID_ATTR_CHAR_FONT );
    5989           0 :         rBind.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
    5990             :     }
    5991           0 :     bUseInputLanguage = bNew;
    5992           0 : }
    5993             : 
    5994           0 : rtl::OUString SwEditWin::GetSurroundingText() const
    5995             : {
    5996           0 :     String sReturn;
    5997           0 :     SwWrtShell& rSh = rView.GetWrtShell();
    5998           0 :     if( rSh.HasSelection() && !rSh.IsMultiSelection() && rSh.IsSelOnePara() )
    5999           0 :         rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR  );
    6000           0 :     else if( !rSh.HasSelection() )
    6001             :     {
    6002           0 :         SwPosition *pPos = rSh.GetCrsr()->GetPoint();
    6003           0 :         xub_StrLen nPos = pPos->nContent.GetIndex();
    6004             : 
    6005             :         // get the sentence around the cursor
    6006           0 :         rSh.HideCrsr();
    6007           0 :         rSh.GoStartSentence();
    6008           0 :         rSh.SetMark();
    6009           0 :         rSh.GoEndSentence();
    6010           0 :         rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR  );
    6011             : 
    6012           0 :         pPos->nContent = nPos;
    6013           0 :         rSh.ClearMark();
    6014           0 :         rSh.HideCrsr();
    6015             :     }
    6016             : 
    6017           0 :     return sReturn;
    6018             : }
    6019             : 
    6020           0 : Selection SwEditWin::GetSurroundingTextSelection() const
    6021             : {
    6022           0 :     SwWrtShell& rSh = rView.GetWrtShell();
    6023           0 :     if( rSh.HasSelection() )
    6024             :     {
    6025           0 :         String sReturn;
    6026           0 :         rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR  );
    6027           0 :         return Selection( 0, sReturn.Len() );
    6028             :     }
    6029             :     else
    6030             :     {
    6031             :         // Return the position of the visible cursor in the sentence
    6032             :         // around the visible cursor.
    6033           0 :         SwPosition *pPos = rSh.GetCrsr()->GetPoint();
    6034           0 :         xub_StrLen nPos = pPos->nContent.GetIndex();
    6035             : 
    6036           0 :         rSh.HideCrsr();
    6037           0 :         rSh.GoStartSentence();
    6038           0 :         xub_StrLen nStartPos = rSh.GetCrsr()->GetPoint()->nContent.GetIndex();
    6039             : 
    6040           0 :         pPos->nContent = nPos;
    6041           0 :         rSh.ClearMark();
    6042           0 :         rSh.ShowCrsr();
    6043             : 
    6044           0 :         return Selection( nPos - nStartPos, nPos - nStartPos );
    6045             :     }
    6046          30 : }
    6047             : 
    6048             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10