nss: upgrade to release 3.73
[LibreOffice.git] / sw / inc / viscrs.hxx
blob95c013b233ca40df9ab2e6c017b2eb168120c4e6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_VISCRS_HXX
20 #define INCLUDED_SW_INC_VISCRS_HXX
22 #include <config_feature_desktop.h>
24 #include <vcl/cursor.hxx>
25 #include "swcrsr.hxx"
26 #include "swrect.hxx"
27 #include "swregion.hxx"
28 #include "swdllapi.h"
30 namespace sdr::overlay { class OverlayObject; }
32 class SwCursorShell;
33 class SfxViewShell;
35 // From here classes/methods for non-text cursor.
37 class SW_DLLPUBLIC SwVisibleCursor
39 friend void InitCore();
40 friend void FinitCore();
42 bool m_bIsVisible;
43 bool m_bIsDragCursor;
45 vcl::Cursor m_aTextCursor;
46 const SwCursorShell* m_pCursorShell;
48 /// For LibreOfficeKit only - remember what page we were at the last time.
49 sal_uInt16 m_nPageLastTime;
51 public:
52 SwVisibleCursor( const SwCursorShell * pCShell );
53 ~SwVisibleCursor();
55 void Show();
56 void Hide();
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;
64 // From here classes/methods for selections.
66 namespace sw::overlay { class OverlayRangesOutline; }
67 class MapMode;
69 class SwSelPaintRects : public SwRects
71 friend void InitCore();
72 friend void FinitCore();
74 static tools::Long s_nPixPtX, s_nPixPtY;
75 static MapMode *s_pMapMode;
77 const SwCursorShell* m_pCursorShell;
79 #if HAVE_FEATURE_DESKTOP || defined(ANDROID)
80 std::unique_ptr<sdr::overlay::OverlayObject> m_pCursorOverlay;
81 #endif
83 bool m_bShowTextInputFieldOverlay;
84 std::unique_ptr<sw::overlay::OverlayRangesOutline> m_pTextInputFieldOverlay;
86 void HighlightInputField();
88 public:
89 SwSelPaintRects( const SwCursorShell& rCSh );
90 virtual ~SwSelPaintRects();
92 virtual void FillRects() = 0;
93 /// Fill rStart and rEnd with a rectangle that represents the start and end for selection handles.
94 virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const = 0;
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);
100 void Show(std::vector<OString>* pSelectionRectangles = nullptr);
101 void Hide();
102 void Invalidate( const SwRect& rRect );
104 void SetShowTextInputFieldOverlay( const bool bShow )
106 m_bShowTextInputFieldOverlay = bShow;
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 tools::Long* pX = nullptr, tools::Long* pY = nullptr );
116 class SW_DLLPUBLIC SwShellCursor : public virtual SwCursor, public SwSelPaintRects
118 private:
119 // Document positions of start/end characters of a SSelection.
120 Point m_MarkPt;
121 Point m_PointPt;
122 const SwPosition* m_pInitialPoint; // For assignment of GetPoint() to m_PointPt.
124 using SwCursor::UpDown;
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
131 SwShellCursor( SwShellCursor& );
132 virtual ~SwShellCursor() override;
134 virtual void FillRects() override; // For Table- and normal cursors.
135 /// @see SwSelPaintRects::FillStartEnd(), override for text selections.
136 virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
138 void Show(SfxViewShell const * pViewShell); // Update and display all selections.
139 void Hide(); // Hide all selections.
140 void Invalidate( const SwRect& rRect );
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; }
151 virtual void SetMark() override;
153 virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
155 virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
156 virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
158 bool UpDown( bool bUp, sal_uInt16 nCnt );
160 // true: Cursor can be set to this position.
161 virtual bool IsAtValidPos( bool bPoint = true ) const override;
163 virtual bool IsReadOnlyAvailable() const override;
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()); }
171 class SwShellTableCursor final : public virtual SwShellCursor, public virtual SwTableCursor
173 /// Left edge of the selection start (top left cell).
174 SwRect m_aStart;
175 /// Right edge of the selection end (bottom right cell).
176 SwRect m_aEnd;
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!!
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;
188 virtual void FillRects() override; // For table and normal cursor.
189 /// @see SwSelPaintRects::FillStartEnd(), override for table selections.
190 virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
192 // Check if SPoint is within table SSelection.
193 bool IsInside( const Point& rPt ) const;
195 virtual void SetMark() override;
196 virtual SwCursor* Create( SwPaM* pRing = nullptr ) const override;
198 virtual short MaxReplaceArived() override; //returns RET_YES/RET_CANCEL/RET_NO
199 virtual void SaveTableBoxContent( const SwPosition* pPos ) override;
201 // true: Cursor can be set to this position.
202 virtual bool IsAtValidPos( bool bPoint = true ) const override;
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()); }
210 #endif // INCLUDED_SW_INC_VISCRS_HXX
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */