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
;
33 // From here classes/methods for non-text cursor.
37 friend void _InitCore();
38 friend void _FinitCore();
43 vcl::Cursor m_aTextCrsr
;
44 const SwCrsrShell
* m_pCrsrShell
;
46 void _SetPosAndShow();
49 SwVisCrsr( const SwCrsrShell
* pCShell
);
55 bool IsVisible() const { return m_bIsVisible
; }
56 void SetDragCrsr( bool bFlag
= true ) { m_bIsDragCrsr
= bFlag
; }
59 // From here classes/methods for selections.
61 namespace sdr
{ namespace overlay
{ class OverlayObject
; }}
62 namespace sw
{ namespace overlay
{ class OverlayRangesOutline
; }}
64 class SwSelPaintRects
: public SwRects
66 friend void _InitCore();
67 friend void _FinitCore();
69 static long s_nPixPtX
, s_nPixPtY
;
70 static MapMode
*s_pMapMode
;
72 const SwCrsrShell
* m_pCursorShell
;
74 #if HAVE_FEATURE_DESKTOP || defined(ANDROID)
75 sdr::overlay::OverlayObject
* m_pCursorOverlay
;
77 // access to m_pCursorOverlay for swapContent
78 sdr::overlay::OverlayObject
* getCursorOverlay() const { return m_pCursorOverlay
; }
79 void setCursorOverlay(sdr::overlay::OverlayObject
* pNew
) { m_pCursorOverlay
= pNew
; }
82 bool m_bShowTextInputFieldOverlay
;
83 sw::overlay::OverlayRangesOutline
* m_pTextInputFieldOverlay
;
85 void HighlightInputField();
88 SwSelPaintRects( const SwCrsrShell
& rCSh
);
89 virtual ~SwSelPaintRects();
91 virtual void FillRects() = 0;
92 /// Fill rStart and rEnd with a rectangle that represents the start and end for selection handles.
93 virtual void FillStartEnd(SwRect
& rStart
, SwRect
& rEnd
) const = 0;
95 // #i75172# in SwCrsrShell::CreateCrsr() the content of SwSelPaintRects is exchanged. To
96 // make a complete swap access to m_pCursorOverlay is needed there
97 void swapContent(SwSelPaintRects
& rSwap
);
99 void Show(std::vector
<OString
>* pSelectionRectangles
= 0);
101 void Invalidate( const SwRect
& rRect
);
103 inline void SetShowTextInputFieldOverlay( const bool bShow
)
105 m_bShowTextInputFieldOverlay
= bShow
;
108 const SwCrsrShell
* GetShell() const { return m_pCursorShell
; }
109 // check current MapMode of the shell and set possibly the static members.
110 // Optional set the parameters pX, pY
111 static void Get1PixelInLogic( const SwViewShell
& rSh
,
112 long* pX
= 0, long* pY
= 0 );
115 class SwShellCrsr
: public virtual SwCursor
, public SwSelPaintRects
118 // Document positions of start/end characters of a SSelection.
121 const SwPosition
* m_pInitialPoint
; // For assignment of GetPoint() to m_PointPt.
123 using SwCursor::UpDown
;
126 SwShellCrsr( const SwCrsrShell
& rCrsrSh
, const SwPosition
&rPos
);
127 SwShellCrsr( const SwCrsrShell
& rCrsrSh
, const SwPosition
&rPos
,
128 const Point
& rPtPos
, SwPaM
* pRing
= 0 );
129 // note: *intentionally* links the new shell cursor into the old one's Ring
130 SwShellCrsr( SwShellCrsr
& );
131 virtual ~SwShellCrsr();
133 virtual void FillRects() SAL_OVERRIDE
; // For Table- und normal cursors.
134 /// @see SwSelPaintRects::FillStartEnd(), override for text selections.
135 virtual void FillStartEnd(SwRect
& rStart
, SwRect
& rEnd
) const SAL_OVERRIDE
;
137 void Show(); // Update and display all selections.
138 void Hide(); // Hide all selections.
139 void Invalidate( const SwRect
& rRect
);
141 const Point
& GetPtPos() const { return (SwPaM::GetPoint() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
142 Point
& GetPtPos() { return (SwPaM::GetPoint() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
143 const Point
& GetMkPos() const { return (SwPaM::GetMark() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
144 Point
& GetMkPos() { return (SwPaM::GetMark() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
145 const Point
& GetSttPos() const { return (SwPaM::Start() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
146 Point
& GetSttPos() { return (SwPaM::Start() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
147 const Point
& GetEndPos() const { return (SwPaM::End() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
148 Point
& GetEndPos() { return (SwPaM::End() == m_pInitialPoint
) ? m_PointPt
: m_MarkPt
; }
150 virtual void SetMark() SAL_OVERRIDE
;
152 virtual SwCursor
* Create( SwPaM
* pRing
= 0 ) const SAL_OVERRIDE
;
154 virtual short MaxReplaceArived() SAL_OVERRIDE
; //returns RET_YES/RET_CANCEL/RET_NO
155 virtual void SaveTableBoxContent( const SwPosition
* pPos
= 0 ) SAL_OVERRIDE
;
157 bool UpDown( bool bUp
, sal_uInt16 nCnt
= 1 );
159 // true: Cursor can be set to this position.
160 virtual bool IsAtValidPos( bool bPoint
= true ) const SAL_OVERRIDE
;
162 virtual bool IsReadOnlyAvailable() const SAL_OVERRIDE
;
164 DECL_FIXEDMEMPOOL_NEWDEL( SwShellCrsr
)
167 class SwShellTableCrsr
: public virtual SwShellCrsr
, public virtual SwTableCursor
169 /// Left edge of the selection start (top left cell).
171 /// Right edge of the selection end (bottom right cell).
173 // The Selection has the same order as the table boxes, i.e.
174 // if something is deleted from the one array at a certain position
175 // it has to be deleted from the other one as well!!
178 SwShellTableCrsr( const SwCrsrShell
& rCrsrSh
, const SwPosition
& rPos
);
179 SwShellTableCrsr( const SwCrsrShell
& rCrsrSh
,
180 const SwPosition
&rMkPos
, const Point
& rMkPt
,
181 const SwPosition
&rPtPos
, const Point
& rPtPt
);
182 virtual ~SwShellTableCrsr();
184 virtual void FillRects() SAL_OVERRIDE
; // For table and normal cursor.
185 /// @see SwSelPaintRects::FillStartEnd(), override for table selections.
186 virtual void FillStartEnd(SwRect
& rStart
, SwRect
& rEnd
) const SAL_OVERRIDE
;
188 // Check if SPoint is within table SSelection.
189 bool IsInside( const Point
& rPt
) const;
191 virtual void SetMark() SAL_OVERRIDE
;
192 virtual SwCursor
* Create( SwPaM
* pRing
= 0 ) const SAL_OVERRIDE
;
194 virtual short MaxReplaceArived() SAL_OVERRIDE
; //returns RET_YES/RET_CANCEL/RET_NO
195 virtual void SaveTableBoxContent( const SwPosition
* pPos
= 0 ) SAL_OVERRIDE
;
197 // true: Cursor can be set to this position.
198 virtual bool IsAtValidPos( bool bPoint
= true ) const SAL_OVERRIDE
;
202 #endif // INCLUDED_SW_INC_VISCRS_HXX
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */