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 
33 class TextEngine;
34 
35 class KeyEvent;
36 class MouseEvent;
37 class CommandEvent;
38 namespace vcl { class Window; }
39 
41  class XClipboard;
42 }
43 namespace i18nutil {
44  struct SearchOptions;
45 }
46 
47 
48 struct ImpTextView;
49 class ExtTextEngine;
50 
51 class UNLESS_MERGELIBS(VCL_DLLPUBLIC) TETextDataObject final : public css::datatransfer::XTransferable,
52  public ::cppu::OWeakObject
53 
54 {
55 private:
56  OUString maText;
57  SvMemoryStream maHTMLStream;
58 
59 public:
60  explicit TETextDataObject( const OUString& rText );
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() throw() override { OWeakObject::acquire(); }
67  void SAL_CALL release() throw() 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 );
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( const OUString& rNewText );
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 
122 public:
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();
145  OUString GetSelected( LineEnd aSeparator );
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 CursorWordLeft( const TextPaM& rPaM );
200  TextPaM CursorWordRight( const TextPaM& rPaM );
201  TextPaM CursorStartOfLine( const TextPaM& rPaM );
202  TextPaM CursorEndOfLine( const TextPaM& rPaM );
203  static TextPaM CursorStartOfParagraph( const TextPaM& rPaM );
204  TextPaM CursorEndOfParagraph( const TextPaM& rPaM );
205  static TextPaM CursorStartOfDoc();
206  TextPaM CursorEndOfDoc();
207 
212  sal_Int32 GetLineNumberOfCursorInSelection() const;
213 
214  void MatchGroup();
215 
216  // tdf#49482: Moves the start of the PaM to the center of the textview
217  void CenterPaM( const TextPaM& rPaM );
218 
219  bool Search( const i18nutil::SearchOptions& rSearchOptions, bool bForward );
220  sal_uInt16 Replace( const i18nutil::SearchOptions& rSearchOptions, bool bAll, bool bForward );
221 
222  bool IndentBlock();
223  bool UnindentBlock();
224 };
225 
226 #endif
227 
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder)
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
virtual void SetCursorAtPoint(const Point &rPointPixel, bool bDontSelectAtCursor=false) override
Definition: textview.cxx:1974
virtual void SAL_CALL acquire() SAL_OVERRIDE
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:303
unsigned char sal_Bool
std::unique_ptr< ImpTextView > mpImpl
Definition: textview.hxx:83
virtual bool IsSelectionAtPoint(const Point &rPointPixel) override
Definition: textview.cxx:1979
LineEnd
Text maText
unsigned char sal_uInt8
virtual void SAL_CALL release() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) SAL_OVERRIDE