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