LCOV - code coverage report
Current view: top level - sw/inc - viscrs.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 14 17 82.4 %
Date: 2015-06-13 12:38:46 Functions: 13 16 81.2 %
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_INC_VISCRS_HXX
      20             : #define INCLUDED_SW_INC_VISCRS_HXX
      21             : 
      22             : #include <config_features.h>
      23             : 
      24             : #include <vcl/cursor.hxx>
      25             : #include "swcrsr.hxx"
      26             : #include "swrect.hxx"
      27             : #include "swregion.hxx"
      28             : 
      29             : class SwCrsrShell;
      30             : class SwShellCrsr;
      31             : class SwTextInputField;
      32             : 
      33             : // From here classes/methods for non-text cursor.
      34             : 
      35             : class SwVisCrsr
      36             : {
      37             :     friend void _InitCore();
      38             :     friend void _FinitCore();
      39             : 
      40             :     bool m_bIsVisible;
      41             :     bool m_bIsDragCrsr;
      42             : 
      43             :     vcl::Cursor m_aTextCrsr;
      44             :     const SwCrsrShell* m_pCrsrShell;
      45             : 
      46             :     void _SetPosAndShow();
      47             : 
      48             : public:
      49             :     SwVisCrsr( const SwCrsrShell * pCShell );
      50             :     ~SwVisCrsr();
      51             : 
      52             :     void Show();
      53             :     void Hide();
      54             : 
      55       25702 :     bool IsVisible() const { return m_bIsVisible; }
      56           0 :     void SetDragCrsr( bool bFlag = true ) { m_bIsDragCrsr = bFlag; }
      57             : };
      58             : 
      59             : // From here classes/methods for selections.
      60             : 
      61             : namespace sdr { namespace overlay { class OverlayObject; }}
      62             : namespace sw { namespace overlay { class OverlayRangesOutline; }}
      63             : 
      64             : class SwSelPaintRects : public SwRects
      65             : {
      66             :     friend void _InitCore();
      67             :     friend void _FinitCore();
      68             : 
      69             :     static long s_nPixPtX, s_nPixPtY;
      70             :     static MapMode *s_pMapMode;
      71             : 
      72             :     const SwCrsrShell* m_pCursorShell;
      73             : 
      74             : #if HAVE_FEATURE_DESKTOP || defined(ANDROID)
      75             :     sdr::overlay::OverlayObject*    m_pCursorOverlay;
      76             : 
      77             :     // access to m_pCursorOverlay for swapContent
      78           0 :     sdr::overlay::OverlayObject* getCursorOverlay() const { return m_pCursorOverlay; }
      79           0 :     void setCursorOverlay(sdr::overlay::OverlayObject* pNew) { m_pCursorOverlay = pNew; }
      80             : #endif
      81             : 
      82             :     bool m_bShowTextInputFieldOverlay;
      83             :     sw::overlay::OverlayRangesOutline* m_pTextInputFieldOverlay;
      84             : 
      85             :     void HighlightInputField();
      86             : 
      87             : public:
      88             :     SwSelPaintRects( const SwCrsrShell& rCSh );
      89             :     virtual ~SwSelPaintRects();
      90             : 
      91             :     virtual void FillRects() = 0;
      92             :     /// Fill rStart and rEnd with a rectangle that represents the start and end for selection handles.
      93             :     virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const = 0;
      94             : 
      95             :     // #i75172# in SwCrsrShell::CreateCrsr() the content of SwSelPaintRects is exchanged. To
      96             :     // make a complete swap access to m_pCursorOverlay is needed there
      97             :     void swapContent(SwSelPaintRects& rSwap);
      98             : 
      99             :     void Show(std::vector<OString>* pSelectionRectangles = 0);
     100             :     void Hide();
     101             :     void Invalidate( const SwRect& rRect );
     102             : 
     103        2176 :     inline void SetShowTextInputFieldOverlay( const bool bShow )
     104             :     {
     105        2176 :         m_bShowTextInputFieldOverlay = bShow;
     106        2176 :     }
     107             : 
     108      235802 :     const SwCrsrShell* GetShell() const { return m_pCursorShell; }
     109             :     // check current MapMode of the shell and set possibly the static members.
     110             :     // Optional set the parameters pX, pY
     111             :     static void Get1PixelInLogic( const SwViewShell& rSh,
     112             :                                     long* pX = 0, long* pY = 0 );
     113             : };
     114             : 
     115             : class SwShellCrsr : public virtual SwCursor, public SwSelPaintRects
     116             : {
     117             : private:
     118             :     // Document positions of start/end characters of a SSelection.
     119             :     Point m_MarkPt;
     120             :     Point m_PointPt;
     121             :     const SwPosition* m_pInitialPoint; // For assignment of GetPoint() to m_PointPt.
     122             : 
     123             :     using SwCursor::UpDown;
     124             : 
     125             : public:
     126             :     SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos );
     127             :     SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos,
     128             :                     const Point& rPtPos, SwPaM* pRing = 0 );
     129             :     // note: *intentionally* links the new shell cursor into the old one's Ring
     130             :     SwShellCrsr( SwShellCrsr& );
     131             :     virtual ~SwShellCrsr();
     132             : 
     133             :     virtual void FillRects() SAL_OVERRIDE;   // For Table- und normal cursors.
     134             :     /// @see SwSelPaintRects::FillStartEnd(), override for text selections.
     135             :     virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const SAL_OVERRIDE;
     136             : 
     137             :     void Show();            // Update and display all selections.
     138             :     void Hide();            // Hide all selections.
     139             :     void Invalidate( const SwRect& rRect );
     140             : 
     141          45 :     const Point& GetPtPos() const   { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
     142      260017 :           Point& GetPtPos()         { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
     143          12 :     const Point& GetMkPos() const   { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
     144          65 :           Point& GetMkPos()         { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
     145          31 :     const Point& GetSttPos() const  { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
     146        1059 :           Point& GetSttPos()        { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
     147          31 :     const Point& GetEndPos() const  { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
     148         981 :           Point& GetEndPos()        { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
     149             : 
     150             :     virtual void SetMark() SAL_OVERRIDE;
     151             : 
     152             :     virtual SwCursor* Create( SwPaM* pRing = 0 ) const SAL_OVERRIDE;
     153             : 
     154             :     virtual short MaxReplaceArived() SAL_OVERRIDE; //returns RET_YES/RET_CANCEL/RET_NO
     155             :     virtual void SaveTableBoxContent( const SwPosition* pPos = 0 ) SAL_OVERRIDE;
     156             : 
     157             :     bool UpDown( bool bUp, sal_uInt16 nCnt = 1 );
     158             : 
     159             :     // true: Cursor can be set to this position.
     160             :     virtual bool IsAtValidPos( bool bPoint = true ) const SAL_OVERRIDE;
     161             : 
     162             :     virtual bool IsReadOnlyAvailable() const SAL_OVERRIDE;
     163             : 
     164        9148 :     DECL_FIXEDMEMPOOL_NEWDEL( SwShellCrsr )
     165             : };
     166             : 
     167             : class SwShellTableCrsr : public virtual SwShellCrsr, public virtual SwTableCursor
     168             : {
     169             :     /// Left edge of the selection start (top left cell).
     170             :     SwRect m_aStart;
     171             :     /// Right edge of the selection end (bottom right cell).
     172             :     SwRect m_aEnd;
     173             :     // The Selection has the same order as the table boxes, i.e.
     174             :     // if something is deleted from the one array at a certain position
     175             :     // it has to be deleted from the other one as well!!
     176             : 
     177             : public:
     178             :     SwShellTableCrsr( const SwCrsrShell& rCrsrSh, const SwPosition& rPos );
     179             :     SwShellTableCrsr( const SwCrsrShell& rCrsrSh,
     180             :                     const SwPosition &rMkPos, const Point& rMkPt,
     181             :                     const SwPosition &rPtPos, const Point& rPtPt );
     182             :     virtual ~SwShellTableCrsr();
     183             : 
     184             :     virtual void FillRects() SAL_OVERRIDE;   // For table and normal cursor.
     185             :     /// @see SwSelPaintRects::FillStartEnd(), override for table selections.
     186             :     virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const SAL_OVERRIDE;
     187             : 
     188             :     // Check if SPoint is within table SSelection.
     189             :     bool IsInside( const Point& rPt ) const;
     190             : 
     191             :     virtual void SetMark() SAL_OVERRIDE;
     192             :     virtual SwCursor* Create( SwPaM* pRing = 0 ) const SAL_OVERRIDE;
     193             : 
     194             :     virtual short MaxReplaceArived() SAL_OVERRIDE; //returns RET_YES/RET_CANCEL/RET_NO
     195             :     virtual void SaveTableBoxContent( const SwPosition* pPos = 0 ) SAL_OVERRIDE;
     196             : 
     197             :     // true: Cursor can be set to this position.
     198             :     virtual bool IsAtValidPos( bool bPoint = true ) const SAL_OVERRIDE;
     199             : 
     200             : };
     201             : 
     202             : #endif // INCLUDED_SW_INC_VISCRS_HXX
     203             : 
     204             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11