Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / textview.hxx
blobba96f89dba56815b4ffc0a498a0df0da294c1bbc
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 <vcl/dllapi.h>
26 #include <vcl/dndhelp.hxx>
27 #include <vcl/textdata.hxx>
28 #include <vcl/window.hxx>
29 #include <memory>
31 class TextEngine;
32 class OutputDevice;
34 class KeyEvent;
35 class MouseEvent;
36 class CommandEvent;
37 class TextSelFunctionSet;
38 class SelectionEngine;
39 class VirtualDevice;
40 struct TextDDInfo;
42 namespace com { namespace sun { namespace star {
43 namespace datatransfer { namespace clipboard {
44 class XClipboard;
45 }}}}}
46 namespace i18nutil {
47 struct SearchOptions;
51 struct ImpTextView;
52 class ExtTextEngine;
54 class VCL_DLLPUBLIC TextView : public vcl::unohelper::DragAndDropClient
56 friend class TextEngine;
57 friend class TextUndo;
58 friend class TextUndoManager;
59 friend class TextSelFunctionSet;
61 private:
62 std::unique_ptr<ImpTextView> mpImpl;
64 TextView( const TextView& ) = delete;
65 TextView& operator=( const TextView& ) = delete;
67 protected:
68 bool ImpIndentBlock( bool bRight );
69 void ShowSelection();
70 void HideSelection();
71 void ShowSelection( const TextSelection& rSel );
72 void ImpShowHideSelection( const TextSelection* pRange = nullptr );
74 TextSelection ImpMoveCursor( const KeyEvent& rKeyEvent );
75 TextPaM ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode );
76 bool IsInSelection( const TextPaM& rPaM );
78 void ImpPaint(vcl::RenderContext& rRenderContext, const Point& rStartPos, tools::Rectangle const* pPaintArea, TextSelection const* pSelection);
79 void ImpPaint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
80 void ImpShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bEndKey );
81 void ImpHighlight( const TextSelection& rSel );
82 void ImpSetSelection( const TextSelection& rSelection );
83 Point ImpGetOutputStartPos( const Point& rStartDocPos ) const;
85 void ImpHideDDCursor();
86 void ImpShowDDCursor();
88 bool ImplTruncateNewText( OUString& rNewText ) const;
89 bool ImplCheckTextLen( const OUString& rNewText );
91 // DragAndDropClient
92 virtual void dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& dge ) override;
93 virtual void dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& dsde ) override;
94 virtual void drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override;
95 virtual void dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override;
96 virtual void dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override;
97 virtual void dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override;
99 using DragAndDropClient::dragEnter;
100 using DragAndDropClient::dragExit;
101 using DragAndDropClient::dragOver;
103 public:
104 TextView( ExtTextEngine* pEng, vcl::Window* pWindow );
105 virtual ~TextView() override;
107 TextEngine* GetTextEngine() const;
108 vcl::Window* GetWindow() const;
110 void Invalidate();
111 void Scroll( long nHorzScroll, long nVertScroll );
113 void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true );
114 void HideCursor();
116 void EnableCursor( bool bEnable );
117 bool IsCursorEnabled() const;
119 const TextSelection& GetSelection() const;
120 TextSelection& GetSelection();
121 void SetSelection( const TextSelection& rNewSel );
122 void SetSelection( const TextSelection& rNewSel, bool bGotoCursor );
123 bool HasSelection() const;
125 OUString GetSelected();
126 OUString GetSelected( LineEnd aSeparator );
127 void DeleteSelected();
129 void InsertText( const OUString& rNew );
131 bool KeyInput( const KeyEvent& rKeyEvent );
132 void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
133 void MouseButtonUp( const MouseEvent& rMouseEvent );
134 void MouseButtonDown( const MouseEvent& rMouseEvent );
135 void MouseMove( const MouseEvent& rMouseEvent );
136 void Command( const CommandEvent& rCEvt );
138 void Cut();
139 void Copy();
140 void Paste();
142 void Copy( css::uno::Reference< css::datatransfer::clipboard::XClipboard >& rxClipboard );
143 void Paste( css::uno::Reference< css::datatransfer::clipboard::XClipboard >& rxClipboard );
145 void Undo();
146 void Redo();
148 bool Read( SvStream& rInput );
150 void SetStartDocPos( const Point& rPos );
151 const Point& GetStartDocPos() const;
153 Point GetDocPos( const Point& rWindowPos ) const;
154 Point GetWindowPos( const Point& rDocPos ) const;
156 void SetInsertMode( bool bInsert );
157 bool IsInsertMode() const;
159 void SetAutoIndentMode( bool bAutoIndent );
161 void SetReadOnly( bool bReadOnly );
162 bool IsReadOnly() const;
164 void SetAutoScroll( bool bAutoScroll );
165 bool IsAutoScroll() const;
167 bool SetCursorAtPoint( const Point& rPointPixel );
168 bool IsSelectionAtPoint( const Point& rPointPixel );
170 void SetPaintSelection( bool bPaint);
172 // aus dem protected Teil hierher verschoben
173 // For 'SvtXECTextCursor' (TL). Must ggf nochmal anders gel?st werden.
174 TextPaM PageUp( const TextPaM& rPaM );
175 TextPaM PageDown( const TextPaM& rPaM );
176 TextPaM CursorUp( const TextPaM& rPaM );
177 TextPaM CursorDown( const TextPaM& rPaM );
178 TextPaM CursorLeft( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode );
179 TextPaM CursorRight( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode );
180 TextPaM CursorWordLeft( const TextPaM& rPaM );
181 TextPaM CursorWordRight( const TextPaM& rPaM );
182 TextPaM CursorStartOfLine( const TextPaM& rPaM );
183 TextPaM CursorEndOfLine( const TextPaM& rPaM );
184 static TextPaM CursorStartOfParagraph( const TextPaM& rPaM );
185 TextPaM CursorEndOfParagraph( const TextPaM& rPaM );
186 static TextPaM CursorStartOfDoc();
187 TextPaM CursorEndOfDoc();
190 Drag and Drop, deleting and selection regards all text that has an attribute
191 TEXTATTR_PROTECTED set as one entity. Drag and dropped text is automatically
192 attributed as protected.
194 void SupportProtectAttribute(bool bSupport);
197 Returns the number in paragraph of the line in which the cursor is blinking
198 if enabled, -1 otherwise.
200 sal_Int32 GetLineNumberOfCursorInSelection() const;
202 bool MatchGroup();
204 bool Search( const i18nutil::SearchOptions& rSearchOptions, bool bForward );
205 sal_uInt16 Replace( const i18nutil::SearchOptions& rSearchOptions, bool bAll, bool bForward );
207 bool IndentBlock();
208 bool UnindentBlock();
211 #endif
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */