Branch libreoffice-5-0-4
[LibreOffice.git] / include / editeng / editview.hxx
blobbb091172c9ba05d86a71a1396d1c43386e8fd949
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 #define LOK_USE_UNSTABLE_API
34 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
36 class EditEngine;
37 class ImpEditEngine;
38 class ImpEditView;
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 class EDITENG_DLLPUBLIC EditView
76 friend class EditEngine;
77 friend class ImpEditEngine;
78 friend class EditSelFunctionSet;
80 public: // Needed for Undo
81 ImpEditView* GetImpEditView() const { return pImpEditView; }
82 ImpEditEngine* GetImpEditEngine() const;
84 private:
85 ImpEditView* pImpEditView;
86 OUString aDicNameSingle;
88 EditView( const EditView& ) SAL_DELETED_FUNCTION;
89 EditView& operator=( const EditView& ) SAL_DELETED_FUNCTION;
91 public:
92 EditView( EditEngine* pEng, vcl::Window* pWindow );
93 virtual ~EditView();
95 void SetEditEngine( EditEngine* pEditEngine );
96 EditEngine* GetEditEngine() const;
98 void SetWindow( vcl::Window* pWin );
99 vcl::Window* GetWindow() const;
101 void Paint( const Rectangle& rRect, OutputDevice* pTargetDevice = 0 );
102 void Invalidate();
103 Pair Scroll( long nHorzScroll, long nVertScroll, sal_uInt8 nRangeCheck = RGCHK_NEG );
105 void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true );
106 void HideCursor();
108 void SetSelectionMode( EESelectionMode eMode );
110 void SetReadOnly( bool bReadOnly );
111 bool IsReadOnly() const;
113 bool HasSelection() const;
114 ESelection GetSelection() const;
115 void SetSelection( const ESelection& rNewSel );
116 bool SelectCurrentWord( sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
118 bool IsInsertMode() const;
119 void SetInsertMode( bool bInsert );
121 void ReplaceSelected( const OUString& rStr );
122 OUString GetSelected();
123 void DeleteSelected();
125 SvtScriptType GetSelectedScriptType() const;
127 // VisArea position of the Output window.
128 // A size change also affects the VisArea
129 void SetOutputArea( const Rectangle& rRect );
130 const Rectangle& GetOutputArea() const;
132 // Document position.
133 // A size change also affects the VisArea
134 void SetVisArea( const Rectangle& rRect );
135 const Rectangle& GetVisArea() const;
137 const Pointer& GetPointer() const;
139 vcl::Cursor* GetCursor() const;
141 void InsertText( const OUString& rNew, bool bSelect = false );
143 bool PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window* pFrameWin = NULL );
145 bool MouseButtonUp( const MouseEvent& rMouseEvent );
146 bool MouseButtonDown( const MouseEvent& rMouseEvent );
147 void ReleaseMouse();
148 bool MouseMove( const MouseEvent& rMouseEvent );
149 void Command( const CommandEvent& rCEvt );
151 void Cut();
152 void Copy();
153 void Paste();
154 void PasteSpecial();
156 void Undo();
157 void Redo();
159 // especially for Oliver Specht
160 Point GetWindowPosTopLeft( sal_Int32 nParagraph );
161 void MoveParagraphs( Range aParagraphs, sal_Int32 nNewPos );
162 void MoveParagraphs( long nDiff );
164 const SfxItemSet& GetEmptyItemSet();
165 SfxItemSet GetAttribs();
166 void SetAttribs( const SfxItemSet& rSet );
167 void RemoveAttribs( bool bRemoveParaAttribs = false, sal_uInt16 nWhich = 0 );
168 void RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich = 0 );
169 void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs = false );
171 sal_uInt32 Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, bool bSelect = false, SvKeyValueIterator* pHTTPHeaderAttrs = NULL );
173 void SetBackgroundColor( const Color& rColor );
174 Color GetBackgroundColor() const;
176 void setTiledRendering(bool bTiledRendering);
177 bool isTiledRendering();
178 /// @see vcl::ITiledRenderable::registerCallback().
179 void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
181 void SetControlWord( EVControlBits nWord );
182 EVControlBits GetControlWord() const;
184 EditTextObject* CreateTextObject();
185 void InsertText( const EditTextObject& rTextObject );
186 void InsertText( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xDataObj, const OUString& rBaseURL, bool bUseSpecial );
188 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > GetTransferable();
190 // An EditView, so that when TRUE the update will be free from flickering:
191 void SetEditEngineUpdateMode( bool bUpdate );
192 void ForceUpdate();
194 const SfxStyleSheet* GetStyleSheet() const;
195 SfxStyleSheet* GetStyleSheet();
197 void SetAnchorMode( EVAnchorMode eMode );
198 EVAnchorMode GetAnchorMode() const;
200 void CompleteAutoCorrect( vcl::Window* pFrameWin = NULL );
202 EESpellState StartSpeller( bool bMultipleDoc = false );
203 EESpellState StartThesaurus();
204 sal_Int32 StartSearchAndReplace( const SvxSearchItem& rSearchItem );
206 // for text conversion
207 void StartTextConversion( LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc );
208 bool HasConvertibleTextPortion( LanguageType nLang );
210 void TransliterateText( sal_Int32 nTransliterationMode );
212 bool IsCursorAtWrongSpelledWord( bool bMarkIfWrong = false );
213 bool IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong = false );
214 bool IsShapeParaFocusable();
215 bool WrongSpelledBreakPara(sal_Int32 nPara, sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nIndex);
216 void ExecuteSpellPopup( const Point& rPosPixel, Link<>* pCallBack = 0 );
218 void InsertField( const SvxFieldItem& rFld );
219 const SvxFieldItem* GetFieldUnderMousePointer() const;
220 const SvxFieldItem* GetFieldUnderMousePointer( sal_Int32& nPara, sal_Int32& nPos ) const;
221 const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pnPara = NULL, sal_Int32* pnPos = NULL ) const;
223 const SvxFieldItem* GetFieldAtSelection() const;
225 void SetInvalidateMore( sal_uInt16 nPixel );
226 sal_uInt16 GetInvalidateMore() const;
228 // grows or shrinks the font height for the current selection
229 void ChangeFontSize( bool bGrow, const FontList* pList );
231 static bool ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFontList );
233 OUString GetSurroundingText() const;
234 Selection GetSurroundingTextSelection() const;
236 /** Tries to determine the language of 'rText', returning a matching known
237 locale if possible, or a fallback, or LANGUAGE_NONE if nothing found or
238 matched.
240 @param bIsParaText
241 If TRUE, rText is a paragraph and the language is obtained by
242 passing the text to xLangGuess.
243 IF FALSE, a language match is tried for, in order,
244 1. the default document language (non-CTL, non-CJK, aka LATIN)
245 2. the UI language (Tools->Options->LanguageSettings->Languages User Interface)
246 3. the locale (Tools->Options->LanguageSettings->Languages Locale)
247 4. en-US
248 If nothing matched, LANGUAGE_NONE is returned.
250 static LanguageType CheckLanguage(
251 const OUString &rText,
252 com::sun::star::uno::Reference< com::sun::star::linguistic2::XSpellChecker1 > xSpell,
253 com::sun::star::uno::Reference< com::sun::star::linguistic2::XLanguageGuessing > xLangGuess,
254 bool bIsParaText );
255 /// Allows adjusting the point or mark of the selection to a document coordinate.
256 void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
259 #endif // INCLUDED_EDITENG_EDITVIEW_HXX
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */