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 34 // -------- Ab hier Klassen / Methoden fuer den nicht Text-Cursor ------ 35 36 class SwVisCrsr 37 #ifdef SW_CRSR_TIMER 38 : private Timer 39 #endif 40 { 41 friend void _InitCore(); 42 friend void _FinitCore(); 43 44 sal_Bool bIsVisible : 1; 45 sal_Bool bIsDragCrsr : 1; 46 47 #ifdef SW_CRSR_TIMER 48 sal_Bool bTimerOn : 1; 49 #endif 50 51 Cursor aTxtCrsr; 52 const SwCrsrShell* pCrsrShell; 53 54 #ifdef SW_CRSR_TIMER 55 virtual void Timeout(); 56 #endif 57 void _SetPosAndShow(); 58 59 public: 60 SwVisCrsr( const SwCrsrShell * pCShell ); 61 ~SwVisCrsr(); 62 63 void Show(); 64 void Hide(); 65 66 sal_Bool IsVisible() const { return bIsVisible; } 67 void SetDragCrsr( sal_Bool bFlag = sal_True ) { bIsDragCrsr = bFlag; } 68 69 #ifdef SW_CRSR_TIMER 70 sal_Bool ChgTimerFlag( sal_Bool bTimerOn = sal_True ); 71 #endif 72 }; 73 74 75 // ------ Ab hier Klassen / Methoden fuer die Selectionen ------- 76 77 // #i75172# predefines 78 namespace sdr { namespace overlay { class OverlayObject; }} 79 80 class SwSelPaintRects : public SwRects 81 { 82 friend void _InitCore(); 83 friend void _FinitCore(); 84 85 static long nPixPtX, nPixPtY; 86 static MapMode *pMapMode; 87 88 // die Shell 89 const SwCrsrShell* pCShell; 90 91 virtual void Paint( const Rectangle& rRect ); 92 virtual void FillRects() = 0; 93 94 // #i75172# 95 sdr::overlay::OverlayObject* mpCursorOverlay; 96 97 // #i75172# access to mpCursorOverlay for swapContent 98 sdr::overlay::OverlayObject* getCursorOverlay() const { return mpCursorOverlay; } 99 void setCursorOverlay(sdr::overlay::OverlayObject* pNew) { mpCursorOverlay = pNew; } 100 101 public: 102 SwSelPaintRects( const SwCrsrShell& rCSh ); 103 virtual ~SwSelPaintRects(); 104 105 // #i75172# in SwCrsrShell::CreateCrsr() the content of SwSelPaintRects is exchanged. To 106 // make a complete swap access to mpCursorOverlay is needed there 107 void swapContent(SwSelPaintRects& rSwap); 108 109 void Show(); 110 void Hide(); 111 void Invalidate( const SwRect& rRect ); 112 113 const SwCrsrShell* GetShell() const { return pCShell; } 114 // check current MapMode of the shell and set possibly the static members. 115 // Optional set the parameters pX, pY 116 static void Get1PixelInLogic( const ViewShell& rSh, 117 long* pX = 0, long* pY = 0 ); 118 }; 119 120 121 class SwShellCrsr : public virtual SwCursor, public SwSelPaintRects 122 { 123 // Dokument-Positionen der Start/End-Charakter einer SSelection 124 Point aMkPt, aPtPt; 125 const SwPosition* pPt; // fuer Zuordung vom GetPoint() zum aPtPt 126 127 virtual void FillRects(); // fuer Table- und normalen Crsr 128 129 using SwCursor::UpDown; 130 131 public: 132 SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos ); 133 SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos, 134 const Point& rPtPos, SwPaM* pRing = 0 ); 135 SwShellCrsr( SwShellCrsr& ); 136 virtual ~SwShellCrsr(); 137 138 void Show(); // Update und zeige alle Selektionen an 139 void Hide(); // verstecke alle Selektionen 140 void Invalidate( const SwRect& rRect ); 141 142 const Point& GetPtPos() const { return( SwPaM::GetPoint() == pPt ? aPtPt : aMkPt ); } 143 Point& GetPtPos() { return( SwPaM::GetPoint() == pPt ? aPtPt : aMkPt ); } 144 const Point& GetMkPos() const { return( SwPaM::GetMark() == pPt ? aPtPt : aMkPt ); } 145 Point& GetMkPos() { return( SwPaM::GetMark() == pPt ? aPtPt : aMkPt ); } 146 const Point& GetSttPos() const { return( SwPaM::Start() == pPt ? aPtPt : aMkPt ); } 147 Point& GetSttPos() { return( SwPaM::Start() == pPt ? aPtPt : aMkPt ); } 148 const Point& GetEndPos() const { return( SwPaM::End() == pPt ? aPtPt : aMkPt ); } 149 Point& GetEndPos() { return( SwPaM::End() == pPt ? aPtPt : aMkPt ); } 150 151 virtual void SetMark(); 152 153 virtual SwCursor* Create( SwPaM* pRing = 0 ) const; 154 155 virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO 156 virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 ); 157 158 sal_Bool UpDown( sal_Bool bUp, sal_uInt16 nCnt = 1 ); 159 160 // sal_True: an die Position kann der Cursor gesetzt werden 161 virtual sal_Bool IsAtValidPos( sal_Bool bPoint = sal_True ) const; 162 163 #ifdef DBG_UTIL 164 // JP 05.03.98: zum Testen des UNO-Crsr Verhaltens hier die Implementierung 165 // am sichtbaren Cursor 166 virtual sal_Bool IsSelOvr( int eFlags = 167 ( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | 168 nsSwCursorSelOverFlags::SELOVER_TOGGLE | 169 nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )); 170 #endif 171 172 virtual bool IsReadOnlyAvailable() const; 173 174 DECL_FIXEDMEMPOOL_NEWDEL( SwShellCrsr ) 175 }; 176 177 178 179 class SwShellTableCrsr : public virtual SwShellCrsr, public virtual SwTableCursor 180 { 181 // die Selection hat die gleiche Reihenfolge wie die 182 // TabellenBoxen. D.h., wird aus dem einen Array an einer Position 183 // etwas geloescht, dann muss es auch im anderen erfolgen!! 184 185 186 public: 187 SwShellTableCrsr( const SwCrsrShell& rCrsrSh, const SwPosition& rPos ); 188 SwShellTableCrsr( const SwCrsrShell& rCrsrSh, 189 const SwPosition &rMkPos, const Point& rMkPt, 190 const SwPosition &rPtPos, const Point& rPtPt ); 191 virtual ~SwShellTableCrsr(); 192 193 virtual void FillRects(); // fuer Table- und normalen Crsr 194 195 // Pruefe, ob sich der SPoint innerhalb der Tabellen-SSelection befindet 196 sal_Bool IsInside( const Point& rPt ) const; 197 198 virtual void SetMark(); 199 virtual SwCursor* Create( SwPaM* pRing = 0 ) const; 200 201 virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO 202 virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 ); 203 204 // sal_True: an die Position kann der Cursor gesetzt werden 205 virtual sal_Bool IsAtValidPos( sal_Bool bPoint = sal_True ) const; 206 207 #ifdef DBG_UTIL 208 // JP 05.03.98: zum Testen des UNO-Crsr Verhaltens hier die Implementierung 209 // am sichtbaren Cursor 210 virtual sal_Bool IsSelOvr( int eFlags = 211 ( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | 212 nsSwCursorSelOverFlags::SELOVER_TOGGLE | 213 nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )); 214 #endif 215 }; 216 217 218 219 #endif // _VISCRS_HXX 220