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 :
30 : class EditEngine;
31 : class ImpEditEngine;
32 : class ImpEditView;
33 : class SvxSearchItem;
34 : class SvxFieldItem;
35 : class Window;
36 : class Pointer;
37 : class Cursor;
38 : class KeyEvent;
39 : class MouseEvent;
40 : class DropEvent;
41 : class CommandEvent;
42 : class Rectangle;
43 : class Link;
44 : class Pair;
45 : class Point;
46 : class Range;
47 : class SvStream;
48 : class SvKeyValueIterator;
49 : class SfxStyleSheet;
50 : class Font;
51 : class FontList;
52 : class OutputDevice;
53 :
54 : #include <editeng/editdata.hxx>
55 : #include <com/sun/star/uno/Reference.h>
56 : #include <editeng/editengdllapi.h>
57 :
58 : namespace com {
59 : namespace sun {
60 : namespace star {
61 : namespace datatransfer {
62 : class XTransferable;
63 : }
64 : namespace linguistic2 {
65 : class XSpellChecker1;
66 : class XLanguageGuessing;
67 : }
68 : }}}
69 :
70 : class EDITENG_DLLPUBLIC EditView
71 : {
72 : friend class EditEngine;
73 : friend class ImpEditEngine;
74 : friend class EditSelFunctionSet;
75 :
76 : public: // Needed for Undo
77 0 : ImpEditView* GetImpEditView() const { return pImpEditView; }
78 : ImpEditEngine* GetImpEditEngine() const;
79 :
80 : private:
81 : ImpEditView* pImpEditView;
82 : OUString aDicNameSingle;
83 :
84 : EDITENG_DLLPRIVATE EditView( const EditView& );
85 : EDITENG_DLLPRIVATE EditView& operator=( const EditView& );
86 :
87 : public:
88 : EditView( EditEngine* pEng, Window* pWindow );
89 : virtual ~EditView();
90 :
91 : void SetEditEngine( EditEngine* pEditEngine );
92 : EditEngine* GetEditEngine() const;
93 :
94 : void SetWindow( Window* pWin );
95 : Window* GetWindow() const;
96 :
97 : void Paint( const Rectangle& rRect, OutputDevice* pTargetDevice = 0 );
98 : void Invalidate();
99 : Pair Scroll( long nHorzScroll, long nVertScroll, sal_uInt8 nRangeCheck = RGCHK_NEG );
100 :
101 : void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true );
102 : void HideCursor();
103 :
104 : void SetSelectionMode( EESelectionMode eMode );
105 :
106 : void SetReadOnly( bool bReadOnly );
107 : bool IsReadOnly() const;
108 :
109 : bool HasSelection() const;
110 : ESelection GetSelection() const;
111 : void SetSelection( const ESelection& rNewSel );
112 : bool SelectCurrentWord( sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
113 :
114 : bool IsInsertMode() const;
115 : void SetInsertMode( bool bInsert );
116 :
117 : void ReplaceSelected( const OUString& rStr );
118 : OUString GetSelected();
119 : void DeleteSelected();
120 :
121 : sal_uInt16 GetSelectedScriptType() const;
122 :
123 : // VisArea position of the Output window.
124 : // A size change also affects the VisArea
125 : void SetOutputArea( const Rectangle& rRect );
126 : const Rectangle& GetOutputArea() const;
127 :
128 : // Document position.
129 : // A size change also affects the VisArea
130 : void SetVisArea( const Rectangle& rRect );
131 : const Rectangle& GetVisArea() const;
132 :
133 : const Pointer& GetPointer() const;
134 :
135 : Cursor* GetCursor() const;
136 :
137 : void InsertText( const OUString& rNew, bool bSelect = false );
138 :
139 : bool PostKeyEvent( const KeyEvent& rKeyEvent, Window* pFrameWin = NULL );
140 :
141 : bool MouseButtonUp( const MouseEvent& rMouseEvent );
142 : bool MouseButtonDown( const MouseEvent& rMouseEvent );
143 : bool MouseMove( const MouseEvent& rMouseEvent );
144 : void Command( const CommandEvent& rCEvt );
145 :
146 : void Cut();
147 : void Copy();
148 : void Paste();
149 : void PasteSpecial();
150 :
151 : void Undo();
152 : void Redo();
153 :
154 : // especially for Oliver Specht
155 : Point GetWindowPosTopLeft( sal_Int32 nParagraph );
156 : void MoveParagraphs( Range aParagraphs, sal_Int32 nNewPos );
157 : void MoveParagraphs( long nDiff );
158 :
159 : const SfxItemSet& GetEmptyItemSet();
160 : SfxItemSet GetAttribs();
161 : void SetAttribs( const SfxItemSet& rSet );
162 : void RemoveAttribs( bool bRemoveParaAttribs = false, sal_uInt16 nWhich = 0 );
163 : void RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich = 0 );
164 : void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs = false );
165 :
166 : sal_uInt32 Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, bool bSelect = false, SvKeyValueIterator* pHTTPHeaderAttrs = NULL );
167 :
168 : void SetBackgroundColor( const Color& rColor );
169 : Color GetBackgroundColor() const;
170 :
171 : void SetControlWord( sal_uInt32 nWord );
172 : sal_uInt32 GetControlWord() const;
173 :
174 : EditTextObject* CreateTextObject();
175 : void InsertText( const EditTextObject& rTextObject );
176 : void InsertText( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xDataObj, const OUString& rBaseURL, bool bUseSpecial );
177 :
178 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > GetTransferable();
179 :
180 : // An EditView, so that when TRUE the update will be free from flickering:
181 : void SetEditEngineUpdateMode( bool bUpdate );
182 : void ForceUpdate();
183 :
184 : const SfxStyleSheet* GetStyleSheet() const;
185 : SfxStyleSheet* GetStyleSheet();
186 :
187 : void SetAnchorMode( EVAnchorMode eMode );
188 : EVAnchorMode GetAnchorMode() const;
189 :
190 : void CompleteAutoCorrect( Window* pFrameWin = NULL );
191 :
192 : EESpellState StartSpeller( bool bMultipleDoc = false );
193 : EESpellState StartThesaurus();
194 : sal_Int32 StartSearchAndReplace( const SvxSearchItem& rSearchItem );
195 :
196 : // for text conversion
197 : void StartTextConversion( LanguageType nSrcLang, LanguageType nDestLang, const Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc );
198 : bool HasConvertibleTextPortion( LanguageType nLang );
199 :
200 : void TransliterateText( sal_Int32 nTransliterationMode );
201 :
202 : bool IsCursorAtWrongSpelledWord( bool bMarkIfWrong = false );
203 : bool IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong = false );
204 : bool IsShapeParaFocusable();
205 : bool WrongSpelledBreakPara(sal_Int32 nPara, sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nIndex);
206 : void ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack = 0 );
207 :
208 : void InsertField( const SvxFieldItem& rFld );
209 : const SvxFieldItem* GetFieldUnderMousePointer() const;
210 : const SvxFieldItem* GetFieldUnderMousePointer( sal_Int32& nPara, sal_Int32& nPos ) const;
211 : const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pnPara = NULL, sal_Int32* pnPos = NULL ) const;
212 :
213 : const SvxFieldItem* GetFieldAtSelection() const;
214 :
215 : void SetInvalidateMore( sal_uInt16 nPixel );
216 : sal_uInt16 GetInvalidateMore() const;
217 :
218 : // grows or shrinks the font height for the current selection
219 : void ChangeFontSize( bool bGrow, const FontList* pList );
220 :
221 : static bool ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFontList );
222 :
223 : OUString GetSurroundingText() const;
224 : Selection GetSurroundingTextSelection() const;
225 :
226 : /** Tries to determine the language of 'rText', returning a matching known
227 : locale if possible, or a fallback, or LANGUAGE_NONE if nothing found or
228 : matched.
229 :
230 : @param bIsParaText
231 : If TRUE, rText is a paragraph and the language is obtained by
232 : passing the text to xLangGuess.
233 : IF FALSE, a language match is tried for, in order,
234 : 1. the default document language (non-CTL, non-CJK, aka LATIN)
235 : 2. the UI language (Tools->Options->LanguageSettings->Languages User Interface)
236 : 3. the locale (Tools->Options->LanguageSettings->Languages Locale)
237 : 4. en-US
238 : If nothing matched, LANGUAGE_NONE is returned.
239 : */
240 : static LanguageType CheckLanguage(
241 : const OUString &rText,
242 : com::sun::star::uno::Reference< com::sun::star::linguistic2::XSpellChecker1 > xSpell,
243 : com::sun::star::uno::Reference< com::sun::star::linguistic2::XLanguageGuessing > xLangGuess,
244 : bool bIsParaText );
245 : };
246 :
247 : #endif // INCLUDED_EDITENG_EDITVIEW_HXX
248 :
249 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|