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
140{
141private:
142 // Document positions of start/end characters of a SSelection.
145 const SwPosition* m_pInitialPoint; // For assignment of GetPoint() to m_PointPt.
146
147 using SwCursor::UpDown;
148
149public:
150 SwShellCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos );
151 SwShellCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos,
152 const Point& rPtPos, SwPaM* pRing );
153 // note: *intentionally* links the new shell cursor into the old one's Ring
155 virtual ~SwShellCursor() override;
156
157 virtual void FillRects() override; // For Table- and normal cursors.
159 virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
160
161 void Show(SfxViewShell const * pViewShell); // Update and display all selections.
162 void Hide(); // Hide all selections.
163 void Invalidate( const SwRect& rRect );
164
165 const Point& GetPtPos() const { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
166 Point& GetPtPos() { return (SwPaM::GetPoint() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
167 const Point& GetMkPos() const { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
168 Point& GetMkPos() { return (SwPaM::GetMark() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
169 const Point& GetSttPos() const { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
170 Point& GetSttPos() { return (SwPaM::Start() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
171 const Point& GetEndPos() const { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
172 Point& GetEndPos() { return (SwPaM::End() == m_pInitialPoint) ? m_PointPt : m_MarkPt; }
173
174 virtual void SetMark() override;
175
176 virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
177
178 virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
179 virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
180
181 bool UpDown( bool bUp, sal_uInt16 nCnt );
182
183 // true: Cursor can be set to this position.
184 virtual bool IsAtValidPos( bool bPoint = true ) const override;
185
186 virtual bool IsReadOnlyAvailable() const override;
187
188 SwShellCursor* GetNext() { return dynamic_cast<SwShellCursor *>(GetNextInRing()); }
189 const SwShellCursor* GetNext() const { return dynamic_cast<SwShellCursor const *>(GetNextInRing()); }
190 SwShellCursor* GetPrev() { return dynamic_cast<SwShellCursor *>(GetPrevInRing()); }
191 const SwShellCursor* GetPrev() const { return dynamic_cast<SwShellCursor const *>(GetPrevInRing()); }
192};
193
194class SwShellTableCursor final : public virtual SwShellCursor, public virtual SwTableCursor
195{
200 // The Selection has the same order as the table boxes, i.e.
201 // if something is deleted from the one array at a certain position
202 // it has to be deleted from the other one as well!!
203
204public:
205 SwShellTableCursor( const SwCursorShell& rCursorSh, const SwPosition& rPos );
206 SwShellTableCursor( const SwCursorShell& rCursorSh,
207 const SwPosition &rMkPos, const Point& rMkPt,
208 const SwPosition &rPtPos, const Point& rPtPt );
209 virtual ~SwShellTableCursor() override;
210
211 virtual void FillRects() override; // For table and normal cursor.
213 virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
214
215 // Check if SPoint is within table SSelection.
216 bool Contains( const Point& rPt ) const;
217
218 virtual void SetMark() override;
219 virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
220
221 virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
222 virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
223
224 // true: Cursor can be set to this position.
225 virtual bool IsAtValidPos( bool bPoint = true ) const override;
226
228 const SwShellTableCursor* GetNext() const { return dynamic_cast<SwShellTableCursor const *>(GetNextInRing()); }
230 const SwShellTableCursor* GetPrev() const { return dynamic_cast<SwShellTableCursor const *>(GetPrevInRing()); }
231};
232
233
234/* 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:1989
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
const SwPosition * GetMark() const
Definition: pam.hxx:255
const SwPosition * End() const
Definition: pam.hxx:263
const SwPosition * GetPoint() const
Definition: pam.hxx:253
const SwPosition * Start() const
Definition: pam.hxx:258
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:422
void SetShowContentControlOverlay(const bool bShow)
Definition: viscrs.hxx:123
void Invalidate(const SwRect &rRect)
Definition: viscrs.cxx:846
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pTextInputFieldOverlay
Definition: viscrs.hxx:94
void swapContent(SwSelPaintRects &rSwap)
Definition: viscrs.cxx:370
const VclPtr< SwContentControlButton > & GetContentControlButton() const
Definition: viscrs.cxx:841
SwSelPaintRects(const SwCursorShell &rCSh)
Definition: viscrs.cxx:355
std::optional< OString > getLOKPayload(int nType, int nViewId) const
Definition: viscrs.cxx:520
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:575
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:879
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:459
friend void FinitCore()
Definition: init.cxx:684
void HighlightContentControl()
Definition: viscrs.cxx:634
bool m_bShowContentControlOverlay
Definition: viscrs.hxx:95
static tools::Long s_nPixPtX
Definition: viscrs.hxx:84
virtual ~SwSelPaintRects()
Definition: viscrs.cxx:364
static tools::Long s_nPixPtY
Definition: viscrs.hxx:84
Represents the current text cursor of one opened edit window.
Definition: viscrs.hxx:140
const SwShellCursor * GetPrev() const
Definition: viscrs.hxx:191
const Point & GetEndPos() const
Definition: viscrs.hxx:171
Point & GetMkPos()
Definition: viscrs.hxx:168
Point & GetEndPos()
Definition: viscrs.hxx:172
Point m_MarkPt
Definition: viscrs.hxx:143
const SwShellCursor * GetNext() const
Definition: viscrs.hxx:189
Point & GetPtPos()
Definition: viscrs.hxx:166
Point m_PointPt
Definition: viscrs.hxx:144
const SwPosition * m_pInitialPoint
Definition: viscrs.hxx:145
const Point & GetSttPos() const
Definition: viscrs.hxx:169
SwShellCursor * GetNext()
Definition: viscrs.hxx:188
const Point & GetPtPos() const
Definition: viscrs.hxx:165
SwShellCursor * GetPrev()
Definition: viscrs.hxx:190
Point & GetSttPos()
Definition: viscrs.hxx:170
const Point & GetMkPos() const
Definition: viscrs.hxx:167
SwShellTableCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
Definition: viscrs.cxx:1114
virtual void FillRects() override
Definition: viscrs.cxx:1150
SwRect m_aEnd
Right edge of the selection end (bottom right cell).
Definition: viscrs.hxx:199
SwRect m_aStart
Left edge of the selection start (top left cell).
Definition: viscrs.hxx:197
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
Definition: viscrs.cxx:1135
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:1133
virtual ~SwShellTableCursor() override
Definition: viscrs.cxx:1131
SwShellTableCursor * GetNext()
Definition: viscrs.hxx:227
virtual bool IsAtValidPos(bool bPoint=true) const override
Return <true> if cursor can be set to this position.
Definition: viscrs.cxx:1251
bool Contains(const Point &rPt) const
Definition: viscrs.cxx:1220
const SwShellTableCursor * GetNext() const
Definition: viscrs.hxx:228
virtual void SaveTableBoxContent(const SwPosition *pPos) override
Definition: viscrs.cxx:1145
const SwShellTableCursor * GetPrev() const
Definition: viscrs.hxx:230
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
Definition: viscrs.cxx:1213
SwShellTableCursor * GetPrev()
Definition: viscrs.hxx:229
virtual short MaxReplaceArived() override
Definition: viscrs.cxx:1140
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:459
void FinitCore()
Definition: init.cxx:684
void Create(SvxOrientationItem &rItem, SvStream &rStrm, sal_uInt16)
long Long
Marks a position in the document model.
Definition: pam.hxx:38
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
std::vector< SwRect > SwRects
Definition: swregion.hxx:26