Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _EDTWIN_HXX
29 : : #define _EDTWIN_HXX
30 : :
31 : : #include <FrameControlsManager.hxx>
32 : :
33 : : #include <svx/svdobj.hxx>
34 : : #include <tools/link.hxx>
35 : : #include <vcl/timer.hxx>
36 : : #include <vcl/window.hxx>
37 : : #include <svtools/transfer.hxx>
38 : : #include <swevent.hxx>
39 : :
40 : :
41 : : class SwWrtShell;
42 : : class SwView;
43 : : class SwRect;
44 : : class ViewShell;
45 : : class SwAnchorMarker;
46 : : class SdrObject;
47 : : class SwShadowCursor;
48 : : class DataChangedEvent;
49 : : class SvxAutoCorrCfg;
50 : : class SvxAutoCorrect;
51 : : class SwPaM;
52 : : struct SwApplyTemplate;
53 : : struct QuickHelpData;
54 : : class SdrDropMarkerOverlay;
55 : :
56 : : /*--------------------------------------------------------------------
57 : : Description: input window
58 : : --------------------------------------------------------------------*/
59 : :
60 : : /** Window class for the Writer edit area, this is the one handling mouse
61 : : and keyboard events and doing the final painting of the document from
62 : : the buffered layout.
63 : :
64 : : To translate the pixel positions from the buffer OutputDevice to the real
65 : : pixel positions, use the PixelToLogic methods of this class.
66 : : */
67 : : class SwEditWin: public Window,
68 : : public DropTargetHelper, public DragSourceHelper
69 : : {
70 : : friend void ScrollMDI(ViewShell* pVwSh, const SwRect&,
71 : : sal_uInt16 nRangeX, sal_uInt16 nRangeY);
72 : : friend sal_Bool IsScrollMDI(ViewShell* pVwSh, const SwRect&);
73 : :
74 : : friend void SizeNotify(ViewShell* pVwSh, const Size &);
75 : :
76 : : friend void PageNumNotify( ViewShell* pVwSh,
77 : : sal_uInt16 nPhyNum,
78 : : sal_uInt16 nVirtNum,
79 : : const String& rPg );
80 : :
81 : : static QuickHelpData* pQuickHlpData;
82 : :
83 : : static sal_Bool bReplaceQuote;
84 : : static long nDDStartPosX, nDDStartPosY;
85 : :
86 : : static Color aTextColor; // text color; for the watering can
87 : : static sal_Bool bTransparentBackColor; // transparent background
88 : : static Color aTextBackColor; // text background; for the watering can
89 : :
90 : : /*
91 : : * timer and handler for scrolling on when the mousepointer
92 : : * stopps outside of EditWin during a drag-operation.
93 : : * The selection is increased towards the mouse position
94 : : * regularly.
95 : : */
96 : : AutoTimer aTimer;
97 : : // timer for overlapping KeyInputs (e.g. for tables)
98 : : Timer aKeyInputTimer;
99 : : // timer for ANY-KeyInut question without a following KeyInputEvent
100 : : Timer aKeyInputFlushTimer;
101 : :
102 : : String aInBuffer;
103 : : LanguageType eBufferLanguage;
104 : : Point aStartPos;
105 : : Point aMovePos;
106 : : Point aRszMvHdlPt;
107 : : Timer aTemplateTimer;
108 : :
109 : : // type/object where the mouse pointer is
110 : : SwCallMouseEvent aSaveCallEvent;
111 : :
112 : : SwApplyTemplate *pApplyTempl;
113 : : SwAnchorMarker *pAnchorMarker; // for relocating the anchor
114 : :
115 : : SdrDropMarkerOverlay *pUserMarker;
116 : : SdrObject *pUserMarkerObj;
117 : : SwShadowCursor *pShadCrsr;
118 : : Point *pRowColumnSelectionStart; // save position where table row/column selection has been started
119 : :
120 : : SwView &rView;
121 : :
122 : : int aActHitType; // current mouse pointer
123 : :
124 : : sal_uLong m_nDropFormat; // format from the last QueryDrop
125 : : sal_uInt16 m_nDropAction; // action from the last QueryDrop
126 : : sal_uInt16 m_nDropDestination; // destination from the last QueryDrop
127 : :
128 : : sal_uInt16 eBezierMode;
129 : : sal_uInt16 nInsFrmColCount; // column number for interactive frame
130 : : SdrObjKind eDrawMode;
131 : : sal_Bool bLinkRemoved : 1,
132 : : bMBPressed : 1,
133 : : bInsDraw : 1,
134 : : bInsFrm : 1,
135 : : bIsInMove : 1,
136 : : bIsInDrag : 1, // don't execute StartExecuteDrag twice
137 : : bOldIdle : 1, // to stop to idle
138 : : bOldIdleSet : 1, // during QeueryDrop
139 : : bTblInsDelMode : 1, //
140 : : bTblIsInsMode : 1, //
141 : : bTblIsColMode : 1, //
142 : : bChainMode : 1, // connect frames
143 : : bWasShdwCrsr : 1, // ShadowCrsr was on in MouseButtonDown
144 : : bLockInput : 1, // lock while calc panel is active
145 : : bIsRowDrag : 1, //selection of rows is used, in combination with pRowColumnSelectionStart
146 : : /** #i42732# display status of font size/name depending on either the input language or the
147 : : selection position depending on what has changed lately
148 : : */
149 : : bUseInputLanguage: 1,
150 : : bObjectSelect : 1;
151 : :
152 : : sal_uInt16 nKS_NUMDOWN_Count; // #i23725#
153 : : sal_uInt16 nKS_NUMINDENTINC_Count;
154 : :
155 : : SwFrameControlsManager m_aFrameControlsManager;
156 : : rtl::OUString m_sTmpHFPageStyle;
157 : : bool m_bTmpHFIsHeader;
158 : :
159 : : void LeaveArea(const Point &);
160 : : void JustifyAreaTimer();
161 : : inline void EnterArea();
162 : :
163 : : void RstMBDownFlags();
164 : :
165 : : void ChangeFly( sal_uInt8 nDir, sal_Bool bWeb = sal_False );
166 : : void ChangeDrawing( sal_uInt8 nDir );
167 : :
168 : : sal_Bool EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos);
169 : : sal_Bool RulerColumnDrag( const MouseEvent& rMEvt, sal_Bool bVerticalMode);
170 : :
171 : : // helper function for D&D
172 : : void DropCleanup();
173 : : void CleanupDropUserMarker();
174 : : sal_uInt16 GetDropDestination( const Point& rPixPnt,
175 : : SdrObject ** ppObj = 0 );
176 : : //select the object/cursor at the mouse position of the context menu request
177 : : sal_Bool SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos );
178 : :
179 : : /*
180 : : * handler for scrolling on when the mousepointer
181 : : * stopps outside of EditWin during a drag-operation.
182 : : * The selection is regularly increased towards the mouse
183 : : * position.
184 : : */
185 : : DECL_LINK( TimerHandler, void * );
186 : : void StartDDTimer();
187 : : void StopDDTimer(SwWrtShell *, const Point &);
188 : : DECL_LINK( DDHandler, void * );
189 : :
190 : : // timer for ANY-KeyInut question without a following KeyInputEvent
191 : : DECL_LINK( KeyInputFlushHandler, void * );
192 : :
193 : : // timer for overlapping KeyInputs (e.g. for tables)
194 : : DECL_LINK( KeyInputTimerHandler, void * );
195 : :
196 : : // timer for ApplyTemplates via mouse (in disguise Drag&Drop)
197 : : DECL_LINK( TemplateTimerHdl, void * );
198 : :
199 : : using OutputDevice::GetTextColor;
200 : :
201 : : protected:
202 : :
203 : : virtual void DataChanged( const DataChangedEvent& );
204 : : virtual void PrePaint();
205 : : virtual void Paint( const Rectangle& rRect );
206 : : virtual void KeyInput(const KeyEvent &rKEvt);
207 : :
208 : : virtual void GetFocus();
209 : : virtual void LoseFocus();
210 : :
211 : :
212 : : virtual void MouseMove(const MouseEvent& rMEvt);
213 : : virtual void MouseButtonDown(const MouseEvent& rMEvt);
214 : : virtual void MouseButtonUp(const MouseEvent& rMEvt);
215 : : virtual void RequestHelp(const HelpEvent& rEvt);
216 : :
217 : : virtual void Command( const CommandEvent& rCEvt );
218 : :
219 : : // Drag & Drop Interface
220 : : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
221 : : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
222 : : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
223 : :
224 : : virtual rtl::OUString GetSurroundingText() const;
225 : : virtual Selection GetSurroundingTextSelection() const;
226 : :
227 : : void ShowAutoTextCorrectQuickHelp( const String& rWord, SvxAutoCorrCfg* pACfg,
228 : : SvxAutoCorrect* pACorr, sal_Bool bFromIME = sal_False );
229 : :
230 : : /// Shows or hides the header & footer separators; only if there is a change.
231 : : void ShowHeaderFooterSeparator( bool bShowHeader, bool bShowFooter );
232 : :
233 : : /// Returns true if in header/footer area, or in the header/footer control.
234 : : bool IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const;
235 : : public:
236 : :
237 : : void UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
238 : :
239 : : sal_Bool IsDrawSelMode();
240 : 0 : sal_Bool IsDrawAction() { return (bInsDraw); }
241 : 0 : void SetDrawAction(sal_Bool bFlag) { bInsDraw = bFlag; }
242 : :
243 : 0 : void SetObjectSelect( sal_Bool bVal ) { bObjectSelect = bVal; }
244 : 0 : sal_Bool IsObjectSelect() const { return bObjectSelect; }
245 : :
246 : 0 : inline SdrObjKind GetSdrDrawMode(/*sal_Bool bBuf = sal_False*/) const { return eDrawMode; }
247 : 0 : inline void SetSdrDrawMode( SdrObjKind eSdrObjectKind ) { eDrawMode = eSdrObjectKind; SetObjectSelect( sal_False ); }
248 : : void StdDrawMode( SdrObjKind eSdrObjectKind, sal_Bool bObjSelect );
249 : :
250 : 24271 : sal_Bool IsFrmAction() { return (bInsFrm); }
251 : 0 : inline sal_uInt16 GetBezierMode() { return eBezierMode; }
252 : 0 : void SetBezierMode(sal_uInt16 eBezMode) { eBezierMode = eBezMode; }
253 : : void EnterDrawTextMode(const Point& aDocPos); // turn on DrawTextEditMode
254 : : void InsFrm(sal_uInt16 nCols);
255 : : void StopInsFrm();
256 : 0 : sal_uInt16 GetFrmColCount() const {return nInsFrmColCount;} // column number for interactive frame
257 : :
258 : :
259 : : void SetChainMode( sal_Bool bOn );
260 : 20688 : sal_Bool IsChainMode() const { return bChainMode; }
261 : :
262 : : void FlushInBuffer();
263 : : sal_Bool IsInputSequenceCheckingRequired( const String &rText, const SwPaM& rCrsr ) const;
264 : :
265 : :
266 : : static void SetReplaceQuote(sal_Bool bOn = sal_True) { bReplaceQuote = bOn; }
267 : : static sal_Bool IsReplaceQuote() { return bReplaceQuote; }
268 : :
269 : : void SetApplyTemplate(const SwApplyTemplate &);
270 : 3534 : SwApplyTemplate* GetApplyTemplate() const { return pApplyTempl; }
271 : :
272 : : void StartExecuteDrag();
273 : : void DragFinished();
274 : : sal_uInt16 GetDropAction() const { return m_nDropAction; }
275 : : sal_uLong GetDropFormat() const { return m_nDropFormat; }
276 : :
277 : 1343 : Color GetTextColor() { return aTextColor; }
278 : :
279 : 0 : void SetTextColor(const Color& rCol ) { aTextColor = rCol; }
280 : :
281 : 1343 : Color GetTextBackColor()
282 : 1343 : { return aTextBackColor; }
283 : 0 : void SetTextBackColor(const Color& rCol )
284 : 0 : { aTextBackColor = rCol; }
285 : 0 : void SetTextBackColorTransparent(sal_Bool bSet)
286 : 0 : { bTransparentBackColor = bSet; }
287 : 1343 : sal_Bool IsTextBackColorTransparent()
288 : 1343 : { return bTransparentBackColor; }
289 : 0 : void LockKeyInput(sal_Bool bSet){bLockInput = bSet;}
290 : :
291 : : const SwView &GetView() const { return rView; }
292 : 31394 : SwView &GetView() { return rView; }
293 : :
294 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
295 : :
296 : 0 : static inline long GetDDStartPosX() { return nDDStartPosX; }
297 : 0 : static inline long GetDDStartPosY() { return nDDStartPosY; }
298 : :
299 : : static void _InitStaticData();
300 : : static void _FinitStaticData();
301 : :
302 : : //#i3370# remove quick help to prevent saving of autocorrection suggestions
303 : : void StopQuickHelp();
304 : :
305 : : // #i42921# - add parameter <bVerticalMode>
306 : : sal_Bool RulerMarginDrag( const MouseEvent& rMEvt,
307 : : const bool bVerticalMode );
308 : :
309 : : /** #i42732# display status of font size/name depending on either the input
310 : : language or the selection position depending on what has changed lately
311 : : */
312 : : void SetUseInputLanguage( sal_Bool bNew );
313 : 4327 : sal_Bool IsUseInputLanguage() const { return bUseInputLanguage; }
314 : :
315 : 25637 : SwFrameControlsManager& GetFrameControlsManager() { return m_aFrameControlsManager; }
316 : :
317 : : SwEditWin(Window *pParent, SwView &);
318 : : virtual ~SwEditWin();
319 : : };
320 : :
321 : : #endif
322 : :
323 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|