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