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