nss: upgrade to release 3.73
[LibreOffice.git] / include / vcl / textview.hxx
blobd913dfd99c0a332ed3a5dcfee2521f5ebc12784b
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 <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>
33 class TextEngine;
35 class KeyEvent;
36 class MouseEvent;
37 class CommandEvent;
38 namespace vcl { class Window; }
40 namespace com::sun::star::datatransfer::clipboard {
41 class XClipboard;
43 namespace i18nutil {
44 struct SearchOptions;
48 struct ImpTextView;
49 class ExtTextEngine;
51 class UNLESS_MERGELIBS(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 SvMemoryStream& GetHTMLStream() { return maHTMLStream; }
64 // css::uno::XInterface
65 css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
66 void SAL_CALL acquire() throw() override { OWeakObject::acquire(); }
67 void SAL_CALL release() throw() override { OWeakObject::release(); }
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;
76 class VCL_DLLPUBLIC TextView final : public vcl::unohelper::DragAndDropClient
78 friend class TextEngine;
79 friend class TextUndo;
80 friend class TextUndoManager;
81 friend class TextSelFunctionSet;
83 std::unique_ptr<ImpTextView> mpImpl;
85 TextView( const TextView& ) = delete;
86 TextView& operator=( const TextView& ) = delete;
88 bool ImpIndentBlock( bool bRight );
89 void ShowSelection();
90 void HideSelection();
91 void ShowSelection( const TextSelection& rSel );
92 void ImpShowHideSelection( const TextSelection* pRange = nullptr );
94 TextSelection const & ImpMoveCursor( const KeyEvent& rKeyEvent );
95 TextPaM ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode );
96 bool IsInSelection( const TextPaM& rPaM );
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 ImpHighlight( const TextSelection& rSel );
102 void ImpSetSelection( const TextSelection& rSelection );
103 Point ImpGetOutputStartPos( const Point& rStartDocPos ) const;
105 void ImpHideDDCursor();
106 void ImpShowDDCursor();
108 bool ImplTruncateNewText( OUString& rNewText ) const;
109 bool ImplCheckTextLen( const OUString& rNewText );
111 // DragAndDropClient
112 virtual void dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& dge ) override;
113 virtual void dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& dsde ) override;
114 virtual void drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override;
115 virtual void dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override;
116 virtual void dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override;
117 virtual void dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override;
119 using DragAndDropClient::dragEnter;
120 using DragAndDropClient::dragExit;
121 using DragAndDropClient::dragOver;
123 public:
124 TextView( ExtTextEngine* pEng, vcl::Window* pWindow );
125 virtual ~TextView() override;
127 TextEngine* GetTextEngine() const;
128 vcl::Window* GetWindow() const;
130 void Invalidate();
131 void Scroll( tools::Long nHorzScroll, tools::Long nVertScroll );
133 void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true );
134 void HideCursor();
136 void EnableCursor( bool bEnable );
137 bool IsCursorEnabled() const;
139 const TextSelection& GetSelection() const;
140 TextSelection& GetSelection();
141 void SetSelection( const TextSelection& rNewSel );
142 void SetSelection( const TextSelection& rNewSel, bool bGotoCursor );
143 bool HasSelection() const;
145 OUString GetSelected();
146 OUString GetSelected( LineEnd aSeparator );
147 void DeleteSelected();
149 void InsertText( const OUString& rNew );
151 bool KeyInput( const KeyEvent& rKeyEvent );
152 void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
153 void MouseButtonUp( const MouseEvent& rMouseEvent );
154 void MouseButtonDown( const MouseEvent& rMouseEvent );
155 void MouseMove( const MouseEvent& rMouseEvent );
156 void Command( const CommandEvent& rCEvt );
158 void Cut();
159 void Copy();
160 void Paste();
162 void Copy( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard );
163 void Paste( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard );
165 void Undo();
166 void Redo();
168 void Read( SvStream& rInput );
170 void SetStartDocPos( const Point& rPos );
171 const Point& GetStartDocPos() const;
173 Point GetDocPos( const Point& rWindowPos ) const;
174 Point GetWindowPos( const Point& rDocPos ) const;
176 void SetInsertMode( bool bInsert );
177 bool IsInsertMode() const;
179 void SetAutoIndentMode( bool bAutoIndent );
181 void SetReadOnly( bool bReadOnly );
182 bool IsReadOnly() const;
184 void SetAutoScroll( bool bAutoScroll );
185 bool IsAutoScroll() const;
187 void SetCursorAtPoint( const Point& rPointPixel );
188 bool IsSelectionAtPoint( const Point& rPointPixel );
190 void SetPaintSelection( bool bPaint);
192 // Moved in here from the protected part.
193 // For 'SvtXECTextCursor' (TL). Possibly needs to be solved again differently.
194 TextPaM PageUp( const TextPaM& rPaM );
195 TextPaM PageDown( const TextPaM& rPaM );
196 TextPaM CursorUp( const TextPaM& rPaM );
197 TextPaM CursorDown( const TextPaM& rPaM );
198 TextPaM CursorLeft( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode );
199 TextPaM CursorRight( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode );
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();
210 Returns the number in paragraph of the line in which the cursor is blinking
211 if enabled, -1 otherwise.
213 sal_Int32 GetLineNumberOfCursorInSelection() const;
215 void MatchGroup();
217 // tdf#49482: Moves the start of the PaM to the center of the textview
218 void CenterPaM( const TextPaM& rPaM );
220 bool Search( const i18nutil::SearchOptions& rSearchOptions, bool bForward );
221 sal_uInt16 Replace( const i18nutil::SearchOptions& rSearchOptions, bool bAll, bool bForward );
223 bool IndentBlock();
224 bool UnindentBlock();
227 #endif
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */