LibreOffice Module editeng (master) 1
editview.hxx
Go to the documentation of this file.
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// MyEDITVIEW, due to exported EditView
20#ifndef INCLUDED_EDITENG_EDITVIEW_HXX
21#define INCLUDED_EDITENG_EDITVIEW_HXX
22
23#include <memory>
24#include <com/sun/star/i18n/WordType.hpp>
25
26#include <i18nlangtag/lang.h>
27#include <tools/color.hxx>
28#include <tools/gen.hxx>
30#include <vcl/vclptr.hxx>
31#include <editeng/editstat.hxx>
32#include <editeng/flditem.hxx>
34#include <editeng/editdata.hxx>
35#include <com/sun/star/uno/Reference.h>
37
38
39class EditTextObject;
40class EditEngine;
41class ImpEditEngine;
42class ImpEditView;
44class SvxSearchItem;
45class SvxFieldItem;
46namespace vcl { class Window; }
47namespace weld { class Widget; }
48class KeyEvent;
49class MouseEvent;
50class CommandEvent;
51class SvStream;
53class SfxStyleSheet;
54class SfxItemSet;
55namespace vcl { class Cursor; }
56namespace vcl { class Font; }
57class FontList;
58class InputContext;
59class OutputDevice;
60enum class TransliterationFlags;
61enum class PointerStyle;
62
63namespace com {
64namespace sun {
65namespace star {
66namespace datatransfer {
67 class XTransferable;
68 namespace clipboard {
69 class XClipboard;
70 }
71 namespace dnd {
72 class XDropTarget;
73 }
74}
75namespace linguistic2 {
76 class XSpellChecker1;
77 class XLanguageGuessing;
78}
79}}}
80
81template <typename Arg, typename Ret> class Link;
82
84{
85 NoNegative = 1, // No negative VisArea when scrolling
86 PaperWidthTextSize = 2, // VisArea must be within paper width, Text Size
87};
88
89enum class LOKSpecialFlags {
90 NONE = 0x0000,
91 LayoutRTL = 0x0001,
92};
93
94namespace o3tl
95{
96 template<> struct typed_flags<LOKSpecialFlags> : is_typed_flags<LOKSpecialFlags, 0x77> {};
97}
98
99// Helper class that allows to set a callback at the EditView. When
100// set, Invalidates and repaints are suppressed at the EditView, but
101// EditViewInvalidate() will be triggered to allow the consumer to
102// react itself as needed.
103// Also Selection visualization is suppressed and EditViewSelectionChange
104// is triggered when Selection changes and needs reaction.
106{
107public:
108 virtual ~EditViewCallbacks();
109
110 // call this when text visualization changed in any way. It
111 // will also update selection, so no need to call this self
112 // additionally (but will also do no harm)
113 virtual void EditViewInvalidate(const tools::Rectangle& rRect) = 0;
114
115 // call this when only selection is changed. Text change will
116 // then *not* be checked and not be reacted on. Still, when
117 // only the selection is changed, this is useful and faster
118 virtual void EditViewSelectionChange() = 0;
119
120 // return the OutputDevice that the EditView will draw to
121 virtual OutputDevice& EditViewOutputDevice() const = 0;
122
124 {
125 return nullptr;
126 }
127
128 // return the Mouse Position
129 virtual Point EditViewPointerPosPixel() const = 0;
130
131 // Triggered to update InputEngine context information
132 virtual void EditViewInputContext(const InputContext& rInputContext) = 0;
133
134 // Triggered to update InputEngine cursor position
135 virtual void EditViewCursorRect(const tools::Rectangle& rRect, int nExtTextInputWidth) = 0;
136
137 // Triggered if scroll bar state should change
139 {
140 }
141
142 // Access to clipboard
143 virtual css::uno::Reference<css::datatransfer::clipboard::XClipboard> GetClipboard() const = 0;
144
145 // implemented if drag and drop support is wanted
146 virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> GetDropTarget()
147 {
148 return nullptr;
149 }
150};
151
153{
154 friend class EditEngine;
155 friend class ImpEditEngine;
156 friend class EditSelFunctionSet;
157
158public:
159 typedef std::vector<VclPtr<vcl::Window>> OutWindowSet;
160
161public: // Needed for Undo
162 ImpEditView* GetImpEditView() const { return pImpEditView.get(); }
163 ImpEditEngine* GetImpEditEngine() const;
164
165private:
166 std::unique_ptr<ImpEditView>
169
170 EditView( const EditView& ) = delete;
171 EditView& operator=( const EditView& ) = delete;
172
173 // counts how many characters take unfolded fields
174 // bCanOverflow - count field length without trim to the selected pos
175 sal_Int32 countFieldsOffsetSum(sal_Int32 nPara, sal_Int32 nPo, bool bCanOverflow) const;
176
177public:
178 EditView( EditEngine* pEng, vcl::Window* pWindow );
179 ~EditView();
180
181 // set EditViewCallbacks for external handling of Repaints/Visualization
182 void setEditViewCallbacks(EditViewCallbacks* pEditViewCallbacks);
183 EditViewCallbacks* getEditViewCallbacks() const;
184
185 void SetEditEngine( EditEngine* pEditEngine );
186 EditEngine* GetEditEngine() const;
187
188 void SetWindow( vcl::Window* pWin );
189 vcl::Window* GetWindow() const;
190 OutputDevice& GetOutputDevice() const;
191
192 LanguageType GetInputLanguage() const;
193
194 bool HasOtherViewWindow( vcl::Window* pWin );
195 bool AddOtherViewWindow( vcl::Window* pWin );
196 bool RemoveOtherViewWindow( vcl::Window* pWin );
197
198 void Paint( const tools::Rectangle& rRect, OutputDevice* pTargetDevice = nullptr );
199 tools::Rectangle GetInvalidateRect() const;
200 void InvalidateWindow(const tools::Rectangle& rClipRect);
201 void InvalidateOtherViewWindows( const tools::Rectangle& rInvRect );
202 void Invalidate();
203 ::Pair Scroll( tools::Long nHorzScroll, tools::Long nVertScroll, ScrollRangeCheck nRangeCheck = ScrollRangeCheck::NoNegative );
204
205 void SetBroadcastLOKViewCursor(bool bSet);
206 tools::Rectangle GetEditCursor() const;
207 void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true, bool bActivate = false );
208 void HideCursor( bool bDeactivate = false );
209
210 void SetSelectionMode( EESelectionMode eMode );
211
212 void SetReadOnly( bool bReadOnly );
213 bool IsReadOnly() const;
214
215 bool HasSelection() const;
216 ESelection GetSelection() const;
217 void SetSelection( const ESelection& rNewSel );
218 bool IsSelectionAtPoint(const Point& rPointPixel);
219 void SelectCurrentWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
221 void GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects) const;
222
223 bool IsInsertMode() const;
224 void SetInsertMode( bool bInsert );
225
226 OUString GetSelected() const;
227 void DeleteSelected();
228
229 SvtScriptType GetSelectedScriptType() const;
230
231 // VisArea position of the Output window.
232 // A size change also affects the VisArea
233 void SetOutputArea( const tools::Rectangle& rRect );
234 const tools::Rectangle& GetOutputArea() const;
235
236 // Document position.
237 // A size change also affects the VisArea
238 void SetVisArea( const tools::Rectangle& rRect );
239 tools::Rectangle GetVisArea() const;
240
241 PointerStyle GetPointer() const;
242
243 vcl::Cursor* GetCursor() const;
244
245 void InsertText( const OUString& rNew, bool bSelect = false , bool bLOKShowSelect = true);
246 void InsertParaBreak();
247
248 bool PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * pFrameWin = nullptr );
249
250 bool MouseButtonUp( const MouseEvent& rMouseEvent );
251 bool MouseButtonDown( const MouseEvent& rMouseEvent );
252 void ReleaseMouse();
253 bool MouseMove( const MouseEvent& rMouseEvent );
254 bool Command(const CommandEvent& rCEvt);
255
256 void Cut();
257 void Copy();
258 void Paste();
259 void PasteSpecial();
260
261 void Undo();
262 void Redo();
263
264 // especially for Oliver Specht
265 Point GetWindowPosTopLeft( sal_Int32 nParagraph );
266 void MoveParagraphs( Range aParagraphs, sal_Int32 nNewPos );
267 void MoveParagraphs( tools::Long nDiff );
268
269 const SfxItemSet& GetEmptyItemSet() const;
270 SfxItemSet GetAttribs();
271 void SetAttribs( const SfxItemSet& rSet );
272 void RemoveAttribs( bool bRemoveParaAttribs = false, sal_uInt16 nWhich = 0 );
273 void RemoveAttribs( EERemoveParaAttribsMode eMode, sal_uInt16 nWhich );
274 void RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich );
275 void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs );
276
277 ErrCode Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs );
278
279 void SetBackgroundColor( const Color& rColor );
280 Color const & GetBackgroundColor() const;
281
283 void RegisterViewShell(OutlinerViewShell* pViewShell);
285 void RegisterOtherShell(OutlinerViewShell* pOtherShell);
286
287 void SetControlWord( EVControlBits nWord );
288 EVControlBits GetControlWord() const;
289
290 std::unique_ptr<EditTextObject> CreateTextObject();
291 void InsertText( const EditTextObject& rTextObject );
292 void InsertText( css::uno::Reference< css::datatransfer::XTransferable > const & xDataObj, const OUString& rBaseURL, bool bUseSpecial );
293
294 css::uno::Reference<css::datatransfer::clipboard::XClipboard> GetClipboard() const;
295 css::uno::Reference<css::datatransfer::XTransferable> GetTransferable() const;
296
297 // An EditView, so that when TRUE the update will be free from flickering:
298 // @return the previous bUpdateLayout state
299 bool SetEditEngineUpdateLayout( bool bUpdate );
300 void ForceLayoutCalculation();
301
302 const SfxStyleSheet* GetStyleSheet() const;
303 SfxStyleSheet* GetStyleSheet();
304
305 void SetAnchorMode( EEAnchorMode eMode );
306 EEAnchorMode GetAnchorMode() const;
307
308 void CompleteAutoCorrect( vcl::Window const * pFrameWin = nullptr );
309
310 EESpellState StartSpeller(weld::Widget* pDialogParent, bool bMultipleDoc = false);
311 EESpellState StartThesaurus(weld::Widget* pDialogParent);
312 sal_Int32 StartSearchAndReplace( const SvxSearchItem& rSearchItem );
313
314 // for text conversion
315 void StartTextConversion(weld::Widget* pDialogParent, LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc);
316
317 void TransliterateText( TransliterationFlags nTransliterationMode );
318
319 bool IsCursorAtWrongSpelledWord();
320 bool IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong = false );
321 bool ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbackInfo&,void>& rCallBack);
322 OUString SpellIgnoreWord();
323
324 void InsertField( const SvxFieldItem& rFld );
325 const SvxFieldItem* GetFieldUnderMousePointer() const;
326 const SvxFieldItem* GetFieldUnderMousePointer( sal_Int32& nPara, sal_Int32& nPos ) const;
327 const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pnPara = nullptr, sal_Int32* pnPos = nullptr ) const;
328
329 const SvxFieldItem* GetFieldAtSelection() const;
331 const SvxFieldData* GetFieldAtCursor() const;
332 void SelectFieldAtCursor();
334 sal_Int32 GetPosNoField(sal_Int32 nPara, sal_Int32 nPos) const;
336 sal_Int32 GetPosWithField(sal_Int32 nPara, sal_Int32 nPos) const;
337
338 void SetInvalidateMore( sal_uInt16 nPixel );
339 sal_uInt16 GetInvalidateMore() const;
340
341 // grows or shrinks the font height for the current selection
342 void ChangeFontSize( bool bGrow, const FontList* pList );
343
344 static bool ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFontList );
345
346 OUString GetSurroundingText() const;
347 Selection GetSurroundingTextSelection() const;
348 bool DeleteSurroundingText(const Selection& rRange);
349
364 static LanguageType CheckLanguage(
365 const OUString &rText,
366 const css::uno::Reference< css::linguistic2::XSpellChecker1 >& xSpell,
367 const css::uno::Reference< css::linguistic2::XLanguageGuessing >& xLangGuess,
368 bool bIsParaText );
370 void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
372 void DrawSelectionXOR(OutlinerViewShell* pOtherShell);
373
382 void InitLOKSpecialPositioning(MapUnit eUnit, const tools::Rectangle& rOutputArea,
383 const Point& rVisDocStartPos);
384 void SetLOKSpecialOutputArea(const tools::Rectangle& rOutputArea);
385 const tools::Rectangle & GetLOKSpecialOutputArea() const;
386 void SetLOKSpecialVisArea(const tools::Rectangle& rVisArea);
387 tools::Rectangle GetLOKSpecialVisArea() const;
388 bool HasLOKSpecialPositioning() const;
389
390 void SetLOKSpecialFlags(LOKSpecialFlags eFlags);
391
392 void SuppressLOKMessages(bool bSet);
393 bool IsSuppressLOKMessages() const;
394
396 void SetNegativeX(bool bSet);
397 bool IsNegativeX() const;
398};
399
400#endif // INCLUDED_EDITENG_EDITVIEW_HXX
401
402/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool IsSelectionAtPoint(const Point &rPointPixel) override
Definition: editsel.cxx:48
virtual weld::Widget * EditViewPopupParent() const
Definition: editview.hxx:123
virtual void EditViewInputContext(const InputContext &rInputContext)=0
virtual void EditViewScrollStateChange()
Definition: editview.hxx:138
virtual css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
Definition: editview.hxx:146
virtual void EditViewCursorRect(const tools::Rectangle &rRect, int nExtTextInputWidth)=0
virtual OutputDevice & EditViewOutputDevice() const =0
virtual void EditViewInvalidate(const tools::Rectangle &rRect)=0
virtual void EditViewSelectionChange()=0
virtual Point EditViewPointerPosPixel() const =0
virtual css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard() const =0
ImpEditView * GetImpEditView() const
Definition: editview.hxx:162
OUString aDicNameSingle
Definition: editview.hxx:168
std::vector< VclPtr< vcl::Window > > OutWindowSet
Definition: editview.hxx:159
EditView & operator=(const EditView &)=delete
EditView(const EditView &)=delete
std::unique_ptr< ImpEditView > pImpEditView
Definition: editview.hxx:167
Interface class to not depend on SfxViewShell in editeng.
Definition: outliner.hxx:372
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
EETextFormat
Definition: editdata.hxx:35
EESpellState
Definition: editdata.hxx:40
EERemoveParaAttribsMode
Definition: editdata.hxx:46
EEAnchorMode
Definition: editdata.hxx:41
EESelectionMode
Definition: editdata.hxx:37
#define EDITENG_DLLPUBLIC
Definition: editengdllapi.h:28
EVControlBits
Definition: editstat.hxx:61
LOKSpecialFlags
Definition: editview.hxx:89
ScrollRangeCheck
Definition: editview.hxx:84
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
SvtScriptType
MapUnit
NONE
long Long
PointerStyle
@ MouseButtonDown
TransliterationFlags
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept
Definition: unotext.cxx:135