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