xref: /trunk/main/sw/inc/viscrs.hxx (revision 69a74367)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _VISCRS_HXX
24 #define _VISCRS_HXX
25 
26 #include <vcl/cursor.hxx>
27 #include "swcrsr.hxx"
28 #include "swrect.hxx"
29 #include "swregion.hxx"
30 
31 class SwCrsrShell;
32 class SwShellCrsr;
33 class SwTxtInputFld;
34 
35 // --------  Ab hier Klassen / Methoden fuer den nicht Text-Cursor ------
36 
37 class SwVisCrsr
38 #ifdef SW_CRSR_TIMER
39 				: private Timer
40 #endif
41 {
42 	friend void _InitCore();
43 	friend void _FinitCore();
44 
45 	sal_Bool bIsVisible : 1;
46 	sal_Bool bIsDragCrsr : 1;
47 
48 #ifdef SW_CRSR_TIMER
49 	sal_Bool bTimerOn : 1;
50 #endif
51 
52 	Cursor aTxtCrsr;
53 	const SwCrsrShell* pCrsrShell;
54 
55 #ifdef SW_CRSR_TIMER
56 	virtual void Timeout();
57 #endif
58 	void _SetPosAndShow();
59 
60 public:
61 	SwVisCrsr( const SwCrsrShell * pCShell );
62 	~SwVisCrsr();
63 
64 	void Show();
65 	void Hide();
66 
IsVisible() const67 	sal_Bool IsVisible() const { return bIsVisible; }
SetDragCrsr(sal_Bool bFlag=sal_True)68     void SetDragCrsr( sal_Bool bFlag = sal_True ) { bIsDragCrsr = bFlag; }
69 
70 #ifdef SW_CRSR_TIMER
71 	sal_Bool ChgTimerFlag( sal_Bool bTimerOn = sal_True );
72 #endif
73 };
74 
75 
76 // ------ Ab hier Klassen / Methoden fuer die Selectionen -------
77 
78 // #i75172# predefines
79 namespace sdr { namespace overlay { class OverlayObject; }}
80 namespace sw { namespace overlay { class OverlayRangesOutline; }}
81 
82 class SwSelPaintRects : public SwRects
83 {
84 	friend void _InitCore();
85 	friend void _FinitCore();
86 
87 	static long nPixPtX, nPixPtY;
88 	static MapMode *pMapMode;
89 
90 	// die Shell
91 	const SwCrsrShell* pCShell;
92 
93 	virtual void Paint( const Rectangle& rRect );
94 
95 	// #i75172#
96 	sdr::overlay::OverlayObject*	mpCursorOverlay;
97 
98 	// #i75172# access to mpCursorOverlay for swapContent
getCursorOverlay() const99 	sdr::overlay::OverlayObject* getCursorOverlay() const { return mpCursorOverlay; }
setCursorOverlay(sdr::overlay::OverlayObject * pNew)100 	void setCursorOverlay(sdr::overlay::OverlayObject* pNew) { mpCursorOverlay = pNew; }
101 
102     bool mbShowTxtInputFldOverlay;
103     sw::overlay::OverlayRangesOutline* mpTxtInputFldOverlay;
104 
105     void HighlightInputFld();
106 
107 public:
108 	SwSelPaintRects( const SwCrsrShell& rCSh );
109 	virtual ~SwSelPaintRects();
110 
111 	virtual void FillRects() = 0;
112 
113     // #i75172# in SwCrsrShell::CreateCrsr() the content of SwSelPaintRects is exchanged. To
114 	// make a complete swap access to mpCursorOverlay is needed there
115 	void swapContent(SwSelPaintRects& rSwap);
116 
117 	void Show();
118 	void Hide();
119 	void Invalidate( const SwRect& rRect );
120 
SetShowTxtInputFldOverlay(const bool bShow)121     inline void SetShowTxtInputFldOverlay( const bool bShow )
122     {
123         mbShowTxtInputFldOverlay = bShow;
124     }
125 
GetShell() const126 	const SwCrsrShell* GetShell() const { return pCShell; }
127 	// check current MapMode of the shell and set possibly the static members.
128 	// Optional set the parameters pX, pY
129 	static void Get1PixelInLogic( const ViewShell& rSh,
130 									long* pX = 0, long* pY = 0 );
131 };
132 
133 
134 class SwShellCrsr : public virtual SwCursor, public SwSelPaintRects
135 {
136 	// Dokument-Positionen der Start/End-Charakter einer SSelection
137 	Point aMkPt, aPtPt;
138 	const SwPosition* pPt;		// fuer Zuordung vom GetPoint() zum aPtPt
139 
140     using SwCursor::UpDown;
141 
142 public:
143 	SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos );
144 	SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos,
145 					const Point& rPtPos, SwPaM* pRing = 0 );
146 	SwShellCrsr( SwShellCrsr& );
147 	virtual ~SwShellCrsr();
148 
149 	virtual void FillRects();	// fuer Table- und normalen Crsr
150 
151 	void Show();			// Update und zeige alle Selektionen an
152 	void Hide();	  		// verstecke alle Selektionen
153 	void Invalidate( const SwRect& rRect );
154 
GetPtPos() const155 	const Point& GetPtPos() const	{ return( SwPaM::GetPoint() == pPt ? aPtPt : aMkPt ); }
GetPtPos()156 		  Point& GetPtPos() 		{ return( SwPaM::GetPoint() == pPt ? aPtPt : aMkPt ); }
GetMkPos() const157 	const Point& GetMkPos() const 	{ return( SwPaM::GetMark() == pPt ? aPtPt : aMkPt ); }
GetMkPos()158 		  Point& GetMkPos() 		{ return( SwPaM::GetMark() == pPt ? aPtPt : aMkPt ); }
GetSttPos() const159 	const Point& GetSttPos() const	{ return( SwPaM::Start() == pPt ? aPtPt : aMkPt ); }
GetSttPos()160 		  Point& GetSttPos() 		{ return( SwPaM::Start() == pPt ? aPtPt : aMkPt ); }
GetEndPos() const161 	const Point& GetEndPos() const	{ return( SwPaM::End() == pPt ? aPtPt : aMkPt ); }
GetEndPos()162 		  Point& GetEndPos() 		{ return( SwPaM::End() == pPt ? aPtPt : aMkPt ); }
163 
164 	virtual void SetMark();
165 
166 	virtual SwCursor* Create( SwPaM* pRing = 0 ) const;
167 
168     virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO
169 	virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 );
170 
171 	sal_Bool UpDown( sal_Bool bUp, sal_uInt16 nCnt = 1 );
172 
173 	// sal_True: an die Position kann der Cursor gesetzt werden
174 	virtual sal_Bool IsAtValidPos( sal_Bool bPoint = sal_True ) const;
175 
176 #ifdef DBG_UTIL
177 // JP 05.03.98: zum Testen des UNO-Crsr Verhaltens hier die Implementierung
178 //				am sichtbaren Cursor
179 	virtual sal_Bool IsSelOvr( int eFlags =
180                                 ( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
181                                   nsSwCursorSelOverFlags::SELOVER_TOGGLE |
182                                   nsSwCursorSelOverFlags::SELOVER_CHANGEPOS ));
183 #endif
184 
185 	virtual bool IsReadOnlyAvailable() const;
186 
187 	DECL_FIXEDMEMPOOL_NEWDEL( SwShellCrsr )
188 };
189 
190 
191 
192 class SwShellTableCrsr : public virtual SwShellCrsr, public virtual SwTableCursor
193 {
194 	// die Selection hat die gleiche Reihenfolge wie die
195 	// TabellenBoxen. D.h., wird aus dem einen Array an einer Position
196 	// etwas geloescht, dann muss es auch im anderen erfolgen!!
197 
198 public:
199 	SwShellTableCrsr( const SwCrsrShell& rCrsrSh, const SwPosition& rPos );
200 	SwShellTableCrsr( const SwCrsrShell& rCrsrSh,
201 					const SwPosition &rMkPos, const Point& rMkPt,
202 					const SwPosition &rPtPos, const Point& rPtPt );
203 	virtual ~SwShellTableCrsr();
204 
205 	virtual void FillRects();	// fuer Table- und normalen Crsr
206 
207 	// Pruefe, ob sich der SPoint innerhalb der Tabellen-SSelection befindet
208 	sal_Bool IsInside( const Point& rPt ) const;
209 
210 	virtual void SetMark();
211 	virtual SwCursor* Create( SwPaM* pRing = 0 ) const;
212 
213     virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO
214     virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 );
215 
216 	// sal_True: an die Position kann der Cursor gesetzt werden
217 	virtual sal_Bool IsAtValidPos( sal_Bool bPoint = sal_True ) const;
218 
219 #ifdef DBG_UTIL
220 // JP 05.03.98: zum Testen des UNO-Crsr Verhaltens hier die Implementierung
221 //				am sichtbaren Cursor
222 	virtual sal_Bool IsSelOvr( int eFlags =
223                                 ( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
224                                   nsSwCursorSelOverFlags::SELOVER_TOGGLE |
225                                   nsSwCursorSelOverFlags::SELOVER_CHANGEPOS ));
226 #endif
227 };
228 
229 
230 
231 #endif	// _VISCRS_HXX
232