Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / textview.hxx
blob721c0c06a706c801922cc427173a8e5b10ece77b
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 <tools/gen.hxx>
24 #include <tools/lineend.hxx>
25 #include <vcl/dllapi.h>
26 #include <vcl/dndhelp.hxx>
27 #include <vcl/textdata.hxx>
28 #include <vcl/window.hxx>
30 class TextEngine;
31 class OutputDevice;
33 class KeyEvent;
34 class MouseEvent;
35 class CommandEvent;
36 class TextSelFunctionSet;
37 class SelectionEngine;
38 class VirtualDevice;
39 struct TextDDInfo;
41 namespace com { namespace sun { namespace star { namespace datatransfer { namespace clipboard {
42 class XClipboard;
43 }}}}}
45 struct ImpTextView;
47 class VCL_DLLPUBLIC TextView : public vcl::unohelper::DragAndDropClient
49 friend class TextEngine;
50 friend class TextUndo;
51 friend class TextUndoManager;
52 friend class TextSelFunctionSet;
53 friend class ExtTextView;
55 private:
56 ImpTextView* mpImpl;
58 TextView( const TextView& ) : vcl::unohelper::DragAndDropClient() {}
59 TextView& operator=( const TextView& ) { return *this; }
61 protected:
62 void ShowSelection();
63 void HideSelection();
64 void ShowSelection( const TextSelection& rSel );
65 void ImpShowHideSelection( bool bShow, const TextSelection* pRange = NULL );
67 TextSelection ImpMoveCursor( const KeyEvent& rKeyEvent );
68 TextPaM ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode );
69 void ImpSetSelection( const TextSelection& rNewSel, bool bUI );
70 bool IsInSelection( const TextPaM& rPaM );
72 void ImpPaint(vcl::RenderContext& rRenderContext, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange = 0, TextSelection const* pSelection = 0);
73 void ImpPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect, bool bUseVirtDev);
74 void ImpShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bEndKey );
75 void ImpHighlight( const TextSelection& rSel );
76 void ImpSetSelection( const TextSelection& rSelection );
77 Point ImpGetOutputStartPos( const Point& rStartDocPos ) const;
79 void ImpHideDDCursor();
80 void ImpShowDDCursor();
82 bool ImplTruncateNewText( OUString& rNewText ) const;
83 bool ImplCheckTextLen( const OUString& rNewText );
85 VirtualDevice* GetVirtualDevice();
87 // DragAndDropClient
88 virtual void dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& dge ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 virtual void dragDropEnd( const ::com::sun::star::datatransfer::dnd::DragSourceDropEvent& dsde ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 virtual void drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 virtual void dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 virtual void dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
93 virtual void dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 using DragAndDropClient::dragEnter;
96 using DragAndDropClient::dragExit;
97 using DragAndDropClient::dragOver;
99 public:
100 TextView( TextEngine* pEng, vcl::Window* pWindow );
101 virtual ~TextView();
103 TextEngine* GetTextEngine() const;
104 vcl::Window* GetWindow() const;
106 void Invalidate();
107 void Scroll( long nHorzScroll, long nVertScroll );
109 void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true );
110 void HideCursor();
112 void EnableCursor( bool bEnable );
113 bool IsCursorEnabled() const;
115 const TextSelection& GetSelection() const;
116 TextSelection& GetSelection();
117 void SetSelection( const TextSelection& rNewSel );
118 void SetSelection( const TextSelection& rNewSel, bool bGotoCursor );
119 bool HasSelection() const;
121 OUString GetSelected();
122 OUString GetSelected( LineEnd aSeparator );
123 void DeleteSelected();
125 void InsertText( const OUString& rNew, bool bSelect = false );
127 bool KeyInput( const KeyEvent& rKeyEvent );
128 void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
129 void MouseButtonUp( const MouseEvent& rMouseEvent );
130 void MouseButtonDown( const MouseEvent& rMouseEvent );
131 void MouseMove( const MouseEvent& rMouseEvent );
132 void Command( const CommandEvent& rCEvt );
134 void Cut();
135 void Copy();
136 void Paste();
138 void Copy( css::uno::Reference< css::datatransfer::clipboard::XClipboard >& rxClipboard );
139 void Paste( css::uno::Reference< css::datatransfer::clipboard::XClipboard >& rxClipboard );
141 void Undo();
142 void Redo();
144 bool Read( SvStream& rInput );
146 void SetStartDocPos( const Point& rPos );
147 const Point& GetStartDocPos() const;
149 Point GetDocPos( const Point& rWindowPos ) const;
150 Point GetWindowPos( const Point& rDocPos ) const;
152 void SetInsertMode( bool bInsert );
153 bool IsInsertMode() const;
155 void SetAutoIndentMode( bool bAutoIndent );
157 void SetReadOnly( bool bReadOnly );
158 bool IsReadOnly() const;
160 void SetAutoScroll( bool bAutoScroll );
161 bool IsAutoScroll() const;
163 bool SetCursorAtPoint( const Point& rPointPixel );
164 bool IsSelectionAtPoint( const Point& rPointPixel );
166 void SetPaintSelection( bool bPaint);
168 void EraseVirtualDevice();
170 // aus dem protected Teil hierher verschoben
171 // For 'SvtXECTextCursor' (TL). Must ggf nochmal anders gel?st werden.
172 TextPaM PageUp( const TextPaM& rPaM );
173 TextPaM PageDown( const TextPaM& rPaM );
174 TextPaM CursorUp( const TextPaM& rPaM );
175 TextPaM CursorDown( const TextPaM& rPaM );
176 TextPaM CursorLeft( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode );
177 TextPaM CursorRight( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode );
178 TextPaM CursorWordLeft( const TextPaM& rPaM );
179 TextPaM CursorWordRight( const TextPaM& rPaM );
180 TextPaM CursorStartOfLine( const TextPaM& rPaM );
181 TextPaM CursorEndOfLine( const TextPaM& rPaM );
182 static TextPaM CursorStartOfParagraph( const TextPaM& rPaM );
183 TextPaM CursorEndOfParagraph( const TextPaM& rPaM );
184 static TextPaM CursorStartOfDoc();
185 TextPaM CursorEndOfDoc();
188 Drag and Drop, deleting and selection regards all text that has an attribute
189 TEXTATTR_PROTECTED set as one entity. Drag and dropped text is automatically
190 attibuted as protected.
192 void SupportProtectAttribute(bool bSupport);
195 Returns the number in paragraph of the line in which the cursor is blinking
196 if enabled, -1 otherwise.
198 sal_Int32 GetLineNumberOfCursorInSelection() const;
201 #endif
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */