Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _VISCRS_HXX
29 : : #define _VISCRS_HXX
30 : :
31 : : #include <vcl/cursor.hxx>
32 : : #include "swcrsr.hxx"
33 : : #include "swrect.hxx"
34 : : #include "swregion.hxx"
35 : :
36 : : class SwCrsrShell;
37 : : class SwShellCrsr;
38 : :
39 : : // From here classes/methods for non-text cursor.
40 : :
41 : : class SwVisCrsr
42 : : #ifdef SW_CRSR_TIMER
43 : : : private Timer
44 : : #endif
45 : : {
46 : : friend void _InitCore();
47 : : friend void _FinitCore();
48 : :
49 : : sal_Bool bIsVisible : 1;
50 : : sal_Bool bIsDragCrsr : 1;
51 : :
52 : : #ifdef SW_CRSR_TIMER
53 : : sal_Bool bTimerOn : 1;
54 : : #endif
55 : :
56 : : Cursor aTxtCrsr;
57 : : const SwCrsrShell* pCrsrShell;
58 : :
59 : : #ifdef SW_CRSR_TIMER
60 : : virtual void Timeout();
61 : : #endif
62 : : void _SetPosAndShow();
63 : :
64 : : public:
65 : : SwVisCrsr( const SwCrsrShell * pCShell );
66 : : ~SwVisCrsr();
67 : :
68 : : void Show();
69 : : void Hide();
70 : :
71 : 17437 : sal_Bool IsVisible() const { return bIsVisible; }
72 : 0 : void SetDragCrsr( sal_Bool bFlag = sal_True ) { bIsDragCrsr = bFlag; }
73 : :
74 : : #ifdef SW_CRSR_TIMER
75 : : sal_Bool ChgTimerFlag( sal_Bool bTimerOn = sal_True );
76 : : #endif
77 : : };
78 : :
79 : :
80 : : // From here classes/methods for selections.
81 : :
82 : : namespace sdr { namespace overlay { class OverlayObject; }}
83 : :
84 : : class SwSelPaintRects : public SwRects
85 : : {
86 : : friend void _InitCore();
87 : : friend void _FinitCore();
88 : :
89 : : static long nPixPtX, nPixPtY;
90 : : static MapMode *pMapMode;
91 : :
92 : : const SwCrsrShell* pCShell;
93 : :
94 : : virtual void Paint( const Rectangle& rRect );
95 : : virtual void FillRects() = 0;
96 : :
97 : : sdr::overlay::OverlayObject* mpCursorOverlay;
98 : :
99 : : // access to mpCursorOverlay for swapContent
100 : 0 : sdr::overlay::OverlayObject* getCursorOverlay() const { return mpCursorOverlay; }
101 : 0 : void setCursorOverlay(sdr::overlay::OverlayObject* pNew) { mpCursorOverlay = pNew; }
102 : :
103 : : public:
104 : : SwSelPaintRects( const SwCrsrShell& rCSh );
105 : : virtual ~SwSelPaintRects();
106 : :
107 : : // in SwCrsrShell::CreateCrsr() the content of SwSelPaintRects is exchanged. To
108 : : // make a complete swap access to mpCursorOverlay is needed there
109 : : void swapContent(SwSelPaintRects& rSwap);
110 : :
111 : : void Show();
112 : : void Hide();
113 : : void Invalidate( const SwRect& rRect );
114 : :
115 : 1818 : const SwCrsrShell* GetShell() const { return pCShell; }
116 : : // check current MapMode of the shell and set possibly the static members.
117 : : // Optional set the parameters pX, pY
118 : : static void Get1PixelInLogic( const ViewShell& rSh,
119 : : long* pX = 0, long* pY = 0 );
120 : : };
121 : :
122 : :
123 : : class SwShellCrsr : public virtual SwCursor, public SwSelPaintRects
124 : : {
125 : : // Document positions of start/end characters of a SSelection.
126 : : Point aMkPt, aPtPt;
127 : : const SwPosition* pPt; // For assignment of GetPoint() to aPtPt.
128 : :
129 : : virtual void FillRects(); // For Table- und normal cursors.
130 : :
131 : : using SwCursor::UpDown;
132 : :
133 : : public:
134 : : SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos );
135 : : SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos,
136 : : const Point& rPtPos, SwPaM* pRing = 0 );
137 : : SwShellCrsr( SwShellCrsr& );
138 : : virtual ~SwShellCrsr();
139 : :
140 : : void Show(); // Update and display all selections.
141 : : void Hide(); // Hide all selections.
142 : : void Invalidate( const SwRect& rRect );
143 : :
144 [ + - ]: 51 : const Point& GetPtPos() const { return( SwPaM::GetPoint() == pPt ? aPtPt : aMkPt ); }
145 [ + + ]: 209494 : Point& GetPtPos() { return( SwPaM::GetPoint() == pPt ? aPtPt : aMkPt ); }
146 [ + + ]: 27 : const Point& GetMkPos() const { return( SwPaM::GetMark() == pPt ? aPtPt : aMkPt ); }
147 [ - + ]: 24 : Point& GetMkPos() { return( SwPaM::GetMark() == pPt ? aPtPt : aMkPt ); }
148 : : const Point& GetSttPos() const { return( SwPaM::Start() == pPt ? aPtPt : aMkPt ); }
149 [ + + ]: 575 : Point& GetSttPos() { return( SwPaM::Start() == pPt ? aPtPt : aMkPt ); }
150 : : const Point& GetEndPos() const { return( SwPaM::End() == pPt ? aPtPt : aMkPt ); }
151 [ + + ]: 467 : Point& GetEndPos() { return( SwPaM::End() == pPt ? aPtPt : aMkPt ); }
152 : :
153 : : virtual void SetMark();
154 : :
155 : : virtual SwCursor* Create( SwPaM* pRing = 0 ) const;
156 : :
157 : : virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO
158 : : virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 );
159 : :
160 : : sal_Bool UpDown( sal_Bool bUp, sal_uInt16 nCnt = 1 );
161 : :
162 : : // sal_True: Cursor can be set to this position.
163 : : virtual sal_Bool IsAtValidPos( sal_Bool bPoint = sal_True ) const;
164 : :
165 : : virtual bool IsReadOnlyAvailable() const;
166 : :
167 [ + + ][ + + ]: 2647 : DECL_FIXEDMEMPOOL_NEWDEL( SwShellCrsr )
168 : : };
169 : :
170 : :
171 : :
172 : : class SwShellTableCrsr : public virtual SwShellCrsr, public virtual SwTableCursor
173 : : {
174 : : // The Selection has the same order as the table boxes, i.e.
175 : : // if something is deleted from the one array at a certain position
176 : : // it has to be deleted from the other one as well!!
177 : :
178 : : public:
179 : : SwShellTableCrsr( const SwCrsrShell& rCrsrSh, const SwPosition& rPos );
180 : : SwShellTableCrsr( const SwCrsrShell& rCrsrSh,
181 : : const SwPosition &rMkPos, const Point& rMkPt,
182 : : const SwPosition &rPtPos, const Point& rPtPt );
183 : : virtual ~SwShellTableCrsr();
184 : :
185 : : virtual void FillRects(); // For table and normal cursor.
186 : :
187 : : // Check if SPoint is within table SSelection.
188 : : sal_Bool IsInside( const Point& rPt ) const;
189 : :
190 : : virtual void SetMark();
191 : : virtual SwCursor* Create( SwPaM* pRing = 0 ) const;
192 : :
193 : : virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO
194 : : virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 );
195 : :
196 : : // sal_True: Cursor can be set to this position.
197 : : virtual sal_Bool IsAtValidPos( sal_Bool bPoint = sal_True ) const;
198 : :
199 : : };
200 : :
201 : : #endif // _VISCRS_HXX
202 : :
203 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|