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