LibreOffice Module vcl (master) 1
textview.hxx
Go to the documentation of this file.
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
20#ifndef INCLUDED_VCL_TEXTVIEW_HXX
21#define INCLUDED_VCL_TEXTVIEW_HXX
22
23#include <config_options.h>
24#include <tools/gen.hxx>
25#include <tools/lineend.hxx>
26#include <tools/stream.hxx>
27#include <vcl/dllapi.h>
28#include <vcl/dndhelp.hxx>
29#include <vcl/textdata.hxx>
30#include <vcl/outdev.hxx>
31#include <memory>
32
33class TextEngine;
34
35class KeyEvent;
36class MouseEvent;
37class CommandEvent;
38namespace vcl { class Window; }
39
41 class XClipboard;
42}
43namespace i18nutil {
44 struct SearchOptions2;
45}
46
47
48struct ImpTextView;
49class ExtTextEngine;
50
51class UNLESS_MERGELIBS(VCL_DLLPUBLIC) TETextDataObject final : public css::datatransfer::XTransferable,
53
54{
55private:
56 OUString maText;
57 SvMemoryStream maHTMLStream;
58
59public:
60 explicit TETextDataObject( OUString aText );
61
62 SvMemoryStream& GetHTMLStream() { return maHTMLStream; }
63
64 // css::uno::XInterface
65 css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
66 void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); }
67 void SAL_CALL release() noexcept override { OWeakObject::release(); }
68
69 // css::datatransfer::XTransferable
70 css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override;
71 css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override;
72 sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override;
73};
74
75
77{
78 friend class TextEngine;
79 friend class TextUndo;
80 friend class TextUndoManager;
81 friend class TextSelFunctionSet;
82
83 std::unique_ptr<ImpTextView> mpImpl;
84
85 TextView( const TextView& ) = delete;
86 TextView& operator=( const TextView& ) = delete;
87
88 bool ImpIndentBlock( bool bRight );
89 void ShowSelection();
90 void HideSelection();
91 void ShowSelection( const TextSelection& rSel );
92 void ImpShowHideSelection( const TextSelection* pRange = nullptr );
93
94 TextSelection const & ImpMoveCursor( const KeyEvent& rKeyEvent );
95 TextPaM ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode );
96 bool IsInSelection( const TextPaM& rPaM ) const;
97
98 void ImpPaint(vcl::RenderContext& rRenderContext, const Point& rStartPos, tools::Rectangle const* pPaintArea, TextSelection const* pSelection);
99 void ImpPaint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
100 void ImpShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bEndKey );
101 void ImpSetSelection( const TextSelection& rSelection );
102 Point ImpGetOutputStartPos( const Point& rStartDocPos ) const;
103
104 void ImpHideDDCursor();
105 void ImpShowDDCursor();
106
107 bool ImplTruncateNewText( OUString& rNewText ) const;
108 bool ImplCheckTextLen( std::u16string_view rNewText ) const;
109
110 // DragAndDropClient
111 virtual void dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& dge ) override;
112 virtual void dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& dsde ) override;
113 virtual void drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override;
114 virtual void dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override;
115 virtual void dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override;
116 virtual void dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override;
117
118 using DragAndDropClient::dragEnter;
119 using DragAndDropClient::dragExit;
120 using DragAndDropClient::dragOver;
121
122public:
123 TextView( ExtTextEngine* pEng, vcl::Window* pWindow );
124 virtual ~TextView() override;
125
126 TextEngine* GetTextEngine() const;
127 vcl::Window* GetWindow() const;
128
129 void Invalidate();
130 void Scroll( tools::Long nHorzScroll, tools::Long nVertScroll );
131
132 void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true );
133 void HideCursor();
134
135 void EnableCursor( bool bEnable );
136 bool IsCursorEnabled() const;
137
138 const TextSelection& GetSelection() const;
140 void SetSelection( const TextSelection& rNewSel );
141 void SetSelection( const TextSelection& rNewSel, bool bGotoCursor );
142 bool HasSelection() const;
143
144 OUString GetSelected() const;
145 OUString GetSelected( LineEnd aSeparator ) const;
146 void DeleteSelected();
147
148 void InsertText( const OUString& rNew );
149
150 bool KeyInput( const KeyEvent& rKeyEvent );
151 void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
152 void MouseButtonUp( const MouseEvent& rMouseEvent );
153 void MouseButtonDown( const MouseEvent& rMouseEvent );
154 void MouseMove( const MouseEvent& rMouseEvent );
155 void Command( const CommandEvent& rCEvt );
156
157 void Cut();
158 void Copy();
159 void Paste();
160
161 void Copy( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard );
162 void Paste( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard );
163
164 void Undo();
165 void Redo();
166
167 void Read( SvStream& rInput );
168
169 void SetStartDocPos( const Point& rPos );
170 const Point& GetStartDocPos() const;
171
172 Point GetDocPos( const Point& rWindowPos ) const;
173 Point GetWindowPos( const Point& rDocPos ) const;
174
175 void SetInsertMode( bool bInsert );
176 bool IsInsertMode() const;
177
178 void SetAutoIndentMode( bool bAutoIndent );
179
180 void SetReadOnly( bool bReadOnly );
181 bool IsReadOnly() const;
182
183 void SetAutoScroll( bool bAutoScroll );
184 bool IsAutoScroll() const;
185
186 void SetCursorAtPoint( const Point& rPointPixel );
187 bool IsSelectionAtPoint( const Point& rPointPixel );
188
189 void SetPaintSelection( bool bPaint);
190
191 // Moved in here from the protected part.
192 // For 'SvtXECTextCursor' (TL). Possibly needs to be solved again differently.
193 TextPaM PageUp( const TextPaM& rPaM );
194 TextPaM PageDown( const TextPaM& rPaM );
195 TextPaM CursorUp( const TextPaM& rPaM );
196 TextPaM CursorDown( const TextPaM& rPaM );
197 TextPaM CursorLeft( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode );
198 TextPaM CursorRight( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode );
199 TextPaM CursorFirstWord( const TextPaM& rPaM );
200 TextPaM CursorWordLeft( const TextPaM& rPaM );
201 TextPaM CursorWordRight( const TextPaM& rPaM );
202 TextPaM CursorStartOfLine( const TextPaM& rPaM );
203 TextPaM CursorEndOfLine( const TextPaM& rPaM );
204 static TextPaM CursorStartOfParagraph( const TextPaM& rPaM );
205 TextPaM CursorEndOfParagraph( const TextPaM& rPaM );
206 static TextPaM CursorStartOfDoc();
207 TextPaM CursorEndOfDoc();
208
213 sal_Int32 GetLineNumberOfCursorInSelection() const;
214
215 void MatchGroup();
216
217 // tdf#49482: Moves the start of the PaM to the center of the textview
218 void CenterPaM( const TextPaM& rPaM );
219
220 bool Search( const i18nutil::SearchOptions2& rSearchOptions, bool bForward );
221 sal_uInt16 Replace( const i18nutil::SearchOptions2& rSearchOptions, bool bAll, bool bForward );
222
223 bool IndentBlock();
224 bool UnindentBlock();
225};
226
227#endif
228
229/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Text maText
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
virtual bool IsSelectionAtPoint(const Point &rPointPixel) override
Definition: textview.cxx:2001
virtual void SetCursorAtPoint(const Point &rPointPixel, bool bDontSelectAtCursor=false) override
Definition: textview.cxx:1996
std::unique_ptr< ImpTextView > mpImpl
Definition: textview.hxx:83
TextView(const TextView &)=delete
TextView & operator=(const TextView &)=delete
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) SAL_OVERRIDE
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
LineEnd
long Long
@ MouseButtonDown
unsigned char sal_uInt8
unsigned char sal_Bool
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept