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