cool#6580 sw: fix infinite loop when changing document language
[LibreOffice.git] / include / vcl / textview.hxx
blob3de25b5acb0d77781d0d9ceb3a4ea5b6a4c51a7c
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 .
20 #ifndef INCLUDED_VCL_TEXTVIEW_HXX
21 #define INCLUDED_VCL_TEXTVIEW_HXX
23 #include <tools/gen.hxx>
24 #include <tools/lineend.hxx>
25 #include <tools/stream.hxx>
26 #include <vcl/dllapi.h>
27 #include <vcl/dndhelp.hxx>
28 #include <vcl/textdata.hxx>
29 #include <vcl/outdev.hxx>
30 #include <memory>
32 class TextEngine;
34 class KeyEvent;
35 class MouseEvent;
36 class CommandEvent;
37 namespace vcl { class Window; }
39 namespace com { namespace sun { namespace star {
40 namespace datatransfer { namespace clipboard {
41 class XClipboard;
42 }}}}}
43 namespace i18nutil {
44 struct SearchOptions;
48 struct ImpTextView;
49 class ExtTextEngine;
51 class VCL_DLLPUBLIC TETextDataObject final : public css::datatransfer::XTransferable,
52 public ::cppu::OWeakObject
55 private:
56 OUString maText;
57 SvMemoryStream maHTMLStream;
59 public:
60 explicit TETextDataObject( const OUString& rText );
62 OUString& GetText() { return maText; }
63 SvMemoryStream& GetHTMLStream() { return maHTMLStream; }
65 // css::uno::XInterface
66 css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
67 void SAL_CALL acquire() throw() override { OWeakObject::acquire(); }
68 void SAL_CALL release() throw() override { OWeakObject::release(); }
70 // css::datatransfer::XTransferable
71 css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override;
72 css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override;
73 sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override;
77 class VCL_DLLPUBLIC TextView final : public vcl::unohelper::DragAndDropClient
79 friend class TextEngine;
80 friend class TextUndo;
81 friend class TextUndoManager;
82 friend class TextSelFunctionSet;
84 std::unique_ptr<ImpTextView> mpImpl;
86 TextView( const TextView& ) = delete;
87 TextView& operator=( const TextView& ) = delete;
89 bool ImpIndentBlock( bool bRight );
90 void ShowSelection();
91 void HideSelection();
92 void ShowSelection( const TextSelection& rSel );
93 void ImpShowHideSelection( const TextSelection* pRange = nullptr );
95 TextSelection const & ImpMoveCursor( const KeyEvent& rKeyEvent );
96 TextPaM ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode );
97 bool IsInSelection( const TextPaM& rPaM );
99 void ImpPaint(vcl::RenderContext& rRenderContext, const Point& rStartPos, tools::Rectangle const* pPaintArea, TextSelection const* pSelection);
100 void ImpPaint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
101 void ImpShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bEndKey );
102 void ImpHighlight( const TextSelection& rSel );
103 void ImpSetSelection( const TextSelection& rSelection );
104 Point ImpGetOutputStartPos( const Point& rStartDocPos ) const;
106 void ImpHideDDCursor();
107 void ImpShowDDCursor();
109 bool ImplTruncateNewText( OUString& rNewText ) const;
110 bool ImplCheckTextLen( const OUString& rNewText );
112 // DragAndDropClient
113 virtual void dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& dge ) override;
114 virtual void dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& dsde ) override;
115 virtual void drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override;
116 virtual void dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override;
117 virtual void dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override;
118 virtual void dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override;
120 using DragAndDropClient::dragEnter;
121 using DragAndDropClient::dragExit;
122 using DragAndDropClient::dragOver;
124 public:
125 TextView( ExtTextEngine* pEng, vcl::Window* pWindow );
126 virtual ~TextView() override;
128 TextEngine* GetTextEngine() const;
129 vcl::Window* GetWindow() const;
131 void Invalidate();
132 void Scroll( long nHorzScroll, long nVertScroll );
134 void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true );
135 void HideCursor();
137 void EnableCursor( bool bEnable );
138 bool IsCursorEnabled() const;
140 const TextSelection& GetSelection() const;
141 TextSelection& GetSelection();
142 void SetSelection( const TextSelection& rNewSel );
143 void SetSelection( const TextSelection& rNewSel, bool bGotoCursor );
144 bool HasSelection() const;
146 OUString GetSelected();
147 OUString GetSelected( LineEnd aSeparator );
148 void DeleteSelected();
150 void InsertText( const OUString& rNew );
152 bool KeyInput( const KeyEvent& rKeyEvent );
153 void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
154 void MouseButtonUp( const MouseEvent& rMouseEvent );
155 void MouseButtonDown( const MouseEvent& rMouseEvent );
156 void MouseMove( const MouseEvent& rMouseEvent );
157 void Command( const CommandEvent& rCEvt );
159 void Cut();
160 void Copy();
161 void Paste();
163 void Copy( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard );
164 void Paste( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard );
166 void Undo();
167 void Redo();
169 void Read( SvStream& rInput );
171 void SetStartDocPos( const Point& rPos );
172 const Point& GetStartDocPos() const;
174 Point GetDocPos( const Point& rWindowPos ) const;
175 Point GetWindowPos( const Point& rDocPos ) const;
177 void SetInsertMode( bool bInsert );
178 bool IsInsertMode() const;
180 void SetAutoIndentMode( bool bAutoIndent );
182 void SetReadOnly( bool bReadOnly );
183 bool IsReadOnly() const;
185 void SetAutoScroll( bool bAutoScroll );
186 bool IsAutoScroll() const;
188 void SetCursorAtPoint( const Point& rPointPixel );
189 bool IsSelectionAtPoint( const Point& rPointPixel );
191 void SetPaintSelection( bool bPaint);
193 // Moved in here from the protected part.
194 // For 'SvtXECTextCursor' (TL). Possibly needs to be solved again differently.
195 TextPaM PageUp( const TextPaM& rPaM );
196 TextPaM PageDown( const TextPaM& rPaM );
197 TextPaM CursorUp( const TextPaM& rPaM );
198 TextPaM CursorDown( const TextPaM& rPaM );
199 TextPaM CursorLeft( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode );
200 TextPaM CursorRight( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode );
201 TextPaM CursorWordLeft( const TextPaM& rPaM );
202 TextPaM CursorWordRight( const TextPaM& rPaM );
203 TextPaM CursorStartOfLine( const TextPaM& rPaM );
204 TextPaM CursorEndOfLine( const TextPaM& rPaM );
205 static TextPaM CursorStartOfParagraph( const TextPaM& rPaM );
206 TextPaM CursorEndOfParagraph( const TextPaM& rPaM );
207 static TextPaM CursorStartOfDoc();
208 TextPaM CursorEndOfDoc();
211 Returns the number in paragraph of the line in which the cursor is blinking
212 if enabled, -1 otherwise.
214 sal_Int32 GetLineNumberOfCursorInSelection() const;
216 void MatchGroup();
218 // tdf#49482: Moves the start of the PaM to the center of the textview
219 void CenterPaM( const TextPaM& rPaM );
221 bool Search( const i18nutil::SearchOptions& rSearchOptions, bool bForward );
222 sal_uInt16 Replace( const i18nutil::SearchOptions& rSearchOptions, bool bAll, bool bForward );
224 bool IndentBlock();
225 bool UnindentBlock();
228 #endif
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */