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 
46 
48  sal_uInt16 m_nPageLastTime;
49 
50 public:
51  SwVisibleCursor( const SwCursorShell * pCShell );
52  ~SwVisibleCursor();
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  const vcl::Cursor& GetTextCursor() const;
61 };
62 
63 // From here classes/methods for selections.
64 
65 namespace sw::overlay { class OverlayRangesOutline; }
66 class MapMode;
67 
68 class SwSelPaintRects : public SwRects
69 {
70  friend void InitCore();
71  friend void FinitCore();
72 
75 
77 
78 #if HAVE_FEATURE_DESKTOP || defined(ANDROID)
79  std::unique_ptr<sdr::overlay::OverlayObject> m_pCursorOverlay;
80 #endif
81 
83  std::unique_ptr<sw::overlay::OverlayRangesOutline> m_pTextInputFieldOverlay;
84 
85  void HighlightInputField();
86 
87 public:
88  SwSelPaintRects( const SwCursorShell& rCSh );
89  virtual ~SwSelPaintRects();
90 
91  virtual void FillRects() = 0;
93  virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const = 0;
94 
95  // #i75172# in SwCursorShell::CreateCursor() 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 = nullptr);
100  void Hide();
101  void Invalidate( const SwRect& rRect );
102 
103  void SetShowTextInputFieldOverlay( const bool bShow )
104  {
105  m_bShowTextInputFieldOverlay = bShow;
106  }
107 
108  const SwCursorShell* 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  tools::Long* pX = nullptr, tools::Long* pY = nullptr );
113 };
114 
115 class SW_DLLPUBLIC SwShellCursor : public virtual SwCursor, public SwSelPaintRects
116 {
117 private:
118  // Document positions of start/end characters of a SSelection.
121  const SwPosition* m_pInitialPoint; // For assignment of GetPoint() to m_PointPt.
122 
123  using SwCursor::UpDown;
124 
125 public:
126  SwShellCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos );
127  SwShellCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos,
128  const Point& rPtPos, SwPaM* pRing );
129  // note: *intentionally* links the new shell cursor into the old one's Ring
131  virtual ~SwShellCursor() override;
132 
133  virtual void FillRects() override; // For Table- and normal cursors.
135  virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
136 
137  void Show(SfxViewShell const * pViewShell); // Update and display all selections.
138  void Hide(); // Hide all selections.
139  void Invalidate( const SwRect& rRect );
140 
141  const Point& GetPtPos() const { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
142  Point& GetPtPos() { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
143  const Point& GetMkPos() const { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
144  Point& GetMkPos() { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
145  const Point& GetSttPos() const { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
146  Point& GetSttPos() { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
147  const Point& GetEndPos() const { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
148  Point& GetEndPos() { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
149 
150  virtual void SetMark() override;
151 
152  virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
153 
154  virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
155  virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
156 
157  bool UpDown( bool bUp, sal_uInt16 nCnt );
158 
159  // true: Cursor can be set to this position.
160  virtual bool IsAtValidPos( bool bPoint = true ) const override;
161 
162  virtual bool IsReadOnlyAvailable() const override;
163 
164  SwShellCursor* GetNext() { return dynamic_cast<SwShellCursor *>(GetNextInRing()); }
165  const SwShellCursor* GetNext() const { return dynamic_cast<SwShellCursor const *>(GetNextInRing()); }
166  SwShellCursor* GetPrev() { return dynamic_cast<SwShellCursor *>(GetPrevInRing()); }
167  const SwShellCursor* GetPrev() const { return dynamic_cast<SwShellCursor const *>(GetPrevInRing()); }
168 };
169 
170 class SwShellTableCursor final : public virtual SwShellCursor, public virtual SwTableCursor
171 {
176  // The Selection has the same order as the table boxes, i.e.
177  // if something is deleted from the one array at a certain position
178  // it has to be deleted from the other one as well!!
179 
180 public:
181  SwShellTableCursor( const SwCursorShell& rCursorSh, const SwPosition& rPos );
182  SwShellTableCursor( const SwCursorShell& rCursorSh,
183  const SwPosition &rMkPos, const Point& rMkPt,
184  const SwPosition &rPtPos, const Point& rPtPt );
185  virtual ~SwShellTableCursor() override;
186 
187  virtual void FillRects() override; // For table and normal cursor.
189  virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
190 
191  // Check if SPoint is within table SSelection.
192  bool IsInside( const Point& rPt ) const;
193 
194  virtual void SetMark() override;
195  virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
196 
197  virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
198  virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
199 
200  // true: Cursor can be set to this position.
201  virtual bool IsAtValidPos( bool bPoint = true ) const override;
202 
203  SwShellTableCursor* GetNext() { return dynamic_cast<SwShellTableCursor *>(GetNextInRing()); }
204  const SwShellTableCursor* GetNext() const { return dynamic_cast<SwShellTableCursor const *>(GetNextInRing()); }
205  SwShellTableCursor* GetPrev() { return dynamic_cast<SwShellTableCursor *>(GetPrevInRing()); }
206  const SwShellTableCursor* GetPrev() const { return dynamic_cast<SwShellTableCursor const *>(GetPrevInRing()); }
207 };
208 
209 
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bIsVisible
Definition: viscrs.hxx:41
virtual short MaxReplaceArived() override
Definition: viscrs.cxx:825
Marks a position in the document model.
Definition: pam.hxx:35
const SwPosition * m_pInitialPoint
Definition: viscrs.hxx:121
Point & GetEndPos()
Definition: viscrs.hxx:148
const SwShellCursor * GetNext() const
Definition: viscrs.hxx:165
virtual short MaxReplaceArived()
Definition: swcrsr.cxx:1141
virtual void SaveTableBoxContent(const SwPosition *pPos) override
Definition: viscrs.cxx:830
long Long
const SwPosition * GetMark() const
Definition: pam.hxx:209
Point & GetPtPos()
Definition: viscrs.hxx:142
virtual SwCursor * Create(SwPaM *pRing=nullptr) const
Definition: swcrsr.cxx:147
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
Definition: viscrs.cxx:820
const Point & GetSttPos() const
Definition: viscrs.hxx:145
SwRect m_aEnd
Right edge of the selection end (bottom right cell).
Definition: viscrs.hxx:175
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
SwShellCursor * GetPrev()
Definition: viscrs.hxx:166
virtual bool IsAtValidPos(bool bPoint=true) const override
Return if cursor can be set to this position.
Definition: viscrs.cxx:936
const SwShellTableCursor * GetPrev() const
Definition: viscrs.hxx:206
void Invalidate(const SwRect &rRect)
Definition: viscrs.cxx:558
bool m_bShowTextInputFieldOverlay
Definition: viscrs.hxx:82
Point m_PointPt
Definition: viscrs.hxx:120
virtual void FillRects() override
Definition: viscrs.cxx:835
SwShellTableCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
Definition: viscrs.cxx:799
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:671
static MapMode * s_pMapMode
Definition: viscrs.hxx:74
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
virtual ~SwShellTableCursor() override
Definition: viscrs.cxx:816
const SwCursorShell * m_pCursorShell
Definition: viscrs.hxx:76
const SwCursorShell * GetShell() const
Definition: viscrs.hxx:108
const SwPosition * GetPoint() const
Definition: pam.hxx:207
void FinitCore()
Definition: init.cxx:671
SwPaM * GetNextInRing()
Definition: ring.hxx:84
void HighlightInputField()
Definition: viscrs.cxx:497
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
Definition: viscrs.cxx:898
bool IsInside(const Point &rPt) const
Definition: viscrs.cxx:905
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:818
const Point & GetMkPos() const
Definition: viscrs.hxx:143
bool UpDown(bool bUp, sal_uInt16 nCnt, Point const *pPt, tools::Long nUpDownX, SwRootFrame &rLayout)
Definition: swcrsr.cxx:1990
Point & GetMkPos()
Definition: viscrs.hxx:144
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
void Show(std::vector< OString > *pSelectionRectangles=nullptr)
Definition: viscrs.cxx:388
const SwPosition * Start() const
Definition: pam.hxx:212
SwShellTableCursor * GetNext()
Definition: viscrs.hxx:203
SwSelPaintRects(const SwCursorShell &rCSh)
Definition: viscrs.cxx:325
void SetShowTextInputFieldOverlay(const bool bShow)
Definition: viscrs.hxx:103
virtual ~SwSelPaintRects()
Definition: viscrs.cxx:334
static void Get1PixelInLogic(const SwViewShell &rSh, tools::Long *pX=nullptr, tools::Long *pY=nullptr)
Definition: viscrs.cxx:591
virtual void FillRects()=0
virtual bool IsReadOnlyAvailable() const
Definition: swcrsr.cxx:152
const SwShellTableCursor * GetNext() const
Definition: viscrs.hxx:204
void InitCore()
Definition: init.cxx:454
std::vector< SwRect > SwRects
Definition: swregion.hxx:26
bool m_bIsDragCursor
Definition: viscrs.hxx:42
vcl::Cursor m_aTextCursor
Definition: viscrs.hxx:44
SwShellCursor * GetNext()
Definition: viscrs.hxx:164
static tools::Long s_nPixPtY
Definition: viscrs.hxx:73
const SwPosition * End() const
Definition: pam.hxx:217
const Point & GetPtPos() const
Definition: viscrs.hxx:141
friend void InitCore()
Definition: init.cxx:454
static tools::Long s_nPixPtX
Definition: viscrs.hxx:73
virtual bool IsAtValidPos(bool bPoint=true) const
Return if cursor can be set to this position.
Definition: swcrsr.cxx:718
const Point & GetEndPos() const
Definition: viscrs.hxx:147
SwRect m_aStart
Left edge of the selection start (top left cell).
Definition: viscrs.hxx:173
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:478
SwShellTableCursor * GetPrev()
Definition: viscrs.hxx:205
const SwCursorShell * m_pCursorShell
Definition: viscrs.hxx:45
const SwShellCursor * GetPrev() const
Definition: viscrs.hxx:167
Point m_MarkPt
Definition: viscrs.hxx:119
void swapContent(SwSelPaintRects &rSwap)
Definition: viscrs.cxx:339
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pTextInputFieldOverlay
Definition: viscrs.hxx:83
virtual void SaveTableBoxContent(const SwPosition *pPos)
Definition: swcrsr.cxx:744
Point & GetSttPos()
Definition: viscrs.hxx:146
bool IsVisible() const
Definition: viscrs.hxx:57