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 SC_INPUTWIN_HXX 29 #define SC_INPUTWIN_HXX 30 31 #include <vector> 32 #include <vcl/toolbox.hxx> 33 #include <sfx2/childwin.hxx> 34 #include <svl/lstner.hxx> 35 #include <vcl/combobox.hxx> 36 #include <vcl/window.hxx> 37 #include <svtools/transfer.hxx> 38 39 class ScEditEngineDefaulter; 40 class EditView; 41 struct ESelection; 42 class ScInputHandler; 43 class ScAccessibleEditLineTextData; 44 struct EENotify; 45 class ScRangeList; 46 47 //======================================================================== 48 49 class ScTextWnd : public Window, public DragSourceHelper // edit window 50 { 51 public: 52 ScTextWnd( Window* pParent ); 53 virtual ~ScTextWnd(); 54 55 void SetTextString( const String& rString ); 56 const String& GetTextString() const; 57 58 sal_Bool IsInputActive(); 59 EditView* GetEditView(); 60 61 // fuer FunktionsAutopiloten 62 void MakeDialogEditView(); 63 64 void StartEditEngine(); 65 void StopEditEngine( sal_Bool bAll ); 66 67 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 68 69 void SetFormulaMode( sal_Bool bSet ); 70 71 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); 72 73 void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData ); 74 void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData ); 75 76 DECL_LINK( NotifyHdl, EENotify* ); 77 78 protected: 79 virtual void Paint( const Rectangle& rRec ); 80 virtual void Resize(); 81 82 virtual void MouseMove( const MouseEvent& rMEvt ); 83 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 84 virtual void MouseButtonUp( const MouseEvent& rMEvt ); 85 virtual void Command( const CommandEvent& rCEvt ); 86 virtual void KeyInput(const KeyEvent& rKEvt); 87 virtual void GetFocus(); 88 virtual void LoseFocus(); 89 90 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); 91 92 virtual String GetText() const; 93 94 private: 95 void ImplInitSettings(); 96 void UpdateAutoCorrFlag(); 97 98 private: 99 typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector; 100 101 String aString; 102 Font aTextFont; 103 ScEditEngineDefaulter* pEditEngine; // erst bei Bedarf angelegt 104 EditView* pEditView; 105 AccTextDataVector maAccTextDatas; // #i105267# text datas may be cloned, remember all copies 106 sal_Bool bIsRTL; 107 sal_Bool bIsInsertMode; 108 sal_Bool bFormulaMode; 109 110 // #102710#; this flag should be true if a key input or a command is handled 111 // it prevents the call of InputChanged in the ModifyHandler of the EditEngine 112 sal_Bool bInputMode; 113 }; 114 115 //======================================================================== 116 117 class ScPosWnd : public ComboBox, public SfxListener // Positionsanzeige 118 { 119 private: 120 String aPosStr; 121 Accelerator* pAccel; 122 sal_uLong nTipVisible; 123 sal_Bool bFormulaMode; 124 sal_Bool bTopHadFocus; 125 126 public: 127 ScPosWnd( Window* pParent ); 128 virtual ~ScPosWnd(); 129 130 void SetPos( const String& rPosStr ); // angezeigter Text 131 void SetFormulaMode( sal_Bool bSet ); 132 133 protected: 134 virtual void Select(); 135 virtual void Modify(); 136 137 virtual long Notify( NotifyEvent& rNEvt ); 138 139 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 140 141 private: 142 void FillRangeNames(); 143 void FillFunctions(); 144 void DoEnter(); 145 void HideTip(); 146 147 void ReleaseFocus_Impl(); 148 }; 149 150 //======================================================================== 151 152 class ScInputWindow : public ToolBox // Parent-Toolbox 153 { 154 public: 155 ScInputWindow( Window* pParent, SfxBindings* pBind ); 156 virtual ~ScInputWindow(); 157 158 virtual void Resize(); 159 virtual void Select(); 160 161 void SetFuncString( const String& rString, sal_Bool bDoEdit = sal_True ); 162 void SetPosString( const String& rStr ); 163 void SetTextString( const String& rString ); 164 165 void SetOkCancelMode(); 166 void SetSumAssignMode(); 167 void EnableButtons( sal_Bool bEnable = sal_True ); 168 169 void SetFormulaMode( sal_Bool bSet ); 170 171 sal_Bool IsInputActive(); 172 EditView* GetEditView(); 173 //UNUSED2008-05 EditView* ActivateEdit( const String& rText, 174 //UNUSED2008-05 const ESelection& rSel ); 175 176 void TextGrabFocus(); 177 void TextInvalidate(); 178 void SwitchToTextWin(); 179 180 void PosGrabFocus(); 181 182 // Fuer FunktionsAutopiloten 183 void MakeDialogEditView(); 184 185 void StopEditEngine( sal_Bool bAll ); 186 187 void SetInputHandler( ScInputHandler* pNew ); 188 189 ScInputHandler* GetInputHandler(){ return pInputHdl;} 190 191 void StateChanged( StateChangedType nType ); 192 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 193 194 195 protected: 196 virtual void SetText( const String& rString ); 197 virtual String GetText() const; 198 199 sal_Bool UseSubTotal( ScRangeList* pRangeList ) const; 200 201 private: 202 ScPosWnd aWndPos; 203 ScTextWnd aTextWindow; 204 ScInputHandler* pInputHdl; 205 SfxBindings* pBindings; 206 String aTextOk; 207 String aTextCancel; 208 String aTextSum; 209 String aTextEqual; 210 sal_Bool bIsOkCancelMode; 211 }; 212 213 //================================================================== 214 215 class ScInputWindowWrapper : public SfxChildWindow 216 { 217 public: 218 ScInputWindowWrapper( Window* pParent, 219 sal_uInt16 nId, 220 SfxBindings* pBindings, 221 SfxChildWinInfo* pInfo ); 222 223 SFX_DECL_CHILDWINDOW(ScInputWindowWrapper); 224 }; 225 226 227 #endif 228 229