1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
24 #include <com/sun/star/i18n/WordType.hpp>
26 #include <rsc/rscsfx.hxx>
27 #include <i18nlangtag/lang.h>
28 #include <tools/color.hxx>
29 #include <tools/gen.hxx>
30 #include <tools/link.hxx>
31 #include <vcl/cursor.hxx>
32 #include <editeng/editstat.hxx>
33 #include <svl/languageoptions.hxx>
34 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
35 #include <editeng/editdata.hxx>
36 #include <com/sun/star/uno/Reference.h>
37 #include <editeng/editengdllapi.h>
43 class OutlinerViewShell
;
46 namespace vcl
{ class Window
; }
51 namespace tools
{ class Rectangle
; }
56 class SvKeyValueIterator
;
58 namespace vcl
{ class Font
; }
61 enum class TransliterationFlags
;
66 namespace datatransfer
{
69 namespace linguistic2
{
71 class XLanguageGuessing
;
75 enum class ScrollRangeCheck
77 NoNegative
= 1, // No negative VisArea when scrolling
78 PaperWidthTextSize
= 2, // VisArea must be within paper width, Text Size
82 class EDITENG_DLLPUBLIC EditView final
84 friend class EditEngine
;
85 friend class ImpEditEngine
;
86 friend class EditSelFunctionSet
;
89 typedef std::vector
<VclPtr
<vcl::Window
>> OutWindowSet
;
91 public: // Needed for Undo
92 ImpEditView
* GetImpEditView() const { return pImpEditView
.get(); }
93 ImpEditEngine
* GetImpEditEngine() const;
96 std::unique_ptr
<ImpEditView
>
98 OUString aDicNameSingle
;
100 EditView( const EditView
& ) = delete;
101 EditView
& operator=( const EditView
& ) = delete;
104 EditView( EditEngine
* pEng
, vcl::Window
* pWindow
);
107 void SetEditEngine( EditEngine
* pEditEngine
);
108 EditEngine
* GetEditEngine() const;
110 void SetWindow( vcl::Window
* pWin
);
111 vcl::Window
* GetWindow() const;
113 bool HasOtherViewWindow( vcl::Window
* pWin
);
114 bool AddOtherViewWindow( vcl::Window
* pWin
);
115 bool RemoveOtherViewWindow( vcl::Window
* pWin
);
117 void Paint( const tools::Rectangle
& rRect
, OutputDevice
* pTargetDevice
= nullptr );
118 tools::Rectangle
GetInvalidateRect() const;
119 void InvalidateOtherViewWindows( const tools::Rectangle
& rInvRect
);
121 Pair
Scroll( long nHorzScroll
, long nVertScroll
, ScrollRangeCheck nRangeCheck
= ScrollRangeCheck::NoNegative
);
123 void ShowCursor( bool bGotoCursor
= true, bool bForceVisCursor
= true, bool bActivate
= false );
124 void HideCursor( bool bDeactivate
= false );
126 void SetSelectionMode( EESelectionMode eMode
);
128 void SetReadOnly( bool bReadOnly
);
129 bool IsReadOnly() const;
131 bool HasSelection() const;
132 ESelection
GetSelection() const;
133 void SetSelection( const ESelection
& rNewSel
);
134 void SelectCurrentWord( sal_Int16 nWordType
= css::i18n::WordType::ANYWORD_IGNOREWHITESPACES
);
135 /// Returns the rectangles of the current selection in TWIPs.
136 void GetSelectionRectangles(std::vector
<tools::Rectangle
>& rLogicRects
) const;
138 bool IsInsertMode() const;
139 void SetInsertMode( bool bInsert
);
141 OUString
GetSelected();
142 void DeleteSelected();
144 SvtScriptType
GetSelectedScriptType() const;
146 // VisArea position of the Output window.
147 // A size change also affects the VisArea
148 void SetOutputArea( const tools::Rectangle
& rRect
);
149 const tools::Rectangle
& GetOutputArea() const;
151 // Document position.
152 // A size change also affects the VisArea
153 void SetVisArea( const tools::Rectangle
& rRect
);
154 const tools::Rectangle
& GetVisArea() const;
156 const Pointer
& GetPointer() const;
158 vcl::Cursor
* GetCursor() const;
160 void InsertText( const OUString
& rNew
, bool bSelect
= false );
162 bool PostKeyEvent( const KeyEvent
& rKeyEvent
, vcl::Window
* pFrameWin
= nullptr );
164 bool MouseButtonUp( const MouseEvent
& rMouseEvent
);
165 bool MouseButtonDown( const MouseEvent
& rMouseEvent
);
167 bool MouseMove( const MouseEvent
& rMouseEvent
);
168 void Command( const CommandEvent
& rCEvt
);
178 // especially for Oliver Specht
179 Point
GetWindowPosTopLeft( sal_Int32 nParagraph
);
180 void MoveParagraphs( Range aParagraphs
, sal_Int32 nNewPos
);
181 void MoveParagraphs( long nDiff
);
183 const SfxItemSet
& GetEmptyItemSet();
184 SfxItemSet
GetAttribs();
185 void SetAttribs( const SfxItemSet
& rSet
);
186 void RemoveAttribs( bool bRemoveParaAttribs
= false, sal_uInt16 nWhich
= 0 );
187 void RemoveCharAttribs( sal_Int32 nPara
, sal_uInt16 nWhich
);
188 void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs
);
190 sal_uInt32
Read( SvStream
& rInput
, EETextFormat eFormat
, SvKeyValueIterator
* pHTTPHeaderAttrs
);
192 void SetBackgroundColor( const Color
& rColor
);
193 Color
GetBackgroundColor() const;
195 /// Informs this edit view about which view shell contains it.
196 void RegisterViewShell(OutlinerViewShell
* pViewShell
);
197 /// Informs this edit view about which other shell listens to it.
198 void RegisterOtherShell(OutlinerViewShell
* pOtherShell
);
200 void SetControlWord( EVControlBits nWord
);
201 EVControlBits
GetControlWord() const;
203 EditTextObject
* CreateTextObject();
204 void InsertText( const EditTextObject
& rTextObject
);
205 void InsertText( css::uno::Reference
< css::datatransfer::XTransferable
> const & xDataObj
, const OUString
& rBaseURL
, bool bUseSpecial
);
207 css::uno::Reference
< css::datatransfer::XTransferable
> GetTransferable();
209 // An EditView, so that when TRUE the update will be free from flickering:
210 void SetEditEngineUpdateMode( bool bUpdate
);
213 const SfxStyleSheet
* GetStyleSheet() const;
214 SfxStyleSheet
* GetStyleSheet();
216 void SetAnchorMode( EEAnchorMode eMode
);
217 EEAnchorMode
GetAnchorMode() const;
219 void CompleteAutoCorrect( vcl::Window
* pFrameWin
= nullptr );
221 EESpellState
StartSpeller( bool bMultipleDoc
= false );
222 EESpellState
StartThesaurus();
223 sal_Int32
StartSearchAndReplace( const SvxSearchItem
& rSearchItem
);
225 // for text conversion
226 void StartTextConversion( LanguageType nSrcLang
, LanguageType nDestLang
, const vcl::Font
*pDestFont
, sal_Int32 nOptions
, bool bIsInteractive
, bool bMultipleDoc
);
228 void TransliterateText( TransliterationFlags nTransliterationMode
);
230 bool IsCursorAtWrongSpelledWord();
231 bool IsWrongSpelledWordAtPos( const Point
& rPosPixel
, bool bMarkIfWrong
= false );
232 void ExecuteSpellPopup( const Point
& rPosPixel
, Link
<SpellCallbackInfo
&,void>* pCallBack
);
234 void InsertField( const SvxFieldItem
& rFld
);
235 const SvxFieldItem
* GetFieldUnderMousePointer() const;
236 const SvxFieldItem
* GetFieldUnderMousePointer( sal_Int32
& nPara
, sal_Int32
& nPos
) const;
237 const SvxFieldItem
* GetField( const Point
& rPos
, sal_Int32
* pnPara
= nullptr, sal_Int32
* pnPos
= nullptr ) const;
239 const SvxFieldItem
* GetFieldAtSelection() const;
241 void SetInvalidateMore( sal_uInt16 nPixel
);
242 sal_uInt16
GetInvalidateMore() const;
244 // grows or shrinks the font height for the current selection
245 void ChangeFontSize( bool bGrow
, const FontList
* pList
);
247 static bool ChangeFontSize( bool bGrow
, SfxItemSet
& rSet
, const FontList
* pFontList
);
249 OUString
GetSurroundingText() const;
250 Selection
GetSurroundingTextSelection() const;
252 /** Tries to determine the language of 'rText', returning a matching known
253 locale if possible, or a fallback, or LANGUAGE_NONE if nothing found or
257 If TRUE, rText is a paragraph and the language is obtained by
258 passing the text to xLangGuess.
259 IF FALSE, a language match is tried for, in order,
260 1. the default document language (non-CTL, non-CJK, aka LATIN)
261 2. the UI language (Tools->Options->LanguageSettings->Languages User Interface)
262 3. the locale (Tools->Options->LanguageSettings->Languages Locale)
264 If nothing matched, LANGUAGE_NONE is returned.
266 static LanguageType
CheckLanguage(
267 const OUString
&rText
,
268 const css::uno::Reference
< css::linguistic2::XSpellChecker1
>& xSpell
,
269 const css::uno::Reference
< css::linguistic2::XLanguageGuessing
>& xLangGuess
,
271 /// Allows adjusting the point or mark of the selection to a document coordinate.
272 void SetCursorLogicPosition(const Point
& rPosition
, bool bPoint
, bool bClearMark
);
273 /// Trigger selection drawing callback in pOtherShell based on our shell's selection state.
274 void DrawSelection(OutlinerViewShell
* pOtherShell
);
277 #endif // INCLUDED_EDITENG_EDITVIEW_HXX
279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */