xref: /aoo41x/main/sw/source/ui/inc/edtwin.hxx (revision cdf0e10c)
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 _EDTWIN_HXX
28*cdf0e10cSrcweir #define _EDTWIN_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <svx/svdobj.hxx>
31*cdf0e10cSrcweir #include <tools/link.hxx>
32*cdf0e10cSrcweir #include <vcl/timer.hxx>
33*cdf0e10cSrcweir #include <vcl/window.hxx>
34*cdf0e10cSrcweir #include <svtools/transfer.hxx>
35*cdf0e10cSrcweir #include <swevent.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #define _SVSTDARR_STRINGSISORTDTOR
38*cdf0e10cSrcweir #include <svl/svstdarr.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir class	SwWrtShell;
41*cdf0e10cSrcweir class 	SwView;
42*cdf0e10cSrcweir class 	SwRect;
43*cdf0e10cSrcweir class	ViewShell;
44*cdf0e10cSrcweir class	SwAnchorMarker;
45*cdf0e10cSrcweir class	SdrObject;
46*cdf0e10cSrcweir class	SwShadowCursor;
47*cdf0e10cSrcweir class	DataChangedEvent;
48*cdf0e10cSrcweir class   SvxAutoCorrCfg;
49*cdf0e10cSrcweir class   SvxAutoCorrect;
50*cdf0e10cSrcweir class   SwPaM;
51*cdf0e10cSrcweir struct	SwApplyTemplate;
52*cdf0e10cSrcweir struct 	QuickHelpData;
53*cdf0e10cSrcweir class SdrDropMarkerOverlay;
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir /*--------------------------------------------------------------------
56*cdf0e10cSrcweir 	Beschreibung:	Eingabe-Fenster
57*cdf0e10cSrcweir  --------------------------------------------------------------------*/
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir class SwEditWin: public Window,
60*cdf0e10cSrcweir 				public DropTargetHelper, public DragSourceHelper
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir friend void 	ScrollMDI(ViewShell* pVwSh, const SwRect&,
63*cdf0e10cSrcweir 						  sal_uInt16 nRangeX, sal_uInt16 nRangeY);
64*cdf0e10cSrcweir friend sal_Bool 	IsScrollMDI(ViewShell* pVwSh, const SwRect&);
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir friend void 	SizeNotify(ViewShell* pVwSh, const Size &);
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir friend void 	PageNumNotify( 	ViewShell* pVwSh,
69*cdf0e10cSrcweir 								sal_uInt16 nPhyNum,
70*cdf0e10cSrcweir 								sal_uInt16 nVirtNum,
71*cdf0e10cSrcweir 								const String& rPg );
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 	static  QuickHelpData* pQuickHlpData;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	static	sal_Bool	bReplaceQuote;
76*cdf0e10cSrcweir 	static	long 	nDDStartPosX, nDDStartPosY;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 	static 	Color	aTextColor; 	//Textfarbe, fuer die Giesskanne
79*cdf0e10cSrcweir 	static 	sal_Bool	bTransparentBackColor; // Hintergrund transparent
80*cdf0e10cSrcweir 	static 	Color	aTextBackColor; //Texthintergrundfarbe, fuer die Giesskanne
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 	/*
83*cdf0e10cSrcweir 	 * Timer und Handler fuer das Weiterscrollen, wenn der
84*cdf0e10cSrcweir 	 * Mauspointer innerhalb eines Drag-Vorgangs ausserhalb des
85*cdf0e10cSrcweir 	 * EditWin stehen bleibt.  In regelmaessigen Intervallen wird
86*cdf0e10cSrcweir 	 * die Selektion in Richtung der Mausposition vergroessert.
87*cdf0e10cSrcweir 	 */
88*cdf0e10cSrcweir 	AutoTimer 		aTimer;
89*cdf0e10cSrcweir 	// Timer fuer verschachtelte KeyInputs (z.B. fuer Tabellen)
90*cdf0e10cSrcweir 	Timer 			aKeyInputTimer;
91*cdf0e10cSrcweir 	// timer for ANY-KeyInut question without a following KeyInputEvent
92*cdf0e10cSrcweir 	Timer 			aKeyInputFlushTimer;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	String			aInBuffer;
95*cdf0e10cSrcweir     LanguageType    eBufferLanguage;
96*cdf0e10cSrcweir 	Point			aStartPos;
97*cdf0e10cSrcweir 	Point			aMovePos;
98*cdf0e10cSrcweir 	Point			aRszMvHdlPt;
99*cdf0e10cSrcweir 	Timer 			aTemplateTimer;
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 	// Type/Objecte ueber dem der MousePointer steht
102*cdf0e10cSrcweir 	SwCallMouseEvent aSaveCallEvent;
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 	SwApplyTemplate 	*pApplyTempl;
105*cdf0e10cSrcweir 	SwAnchorMarker		*pAnchorMarker; // zum Verschieben eines Ankers
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 	SdrDropMarkerOverlay	*pUserMarker;
108*cdf0e10cSrcweir 	SdrObject				*pUserMarkerObj;
109*cdf0e10cSrcweir 	SwShadowCursor			*pShadCrsr;
110*cdf0e10cSrcweir     Point					*pRowColumnSelectionStart; // save position where table row/column selection has been started
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 	SwView		   &rView;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	int		 		aActHitType;	// aktueller Mauspointer
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     sal_uLong           m_nDropFormat;   //Format aus dem letzten QueryDrop
117*cdf0e10cSrcweir     sal_uInt16          m_nDropAction;   //Action aus dem letzten QueryDrop
118*cdf0e10cSrcweir     sal_uInt16          m_nDropDestination;  //Ziel aus dem letzten QueryDrop
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	sal_uInt16			eBezierMode;
121*cdf0e10cSrcweir 	sal_uInt16			nInsFrmColCount; //Spaltenzahl fuer interaktiven Rahmen
122*cdf0e10cSrcweir 	SdrObjKind		eDrawMode;
123*cdf0e10cSrcweir 	sal_Bool			bLinkRemoved	: 1,
124*cdf0e10cSrcweir 					bMBPressed		: 1,
125*cdf0e10cSrcweir 					bInsDraw 		: 1,
126*cdf0e10cSrcweir 					bInsFrm 		: 1,
127*cdf0e10cSrcweir 					bIsInMove		: 1,
128*cdf0e10cSrcweir 					bIsInDrag		: 1, //StartExecuteDrag nich doppelt ausfuehren
129*cdf0e10cSrcweir 					bOldIdle		: 1, //Zum abschalten des Idle'ns
130*cdf0e10cSrcweir 					bOldIdleSet		: 1, //waehrend QeueryDrop
131*cdf0e10cSrcweir 					bTblInsDelMode	: 1, //
132*cdf0e10cSrcweir 					bTblIsInsMode	: 1, //
133*cdf0e10cSrcweir 					bTblIsColMode	: 1, //
134*cdf0e10cSrcweir 					bChainMode		: 1, //Rahmen verbinden
135*cdf0e10cSrcweir 					bWasShdwCrsr	: 1, //ShadowCrsr war im MouseButtonDown an
136*cdf0e10cSrcweir                     bLockInput      : 1, //Lock waehrend die Rechenleiste aktiv ist
137*cdf0e10cSrcweir                     bIsRowDrag      : 1, //selection of rows is used, in combination with pRowColumnSelectionStart
138*cdf0e10cSrcweir                     /** #i42732# display status of font size/name depending on either the input language or the
139*cdf0e10cSrcweir                         selection position depending on what has changed lately
140*cdf0e10cSrcweir                      */
141*cdf0e10cSrcweir                     bUseInputLanguage: 1,
142*cdf0e10cSrcweir 					bObjectSelect	: 1;
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     sal_uInt16          nKS_NUMDOWN_Count; // #i23725#
146*cdf0e10cSrcweir     sal_uInt16          nKS_NUMINDENTINC_Count;
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	void			LeaveArea(const Point &);
149*cdf0e10cSrcweir 	void			JustifyAreaTimer();
150*cdf0e10cSrcweir 	inline void		EnterArea();
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 	void			RstMBDownFlags();
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	void			ChangeFly( sal_uInt8 nDir, sal_Bool bWeb = sal_False );
155*cdf0e10cSrcweir     void            ChangeDrawing( sal_uInt8 nDir );
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 	sal_Bool			EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos);
158*cdf0e10cSrcweir     sal_Bool            RulerColumnDrag( const MouseEvent& rMEvt, sal_Bool bVerticalMode);
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 	//Hilfsfunktionen fuer D&D
161*cdf0e10cSrcweir 	void			DropCleanup();
162*cdf0e10cSrcweir 	void			CleanupDropUserMarker();
163*cdf0e10cSrcweir 	sal_uInt16			GetDropDestination( const Point& rPixPnt,
164*cdf0e10cSrcweir 										SdrObject ** ppObj = 0 );
165*cdf0e10cSrcweir     //select the object/cursor at the mouse position of the context menu request
166*cdf0e10cSrcweir     sal_Bool            SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos );
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 	/*
169*cdf0e10cSrcweir 	 * Handler fuer das Weiterscrollen, wenn der Mauspointer innerhalb eines
170*cdf0e10cSrcweir 	 * Drag-Vorgangs ausserhalb des EditWin stehen bleibt. In regelmaessigen
171*cdf0e10cSrcweir 	 * Intervallen wird die Selektion in Richtung der Mausposition
172*cdf0e10cSrcweir 	 * vergroessert.
173*cdf0e10cSrcweir 	 */
174*cdf0e10cSrcweir 	DECL_LINK( TimerHandler, Timer * );
175*cdf0e10cSrcweir 	void			StartDDTimer();
176*cdf0e10cSrcweir 	void			StopDDTimer(SwWrtShell *, const Point &);
177*cdf0e10cSrcweir 	DECL_LINK( DDHandler, Timer * );
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 	// timer for ANY-KeyInut question without a following KeyInputEvent
180*cdf0e10cSrcweir 	DECL_LINK( KeyInputFlushHandler, Timer * );
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	// Timer fuer verschachtelte KeyInputs (z.B. fuer Tabellen)
183*cdf0e10cSrcweir 	DECL_LINK( KeyInputTimerHandler, Timer * );
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 	// Timer fuer das ApplyTemplates per Maus (verkapptes Drag&Drop)
186*cdf0e10cSrcweir 	DECL_LINK( TemplateTimerHdl, Timer* );
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     using OutputDevice::GetTextColor;
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir protected:
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir 	virtual void	DataChanged( const DataChangedEvent& );
193*cdf0e10cSrcweir 	virtual void	PrePaint();
194*cdf0e10cSrcweir 	virtual void	Paint( const Rectangle& rRect );
195*cdf0e10cSrcweir 	virtual void 	KeyInput(const KeyEvent &rKEvt);
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 	virtual void 	GetFocus();
198*cdf0e10cSrcweir 	virtual void 	LoseFocus();
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	virtual void 	MouseMove(const MouseEvent& rMEvt);
202*cdf0e10cSrcweir 	virtual void 	MouseButtonDown(const MouseEvent& rMEvt);
203*cdf0e10cSrcweir 	virtual void 	MouseButtonUp(const MouseEvent& rMEvt);
204*cdf0e10cSrcweir 	virtual void	RequestHelp(const HelpEvent& rEvt);
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 	virtual void	Command( const CommandEvent& rCEvt );
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 								// Drag & Drop Interface
209*cdf0e10cSrcweir 	virtual sal_Int8 	AcceptDrop( const AcceptDropEvent& rEvt );
210*cdf0e10cSrcweir 	virtual sal_Int8 	ExecuteDrop( const ExecuteDropEvent& rEvt );
211*cdf0e10cSrcweir 	virtual void		StartDrag( sal_Int8 nAction, const Point& rPosPixel );
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir     virtual XubString GetSurroundingText() const;
214*cdf0e10cSrcweir     virtual Selection GetSurroundingTextSelection() const;
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir     void    ShowAutoTextCorrectQuickHelp( const String& rWord, SvxAutoCorrCfg* pACfg,
217*cdf0e10cSrcweir                                 SvxAutoCorrect* pACorr, sal_Bool bFromIME = sal_False );
218*cdf0e10cSrcweir public:
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 	void			UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir 	sal_Bool			IsDrawSelMode();
223*cdf0e10cSrcweir 	sal_Bool			IsDrawAction() 					{ return (bInsDraw); }
224*cdf0e10cSrcweir 	void			SetDrawAction(sal_Bool bFlag) 		{ bInsDraw = bFlag; }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 	void			SetObjectSelect( sal_Bool bVal )	{ bObjectSelect = bVal; }
227*cdf0e10cSrcweir 	sal_Bool			IsObjectSelect() const			{ return bObjectSelect; }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 	inline SdrObjKind	GetSdrDrawMode(/*sal_Bool bBuf = sal_False*/) const { return eDrawMode; }
230*cdf0e10cSrcweir 	inline void			SetSdrDrawMode( SdrObjKind eSdrObjectKind )	{ eDrawMode = eSdrObjectKind; SetObjectSelect( sal_False ); }
231*cdf0e10cSrcweir 	void				StdDrawMode( SdrObjKind eSdrObjectKind, sal_Bool bObjSelect );
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 	sal_Bool			IsFrmAction() 					{ return (bInsFrm); }
234*cdf0e10cSrcweir 	inline sal_uInt16	GetBezierMode() 				{ return eBezierMode; }
235*cdf0e10cSrcweir 	void			SetBezierMode(sal_uInt16 eBezMode)	{ eBezierMode = eBezMode; }
236*cdf0e10cSrcweir 	void			EnterDrawTextMode(const Point& aDocPos); // DrawTextEditMode einschalten
237*cdf0e10cSrcweir 	void			InsFrm(sal_uInt16 nCols);
238*cdf0e10cSrcweir 	void 			StopInsFrm();
239*cdf0e10cSrcweir 	sal_uInt16			GetFrmColCount() const {return nInsFrmColCount;} //Spaltenzahl fuer interaktiven Rahmen
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 	void			SetChainMode( sal_Bool bOn );
243*cdf0e10cSrcweir 	sal_Bool			IsChainMode() const				{ return bChainMode; }
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir     void            FlushInBuffer();
246*cdf0e10cSrcweir     sal_Bool            IsInputSequenceCheckingRequired( const String &rText, const SwPaM& rCrsr ) const;
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 	static	void 	SetReplaceQuote(sal_Bool bOn = sal_True) { bReplaceQuote = bOn; }
250*cdf0e10cSrcweir 	static	sal_Bool 	IsReplaceQuote() { return bReplaceQuote; }
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	void 			 SetApplyTemplate(const SwApplyTemplate &);
253*cdf0e10cSrcweir 	SwApplyTemplate* GetApplyTemplate() const { return pApplyTempl; }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 	void			StartExecuteDrag();
256*cdf0e10cSrcweir 	void			DragFinished();
257*cdf0e10cSrcweir     sal_uInt16          GetDropAction() const { return m_nDropAction; }
258*cdf0e10cSrcweir     sal_uLong           GetDropFormat() const { return m_nDropFormat; }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir 	Color 			GetTextColor() { return aTextColor; }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 	void 			SetTextColor(const Color& rCol ) { aTextColor = rCol; }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir 	Color 			GetTextBackColor()
265*cdf0e10cSrcweir 											{ return aTextBackColor; }
266*cdf0e10cSrcweir 	void 			SetTextBackColor(const Color& rCol )
267*cdf0e10cSrcweir 											{ aTextBackColor = rCol; }
268*cdf0e10cSrcweir 	void			SetTextBackColorTransparent(sal_Bool bSet)
269*cdf0e10cSrcweir 									{ bTransparentBackColor = bSet; }
270*cdf0e10cSrcweir 	sal_Bool			IsTextBackColorTransparent()
271*cdf0e10cSrcweir 									{ return bTransparentBackColor; }
272*cdf0e10cSrcweir 	void			LockKeyInput(sal_Bool bSet){bLockInput = bSet;}
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir 	const SwView &GetView() const { return rView; }
275*cdf0e10cSrcweir 		  SwView &GetView() 	  { return rView; }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir 	// Tipfenster loeschen
280*cdf0e10cSrcweir 	static void ClearTip();
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir 	static inline long GetDDStartPosX() { return nDDStartPosX; }
283*cdf0e10cSrcweir 	static inline long GetDDStartPosY() { return nDDStartPosY; }
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir 	static void	_InitStaticData();
286*cdf0e10cSrcweir 	static void	_FinitStaticData();
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir     //#i3370# remove quick help to prevent saving of autocorrection suggestions
289*cdf0e10cSrcweir     void StopQuickHelp();
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir     // --> OD 2005-02-18 #i42921# - add parameter <bVerticalMode>
292*cdf0e10cSrcweir     sal_Bool RulerMarginDrag( const MouseEvent& rMEvt,
293*cdf0e10cSrcweir                                      const bool bVerticalMode );
294*cdf0e10cSrcweir     // <--
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir     /** #i42732# display status of font size/name depending on either the input
297*cdf0e10cSrcweir         language or the selection position depending on what has changed lately
298*cdf0e10cSrcweir      */
299*cdf0e10cSrcweir     void        SetUseInputLanguage( sal_Bool bNew );
300*cdf0e10cSrcweir     sal_Bool    IsUseInputLanguage() const { return bUseInputLanguage; }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir     SwEditWin(Window *pParent, SwView &);
303*cdf0e10cSrcweir 	virtual ~SwEditWin();
304*cdf0e10cSrcweir };
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir #endif
307*cdf0e10cSrcweir 
308