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-17 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          24 : Color   SwEditWin::aTextBackColor(COL_YELLOW);
     184          24 : 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          24 : 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          24 :     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         482 : void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier )
     327             : {
     328         482 :     SwWrtShell &rSh = rView.GetWrtShell();
     329         482 :     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         482 :     if( !rSh.VisArea().Width() )
     376             :         return;
     377             : 
     378         295 :     SET_CURR_SHELL(&rSh);
     379             : 
     380         295 :     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         295 :     sal_Bool bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
     406         295 :     if ( !bExecHyperlinks )
     407             :     {
     408         295 :         SvtSecurityOptions aSecOpts;
     409         295 :         const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
     410         295 :         if ( (  bSecureOption && nModifier == KEY_MOD1 ) ||
     411             :              ( !bSecureOption && nModifier != KEY_MOD1 ) )
     412           0 :             bExecHyperlinks = sal_True;
     413             :     }
     414             : 
     415         295 :     const sal_Bool bExecSmarttags  = nModifier == KEY_MOD1;
     416             : 
     417         295 :     SdrView *pSdrView = rSh.GetDrawView();
     418         295 :     sal_Bool bPrefSdrPointer = sal_False;
     419         295 :     sal_Bool bHitHandle = sal_False;
     420         295 :     sal_Bool bCntAtPos = sal_False;
     421         295 :     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
     422         295 :                           rSh.IsCrsrReadonly();
     423         295 :     aActHitType = SDRHIT_NONE;
     424         295 :     PointerStyle eStyle = POINTER_TEXT;
     425         295 :     if ( !pSdrView )
     426           0 :         bCntAtPos = sal_True;
     427         295 :     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         295 :         const sal_Bool bNotInSelObj = !rSh.IsInsideSelectedObj( rLPt );
     435         295 :         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         295 :             pSdrView->SetHitTolerancePixel( HIT_PIX );
     447         295 :             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         295 :                 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         295 :                     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         295 :                         if ( rView.GetDrawFuncPtr() )
     518           0 :                             bPrefSdrPointer = sal_True;
     519             :                         else
     520         295 :                             bCntAtPos = sal_True;
     521             :                     }
     522             :                 }
     523             :             }
     524             :         }
     525             :     }
     526         295 :     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         295 :         if( !rSh.IsPageAtPos( rLPt ) || pAnchorMarker )
     541         295 :             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         295 :         if( POINTER_TEXT == eStyle && rSh.IsInVerticalText( &rLPt ))
     568           0 :             eStyle = POINTER_TEXT_VERTICAL;
     569             : 
     570         295 :         SetPointer( eStyle );
     571         295 :     }
     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             :                         // if the cursor position was corrected or if a Fly
    3277             :                         // was selected in ReadOnlyMode, no word selection.
    3278           0 :                         if ( !bValidCrsrPos ||
    3279           0 :                             (rSh.IsFrmSelected() && rSh.IsFrmSelected() ))
    3280             :                             return;
    3281             : 
    3282             :                         SwField *pFld;
    3283           0 :                         sal_Bool bFtn = sal_False;
    3284             : 
    3285           0 :                         if( !bIsDocReadOnly &&
    3286           0 :                             ( 0 != ( pFld = rSh.GetCurFld() ) ||
    3287           0 :                               0 != ( bFtn = rSh.GetCurFtn() )) )
    3288             :                         {
    3289           0 :                             RstMBDownFlags();
    3290           0 :                             if( bFtn )
    3291           0 :                                 GetView().GetViewFrame()->GetBindings().Execute( FN_EDIT_FOOTNOTE );
    3292             :                             else
    3293             :                             {
    3294           0 :                                 sal_uInt16 nTypeId = pFld->GetTypeId();
    3295           0 :                                 SfxViewFrame* pVFrame = GetView().GetViewFrame();
    3296           0 :                                 switch( nTypeId )
    3297             :                                 {
    3298             :                                 case TYP_POSTITFLD:
    3299             :                                 case TYP_SCRIPTFLD:
    3300             :                                 {
    3301             :                                     // if it's a Readonly region, status has to be enabled
    3302           0 :                                     sal_uInt16 nSlot = TYP_POSTITFLD == nTypeId ? FN_POSTIT : FN_JAVAEDIT;
    3303           0 :                                     SfxBoolItem aItem(nSlot, sal_True);
    3304           0 :                                     pVFrame->GetBindings().SetState(aItem);
    3305           0 :                                     pVFrame->GetBindings().Execute(nSlot);
    3306           0 :                                     break;
    3307             :                                 }
    3308             :                                 case TYP_AUTHORITY :
    3309           0 :                                     pVFrame->GetBindings().Execute(FN_EDIT_AUTH_ENTRY_DLG);
    3310           0 :                                 break;
    3311             :                                 default:
    3312           0 :                                     pVFrame->GetBindings().Execute(FN_EDIT_FIELD);
    3313             :                                 }
    3314             :                             }
    3315             :                             return;
    3316             :                         }
    3317             :                         // in extended mode double and triple
    3318             :                         // click has no effect.
    3319           0 :                         if ( rSh.IsExtMode() || rSh.IsBlockMode() )
    3320             :                             return;
    3321             : 
    3322             :                         // select work, AdditionalMode if applicable
    3323           0 :                         if ( KEY_MOD1 == rMEvt.GetModifier() && !rSh.IsAddMode() )
    3324             :                         {
    3325           0 :                             rSh.EnterAddMode();
    3326           0 :                             rSh.SelWrd( &aDocPos );
    3327           0 :                             rSh.LeaveAddMode();
    3328             :                         }
    3329             :                         else
    3330           0 :                             rSh.SelWrd( &aDocPos );
    3331           0 :                         bHoldSelection = sal_True;
    3332             :                         return;
    3333             :                     }
    3334             :                     case 3:
    3335             :                     case 4:
    3336             :                     {
    3337           0 :                         bFrmDrag = sal_False;
    3338             :                         // in extended mode double and triple
    3339             :                         // click has no effect.
    3340           0 :                         if ( rSh.IsExtMode() )
    3341             :                             return;
    3342             : 
    3343             :                         // if the cursor position was corrected or if a Fly
    3344             :                         // was selected in ReadOnlyMode, no word selection.
    3345           0 :                         if ( !bValidCrsrPos || rSh.IsFrmSelected() )
    3346             :                             return;
    3347             : 
    3348             :                         // select line, AdditionalMode if applicable
    3349           0 :                         const bool bMod = KEY_MOD1 == rMEvt.GetModifier() &&
    3350           0 :                                          !rSh.IsAddMode();
    3351             : 
    3352           0 :                         if ( bMod )
    3353           0 :                             rSh.EnterAddMode();
    3354             : 
    3355           0 :                         if ( 3 == nNumberOfClicks )
    3356           0 :                             rSh.SelSentence( &aDocPos );
    3357             :                         else
    3358           0 :                             rSh.SelPara( &aDocPos );
    3359             : 
    3360           0 :                         if ( bMod )
    3361           0 :                             rSh.LeaveAddMode();
    3362             : 
    3363           0 :                         bHoldSelection = sal_True;
    3364             :                         return;
    3365             :                     }
    3366             : 
    3367             :                     default:
    3368             :                         return;
    3369             :                 }
    3370             :             }
    3371             :                 /* no break */
    3372             :             case MOUSE_LEFT + KEY_SHIFT:
    3373             :             case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
    3374             :             {
    3375           0 :                 sal_Bool bLockView = bWasShdwCrsr;
    3376             : 
    3377           0 :                 switch ( rMEvt.GetModifier() )
    3378             :                 {
    3379             :                     case KEY_MOD1 + KEY_SHIFT:
    3380             :                     {
    3381           0 :                         if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
    3382             :                         {
    3383           0 :                             rView.NoRotate();
    3384           0 :                             rSh.HideCrsr();
    3385           0 :                             if ( rSh.IsSelFrmMode() )
    3386           0 :                                 rSh.SelectObj(aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP);
    3387             :                             else
    3388           0 :                             {   if ( rSh.SelectObj( aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP ) )
    3389             :                                 {
    3390           0 :                                     rSh.EnterSelFrmMode( &aDocPos );
    3391           0 :                                     SwEditWin::nDDStartPosY = aDocPos.Y();
    3392           0 :                                     SwEditWin::nDDStartPosX = aDocPos.X();
    3393           0 :                                     bFrmDrag = sal_True;
    3394             :                                     return;
    3395             :                                 }
    3396             :                             }
    3397             :                         }
    3398           0 :                         else if( rSh.IsSelFrmMode() &&
    3399           0 :                                  rSh.GetDrawView()->PickHandle( aDocPos ))
    3400             :                         {
    3401           0 :                             bFrmDrag = sal_True;
    3402           0 :                             bNoInterrupt = sal_False;
    3403             :                             return;
    3404             :                         }
    3405             :                     }
    3406           0 :                     break;
    3407             :                     case KEY_MOD1:
    3408           0 :                     if ( !bExecDrawTextLink )
    3409             :                     {
    3410           0 :                         if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) && !lcl_urlOverBackground( rSh, aDocPos ) )
    3411             :                         {
    3412           0 :                             rView.NoRotate();
    3413           0 :                             rSh.HideCrsr();
    3414           0 :                             if ( rSh.IsSelFrmMode() )
    3415           0 :                                 rSh.SelectObj(aDocPos, SW_ENTER_GROUP);
    3416             :                             else
    3417           0 :                             {   if ( rSh.SelectObj( aDocPos, SW_ENTER_GROUP ) )
    3418             :                                 {
    3419           0 :                                     rSh.EnterSelFrmMode( &aDocPos );
    3420           0 :                                     SwEditWin::nDDStartPosY = aDocPos.Y();
    3421           0 :                                     SwEditWin::nDDStartPosX = aDocPos.X();
    3422           0 :                                     bFrmDrag = sal_True;
    3423             :                                     return;
    3424             :                                 }
    3425             :                             }
    3426             :                         }
    3427           0 :                         else if( rSh.IsSelFrmMode() &&
    3428           0 :                                  rSh.GetDrawView()->PickHandle( aDocPos ))
    3429             :                         {
    3430           0 :                             bFrmDrag = sal_True;
    3431           0 :                             bNoInterrupt = sal_False;
    3432             :                             return;
    3433             :                         }
    3434             :                         else
    3435             :                         {
    3436           0 :                             if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
    3437             :                             {
    3438           0 :                                 rSh.PushMode();
    3439           0 :                                 bModePushed = sal_True;
    3440             : 
    3441           0 :                                 sal_Bool bUnLockView = !rSh.IsViewLocked();
    3442           0 :                                 rSh.LockView( sal_True );
    3443           0 :                                 rSh.EnterAddMode();
    3444           0 :                                 if( bUnLockView )
    3445           0 :                                     rSh.LockView( sal_False );
    3446             :                             }
    3447           0 :                             bCallBase = sal_False;
    3448             :                         }
    3449             :                     }
    3450           0 :                     break;
    3451             :                     case KEY_MOD2:
    3452             :                     {
    3453           0 :                         if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
    3454             :                         {
    3455           0 :                             rSh.PushMode();
    3456           0 :                             bModePushed = sal_True;
    3457           0 :                             sal_Bool bUnLockView = !rSh.IsViewLocked();
    3458           0 :                             rSh.LockView( sal_True );
    3459           0 :                             rSh.EnterBlockMode();
    3460           0 :                             if( bUnLockView )
    3461           0 :                                 rSh.LockView( sal_False );
    3462             :                         }
    3463           0 :                         bCallBase = sal_False;
    3464             :                     }
    3465           0 :                     break;
    3466             :                     case KEY_SHIFT:
    3467             :                     {
    3468           0 :                         if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
    3469             :                         {
    3470           0 :                             rView.NoRotate();
    3471           0 :                             rSh.HideCrsr();
    3472           0 :                             if ( rSh.IsSelFrmMode() )
    3473             :                             {
    3474           0 :                                 rSh.SelectObj(aDocPos, SW_ADD_SELECT);
    3475             : 
    3476           0 :                                 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
    3477           0 :                                 if (rMarkList.GetMark(0) == NULL)
    3478             :                                 {
    3479           0 :                                     rSh.LeaveSelFrmMode();
    3480           0 :                                     rView.AttrChangedNotify(&rSh);
    3481           0 :                                     bFrmDrag = sal_False;
    3482             :                                 }
    3483             :                             }
    3484             :                             else
    3485           0 :                             {   if ( rSh.SelectObj( aDocPos ) )
    3486             :                                 {
    3487           0 :                                     rSh.EnterSelFrmMode( &aDocPos );
    3488           0 :                                     SwEditWin::nDDStartPosY = aDocPos.Y();
    3489           0 :                                     SwEditWin::nDDStartPosX = aDocPos.X();
    3490           0 :                                     bFrmDrag = sal_True;
    3491             :                                     return;
    3492             :                                 }
    3493             :                             }
    3494             :                         }
    3495             :                         else
    3496             :                         {
    3497           0 :                             if ( rSh.IsSelFrmMode() &&
    3498           0 :                                  rSh.IsInsideSelectedObj( aDocPos ) )
    3499             :                             {
    3500           0 :                                 rSh.EnterSelFrmMode( &aDocPos );
    3501           0 :                                 SwEditWin::nDDStartPosY = aDocPos.Y();
    3502           0 :                                 SwEditWin::nDDStartPosX = aDocPos.X();
    3503           0 :                                 bFrmDrag = sal_True;
    3504             :                                 return;
    3505             :                             }
    3506           0 :                             if ( rSh.IsSelFrmMode() )
    3507             :                             {
    3508           0 :                                 rSh.UnSelectFrm();
    3509           0 :                                 rSh.LeaveSelFrmMode();
    3510           0 :                                 rView.AttrChangedNotify(&rSh);
    3511           0 :                                 bFrmDrag = sal_False;
    3512             :                             }
    3513           0 :                             if ( !rSh.IsExtMode() )
    3514             :                             {
    3515             :                                 // don't start a selection when an
    3516             :                                 // URL field or a graphic is clicked
    3517           0 :                                 sal_Bool bSttSelect = rSh.HasSelection() ||
    3518           0 :                                                 Pointer(POINTER_REFHAND) != GetPointer();
    3519             : 
    3520           0 :                                 if( !bSttSelect )
    3521             :                                 {
    3522           0 :                                     bSttSelect = sal_True;
    3523           0 :                                     if( bExecHyperlinks )
    3524             :                                     {
    3525             :                                         SwContentAtPos aCntntAtPos(
    3526             :                                             SwContentAtPos::SW_FTN |
    3527           0 :                                             SwContentAtPos::SW_INETATTR );
    3528             : 
    3529           0 :                                         if( rSh.GetContentAtPos( aDocPos, aCntntAtPos ) )
    3530             :                                         {
    3531           0 :                                             if( !rSh.IsViewLocked() &&
    3532           0 :                                                 !rSh.IsReadOnlyAvailable() &&
    3533           0 :                                                 aCntntAtPos.IsInProtectSect() )
    3534           0 :                                                     bLockView = sal_True;
    3535             : 
    3536           0 :                                             bSttSelect = sal_False;
    3537             :                                         }
    3538           0 :                                         else if( rSh.IsURLGrfAtPos( aDocPos ))
    3539           0 :                                             bSttSelect = sal_False;
    3540             :                                     }
    3541             :                                 }
    3542             : 
    3543           0 :                                 if( bSttSelect )
    3544           0 :                                     rSh.SttSelect();
    3545             :                             }
    3546             :                         }
    3547           0 :                         bCallBase = sal_False;
    3548           0 :                         break;
    3549             :                     }
    3550             :                     default:
    3551           0 :                         if( !rSh.IsViewLocked() )
    3552             :                         {
    3553             :                             SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD |
    3554           0 :                                                         SwContentAtPos::SW_INETATTR );
    3555           0 :                             if( rSh.GetContentAtPos( aDocPos, aCntntAtPos, sal_False ) &&
    3556           0 :                                 !rSh.IsReadOnlyAvailable() &&
    3557           0 :                                 aCntntAtPos.IsInProtectSect() )
    3558           0 :                                 bLockView = sal_True;
    3559             :                         }
    3560             :                 }
    3561             : 
    3562           0 :                 if ( rSh.IsGCAttr() )
    3563             :                 {
    3564           0 :                     rSh.GCAttr();
    3565           0 :                     rSh.ClearGCAttr();
    3566             :                 }
    3567             : 
    3568           0 :                 sal_Bool bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = sal_False;
    3569           0 :                 if( !bOverSelect )
    3570           0 :                     bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos );
    3571             : 
    3572           0 :                 if ( !bOverSelect )
    3573             :                 {
    3574           0 :                     const sal_Bool bTmpNoInterrupt = bNoInterrupt;
    3575           0 :                     bNoInterrupt = sal_False;
    3576             : 
    3577           0 :                     if( !rSh.IsViewLocked() && bLockView )
    3578           0 :                         rSh.LockView( sal_True );
    3579             :                     else
    3580           0 :                         bLockView = sal_False;
    3581             : 
    3582           0 :                     int nTmpSetCrsr = 0;
    3583             : 
    3584             :                     {   // only temporary generate Move-Kontext because otherwise
    3585             :                         // the query to the content form doesn't work!!!
    3586           0 :                         SwMvContext aMvContext( &rSh );
    3587           0 :                         nTmpSetCrsr = rSh.SetCursor(&aDocPos, bOnlyText);
    3588           0 :                         bValidCrsrPos = !(CRSR_POSCHG & nTmpSetCrsr);
    3589           0 :                         bCallBase = sal_False;
    3590             :                     }
    3591             : 
    3592             :                     // notify the edit window that from now on we do not use the input language
    3593           0 :                     if ( !(CRSR_POSOLD & nTmpSetCrsr) )
    3594           0 :                         SetUseInputLanguage( sal_False );
    3595             : 
    3596           0 :                     if( bLockView )
    3597           0 :                         rSh.LockView( sal_False );
    3598             : 
    3599           0 :                     bNoInterrupt = bTmpNoInterrupt;
    3600             :                 }
    3601           0 :                 if ( !bOverURLGrf && !bOnlyText )
    3602             :                 {
    3603           0 :                     const int nSelType = rSh.GetSelectionType();
    3604             :                     // Check in general, if an object is selectable at given position.
    3605             :                     // Thus, also text fly frames in background become selectable via Ctrl-Click.
    3606           0 :                     if ( ( nSelType & nsSelectionType::SEL_OLE ||
    3607             :                          nSelType & nsSelectionType::SEL_GRF ||
    3608           0 :                          rSh.IsObjSelectable( aDocPos ) ) && !lcl_urlOverBackground( rSh, aDocPos ) )
    3609             :                     {
    3610           0 :                         SwMvContext aMvContext( &rSh );
    3611           0 :                         if( !rSh.IsFrmSelected() )
    3612           0 :                             rSh.GotoNextFly();
    3613           0 :                         rSh.EnterSelFrmMode();
    3614           0 :                         bCallBase = sal_False;
    3615             :                     }
    3616             :                 }
    3617             :                 // don't reset here any longer so that, in case through MouseMove
    3618             :                 // with pressed Ctrl key a multiple-selection should happen,
    3619             :                 // the previous selection is not released in Drag.
    3620           0 :                 break;
    3621             :             }
    3622             :         }
    3623             :     }
    3624           0 :     if (bCallBase)
    3625           0 :         Window::MouseButtonDown(rMEvt);
    3626             : }
    3627             : 
    3628             : /*--------------------------------------------------------------------
    3629             :     Description:   MouseMove
    3630             :  --------------------------------------------------------------------*/
    3631             : 
    3632           0 : void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
    3633             : {
    3634           0 :     MouseEvent rMEvt(_rMEvt);
    3635             : 
    3636             :     //ignore key modifiers for format paintbrush
    3637             :     {
    3638             :         sal_Bool bExecFormatPaintbrush = pApplyTempl && pApplyTempl->pFormatClipboard
    3639           0 :                                 &&  pApplyTempl->pFormatClipboard->HasContent();
    3640           0 :         if( bExecFormatPaintbrush )
    3641           0 :             rMEvt = MouseEvent( _rMEvt.GetPosPixel(), _rMEvt.GetClicks(),
    3642           0 :                                     _rMEvt.GetMode(), _rMEvt.GetButtons() );
    3643             :     }
    3644             : 
    3645             :     // as long as an action is running the MouseMove should be disconnected
    3646             :     // otherwise bug 40102 occurs
    3647           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    3648           0 :     if( rSh.ActionPend() )
    3649             :         return ;
    3650             : 
    3651           0 :     if( pShadCrsr && 0 != (rMEvt.GetModifier() + rMEvt.GetButtons() ) )
    3652           0 :         delete pShadCrsr, pShadCrsr = 0;
    3653             : 
    3654           0 :     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly();
    3655             : 
    3656           0 :     SET_CURR_SHELL( &rSh );
    3657             : 
    3658             :     //aPixPt == Point in Pixel, relative to ChildWin
    3659             :     //aDocPt == Point in Twips, document coordinates
    3660           0 :     const Point aPixPt( rMEvt.GetPosPixel() );
    3661           0 :     const Point aDocPt( PixelToLogic( aPixPt ) );
    3662             : 
    3663           0 :     if ( IsChainMode() )
    3664             :     {
    3665           0 :         UpdatePointer( aDocPt, rMEvt.GetModifier() );
    3666             :         return;
    3667             :     }
    3668             : 
    3669           0 :     SdrView *pSdrView = rSh.GetDrawView();
    3670             : 
    3671           0 :     const SwCallMouseEvent aLastCallEvent( aSaveCallEvent );
    3672           0 :     aSaveCallEvent.Clear();
    3673             : 
    3674           0 :     if ( !bIsDocReadOnly && pSdrView && pSdrView->MouseMove(rMEvt,this) )
    3675             :     {
    3676           0 :         SetPointer( POINTER_TEXT );
    3677             :         return; // evaluate SdrView's event
    3678             :     }
    3679             : 
    3680           0 :     const Point aOldPt( rSh.VisArea().Pos() );
    3681           0 :     const sal_Bool bInsWin = rSh.VisArea().IsInside( aDocPt );
    3682             : 
    3683           0 :     if( pShadCrsr && !bInsWin )
    3684           0 :         delete pShadCrsr, pShadCrsr = 0;
    3685             : 
    3686           0 :     if( bInsWin && pRowColumnSelectionStart )
    3687             :     {
    3688           0 :         EnterArea();
    3689           0 :         Point aPos( aDocPt );
    3690           0 :         if( rSh.SelectTableRowCol( *pRowColumnSelectionStart, &aPos, bIsRowDrag ))
    3691             :             return;
    3692             :     }
    3693             : 
    3694             :     // position is necessary for OS/2 because obviously after a MB-Down
    3695             :     // a MB-Move is called immediately.
    3696           0 :     if( bDDTimerStarted )
    3697             :     {
    3698           0 :         Point aDD( SwEditWin::nDDStartPosX, SwEditWin::nDDStartPosY );
    3699           0 :         aDD = LogicToPixel( aDD );
    3700           0 :         Rectangle aRect( aDD.X()-3, aDD.Y()-3, aDD.X()+3, aDD.Y()+3 );
    3701           0 :         if ( !aRect.IsInside( aPixPt ) )
    3702           0 :             StopDDTimer( &rSh, aDocPt );
    3703             :     }
    3704             : 
    3705           0 :     if(rView.GetDrawFuncPtr())
    3706             :     {
    3707           0 :         if( bInsDraw  )
    3708             :         {
    3709           0 :             rView.GetDrawFuncPtr()->MouseMove( rMEvt );
    3710           0 :             if ( !bInsWin )
    3711             :             {
    3712           0 :                 Point aTmp( aDocPt );
    3713           0 :                 aTmp += rSh.VisArea().Pos() - aOldPt;
    3714           0 :                 LeaveArea( aTmp );
    3715             :             }
    3716             :             else
    3717           0 :                 EnterArea();
    3718             :             return;
    3719             :         }
    3720           0 :         else if(!rSh.IsFrmSelected() && !rSh.IsObjSelected())
    3721             :         {
    3722           0 :             SfxBindings &rBnd = rSh.GetView().GetViewFrame()->GetBindings();
    3723           0 :             Point aRelPos = rSh.GetRelativePagePosition(aDocPt);
    3724           0 :             if(aRelPos.X() >= 0)
    3725             :             {
    3726           0 :                 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
    3727           0 :                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
    3728           0 :                 const SfxPointItem aTmp1( SID_ATTR_POSITION, aRelPos );
    3729           0 :                 rBnd.SetState( aTmp1 );
    3730             :             }
    3731             :             else
    3732             :             {
    3733           0 :                 rBnd.Invalidate(SID_ATTR_POSITION);
    3734             :             }
    3735           0 :             rBnd.Invalidate(SID_ATTR_SIZE);
    3736           0 :             const SfxStringItem aCell( SID_TABLE_CELL, aEmptyStr );
    3737           0 :             rBnd.SetState( aCell );
    3738             :         }
    3739             :     }
    3740             : 
    3741             :     sal_uInt8 nMouseTabCol;
    3742           0 :     if( !bIsDocReadOnly && bInsWin && !pApplyTempl && !rSh.IsInSelect() )
    3743             :     {
    3744           0 :         if ( SW_TABCOL_NONE != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPt ) ) &&
    3745           0 :              !rSh.IsObjSelectable( aDocPt ) )
    3746             :         {
    3747           0 :             sal_uInt16 nPointer = USHRT_MAX;
    3748           0 :             bool bChkTblSel = false;
    3749             : 
    3750           0 :             switch ( nMouseTabCol )
    3751             :             {
    3752             :                 case SW_TABCOL_VERT :
    3753             :                 case SW_TABROW_HORI :
    3754           0 :                     nPointer = POINTER_VSIZEBAR;
    3755           0 :                     bChkTblSel = true;
    3756           0 :                     break;
    3757             :                 case SW_TABROW_VERT :
    3758             :                 case SW_TABCOL_HORI :
    3759           0 :                     nPointer = POINTER_HSIZEBAR;
    3760           0 :                     bChkTblSel = true;
    3761           0 :                     break;
    3762             :                 case SW_TABSEL_HORI :
    3763           0 :                     nPointer = POINTER_TAB_SELECT_SE;
    3764           0 :                     break;
    3765             :                 case SW_TABSEL_HORI_RTL :
    3766             :                 case SW_TABSEL_VERT :
    3767           0 :                     nPointer = POINTER_TAB_SELECT_SW;
    3768           0 :                     break;
    3769             :                 case SW_TABCOLSEL_HORI :
    3770             :                 case SW_TABROWSEL_VERT :
    3771           0 :                     nPointer = POINTER_TAB_SELECT_S;
    3772           0 :                     break;
    3773             :                 case SW_TABROWSEL_HORI :
    3774           0 :                     nPointer = POINTER_TAB_SELECT_E;
    3775           0 :                     break;
    3776             :                 case SW_TABROWSEL_HORI_RTL :
    3777             :                 case SW_TABCOLSEL_VERT :
    3778           0 :                     nPointer = POINTER_TAB_SELECT_W;
    3779           0 :                     break;
    3780             :             }
    3781             : 
    3782           0 :             if ( USHRT_MAX != nPointer &&
    3783             :                 // i#35543 - Enhanced table selection is explicitly allowed in table mode
    3784           0 :                 ( !bChkTblSel || !rSh.IsTableMode() ) )
    3785             :             {
    3786           0 :                 SetPointer( nPointer );
    3787             :             }
    3788             : 
    3789             :             return;
    3790             :         }
    3791           0 :         else if (rSh.IsNumLabel(aDocPt, RULER_MOUSE_MARGINWIDTH))
    3792             :         {
    3793             :             // i#42921 - consider vertical mode
    3794           0 :             SwTxtNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPt );
    3795             :             const sal_uInt16 nPointer =
    3796           0 :                     rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPt )
    3797             :                     ? POINTER_VSIZEBAR
    3798           0 :                     : POINTER_HSIZEBAR;
    3799           0 :             SetPointer( nPointer );
    3800             : 
    3801             :             return;
    3802             :         }
    3803             :     }
    3804             : 
    3805           0 :     sal_Bool bDelShadCrsr = sal_True;
    3806             : 
    3807           0 :     switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
    3808             :     {
    3809             :         case MOUSE_LEFT:
    3810           0 :             if( pAnchorMarker )
    3811             :             {
    3812             :                 // Now we need to refresh the SdrHdl pointer of pAnchorMarker.
    3813             :                 // This looks a little bit tricky, but it solves the following
    3814             :                 // problem: the pAnchorMarker contains a pointer to an SdrHdl,
    3815             :                 // if the FindAnchorPos-call cause a scrolling of the visible
    3816             :                 // area, it's possible that the SdrHdl will be destroyed and a
    3817             :                 // new one will initialized at the original position(GetHdlPos).
    3818             :                 // So the pAnchorMarker has to find the right SdrHdl, if it's
    3819             :                 // the old one, it will find it with position aOld, if this one
    3820             :                 // is destroyed, it will find a new one at position GetHdlPos().
    3821             : 
    3822           0 :                 const Point aOld = pAnchorMarker->GetPosForHitTest( *(rSh.GetOut()) );
    3823           0 :                 Point aNew = rSh.FindAnchorPos( aDocPt );
    3824             :                 SdrHdl* pHdl;
    3825           0 :                 if( (0!=( pHdl = pSdrView->PickHandle( aOld ) )||
    3826           0 :                     0 !=(pHdl = pSdrView->PickHandle( pAnchorMarker->GetHdlPos()) ) ) &&
    3827           0 :                         ( pHdl->GetKind() == HDL_ANCHOR ||
    3828           0 :                           pHdl->GetKind() == HDL_ANCHOR_TR ) )
    3829             :                 {
    3830           0 :                     pAnchorMarker->ChgHdl( pHdl );
    3831           0 :                     if( aNew.X() || aNew.Y() )
    3832             :                     {
    3833           0 :                         pAnchorMarker->SetPos( aNew );
    3834           0 :                         pAnchorMarker->SetLastPos( aDocPt );
    3835             :                     }
    3836             :                 }
    3837             :                 else
    3838             :                 {
    3839           0 :                     delete pAnchorMarker;
    3840           0 :                     pAnchorMarker = NULL;
    3841             :                 }
    3842             :             }
    3843           0 :             if ( bInsDraw )
    3844             :             {
    3845           0 :                 if ( !bMBPressed )
    3846           0 :                     break;
    3847           0 :                 if ( bIsInMove || IsMinMove( aStartPos, aPixPt ) )
    3848             :                 {
    3849           0 :                     if ( !bInsWin )
    3850           0 :                         LeaveArea( aDocPt );
    3851             :                     else
    3852           0 :                         EnterArea();
    3853           0 :                     if ( rView.GetDrawFuncPtr() )
    3854             :                     {
    3855           0 :                         pSdrView->SetOrtho(sal_False);
    3856           0 :                         rView.GetDrawFuncPtr()->MouseMove( rMEvt );
    3857             :                     }
    3858           0 :                     bIsInMove = sal_True;
    3859             :                 }
    3860             :                 return;
    3861             :             }
    3862             : 
    3863             :             {
    3864           0 :             SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
    3865           0 :             if (pWrdCnt)
    3866           0 :                 pWrdCnt->UpdateCounts();
    3867             :             }
    3868             : 
    3869             :         case MOUSE_LEFT + KEY_SHIFT:
    3870             :         case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
    3871           0 :             if ( !bMBPressed )
    3872           0 :                 break;
    3873             :         case MOUSE_LEFT + KEY_MOD1:
    3874           0 :             if ( bFrmDrag && rSh.IsSelFrmMode() )
    3875             :             {
    3876           0 :                 if( !bMBPressed )
    3877           0 :                     break;
    3878             : 
    3879           0 :                 if ( bIsInMove || IsMinMove( aStartPos, aPixPt ) )
    3880             :                 {
    3881             :                     // event processing for resizing
    3882           0 :                     if( pSdrView->AreObjectsMarked() )
    3883             :                     {
    3884             :                         const SwFrmFmt* pFlyFmt;
    3885             :                         const SvxMacro* pMacro;
    3886             : 
    3887           0 :                         const Point aSttPt( PixelToLogic( aStartPos ) );
    3888             : 
    3889             :                         // can we start?
    3890           0 :                         if( HDL_USER == eSdrMoveHdl )
    3891             :                         {
    3892           0 :                             SdrHdl* pHdl = pSdrView->PickHandle( aSttPt );
    3893           0 :                             eSdrMoveHdl = pHdl ? pHdl->GetKind() : HDL_MOVE;
    3894             :                         }
    3895             : 
    3896             :                         sal_uInt16 nEvent = HDL_MOVE == eSdrMoveHdl
    3897             :                                             ? SW_EVENT_FRM_MOVE
    3898           0 :                                             : SW_EVENT_FRM_RESIZE;
    3899             : 
    3900           0 :                         if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) &&
    3901           0 :                             0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable().
    3902           0 :                             Get( nEvent )) &&
    3903             : // or notify only e.g. every 20 Twip?
    3904           0 :                             aRszMvHdlPt != aDocPt )
    3905             :                         {
    3906           0 :                             aRszMvHdlPt = aDocPt;
    3907           0 :                             sal_uInt16 nPos = 0;
    3908           0 :                             String sRet;
    3909           0 :                             SbxArrayRef xArgs = new SbxArray;
    3910           0 :                             SbxVariableRef xVar = new SbxVariable;
    3911           0 :                             xVar->PutString( pFlyFmt->GetName() );
    3912           0 :                             xArgs->Put( &xVar, ++nPos );
    3913             : 
    3914           0 :                             if( SW_EVENT_FRM_RESIZE == nEvent )
    3915             :                             {
    3916           0 :                                 xVar = new SbxVariable;
    3917           0 :                                 xVar->PutUShort( static_cast< sal_uInt16 >(eSdrMoveHdl) );
    3918           0 :                                 xArgs->Put( &xVar, ++nPos );
    3919             :                             }
    3920             : 
    3921           0 :                             xVar = new SbxVariable;
    3922           0 :                             xVar->PutLong( aDocPt.X() - aSttPt.X() );
    3923           0 :                             xArgs->Put( &xVar, ++nPos );
    3924           0 :                             xVar = new SbxVariable;
    3925           0 :                             xVar->PutLong( aDocPt.Y() - aSttPt.Y() );
    3926           0 :                             xArgs->Put( &xVar, ++nPos );
    3927             : 
    3928           0 :                             ReleaseMouse();
    3929             : 
    3930           0 :                             rSh.ExecMacro( *pMacro, &sRet, &xArgs );
    3931             : 
    3932           0 :                             CaptureMouse();
    3933             : 
    3934           0 :                             if( sRet.Len() && 0 != sRet.ToInt32() )
    3935           0 :                                 return ;
    3936             :                         }
    3937             :                     }
    3938             :                     // event processing for resizing
    3939             : 
    3940           0 :                     if( bIsDocReadOnly )
    3941           0 :                         break;
    3942             : 
    3943           0 :                     if ( rMEvt.IsShift() )
    3944             :                     {
    3945           0 :                         pSdrView->SetOrtho(sal_True);
    3946           0 :                         pSdrView->SetAngleSnapEnabled(sal_True);
    3947             :                     }
    3948             :                     else
    3949             :                     {
    3950           0 :                         pSdrView->SetOrtho(sal_False);
    3951           0 :                         pSdrView->SetAngleSnapEnabled(sal_False);
    3952             :                     }
    3953             : 
    3954           0 :                     rSh.Drag( &aDocPt, rMEvt.IsShift() );
    3955           0 :                     bIsInMove = sal_True;
    3956             :                 }
    3957           0 :                 else if( bIsDocReadOnly )
    3958           0 :                     break;
    3959             : 
    3960           0 :                 if ( !bInsWin )
    3961             :                 {
    3962           0 :                     Point aTmp( aDocPt );
    3963           0 :                     aTmp += rSh.VisArea().Pos() - aOldPt;
    3964           0 :                     LeaveArea( aTmp );
    3965             :                 }
    3966           0 :                 else if(bIsInMove)
    3967           0 :                     EnterArea();
    3968             :                 return;
    3969             :             }
    3970           0 :             if ( !rSh.IsSelFrmMode() && !bDDINetAttr &&
    3971           0 :                 (IsMinMove( aStartPos,aPixPt ) || bIsInMove) &&
    3972           0 :                 (rSh.IsInSelect() || !rSh.ChgCurrPam( aDocPt )) )
    3973             :             {
    3974           0 :                 if ( pSdrView )
    3975             :                 {
    3976           0 :                     if ( rMEvt.IsShift() )
    3977           0 :                         pSdrView->SetOrtho(sal_True);
    3978             :                     else
    3979           0 :                         pSdrView->SetOrtho(sal_False);
    3980             :                 }
    3981           0 :                 if ( !bInsWin )
    3982             :                 {
    3983           0 :                     Point aTmp( aDocPt );
    3984           0 :                     aTmp += rSh.VisArea().Pos() - aOldPt;
    3985           0 :                     LeaveArea( aTmp );
    3986             :                 }
    3987             :                 else
    3988             :                 {
    3989           0 :                     if( !rMEvt.IsSynthetic() &&
    3990             :                             !(( MOUSE_LEFT + KEY_MOD1 ==
    3991           0 :                             rMEvt.GetModifier() + rMEvt.GetButtons() ) &&
    3992           0 :                             rSh.Is_FnDragEQBeginDrag() && !rSh.IsAddMode() ))
    3993             :                     {
    3994           0 :                         rSh.Drag( &aDocPt, false );
    3995             : 
    3996           0 :                         bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPt, false));
    3997           0 :                         EnterArea();
    3998             :                     }
    3999             :                 }
    4000             :             }
    4001           0 :             bDDINetAttr = sal_False;
    4002           0 :             break;
    4003             :         case 0:
    4004             :         {
    4005           0 :             if ( pApplyTempl )
    4006             :             {
    4007           0 :                 UpdatePointer(aDocPt, 0); // maybe a frame has to be marked here
    4008             :                 break;
    4009             :             }
    4010             :             // change ui if mouse is over SwPostItField
    4011             :             // TODO: do the same thing for redlines SW_REDLINE
    4012           0 :             SwRect aFldRect;
    4013           0 :             SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD);
    4014           0 :             if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_False, &aFldRect ) )
    4015             :             {
    4016           0 :                 const SwField* pFld = aCntntAtPos.aFnd.pFld;
    4017           0 :                 if (pFld->Which()== RES_POSTITFLD)
    4018             :                 {
    4019           0 :                     rView.GetPostItMgr()->SetShadowState(reinterpret_cast<const SwPostItField*>(pFld),false);
    4020             :                 }
    4021             :                 else
    4022           0 :                     rView.GetPostItMgr()->SetShadowState(0,false);
    4023             :             }
    4024             :             else
    4025           0 :                 rView.GetPostItMgr()->SetShadowState(0,false);
    4026             :         }
    4027             :         // no break;
    4028             :         case KEY_SHIFT:
    4029             :         case KEY_MOD2:
    4030             :         case KEY_MOD1:
    4031           0 :             if ( !bInsDraw )
    4032             :             {
    4033           0 :                 sal_Bool bTstShdwCrsr = sal_True;
    4034             : 
    4035           0 :                 UpdatePointer( aDocPt, rMEvt.GetModifier() );
    4036             : 
    4037           0 :                 const SwFrmFmt* pFmt = 0;
    4038           0 :                 const SwFmtINetFmt* pINet = 0;
    4039           0 :                 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
    4040           0 :                 if( rSh.GetContentAtPos( aDocPt, aCntntAtPos ) )
    4041           0 :                     pINet = (SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr;
    4042             : 
    4043           0 :                 const void* pTmp = pINet;
    4044             : 
    4045           0 :                 if( pINet ||
    4046           0 :                     0 != ( pTmp = pFmt = rSh.GetFmtFromAnyObj( aDocPt )))
    4047             :                 {
    4048           0 :                     bTstShdwCrsr = sal_False;
    4049           0 :                     if( pTmp == pINet )
    4050           0 :                         aSaveCallEvent.Set( pINet );
    4051             :                     else
    4052             :                     {
    4053           0 :                         IMapObject* pIMapObj = pFmt->GetIMapObject( aDocPt );
    4054           0 :                         if( pIMapObj )
    4055           0 :                             aSaveCallEvent.Set( pFmt, pIMapObj );
    4056             :                         else
    4057           0 :                             aSaveCallEvent.Set( EVENT_OBJECT_URLITEM, pFmt );
    4058             :                     }
    4059             : 
    4060             :                     // should be be over a InternetField with an
    4061             :                     // embedded macro?
    4062           0 :                     if( aSaveCallEvent != aLastCallEvent )
    4063             :                     {
    4064           0 :                         if( aLastCallEvent.HasEvent() )
    4065             :                             rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT,
    4066           0 :                                             aLastCallEvent, true );
    4067             :                         // 0 says that the object doesn't have any table
    4068           0 :                         if( !rSh.CallEvent( SFX_EVENT_MOUSEOVER_OBJECT,
    4069           0 :                                         aSaveCallEvent ))
    4070           0 :                             aSaveCallEvent.Clear();
    4071             :                     }
    4072             :                 }
    4073           0 :                 else if( aLastCallEvent.HasEvent() )
    4074             :                 {
    4075             :                     // cursor was on an object
    4076             :                     rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT,
    4077           0 :                                     aLastCallEvent, true );
    4078             :                 }
    4079             : 
    4080           0 :                 if( bTstShdwCrsr && bInsWin && !bIsDocReadOnly &&
    4081           0 :                     !bInsFrm &&
    4082           0 :                     !rSh.GetViewOptions()->getBrowseMode() &&
    4083           0 :                     rSh.GetViewOptions()->IsShadowCursor() &&
    4084           0 :                     !(rMEvt.GetModifier() + rMEvt.GetButtons()) &&
    4085           0 :                     !rSh.HasSelection() && !GetConnectMetaFile() )
    4086             :                 {
    4087           0 :                     SwRect aRect;
    4088             :                     sal_Int16 eOrient;
    4089           0 :                     SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode();
    4090           0 :                     if( rSh.GetShadowCrsrPos( aDocPt, eMode, aRect, eOrient ))
    4091             :                     {
    4092           0 :                         if( !pShadCrsr )
    4093             :                             pShadCrsr = new SwShadowCursor( *this,
    4094           0 :                                 SwViewOption::GetDirectCursorColor() );
    4095           0 :                         if( text::HoriOrientation::RIGHT != eOrient && text::HoriOrientation::CENTER != eOrient )
    4096           0 :                             eOrient = text::HoriOrientation::LEFT;
    4097           0 :                         pShadCrsr->SetPos( aRect.Pos(), aRect.Height(), static_cast< sal_uInt16 >(eOrient) );
    4098           0 :                         bDelShadCrsr = sal_False;
    4099             :                     }
    4100           0 :                 }
    4101             :             }
    4102           0 :             break;
    4103             :         case MOUSE_LEFT + KEY_MOD2:
    4104           0 :             if( rSh.IsBlockMode() && !rMEvt.IsSynthetic() )
    4105             :             {
    4106           0 :                 rSh.Drag( &aDocPt, false );
    4107           0 :                 bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPt, false));
    4108           0 :                 EnterArea();
    4109             :             }
    4110           0 :         break;
    4111             :     }
    4112             : 
    4113           0 :     if( bDelShadCrsr && pShadCrsr )
    4114           0 :         delete pShadCrsr, pShadCrsr = 0;
    4115           0 :     bWasShdwCrsr = sal_False;
    4116             : }
    4117             : 
    4118             : /*--------------------------------------------------------------------
    4119             :     Description:   Button Up
    4120             :  --------------------------------------------------------------------*/
    4121             : 
    4122           0 : void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
    4123             : {
    4124           0 :     sal_Bool bCallBase = sal_True;
    4125             : 
    4126           0 :     sal_Bool bCallShadowCrsr = bWasShdwCrsr;
    4127           0 :     bWasShdwCrsr = sal_False;
    4128           0 :     if( pShadCrsr )
    4129           0 :         delete pShadCrsr, pShadCrsr = 0;
    4130             : 
    4131           0 :     if( pRowColumnSelectionStart )
    4132           0 :         DELETEZ( pRowColumnSelectionStart );
    4133             : 
    4134           0 :     SdrHdlKind eOldSdrMoveHdl = eSdrMoveHdl;
    4135           0 :     eSdrMoveHdl = HDL_USER;     // for MoveEvents - reset again
    4136             : 
    4137             :     // preventively reset
    4138           0 :     rView.SetTabColFromDoc( sal_False );
    4139           0 :     rView.SetNumRuleNodeFromDoc(NULL);
    4140             : 
    4141           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    4142           0 :     SET_CURR_SHELL( &rSh );
    4143           0 :     SdrView *pSdrView = rSh.GetDrawView();
    4144           0 :     if ( pSdrView )
    4145             :     {
    4146           0 :         pSdrView->SetOrtho(sal_False);
    4147             : 
    4148           0 :         if ( pSdrView->MouseButtonUp( rMEvt,this ) )
    4149             :         {
    4150           0 :             rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
    4151             :             return; // SdrView's event evaluated
    4152             :         }
    4153             :     }
    4154             :     // only process MouseButtonUp when the Down went to that windows as well.
    4155           0 :     if ( !bMBPressed )
    4156             :     {
    4157             : // Undo for the watering can is already in CommandHdl
    4158             : // that's the way it should be!
    4159             : 
    4160             :         return;
    4161             :     }
    4162             : 
    4163           0 :     Point aDocPt( PixelToLogic( rMEvt.GetPosPixel() ) );
    4164             : 
    4165           0 :     if ( bDDTimerStarted )
    4166             :     {
    4167           0 :         StopDDTimer( &rSh, aDocPt );
    4168           0 :         bMBPressed = sal_False;
    4169           0 :         if ( rSh.IsSelFrmMode() )
    4170             :         {
    4171           0 :             rSh.EndDrag( &aDocPt, false );
    4172           0 :             bFrmDrag = sal_False;
    4173             :         }
    4174           0 :         bNoInterrupt = sal_False;
    4175           0 :         ReleaseMouse();
    4176             :         return;
    4177             :     }
    4178             : 
    4179           0 :     if( pAnchorMarker )
    4180             :     {
    4181           0 :         Point aPnt( pAnchorMarker->GetLastPos() );
    4182           0 :         DELETEZ( pAnchorMarker );
    4183           0 :         if( aPnt.X() || aPnt.Y() )
    4184           0 :             rSh.FindAnchorPos( aPnt, sal_True );
    4185             :     }
    4186           0 :     if ( bInsDraw && rView.GetDrawFuncPtr() )
    4187             :     {
    4188           0 :         if ( rView.GetDrawFuncPtr()->MouseButtonUp( rMEvt ) )
    4189             :         {
    4190           0 :             if (rView.GetDrawFuncPtr()) // could have been destroyed in MouseButtonUp
    4191             :             {
    4192           0 :                 rView.GetDrawFuncPtr()->Deactivate();
    4193             : 
    4194           0 :                 if (!rView.IsDrawMode())
    4195             :                 {
    4196           0 :                     rView.SetDrawFuncPtr(NULL);
    4197           0 :                     SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
    4198           0 :                     rBind.Invalidate( SID_ATTR_SIZE );
    4199           0 :                     rBind.Invalidate( SID_TABLE_CELL );
    4200             :                 }
    4201             :             }
    4202             : 
    4203           0 :             if ( rSh.IsObjSelected() )
    4204             :             {
    4205           0 :                 rSh.EnterSelFrmMode();
    4206           0 :                 if (!rView.GetDrawFuncPtr())
    4207           0 :                     StdDrawMode( OBJ_NONE, sal_True );
    4208             :             }
    4209           0 :             else if ( rSh.IsFrmSelected() )
    4210             :             {
    4211           0 :                 rSh.EnterSelFrmMode();
    4212           0 :                 StopInsFrm();
    4213             :             }
    4214             :             else
    4215             :             {
    4216           0 :                 const Point aDocPos( PixelToLogic( aStartPos ) );
    4217           0 :                 bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
    4218           0 :                 rSh.Edit();
    4219             :             }
    4220             : 
    4221           0 :             rView.AttrChangedNotify( &rSh );
    4222             :         }
    4223           0 :         else if (rMEvt.GetButtons() == MOUSE_RIGHT && rSh.IsDrawCreate())
    4224           0 :             rView.GetDrawFuncPtr()->BreakCreate();   // abort drawing
    4225             : 
    4226           0 :         bNoInterrupt = sal_False;
    4227           0 :         ReleaseMouse();
    4228             :         return;
    4229             :     }
    4230           0 :     sal_Bool bPopMode = sal_False;
    4231           0 :     switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
    4232             :     {
    4233             :         case MOUSE_LEFT:
    4234           0 :             if ( bInsDraw && rSh.IsDrawCreate() )
    4235             :             {
    4236           0 :                 if ( rView.GetDrawFuncPtr() && rView.GetDrawFuncPtr()->MouseButtonUp(rMEvt) == sal_True )
    4237             :                 {
    4238           0 :                     rView.GetDrawFuncPtr()->Deactivate();
    4239           0 :                     rView.AttrChangedNotify( &rSh );
    4240           0 :                     if ( rSh.IsObjSelected() )
    4241           0 :                         rSh.EnterSelFrmMode();
    4242           0 :                     if ( rView.GetDrawFuncPtr() && bInsFrm )
    4243           0 :                         StopInsFrm();
    4244             :                 }
    4245           0 :                 bCallBase = sal_False;
    4246           0 :                 break;
    4247             :             }
    4248             :         case MOUSE_LEFT + KEY_MOD1:
    4249             :         case MOUSE_LEFT + KEY_MOD2:
    4250             :         case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
    4251           0 :             if ( bFrmDrag && rSh.IsSelFrmMode() )
    4252             :             {
    4253           0 :                 if ( rMEvt.IsMod1() ) // copy and don't move.
    4254             :                 {
    4255             :                     // abort drag, use internal Copy instead
    4256           0 :                     Rectangle aRect;
    4257           0 :                     rSh.GetDrawView()->TakeActionRect( aRect );
    4258           0 :                     if (!aRect.IsEmpty())
    4259             :                     {
    4260           0 :                         rSh.BreakDrag();
    4261           0 :                         Point aEndPt, aSttPt;
    4262           0 :                         if ( rSh.GetSelFrmType() & FRMTYPE_FLY_ATCNT )
    4263             :                         {
    4264           0 :                             aEndPt = aRect.TopLeft();
    4265           0 :                             aSttPt = rSh.GetDrawView()->GetAllMarkedRect().TopLeft();
    4266             :                         }
    4267             :                         else
    4268             :                         {
    4269           0 :                             aEndPt = aRect.Center();
    4270           0 :                             aSttPt = rSh.GetDrawView()->GetAllMarkedRect().Center();
    4271             :                         }
    4272           0 :                         if ( aSttPt != aEndPt )
    4273             :                         {
    4274           0 :                             rSh.StartUndo( UNDO_UI_DRAG_AND_COPY );
    4275           0 :                             rSh.Copy(&rSh, aSttPt, aEndPt, sal_False);
    4276           0 :                             rSh.EndUndo( UNDO_UI_DRAG_AND_COPY );
    4277             :                         }
    4278             :                     }
    4279             :                     else
    4280           0 :                         rSh.EndDrag( &aDocPt, false );
    4281             :                 }
    4282             :                 else
    4283             :                 {
    4284             :                     {
    4285             :                         const SwFrmFmt* pFlyFmt;
    4286             :                         const SvxMacro* pMacro;
    4287             : 
    4288             :                         sal_uInt16 nEvent = HDL_MOVE == eOldSdrMoveHdl
    4289             :                                             ? SW_EVENT_FRM_MOVE
    4290           0 :                                             : SW_EVENT_FRM_RESIZE;
    4291             : 
    4292           0 :                         if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) &&
    4293           0 :                             0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable().
    4294           0 :                             Get( nEvent )) )
    4295             :                         {
    4296           0 :                             const Point aSttPt( PixelToLogic( aStartPos ) );
    4297           0 :                             aRszMvHdlPt = aDocPt;
    4298           0 :                             sal_uInt16 nPos = 0;
    4299           0 :                             SbxArrayRef xArgs = new SbxArray;
    4300           0 :                             SbxVariableRef xVar = new SbxVariable;
    4301           0 :                             xVar->PutString( pFlyFmt->GetName() );
    4302           0 :                             xArgs->Put( &xVar, ++nPos );
    4303             : 
    4304           0 :                             if( SW_EVENT_FRM_RESIZE == nEvent )
    4305             :                             {
    4306           0 :                                 xVar = new SbxVariable;
    4307           0 :                                 xVar->PutUShort( static_cast< sal_uInt16 >(eOldSdrMoveHdl) );
    4308           0 :                                 xArgs->Put( &xVar, ++nPos );
    4309             :                             }
    4310             : 
    4311           0 :                             xVar = new SbxVariable;
    4312           0 :                             xVar->PutLong( aDocPt.X() - aSttPt.X() );
    4313           0 :                             xArgs->Put( &xVar, ++nPos );
    4314           0 :                             xVar = new SbxVariable;
    4315           0 :                             xVar->PutLong( aDocPt.Y() - aSttPt.Y() );
    4316           0 :                             xArgs->Put( &xVar, ++nPos );
    4317             : 
    4318           0 :                             xVar = new SbxVariable;
    4319           0 :                             xVar->PutUShort( 1 );
    4320           0 :                             xArgs->Put( &xVar, ++nPos );
    4321             : 
    4322           0 :                             ReleaseMouse();
    4323             : 
    4324           0 :                             rSh.ExecMacro( *pMacro, 0, &xArgs );
    4325             : 
    4326           0 :                             CaptureMouse();
    4327             :                         }
    4328             :                     }
    4329           0 :                     rSh.EndDrag( &aDocPt, false );
    4330             :                 }
    4331           0 :                 bFrmDrag = sal_False;
    4332           0 :                 bCallBase = sal_False;
    4333           0 :                 break;
    4334             :             }
    4335           0 :             bPopMode = sal_True;
    4336             :             // no break
    4337             :         case MOUSE_LEFT + KEY_SHIFT:
    4338           0 :             if (rSh.IsSelFrmMode())
    4339             :             {
    4340             : 
    4341           0 :                 rSh.EndDrag( &aDocPt, false );
    4342           0 :                 bFrmDrag = sal_False;
    4343           0 :                 bCallBase = sal_False;
    4344           0 :                 break;
    4345             :             }
    4346             : 
    4347           0 :             if( bHoldSelection )
    4348             :             {
    4349             :                 // the EndDrag should be called in any case
    4350           0 :                 bHoldSelection = sal_False;
    4351           0 :                 rSh.EndDrag( &aDocPt, false );
    4352             :             }
    4353             :             else
    4354             :             {
    4355           0 :                 SwContentAtPos aFieldAtPos ( SwContentAtPos::SW_FIELD );
    4356           0 :                 if ( !rSh.IsInSelect() && rSh.ChgCurrPam( aDocPt ) && !rSh.GetContentAtPos( aDocPt, aFieldAtPos ) )
    4357             :                 {
    4358           0 :                     const sal_Bool bTmpNoInterrupt = bNoInterrupt;
    4359           0 :                     bNoInterrupt = sal_False;
    4360             :                     {   // create only temporary move context because otherwise
    4361             :                         // the query to the content form doesn't work!!!
    4362           0 :                         SwMvContext aMvContext( &rSh );
    4363           0 :                         const Point aDocPos( PixelToLogic( aStartPos ) );
    4364           0 :                         bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
    4365             :                     }
    4366           0 :                     bNoInterrupt = bTmpNoInterrupt;
    4367             : 
    4368             :                 }
    4369             :                 else
    4370             :                 {
    4371           0 :                     sal_Bool bInSel = rSh.IsInSelect();
    4372           0 :                     rSh.EndDrag( &aDocPt, false );
    4373             : 
    4374             :                     // Internetfield? --> call link (load doc!!)
    4375           0 :                     if( !bInSel )
    4376             :                     {
    4377           0 :                         sal_uInt16 nFilter = URLLOAD_NOFILTER;
    4378           0 :                         if( KEY_MOD1 == rMEvt.GetModifier() )
    4379           0 :                             nFilter |= URLLOAD_NEWVIEW;
    4380             : 
    4381           0 :                         sal_Bool bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
    4382           0 :                         if ( !bExecHyperlinks )
    4383             :                         {
    4384           0 :                             SvtSecurityOptions aSecOpts;
    4385           0 :                             const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
    4386           0 :                             if ( (  bSecureOption && rMEvt.GetModifier() == KEY_MOD1 ) ||
    4387           0 :                                  ( !bSecureOption && rMEvt.GetModifier() != KEY_MOD1 ) )
    4388           0 :                                 bExecHyperlinks = sal_True;
    4389             :                         }
    4390             : 
    4391           0 :                         const sal_Bool bExecSmarttags = rMEvt.GetModifier() == KEY_MOD1;
    4392             : 
    4393           0 :                         if(pApplyTempl)
    4394           0 :                             bExecHyperlinks = sal_False;
    4395             : 
    4396             :                         SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD |
    4397             :                                                     SwContentAtPos::SW_INETATTR |
    4398           0 :                                                     SwContentAtPos::SW_SMARTTAG  | SwContentAtPos::SW_FORMCTRL);
    4399             : 
    4400           0 :                         if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_False ) )
    4401             :                         {
    4402             :                             // Do it again if we're not on a field to update the cursor accordingly
    4403           0 :                             if ( SwContentAtPos::SW_FIELD != aCntntAtPos.eCntntAtPos )
    4404           0 :                                 rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_True );
    4405             : 
    4406           0 :                             sal_Bool bViewLocked = rSh.IsViewLocked();
    4407           0 :                             if( !bViewLocked && !rSh.IsReadOnlyAvailable() &&
    4408           0 :                                 aCntntAtPos.IsInProtectSect() )
    4409           0 :                                 rSh.LockView( sal_True );
    4410             : 
    4411           0 :                             ReleaseMouse();
    4412             : 
    4413           0 :                             if( SwContentAtPos::SW_FIELD == aCntntAtPos.eCntntAtPos )
    4414             :                             {
    4415           0 :                                 rSh.ClickToField( *aCntntAtPos.aFnd.pFld );
    4416             :                             }
    4417           0 :                             else if ( SwContentAtPos::SW_SMARTTAG == aCntntAtPos.eCntntAtPos )
    4418             :                             {
    4419             :                                     // execute smarttag menu
    4420           0 :                                     if ( bExecSmarttags && SwSmartTagMgr::Get().IsSmartTagsEnabled() )
    4421           0 :                                         rView.ExecSmartTagPopup( aDocPt );
    4422             :                             }
    4423           0 :                             else if ( SwContentAtPos::SW_FORMCTRL == aCntntAtPos.eCntntAtPos )
    4424             :                             {
    4425             :                                 OSL_ENSURE( aCntntAtPos.aFnd.pFldmark != NULL, "where is my field ptr???");
    4426           0 :                                 if ( aCntntAtPos.aFnd.pFldmark != NULL)
    4427             :                                 {
    4428           0 :                                     IFieldmark *fieldBM = const_cast< IFieldmark* > ( aCntntAtPos.aFnd.pFldmark );
    4429           0 :                                     if ( fieldBM->GetFieldname( ) == ODF_FORMCHECKBOX )
    4430             :                                     {
    4431           0 :                                         ICheckboxFieldmark* pCheckboxFm = dynamic_cast<ICheckboxFieldmark*>(fieldBM);
    4432           0 :                                         pCheckboxFm->SetChecked(!pCheckboxFm->IsChecked());
    4433           0 :                                         pCheckboxFm->Invalidate();
    4434           0 :                                         rSh.InvalidateWindows( rView.GetVisArea() );
    4435           0 :                                     } else if ( fieldBM->GetFieldname() == ODF_FORMDROPDOWN ) {
    4436           0 :                                         rView.ExecFieldPopup( aDocPt, fieldBM );
    4437           0 :                                         fieldBM->Invalidate();
    4438           0 :                                         rSh.InvalidateWindows( rView.GetVisArea() );
    4439             :                                     } else {
    4440             :                                         // unknown type..
    4441             :                                     }
    4442             :                                 }
    4443             :                             }
    4444             :                             else
    4445             :                             {
    4446           0 :                                 if ( bExecHyperlinks )
    4447           0 :                                     rSh.ClickToINetAttr( *(SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr, nFilter );
    4448             :                             }
    4449             : 
    4450           0 :                             rSh.LockView( bViewLocked );
    4451           0 :                             bCallShadowCrsr = sal_False;
    4452             :                         }
    4453             :                         else
    4454             :                         {
    4455           0 :                             aCntntAtPos = SwContentAtPos( SwContentAtPos::SW_FTN );
    4456           0 :                             if( !rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_True ) && bExecHyperlinks )
    4457             :                             {
    4458           0 :                                 SdrViewEvent aVEvt;
    4459             : 
    4460           0 :                                 if (pSdrView)
    4461           0 :                                     pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
    4462             : 
    4463           0 :                                 if (pSdrView && aVEvt.eEvent == SDREVENT_EXECUTEURL)
    4464             :                                 {
    4465             :                                     // hit URL field
    4466           0 :                                     const SvxURLField *pField = aVEvt.pURLField;
    4467           0 :                                     if (pField)
    4468             :                                     {
    4469           0 :                                         String sURL(pField->GetURL());
    4470           0 :                                         String sTarget(pField->GetTargetFrame());
    4471           0 :                                         ::LoadURL(rSh, sURL, nFilter, sTarget);
    4472             :                                     }
    4473           0 :                                     bCallShadowCrsr = sal_False;
    4474             :                                 }
    4475             :                                 else
    4476             :                                 {
    4477             :                                     // hit graphic
    4478           0 :                                     ReleaseMouse();
    4479           0 :                                     if( rSh.ClickToINetGrf( aDocPt, nFilter ))
    4480           0 :                                         bCallShadowCrsr = sal_False;
    4481           0 :                                 }
    4482             :                             }
    4483             :                         }
    4484             : 
    4485           0 :                         if( bCallShadowCrsr &&
    4486           0 :                             rSh.GetViewOptions()->IsShadowCursor() &&
    4487           0 :                             MOUSE_LEFT == (rMEvt.GetModifier() + rMEvt.GetButtons()) &&
    4488           0 :                             !rSh.HasSelection() &&
    4489           0 :                             !GetConnectMetaFile() &&
    4490           0 :                             rSh.VisArea().IsInside( aDocPt ))
    4491             :                         {
    4492           0 :                             SwUndoId nLastUndoId(UNDO_EMPTY);
    4493           0 :                             if (rSh.GetLastUndoInfo(0, & nLastUndoId))
    4494             :                             {
    4495           0 :                                 if (UNDO_INS_FROM_SHADOWCRSR == nLastUndoId)
    4496             :                                 {
    4497           0 :                                     rSh.Undo();
    4498             :                                 }
    4499             :                             }
    4500           0 :                             SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode();
    4501           0 :                             rSh.SetShadowCrsrPos( aDocPt, eMode );
    4502           0 :                         }
    4503             :                     }
    4504             :                 }
    4505           0 :                 bCallBase = sal_False;
    4506             : 
    4507             :             }
    4508             : 
    4509             :             // reset pushed mode in Down again if applicable
    4510           0 :             if ( bPopMode && bModePushed )
    4511             :             {
    4512           0 :                 rSh.PopMode();
    4513           0 :                 bModePushed = sal_False;
    4514           0 :                 bCallBase = sal_False;
    4515             :             }
    4516           0 :             break;
    4517             : 
    4518             :         default:
    4519           0 :             ReleaseMouse();
    4520             :             return;
    4521             :     }
    4522             : 
    4523           0 :     if( pApplyTempl )
    4524             :     {
    4525           0 :         int eSelection = rSh.GetSelectionType();
    4526           0 :         SwFormatClipboard* pFormatClipboard = pApplyTempl->pFormatClipboard;
    4527           0 :         if( pFormatClipboard )//apply format paintbrush
    4528             :         {
    4529             :             //get some parameters
    4530           0 :             SwWrtShell& rWrtShell = rView.GetWrtShell();
    4531           0 :             SfxStyleSheetBasePool* pPool=0;
    4532           0 :             bool bNoCharacterFormats = false;
    4533           0 :             bool bNoParagraphFormats = true;
    4534             :             {
    4535           0 :                 SwDocShell* pDocSh = rView.GetDocShell();
    4536           0 :                 if(pDocSh)
    4537           0 :                     pPool = pDocSh->GetStyleSheetPool();
    4538           0 :                 if( (rMEvt.GetModifier()&KEY_MOD1) && (rMEvt.GetModifier()&KEY_SHIFT) )
    4539             :                 {
    4540           0 :                     bNoCharacterFormats = true;
    4541           0 :                     bNoParagraphFormats = false;
    4542             :                 }
    4543           0 :                 else if( rMEvt.GetModifier() & KEY_MOD1 )
    4544           0 :                     bNoParagraphFormats = false;
    4545             :             }
    4546             :             //execute paste
    4547           0 :             pFormatClipboard->Paste( rWrtShell, pPool, bNoCharacterFormats, bNoParagraphFormats );
    4548             : 
    4549             :             //if the clipboard is empty after paste remove the ApplyTemplate
    4550           0 :             if(!pFormatClipboard->HasContent())
    4551           0 :                 SetApplyTemplate(SwApplyTemplate());
    4552             :         }
    4553           0 :         else if( pApplyTempl->nColor )
    4554             :         {
    4555           0 :             sal_uInt16 nId = 0;
    4556           0 :             switch( pApplyTempl->nColor )
    4557             :             {
    4558             :                 case SID_ATTR_CHAR_COLOR_EXT:
    4559             :                 case SID_ATTR_CHAR_COLOR2:
    4560           0 :                     nId = RES_CHRATR_COLOR;
    4561           0 :                     break;
    4562             :                 case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
    4563             :                 case SID_ATTR_CHAR_COLOR_BACKGROUND:
    4564           0 :                     nId = RES_CHRATR_BACKGROUND;
    4565           0 :                     break;
    4566             :             }
    4567           0 :             if( nId && (nsSelectionType::SEL_TXT|nsSelectionType::SEL_TBL) & eSelection)
    4568             :             {
    4569           0 :                 if( rSh.IsSelection() && !rSh.HasReadonlySel() )
    4570             :                 {
    4571           0 :                     if(nId == RES_CHRATR_BACKGROUND)
    4572             :                     {
    4573           0 :                         Color aColor( COL_TRANSPARENT  );
    4574           0 :                         if( !SwEditWin::bTransparentBackColor )
    4575           0 :                             aColor = SwEditWin::aTextBackColor;
    4576           0 :                         rSh.SetAttr( SvxBrushItem( aColor, nId ) );
    4577             :                     }
    4578             :                     else
    4579           0 :                         rSh.SetAttr( SvxColorItem(SwEditWin::aTextColor, nId) );
    4580           0 :                     rSh.UnSetVisCrsr();
    4581           0 :                     rSh.EnterStdMode();
    4582           0 :                     rSh.SetVisCrsr(aDocPt);
    4583             : 
    4584           0 :                     pApplyTempl->bUndo = sal_True;
    4585           0 :                     bCallBase = sal_False;
    4586           0 :                     aTemplateTimer.Stop();
    4587             :                 }
    4588           0 :                 else if(rMEvt.GetClicks() == 1)
    4589             :                 {
    4590             :                     // no selection -> so turn off watering can
    4591           0 :                     aTemplateTimer.Start();
    4592             :                 }
    4593             :             }
    4594             :         }
    4595             :         else
    4596             :         {
    4597           0 :             String aStyleName;
    4598           0 :             switch ( pApplyTempl->eType )
    4599             :             {
    4600             :                 case SFX_STYLE_FAMILY_PARA:
    4601           0 :                     if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL )
    4602           0 :                          & eSelection ) && !rSh.HasReadonlySel() )
    4603             :                     {
    4604           0 :                         rSh.SetTxtFmtColl( pApplyTempl->aColl.pTxtColl );
    4605           0 :                         pApplyTempl->bUndo = sal_True;
    4606           0 :                         bCallBase = sal_False;
    4607           0 :                         if ( pApplyTempl->aColl.pTxtColl )
    4608           0 :                             aStyleName = pApplyTempl->aColl.pTxtColl->GetName();
    4609             :                     }
    4610           0 :                     break;
    4611             :                 case SFX_STYLE_FAMILY_CHAR:
    4612           0 :                     if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL )
    4613           0 :                          & eSelection ) && !rSh.HasReadonlySel() )
    4614             :                     {
    4615           0 :                         rSh.SetAttr( SwFmtCharFmt(pApplyTempl->aColl.pCharFmt) );
    4616           0 :                         rSh.UnSetVisCrsr();
    4617           0 :                         rSh.EnterStdMode();
    4618           0 :                         rSh.SetVisCrsr(aDocPt);
    4619           0 :                         pApplyTempl->bUndo = sal_True;
    4620           0 :                         bCallBase = sal_False;
    4621           0 :                         if ( pApplyTempl->aColl.pCharFmt )
    4622           0 :                             aStyleName = pApplyTempl->aColl.pCharFmt->GetName();
    4623             :                     }
    4624           0 :                     break;
    4625             :                 case SFX_STYLE_FAMILY_FRAME :
    4626             :                 {
    4627           0 :                     const SwFrmFmt* pFmt = rSh.GetFmtFromObj( aDocPt );
    4628           0 :                     if(PTR_CAST(SwFlyFrmFmt, pFmt))
    4629             :                     {
    4630           0 :                         rSh.SetFrmFmt( pApplyTempl->aColl.pFrmFmt, false, &aDocPt );
    4631           0 :                         pApplyTempl->bUndo = sal_True;
    4632           0 :                         bCallBase = sal_False;
    4633           0 :                         if( pApplyTempl->aColl.pFrmFmt )
    4634           0 :                             aStyleName = pApplyTempl->aColl.pFrmFmt->GetName();
    4635             :                     }
    4636           0 :                     break;
    4637             :                 }
    4638             :                 case SFX_STYLE_FAMILY_PAGE:
    4639             :                             // no Undo with page templates
    4640           0 :                     rSh.ChgCurPageDesc( *pApplyTempl->aColl.pPageDesc );
    4641           0 :                     if ( pApplyTempl->aColl.pPageDesc )
    4642           0 :                         aStyleName = pApplyTempl->aColl.pPageDesc->GetName();
    4643           0 :                     bCallBase = sal_False;
    4644           0 :                     break;
    4645             :                 case SFX_STYLE_FAMILY_PSEUDO:
    4646           0 :                     if( !rSh.HasReadonlySel() )
    4647             :                     {
    4648             :                         rSh.SetCurNumRule( *pApplyTempl->aColl.pNumRule,
    4649             :                                            false,
    4650           0 :                                            pApplyTempl->aColl.pNumRule->GetDefaultListId() );
    4651           0 :                         bCallBase = sal_False;
    4652           0 :                         pApplyTempl->bUndo = sal_True;
    4653           0 :                         if( pApplyTempl->aColl.pNumRule )
    4654           0 :                             aStyleName = pApplyTempl->aColl.pNumRule->GetName();
    4655             :                     }
    4656           0 :                     break;
    4657             :             }
    4658             : 
    4659             :             uno::Reference< frame::XDispatchRecorder > xRecorder =
    4660           0 :                     rView.GetViewFrame()->GetBindings().GetRecorder();
    4661           0 :             if ( aStyleName.Len() && xRecorder.is() )
    4662             :             {
    4663           0 :                 SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) );
    4664           0 :                 if ( pSfxShell )
    4665             :                 {
    4666           0 :                     SfxRequest aReq( rView.GetViewFrame(), SID_STYLE_APPLY );
    4667           0 :                     aReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aStyleName ) );
    4668           0 :                     aReq.AppendItem( SfxUInt16Item( SID_STYLE_FAMILY, (sal_uInt16) pApplyTempl->eType ) );
    4669           0 :                     aReq.Done();
    4670             :                 }
    4671           0 :             }
    4672             :         }
    4673             : 
    4674             :     }
    4675           0 :     ReleaseMouse();
    4676             :     // Only processed MouseEvents arrive here; only at these the moduses can
    4677             :     // be resetted.
    4678           0 :     bMBPressed = sal_False;
    4679             : 
    4680             :     //sicherheitshalber aufrufen, da jetzt das Selektieren bestimmt zu Ende ist.
    4681             :     //Andernfalls koennte der Timeout des Timers Kummer machen.
    4682           0 :     EnterArea();
    4683           0 :     bNoInterrupt = sal_False;
    4684             : 
    4685           0 :     if (bCallBase)
    4686           0 :         Window::MouseButtonUp(rMEvt);
    4687             : }
    4688             : 
    4689             : /*--------------------------------------------------------------------
    4690             :     Description:   apply template
    4691             :  --------------------------------------------------------------------*/
    4692             : 
    4693           0 : void SwEditWin::SetApplyTemplate(const SwApplyTemplate &rTempl)
    4694             : {
    4695             :     static sal_Bool bIdle = sal_False;
    4696           0 :     DELETEZ(pApplyTempl);
    4697           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    4698             : 
    4699           0 :     if(rTempl.pFormatClipboard)
    4700             :     {
    4701           0 :         pApplyTempl = new SwApplyTemplate( rTempl );
    4702           0 :               SetPointer( POINTER_FILL );//@todo #i20119# maybe better a new brush pointer here in future
    4703           0 :               rSh.NoEdit( sal_False );
    4704           0 :               bIdle = rSh.GetViewOptions()->IsIdle();
    4705           0 :               ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
    4706             :     }
    4707           0 :     else if(rTempl.nColor)
    4708             :     {
    4709           0 :         pApplyTempl = new SwApplyTemplate( rTempl );
    4710           0 :         SetPointer( POINTER_FILL );
    4711           0 :         rSh.NoEdit( sal_False );
    4712           0 :         bIdle = rSh.GetViewOptions()->IsIdle();
    4713           0 :         ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
    4714             :     }
    4715           0 :     else if( rTempl.eType )
    4716             :     {
    4717           0 :         pApplyTempl = new SwApplyTemplate( rTempl );
    4718           0 :         SetPointer( POINTER_FILL  );
    4719           0 :         rSh.NoEdit( sal_False );
    4720           0 :         bIdle = rSh.GetViewOptions()->IsIdle();
    4721           0 :         ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
    4722             :     }
    4723             :     else
    4724             :     {
    4725           0 :         SetPointer( POINTER_TEXT );
    4726           0 :         rSh.UnSetVisCrsr();
    4727             : 
    4728           0 :         ((SwViewOption *)rSh.GetViewOptions())->SetIdle( bIdle );
    4729           0 :         if ( !rSh.IsSelFrmMode() )
    4730           0 :             rSh.Edit();
    4731             :     }
    4732             : 
    4733             :     static sal_uInt16 aInva[] =
    4734             :     {
    4735             :         SID_STYLE_WATERCAN,
    4736             :         SID_ATTR_CHAR_COLOR_EXT,
    4737             :         SID_ATTR_CHAR_COLOR_BACKGROUND_EXT,
    4738             :         0
    4739             :     };
    4740           0 :     rView.GetViewFrame()->GetBindings().Invalidate(aInva);
    4741           0 : }
    4742             : 
    4743             : /*--------------------------------------------------------------------
    4744             :     Description:   ctor
    4745             :  --------------------------------------------------------------------*/
    4746             : 
    4747         478 : SwEditWin::SwEditWin(Window *pParent, SwView &rMyView):
    4748             :     Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
    4749             :     DropTargetHelper( this ),
    4750             :     DragSourceHelper( this ),
    4751             : 
    4752             :     eBufferLanguage(LANGUAGE_DONTKNOW),
    4753             :     pApplyTempl(0),
    4754             :     pAnchorMarker( 0 ),
    4755             :     pUserMarker( 0 ),
    4756             :     pUserMarkerObj( 0 ),
    4757             :     pShadCrsr( 0 ),
    4758             :     pRowColumnSelectionStart( 0 ),
    4759             : 
    4760             :     rView( rMyView ),
    4761             : 
    4762             :     aActHitType(SDRHIT_NONE),
    4763             :     m_nDropFormat( 0 ),
    4764             :     m_nDropAction( 0 ),
    4765             :     m_nDropDestination( 0 ),
    4766             : 
    4767             :     nInsFrmColCount( 1 ),
    4768             :     eDrawMode(OBJ_NONE),
    4769             : 
    4770             :     bLockInput(sal_False),
    4771             :     bObjectSelect( sal_False ),
    4772             :     nKS_NUMDOWN_Count(0),
    4773             :     nKS_NUMINDENTINC_Count(0),
    4774         478 :     m_aFrameControlsManager( this )
    4775             : {
    4776         478 :     SetHelpId(HID_EDIT_WIN);
    4777         478 :     EnableChildTransparentMode();
    4778         478 :     SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS );
    4779             : 
    4780             :     bLinkRemoved = bMBPressed = bInsDraw = bInsFrm =
    4781         478 :     bIsInDrag = bOldIdle = bOldIdleSet = bChainMode = bWasShdwCrsr = sal_False;
    4782             :     // initially use the input language
    4783         478 :     bUseInputLanguage = sal_True;
    4784             : 
    4785         478 :     SetMapMode(MapMode(MAP_TWIP));
    4786             : 
    4787         478 :     SetPointer( POINTER_TEXT );
    4788         478 :     aTimer.SetTimeoutHdl(LINK(this, SwEditWin, TimerHandler));
    4789             : 
    4790         478 :     bTblInsDelMode = sal_False;
    4791         478 :     aKeyInputTimer.SetTimeout( 3000 );
    4792         478 :     aKeyInputTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputTimerHandler));
    4793             : 
    4794         478 :     aKeyInputFlushTimer.SetTimeout( 200 );
    4795         478 :     aKeyInputFlushTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputFlushHandler));
    4796             : 
    4797             :     // TemplatePointer for colors should be resetted without
    4798             :     // selection after single click
    4799         478 :     aTemplateTimer.SetTimeout(400);
    4800         478 :     aTemplateTimer.SetTimeoutHdl(LINK(this, SwEditWin, TemplateTimerHdl));
    4801             : 
    4802             :     // temporary solution!!! Should set the font of the current
    4803             :     //          insert position at every curor movement!
    4804         478 :     if( !rMyView.GetDocShell()->IsReadOnly() )
    4805             :     {
    4806         478 :         Font aFont;
    4807             :         SetInputContext( InputContext( aFont, INPUTCONTEXT_TEXT |
    4808         478 :                                             INPUTCONTEXT_EXTTEXTINPUT ) );
    4809             :     }
    4810         478 : }
    4811             : 
    4812         216 : SwEditWin::~SwEditWin()
    4813             : {
    4814          72 :     aKeyInputTimer.Stop();
    4815          72 :     delete pShadCrsr;
    4816          72 :     delete pRowColumnSelectionStart;
    4817          72 :     if( pQuickHlpData->m_bIsDisplayed && rView.GetWrtShellPtr() )
    4818           0 :         pQuickHlpData->Stop( rView.GetWrtShell() );
    4819          72 :     bExecuteDrag = sal_False;
    4820          72 :     delete pApplyTempl;
    4821          72 :     rView.SetDrawFuncPtr(NULL);
    4822             : 
    4823          72 :     delete pUserMarker;
    4824          72 :     delete pAnchorMarker;
    4825         144 : }
    4826             : 
    4827             : /******************************************************************************
    4828             :  *  Description: turn on DrawTextEditMode
    4829             :  ******************************************************************************/
    4830             : 
    4831           0 : void SwEditWin::EnterDrawTextMode( const Point& aDocPos )
    4832             : {
    4833           0 :     if ( rView.EnterDrawTextMode(aDocPos) == sal_True )
    4834             :     {
    4835           0 :         if (rView.GetDrawFuncPtr())
    4836             :         {
    4837           0 :             rView.GetDrawFuncPtr()->Deactivate();
    4838           0 :             rView.SetDrawFuncPtr(NULL);
    4839           0 :             rView.LeaveDrawCreate();
    4840             :         }
    4841           0 :         rView.NoRotate();
    4842           0 :         rView.AttrChangedNotify( &rView.GetWrtShell() );
    4843             :     }
    4844           0 : }
    4845             : 
    4846             : /******************************************************************************
    4847             :  *  Description: turn on DrawMode
    4848             :  ******************************************************************************/
    4849             : 
    4850           0 : sal_Bool SwEditWin::EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos)
    4851             : {
    4852           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    4853           0 :     SdrView *pSdrView = rSh.GetDrawView();
    4854             : 
    4855           0 :     if ( rView.GetDrawFuncPtr() )
    4856             :     {
    4857           0 :         if (rSh.IsDrawCreate())
    4858           0 :             return sal_True;
    4859             : 
    4860           0 :         sal_Bool bRet = rView.GetDrawFuncPtr()->MouseButtonDown( rMEvt );
    4861           0 :         rView.AttrChangedNotify( &rSh );
    4862           0 :         return bRet;
    4863             :     }
    4864             : 
    4865           0 :     if ( pSdrView && pSdrView->IsTextEdit() )
    4866             :     {
    4867           0 :         sal_Bool bUnLockView = !rSh.IsViewLocked();
    4868           0 :         rSh.LockView( sal_True );
    4869             : 
    4870           0 :         rSh.EndTextEdit(); // clicked aside, end Edit
    4871           0 :         rSh.SelectObj( aDocPos );
    4872           0 :         if ( !rSh.IsObjSelected() && !rSh.IsFrmSelected() )
    4873           0 :             rSh.LeaveSelFrmMode();
    4874             :         else
    4875             :         {
    4876           0 :             SwEditWin::nDDStartPosY = aDocPos.Y();
    4877           0 :             SwEditWin::nDDStartPosX = aDocPos.X();
    4878           0 :             bFrmDrag = sal_True;
    4879             :         }
    4880           0 :         if( bUnLockView )
    4881           0 :             rSh.LockView( sal_False );
    4882           0 :         rView.AttrChangedNotify( &rSh );
    4883           0 :         return sal_True;
    4884             :     }
    4885           0 :     return sal_False;
    4886             : }
    4887             : 
    4888           0 : sal_Bool SwEditWin::IsDrawSelMode()
    4889             : {
    4890           0 :     return IsObjectSelect();
    4891             : }
    4892             : 
    4893         292 : void SwEditWin::GetFocus()
    4894             : {
    4895         292 :     if ( rView.GetPostItMgr()->HasActiveSidebarWin() )
    4896             :     {
    4897           0 :         rView.GetPostItMgr()->GrabFocusOnActiveSidebarWin();
    4898             :     }
    4899             :     else
    4900             :     {
    4901         292 :         rView.GotFocus();
    4902         292 :         Window::GetFocus();
    4903         292 :         rView.GetWrtShell().InvalidateAccessibleFocus();
    4904             :     }
    4905         292 : }
    4906             : 
    4907         292 : void SwEditWin::LoseFocus()
    4908             : {
    4909         292 :     rView.GetWrtShell().InvalidateAccessibleFocus();
    4910         292 :     Window::LoseFocus();
    4911         292 :     if( pQuickHlpData->m_bIsDisplayed )
    4912           0 :         pQuickHlpData->Stop( rView.GetWrtShell() );
    4913         292 :     rView.LostFocus();
    4914         292 : }
    4915             : 
    4916           0 : void SwEditWin::Command( const CommandEvent& rCEvt )
    4917             : {
    4918           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    4919             : 
    4920           0 :     if ( !rView.GetViewFrame() )
    4921             :     {
    4922             :         // If ViewFrame dies shortly, no popup anymore!
    4923           0 :         Window::Command(rCEvt);
    4924           0 :         return;
    4925             :     }
    4926             : 
    4927             :     // The command event is send to the window after a possible context
    4928             :     // menu from an inplace client has been closed. Now we have the chance
    4929             :     // to deactivate the inplace client without any problem regarding parent
    4930             :     // windows and code on the stack.
    4931           0 :     SfxInPlaceClient* pIPClient = rSh.GetSfxViewShell()->GetIPClient();
    4932           0 :     sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
    4933           0 :     if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ))
    4934             :     {
    4935           0 :         rSh.FinishOLEObj();
    4936           0 :         return;
    4937             :     }
    4938             : 
    4939           0 :     sal_Bool bCallBase      = sal_True;
    4940             : 
    4941           0 :     switch ( rCEvt.GetCommand() )
    4942             :     {
    4943             :         case COMMAND_CONTEXTMENU:
    4944             :         {
    4945           0 :             const sal_uInt16 nId = SwInputChild::GetChildWindowId();
    4946           0 :             SwInputChild* pChildWin = (SwInputChild*)GetView().GetViewFrame()->
    4947           0 :                                                 GetChildWindow( nId );
    4948             : 
    4949           0 :             if (rView.GetPostItMgr()->IsHit(rCEvt.GetMousePosPixel()))
    4950             :                 return;
    4951             : 
    4952           0 :             Point aDocPos( PixelToLogic( rCEvt.GetMousePosPixel() ) );
    4953           0 :             if ( !rCEvt.IsMouseEvent() )
    4954           0 :                 aDocPos = rSh.GetCharRect().Center();
    4955             : 
    4956             :             // Don't trigger the command on a frame anchored to header/footer is not editing it
    4957             :             FrameControlType eControl;
    4958           0 :             bool bOverFly = false;
    4959           0 :             bool bPageAnchored = false;
    4960           0 :             bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly, bPageAnchored );
    4961             :             // !bOverHeaderFooterFly doesn't mean we have a frame to select
    4962           0 :             if ( !bPageAnchored && rCEvt.IsMouseEvent( ) &&
    4963           0 :                  ( ( rSh.IsHeaderFooterEdit( ) && !bOverHeaderFooterFly && bOverFly ) ||
    4964           0 :                    ( !rSh.IsHeaderFooterEdit( ) && bOverHeaderFooterFly ) ) )
    4965             :             {
    4966             :                 return;
    4967             :             }
    4968             : 
    4969           0 :             if((!pChildWin || pChildWin->GetView() != &rView) &&
    4970           0 :                 !rSh.IsDrawCreate() && !IsDrawAction())
    4971             :             {
    4972           0 :                 SET_CURR_SHELL( &rSh );
    4973           0 :                 if (!pApplyTempl)
    4974             :                 {
    4975           0 :                     if (bNoInterrupt == sal_True)
    4976             :                     {
    4977           0 :                         ReleaseMouse();
    4978           0 :                         bNoInterrupt = sal_False;
    4979           0 :                         bMBPressed = sal_False;
    4980             :                     }
    4981           0 :                     if ( rCEvt.IsMouseEvent() )
    4982             :                     {
    4983           0 :                         SelectMenuPosition(rSh, rCEvt.GetMousePosPixel());
    4984           0 :                         rView.StopShellTimer();
    4985             :                     }
    4986           0 :                     const Point aPixPos = LogicToPixel( aDocPos );
    4987             : 
    4988           0 :                     if ( rView.GetDocShell()->IsReadOnly() )
    4989             :                     {
    4990           0 :                         SwReadOnlyPopup* pROPopup = new SwReadOnlyPopup( aDocPos, rView );
    4991             : 
    4992           0 :                         ui::ContextMenuExecuteEvent aEvent;
    4993           0 :                         aEvent.SourceWindow = VCLUnoHelper::GetInterface( this );
    4994           0 :                         aEvent.ExecutePosition.X = aPixPos.X();
    4995           0 :                         aEvent.ExecutePosition.Y = aPixPos.Y();
    4996           0 :                         Menu* pMenu = 0;
    4997           0 :                         ::rtl::OUString sMenuName(RTL_CONSTASCII_USTRINGPARAM("private:resource/ReadonlyContextMenu"));
    4998           0 :                         if( GetView().TryContextMenuInterception( *pROPopup, sMenuName, pMenu, aEvent ) )
    4999             :                         {
    5000           0 :                             if ( pMenu )
    5001             :                             {
    5002           0 :                                 sal_uInt16 nExecId = ((PopupMenu*)pMenu)->Execute(this, aPixPos);
    5003           0 :                                 if( !::ExecuteMenuCommand( *static_cast<PopupMenu*>(pMenu), *rView.GetViewFrame(), nExecId ))
    5004           0 :                                     pROPopup->Execute(this, nExecId);
    5005             :                             }
    5006             :                             else
    5007           0 :                                 pROPopup->Execute(this, aPixPos);
    5008             :                         }
    5009           0 :                         delete pROPopup;
    5010             :                     }
    5011           0 :                     else if ( !rView.ExecSpellPopup( aDocPos ) )
    5012           0 :                         GetView().GetViewFrame()->GetDispatcher()->ExecutePopup( 0, this, &aPixPos);
    5013             :                 }
    5014           0 :                 else if (pApplyTempl->bUndo)
    5015           0 :                     rSh.Do(SwWrtShell::UNDO);
    5016           0 :                 bCallBase = sal_False;
    5017             :             }
    5018             :         }
    5019           0 :         break;
    5020             : 
    5021             :         case COMMAND_WHEEL:
    5022             :         case COMMAND_STARTAUTOSCROLL:
    5023             :         case COMMAND_AUTOSCROLL:
    5024           0 :             if( pShadCrsr )
    5025           0 :                 delete pShadCrsr, pShadCrsr = 0;
    5026           0 :             bCallBase = !rView.HandleWheelCommands( rCEvt );
    5027           0 :             break;
    5028             : 
    5029             :         case COMMAND_VOICE:
    5030             :             {
    5031             :                 // forward to Outliner if applicable
    5032           0 :                 if ( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
    5033             :                 {
    5034           0 :                     bCallBase = sal_False;
    5035           0 :                     rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
    5036           0 :                     break;
    5037             :                 }
    5038             : 
    5039           0 :                 const CommandVoiceData *pCData = rCEvt.GetVoiceData();
    5040           0 :                 if ( VOICECOMMANDTYPE_CONTROL == pCData->GetType() )
    5041           0 :                     break;
    5042             : 
    5043           0 :                 sal_uInt16 nSlotId = 0;
    5044           0 :                 SfxPoolItem *pItem = 0;
    5045             : 
    5046           0 :                 switch ( pCData->GetCommand() )
    5047             :                 {
    5048           0 :                     case DICTATIONCOMMAND_NEWPARAGRAPH: nSlotId = FN_INSERT_BREAK; break;
    5049           0 :                     case DICTATIONCOMMAND_NEWLINE:      nSlotId = FN_INSERT_LINEBREAK; break;
    5050           0 :                     case DICTATIONCOMMAND_LEFT:         nSlotId = FN_PREV_WORD; break;
    5051           0 :                     case DICTATIONCOMMAND_RIGHT:        nSlotId = FN_NEXT_WORD; break;
    5052           0 :                     case DICTATIONCOMMAND_UP:           nSlotId = FN_LINE_UP; break;
    5053           0 :                     case DICTATIONCOMMAND_DOWN:         nSlotId = FN_LINE_DOWN; break;
    5054           0 :                     case DICTATIONCOMMAND_UNDO:         nSlotId = SID_UNDO; break;
    5055           0 :                     case DICTATIONCOMMAND_REPEAT:       nSlotId = SID_REPEAT; break;
    5056           0 :                     case DICTATIONCOMMAND_DEL:          nSlotId = FN_DELETE_BACK_WORD; break;
    5057             : 
    5058           0 :                     case DICTATIONCOMMAND_BOLD_ON:      nSlotId = SID_ATTR_CHAR_WEIGHT;
    5059           0 :                                                         pItem = new SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT );
    5060           0 :                                                         break;
    5061           0 :                     case DICTATIONCOMMAND_BOLD_OFF:     nSlotId = SID_ATTR_CHAR_WEIGHT;
    5062           0 :                                                         pItem = new SvxWeightItem( WEIGHT_NORMAL, RES_CHRATR_WEIGHT );
    5063           0 :                                                         break;
    5064           0 :                     case DICTATIONCOMMAND_UNDERLINE_ON: nSlotId = SID_ATTR_CHAR_UNDERLINE;
    5065           0 :                                                         pItem = new SvxUnderlineItem( UNDERLINE_SINGLE, RES_CHRATR_WEIGHT );
    5066           0 :                                                         break;
    5067           0 :                     case DICTATIONCOMMAND_UNDERLINE_OFF:nSlotId = SID_ATTR_CHAR_UNDERLINE;
    5068           0 :                                                         pItem = new SvxUnderlineItem( UNDERLINE_NONE, RES_CHRATR_UNDERLINE );
    5069           0 :                                                         break;
    5070           0 :                     case DICTATIONCOMMAND_ITALIC_ON:    nSlotId = SID_ATTR_CHAR_POSTURE;
    5071           0 :                                                         pItem = new SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE );
    5072           0 :                                                         break;
    5073           0 :                     case DICTATIONCOMMAND_ITALIC_OFF:   nSlotId = SID_ATTR_CHAR_POSTURE;
    5074           0 :                                                         pItem = new SvxPostureItem( ITALIC_NONE, RES_CHRATR_POSTURE );
    5075           0 :                                                         break;
    5076             :                     case DICTATIONCOMMAND_NUMBERING_ON:
    5077           0 :                                     if ( !rSh.GetCurNumRule() )
    5078           0 :                                         nSlotId = FN_NUM_NUMBERING_ON;
    5079           0 :                                     break;
    5080             :                     case DICTATIONCOMMAND_NUMBERING_OFF:
    5081           0 :                                     if ( rSh.GetCurNumRule() )
    5082           0 :                                        nSlotId = FN_NUM_NUMBERING_ON;
    5083           0 :                                     break;
    5084             :                     case DICTATIONCOMMAND_TAB:
    5085             :                                     {
    5086           0 :                                        rSh.Insert( '\t' );
    5087             :                                     }
    5088           0 :                                     break;
    5089             :                     case DICTATIONCOMMAND_UNKNOWN:
    5090             :                                     {
    5091           0 :                                         rView.GetWrtShell().Insert( pCData->GetText() );
    5092             :                                     }
    5093           0 :                                     break;
    5094             : 
    5095             : #if OSL_DEBUG_LEVEL > 0
    5096             :                     default:
    5097             :                         OSL_ENSURE( !this, "unknown speech command." );
    5098             : #endif
    5099             :                 }
    5100           0 :                 if ( nSlotId )
    5101             :                 {
    5102           0 :                     bCallBase = sal_False;
    5103           0 :                     if ( pItem )
    5104             :                     {
    5105             :                         const SfxPoolItem* aArgs[2];
    5106           0 :                         aArgs[0] = pItem;
    5107           0 :                         aArgs[1] = 0;
    5108           0 :                         GetView().GetViewFrame()->GetBindings().Execute(
    5109           0 :                                     nSlotId, aArgs, 0, SFX_CALLMODE_STANDARD );
    5110           0 :                         delete pItem;
    5111             :                     }
    5112             :                     else
    5113           0 :                         GetView().GetViewFrame()->GetBindings().Execute( nSlotId );
    5114             :                 }
    5115             :             }
    5116           0 :             break;
    5117             : 
    5118             :     case COMMAND_STARTEXTTEXTINPUT:
    5119             :     {
    5120           0 :         sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
    5121           0 :                               rSh.IsCrsrReadonly();
    5122           0 :         if(!bIsDocReadOnly)
    5123             :         {
    5124           0 :             if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
    5125             :             {
    5126           0 :                 bCallBase = sal_False;
    5127           0 :                 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
    5128             :             }
    5129             :             else
    5130             :             {
    5131           0 :                 if( rSh.HasSelection() )
    5132           0 :                     rSh.DelRight();
    5133             : 
    5134           0 :                 bCallBase = sal_False;
    5135           0 :                 LanguageType eInputLanguage = GetInputLanguage();
    5136           0 :                 rSh.CreateExtTextInput(eInputLanguage);
    5137             :             }
    5138             :         }
    5139           0 :         break;
    5140             :     }
    5141             :     case COMMAND_ENDEXTTEXTINPUT:
    5142             :     {
    5143           0 :         sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
    5144           0 :                               rSh.IsCrsrReadonly();
    5145           0 :         if(!bIsDocReadOnly)
    5146             :         {
    5147           0 :             if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
    5148             :             {
    5149           0 :                 bCallBase = sal_False;
    5150           0 :                 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
    5151             :             }
    5152             :             else
    5153             :             {
    5154           0 :                 bCallBase = sal_False;
    5155           0 :                 String sRecord = rSh.DeleteExtTextInput();
    5156             :                 uno::Reference< frame::XDispatchRecorder > xRecorder =
    5157           0 :                         rView.GetViewFrame()->GetBindings().GetRecorder();
    5158             : 
    5159           0 :                 if ( sRecord.Len() )
    5160             :                 {
    5161             :                     // convert quotes in IME text
    5162             :                     // works on the last input character, this is escpecially in Korean text often done
    5163             :                     // quotes that are inside of the string are not replaced!
    5164           0 :                     const sal_Unicode aCh = sRecord.GetChar(sRecord.Len() - 1);
    5165           0 :                     SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
    5166           0 :                     SvxAutoCorrect* pACorr = rACfg.GetAutoCorrect();
    5167           0 :                     if(pACorr &&
    5168           0 :                         (( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))||
    5169           0 :                         ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh))))
    5170             :                     {
    5171           0 :                         rSh.DelLeft();
    5172           0 :                         rSh.AutoCorrect( *pACorr, aCh );
    5173             :                     }
    5174             : 
    5175           0 :                     if ( xRecorder.is() )
    5176             :                     {
    5177             :                         // determine Shell
    5178           0 :                         SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) );
    5179             :                         // generate request and record
    5180           0 :                         if (pSfxShell)
    5181             :                         {
    5182           0 :                             SfxRequest aReq( rView.GetViewFrame(), FN_INSERT_STRING );
    5183           0 :                             aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, sRecord ) );
    5184           0 :                             aReq.Done();
    5185             :                         }
    5186             :                     }
    5187           0 :                 }
    5188             :             }
    5189             :         }
    5190             :     }
    5191           0 :     break;
    5192             :     case COMMAND_EXTTEXTINPUT:
    5193             :     {
    5194           0 :         sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
    5195           0 :                               rSh.IsCrsrReadonly();
    5196           0 :         if(!bIsDocReadOnly)
    5197             :         {
    5198           0 :             if( pQuickHlpData->m_bIsDisplayed )
    5199           0 :                 pQuickHlpData->Stop( rSh );
    5200             : 
    5201           0 :             String sWord;
    5202           0 :             if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
    5203             :             {
    5204           0 :                 bCallBase = sal_False;
    5205           0 :                 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
    5206             :             }
    5207             :             else
    5208             :             {
    5209           0 :                 const CommandExtTextInputData* pData = rCEvt.GetExtTextInputData();
    5210           0 :                 if( pData )
    5211             :                 {
    5212           0 :                     sWord = pData->GetText();
    5213           0 :                     bCallBase = sal_False;
    5214           0 :                     rSh.SetExtTextInputData( *pData );
    5215             :                 }
    5216             :             }
    5217             :                 uno::Reference< frame::XDispatchRecorder > xRecorder =
    5218           0 :                         rView.GetViewFrame()->GetBindings().GetRecorder();
    5219           0 :                 if(!xRecorder.is())
    5220             :                 {
    5221           0 :                     SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
    5222           0 :                     SvxAutoCorrect* pACorr = rACfg.GetAutoCorrect();
    5223           0 :                     if( pACorr &&
    5224             :                         // If autocompletion required...
    5225           0 :                         ( rACfg.IsAutoTextTip() ||
    5226           0 :                           pACorr->GetSwFlags().bAutoCompleteWords ) &&
    5227             :                         // ... and extraction of last word from text input was successful...
    5228           0 :                         rSh.GetPrevAutoCorrWord( *pACorr, sWord ) )
    5229             :                     {
    5230             :                         // ... request for auto completion help to be shown.
    5231           0 :                         ShowAutoTextCorrectQuickHelp(sWord, &rACfg, pACorr, true);
    5232             :                     }
    5233           0 :                 }
    5234             :         }
    5235             :     }
    5236           0 :     break;
    5237             :     case COMMAND_CURSORPOS:
    5238             :         // will be handled by the base class
    5239           0 :         break;
    5240             : 
    5241             :     case COMMAND_PASTESELECTION:
    5242           0 :         if( !rView.GetDocShell()->IsReadOnly() )
    5243             :         {
    5244             :             TransferableDataHelper aDataHelper(
    5245           0 :                         TransferableDataHelper::CreateFromSelection( this ));
    5246           0 :             if( !aDataHelper.GetXTransferable().is() )
    5247             :                 break;
    5248             : 
    5249             :             sal_uLong nDropFormat;
    5250             :             sal_uInt16 nEventAction, nDropAction, nDropDestination;
    5251           0 :             nDropDestination = GetDropDestination( rCEvt.GetMousePosPixel() );
    5252           0 :             if( !nDropDestination )
    5253             :                 break;
    5254             : 
    5255             :             nDropAction = SotExchange::GetExchangeAction(
    5256           0 :                                 aDataHelper.GetDataFlavorExVector(),
    5257             :                                 nDropDestination, EXCHG_IN_ACTION_COPY,
    5258             :                                 EXCHG_IN_ACTION_COPY, nDropFormat,
    5259           0 :                                 nEventAction );
    5260           0 :             if( EXCHG_INOUT_ACTION_NONE != nDropAction )
    5261             :             {
    5262           0 :                 const Point aDocPt( PixelToLogic( rCEvt.GetMousePosPixel() ) );
    5263             :                 SwTransferable::PasteData( aDataHelper, rSh, nDropAction,
    5264             :                                     nDropFormat, nDropDestination, sal_False,
    5265             :                                     sal_False, &aDocPt, EXCHG_IN_ACTION_COPY,
    5266           0 :                                     sal_True );
    5267           0 :             }
    5268             :         }
    5269           0 :         break;
    5270             :         case COMMAND_MODKEYCHANGE :
    5271             :         {
    5272           0 :             const CommandModKeyData* pCommandData = (const CommandModKeyData*)rCEvt.GetData();
    5273           0 :             if(pCommandData->IsMod1() && !pCommandData->IsMod2())
    5274             :             {
    5275           0 :                 sal_uInt16 nSlot = 0;
    5276           0 :                 if(pCommandData->IsLeftShift() && !pCommandData->IsRightShift())
    5277           0 :                     nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT;
    5278           0 :                 else if(!pCommandData->IsLeftShift() && pCommandData->IsRightShift())
    5279           0 :                     nSlot = SID_ATTR_PARA_RIGHT_TO_LEFT;
    5280           0 :                 if(nSlot && SW_MOD()->GetCTLOptions().IsCTLFontEnabled())
    5281           0 :                     GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot);
    5282             :             }
    5283             :         }
    5284           0 :         break;
    5285             :         case COMMAND_HANGUL_HANJA_CONVERSION :
    5286           0 :             GetView().GetViewFrame()->GetDispatcher()->Execute(SID_HANGUL_HANJA_CONVERSION);
    5287           0 :         break;
    5288             :         case COMMAND_INPUTLANGUAGECHANGE :
    5289             :             // i#42732 - update state of fontname if input language changes
    5290           0 :             bInputLanguageSwitched = true;
    5291           0 :             SetUseInputLanguage( sal_True );
    5292           0 :         break;
    5293             :         case COMMAND_SELECTIONCHANGE:
    5294             :         {
    5295           0 :             const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData();
    5296           0 :             rSh.SttCrsrMove();
    5297           0 :             rSh.GoStartSentence();
    5298           0 :             rSh.GetCrsr()->GetPoint()->nContent += sal::static_int_cast<sal_uInt16, sal_uLong>(pData->GetStart());
    5299           0 :             rSh.SetMark();
    5300           0 :             rSh.GetCrsr()->GetMark()->nContent += sal::static_int_cast<sal_uInt16, sal_uLong>(pData->GetEnd() - pData->GetStart());
    5301           0 :             rSh.EndCrsrMove( sal_True );
    5302             :         }
    5303           0 :         break;
    5304             :         case COMMAND_PREPARERECONVERSION:
    5305           0 :         if( rSh.HasSelection() )
    5306             :         {
    5307           0 :             SwPaM *pCrsr = (SwPaM*)rSh.GetCrsr();
    5308             : 
    5309           0 :             if( rSh.IsMultiSelection() )
    5310             :             {
    5311           0 :                 if( pCrsr && !pCrsr->HasMark() &&
    5312           0 :                 pCrsr->GetPoint() == pCrsr->GetMark() )
    5313             :                 {
    5314           0 :                 rSh.GoPrevCrsr();
    5315           0 :                 pCrsr = (SwPaM*)rSh.GetCrsr();
    5316             :                 }
    5317             : 
    5318             :                 // Cancel all selections other than the last selected one.
    5319           0 :                 while( rSh.GetCrsr()->GetNext() != rSh.GetCrsr() )
    5320           0 :                 delete rSh.GetCrsr()->GetNext();
    5321             :             }
    5322             : 
    5323           0 :             if( pCrsr )
    5324             :             {
    5325           0 :                 sal_uLong nPosNodeIdx = pCrsr->GetPoint()->nNode.GetIndex();
    5326           0 :                 xub_StrLen nPosIdx = pCrsr->GetPoint()->nContent.GetIndex();
    5327           0 :                 sal_uLong nMarkNodeIdx = pCrsr->GetMark()->nNode.GetIndex();
    5328           0 :                 xub_StrLen nMarkIdx = pCrsr->GetMark()->nContent.GetIndex();
    5329             : 
    5330           0 :                 if( !rSh.GetCrsr()->HasMark() )
    5331           0 :                 rSh.GetCrsr()->SetMark();
    5332             : 
    5333           0 :                 rSh.SttCrsrMove();
    5334             : 
    5335           0 :                 if( nPosNodeIdx < nMarkNodeIdx )
    5336             :                 {
    5337           0 :                 rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx;
    5338           0 :                 rSh.GetCrsr()->GetPoint()->nContent = nPosIdx;
    5339           0 :                 rSh.GetCrsr()->GetMark()->nNode = nPosNodeIdx;
    5340           0 :                 rSh.GetCrsr()->GetMark()->nContent =
    5341           0 :                     rSh.GetCrsr()->GetCntntNode( sal_True )->Len();
    5342             :                 }
    5343           0 :                 else if( nPosNodeIdx == nMarkNodeIdx )
    5344             :                 {
    5345           0 :                 rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx;
    5346           0 :                 rSh.GetCrsr()->GetPoint()->nContent = nPosIdx;
    5347           0 :                 rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx;
    5348           0 :                 rSh.GetCrsr()->GetMark()->nContent = nMarkIdx;
    5349             :                 }
    5350             :                 else
    5351             :                 {
    5352           0 :                 rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx;
    5353           0 :                 rSh.GetCrsr()->GetMark()->nContent = nMarkIdx;
    5354           0 :                 rSh.GetCrsr()->GetPoint()->nNode = nMarkNodeIdx;
    5355           0 :                 rSh.GetCrsr()->GetPoint()->nContent =
    5356           0 :                     rSh.GetCrsr()->GetCntntNode( sal_False )->Len();
    5357             :                 }
    5358             : 
    5359           0 :                 rSh.EndCrsrMove( sal_True );
    5360             :             }
    5361             :         }
    5362           0 :         break;
    5363             : #if OSL_DEBUG_LEVEL > 0
    5364             :         default:
    5365             :             OSL_ENSURE( !this, "unknown command." );
    5366             : #endif
    5367             :     }
    5368           0 :     if (bCallBase)
    5369           0 :         Window::Command(rCEvt);
    5370             : }
    5371             : 
    5372             : /*  i#18686 select the object/cursor at the mouse
    5373             :     position of the context menu request */
    5374           0 : sal_Bool SwEditWin::SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos )
    5375             : {
    5376           0 :     sal_Bool bRet = sal_False;
    5377           0 :     const Point aDocPos( PixelToLogic( rMousePos ) );
    5378           0 :     const bool bIsInsideSelectedObj( rSh.IsInsideSelectedObj( aDocPos ) );
    5379             :     //create a synthetic mouse event out of the coordinates
    5380           0 :     MouseEvent aMEvt(rMousePos);
    5381           0 :     SdrView *pSdrView = rSh.GetDrawView();
    5382           0 :     if ( pSdrView )
    5383             :     {
    5384             :         // no close of insert_draw and reset of
    5385             :         // draw mode, if context menu position is inside a selected object.
    5386           0 :         if ( !bIsInsideSelectedObj && rView.GetDrawFuncPtr() )
    5387             :         {
    5388             : 
    5389           0 :             rView.GetDrawFuncPtr()->Deactivate();
    5390           0 :             rView.SetDrawFuncPtr(NULL);
    5391           0 :             rView.LeaveDrawCreate();
    5392           0 :             SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
    5393           0 :             rBind.Invalidate( SID_ATTR_SIZE );
    5394           0 :             rBind.Invalidate( SID_TABLE_CELL );
    5395             :         }
    5396             : 
    5397             :         // if draw text is active and there's a text selection
    5398             :         // at the mouse position then do nothing
    5399           0 :         if(rSh.GetSelectionType() & nsSelectionType::SEL_DRW_TXT)
    5400             :         {
    5401           0 :             OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
    5402           0 :             ESelection aSelection = pOLV->GetSelection();
    5403           0 :             if(!aSelection.IsZero())
    5404             :             {
    5405           0 :                 SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
    5406           0 :                 sal_Bool bVertical = pOutliner->IsVertical();
    5407           0 :                 const EditEngine& rEditEng = pOutliner->GetEditEngine();
    5408           0 :                 Point aEEPos(aDocPos);
    5409           0 :                 const Rectangle& rOutputArea = pOLV->GetOutputArea();
    5410             :                 // regard vertical mode
    5411           0 :                 if(bVertical)
    5412             :                 {
    5413           0 :                     aEEPos -= rOutputArea.TopRight();
    5414             :                     //invert the horizontal direction and exchange X and Y
    5415           0 :                     long nTemp = -aEEPos.X();
    5416           0 :                     aEEPos.X() = aEEPos.Y();
    5417           0 :                     aEEPos.Y() = nTemp;
    5418             :                 }
    5419             :                 else
    5420           0 :                     aEEPos -= rOutputArea.TopLeft();
    5421             : 
    5422           0 :                 EPosition aDocPosition = rEditEng.FindDocPosition(aEEPos);
    5423           0 :                 ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
    5424             :                 // make it a forward selection - otherwise the IsLess/IsGreater do not work :-(
    5425           0 :                 aSelection.Adjust();
    5426           0 :                 if(!aCompare.IsLess(aSelection)  && !aCompare.IsGreater(aSelection))
    5427             :                 {
    5428           0 :                     return sal_False;
    5429             :                 }
    5430             :             }
    5431             : 
    5432             :         }
    5433             : 
    5434           0 :         if (pSdrView->MouseButtonDown( aMEvt, this ) )
    5435             :         {
    5436           0 :             pSdrView->MouseButtonUp( aMEvt, this );
    5437           0 :             rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
    5438           0 :             return sal_True;
    5439             :         }
    5440             :     }
    5441           0 :     rSh.ResetCursorStack();
    5442             : 
    5443           0 :     if ( EnterDrawMode( aMEvt, aDocPos ) )
    5444             :     {
    5445           0 :         return sal_True;
    5446             :     }
    5447           0 :     if ( rView.GetDrawFuncPtr() && bInsFrm )
    5448             :     {
    5449           0 :         StopInsFrm();
    5450           0 :         rSh.Edit();
    5451             :     }
    5452             : 
    5453           0 :     UpdatePointer( aDocPos, 0 );
    5454             : 
    5455           0 :     if( !rSh.IsSelFrmMode() &&
    5456           0 :         !GetView().GetViewFrame()->GetDispatcher()->IsLocked() )
    5457             :     {
    5458             :         // Test if there is a draw object at that position and if it should be selected.
    5459           0 :         sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos);
    5460             : 
    5461           0 :         if(bShould)
    5462             :         {
    5463           0 :             rView.NoRotate();
    5464           0 :             rSh.HideCrsr();
    5465             : 
    5466           0 :             sal_Bool bUnLockView = !rSh.IsViewLocked();
    5467           0 :             rSh.LockView( sal_True );
    5468           0 :             sal_Bool bSelObj = rSh.SelectObj( aDocPos, 0);
    5469           0 :             if( bUnLockView )
    5470           0 :                 rSh.LockView( sal_False );
    5471             : 
    5472           0 :             if( bSelObj )
    5473             :             {
    5474           0 :                 bRet = sal_True;
    5475             :                 // in case the frame was deselected in the macro
    5476             :                 // just the cursor has to be displayed again.
    5477           0 :                 if( FRMTYPE_NONE == rSh.GetSelFrmType() )
    5478           0 :                     rSh.ShowCrsr();
    5479             :                 else
    5480             :                 {
    5481           0 :                     if (rSh.IsFrmSelected() && rView.GetDrawFuncPtr())
    5482             :                     {
    5483           0 :                         rView.GetDrawFuncPtr()->Deactivate();
    5484           0 :                         rView.SetDrawFuncPtr(NULL);
    5485           0 :                         rView.LeaveDrawCreate();
    5486           0 :                         rView.AttrChangedNotify( &rSh );
    5487             :                     }
    5488             : 
    5489           0 :                     rSh.EnterSelFrmMode( &aDocPos );
    5490           0 :                     bFrmDrag = sal_True;
    5491           0 :                     UpdatePointer( aDocPos, 0 );
    5492           0 :                     return bRet;
    5493             :                 }
    5494             :             }
    5495             : 
    5496           0 :             if (!rView.GetDrawFuncPtr())
    5497           0 :                 rSh.ShowCrsr();
    5498             :         }
    5499             :     }
    5500           0 :     else if ( rSh.IsSelFrmMode() &&
    5501             :               (aActHitType == SDRHIT_NONE ||
    5502           0 :                !bIsInsideSelectedObj))
    5503             :     {
    5504           0 :         rView.NoRotate();
    5505           0 :         sal_Bool bUnLockView = !rSh.IsViewLocked();
    5506           0 :         rSh.LockView( sal_True );
    5507           0 :         sal_uInt8 nFlag = 0;
    5508             : 
    5509           0 :         if ( rSh.IsSelFrmMode() )
    5510             :         {
    5511           0 :             rSh.UnSelectFrm();
    5512           0 :             rSh.LeaveSelFrmMode();
    5513           0 :             rView.AttrChangedNotify(&rSh);
    5514           0 :             bRet = sal_True;
    5515             :         }
    5516             : 
    5517           0 :         sal_Bool bSelObj = rSh.SelectObj( aDocPos, nFlag );
    5518           0 :         if( bUnLockView )
    5519           0 :             rSh.LockView( sal_False );
    5520             : 
    5521           0 :         if( !bSelObj )
    5522             :         {
    5523             :             // move cursor here so that it is not drawn in the
    5524             :             // frame at first; ShowCrsr() happens in LeaveSelFrmMode()
    5525           0 :             bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
    5526           0 :             rSh.LeaveSelFrmMode();
    5527           0 :             rView.LeaveDrawCreate();
    5528           0 :             rView.AttrChangedNotify( &rSh );
    5529           0 :             bRet = sal_True;
    5530             :         }
    5531             :         else
    5532             :         {
    5533           0 :             rSh.HideCrsr();
    5534           0 :             rSh.EnterSelFrmMode( &aDocPos );
    5535           0 :             rSh.SelFlyGrabCrsr();
    5536           0 :             rSh.MakeSelVisible();
    5537           0 :             bFrmDrag = sal_True;
    5538           0 :             if( rSh.IsFrmSelected() &&
    5539           0 :                 rView.GetDrawFuncPtr() )
    5540             :             {
    5541           0 :                 rView.GetDrawFuncPtr()->Deactivate();
    5542           0 :                 rView.SetDrawFuncPtr(NULL);
    5543           0 :                 rView.LeaveDrawCreate();
    5544           0 :                 rView.AttrChangedNotify( &rSh );
    5545             :             }
    5546           0 :             UpdatePointer( aDocPos, 0 );
    5547           0 :             bRet = sal_True;
    5548             :         }
    5549             :     }
    5550           0 :     else if ( rSh.IsSelFrmMode() && bIsInsideSelectedObj )
    5551             :     {
    5552             :         // ## object at the mouse cursor is already selected - do nothing
    5553           0 :         return sal_False;
    5554             :     }
    5555             : 
    5556           0 :     if ( rSh.IsGCAttr() )
    5557             :     {
    5558           0 :         rSh.GCAttr();
    5559           0 :         rSh.ClearGCAttr();
    5560             :     }
    5561             : 
    5562           0 :     sal_Bool bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = sal_False;
    5563           0 :     if( !bOverSelect )
    5564           0 :         bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos );
    5565             : 
    5566           0 :     if ( !bOverSelect )
    5567             :     {
    5568             :         {   // create only temporary move context because otherwise
    5569             :             // the query against the content form doesn't work!!!
    5570           0 :             SwMvContext aMvContext( &rSh );
    5571           0 :             rSh.SetCursor(&aDocPos, false);
    5572           0 :             bRet = sal_True;
    5573             :         }
    5574             :     }
    5575           0 :     if( !bOverURLGrf )
    5576             :     {
    5577           0 :         const int nSelType = rSh.GetSelectionType();
    5578           0 :         if( nSelType == nsSelectionType::SEL_OLE ||
    5579             :             nSelType == nsSelectionType::SEL_GRF )
    5580             :         {
    5581           0 :             SwMvContext aMvContext( &rSh );
    5582           0 :             if( !rSh.IsFrmSelected() )
    5583           0 :                 rSh.GotoNextFly();
    5584           0 :             rSh.EnterSelFrmMode();
    5585           0 :             bRet = sal_True;
    5586             :         }
    5587             :     }
    5588           0 :     return bRet;
    5589             : }
    5590             : 
    5591           0 : static SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType )
    5592             : {
    5593             :     // determine Shell
    5594             :     SfxShell* pShell;
    5595           0 :     SfxDispatcher* pDispatcher = rView.GetViewFrame()->GetDispatcher();
    5596           0 :     for(sal_uInt16  i = 0; sal_True; ++i )
    5597             :     {
    5598           0 :         pShell = pDispatcher->GetShell( i );
    5599           0 :         if( !pShell || pShell->IsA( nType ) )
    5600           0 :             break;
    5601             :     }
    5602           0 :     return pShell;
    5603             : }
    5604             : 
    5605           0 : IMPL_LINK_NOARG(SwEditWin, KeyInputFlushHandler)
    5606             : {
    5607           0 :     FlushInBuffer();
    5608           0 :     return 0;
    5609             : }
    5610             : 
    5611           0 : IMPL_LINK_NOARG(SwEditWin, KeyInputTimerHandler)
    5612             : {
    5613           0 :     bTblInsDelMode = sal_False;
    5614           0 :     return 0;
    5615             : }
    5616             : 
    5617          24 : void SwEditWin::_InitStaticData()
    5618             : {
    5619          24 :     pQuickHlpData = new QuickHelpData();
    5620          24 : }
    5621             : 
    5622          24 : void SwEditWin::_FinitStaticData()
    5623             : {
    5624          24 :     delete pQuickHlpData;
    5625          24 : }
    5626             : /* i#3370 - remove quick help to prevent saving
    5627             :  * of autocorrection suggestions */
    5628          12 : void SwEditWin::StopQuickHelp()
    5629             : {
    5630          12 :     if( HasFocus() && pQuickHlpData && pQuickHlpData->m_bIsDisplayed  )
    5631           0 :         pQuickHlpData->Stop( rView.GetWrtShell() );
    5632          12 : }
    5633             : 
    5634           0 : IMPL_LINK_NOARG(SwEditWin, TemplateTimerHdl)
    5635             : {
    5636           0 :     SetApplyTemplate(SwApplyTemplate());
    5637           0 :     return 0;
    5638             : }
    5639             : 
    5640           0 : void SwEditWin::SetChainMode( sal_Bool bOn )
    5641             : {
    5642           0 :     if ( !bChainMode )
    5643           0 :         StopInsFrm();
    5644             : 
    5645           0 :     if ( pUserMarker )
    5646             :     {
    5647           0 :         delete pUserMarker;
    5648           0 :         pUserMarker = 0L;
    5649             :     }
    5650             : 
    5651           0 :     bChainMode = bOn;
    5652             : 
    5653             :     static sal_uInt16 aInva[] =
    5654             :     {
    5655             :         FN_FRAME_CHAIN, FN_FRAME_UNCHAIN, 0
    5656             :     };
    5657           0 :     rView.GetViewFrame()->GetBindings().Invalidate(aInva);
    5658           0 : }
    5659             : 
    5660           0 : uno::Reference< ::com::sun::star::accessibility::XAccessible > SwEditWin::CreateAccessible()
    5661             : {
    5662           0 :     SolarMutexGuard aGuard;   // this should have happend already!!!
    5663           0 :     SwWrtShell *pSh = rView.GetWrtShellPtr();
    5664             :     OSL_ENSURE( pSh, "no writer shell, no accessible object" );
    5665             :     uno::Reference<
    5666           0 :         ::com::sun::star::accessibility::XAccessible > xAcc;
    5667           0 :     if( pSh )
    5668           0 :         xAcc = pSh->CreateAccessible();
    5669             : 
    5670           0 :     return xAcc;
    5671             : }
    5672             : 
    5673             : //-------------------------------------------------------------
    5674             : 
    5675           0 : void QuickHelpData::Move( QuickHelpData& rCpy )
    5676             : {
    5677           0 :     m_aHelpStrings.clear();
    5678           0 :     m_aHelpStrings.swap( rCpy.m_aHelpStrings );
    5679             : 
    5680           0 :     m_bIsDisplayed = rCpy.m_bIsDisplayed;
    5681           0 :     nLen = rCpy.nLen;
    5682           0 :     nCurArrPos = rCpy.nCurArrPos;
    5683           0 :     m_bAppendSpace = rCpy.m_bAppendSpace;
    5684           0 :     m_bIsTip = rCpy.m_bIsTip;
    5685           0 :     m_bIsAutoText = rCpy.m_bIsAutoText;
    5686           0 : }
    5687             : 
    5688          24 : void QuickHelpData::ClearCntnt()
    5689             : {
    5690          24 :     nLen = nCurArrPos = 0;
    5691          24 :     m_bIsDisplayed = m_bAppendSpace = false;
    5692          24 :     nTipId = 0;
    5693          24 :     m_aHelpStrings.clear();
    5694          24 :     m_bIsTip = true;
    5695          24 :     m_bIsAutoText = true;
    5696          24 : }
    5697             : 
    5698           0 : void QuickHelpData::Start( SwWrtShell& rSh, sal_uInt16 nWrdLen )
    5699             : {
    5700           0 :     if( USHRT_MAX != nWrdLen )
    5701             :     {
    5702           0 :         nLen = nWrdLen;
    5703           0 :         nCurArrPos = 0;
    5704             :     }
    5705           0 :     m_bIsDisplayed = true;
    5706             : 
    5707           0 :     Window& rWin = rSh.GetView().GetEditWin();
    5708           0 :     if( m_bIsTip )
    5709             :     {
    5710             :         Point aPt( rWin.OutputToScreenPixel( rWin.LogicToPixel(
    5711           0 :                     rSh.GetCharRect().Pos() )));
    5712           0 :         aPt.Y() -= 3;
    5713             :         nTipId = Help::ShowTip( &rWin, Rectangle( aPt, Size( 1, 1 )),
    5714           0 :                         m_aHelpStrings[ nCurArrPos ],
    5715           0 :                         QUICKHELP_LEFT | QUICKHELP_BOTTOM );
    5716             :     }
    5717             :     else
    5718             :     {
    5719           0 :         String sStr( m_aHelpStrings[ nCurArrPos ] );
    5720           0 :         sStr.Erase( 0, nLen );
    5721           0 :         sal_uInt16 nL = sStr.Len();
    5722             :         const sal_uInt16 nVal = EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE |
    5723           0 :                                 EXTTEXTINPUT_ATTR_HIGHLIGHT;
    5724           0 :         const std::vector<sal_uInt16> aAttrs( nL, nVal );
    5725           0 :         CommandExtTextInputData aCETID( sStr, &aAttrs[0], nL,
    5726           0 :                                         0, 0, 0, sal_False );
    5727             : 
    5728             :         //fdo#33092. If the current input language is the default
    5729             :         //language that text would appear in if typed, then don't
    5730             :         //force a language on for the ExtTextInput.
    5731           0 :         LanguageType eInputLanguage = rWin.GetInputLanguage();
    5732           0 :         if (lcl_isNonDefaultLanguage(eInputLanguage,
    5733           0 :             rSh.GetView(), sStr) == INVALID_HINT)
    5734             :         {
    5735           0 :             eInputLanguage = LANGUAGE_DONTKNOW;
    5736             :         }
    5737             : 
    5738           0 :         rSh.CreateExtTextInput(eInputLanguage);
    5739           0 :         rSh.SetExtTextInputData( aCETID );
    5740             :     }
    5741           0 : }
    5742             : 
    5743           0 : void QuickHelpData::Stop( SwWrtShell& rSh )
    5744             : {
    5745           0 :     if( !m_bIsTip )
    5746           0 :         rSh.DeleteExtTextInput( 0, sal_False );
    5747           0 :     else if( nTipId )
    5748           0 :         Help::HideTip( nTipId );
    5749           0 :     ClearCntnt();
    5750           0 : }
    5751             : 
    5752           0 : void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord, bool bIgnoreCurrentPos )
    5753             : {
    5754             :     enum Capitalization { CASE_LOWER, CASE_UPPER, CASE_SENTENCE, CASE_OTHER };
    5755             : 
    5756             :     // Determine word capitalization
    5757           0 :     const CharClass& rCC = GetAppCharClass();
    5758           0 :     const String sWordLower = rCC.lowercase( rWord );
    5759           0 :     Capitalization aWordCase = CASE_OTHER;
    5760           0 :     if ( rWord.Len() > 0 )
    5761             :     {
    5762           0 :         if ( rWord.GetChar(0) == sWordLower.GetChar(0) )
    5763             :         {
    5764           0 :             if ( rWord == sWordLower )
    5765           0 :                 aWordCase = CASE_LOWER;
    5766             :         }
    5767             :         else
    5768             :         {
    5769             :             // First character is not lower case i.e. assume upper or title case
    5770           0 :             String sWordSentence = sWordLower;
    5771           0 :             sWordSentence.SetChar( 0, rWord.GetChar(0) );
    5772           0 :             if ( rWord == sWordSentence )
    5773           0 :                 aWordCase = CASE_SENTENCE;
    5774             :             else
    5775             :             {
    5776           0 :                 if ( rWord == static_cast<String>( rCC.uppercase( rWord ) ) )
    5777           0 :                     aWordCase = CASE_UPPER;
    5778           0 :             }
    5779             :         }
    5780             :     }
    5781             : 
    5782           0 :     salhelper::SingletonRef<SwCalendarWrapper>* pCalendar = s_getCalendarWrapper();
    5783           0 :     (*pCalendar)->LoadDefaultCalendar( rSh.GetCurLang() );
    5784             : 
    5785             :     // Add matching calendar month and day names
    5786           0 :     uno::Sequence< i18n::CalendarItem2 > aNames( (*pCalendar)->getMonths() );
    5787           0 :     for ( sal_uInt16 i = 0; i < 2; ++i )
    5788             :     {
    5789           0 :         for ( long n = 0; n < aNames.getLength(); ++n )
    5790             :         {
    5791           0 :             const String& rStr( aNames[n].FullName );
    5792             :             // Check string longer than word and case insensitive match
    5793           0 :             if( rStr.Len() > rWord.Len() &&
    5794           0 :                 static_cast<String>( rCC.lowercase( rStr, 0, rWord.Len() ) )
    5795           0 :                 == sWordLower )
    5796             :             {
    5797           0 :                 if ( aWordCase == CASE_LOWER )
    5798           0 :                     m_aHelpStrings.push_back( rCC.lowercase( rStr ) );
    5799           0 :                 else if ( aWordCase == CASE_SENTENCE )
    5800             :                 {
    5801           0 :                     String sTmp = rCC.lowercase( rStr );
    5802           0 :                     sTmp.SetChar( 0, rStr.GetChar(0) );
    5803           0 :                     m_aHelpStrings.push_back( sTmp );
    5804             :                 }
    5805           0 :                 else if ( aWordCase == CASE_UPPER )
    5806           0 :                     m_aHelpStrings.push_back( rCC.uppercase( rStr ) );
    5807             :                 else // CASE_OTHER - use retrieved capitalization
    5808           0 :                     m_aHelpStrings.push_back( rStr );
    5809             :             }
    5810           0 :         }
    5811             :         // Data for second loop iteration
    5812           0 :         if ( i == 0 )
    5813           0 :             aNames = (*pCalendar)->getDays();
    5814             :     }
    5815             : 
    5816             :     // Add matching words from AutoCompleteWord list
    5817           0 :     const SwAutoCompleteWord& rACList = rSh.GetAutoCompleteWords();
    5818           0 :     std::vector<String> strings;
    5819             : 
    5820           0 :     if ( rACList.GetWordsMatching( rWord, strings, bIgnoreCurrentPos ) )
    5821             :     {
    5822           0 :         for (unsigned int i= 0; i<strings.size(); i++)
    5823             :         {
    5824           0 :             String aCompletedString = strings[i];
    5825           0 :             if ( aWordCase == CASE_LOWER )
    5826           0 :                 m_aHelpStrings.push_back( rCC.lowercase( aCompletedString ) );
    5827           0 :             else if ( aWordCase == CASE_SENTENCE )
    5828             :             {
    5829           0 :                 String sTmp = rCC.lowercase( aCompletedString );
    5830           0 :                 sTmp.SetChar( 0, aCompletedString.GetChar(0) );
    5831           0 :                 m_aHelpStrings.push_back( sTmp );
    5832             :             }
    5833           0 :             else if ( aWordCase == CASE_UPPER )
    5834           0 :                 m_aHelpStrings.push_back( rCC.uppercase( aCompletedString ) );
    5835             :             else // CASE_OTHER - use retrieved capitalization
    5836           0 :                 m_aHelpStrings.push_back( aCompletedString );
    5837           0 :         }
    5838           0 :     }
    5839             : 
    5840           0 : }
    5841             : 
    5842             : namespace {
    5843             : 
    5844             : struct CompareIgnoreCaseAscii
    5845             : {
    5846           0 :     bool operator()(const String& s1, const String& s2) const
    5847             :     {
    5848           0 :         return s1.CompareIgnoreCaseToAscii(s2) == COMPARE_LESS;
    5849             :     }
    5850             : };
    5851             : 
    5852             : struct EqualIgnoreCaseAscii
    5853             : {
    5854           0 :     bool operator()(const String& s1, const String& s2) const
    5855             :     {
    5856           0 :         return s1.CompareIgnoreCaseToAscii(s2) == COMPARE_EQUAL;
    5857             :     }
    5858             : };
    5859             : 
    5860             : } // anonymous namespace
    5861             : 
    5862             : // TODO - implement an i18n aware sort
    5863           0 : void QuickHelpData::SortAndFilter()
    5864             : {
    5865             :     std::sort( m_aHelpStrings.begin(),
    5866             :                m_aHelpStrings.end(),
    5867           0 :                CompareIgnoreCaseAscii() );
    5868             : 
    5869             :     std::vector<String>::iterator it = std::unique( m_aHelpStrings.begin(),
    5870             :                                                     m_aHelpStrings.end(),
    5871           0 :                                                     EqualIgnoreCaseAscii() );
    5872           0 :     m_aHelpStrings.erase( it, m_aHelpStrings.end() );
    5873             : 
    5874           0 :     nCurArrPos = 0;
    5875           0 : }
    5876             : 
    5877           0 : void SwEditWin::ShowAutoTextCorrectQuickHelp(
    5878             :         const String& rWord, SvxAutoCorrCfg* pACfg, SvxAutoCorrect* pACorr,
    5879             :         bool bFromIME )
    5880             : {
    5881           0 :     SwWrtShell& rSh = rView.GetWrtShell();
    5882           0 :     pQuickHlpData->ClearCntnt();
    5883           0 :     if( pACfg->IsAutoTextTip() )
    5884             :     {
    5885           0 :         SwGlossaryList* pList = ::GetGlossaryList();
    5886           0 :         pList->HasLongName( rWord, &pQuickHlpData->m_aHelpStrings );
    5887             :     }
    5888             : 
    5889           0 :     if( pQuickHlpData->m_aHelpStrings.empty() &&
    5890           0 :         pACorr->GetSwFlags().bAutoCompleteWords )
    5891             :     {
    5892           0 :         pQuickHlpData->m_bIsAutoText = false;
    5893             :         pQuickHlpData->m_bIsTip = bFromIME ||
    5894             :                     !pACorr ||
    5895           0 :                     pACorr->GetSwFlags().bAutoCmpltShowAsTip;
    5896             : 
    5897             :         // Get the neccessary data to show help text.
    5898           0 :         pQuickHlpData->FillStrArr( rSh, rWord, bFromIME );
    5899             :     }
    5900             : 
    5901             : 
    5902           0 :     if( !pQuickHlpData->m_aHelpStrings.empty() )
    5903             :     {
    5904           0 :         pQuickHlpData->SortAndFilter();
    5905           0 :         pQuickHlpData->Start( rSh, rWord.Len() );
    5906             :     }
    5907           0 : }
    5908             : 
    5909           0 : bool SwEditWin::IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const
    5910             : {
    5911           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    5912           0 :     const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( rDocPt );
    5913             : 
    5914           0 :     if ( pPageFrm && pPageFrm->IsOverHeaderFooterArea( rDocPt, rControl ) )
    5915           0 :         return true;
    5916             : 
    5917           0 :     if ( rSh.IsShowHeaderFooterSeparator( Header ) || rSh.IsShowHeaderFooterSeparator( Footer ) )
    5918             :     {
    5919           0 :         SwFrameControlsManager &rMgr = rSh.GetView().GetEditWin().GetFrameControlsManager();
    5920           0 :         Point aPoint( LogicToPixel( rDocPt ) );
    5921             : 
    5922           0 :         if ( rSh.IsShowHeaderFooterSeparator( Header ) )
    5923             :         {
    5924           0 :             SwFrameControlPtr pControl = rMgr.GetControl( Header, pPageFrm );
    5925           0 :             if ( pControl.get() && pControl->Contains( aPoint ) )
    5926             :             {
    5927           0 :                 rControl = Header;
    5928           0 :                 return true;
    5929           0 :             }
    5930             :         }
    5931             : 
    5932           0 :         if ( rSh.IsShowHeaderFooterSeparator( Footer ) )
    5933             :         {
    5934           0 :             SwFrameControlPtr pControl = rMgr.GetControl( Footer, pPageFrm );
    5935           0 :             if ( pControl.get() && pControl->Contains( aPoint ) )
    5936             :             {
    5937           0 :                 rControl = Footer;
    5938           0 :                 return true;
    5939           0 :             }
    5940             :         }
    5941             :     }
    5942             : 
    5943           0 :     return false;
    5944             : }
    5945             : 
    5946           0 : bool SwEditWin::IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const
    5947             : {
    5948           0 :     bool bRet = false;
    5949           0 :     Point aPt( rDocPos );
    5950           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    5951           0 :     SwPaM aPam( *rSh.GetCurrentShellCursor().GetPoint() );
    5952           0 :     rSh.GetLayout()->GetCrsrOfst( aPam.GetPoint(), aPt, NULL, true );
    5953             : 
    5954           0 :     const SwStartNode* pStartFly = aPam.GetPoint()->nNode.GetNode().FindFlyStartNode();
    5955           0 :     if ( pStartFly )
    5956             :     {
    5957           0 :         bOverFly = true;
    5958           0 :         SwFrmFmt* pFlyFmt = pStartFly->GetFlyFmt( );
    5959           0 :         if ( pFlyFmt )
    5960             :         {
    5961           0 :             const SwPosition* pAnchor = pFlyFmt->GetAnchor( ).GetCntntAnchor( );
    5962           0 :             if ( pAnchor )
    5963             :             {
    5964           0 :                 bool bInHeader = pAnchor->nNode.GetNode( ).FindHeaderStartNode( ) != NULL;
    5965           0 :                 bool bInFooter = pAnchor->nNode.GetNode( ).FindFooterStartNode( ) != NULL;
    5966             : 
    5967           0 :                 bRet = bInHeader || bInFooter;
    5968           0 :                 if ( bInHeader )
    5969           0 :                     rControl = Header;
    5970           0 :                 else if ( bInFooter )
    5971           0 :                     rControl = Footer;
    5972             :             }
    5973             :             else
    5974           0 :                 bPageAnchored = pFlyFmt->GetAnchor( ).GetAnchorId( ) == FLY_AT_PAGE;
    5975             :         }
    5976             :     }
    5977             :     else
    5978           0 :         bOverFly = false;
    5979           0 :     return bRet;
    5980             : }
    5981             : 
    5982           0 : void SwEditWin::SetUseInputLanguage( sal_Bool bNew )
    5983             : {
    5984           0 :     if ( bNew || bUseInputLanguage )
    5985             :     {
    5986           0 :         SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
    5987           0 :         rBind.Invalidate( SID_ATTR_CHAR_FONT );
    5988           0 :         rBind.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
    5989             :     }
    5990           0 :     bUseInputLanguage = bNew;
    5991           0 : }
    5992             : 
    5993           0 : rtl::OUString SwEditWin::GetSurroundingText() const
    5994             : {
    5995           0 :     String sReturn;
    5996           0 :     SwWrtShell& rSh = rView.GetWrtShell();
    5997           0 :     if( rSh.HasSelection() && !rSh.IsMultiSelection() && rSh.IsSelOnePara() )
    5998           0 :         rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR  );
    5999           0 :     else if( !rSh.HasSelection() )
    6000             :     {
    6001           0 :         SwPosition *pPos = rSh.GetCrsr()->GetPoint();
    6002           0 :         xub_StrLen nPos = pPos->nContent.GetIndex();
    6003             : 
    6004             :         // get the sentence around the cursor
    6005           0 :         rSh.HideCrsr();
    6006           0 :         rSh.GoStartSentence();
    6007           0 :         rSh.SetMark();
    6008           0 :         rSh.GoEndSentence();
    6009           0 :         rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR  );
    6010             : 
    6011           0 :         pPos->nContent = nPos;
    6012           0 :         rSh.ClearMark();
    6013           0 :         rSh.HideCrsr();
    6014             :     }
    6015             : 
    6016           0 :     return sReturn;
    6017             : }
    6018             : 
    6019           0 : Selection SwEditWin::GetSurroundingTextSelection() const
    6020             : {
    6021           0 :     SwWrtShell& rSh = rView.GetWrtShell();
    6022           0 :     if( rSh.HasSelection() )
    6023             :     {
    6024           0 :         String sReturn;
    6025           0 :         rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR  );
    6026           0 :         return Selection( 0, sReturn.Len() );
    6027             :     }
    6028             :     else
    6029             :     {
    6030             :         // Return the position of the visible cursor in the sentence
    6031             :         // around the visible cursor.
    6032           0 :         SwPosition *pPos = rSh.GetCrsr()->GetPoint();
    6033           0 :         xub_StrLen nPos = pPos->nContent.GetIndex();
    6034             : 
    6035           0 :         rSh.HideCrsr();
    6036           0 :         rSh.GoStartSentence();
    6037           0 :         xub_StrLen nStartPos = rSh.GetCrsr()->GetPoint()->nContent.GetIndex();
    6038             : 
    6039           0 :         pPos->nContent = nPos;
    6040           0 :         rSh.ClearMark();
    6041           0 :         rSh.ShowCrsr();
    6042             : 
    6043           0 :         return Selection( nPos - nStartPos, nPos - nStartPos );
    6044             :     }
    6045          72 : }
    6046             : 
    6047             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10