Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / editeng / editview.hxx
blob163ea7c6653c5910a60b980133ac33df56a0733f
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 <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>
35 class EditEngine;
36 class ImpEditEngine;
37 class ImpEditView;
38 class OutlinerSearchable;
39 class SvxSearchItem;
40 class SvxFieldItem;
41 namespace vcl { class Window; }
42 class Pointer;
43 class KeyEvent;
44 class MouseEvent;
45 class DropEvent;
46 class CommandEvent;
47 class Rectangle;
48 class Pair;
49 class Point;
50 class Range;
51 class SvStream;
52 class SvKeyValueIterator;
53 class SfxStyleSheet;
54 namespace vcl { class Font; }
55 class FontList;
56 class OutputDevice;
58 #include <editeng/editdata.hxx>
59 #include <com/sun/star/uno/Reference.h>
60 #include <editeng/editengdllapi.h>
62 namespace com {
63 namespace sun {
64 namespace star {
65 namespace datatransfer {
66 class XTransferable;
68 namespace linguistic2 {
69 class XSpellChecker1;
70 class XLanguageGuessing;
72 }}}
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
84 friend class EditEngine;
85 friend class ImpEditEngine;
86 friend class EditSelFunctionSet;
88 public: // Needed for Undo
89 ImpEditView* GetImpEditView() const { return pImpEditView; }
90 ImpEditEngine* GetImpEditEngine() const;
92 private:
93 ImpEditView* pImpEditView;
94 OUString aDicNameSingle;
96 EditView( const EditView& ) = delete;
97 EditView& operator=( const EditView& ) = delete;
99 public:
100 EditView( EditEngine* pEng, vcl::Window* pWindow );
101 virtual ~EditView();
103 void SetEditEngine( EditEngine* pEditEngine );
104 EditEngine* GetEditEngine() const;
106 void SetWindow( vcl::Window* pWin );
107 vcl::Window* GetWindow() const;
109 void Paint( const Rectangle& rRect, OutputDevice* pTargetDevice = nullptr );
110 void Invalidate();
111 Pair Scroll( long nHorzScroll, long nVertScroll, ScrollRangeCheck nRangeCheck = ScrollRangeCheck::NoNegative );
113 void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true );
114 void HideCursor();
116 void SetSelectionMode( EESelectionMode eMode );
118 void SetReadOnly( bool bReadOnly );
119 bool IsReadOnly() const;
121 bool HasSelection() const;
122 ESelection GetSelection() const;
123 void SetSelection( const ESelection& rNewSel );
124 void SelectCurrentWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
125 /// Returns the rectangles of the current selection in TWIPs.
126 void GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const;
128 bool IsInsertMode() const;
129 void SetInsertMode( bool bInsert );
131 OUString GetSelected();
132 void DeleteSelected();
134 SvtScriptType GetSelectedScriptType() const;
136 // VisArea position of the Output window.
137 // A size change also affects the VisArea
138 void SetOutputArea( const Rectangle& rRect );
139 const Rectangle& GetOutputArea() const;
141 // Document position.
142 // A size change also affects the VisArea
143 void SetVisArea( const Rectangle& rRect );
144 const Rectangle& GetVisArea() const;
146 const Pointer& GetPointer() const;
148 vcl::Cursor* GetCursor() const;
150 void InsertText( const OUString& rNew, bool bSelect = false );
152 bool PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window* pFrameWin = nullptr );
154 bool MouseButtonUp( const MouseEvent& rMouseEvent );
155 bool MouseButtonDown( const MouseEvent& rMouseEvent );
156 void ReleaseMouse();
157 bool MouseMove( const MouseEvent& rMouseEvent );
158 void Command( const CommandEvent& rCEvt );
160 void Cut();
161 void Copy();
162 void Paste();
163 void PasteSpecial();
165 void Undo();
166 void Redo();
168 // especially for Oliver Specht
169 Point GetWindowPosTopLeft( sal_Int32 nParagraph );
170 void MoveParagraphs( Range aParagraphs, sal_Int32 nNewPos );
171 void MoveParagraphs( long nDiff );
173 const SfxItemSet& GetEmptyItemSet();
174 SfxItemSet GetAttribs();
175 void SetAttribs( const SfxItemSet& rSet );
176 void RemoveAttribs( bool bRemoveParaAttribs = false, sal_uInt16 nWhich = 0 );
177 void RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich = 0 );
178 void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs = false );
180 sal_uInt32 Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs = nullptr );
182 void SetBackgroundColor( const Color& rColor );
183 Color GetBackgroundColor() const;
185 /// @see vcl::ITiledRenderable::registerCallback().
186 void registerLibreOfficeKitCallback(OutlinerSearchable *pSearchable);
188 void SetControlWord( EVControlBits nWord );
189 EVControlBits GetControlWord() const;
191 EditTextObject* CreateTextObject();
192 void InsertText( const EditTextObject& rTextObject );
193 void InsertText( css::uno::Reference< css::datatransfer::XTransferable > xDataObj, const OUString& rBaseURL, bool bUseSpecial );
195 css::uno::Reference< css::datatransfer::XTransferable > GetTransferable();
197 // An EditView, so that when TRUE the update will be free from flickering:
198 void SetEditEngineUpdateMode( bool bUpdate );
199 void ForceUpdate();
201 const SfxStyleSheet* GetStyleSheet() const;
202 SfxStyleSheet* GetStyleSheet();
204 void SetAnchorMode( EVAnchorMode eMode );
205 EVAnchorMode GetAnchorMode() const;
207 void CompleteAutoCorrect( vcl::Window* pFrameWin = nullptr );
209 EESpellState StartSpeller( bool bMultipleDoc = false );
210 EESpellState StartThesaurus();
211 sal_Int32 StartSearchAndReplace( const SvxSearchItem& rSearchItem );
213 // for text conversion
214 void StartTextConversion( LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc );
216 void TransliterateText( sal_Int32 nTransliterationMode );
218 bool IsCursorAtWrongSpelledWord();
219 bool IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong = false );
220 void ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo&,void>* pCallBack = nullptr );
222 void InsertField( const SvxFieldItem& rFld );
223 const SvxFieldItem* GetFieldUnderMousePointer() const;
224 const SvxFieldItem* GetFieldUnderMousePointer( sal_Int32& nPara, sal_Int32& nPos ) const;
225 const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pnPara = nullptr, sal_Int32* pnPos = nullptr ) const;
227 const SvxFieldItem* GetFieldAtSelection() const;
229 void SetInvalidateMore( sal_uInt16 nPixel );
230 sal_uInt16 GetInvalidateMore() const;
232 // grows or shrinks the font height for the current selection
233 void ChangeFontSize( bool bGrow, const FontList* pList );
235 static bool ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFontList );
237 OUString GetSurroundingText() const;
238 Selection GetSurroundingTextSelection() const;
240 /** Tries to determine the language of 'rText', returning a matching known
241 locale if possible, or a fallback, or LANGUAGE_NONE if nothing found or
242 matched.
244 @param bIsParaText
245 If TRUE, rText is a paragraph and the language is obtained by
246 passing the text to xLangGuess.
247 IF FALSE, a language match is tried for, in order,
248 1. the default document language (non-CTL, non-CJK, aka LATIN)
249 2. the UI language (Tools->Options->LanguageSettings->Languages User Interface)
250 3. the locale (Tools->Options->LanguageSettings->Languages Locale)
251 4. en-US
252 If nothing matched, LANGUAGE_NONE is returned.
254 static LanguageType CheckLanguage(
255 const OUString &rText,
256 const css::uno::Reference< css::linguistic2::XSpellChecker1 >& xSpell,
257 const css::uno::Reference< css::linguistic2::XLanguageGuessing >& xLangGuess,
258 bool bIsParaText );
259 /// Allows adjusting the point or mark of the selection to a document coordinate.
260 void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
263 #endif // INCLUDED_EDITENG_EDITVIEW_HXX
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */