LCOV - code coverage report
Current view: top level - sw/source/core/uibase/docvw - edtwin.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 3117 0.0 %
Date: 2014-04-14 Functions: 0 77 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10