1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_features.h>
24 #include <vcl/cursor.hxx>
27 #include "swregion.hxx"
31 class SwTextInputField
;
34 // From here classes/methods for non-text cursor.
38 friend void InitCore();
39 friend void FinitCore();
44 vcl::Cursor m_aTextCursor
;
45 const SwCursorShell
* m_pCursorShell
;
47 /// For LibreOfficeKit only - remember what page we were at the last time.
48 sal_uInt16 m_nPageLastTime
;
51 SwVisibleCursor( const SwCursorShell
* pCShell
);
57 bool IsVisible() const { return m_bIsVisible
; }
58 void SetDragCursor( bool bFlag
= true ) { m_bIsDragCursor
= bFlag
; }
59 void SetPosAndShow(SfxViewShell
* pViewShell
);
62 // From here classes/methods for selections.
64 namespace sdr
{ namespace overlay
{ class OverlayObject
; }}
65 namespace sw
{ namespace overlay
{ class OverlayRangesOutline
; }}
67 class SwSelPaintRects
: public SwRects
69 friend void InitCore();
70 friend void FinitCore();
72 static long s_nPixPtX
, s_nPixPtY
;
73 static MapMode
*s_pMapMode
;
75 const SwCursorShell
* m_pCursorShell
;
77 #if HAVE_FEATURE_DESKTOP || defined(ANDROID)
78 sdr::overlay::OverlayObject
* m_pCursorOverlay
;
80 // access to m_pCursorOverlay for swapContent
81 sdr::overlay::OverlayObject
* getCursorOverlay() const { return m_pCursorOverlay
; }
82 void setCursorOverlay(sdr::overlay::OverlayObject
* pNew
) { m_pCursorOverlay
= pNew
; }
85 bool m_bShowTextInputFieldOverlay
;
86 sw::overlay::OverlayRangesOutline
* m_pTextInputFieldOverlay
;
88 void HighlightInputField();
91 SwSelPaintRects( const SwCursorShell
& rCSh
);
92 virtual ~SwSelPaintRects();
94 virtual void FillRects() = 0;
95 /// Fill rStart and rEnd with a rectangle that represents the start and end for selection handles.
96 virtual void FillStartEnd(SwRect
& rStart
, SwRect
& rEnd
) const = 0;
98 // #i75172# in SwCursorShell::CreateCursor() the content of SwSelPaintRects is exchanged. To
99 // make a complete swap access to m_pCursorOverlay is needed there
100 void swapContent(SwSelPaintRects
& rSwap
);
102 void Show(std::vector
<OString
>* pSelectionRectangles
= nullptr);
104 void Invalidate( const SwRect
& rRect
);
106 void SetShowTextInputFieldOverlay( const bool bShow
)
108 m_bShowTextInputFieldOverlay
= bShow
;
111 const SwCursorShell
* GetShell() const { return m_pCursorShell
; }
112 // check current MapMode of the shell and set possibly the static members.
113 // Optional set the parameters pX, pY
114 static void Get1PixelInLogic( const SwViewShell
& rSh
,
115 long* pX
= nullptr, long* pY
= nullptr );
118 class SwShellCursor
: public virtual SwCursor
, public SwSelPaintRects
121 // Document positions of start/end characters of a SSelection.
124 const SwPosition
* m_pInitialPoint
; // For assignment of GetPoint() to m_PointPt.
126 using SwCursor::UpDown
;
129 SwShellCursor( const SwCursorShell
& rCursorSh
, const SwPosition
&rPos
);
130 SwShellCursor( const SwCursorShell
& rCursorSh
, const SwPosition
&rPos
,
131 const Point
& rPtPos
, SwPaM
* pRing
);
132 // note: *intentionally* links the new shell cursor into the old one's Ring
133 SwShellCursor( SwShellCursor
& );
134 virtual ~SwShellCursor() override
;
136 virtual void FillRects() override
; // For Table- and normal cursors.
137 /// @see SwSelPaintRects::FillStartEnd(), override for text selections.
138 virtual void FillStartEnd(SwRect
& rStart
, SwRect
& rEnd
) const override
;
140 void Show(SfxViewShell
* pViewShell
); // Update and display all selections.
141 void Hide(); // Hide all selections.
142 void Invalidate( const SwRect
& rRect
);
144 const Point
& GetPtPos() const { return (SwPaM::GetPoint() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
145 Point
& GetPtPos() { return (SwPaM::GetPoint() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
146 const Point
& GetMkPos() const { return (SwPaM::GetMark() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
147 Point
& GetMkPos() { return (SwPaM::GetMark() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
148 const Point
& GetSttPos() const { return (SwPaM::Start() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
149 Point
& GetSttPos() { return (SwPaM::Start() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
150 const Point
& GetEndPos() const { return (SwPaM::End() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
151 Point
& GetEndPos() { return (SwPaM::End() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
153 virtual void SetMark() override
;
155 virtual SwCursor
* Create( SwPaM
* pRing
= nullptr ) const override
;
157 virtual short MaxReplaceArived() override
; //returns RET_YES/RET_CANCEL/RET_NO
158 virtual void SaveTableBoxContent( const SwPosition
* pPos
) override
;
160 bool UpDown( bool bUp
, sal_uInt16 nCnt
);
162 // true: Cursor can be set to this position.
163 virtual bool IsAtValidPos( bool bPoint
= true ) const override
;
165 virtual bool IsReadOnlyAvailable() const override
;
167 DECL_FIXEDMEMPOOL_NEWDEL( SwShellCursor
)
170 class SwShellTableCursor
: public virtual SwShellCursor
, public virtual SwTableCursor
172 /// Left edge of the selection start (top left cell).
174 /// Right edge of the selection end (bottom right cell).
176 // The Selection has the same order as the table boxes, i.e.
177 // if something is deleted from the one array at a certain position
178 // it has to be deleted from the other one as well!!
181 SwShellTableCursor( const SwCursorShell
& rCursorSh
, const SwPosition
& rPos
);
182 SwShellTableCursor( const SwCursorShell
& rCursorSh
,
183 const SwPosition
&rMkPos
, const Point
& rMkPt
,
184 const SwPosition
&rPtPos
, const Point
& rPtPt
);
185 virtual ~SwShellTableCursor() override
;
187 virtual void FillRects() override
; // For table and normal cursor.
188 /// @see SwSelPaintRects::FillStartEnd(), override for table selections.
189 virtual void FillStartEnd(SwRect
& rStart
, SwRect
& rEnd
) const override
;
191 // Check if SPoint is within table SSelection.
192 bool IsInside( const Point
& rPt
) const;
194 virtual void SetMark() override
;
195 virtual SwCursor
* Create( SwPaM
* pRing
= nullptr ) const override
;
197 virtual short MaxReplaceArived() override
; //returns RET_YES/RET_CANCEL/RET_NO
198 virtual void SaveTableBoxContent( const SwPosition
* pPos
) override
;
200 // true: Cursor can be set to this position.
201 virtual bool IsAtValidPos( bool bPoint
= true ) const override
;
205 #endif // INCLUDED_SW_INC_VISCRS_HXX
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */