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 ImpHighlight( const TextSelection& rSel );
102  void ImpSetSelection( const TextSelection& rSelection );
103  Point ImpGetOutputStartPos( const Point& rStartDocPos ) const;
104 
105  void ImpHideDDCursor();
106  void ImpShowDDCursor();
107 
108  bool ImplTruncateNewText( OUString& rNewText ) const;
109  bool ImplCheckTextLen( const OUString& rNewText );
110 
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;
118 
119  using DragAndDropClient::dragEnter;
120  using DragAndDropClient::dragExit;
121  using DragAndDropClient::dragOver;
122 
123 public:
124  TextView( ExtTextEngine* pEng, vcl::Window* pWindow );
125  virtual ~TextView() override;
126 
127  TextEngine* GetTextEngine() const;
128  vcl::Window* GetWindow() const;
129 
130  void Invalidate();
131  void Scroll( long nHorzScroll, long nVertScroll );
132 
133  void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true );
134  void HideCursor();
135 
136  void EnableCursor( bool bEnable );
137  bool IsCursorEnabled() const;
138 
139  const TextSelection& GetSelection() const;
141  void SetSelection( const TextSelection& rNewSel );
142  void SetSelection( const TextSelection& rNewSel, bool bGotoCursor );
143  bool HasSelection() const;
144 
145  OUString GetSelected();
146  OUString GetSelected( LineEnd aSeparator );
147  void DeleteSelected();
148 
149  void InsertText( const OUString& rNew );
150 
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 );
157 
158  void Cut();
159  void Copy();
160  void Paste();
161 
162  void Copy( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard );
163  void Paste( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard );
164 
165  void Undo();
166  void Redo();
167 
168  void Read( SvStream& rInput );
169 
170  void SetStartDocPos( const Point& rPos );
171  const Point& GetStartDocPos() const;
172 
173  Point GetDocPos( const Point& rWindowPos ) const;
174  Point GetWindowPos( const Point& rDocPos ) const;
175 
176  void SetInsertMode( bool bInsert );
177  bool IsInsertMode() const;
178 
179  void SetAutoIndentMode( bool bAutoIndent );
180 
181  void SetReadOnly( bool bReadOnly );
182  bool IsReadOnly() const;
183 
184  void SetAutoScroll( bool bAutoScroll );
185  bool IsAutoScroll() const;
186 
187  void SetCursorAtPoint( const Point& rPointPixel );
188  bool IsSelectionAtPoint( const Point& rPointPixel );
189 
190  void SetPaintSelection( bool bPaint);
191 
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();
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::SearchOptions& rSearchOptions, bool bForward );
221  sal_uInt16 Replace( const i18nutil::SearchOptions& 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: */
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder)
const OUStringLiteral IsReadOnly("IsReadOnly")
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
virtual void SetCursorAtPoint(const Point &rPointPixel, bool bDontSelectAtCursor=false) override
Definition: textview.cxx:2060
virtual void SAL_CALL acquire() SAL_OVERRIDE
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
unsigned char sal_Bool
std::unique_ptr< ImpTextView > mpImpl
Definition: textview.hxx:83
virtual bool IsSelectionAtPoint(const Point &rPointPixel) override
Definition: textview.cxx:2065
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