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 <vcl/cursor.hxx>
30 :
31 : class EditEngine;
32 : class ImpEditEngine;
33 : class ImpEditView;
34 : class SvxSearchItem;
35 : class SvxFieldItem;
36 : namespace vcl { class Window; }
37 : class Pointer;
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 : namespace vcl { 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 156 : 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, vcl::Window* pWindow );
89 : virtual ~EditView();
90 :
91 : void SetEditEngine( EditEngine* pEditEngine );
92 : EditEngine* GetEditEngine() const;
93 :
94 : void SetWindow( vcl::Window* pWin );
95 : vcl::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 : vcl::Cursor* GetCursor() const;
136 :
137 : void InsertText( const OUString& rNew, bool bSelect = false );
138 :
139 : bool PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window* pFrameWin = NULL );
140 :
141 : bool MouseButtonUp( const MouseEvent& rMouseEvent );
142 : bool MouseButtonDown( const MouseEvent& rMouseEvent );
143 : void ReleaseMouse();
144 : bool MouseMove( const MouseEvent& rMouseEvent );
145 : void Command( const CommandEvent& rCEvt );
146 :
147 : void Cut();
148 : void Copy();
149 : void Paste();
150 : void PasteSpecial();
151 :
152 : void Undo();
153 : void Redo();
154 :
155 : // especially for Oliver Specht
156 : Point GetWindowPosTopLeft( sal_Int32 nParagraph );
157 : void MoveParagraphs( Range aParagraphs, sal_Int32 nNewPos );
158 : void MoveParagraphs( long nDiff );
159 :
160 : const SfxItemSet& GetEmptyItemSet();
161 : SfxItemSet GetAttribs();
162 : void SetAttribs( const SfxItemSet& rSet );
163 : void RemoveAttribs( bool bRemoveParaAttribs = false, sal_uInt16 nWhich = 0 );
164 : void RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich = 0 );
165 : void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs = false );
166 :
167 : sal_uInt32 Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, bool bSelect = false, SvKeyValueIterator* pHTTPHeaderAttrs = NULL );
168 :
169 : void SetBackgroundColor( const Color& rColor );
170 : Color GetBackgroundColor() const;
171 :
172 : void SetControlWord( sal_uInt32 nWord );
173 : sal_uInt32 GetControlWord() const;
174 :
175 : EditTextObject* CreateTextObject();
176 : void InsertText( const EditTextObject& rTextObject );
177 : void InsertText( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xDataObj, const OUString& rBaseURL, bool bUseSpecial );
178 :
179 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > GetTransferable();
180 :
181 : // An EditView, so that when TRUE the update will be free from flickering:
182 : void SetEditEngineUpdateMode( bool bUpdate );
183 : void ForceUpdate();
184 :
185 : const SfxStyleSheet* GetStyleSheet() const;
186 : SfxStyleSheet* GetStyleSheet();
187 :
188 : void SetAnchorMode( EVAnchorMode eMode );
189 : EVAnchorMode GetAnchorMode() const;
190 :
191 : void CompleteAutoCorrect( vcl::Window* pFrameWin = NULL );
192 :
193 : EESpellState StartSpeller( bool bMultipleDoc = false );
194 : EESpellState StartThesaurus();
195 : sal_Int32 StartSearchAndReplace( const SvxSearchItem& rSearchItem );
196 :
197 : // for text conversion
198 : void StartTextConversion( LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc );
199 : bool HasConvertibleTextPortion( LanguageType nLang );
200 :
201 : void TransliterateText( sal_Int32 nTransliterationMode );
202 :
203 : bool IsCursorAtWrongSpelledWord( bool bMarkIfWrong = false );
204 : bool IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong = false );
205 : bool IsShapeParaFocusable();
206 : bool WrongSpelledBreakPara(sal_Int32 nPara, sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nIndex);
207 : void ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack = 0 );
208 :
209 : void InsertField( const SvxFieldItem& rFld );
210 : const SvxFieldItem* GetFieldUnderMousePointer() const;
211 : const SvxFieldItem* GetFieldUnderMousePointer( sal_Int32& nPara, sal_Int32& nPos ) const;
212 : const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pnPara = NULL, sal_Int32* pnPos = NULL ) const;
213 :
214 : const SvxFieldItem* GetFieldAtSelection() const;
215 :
216 : void SetInvalidateMore( sal_uInt16 nPixel );
217 : sal_uInt16 GetInvalidateMore() const;
218 :
219 : // grows or shrinks the font height for the current selection
220 : void ChangeFontSize( bool bGrow, const FontList* pList );
221 :
222 : static bool ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFontList );
223 :
224 : OUString GetSurroundingText() const;
225 : Selection GetSurroundingTextSelection() const;
226 :
227 : /** Tries to determine the language of 'rText', returning a matching known
228 : locale if possible, or a fallback, or LANGUAGE_NONE if nothing found or
229 : matched.
230 :
231 : @param bIsParaText
232 : If TRUE, rText is a paragraph and the language is obtained by
233 : passing the text to xLangGuess.
234 : IF FALSE, a language match is tried for, in order,
235 : 1. the default document language (non-CTL, non-CJK, aka LATIN)
236 : 2. the UI language (Tools->Options->LanguageSettings->Languages User Interface)
237 : 3. the locale (Tools->Options->LanguageSettings->Languages Locale)
238 : 4. en-US
239 : If nothing matched, LANGUAGE_NONE is returned.
240 : */
241 : static LanguageType CheckLanguage(
242 : const OUString &rText,
243 : com::sun::star::uno::Reference< com::sun::star::linguistic2::XSpellChecker1 > xSpell,
244 : com::sun::star::uno::Reference< com::sun::star::linguistic2::XLanguageGuessing > xLangGuess,
245 : bool bIsParaText );
246 : };
247 :
248 : #endif // INCLUDED_EDITENG_EDITVIEW_HXX
249 :
250 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|