1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _VISCRS_HXX 28 #define _VISCRS_HXX 29 30 #include <vcl/cursor.hxx> 31 #include "swcrsr.hxx" 32 #include "swrect.hxx" 33 #include "swregion.hxx" 34 35 class SwCrsrShell; 36 class SwShellCrsr; 37 38 // -------- Ab hier Klassen / Methoden fuer den nicht Text-Cursor ------ 39 40 class SwVisCrsr 41 #ifdef SW_CRSR_TIMER 42 : private Timer 43 #endif 44 { 45 friend void _InitCore(); 46 friend void _FinitCore(); 47 48 sal_Bool bIsVisible : 1; 49 sal_Bool bIsDragCrsr : 1; 50 51 #ifdef SW_CRSR_TIMER 52 sal_Bool bTimerOn : 1; 53 #endif 54 55 Cursor aTxtCrsr; 56 const SwCrsrShell* pCrsrShell; 57 58 #ifdef SW_CRSR_TIMER 59 virtual void Timeout(); 60 #endif 61 void _SetPosAndShow(); 62 63 public: 64 SwVisCrsr( const SwCrsrShell * pCShell ); 65 ~SwVisCrsr(); 66 67 void Show(); 68 void Hide(); 69 70 sal_Bool IsVisible() const { return bIsVisible; } 71 void SetDragCrsr( sal_Bool bFlag = sal_True ) { bIsDragCrsr = bFlag; } 72 73 #ifdef SW_CRSR_TIMER 74 sal_Bool ChgTimerFlag( sal_Bool bTimerOn = sal_True ); 75 #endif 76 }; 77 78 79 // ------ Ab hier Klassen / Methoden fuer die Selectionen ------- 80 81 // #i75172# predefines 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 // die Shell 93 const SwCrsrShell* pCShell; 94 95 virtual void Paint( const Rectangle& rRect ); 96 virtual void FillRects() = 0; 97 98 // #i75172# 99 sdr::overlay::OverlayObject* mpCursorOverlay; 100 101 // #i75172# access to mpCursorOverlay for swapContent 102 sdr::overlay::OverlayObject* getCursorOverlay() const { return mpCursorOverlay; } 103 void setCursorOverlay(sdr::overlay::OverlayObject* pNew) { mpCursorOverlay = pNew; } 104 105 public: 106 SwSelPaintRects( const SwCrsrShell& rCSh ); 107 virtual ~SwSelPaintRects(); 108 109 // #i75172# in SwCrsrShell::CreateCrsr() the content of SwSelPaintRects is exchanged. To 110 // make a complete swap access to mpCursorOverlay is needed there 111 void swapContent(SwSelPaintRects& rSwap); 112 113 void Show(); 114 void Hide(); 115 void Invalidate( const SwRect& rRect ); 116 117 const SwCrsrShell* GetShell() const { return pCShell; } 118 // check current MapMode of the shell and set possibly the static members. 119 // Optional set the parameters pX, pY 120 static void Get1PixelInLogic( const ViewShell& rSh, 121 long* pX = 0, long* pY = 0 ); 122 }; 123 124 125 class SwShellCrsr : public virtual SwCursor, public SwSelPaintRects 126 { 127 // Dokument-Positionen der Start/End-Charakter einer SSelection 128 Point aMkPt, aPtPt; 129 const SwPosition* pPt; // fuer Zuordung vom GetPoint() zum aPtPt 130 131 virtual void FillRects(); // fuer Table- und normalen Crsr 132 133 using SwCursor::UpDown; 134 135 public: 136 SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos ); 137 SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos, 138 const Point& rPtPos, SwPaM* pRing = 0 ); 139 SwShellCrsr( SwShellCrsr& ); 140 virtual ~SwShellCrsr(); 141 142 void Show(); // Update und zeige alle Selektionen an 143 void Hide(); // verstecke alle Selektionen 144 void Invalidate( const SwRect& rRect ); 145 146 const Point& GetPtPos() const { return( SwPaM::GetPoint() == pPt ? aPtPt : aMkPt ); } 147 Point& GetPtPos() { return( SwPaM::GetPoint() == pPt ? aPtPt : aMkPt ); } 148 const Point& GetMkPos() const { return( SwPaM::GetMark() == pPt ? aPtPt : aMkPt ); } 149 Point& GetMkPos() { return( SwPaM::GetMark() == pPt ? aPtPt : aMkPt ); } 150 const Point& GetSttPos() const { return( SwPaM::Start() == pPt ? aPtPt : aMkPt ); } 151 Point& GetSttPos() { return( SwPaM::Start() == pPt ? aPtPt : aMkPt ); } 152 const Point& GetEndPos() const { return( SwPaM::End() == pPt ? aPtPt : aMkPt ); } 153 Point& GetEndPos() { return( SwPaM::End() == pPt ? aPtPt : aMkPt ); } 154 155 virtual void SetMark(); 156 157 virtual SwCursor* Create( SwPaM* pRing = 0 ) const; 158 159 virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO 160 virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 ); 161 162 sal_Bool UpDown( sal_Bool bUp, sal_uInt16 nCnt = 1 ); 163 164 // sal_True: an die Position kann der Cursor gesetzt werden 165 virtual sal_Bool IsAtValidPos( sal_Bool bPoint = sal_True ) const; 166 167 #ifdef DBG_UTIL 168 // JP 05.03.98: zum Testen des UNO-Crsr Verhaltens hier die Implementierung 169 // am sichtbaren Cursor 170 virtual sal_Bool IsSelOvr( int eFlags = 171 ( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | 172 nsSwCursorSelOverFlags::SELOVER_TOGGLE | 173 nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )); 174 #endif 175 176 virtual bool IsReadOnlyAvailable() const; 177 178 DECL_FIXEDMEMPOOL_NEWDEL( SwShellCrsr ) 179 }; 180 181 182 183 class SwShellTableCrsr : public virtual SwShellCrsr, public virtual SwTableCursor 184 { 185 // die Selection hat die gleiche Reihenfolge wie die 186 // TabellenBoxen. D.h., wird aus dem einen Array an einer Position 187 // etwas geloescht, dann muss es auch im anderen erfolgen!! 188 189 190 public: 191 SwShellTableCrsr( const SwCrsrShell& rCrsrSh, const SwPosition& rPos ); 192 SwShellTableCrsr( const SwCrsrShell& rCrsrSh, 193 const SwPosition &rMkPos, const Point& rMkPt, 194 const SwPosition &rPtPos, const Point& rPtPt ); 195 virtual ~SwShellTableCrsr(); 196 197 virtual void FillRects(); // fuer Table- und normalen Crsr 198 199 // Pruefe, ob sich der SPoint innerhalb der Tabellen-SSelection befindet 200 sal_Bool IsInside( const Point& rPt ) const; 201 202 virtual void SetMark(); 203 virtual SwCursor* Create( SwPaM* pRing = 0 ) const; 204 205 virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO 206 virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 ); 207 208 // sal_True: an die Position kann der Cursor gesetzt werden 209 virtual sal_Bool IsAtValidPos( sal_Bool bPoint = sal_True ) const; 210 211 #ifdef DBG_UTIL 212 // JP 05.03.98: zum Testen des UNO-Crsr Verhaltens hier die Implementierung 213 // am sichtbaren Cursor 214 virtual sal_Bool IsSelOvr( int eFlags = 215 ( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | 216 nsSwCursorSelOverFlags::SELOVER_TOGGLE | 217 nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )); 218 #endif 219 }; 220 221 222 223 #endif // _VISCRS_HXX 224