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 #pragma once
20 
21 #include <config_feature_desktop.h>
22 
23 #include <vcl/cursor.hxx>
24 #include "swcrsr.hxx"
25 #include "swrect.hxx"
26 #include "swregion.hxx"
27 #include "swdllapi.h"
28 
29 namespace sdr::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 
45  sal_uInt16 m_nPageLastTime;
47 
50 
51 public:
52  SwVisibleCursor( const SwCursorShell * pCShell );
53  ~SwVisibleCursor();
54 
55  void Show();
56  void Hide();
57 
58  bool IsVisible() const { return m_bIsVisible; }
59  void SetDragCursor( bool bFlag = true ) { m_bIsDragCursor = bFlag; }
60  void SetPosAndShow(SfxViewShell const * pViewShell);
61  const vcl::Cursor& GetTextCursor() const;
62 
63  OString getLOKPayload(int nType, int nViewId, bool* ignore) const;
64 };
65 
66 // From here classes/methods for selections.
67 
68 namespace sw::overlay { class OverlayRangesOutline; }
69 class MapMode;
70 
71 class SwSelPaintRects : public SwRects
72 {
73  friend void InitCore();
74  friend void FinitCore();
75 
78 
80 
81 #if HAVE_FEATURE_DESKTOP || defined(ANDROID)
82  std::unique_ptr<sdr::overlay::OverlayObject> m_pCursorOverlay;
83 #endif
84 
86  std::unique_ptr<sw::overlay::OverlayRangesOutline> m_pTextInputFieldOverlay;
87 
88  void HighlightInputField();
89 
90 public:
91  SwSelPaintRects( const SwCursorShell& rCSh );
92  virtual ~SwSelPaintRects();
93 
94  virtual void FillRects() = 0;
96  virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const = 0;
97 
98  // #i75172# in SwCursorShell::CreateCursor() the content of SwSelPaintRects is exchanged. To
99  // make a complete swap access to m_pCursorOverlay is needed there
100  void swapContent(SwSelPaintRects& rSwap);
101 
102  void Show(std::vector<OString>* pSelectionRectangles = nullptr);
103  void Hide();
104  void Invalidate( const SwRect& rRect );
105 
106  void SetShowTextInputFieldOverlay( const bool bShow )
107  {
108  m_bShowTextInputFieldOverlay = bShow;
109  }
110 
111  const SwCursorShell* GetShell() const { return m_pCursorShell; }
112  // check current MapMode of the shell and set possibly the static members.
113  // Optional set the parameters pX, pY
114  static void Get1PixelInLogic( const SwViewShell& rSh,
115  tools::Long* pX = nullptr, tools::Long* pY = nullptr );
116 
117  OString getLOKPayload(int nType, int nViewId, bool* ignore) const;
118 };
119 
120 class SW_DLLPUBLIC SwShellCursor : public virtual SwCursor, public SwSelPaintRects
121 {
122 private:
123  // Document positions of start/end characters of a SSelection.
126  const SwPosition* m_pInitialPoint; // For assignment of GetPoint() to m_PointPt.
127 
128  using SwCursor::UpDown;
129 
130 public:
131  SwShellCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos );
132  SwShellCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos,
133  const Point& rPtPos, SwPaM* pRing );
134  // note: *intentionally* links the new shell cursor into the old one's Ring
136  virtual ~SwShellCursor() override;
137 
138  virtual void FillRects() override; // For Table- and normal cursors.
140  virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
141 
142  void Show(SfxViewShell const * pViewShell); // Update and display all selections.
143  void Hide(); // Hide all selections.
144  void Invalidate( const SwRect& rRect );
145 
146  const Point& GetPtPos() const { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
147  Point& GetPtPos() { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
148  const Point& GetMkPos() const { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
149  Point& GetMkPos() { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
150  const Point& GetSttPos() const { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
151  Point& GetSttPos() { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
152  const Point& GetEndPos() const { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
153  Point& GetEndPos() { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
154 
155  virtual void SetMark() override;
156 
157  virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
158 
159  virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
160  virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
161 
162  bool UpDown( bool bUp, sal_uInt16 nCnt );
163 
164  // true: Cursor can be set to this position.
165  virtual bool IsAtValidPos( bool bPoint = true ) const override;
166 
167  virtual bool IsReadOnlyAvailable() const override;
168 
169  SwShellCursor* GetNext() { return dynamic_cast<SwShellCursor *>(GetNextInRing()); }
170  const SwShellCursor* GetNext() const { return dynamic_cast<SwShellCursor const *>(GetNextInRing()); }
171  SwShellCursor* GetPrev() { return dynamic_cast<SwShellCursor *>(GetPrevInRing()); }
172  const SwShellCursor* GetPrev() const { return dynamic_cast<SwShellCursor const *>(GetPrevInRing()); }
173 };
174 
175 class SwShellTableCursor final : public virtual SwShellCursor, public virtual SwTableCursor
176 {
181  // The Selection has the same order as the table boxes, i.e.
182  // if something is deleted from the one array at a certain position
183  // it has to be deleted from the other one as well!!
184 
185 public:
186  SwShellTableCursor( const SwCursorShell& rCursorSh, const SwPosition& rPos );
187  SwShellTableCursor( const SwCursorShell& rCursorSh,
188  const SwPosition &rMkPos, const Point& rMkPt,
189  const SwPosition &rPtPos, const Point& rPtPt );
190  virtual ~SwShellTableCursor() override;
191 
192  virtual void FillRects() override; // For table and normal cursor.
194  virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
195 
196  // Check if SPoint is within table SSelection.
197  bool Contains( const Point& rPt ) const;
198 
199  virtual void SetMark() override;
200  virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
201 
202  virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
203  virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
204 
205  // true: Cursor can be set to this position.
206  virtual bool IsAtValidPos( bool bPoint = true ) const override;
207 
208  SwShellTableCursor* GetNext() { return dynamic_cast<SwShellTableCursor *>(GetNextInRing()); }
209  const SwShellTableCursor* GetNext() const { return dynamic_cast<SwShellTableCursor const *>(GetNextInRing()); }
210  SwShellTableCursor* GetPrev() { return dynamic_cast<SwShellTableCursor *>(GetPrevInRing()); }
211  const SwShellTableCursor* GetPrev() const { return dynamic_cast<SwShellTableCursor const *>(GetPrevInRing()); }
212 };
213 
214 
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bIsVisible
Definition: viscrs.hxx:48
virtual short MaxReplaceArived() override
Definition: viscrs.cxx:888
Marks a position in the document model.
Definition: pam.hxx:36
const SwPosition * m_pInitialPoint
Definition: viscrs.hxx:126
Point & GetEndPos()
Definition: viscrs.hxx:153
const SwShellCursor * GetNext() const
Definition: viscrs.hxx:170
virtual short MaxReplaceArived()
Definition: swcrsr.cxx:1143
virtual void SaveTableBoxContent(const SwPosition *pPos) override
Definition: viscrs.cxx:893
long Long
const SwPosition * GetMark() const
Definition: pam.hxx:210
Point & GetPtPos()
Definition: viscrs.hxx:147
virtual SwCursor * Create(SwPaM *pRing=nullptr) const
Definition: swcrsr.cxx:149
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
Definition: viscrs.cxx:883
const Point & GetSttPos() const
Definition: viscrs.hxx:150
SwRect m_aEnd
Right edge of the selection end (bottom right cell).
Definition: viscrs.hxx:180
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SwShellCursor * GetPrev()
Definition: viscrs.hxx:171
virtual bool IsAtValidPos(bool bPoint=true) const override
Return if cursor can be set to this position.
Definition: viscrs.cxx:999
const SwShellTableCursor * GetPrev() const
Definition: viscrs.hxx:211
void Invalidate(const SwRect &rRect)
Definition: viscrs.cxx:621
bool m_bShowTextInputFieldOverlay
Definition: viscrs.hxx:85
Point m_PointPt
Definition: viscrs.hxx:125
virtual void FillRects() override
Definition: viscrs.cxx:898
SwShellTableCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
Definition: viscrs.cxx:862
OString getLOKPayload(int nType, int nViewId, bool *ignore) const
Definition: viscrs.cxx:508
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:666
static MapMode * s_pMapMode
Definition: viscrs.hxx:77
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
virtual ~SwShellTableCursor() override
Definition: viscrs.cxx:879
const SwCursorShell * m_pCursorShell
Definition: viscrs.hxx:79
const SwCursorShell * GetShell() const
Definition: viscrs.hxx:111
const SwPosition * GetPoint() const
Definition: pam.hxx:208
void FinitCore()
Definition: init.cxx:666
bool Contains(const Point &rPt) const
Definition: viscrs.cxx:968
SwPaM * GetNextInRing()
Definition: ring.hxx:84
void HighlightInputField()
Definition: viscrs.cxx:561
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
Definition: viscrs.cxx:961
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:881
const Point & GetMkPos() const
Definition: viscrs.hxx:148
bool UpDown(bool bUp, sal_uInt16 nCnt, Point const *pPt, tools::Long nUpDownX, SwRootFrame &rLayout)
Definition: swcrsr.cxx:1997
Point & GetMkPos()
Definition: viscrs.hxx:149
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
void Show(std::vector< OString > *pSelectionRectangles=nullptr)
Definition: viscrs.cxx:411
const SwPosition * Start() const
Definition: pam.hxx:213
SwShellTableCursor * GetNext()
Definition: viscrs.hxx:208
SwSelPaintRects(const SwCursorShell &rCSh)
Definition: viscrs.cxx:349
SwRect m_aLastLOKRect
Definition: viscrs.hxx:46
void SetShowTextInputFieldOverlay(const bool bShow)
Definition: viscrs.hxx:106
virtual ~SwSelPaintRects()
Definition: viscrs.cxx:357
static void Get1PixelInLogic(const SwViewShell &rSh, tools::Long *pX=nullptr, tools::Long *pY=nullptr)
Definition: viscrs.cxx:654
virtual void FillRects()=0
virtual bool IsReadOnlyAvailable() const
Definition: swcrsr.cxx:154
const SwShellTableCursor * GetNext() const
Definition: viscrs.hxx:209
void InitCore()
Definition: init.cxx:447
std::vector< SwRect > SwRects
Definition: swregion.hxx:26
bool m_bIsDragCursor
Definition: viscrs.hxx:49
vcl::Cursor m_aTextCursor
Definition: viscrs.hxx:42
SwShellCursor * GetNext()
Definition: viscrs.hxx:169
static tools::Long s_nPixPtY
Definition: viscrs.hxx:76
const SwPosition * End() const
Definition: pam.hxx:218
const Point & GetPtPos() const
Definition: viscrs.hxx:146
friend void InitCore()
Definition: init.cxx:447
static tools::Long s_nPixPtX
Definition: viscrs.hxx:76
virtual bool IsAtValidPos(bool bPoint=true) const
Return if cursor can be set to this position.
Definition: swcrsr.cxx:720
const Point & GetEndPos() const
Definition: viscrs.hxx:152
SwRect m_aStart
Left edge of the selection start (top left cell).
Definition: viscrs.hxx:178
sal_uInt16 m_nPageLastTime
For LibreOfficeKit only - remember what page we were at the last time.
Definition: viscrs.hxx:45
void SetDragCursor(bool bFlag=true)
Definition: viscrs.hxx:59
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:478
SwShellTableCursor * GetPrev()
Definition: viscrs.hxx:210
const SwCursorShell * m_pCursorShell
Definition: viscrs.hxx:41
const SwShellCursor * GetPrev() const
Definition: viscrs.hxx:172
Point m_MarkPt
Definition: viscrs.hxx:124
void swapContent(SwSelPaintRects &rSwap)
Definition: viscrs.cxx:362
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pTextInputFieldOverlay
Definition: viscrs.hxx:86
virtual void SaveTableBoxContent(const SwPosition *pPos)
Definition: swcrsr.cxx:746
Point & GetSttPos()
Definition: viscrs.hxx:151
bool IsVisible() const
Definition: viscrs.hxx:58