LibreOffice Module sw (master)  1
viscrs.hxx
Go to the documentation of this file.
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 namespace sdr { namespace overlay { class OverlayObject; } }
30 
31 class SwCursorShell;
32 class SfxViewShell;
33 
34 // From here classes/methods for non-text cursor.
35 
37 {
38  friend void InitCore();
39  friend void FinitCore();
40 
43 
46 
48  sal_uInt16 m_nPageLastTime;
49 
50 public:
51  SwVisibleCursor( const SwCursorShell * pCShell );
53 
54  void Show();
55  void Hide();
56 
57  bool IsVisible() const { return m_bIsVisible; }
58  void SetDragCursor( bool bFlag = true ) { m_bIsDragCursor = bFlag; }
59  void SetPosAndShow(SfxViewShell const * pViewShell);
60 };
61 
62 // From here classes/methods for selections.
63 
64 namespace sw { namespace overlay { class OverlayRangesOutline; }}
65 class MapMode;
66 
67 class SwSelPaintRects : public SwRects
68 {
69  friend void InitCore();
70  friend void FinitCore();
71 
72  static long s_nPixPtX, s_nPixPtY;
74 
76 
77 #if HAVE_FEATURE_DESKTOP || defined(ANDROID)
78  std::unique_ptr<sdr::overlay::OverlayObject> m_pCursorOverlay;
79 #endif
80 
82  std::unique_ptr<sw::overlay::OverlayRangesOutline> m_pTextInputFieldOverlay;
83 
84  void HighlightInputField();
85 
86 public:
87  SwSelPaintRects( const SwCursorShell& rCSh );
88  virtual ~SwSelPaintRects();
89 
90  virtual void FillRects() = 0;
92  virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const = 0;
93 
94  // #i75172# in SwCursorShell::CreateCursor() the content of SwSelPaintRects is exchanged. To
95  // make a complete swap access to m_pCursorOverlay is needed there
96  void swapContent(SwSelPaintRects& rSwap);
97 
98  void Show(std::vector<OString>* pSelectionRectangles = nullptr);
99  void Hide();
100  void Invalidate( const SwRect& rRect );
101 
102  void SetShowTextInputFieldOverlay( const bool bShow )
103  {
104  m_bShowTextInputFieldOverlay = bShow;
105  }
106 
107  const SwCursorShell* GetShell() const { return m_pCursorShell; }
108  // check current MapMode of the shell and set possibly the static members.
109  // Optional set the parameters pX, pY
110  static void Get1PixelInLogic( const SwViewShell& rSh,
111  long* pX = nullptr, long* pY = nullptr );
112 };
113 
114 class SW_DLLPUBLIC SwShellCursor : public virtual SwCursor, public SwSelPaintRects
115 {
116 private:
117  // Document positions of start/end characters of a SSelection.
120  const SwPosition* m_pInitialPoint; // For assignment of GetPoint() to m_PointPt.
121 
122  using SwCursor::UpDown;
123 
124 public:
125  SwShellCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos );
126  SwShellCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos,
127  const Point& rPtPos, SwPaM* pRing );
128  // note: *intentionally* links the new shell cursor into the old one's Ring
130  virtual ~SwShellCursor() override;
131 
132  virtual void FillRects() override; // For Table- and normal cursors.
134  virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
135 
136  void Show(SfxViewShell const * pViewShell); // Update and display all selections.
137  void Hide(); // Hide all selections.
138  void Invalidate( const SwRect& rRect );
139 
140  const Point& GetPtPos() const { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
141  Point& GetPtPos() { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
142  const Point& GetMkPos() const { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
143  Point& GetMkPos() { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
144  const Point& GetSttPos() const { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
145  Point& GetSttPos() { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
146  const Point& GetEndPos() const { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
147  Point& GetEndPos() { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
148 
149  virtual void SetMark() override;
150 
151  virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
152 
153  virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
154  virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
155 
156  bool UpDown( bool bUp, sal_uInt16 nCnt );
157 
158  // true: Cursor can be set to this position.
159  virtual bool IsAtValidPos( bool bPoint = true ) const override;
160 
161  virtual bool IsReadOnlyAvailable() const override;
162 
163  SwShellCursor* GetNext() { return dynamic_cast<SwShellCursor *>(GetNextInRing()); }
164  const SwShellCursor* GetNext() const { return dynamic_cast<SwShellCursor const *>(GetNextInRing()); }
165  SwShellCursor* GetPrev() { return dynamic_cast<SwShellCursor *>(GetPrevInRing()); }
166  const SwShellCursor* GetPrev() const { return dynamic_cast<SwShellCursor const *>(GetPrevInRing()); }
167 };
168 
169 class SwShellTableCursor : public virtual SwShellCursor, public virtual SwTableCursor
170 {
175  // The Selection has the same order as the table boxes, i.e.
176  // if something is deleted from the one array at a certain position
177  // it has to be deleted from the other one as well!!
178 
179 public:
180  SwShellTableCursor( const SwCursorShell& rCursorSh, const SwPosition& rPos );
181  SwShellTableCursor( const SwCursorShell& rCursorSh,
182  const SwPosition &rMkPos, const Point& rMkPt,
183  const SwPosition &rPtPos, const Point& rPtPt );
184  virtual ~SwShellTableCursor() override;
185 
186  virtual void FillRects() override; // For table and normal cursor.
188  virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
189 
190  // Check if SPoint is within table SSelection.
191  bool IsInside( const Point& rPt ) const;
192 
193  virtual void SetMark() override;
194  virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
195 
196  virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
197  virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
198 
199  // true: Cursor can be set to this position.
200  virtual bool IsAtValidPos( bool bPoint = true ) const override;
201 
202  SwShellTableCursor* GetNext() { return dynamic_cast<SwShellTableCursor *>(GetNextInRing()); }
203  const SwShellTableCursor* GetNext() const { return dynamic_cast<SwShellTableCursor const *>(GetNextInRing()); }
204  SwShellTableCursor* GetPrev() { return dynamic_cast<SwShellTableCursor *>(GetPrevInRing()); }
205  const SwShellTableCursor* GetPrev() const { return dynamic_cast<SwShellTableCursor const *>(GetPrevInRing()); }
206 };
207 
208 #endif // INCLUDED_SW_INC_VISCRS_HXX
209 
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bIsVisible
Definition: viscrs.hxx:41
virtual short MaxReplaceArived() override
Definition: viscrs.cxx:747
friend void FinitCore()
Definition: init.cxx:676
Marks a position in the document model.
Definition: pam.hxx:35
static long s_nPixPtY
Definition: viscrs.hxx:72
const SwPosition * m_pInitialPoint
Definition: viscrs.hxx:120
Point & GetEndPos()
Definition: viscrs.hxx:147
const SwShellCursor * GetNext() const
Definition: viscrs.hxx:164
virtual short MaxReplaceArived()
Definition: swcrsr.cxx:1112
virtual void SaveTableBoxContent(const SwPosition *pPos) override
Definition: viscrs.cxx:752
const SwPosition * GetMark() const
Definition: pam.hxx:209
Point & GetPtPos()
Definition: viscrs.hxx:141
virtual SwCursor * Create(SwPaM *pRing=nullptr) const
Definition: swcrsr.cxx:139
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
Definition: viscrs.cxx:742
const Point & GetSttPos() const
Definition: viscrs.hxx:144
SwRect m_aEnd
Right edge of the selection end (bottom right cell).
Definition: viscrs.hxx:174
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:40
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SwShellCursor * GetPrev()
Definition: viscrs.hxx:165
virtual bool IsAtValidPos(bool bPoint=true) const override
Return if cursor can be set to this position.
Definition: viscrs.cxx:858
const SwShellTableCursor * GetPrev() const
Definition: viscrs.hxx:205
void Invalidate(const SwRect &rRect)
Definition: viscrs.cxx:480
bool m_bShowTextInputFieldOverlay
Definition: viscrs.hxx:81
static long s_nPixPtX
Definition: viscrs.hxx:72
Point m_PointPt
Definition: viscrs.hxx:119
virtual void FillRects() override
Definition: viscrs.cxx:757
SwShellTableCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
Definition: viscrs.cxx:721
SwPaM * GetPrevInRing()
Definition: ring.hxx:87
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const =0
Fill rStart and rEnd with a rectangle that represents the start and end for selection handles...
friend void FinitCore()
Definition: init.cxx:676
static MapMode * s_pMapMode
Definition: viscrs.hxx:73
SwVisibleCursor(const SwCursorShell *pCShell)
Definition: viscrs.cxx:73
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
virtual ~SwShellTableCursor() override
Definition: viscrs.cxx:738
const SwCursorShell * m_pCursorShell
Definition: viscrs.hxx:75
const SwCursorShell * GetShell() const
Definition: viscrs.hxx:107
void SetPosAndShow(SfxViewShell const *pViewShell)
Definition: viscrs.cxx:114
const SwPosition * GetPoint() const
Definition: pam.hxx:207
SwPaM * GetNextInRing()
Definition: ring.hxx:84
void HighlightInputField()
Definition: viscrs.cxx:419
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
Definition: viscrs.cxx:820
bool IsInside(const Point &rPt) const
Definition: viscrs.cxx:827
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:740
const Point & GetMkPos() const
Definition: viscrs.hxx:142
Point & GetMkPos()
Definition: viscrs.hxx:143
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
void Show(std::vector< OString > *pSelectionRectangles=nullptr)
Definition: viscrs.cxx:310
friend void InitCore()
Definition: init.cxx:460
const SwPosition * Start() const
Definition: pam.hxx:212
SwShellTableCursor * GetNext()
Definition: viscrs.hxx:202
SwSelPaintRects(const SwCursorShell &rCSh)
Definition: viscrs.cxx:247
void SetShowTextInputFieldOverlay(const bool bShow)
Definition: viscrs.hxx:102
virtual ~SwSelPaintRects()
Definition: viscrs.cxx:256
virtual void FillRects()=0
virtual bool IsReadOnlyAvailable() const
Definition: swcrsr.cxx:144
static void Get1PixelInLogic(const SwViewShell &rSh, long *pX=nullptr, long *pY=nullptr)
Definition: viscrs.cxx:513
const SwShellTableCursor * GetNext() const
Definition: viscrs.hxx:203
std::vector< SwRect > SwRects
Definition: swregion.hxx:26
bool UpDown(bool bUp, sal_uInt16 nCnt, Point const *pPt, long nUpDownX, SwRootFrame &rLayout)
Definition: swcrsr.cxx:1923
bool m_bIsDragCursor
Definition: viscrs.hxx:42
vcl::Cursor m_aTextCursor
Definition: viscrs.hxx:44
SwShellCursor * GetNext()
Definition: viscrs.hxx:163
const SwPosition * End() const
Definition: pam.hxx:217
const Point & GetPtPos() const
Definition: viscrs.hxx:140
friend void InitCore()
Definition: init.cxx:460
void Show()
Definition: viscrs.cxx:91
virtual bool IsAtValidPos(bool bPoint=true) const
Return if cursor can be set to this position.
Definition: swcrsr.cxx:693
const Point & GetEndPos() const
Definition: viscrs.hxx:146
SwRect m_aStart
Left edge of the selection start (top left cell).
Definition: viscrs.hxx:172
sal_uInt16 m_nPageLastTime
For LibreOfficeKit only - remember what page we were at the last time.
Definition: viscrs.hxx:48
void SetDragCursor(bool bFlag=true)
Definition: viscrs.hxx:58
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:457
SwShellTableCursor * GetPrev()
Definition: viscrs.hxx:204
const SwCursorShell * m_pCursorShell
Definition: viscrs.hxx:45
const SwShellCursor * GetPrev() const
Definition: viscrs.hxx:166
Point m_MarkPt
Definition: viscrs.hxx:118
void swapContent(SwSelPaintRects &rSwap)
Definition: viscrs.cxx:261
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pTextInputFieldOverlay
Definition: viscrs.hxx:82
virtual void SaveTableBoxContent(const SwPosition *pPos)
Definition: swcrsr.cxx:719
Point & GetSttPos()
Definition: viscrs.hxx:145
bool IsVisible() const
Definition: viscrs.hxx:57