Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef _EDTWIN_HXX
20 : #define _EDTWIN_HXX
21 :
22 : #include <FrameControlsManager.hxx>
23 :
24 : #include <svx/svdobj.hxx>
25 : #include <tools/link.hxx>
26 : #include <vcl/timer.hxx>
27 : #include <vcl/window.hxx>
28 : #include <svtools/transfer.hxx>
29 : #include <swevent.hxx>
30 :
31 :
32 : class SwWrtShell;
33 : class SwView;
34 : class SwRect;
35 : class ViewShell;
36 : class SwAnchorMarker;
37 : class SdrObject;
38 : class SwShadowCursor;
39 : class DataChangedEvent;
40 : class SvxAutoCorrCfg;
41 : class SvxAutoCorrect;
42 : class SwPaM;
43 : struct SwApplyTemplate;
44 : struct QuickHelpData;
45 : class SdrDropMarkerOverlay;
46 :
47 : /*--------------------------------------------------------------------
48 : Description: input window
49 : --------------------------------------------------------------------*/
50 :
51 : /** Window class for the Writer edit area, this is the one handling mouse
52 : and keyboard events and doing the final painting of the document from
53 : the buffered layout.
54 :
55 : To translate the pixel positions from the buffer OutputDevice to the real
56 : pixel positions, use the PixelToLogic methods of this class.
57 : */
58 : class SwEditWin: public Window,
59 : public DropTargetHelper, public DragSourceHelper
60 : {
61 : friend void ScrollMDI(ViewShell* pVwSh, const SwRect&,
62 : sal_uInt16 nRangeX, sal_uInt16 nRangeY);
63 : friend sal_Bool IsScrollMDI(ViewShell* pVwSh, const SwRect&);
64 :
65 : friend void SizeNotify(ViewShell* pVwSh, const Size &);
66 :
67 : friend void PageNumNotify( ViewShell* pVwSh,
68 : sal_uInt16 nPhyNum,
69 : sal_uInt16 nVirtNum,
70 : const String& rPg );
71 :
72 : static QuickHelpData* m_pQuickHlpData;
73 :
74 : static long m_nDDStartPosX, m_nDDStartPosY;
75 :
76 : static Color m_aTextColor; // text color; for the watering can
77 : static bool m_bTransparentBackColor; // transparent background
78 : static Color m_aTextBackColor; // text background; for the watering can
79 :
80 : /*
81 : * timer and handler for scrolling on when the mousepointer
82 : * stopps outside of EditWin during a drag-operation.
83 : * The selection is increased towards the mouse position
84 : * regularly.
85 : */
86 : AutoTimer m_aTimer;
87 : // timer for overlapping KeyInputs (e.g. for tables)
88 : Timer m_aKeyInputTimer;
89 : // timer for ANY-KeyInut question without a following KeyInputEvent
90 : Timer m_aKeyInputFlushTimer;
91 :
92 : String m_aInBuffer;
93 : LanguageType m_eBufferLanguage;
94 : Point m_aStartPos;
95 : Point m_aMovePos;
96 : Point m_aRszMvHdlPt;
97 : Timer m_aTemplateTimer;
98 :
99 : // type/object where the mouse pointer is
100 : SwCallMouseEvent m_aSaveCallEvent;
101 :
102 : SwApplyTemplate *m_pApplyTempl;
103 : SwAnchorMarker *m_pAnchorMarker; // for relocating the anchor
104 :
105 : SdrDropMarkerOverlay *m_pUserMarker;
106 : SdrObject *m_pUserMarkerObj;
107 : SwShadowCursor *m_pShadCrsr;
108 : Point *m_pRowColumnSelectionStart; // save position where table row/column selection has been started
109 :
110 : SwView &m_rView;
111 :
112 : int m_aActHitType; // current mouse pointer
113 :
114 : sal_uLong m_nDropFormat; // format from the last QueryDrop
115 : sal_uInt16 m_nDropAction; // action from the last QueryDrop
116 : sal_uInt16 m_nDropDestination; // destination from the last QueryDrop
117 :
118 : sal_uInt16 m_eBezierMode;
119 : sal_uInt16 m_nInsFrmColCount; // column number for interactive frame
120 : SdrObjKind m_eDrawMode;
121 : sal_Bool m_bMBPressed : 1,
122 : m_bInsDraw : 1,
123 : m_bInsFrm : 1,
124 : m_bIsInMove : 1,
125 : m_bIsInDrag : 1, // don't execute StartExecuteDrag twice
126 : m_bOldIdle : 1, // to stop to idle
127 : m_bOldIdleSet : 1, // during QeueryDrop
128 : m_bTblInsDelMode : 1, //
129 : m_bTblIsInsMode : 1, //
130 : m_bChainMode : 1, // connect frames
131 : m_bWasShdwCrsr : 1, // ShadowCrsr was on in MouseButtonDown
132 : m_bLockInput : 1, // lock while calc panel is active
133 : m_bIsRowDrag : 1, //selection of rows is used, in combination with m_pRowColumnSelectionStart
134 : /** #i42732# display status of font size/name depending on either the input language or the
135 : selection position depending on what has changed lately
136 : */
137 : m_bUseInputLanguage: 1,
138 : m_bObjectSelect : 1;
139 :
140 : sal_uInt16 m_nKS_NUMDOWN_Count; // #i23725#
141 : sal_uInt16 m_nKS_NUMINDENTINC_Count;
142 :
143 : SwFrameControlsManager m_aFrameControlsManager;
144 :
145 : void LeaveArea(const Point &);
146 : void JustifyAreaTimer();
147 : inline void EnterArea();
148 :
149 : void RstMBDownFlags();
150 :
151 : void ChangeFly( sal_uInt8 nDir, sal_Bool bWeb = sal_False );
152 : void ChangeDrawing( sal_uInt8 nDir );
153 :
154 : sal_Bool EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos);
155 : sal_Bool RulerColumnDrag( const MouseEvent& rMEvt, sal_Bool bVerticalMode);
156 :
157 : // helper function for D&D
158 : void DropCleanup();
159 : void CleanupDropUserMarker();
160 : sal_uInt16 GetDropDestination( const Point& rPixPnt,
161 : SdrObject ** ppObj = 0 );
162 : //select the object/cursor at the mouse position of the context menu request
163 : sal_Bool SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos );
164 :
165 : /*
166 : * handler for scrolling on when the mousepointer
167 : * stopps outside of EditWin during a drag-operation.
168 : * The selection is regularly increased towards the mouse
169 : * position.
170 : */
171 : DECL_LINK( TimerHandler, void * );
172 : void StartDDTimer();
173 : void StopDDTimer(SwWrtShell *, const Point &);
174 : DECL_LINK( DDHandler, void * );
175 :
176 : // timer for ANY-KeyInut question without a following KeyInputEvent
177 : DECL_LINK( KeyInputFlushHandler, void * );
178 :
179 : // timer for overlapping KeyInputs (e.g. for tables)
180 : DECL_LINK( KeyInputTimerHandler, void * );
181 :
182 : // timer for ApplyTemplates via mouse (in disguise Drag&Drop)
183 : DECL_LINK( TemplateTimerHdl, void * );
184 :
185 : using OutputDevice::GetTextColor;
186 :
187 : protected:
188 :
189 : virtual void DataChanged( const DataChangedEvent& );
190 : virtual void PrePaint();
191 : virtual void Paint( const Rectangle& rRect );
192 : virtual void KeyInput(const KeyEvent &rKEvt);
193 :
194 : virtual void GetFocus();
195 : virtual void LoseFocus();
196 :
197 :
198 : virtual void MouseMove(const MouseEvent& rMEvt);
199 : virtual void MouseButtonDown(const MouseEvent& rMEvt);
200 : virtual void MouseButtonUp(const MouseEvent& rMEvt);
201 : virtual void RequestHelp(const HelpEvent& rEvt);
202 :
203 : virtual void Command( const CommandEvent& rCEvt );
204 :
205 : // Drag & Drop Interface
206 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
207 : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
208 : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
209 :
210 : virtual OUString GetSurroundingText() const;
211 : virtual Selection GetSurroundingTextSelection() const;
212 :
213 : void ShowAutoTextCorrectQuickHelp( const String& rWord, SvxAutoCorrCfg* pACfg,
214 : SvxAutoCorrect* pACorr, bool bFromIME = false );
215 :
216 : /// Returns true if in header/footer area, or in the header/footer control.
217 : bool IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const;
218 :
219 : bool IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const;
220 : public:
221 :
222 : void UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
223 :
224 : sal_Bool IsDrawSelMode();
225 0 : sal_Bool IsDrawAction() { return (m_bInsDraw); }
226 0 : void SetDrawAction(sal_Bool bFlag) { m_bInsDraw = bFlag; }
227 :
228 0 : void SetObjectSelect( sal_Bool bVal ) { m_bObjectSelect = bVal; }
229 0 : sal_Bool IsObjectSelect() const { return m_bObjectSelect; }
230 :
231 0 : inline SdrObjKind GetSdrDrawMode(/*sal_Bool bBuf = sal_False*/) const { return m_eDrawMode; }
232 0 : inline void SetSdrDrawMode( SdrObjKind eSdrObjectKind ) { m_eDrawMode = eSdrObjectKind; SetObjectSelect( sal_False ); }
233 : void StdDrawMode( SdrObjKind eSdrObjectKind, sal_Bool bObjSelect );
234 :
235 12415 : sal_Bool IsFrmAction() { return (m_bInsFrm); }
236 0 : inline sal_uInt16 GetBezierMode() { return m_eBezierMode; }
237 0 : void SetBezierMode(sal_uInt16 eBezMode) { m_eBezierMode = eBezMode; }
238 : void EnterDrawTextMode(const Point& aDocPos); // turn on DrawTextEditMode
239 : void InsFrm(sal_uInt16 nCols);
240 : void StopInsFrm();
241 0 : sal_uInt16 GetFrmColCount() const {return m_nInsFrmColCount;} // column number for interactive frame
242 :
243 :
244 : void SetChainMode( sal_Bool bOn );
245 10709 : sal_Bool IsChainMode() const { return m_bChainMode; }
246 :
247 : void FlushInBuffer();
248 : sal_Bool IsInputSequenceCheckingRequired( const String &rText, const SwPaM& rCrsr ) const;
249 :
250 : void SetApplyTemplate(const SwApplyTemplate &);
251 1673 : SwApplyTemplate* GetApplyTemplate() const { return m_pApplyTempl; }
252 :
253 : void StartExecuteDrag();
254 : void DragFinished();
255 : sal_uInt16 GetDropAction() const { return m_nDropAction; }
256 : sal_uLong GetDropFormat() const { return m_nDropFormat; }
257 :
258 630 : Color GetTextColor() { return m_aTextColor; }
259 :
260 0 : void SetTextColor(const Color& rCol ) { m_aTextColor = rCol; }
261 :
262 630 : Color GetTextBackColor()
263 630 : { return m_aTextBackColor; }
264 0 : void SetTextBackColor(const Color& rCol )
265 0 : { m_aTextBackColor = rCol; }
266 0 : void SetTextBackColorTransparent(bool bSet)
267 0 : { m_bTransparentBackColor = bSet; }
268 630 : bool IsTextBackColorTransparent()
269 630 : { return m_bTransparentBackColor; }
270 0 : void LockKeyInput(sal_Bool bSet){m_bLockInput = bSet;}
271 :
272 : const SwView &GetView() const { return m_rView; }
273 14039 : SwView &GetView() { return m_rView; }
274 :
275 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
276 :
277 0 : static inline long GetDDStartPosX() { return m_nDDStartPosX; }
278 0 : static inline long GetDDStartPosY() { return m_nDDStartPosY; }
279 :
280 : static void _InitStaticData();
281 : static void _FinitStaticData();
282 :
283 : //#i3370# remove quick help to prevent saving of autocorrection suggestions
284 : void StopQuickHelp();
285 :
286 : // #i42921# - add parameter <bVerticalMode>
287 : sal_Bool RulerMarginDrag( const MouseEvent& rMEvt,
288 : const bool bVerticalMode );
289 :
290 : /** #i42732# display status of font size/name depending on either the input
291 : language or the selection position depending on what has changed lately
292 : */
293 : void SetUseInputLanguage( sal_Bool bNew );
294 2096 : sal_Bool IsUseInputLanguage() const { return m_bUseInputLanguage; }
295 :
296 12068 : SwFrameControlsManager& GetFrameControlsManager() { return m_aFrameControlsManager; }
297 :
298 : SwEditWin(Window *pParent, SwView &);
299 : virtual ~SwEditWin();
300 : };
301 :
302 : #endif
303 :
304 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|