nss: upgrade to release 3.73
[LibreOffice.git] / include / editeng / editview.hxx
blob96c629f2e039384f0f00960cc93649ccf00ffe57
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 // MyEDITVIEW, due to exported EditView
20 #ifndef INCLUDED_EDITENG_EDITVIEW_HXX
21 #define INCLUDED_EDITENG_EDITVIEW_HXX
23 #include <config_options.h>
24 #include <memory>
25 #include <com/sun/star/i18n/WordType.hpp>
27 #include <i18nlangtag/lang.h>
28 #include <tools/color.hxx>
29 #include <tools/gen.hxx>
30 #include <vcl/errcode.hxx>
31 #include <vcl/vclptr.hxx>
32 #include <editeng/editstat.hxx>
33 #include <editeng/flditem.hxx>
34 #include <svl/languageoptions.hxx>
35 #include <editeng/editdata.hxx>
36 #include <com/sun/star/uno/Reference.h>
37 #include <editeng/editengdllapi.h>
40 class EditTextObject;
41 class EditEngine;
42 class ImpEditEngine;
43 class ImpEditView;
44 class OutlinerViewShell;
45 class SvxSearchItem;
46 class SvxFieldItem;
47 namespace vcl { class Window; }
48 class KeyEvent;
49 class MouseEvent;
50 class CommandEvent;
51 class SvStream;
52 class SvKeyValueIterator;
53 class SfxStyleSheet;
54 class SfxItemSet;
55 namespace vcl { class Cursor; }
56 namespace vcl { class Font; }
57 class FontList;
58 class InputContext;
59 class OutputDevice;
60 enum class TransliterationFlags;
61 enum class PointerStyle;
63 namespace com {
64 namespace sun {
65 namespace star {
66 namespace datatransfer {
67 class XTransferable;
68 namespace dnd {
69 class XDropTarget;
72 namespace linguistic2 {
73 class XSpellChecker1;
74 class XLanguageGuessing;
76 }}}
78 template <typename Arg, typename Ret> class Link;
80 enum class ScrollRangeCheck
82 NoNegative = 1, // No negative VisArea when scrolling
83 PaperWidthTextSize = 2, // VisArea must be within paper width, Text Size
86 // Helper class that allows to set a callback at the EditView. When
87 // set, Invalidates and repaints are suppressed at the EditView, but
88 // EditViewInvalidate() will be triggered to allow the consumer to
89 // react itself as needed.
90 // Also Selection visualization is suppressed and EditViewSelectionChange
91 // is triggered when Selection changes and needs reaction.
92 class UNLESS_MERGELIBS(EDITENG_DLLPUBLIC) EditViewCallbacks
94 public:
95 EditViewCallbacks() {}
96 virtual ~EditViewCallbacks();
98 // call this when text visualization changed in any way. It
99 // will also update selection, so no need to call this self
100 // additionally (but will also do no harm)
101 virtual void EditViewInvalidate(const tools::Rectangle& rRect) = 0;
103 // call this when only selection is changed. Text change will
104 // then *not* be checked and not be reacted on. Still, when
105 // only the selection is changed, this is useful and faster
106 virtual void EditViewSelectionChange() = 0;
108 // return the OutputDevice that the EditView will draw to
109 virtual OutputDevice& EditViewOutputDevice() const = 0;
111 // Triggered to update InputEngine context information
112 virtual void EditViewInputContext(const InputContext& rInputContext) = 0;
114 // Triggered to update InputEngine cursor position
115 virtual void EditViewCursorRect(const tools::Rectangle& rRect, int nExtTextInputWidth) = 0;
117 // Triggered if scroll bar state should change
118 virtual void EditViewScrollStateChange()
122 // implemented if drag and drop support is wanted
123 virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> GetDropTarget()
125 return nullptr;
129 class EDITENG_DLLPUBLIC EditView final
131 friend class EditEngine;
132 friend class ImpEditEngine;
133 friend class EditSelFunctionSet;
135 public:
136 typedef std::vector<VclPtr<vcl::Window>> OutWindowSet;
138 public: // Needed for Undo
139 ImpEditView* GetImpEditView() const { return pImpEditView.get(); }
140 ImpEditEngine* GetImpEditEngine() const;
142 private:
143 std::unique_ptr<ImpEditView>
144 pImpEditView;
145 OUString aDicNameSingle;
147 EditView( const EditView& ) = delete;
148 EditView& operator=( const EditView& ) = delete;
150 public:
151 EditView( EditEngine* pEng, vcl::Window* pWindow );
152 ~EditView();
154 // set EditViewCallbacks for external handling of Repaints/Visualization
155 void setEditViewCallbacks(EditViewCallbacks* pEditViewCallbacks);
156 EditViewCallbacks* getEditViewCallbacks() const;
158 void SetEditEngine( EditEngine* pEditEngine );
159 EditEngine* GetEditEngine() const;
161 void SetWindow( vcl::Window* pWin );
162 vcl::Window* GetWindow() const;
163 OutputDevice& GetOutputDevice() const;
165 bool HasOtherViewWindow( vcl::Window* pWin );
166 bool AddOtherViewWindow( vcl::Window* pWin );
167 bool RemoveOtherViewWindow( vcl::Window* pWin );
169 void Paint( const tools::Rectangle& rRect, OutputDevice* pTargetDevice = nullptr );
170 tools::Rectangle GetInvalidateRect() const;
171 void InvalidateWindow(const tools::Rectangle& rClipRect);
172 void InvalidateOtherViewWindows( const tools::Rectangle& rInvRect );
173 void Invalidate();
174 Pair Scroll( tools::Long nHorzScroll, tools::Long nVertScroll, ScrollRangeCheck nRangeCheck = ScrollRangeCheck::NoNegative );
176 void SetBroadcastLOKViewCursor(bool bSet);
177 tools::Rectangle GetEditCursor() const;
178 void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true, bool bActivate = false );
179 void HideCursor( bool bDeactivate = false );
181 void SetSelectionMode( EESelectionMode eMode );
183 void SetReadOnly( bool bReadOnly );
184 bool IsReadOnly() const;
186 bool HasSelection() const;
187 ESelection GetSelection() const;
188 void SetSelection( const ESelection& rNewSel );
189 bool IsSelectionAtPoint(const Point& rPointPixel);
190 void SelectCurrentWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
191 /// Returns the rectangles of the current selection in TWIPs.
192 void GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects) const;
194 bool IsInsertMode() const;
195 void SetInsertMode( bool bInsert );
197 OUString GetSelected() const;
198 void DeleteSelected();
200 SvtScriptType GetSelectedScriptType() const;
202 // VisArea position of the Output window.
203 // A size change also affects the VisArea
204 void SetOutputArea( const tools::Rectangle& rRect );
205 const tools::Rectangle& GetOutputArea() const;
207 // Document position.
208 // A size change also affects the VisArea
209 void SetVisArea( const tools::Rectangle& rRect );
210 const tools::Rectangle& GetVisArea() const;
212 PointerStyle GetPointer() const;
214 vcl::Cursor* GetCursor() const;
216 void InsertText( const OUString& rNew, bool bSelect = false );
217 void InsertParaBreak();
219 bool PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * pFrameWin = nullptr );
221 bool MouseButtonUp( const MouseEvent& rMouseEvent );
222 bool MouseButtonDown( const MouseEvent& rMouseEvent );
223 void ReleaseMouse();
224 bool MouseMove( const MouseEvent& rMouseEvent );
225 void Command( const CommandEvent& rCEvt );
227 void Cut();
228 void Copy();
229 void Paste();
230 void PasteSpecial();
232 void Undo();
233 void Redo();
235 // especially for Oliver Specht
236 Point GetWindowPosTopLeft( sal_Int32 nParagraph );
237 void MoveParagraphs( Range aParagraphs, sal_Int32 nNewPos );
238 void MoveParagraphs( tools::Long nDiff );
240 const SfxItemSet& GetEmptyItemSet() const;
241 SfxItemSet GetAttribs();
242 void SetAttribs( const SfxItemSet& rSet );
243 void RemoveAttribs( bool bRemoveParaAttribs = false, sal_uInt16 nWhich = 0 );
244 void RemoveAttribs( EERemoveParaAttribsMode eMode, sal_uInt16 nWhich );
245 void RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich );
246 void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs );
248 ErrCode Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs );
250 void SetBackgroundColor( const Color& rColor );
251 Color const & GetBackgroundColor() const;
253 /// Informs this edit view about which view shell contains it.
254 void RegisterViewShell(OutlinerViewShell* pViewShell);
255 /// Informs this edit view about which other shell listens to it.
256 void RegisterOtherShell(OutlinerViewShell* pOtherShell);
258 void SetControlWord( EVControlBits nWord );
259 EVControlBits GetControlWord() const;
261 std::unique_ptr<EditTextObject> CreateTextObject();
262 void InsertText( const EditTextObject& rTextObject );
263 void InsertText( css::uno::Reference< css::datatransfer::XTransferable > const & xDataObj, const OUString& rBaseURL, bool bUseSpecial );
265 css::uno::Reference< css::datatransfer::XTransferable > GetTransferable() const;
267 // An EditView, so that when TRUE the update will be free from flickering:
268 void SetEditEngineUpdateMode( bool bUpdate );
269 void ForceUpdate();
271 const SfxStyleSheet* GetStyleSheet() const;
272 SfxStyleSheet* GetStyleSheet();
274 void SetAnchorMode( EEAnchorMode eMode );
275 EEAnchorMode GetAnchorMode() const;
277 void CompleteAutoCorrect( vcl::Window const * pFrameWin = nullptr );
279 EESpellState StartSpeller( bool bMultipleDoc = false );
280 EESpellState StartThesaurus();
281 sal_Int32 StartSearchAndReplace( const SvxSearchItem& rSearchItem );
283 // for text conversion
284 void StartTextConversion( LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc );
286 void TransliterateText( TransliterationFlags nTransliterationMode );
288 bool IsCursorAtWrongSpelledWord();
289 bool IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong = false );
290 void ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo&,void> const * pCallBack );
291 OUString SpellIgnoreWord();
293 void InsertField( const SvxFieldItem& rFld );
294 const SvxFieldItem* GetFieldUnderMousePointer() const;
295 const SvxFieldItem* GetFieldUnderMousePointer( sal_Int32& nPara, sal_Int32& nPos ) const;
296 const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pnPara = nullptr, sal_Int32* pnPos = nullptr ) const;
298 const SvxFieldItem* GetFieldAtSelection() const;
299 /// Select and return the field at the current cursor position
300 const SvxFieldData* GetFieldAtCursor() const;
301 void SelectFieldAtCursor();
303 void SetInvalidateMore( sal_uInt16 nPixel );
304 sal_uInt16 GetInvalidateMore() const;
306 // grows or shrinks the font height for the current selection
307 void ChangeFontSize( bool bGrow, const FontList* pList );
309 static bool ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFontList );
311 OUString GetSurroundingText() const;
312 Selection GetSurroundingTextSelection() const;
313 bool DeleteSurroundingText(const Selection& rRange);
315 /** Tries to determine the language of 'rText', returning a matching known
316 locale if possible, or a fallback, or LANGUAGE_NONE if nothing found or
317 matched.
319 @param bIsParaText
320 If TRUE, rText is a paragraph and the language is obtained by
321 passing the text to xLangGuess.
322 IF FALSE, a language match is tried for, in order,
323 1. the default document language (non-CTL, non-CJK, aka LATIN)
324 2. the UI language (Tools->Options->LanguageSettings->Languages User Interface)
325 3. the locale (Tools->Options->LanguageSettings->Languages Locale)
326 4. en-US
327 If nothing matched, LANGUAGE_NONE is returned.
329 static LanguageType CheckLanguage(
330 const OUString &rText,
331 const css::uno::Reference< css::linguistic2::XSpellChecker1 >& xSpell,
332 const css::uno::Reference< css::linguistic2::XLanguageGuessing >& xLangGuess,
333 bool bIsParaText );
334 /// Allows adjusting the point or mark of the selection to a document coordinate.
335 void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
336 /// Trigger selection drawing callback in pOtherShell based on our shell's selection state.
337 void DrawSelectionXOR(OutlinerViewShell* pOtherShell);
340 * This is meant for Calc(LOK), but there may be other use-cases.
341 * In Calc, all logical positions are computed by
342 * doing independent pixel-alignment for each cell's size. The *LOKSpecial* methods
343 * can be used to set/get the output-area and visible-area in real logical
344 * units. This enables EditView to send cursor/selection messages in
345 * real logical units like it is done for Writer.
347 void InitLOKSpecialPositioning(MapUnit eUnit, const tools::Rectangle& rOutputArea,
348 const Point& rVisDocStartPos);
349 void SetLOKSpecialOutputArea(const tools::Rectangle& rOutputArea);
350 tools::Rectangle GetLOKSpecialOutputArea() const;
351 void SetLOKSpecialVisArea(const tools::Rectangle& rVisArea);
352 tools::Rectangle GetLOKSpecialVisArea() const;
353 bool HasLOKSpecialPositioning() const;
355 void SuppressLOKMessages(bool bSet);
356 bool IsSuppressLOKMessages() const;
359 #endif // INCLUDED_EDITENG_EDITVIEW_HXX
361 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */