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
23 #include <com/sun/star/i18n/WordType.hpp>
25 #include <rsc/rscsfx.hxx>
26 #include <i18nlangtag/lang.h>
27 #include <tools/color.hxx>
28 #include <tools/gen.hxx>
29 #include <tools/link.hxx>
30 #include <vcl/cursor.hxx>
31 #include <editeng/editstat.hxx>
32 #include <svl/languageoptions.hxx>
33 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
34 #include <editeng/editdata.hxx>
35 #include <com/sun/star/uno/Reference.h>
36 #include <editeng/editengdllapi.h>
42 class OutlinerViewShell
;
45 namespace vcl
{ class Window
; }
56 class SvKeyValueIterator
;
58 namespace vcl
{ class Font
; }
65 namespace datatransfer
{
68 namespace linguistic2
{
70 class XLanguageGuessing
;
74 enum class ScrollRangeCheck
76 NONE
= 0, // No correction of VisArea when scrolling
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
; }
93 ImpEditEngine
* GetImpEditEngine() const;
96 ImpEditView
* pImpEditView
;
97 OUString aDicNameSingle
;
99 EditView( const EditView
& ) = delete;
100 EditView
& operator=( const EditView
& ) = delete;
103 EditView( EditEngine
* pEng
, vcl::Window
* pWindow
);
106 void SetEditEngine( EditEngine
* pEditEngine
);
107 EditEngine
* GetEditEngine() const;
109 void SetWindow( vcl::Window
* pWin
);
110 vcl::Window
* GetWindow() const;
112 bool HasOtherViewWindow( vcl::Window
* pWin
);
113 bool AddOtherViewWindow( vcl::Window
* pWin
);
114 bool RemoveOtherViewWindow( vcl::Window
* pWin
);
116 void Paint( const Rectangle
& rRect
, OutputDevice
* pTargetDevice
= nullptr );
117 Rectangle
GetInvalidateRect() const;
118 void InvalidateOtherViewWindows( const Rectangle
& rInvRect
);
120 Pair
Scroll( long nHorzScroll
, long nVertScroll
, ScrollRangeCheck nRangeCheck
= ScrollRangeCheck::NoNegative
);
122 void ShowCursor( bool bGotoCursor
= true, bool bForceVisCursor
= true, bool bActivate
= false );
123 void HideCursor( bool bDeactivate
= false );
125 void SetSelectionMode( EESelectionMode eMode
);
127 void SetReadOnly( bool bReadOnly
);
128 bool IsReadOnly() const;
130 bool HasSelection() const;
131 ESelection
GetSelection() const;
132 void SetSelection( const ESelection
& rNewSel
);
133 void SelectCurrentWord( sal_Int16 nWordType
= css::i18n::WordType::ANYWORD_IGNOREWHITESPACES
);
134 /// Returns the rectangles of the current selection in TWIPs.
135 void GetSelectionRectangles(std::vector
<Rectangle
>& rLogicRects
) const;
137 bool IsInsertMode() const;
138 void SetInsertMode( bool bInsert
);
140 OUString
GetSelected();
141 void DeleteSelected();
143 SvtScriptType
GetSelectedScriptType() const;
145 // VisArea position of the Output window.
146 // A size change also affects the VisArea
147 void SetOutputArea( const Rectangle
& rRect
);
148 const Rectangle
& GetOutputArea() const;
150 // Document position.
151 // A size change also affects the VisArea
152 void SetVisArea( const Rectangle
& rRect
);
153 const Rectangle
& GetVisArea() const;
155 const Pointer
& GetPointer() const;
157 vcl::Cursor
* GetCursor() const;
159 void InsertText( const OUString
& rNew
, bool bSelect
= false );
161 bool PostKeyEvent( const KeyEvent
& rKeyEvent
, vcl::Window
* pFrameWin
= nullptr );
163 bool MouseButtonUp( const MouseEvent
& rMouseEvent
);
164 bool MouseButtonDown( const MouseEvent
& rMouseEvent
);
166 bool MouseMove( const MouseEvent
& rMouseEvent
);
167 void Command( const CommandEvent
& rCEvt
);
177 // especially for Oliver Specht
178 Point
GetWindowPosTopLeft( sal_Int32 nParagraph
);
179 void MoveParagraphs( Range aParagraphs
, sal_Int32 nNewPos
);
180 void MoveParagraphs( long nDiff
);
182 const SfxItemSet
& GetEmptyItemSet();
183 SfxItemSet
GetAttribs();
184 void SetAttribs( const SfxItemSet
& rSet
);
185 void RemoveAttribs( bool bRemoveParaAttribs
= false, sal_uInt16 nWhich
= 0 );
186 void RemoveCharAttribs( sal_Int32 nPara
, sal_uInt16 nWhich
);
187 void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs
);
189 sal_uInt32
Read( SvStream
& rInput
, const OUString
& rBaseURL
, EETextFormat eFormat
, SvKeyValueIterator
* pHTTPHeaderAttrs
);
191 void SetBackgroundColor( const Color
& rColor
);
192 Color
GetBackgroundColor() const;
194 /// Informs this edit view about which view shell contains it.
195 void RegisterViewShell(OutlinerViewShell
* pViewShell
);
196 /// Informs this edit view about which other shell listens to it.
197 void RegisterOtherShell(OutlinerViewShell
* pOtherShell
);
199 void SetControlWord( EVControlBits nWord
);
200 EVControlBits
GetControlWord() const;
202 EditTextObject
* CreateTextObject();
203 void InsertText( const EditTextObject
& rTextObject
);
204 void InsertText( css::uno::Reference
< css::datatransfer::XTransferable
> const & xDataObj
, const OUString
& rBaseURL
, bool bUseSpecial
);
206 css::uno::Reference
< css::datatransfer::XTransferable
> GetTransferable();
208 // An EditView, so that when TRUE the update will be free from flickering:
209 void SetEditEngineUpdateMode( bool bUpdate
);
212 const SfxStyleSheet
* GetStyleSheet() const;
213 SfxStyleSheet
* GetStyleSheet();
215 void SetAnchorMode( EVAnchorMode eMode
);
216 EVAnchorMode
GetAnchorMode() const;
218 void CompleteAutoCorrect( vcl::Window
* pFrameWin
= nullptr );
220 EESpellState
StartSpeller( bool bMultipleDoc
= false );
221 EESpellState
StartThesaurus();
222 sal_Int32
StartSearchAndReplace( const SvxSearchItem
& rSearchItem
);
224 // for text conversion
225 void StartTextConversion( LanguageType nSrcLang
, LanguageType nDestLang
, const vcl::Font
*pDestFont
, sal_Int32 nOptions
, bool bIsInteractive
, bool bMultipleDoc
);
227 void TransliterateText( sal_Int32 nTransliterationMode
);
229 bool IsCursorAtWrongSpelledWord();
230 bool IsWrongSpelledWordAtPos( const Point
& rPosPixel
, bool bMarkIfWrong
= false );
231 void ExecuteSpellPopup( const Point
& rPosPixel
, Link
<SpellCallbackInfo
&,void>* pCallBack
);
233 void InsertField( const SvxFieldItem
& rFld
);
234 const SvxFieldItem
* GetFieldUnderMousePointer() const;
235 const SvxFieldItem
* GetFieldUnderMousePointer( sal_Int32
& nPara
, sal_Int32
& nPos
) const;
236 const SvxFieldItem
* GetField( const Point
& rPos
, sal_Int32
* pnPara
= nullptr, sal_Int32
* pnPos
= nullptr ) const;
238 const SvxFieldItem
* GetFieldAtSelection() const;
240 void SetInvalidateMore( sal_uInt16 nPixel
);
241 sal_uInt16
GetInvalidateMore() const;
243 // grows or shrinks the font height for the current selection
244 void ChangeFontSize( bool bGrow
, const FontList
* pList
);
246 static bool ChangeFontSize( bool bGrow
, SfxItemSet
& rSet
, const FontList
* pFontList
);
248 OUString
GetSurroundingText() const;
249 Selection
GetSurroundingTextSelection() const;
251 /** Tries to determine the language of 'rText', returning a matching known
252 locale if possible, or a fallback, or LANGUAGE_NONE if nothing found or
256 If TRUE, rText is a paragraph and the language is obtained by
257 passing the text to xLangGuess.
258 IF FALSE, a language match is tried for, in order,
259 1. the default document language (non-CTL, non-CJK, aka LATIN)
260 2. the UI language (Tools->Options->LanguageSettings->Languages User Interface)
261 3. the locale (Tools->Options->LanguageSettings->Languages Locale)
263 If nothing matched, LANGUAGE_NONE is returned.
265 static LanguageType
CheckLanguage(
266 const OUString
&rText
,
267 const css::uno::Reference
< css::linguistic2::XSpellChecker1
>& xSpell
,
268 const css::uno::Reference
< css::linguistic2::XLanguageGuessing
>& xLangGuess
,
270 /// Allows adjusting the point or mark of the selection to a document coordinate.
271 void SetCursorLogicPosition(const Point
& rPosition
, bool bPoint
, bool bClearMark
);
272 /// Trigger selection drawing callback in pOtherShell based on our shell's selection state.
273 void DrawSelection(OutlinerViewShell
* pOtherShell
);
276 #endif // INCLUDED_EDITENG_EDITVIEW_HXX
278 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */