1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _TEXTVIEW_HXX 29 #define _TEXTVIEW_HXX 30 31 #include "svtools/svtdllapi.h" 32 #include <svtools/textdata.hxx> 33 #include <tools/gen.hxx> 34 #include <vcl/dndhelp.hxx> 35 36 class TextEngine; 37 class OutputDevice; 38 class Window; 39 class Cursor; 40 class KeyEvent; 41 class MouseEvent; 42 class CommandEvent; 43 class TextSelFunctionSet; 44 class SelectionEngine; 45 class VirtualDevice; 46 struct TextDDInfo; 47 48 namespace com { 49 namespace sun { 50 namespace star { 51 namespace datatransfer { 52 namespace clipboard { 53 class XClipboard; 54 }}}}} 55 56 struct ImpTextView; 57 58 class SVT_DLLPUBLIC TextView : public vcl::unohelper::DragAndDropClient 59 { 60 friend class TextEngine; 61 friend class TextUndo; 62 friend class TextUndoManager; 63 friend class TextSelFunctionSet; 64 friend class ExtTextView; 65 66 private: 67 ImpTextView* mpImpl; 68 69 TextView( const TextView& ) : vcl::unohelper::DragAndDropClient() {} 70 TextView& operator=( const TextView& ) { return *this; } 71 72 protected: 73 void ShowSelection(); 74 void HideSelection(); 75 void ShowSelection( const TextSelection& rSel ); 76 void ImpShowHideSelection( sal_Bool bShow, const TextSelection* pRange = NULL ); 77 78 TextSelection ImpMoveCursor( const KeyEvent& rKeyEvent ); 79 TextPaM ImpDelete( sal_Bool bForward, sal_uInt8 nMode ); 80 void ImpSetSelection( const TextSelection& rNewSel, sal_Bool bUI ); 81 sal_Bool IsInSelection( const TextPaM& rPaM ); 82 83 void ImpPaint( OutputDevice* pOut, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange = 0, TextSelection const* pSelection = 0 ); 84 void ImpPaint( const Rectangle& rRect, sal_Bool bUseVirtDev ); 85 void ImpShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, sal_Bool bEndKey ); 86 void ImpHighlight( const TextSelection& rSel ); 87 void ImpSetSelection( const TextSelection& rSelection ); 88 Point ImpGetOutputStartPos( const Point& rStartDocPos ) const; 89 90 void ImpHideDDCursor(); 91 void ImpShowDDCursor(); 92 93 bool ImplTruncateNewText( rtl::OUString& rNewText ) const; 94 sal_Bool ImplCheckTextLen( const String& rNewText ); 95 96 VirtualDevice* GetVirtualDevice(); 97 98 // DragAndDropClient 99 virtual void dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& dge ) throw (::com::sun::star::uno::RuntimeException); 100 virtual void dragDropEnd( const ::com::sun::star::datatransfer::dnd::DragSourceDropEvent& dsde ) throw (::com::sun::star::uno::RuntimeException); 101 virtual void drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw (::com::sun::star::uno::RuntimeException); 102 virtual void dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw (::com::sun::star::uno::RuntimeException); 103 virtual void dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw (::com::sun::star::uno::RuntimeException); 104 virtual void dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw (::com::sun::star::uno::RuntimeException); 105 106 using DragAndDropClient::dragEnter; 107 using DragAndDropClient::dragExit; 108 using DragAndDropClient::dragOver; 109 110 public: 111 TextView( TextEngine* pEng, Window* pWindow ); 112 virtual ~TextView(); 113 114 TextEngine* GetTextEngine() const; 115 Window* GetWindow() const; 116 117 void Invalidate(); 118 void Scroll( long nHorzScroll, long nVertScroll ); 119 120 void ShowCursor( sal_Bool bGotoCursor = sal_True, sal_Bool bForceVisCursor = sal_True ); 121 void HideCursor(); 122 123 void EnableCursor( sal_Bool bEnable ); 124 sal_Bool IsCursorEnabled() const; 125 126 const TextSelection& GetSelection() const; 127 TextSelection& GetSelection(); 128 void SetSelection( const TextSelection& rNewSel ); 129 void SetSelection( const TextSelection& rNewSel, sal_Bool bGotoCursor ); 130 sal_Bool HasSelection() const; 131 132 String GetSelected(); 133 String GetSelected( LineEnd aSeparator ); 134 void DeleteSelected(); 135 136 void InsertNewText( const rtl::OUString& rNew, sal_Bool bSelect = sal_False ); 137 // deprecated: use InsertNewText instead 138 void InsertText( const String& rNew, sal_Bool bSelect = sal_False ); 139 140 sal_Bool KeyInput( const KeyEvent& rKeyEvent ); 141 void Paint( const Rectangle& rRect ); 142 void MouseButtonUp( const MouseEvent& rMouseEvent ); 143 void MouseButtonDown( const MouseEvent& rMouseEvent ); 144 void MouseMove( const MouseEvent& rMouseEvent ); 145 void Command( const CommandEvent& rCEvt ); 146 147 void Cut(); 148 void Copy(); 149 void Paste(); 150 151 void Copy( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard ); 152 void Paste( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard ); 153 154 void Undo(); 155 void Redo(); 156 157 sal_Bool Read( SvStream& rInput ); 158 sal_Bool Write( SvStream& rOutput ); 159 160 void SetStartDocPos( const Point& rPos ); 161 const Point& GetStartDocPos() const; 162 163 Point GetDocPos( const Point& rWindowPos ) const; 164 Point GetWindowPos( const Point& rDocPos ) const; 165 166 void SetInsertMode( sal_Bool bInsert ); 167 sal_Bool IsInsertMode() const; 168 169 void SetAutoIndentMode( sal_Bool bAutoIndent ); 170 sal_Bool IsAutoIndentMode() const; 171 172 void SetReadOnly( sal_Bool bReadOnly ); 173 sal_Bool IsReadOnly() const; 174 175 void SetAutoScroll( sal_Bool bAutoScroll ); 176 sal_Bool IsAutoScroll() const; 177 178 sal_Bool SetCursorAtPoint( const Point& rPointPixel ); 179 sal_Bool IsSelectionAtPoint( const Point& rPointPixel ); 180 181 void SetPaintSelection( sal_Bool bPaint); 182 sal_Bool IsPaintSelection() const; 183 184 void SetHighlightSelection( sal_Bool bSelectByHighlight ); 185 sal_Bool IsHighlightSelection() const; 186 187 void EraseVirtualDevice(); 188 189 // aus dem protected Teil hierher verschoben 190 // F�r 'SvtXECTextCursor' (TL). Mu� ggf nochmal anders gel�st werden. 191 TextPaM PageUp( const TextPaM& rPaM ); 192 TextPaM PageDown( const TextPaM& rPaM ); 193 TextPaM CursorUp( const TextPaM& rPaM ); 194 TextPaM CursorDown( const TextPaM& rPaM ); 195 TextPaM CursorLeft( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode ); 196 TextPaM CursorRight( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode ); 197 TextPaM CursorWordLeft( const TextPaM& rPaM ); 198 TextPaM CursorWordRight( const TextPaM& rPaM ); 199 TextPaM CursorStartOfLine( const TextPaM& rPaM ); 200 TextPaM CursorEndOfLine( const TextPaM& rPaM ); 201 TextPaM CursorStartOfParagraph( const TextPaM& rPaM ); 202 TextPaM CursorEndOfParagraph( const TextPaM& rPaM ); 203 TextPaM CursorStartOfDoc(); 204 TextPaM CursorEndOfDoc(); 205 206 // Old, remove! 207 TextPaM CursorLeft( const TextPaM& rPaM, sal_Bool bWordMode = sal_False ); 208 TextPaM CursorRight( const TextPaM& rPaM, sal_Bool bWordMode = sal_False ); 209 210 /** 211 Drag and Drop, deleting and selection regards all text that has an attribute 212 TEXTATTR_PROTECTED set as one entitity. Drag and dropped text is automatically 213 attibuted as protected. 214 */ 215 void SupportProtectAttribute(sal_Bool bSupport); 216 217 /** 218 Returns the number in paragraph of the line in which the cursor is blinking 219 if enabled, -1 otherwise. 220 */ 221 sal_Int32 GetLineNumberOfCursorInSelection() const; 222 }; 223 224 #endif // _TEXTVIEW_HXX 225