bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / inc / edtwin.hxx
blob99cbf594a81f905d70c2b04cf1c0a67104efa45d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _EDTWIN_HXX
20 #define _EDTWIN_HXX
22 #include <FrameControlsManager.hxx>
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>
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;
47 /*--------------------------------------------------------------------
48 Description: input window
49 --------------------------------------------------------------------*/
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.
55 To translate the pixel positions from the buffer OutputDevice to the real
56 pixel positions, use the PixelToLogic methods of this class.
58 class SwEditWin: public Window,
59 public DropTargetHelper, public DragSourceHelper
61 friend void ScrollMDI(ViewShell* pVwSh, const SwRect&,
62 sal_uInt16 nRangeX, sal_uInt16 nRangeY);
63 friend sal_Bool IsScrollMDI(ViewShell* pVwSh, const SwRect&);
65 friend void SizeNotify(ViewShell* pVwSh, const Size &);
67 friend void PageNumNotify( ViewShell* pVwSh,
68 sal_uInt16 nPhyNum,
69 sal_uInt16 nVirtNum,
70 const String& rPg );
72 static QuickHelpData* m_pQuickHlpData;
74 static long m_nDDStartPosX, m_nDDStartPosY;
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
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.
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;
92 String m_aInBuffer;
93 LanguageType m_eBufferLanguage;
94 Point m_aStartPos;
95 Point m_aMovePos;
96 Point m_aRszMvHdlPt;
97 Timer m_aTemplateTimer;
99 // type/object where the mouse pointer is
100 SwCallMouseEvent m_aSaveCallEvent;
102 SwApplyTemplate *m_pApplyTempl;
103 SwAnchorMarker *m_pAnchorMarker; // for relocating the anchor
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
110 SwView &m_rView;
112 int m_aActHitType; // current mouse pointer
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
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
137 m_bUseInputLanguage: 1,
138 m_bObjectSelect : 1;
140 sal_uInt16 m_nKS_NUMDOWN_Count; // #i23725#
141 sal_uInt16 m_nKS_NUMINDENTINC_Count;
143 SwFrameControlsManager m_aFrameControlsManager;
145 void LeaveArea(const Point &);
146 void JustifyAreaTimer();
147 inline void EnterArea();
149 void RstMBDownFlags();
151 void ChangeFly( sal_uInt8 nDir, sal_Bool bWeb = sal_False );
152 void ChangeDrawing( sal_uInt8 nDir );
154 sal_Bool EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos);
155 sal_Bool RulerColumnDrag( const MouseEvent& rMEvt, sal_Bool bVerticalMode);
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 );
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.
171 DECL_LINK( TimerHandler, void * );
172 void StartDDTimer();
173 void StopDDTimer(SwWrtShell *, const Point &);
174 DECL_LINK( DDHandler, void * );
176 // timer for ANY-KeyInut question without a following KeyInputEvent
177 DECL_LINK( KeyInputFlushHandler, void * );
179 // timer for overlapping KeyInputs (e.g. for tables)
180 DECL_LINK( KeyInputTimerHandler, void * );
182 // timer for ApplyTemplates via mouse (in disguise Drag&Drop)
183 DECL_LINK( TemplateTimerHdl, void * );
185 using OutputDevice::GetTextColor;
187 protected:
189 virtual void DataChanged( const DataChangedEvent& );
190 virtual void PrePaint();
191 virtual void Paint( const Rectangle& rRect );
192 virtual void KeyInput(const KeyEvent &rKEvt);
194 virtual void GetFocus();
195 virtual void LoseFocus();
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);
203 virtual void Command( const CommandEvent& rCEvt );
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 );
210 virtual OUString GetSurroundingText() const;
211 virtual Selection GetSurroundingTextSelection() const;
213 void ShowAutoTextCorrectQuickHelp( const String& rWord, SvxAutoCorrCfg* pACfg,
214 SvxAutoCorrect* pACorr, bool bFromIME = false );
216 /// Returns true if in header/footer area, or in the header/footer control.
217 bool IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const;
219 bool IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const;
220 public:
222 void UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
224 sal_Bool IsDrawSelMode();
225 sal_Bool IsDrawAction() { return (m_bInsDraw); }
226 void SetDrawAction(sal_Bool bFlag) { m_bInsDraw = bFlag; }
228 void SetObjectSelect( sal_Bool bVal ) { m_bObjectSelect = bVal; }
229 sal_Bool IsObjectSelect() const { return m_bObjectSelect; }
231 inline SdrObjKind GetSdrDrawMode(/*sal_Bool bBuf = sal_False*/) const { return m_eDrawMode; }
232 inline void SetSdrDrawMode( SdrObjKind eSdrObjectKind ) { m_eDrawMode = eSdrObjectKind; SetObjectSelect( sal_False ); }
233 void StdDrawMode( SdrObjKind eSdrObjectKind, sal_Bool bObjSelect );
235 sal_Bool IsFrmAction() { return (m_bInsFrm); }
236 inline sal_uInt16 GetBezierMode() { return m_eBezierMode; }
237 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 sal_uInt16 GetFrmColCount() const {return m_nInsFrmColCount;} // column number for interactive frame
244 void SetChainMode( sal_Bool bOn );
245 sal_Bool IsChainMode() const { return m_bChainMode; }
247 void FlushInBuffer();
248 sal_Bool IsInputSequenceCheckingRequired( const String &rText, const SwPaM& rCrsr ) const;
250 void SetApplyTemplate(const SwApplyTemplate &);
251 SwApplyTemplate* GetApplyTemplate() const { return m_pApplyTempl; }
253 void StartExecuteDrag();
254 void DragFinished();
255 sal_uInt16 GetDropAction() const { return m_nDropAction; }
256 sal_uLong GetDropFormat() const { return m_nDropFormat; }
258 Color GetTextColor() { return m_aTextColor; }
260 void SetTextColor(const Color& rCol ) { m_aTextColor = rCol; }
262 Color GetTextBackColor()
263 { return m_aTextBackColor; }
264 void SetTextBackColor(const Color& rCol )
265 { m_aTextBackColor = rCol; }
266 void SetTextBackColorTransparent(bool bSet)
267 { m_bTransparentBackColor = bSet; }
268 bool IsTextBackColorTransparent()
269 { return m_bTransparentBackColor; }
270 void LockKeyInput(sal_Bool bSet){m_bLockInput = bSet;}
272 const SwView &GetView() const { return m_rView; }
273 SwView &GetView() { return m_rView; }
275 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
277 static inline long GetDDStartPosX() { return m_nDDStartPosX; }
278 static inline long GetDDStartPosY() { return m_nDDStartPosY; }
280 static void _InitStaticData();
281 static void _FinitStaticData();
283 //#i3370# remove quick help to prevent saving of autocorrection suggestions
284 void StopQuickHelp();
286 // #i42921# - add parameter <bVerticalMode>
287 sal_Bool RulerMarginDrag( const MouseEvent& rMEvt,
288 const bool bVerticalMode );
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
293 void SetUseInputLanguage( sal_Bool bNew );
294 sal_Bool IsUseInputLanguage() const { return m_bUseInputLanguage; }
296 SwFrameControlsManager& GetFrameControlsManager() { return m_aFrameControlsManager; }
298 SwEditWin(Window *pParent, SwView &);
299 virtual ~SwEditWin();
302 #endif
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */