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