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#include <optional>
30
31namespace sdr::overlay { class OverlayObject; }
32
33class SwCursorShell;
34class SfxViewShell;
36
37// From here classes/methods for non-text cursor.
38
40{
41 friend void InitCore();
42 friend void FinitCore();
43
46
48 sal_uInt16 m_nPageLastTime;
50
53
54public:
55 SwVisibleCursor( const SwCursorShell * pCShell );
57
58 void Show();
59 void Hide();
60
61 bool IsVisible() const { return m_bIsVisible; }
62 void SetDragCursor( bool bFlag = true ) { m_bIsDragCursor = bFlag; }
63 void SetPosAndShow(SfxViewShell const * pViewShell);
64 const vcl::Cursor& GetTextCursor() const;
65
66 std::optional<OString> getLOKPayload(int nType, int nViewId) const;
67};
68
69// From here classes/methods for selections.
70
71namespace sw::overlay { class OverlayRangesOutline; }
72class MapMode;
73
80{
81 friend void InitCore();
82 friend void FinitCore();
83
86
88
89#if HAVE_FEATURE_DESKTOP || defined(ANDROID)
90 std::unique_ptr<sdr::overlay::OverlayObject> m_pCursorOverlay;
91#endif
92
94 std::unique_ptr<sw::overlay::OverlayRangesOutline> m_pTextInputFieldOverlay;
96 std::unique_ptr<sw::overlay::OverlayRangesOutline> m_pContentControlOverlay;
98
101
102public:
103 SwSelPaintRects( const SwCursorShell& rCSh );
104 virtual ~SwSelPaintRects();
105
106 virtual void FillRects() = 0;
108 virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const = 0;
109
110 // #i75172# in SwCursorShell::CreateCursor() the content of SwSelPaintRects is exchanged. To
111 // make a complete swap access to m_pCursorOverlay is needed there
112 void swapContent(SwSelPaintRects& rSwap);
113
114 void Show(std::vector<OString>* pSelectionRectangles = nullptr);
115 void Hide();
116 void Invalidate( const SwRect& rRect );
117
118 void SetShowTextInputFieldOverlay( const bool bShow )
119 {
121 }
122
124
126
127 const SwCursorShell* GetShell() const { return m_pCursorShell; }
128 // check current MapMode of the shell and set possibly the static members.
129 // Optional set the parameters pX, pY
130 static void Get1PixelInLogic( const SwViewShell& rSh,
131 tools::Long* pX = nullptr, tools::Long* pY = nullptr );
132
133 std::optional<OString> getLOKPayload(int nType, int nViewId) const;
134};
135
137{
138private:
139 // Document positions of start/end characters of a SSelection.
142 const SwPosition* m_pInitialPoint; // For assignment of GetPoint() to m_PointPt.
143
144 using SwCursor::UpDown;
145
146public:
147 SwShellCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos );
148 SwShellCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos,
149 const Point& rPtPos, SwPaM* pRing );
150 // note: *intentionally* links the new shell cursor into the old one's Ring
152 virtual ~SwShellCursor() override;
153
154 virtual void FillRects() override; // For Table- and normal cursors.
156 virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
157
158 void Show(SfxViewShell const * pViewShell); // Update and display all selections.
159 void Hide(); // Hide all selections.
160 void Invalidate( const SwRect& rRect );
161
162 const Point& GetPtPos() const { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
163 Point& GetPtPos() { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
164 const Point& GetMkPos() const { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
165 Point& GetMkPos() { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
166 const Point& GetSttPos() const { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
167 Point& GetSttPos() { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
168 const Point& GetEndPos() const { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
169 Point& GetEndPos() { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
170
171 virtual void SetMark() override;
172
173 virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
174
175 virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
176 virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
177
178 bool UpDown( bool bUp, sal_uInt16 nCnt );
179
180 // true: Cursor can be set to this position.
181 virtual bool IsAtValidPos( bool bPoint = true ) const override;
182
183 virtual bool IsReadOnlyAvailable() const override;
184
185 SwShellCursor* GetNext() { return dynamic_cast<SwShellCursor *>(GetNextInRing()); }
186 const SwShellCursor* GetNext() const { return dynamic_cast<SwShellCursor const *>(GetNextInRing()); }
187 SwShellCursor* GetPrev() { return dynamic_cast<SwShellCursor *>(GetPrevInRing()); }
188 const SwShellCursor* GetPrev() const { return dynamic_cast<SwShellCursor const *>(GetPrevInRing()); }
189};
190
191class SwShellTableCursor final : public virtual SwShellCursor, public virtual SwTableCursor
192{
197 // The Selection has the same order as the table boxes, i.e.
198 // if something is deleted from the one array at a certain position
199 // it has to be deleted from the other one as well!!
200
201public:
202 SwShellTableCursor( const SwCursorShell& rCursorSh, const SwPosition& rPos );
203 SwShellTableCursor( const SwCursorShell& rCursorSh,
204 const SwPosition &rMkPos, const Point& rMkPt,
205 const SwPosition &rPtPos, const Point& rPtPt );
206 virtual ~SwShellTableCursor() override;
207
208 virtual void FillRects() override; // For table and normal cursor.
210 virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
211
212 // Check if SPoint is within table SSelection.
213 bool Contains( const Point& rPt ) const;
214
215 virtual void SetMark() override;
216 virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
217
218 virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
219 virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
220
221 // true: Cursor can be set to this position.
222 virtual bool IsAtValidPos( bool bPoint = true ) const override;
223
225 const SwShellTableCursor* GetNext() const { return dynamic_cast<SwShellTableCursor const *>(GetNextInRing()); }
227 const SwShellTableCursor* GetPrev() const { return dynamic_cast<SwShellTableCursor const *>(GetPrevInRing()); }
228};
229
230
231/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This button is shown when the cursor is inside a content control with drop-down capability.
bool UpDown(bool bUp, sal_uInt16 nCnt, Point const *pPt, tools::Long nUpDownX, SwRootFrame &rLayout)
Definition: swcrsr.cxx:1984
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
const SwPosition * GetMark() const
Definition: pam.hxx:263
const SwPosition * End() const
Definition: pam.hxx:271
const SwPosition * GetPoint() const
Definition: pam.hxx:261
const SwPosition * Start() const
Definition: pam.hxx:266
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
SwSelPaintRects is a base class of SwShellCursor, which stores the overlay for the cursor/selection: ...
Definition: viscrs.hxx:80
const SwCursorShell * GetShell() const
Definition: viscrs.hxx:127
void Show(std::vector< OString > *pSelectionRectangles=nullptr)
Definition: viscrs.cxx:421
void SetShowContentControlOverlay(const bool bShow)
Definition: viscrs.hxx:123
void Invalidate(const SwRect &rRect)
Definition: viscrs.cxx:799
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pTextInputFieldOverlay
Definition: viscrs.hxx:94
void swapContent(SwSelPaintRects &rSwap)
Definition: viscrs.cxx:369
const VclPtr< SwContentControlButton > & GetContentControlButton() const
Definition: viscrs.cxx:794
SwSelPaintRects(const SwCursorShell &rCSh)
Definition: viscrs.cxx:354
std::optional< OString > getLOKPayload(int nType, int nViewId) const
Definition: viscrs.cxx:519
virtual void FillRects()=0
VclPtr< SwContentControlButton > m_pContentControlButton
Definition: viscrs.hxx:97
bool m_bShowTextInputFieldOverlay
Definition: viscrs.hxx:93
static MapMode * s_pMapMode
Definition: viscrs.hxx:85
void HighlightInputField()
Definition: viscrs.cxx:574
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pContentControlOverlay
Definition: viscrs.hxx:96
void SetShowTextInputFieldOverlay(const bool bShow)
Definition: viscrs.hxx:118
static void Get1PixelInLogic(const SwViewShell &rSh, tools::Long *pX=nullptr, tools::Long *pY=nullptr)
Definition: viscrs.cxx:832
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.
const SwCursorShell * m_pCursorShell
Definition: viscrs.hxx:87
friend void InitCore()
Definition: init.cxx:449
friend void FinitCore()
Definition: init.cxx:668
void HighlightContentControl()
Definition: viscrs.cxx:633
bool m_bShowContentControlOverlay
Definition: viscrs.hxx:95
static tools::Long s_nPixPtX
Definition: viscrs.hxx:84
virtual ~SwSelPaintRects()
Definition: viscrs.cxx:363
static tools::Long s_nPixPtY
Definition: viscrs.hxx:84
const SwShellCursor * GetPrev() const
Definition: viscrs.hxx:188
const Point & GetEndPos() const
Definition: viscrs.hxx:168
Point & GetMkPos()
Definition: viscrs.hxx:165
Point & GetEndPos()
Definition: viscrs.hxx:169
Point m_MarkPt
Definition: viscrs.hxx:140
const SwShellCursor * GetNext() const
Definition: viscrs.hxx:186
Point & GetPtPos()
Definition: viscrs.hxx:163
Point m_PointPt
Definition: viscrs.hxx:141
const SwPosition * m_pInitialPoint
Definition: viscrs.hxx:142
const Point & GetSttPos() const
Definition: viscrs.hxx:166
SwShellCursor * GetNext()
Definition: viscrs.hxx:185
const Point & GetPtPos() const
Definition: viscrs.hxx:162
SwShellCursor * GetPrev()
Definition: viscrs.hxx:187
Point & GetSttPos()
Definition: viscrs.hxx:167
const Point & GetMkPos() const
Definition: viscrs.hxx:164
SwShellTableCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
Definition: viscrs.cxx:1040
virtual void FillRects() override
Definition: viscrs.cxx:1076
SwRect m_aEnd
Right edge of the selection end (bottom right cell).
Definition: viscrs.hxx:196
SwRect m_aStart
Left edge of the selection start (top left cell).
Definition: viscrs.hxx:194
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
Definition: viscrs.cxx:1061
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:1059
virtual ~SwShellTableCursor() override
Definition: viscrs.cxx:1057
SwShellTableCursor * GetNext()
Definition: viscrs.hxx:224
virtual bool IsAtValidPos(bool bPoint=true) const override
Return <true> if cursor can be set to this position.
Definition: viscrs.cxx:1177
bool Contains(const Point &rPt) const
Definition: viscrs.cxx:1146
const SwShellTableCursor * GetNext() const
Definition: viscrs.hxx:225
virtual void SaveTableBoxContent(const SwPosition *pPos) override
Definition: viscrs.cxx:1071
const SwShellTableCursor * GetPrev() const
Definition: viscrs.hxx:227
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
Definition: viscrs.cxx:1139
SwShellTableCursor * GetPrev()
Definition: viscrs.hxx:226
virtual short MaxReplaceArived() override
Definition: viscrs.cxx:1066
vcl::Cursor m_aTextCursor
Definition: viscrs.hxx:45
bool IsVisible() const
Definition: viscrs.hxx:61
void SetDragCursor(bool bFlag=true)
Definition: viscrs.hxx:62
SwRect m_aLastLOKRect
Definition: viscrs.hxx:49
bool m_bIsDragCursor
Definition: viscrs.hxx:52
const SwCursorShell * m_pCursorShell
Definition: viscrs.hxx:44
bool m_bIsVisible
Definition: viscrs.hxx:51
sal_uInt16 m_nPageLastTime
For LibreOfficeKit only - remember what page we were at the last time.
Definition: viscrs.hxx:48
SwPaM * GetPrevInRing()
Definition: ring.hxx:87
SwPaM * GetNextInRing()
Definition: ring.hxx:84
void InitCore()
Definition: init.cxx:449
void FinitCore()
Definition: init.cxx:668
void Create(SvxOrientationItem &rItem, SvStream &rStrm, sal_uInt16)
long Long
Marks a position in the document model.
Definition: pam.hxx:37
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
std::vector< SwRect > SwRects
Definition: swregion.hxx:26