LCOV - code coverage report
Current view: top level - sw/source/uibase/inc - edtwin.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 24 25.0 %
Date: 2015-06-13 12:38:46 Functions: 6 22 27.3 %
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             : #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_EDTWIN_HXX
      20             : #define INCLUDED_SW_SOURCE_UIBASE_INC_EDTWIN_HXX
      21             : 
      22             : #include <FrameControlsManager.hxx>
      23             : 
      24             : #include <sot/exchange.hxx>
      25             : #include <svx/svdobj.hxx>
      26             : #include <tools/link.hxx>
      27             : #include <vcl/timer.hxx>
      28             : #include <vcl/idle.hxx>
      29             : #include <vcl/window.hxx>
      30             : #include <svtools/transfer.hxx>
      31             : #include <swevent.hxx>
      32             : 
      33             : class   SwWrtShell;
      34             : class   SwView;
      35             : class   SwRect;
      36             : class   SwViewShell;
      37             : class   SwAnchorMarker;
      38             : class   SdrObject;
      39             : class   SwShadowCursor;
      40             : class   DataChangedEvent;
      41             : class   SvxAutoCorrCfg;
      42             : class   SvxAutoCorrect;
      43             : class   SwPaM;
      44             : struct  SwApplyTemplate;
      45             : struct  QuickHelpData;
      46             : class   SdrDropMarkerOverlay;
      47             : 
      48             : // input window
      49             : 
      50             : /** Window class for the Writer edit area, this is the one handling mouse
      51             :     and keyboard events and doing the final painting of the document from
      52             :     the buffered layout.
      53             : 
      54             :     To translate the pixel positions from the buffer OutputDevice to the real
      55             :     pixel positions, use the PixelToLogic methods of this class.
      56             :   */
      57             : class SwEditWin: public vcl::Window,
      58             :                 public DropTargetHelper, public DragSourceHelper
      59             : {
      60             : friend void     ScrollMDI(SwViewShell* pVwSh, const SwRect&,
      61             :                           sal_uInt16 nRangeX, sal_uInt16 nRangeY);
      62             : friend bool     IsScrollMDI(SwViewShell* pVwSh, const SwRect&);
      63             : 
      64             : friend void     SizeNotify(SwViewShell* pVwSh, const Size &);
      65             : 
      66             : friend void     PageNumNotify(  SwViewShell* pVwSh,
      67             :                                 sal_uInt16 nPhyNum,
      68             :                                 sal_uInt16 nVirtNum,
      69             :                                 const OUString& rPg );
      70             : 
      71             :     static  QuickHelpData* m_pQuickHlpData;
      72             : 
      73             :     static  long    m_nDDStartPosX, m_nDDStartPosY;
      74             : 
      75             :     static  Color   m_aWaterCanTextColor;     // text color; for the watering can
      76             :     static  Color   m_aWaterCanTextBackColor; // text background; for the watering can
      77             : 
      78             :     /*
      79             :      * timer and handler for scrolling on when the mousepointer
      80             :      * stops outside of EditWin during a drag-operation.
      81             :      * The selection is increased towards the mouse position
      82             :      * regularly.
      83             :      */
      84             :     AutoTimer       m_aTimer;
      85             :     // timer for overlapping KeyInputs (e.g. for tables)
      86             :     Timer           m_aKeyInputTimer;
      87             :     // timer for ANY-KeyInput question without a following KeyInputEvent
      88             :     Timer           m_aKeyInputFlushTimer;
      89             : 
      90             :     OUString        m_aInBuffer;
      91             :     LanguageType    m_eBufferLanguage;
      92             :     Point           m_aStartPos;
      93             :     Point           m_aMovePos;
      94             :     Point           m_aRszMvHdlPt;
      95             :     Idle            m_aTemplateIdle;
      96             : 
      97             :     // type/object where the mouse pointer is
      98             :     SwCallMouseEvent m_aSaveCallEvent;
      99             : 
     100             :     SwApplyTemplate     *m_pApplyTempl;
     101             :     SwAnchorMarker      *m_pAnchorMarker; // for relocating the anchor
     102             : 
     103             :     SdrDropMarkerOverlay    *m_pUserMarker;
     104             :     SdrObject               *m_pUserMarkerObj;
     105             :     SwShadowCursor          *m_pShadCrsr;
     106             :     Point                   *m_pRowColumnSelectionStart; // save position where table row/column selection has been started
     107             : 
     108             :     SwView         &m_rView;
     109             : 
     110             :     int             m_aActHitType;    // current mouse pointer
     111             : 
     112             :     SotClipboardFormatId m_nDropFormat;   // format from the last QueryDrop
     113             :     sal_uInt16      m_nDropAction;   // action from the last QueryDrop
     114             :     SotExchangeDest m_nDropDestination;  // destination from the last QueryDrop
     115             : 
     116             :     sal_uInt16      m_eBezierMode;
     117             :     sal_uInt16      m_nInsFrmColCount; // column number for interactive frame
     118             :     SdrObjKind      m_eDrawMode;
     119             :     bool        m_bMBPressed      : 1,
     120             :                     m_bInsDraw        : 1,
     121             :                     m_bInsFrm         : 1,
     122             :                     m_bIsInMove       : 1,
     123             :                     m_bIsInDrag       : 1, // don't execute StartExecuteDrag twice
     124             :                     m_bOldIdle        : 1, // to stop to idle
     125             :                     m_bOldIdleSet     : 1, // during QeueryDrop
     126             :                     m_bTableInsDelMode  : 1,
     127             :                     m_bTableIsInsMode   : 1,
     128             :                     m_bChainMode      : 1, // connect frames
     129             :                     m_bWasShdwCrsr    : 1, // ShadowCrsr was on in MouseButtonDown
     130             :                     m_bLockInput      : 1, // lock while calc panel is active
     131             :                     m_bIsRowDrag      : 1, //selection of rows is used, in combination with m_pRowColumnSelectionStart
     132             :                     /** #i42732# display status of font size/name depending on either the input language or the
     133             :                         selection position depending on what has changed lately
     134             :                      */
     135             :                     m_bUseInputLanguage: 1,
     136             :                     m_bObjectSelect   : 1;
     137             : 
     138             :     sal_uInt16          m_nKS_NUMDOWN_Count; // #i23725#
     139             :     sal_uInt16          m_nKS_NUMINDENTINC_Count;
     140             : 
     141             :     SwFrameControlsManager m_aFrameControlsManager;
     142             : 
     143             :     void            LeaveArea(const Point &);
     144             :     void            JustifyAreaTimer();
     145             :     inline void     EnterArea();
     146             : 
     147             :     void            RstMBDownFlags();
     148             : 
     149             :     void            ChangeFly( sal_uInt8 nDir, bool bWeb = false );
     150             :     void            ChangeDrawing( sal_uInt8 nDir );
     151             : 
     152             :     bool            EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos);
     153             :     bool            RulerColumnDrag( const MouseEvent& rMEvt, bool bVerticalMode);
     154             : 
     155             :     // helper function for D&D
     156             :     void            DropCleanup();
     157             :     void            CleanupDropUserMarker();
     158             :     SotExchangeDest GetDropDestination( const Point& rPixPnt,
     159             :                                         SdrObject ** ppObj = 0 );
     160             :     //select the object/cursor at the mouse position of the context menu request
     161             :     bool            SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos );
     162             : 
     163             :     /*
     164             :      * handler for scrolling on when the mousepointer
     165             :      * stopps outside of EditWin during a drag-operation.
     166             :      * The selection is regularly increased towards the mouse
     167             :      * position.
     168             :      */
     169             :     DECL_LINK_TYPED( TimerHandler, Timer *, void );
     170             :     void            StartDDTimer();
     171             :     void            StopDDTimer(SwWrtShell *, const Point &);
     172             :     DECL_LINK_TYPED( DDHandler, Timer *, void );
     173             : 
     174             :     // timer for ANY-KeyInut question without a following KeyInputEvent
     175             :     DECL_LINK_TYPED( KeyInputFlushHandler, Timer *, void );
     176             : 
     177             :     // timer for overlapping KeyInputs (e.g. for tables)
     178             :     DECL_LINK_TYPED( KeyInputTimerHandler, Timer *, void );
     179             : 
     180             :     // timer for ApplyTemplates via mouse (in disguise Drag&Drop)
     181             :     DECL_LINK_TYPED( TemplateTimerHdl, Idle *, void );
     182             : 
     183             :     void            MoveCursor( SwWrtShell &rSh, const Point& rDocPos,
     184             :                                 const bool bOnlyText, bool bLockView );
     185             : 
     186             : protected:
     187             : 
     188             :     virtual void    DataChanged( const DataChangedEvent& ) SAL_OVERRIDE;
     189             :     virtual void    PrePaint(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
     190             :     virtual void    Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
     191             : 
     192             :     virtual void    GetFocus() SAL_OVERRIDE;
     193             :     virtual void    LoseFocus() SAL_OVERRIDE;
     194             : 
     195             :     virtual void    MouseMove(const MouseEvent& rMEvt) SAL_OVERRIDE;
     196             :     virtual void    MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
     197             :     virtual void    MouseButtonUp(const MouseEvent& rMEvt) SAL_OVERRIDE;
     198             :     virtual void    RequestHelp(const HelpEvent& rEvt) SAL_OVERRIDE;
     199             : 
     200             :     virtual void    Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
     201             : 
     202             :                                 // Drag & Drop Interface
     203             :     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
     204             :     virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
     205             :     virtual void        StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
     206             : 
     207             :     virtual OUString GetSurroundingText() const SAL_OVERRIDE;
     208             :     virtual Selection GetSurroundingTextSelection() const SAL_OVERRIDE;
     209             : 
     210             :     void    ShowAutoTextCorrectQuickHelp( const OUString& rWord, SvxAutoCorrCfg* pACfg,
     211             :                                 SvxAutoCorrect* pACorr, bool bFromIME = false );
     212             : 
     213             :     /// Returns true if in header/footer area, or in the header/footer control.
     214             :     bool    IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const;
     215             : 
     216             :     bool    IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const;
     217             : public:
     218             : 
     219             :     virtual void    KeyInput(const KeyEvent &rKEvt) SAL_OVERRIDE;
     220             :     void            UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
     221             : 
     222             :     bool            IsDrawSelMode();
     223           0 :     bool            IsDrawAction()                  { return m_bInsDraw; }
     224           0 :     void            SetDrawAction(bool bFlag)       { m_bInsDraw = bFlag; }
     225             : 
     226           0 :     void            SetObjectSelect( bool bVal )    { m_bObjectSelect = bVal; }
     227           0 :     bool            IsObjectSelect() const          { return m_bObjectSelect; }
     228             : 
     229           0 :     inline SdrObjKind   GetSdrDrawMode() const { return m_eDrawMode; }
     230           0 :     inline void         SetSdrDrawMode( SdrObjKind eSdrObjectKind ) { m_eDrawMode = eSdrObjectKind; SetObjectSelect( false ); }
     231             :     void                StdDrawMode( SdrObjKind eSdrObjectKind, bool bObjSelect );
     232             : 
     233       19894 :     bool            IsFrmAction() const             { return m_bInsFrm; }
     234           0 :     sal_uInt16      GetBezierMode() const           { return m_eBezierMode; }
     235           0 :     void            SetBezierMode(sal_uInt16 eBezMode)  { m_eBezierMode = eBezMode; }
     236             :     void            EnterDrawTextMode(const Point& aDocPos); // turn on DrawTextEditMode
     237             :     void            InsFrm(sal_uInt16 nCols);
     238             :     void            StopInsFrm();
     239           0 :     sal_uInt16      GetFrmColCount() const {return m_nInsFrmColCount;} // column number for interactive frame
     240             : 
     241             :     void            SetChainMode( bool bOn );
     242       14509 :     bool            IsChainMode() const             { return m_bChainMode; }
     243             : 
     244             :     void            FlushInBuffer();
     245             :     static bool     IsInputSequenceCheckingRequired( const OUString &rText, const SwPaM& rCrsr );
     246             : 
     247             :     void             SetApplyTemplate(const SwApplyTemplate &);
     248        2372 :     SwApplyTemplate* GetApplyTemplate() const { return m_pApplyTempl; }
     249             : 
     250             :     void            StartExecuteDrag();
     251             :     void            DragFinished();
     252             :     sal_uInt16           GetDropAction() const { return m_nDropAction; }
     253             :     SotClipboardFormatId GetDropFormat() const { return m_nDropFormat; }
     254             : 
     255           0 :     static Color    GetWaterCanTextColor() { return m_aWaterCanTextColor; }
     256             : 
     257           0 :     static void     SetWaterCanTextColor(const Color& rCol ) { m_aWaterCanTextColor = rCol; }
     258             : 
     259           0 :     static Color    GetWaterCanTextBackColor()
     260           0 :                                             { return m_aWaterCanTextBackColor; }
     261           0 :     static void     SetWaterCanTextBackColor(const Color& rCol )
     262           0 :                                             { m_aWaterCanTextBackColor = rCol; }
     263           0 :     void            LockKeyInput(bool bSet){m_bLockInput = bSet;}
     264             : 
     265             :     const SwView &GetView() const { return m_rView; }
     266       46466 :           SwView &GetView()       { return m_rView; }
     267             : 
     268             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
     269             : 
     270           0 :     static inline long GetDDStartPosX() { return m_nDDStartPosX; }
     271           0 :     static inline long GetDDStartPosY() { return m_nDDStartPosY; }
     272             : 
     273             :     static void _InitStaticData();
     274             :     static void _FinitStaticData();
     275             : 
     276             :     //#i3370# remove quick help to prevent saving of autocorrection suggestions
     277             :     void StopQuickHelp();
     278             : 
     279             :     // #i42921# - add parameter <bVerticalMode>
     280             :     bool RulerMarginDrag( const MouseEvent& rMEvt,
     281             :                                      const bool bVerticalMode );
     282             : 
     283             :     /** #i42732# display status of font size/name depending on either the input
     284             :         language or the selection position depending on what has changed lately
     285             :      */
     286             :     void    SetUseInputLanguage( bool bNew );
     287        3887 :     bool    IsUseInputLanguage() const { return m_bUseInputLanguage; }
     288             : 
     289             :     /** fdo#55546 cut very long tooltips to 2/3 of the width of the screen
     290             :         via center ellipsis
     291             :      */
     292             :     OUString ClipLongToolTip(const OUString& rText);
     293             : 
     294       20050 :     SwFrameControlsManager& GetFrameControlsManager() { return m_aFrameControlsManager; }
     295             : 
     296             :     SwEditWin(vcl::Window *pParent, SwView &);
     297             :     virtual ~SwEditWin();
     298             :     virtual void dispose() SAL_OVERRIDE;
     299             : 
     300             :     /// @see OutputDevice::LogicInvalidate().
     301             :     void LogicInvalidate(const Rectangle* pRectangle) SAL_OVERRIDE;
     302             :     /// Same as MouseButtonDown(), but coordinates are in logic unit.
     303             :     void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
     304             :     /// Same as MouseButtonUp(), but coordinates are in logic unit.
     305             :     void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
     306             :     /// Same as MouseMove(), but coordinates are in logic unit.
     307             :     void LogicMouseMove(const MouseEvent& rMouseEvent);
     308             :     /// Allows adjusting the point or mark of the selection to a document coordinate.
     309             :     void SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool bClearMark);
     310             :     /// Allows starting or ending a graphic move or resize action.
     311             :     void SetGraphicTwipPosition(bool bStart, const Point& rPosition);
     312             : };
     313             : 
     314             : #endif
     315             : 
     316             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11