Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : // MyEDITVIEW, due to exported EditView
20 : #ifndef INCLUDED_EDITENG_EDITVIEW_HXX
21 : #define INCLUDED_EDITENG_EDITVIEW_HXX
22 :
23 : #include <com/sun/star/i18n/WordType.hpp>
24 :
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>
35 :
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;
57 :
58 : #include <editeng/editdata.hxx>
59 : #include <com/sun/star/uno/Reference.h>
60 : #include <editeng/editengdllapi.h>
61 :
62 : namespace com {
63 : namespace sun {
64 : namespace star {
65 : namespace datatransfer {
66 : class XTransferable;
67 : }
68 : namespace linguistic2 {
69 : class XSpellChecker1;
70 : class XLanguageGuessing;
71 : }
72 : }}}
73 :
74 : class EDITENG_DLLPUBLIC EditView
75 : {
76 : friend class EditEngine;
77 : friend class ImpEditEngine;
78 : friend class EditSelFunctionSet;
79 :
80 : public: // Needed for Undo
81 97 : ImpEditView* GetImpEditView() const { return pImpEditView; }
82 : ImpEditEngine* GetImpEditEngine() const;
83 :
84 : private:
85 : ImpEditView* pImpEditView;
86 : OUString aDicNameSingle;
87 :
88 : EditView( const EditView& ) SAL_DELETED_FUNCTION;
89 : EditView& operator=( const EditView& ) SAL_DELETED_FUNCTION;
90 :
91 : public:
92 : EditView( EditEngine* pEng, vcl::Window* pWindow );
93 : virtual ~EditView();
94 :
95 : void SetEditEngine( EditEngine* pEditEngine );
96 : EditEngine* GetEditEngine() const;
97 :
98 : void SetWindow( vcl::Window* pWin );
99 : vcl::Window* GetWindow() const;
100 :
101 : void Paint( const Rectangle& rRect, OutputDevice* pTargetDevice = 0 );
102 : void Invalidate();
103 : Pair Scroll( long nHorzScroll, long nVertScroll, sal_uInt8 nRangeCheck = RGCHK_NEG );
104 :
105 : void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true );
106 : void HideCursor();
107 :
108 : void SetSelectionMode( EESelectionMode eMode );
109 :
110 : void SetReadOnly( bool bReadOnly );
111 : bool IsReadOnly() const;
112 :
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 );
117 :
118 : bool IsInsertMode() const;
119 : void SetInsertMode( bool bInsert );
120 :
121 : void ReplaceSelected( const OUString& rStr );
122 : OUString GetSelected();
123 : void DeleteSelected();
124 :
125 : SvtScriptType GetSelectedScriptType() const;
126 :
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;
131 :
132 : // Document position.
133 : // A size change also affects the VisArea
134 : void SetVisArea( const Rectangle& rRect );
135 : const Rectangle& GetVisArea() const;
136 :
137 : const Pointer& GetPointer() const;
138 :
139 : vcl::Cursor* GetCursor() const;
140 :
141 : void InsertText( const OUString& rNew, bool bSelect = false );
142 :
143 : bool PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window* pFrameWin = NULL );
144 :
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 );
150 :
151 : void Cut();
152 : void Copy();
153 : void Paste();
154 : void PasteSpecial();
155 :
156 : void Undo();
157 : void Redo();
158 :
159 : // especially for Oliver Specht
160 : Point GetWindowPosTopLeft( sal_Int32 nParagraph );
161 : void MoveParagraphs( Range aParagraphs, sal_Int32 nNewPos );
162 : void MoveParagraphs( long nDiff );
163 :
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 );
170 :
171 : sal_uInt32 Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, bool bSelect = false, SvKeyValueIterator* pHTTPHeaderAttrs = NULL );
172 :
173 : void SetBackgroundColor( const Color& rColor );
174 : Color GetBackgroundColor() const;
175 :
176 : void setTiledRendering(bool bTiledRendering);
177 : bool isTiledRendering();
178 : /// @see vcl::ITiledRenderable::registerCallback().
179 : void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
180 :
181 : void SetControlWord( EVControlBits nWord );
182 : EVControlBits GetControlWord() const;
183 :
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 );
187 :
188 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > GetTransferable();
189 :
190 : // An EditView, so that when TRUE the update will be free from flickering:
191 : void SetEditEngineUpdateMode( bool bUpdate );
192 : void ForceUpdate();
193 :
194 : const SfxStyleSheet* GetStyleSheet() const;
195 : SfxStyleSheet* GetStyleSheet();
196 :
197 : void SetAnchorMode( EVAnchorMode eMode );
198 : EVAnchorMode GetAnchorMode() const;
199 :
200 : void CompleteAutoCorrect( vcl::Window* pFrameWin = NULL );
201 :
202 : EESpellState StartSpeller( bool bMultipleDoc = false );
203 : EESpellState StartThesaurus();
204 : sal_Int32 StartSearchAndReplace( const SvxSearchItem& rSearchItem );
205 :
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 );
209 :
210 : void TransliterateText( sal_Int32 nTransliterationMode );
211 :
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 );
217 :
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;
222 :
223 : const SvxFieldItem* GetFieldAtSelection() const;
224 :
225 : void SetInvalidateMore( sal_uInt16 nPixel );
226 : sal_uInt16 GetInvalidateMore() const;
227 :
228 : // grows or shrinks the font height for the current selection
229 : void ChangeFontSize( bool bGrow, const FontList* pList );
230 :
231 : static bool ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFontList );
232 :
233 : OUString GetSurroundingText() const;
234 : Selection GetSurroundingTextSelection() const;
235 :
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.
239 :
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.
249 : */
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);
257 : };
258 :
259 : #endif // INCLUDED_EDITENG_EDITVIEW_HXX
260 :
261 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|