PageRenderTime 35ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/sc/source/ui/inc/inputhdl.hxx

https://repo.or.cz/LibreOffice.git
C++ Header | 328 lines | 228 code | 67 blank | 33 comment | 5 complexity | 38b74421a17cc03ee24d9873b1b95f2f MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, BSD-3-Clause-No-Nuclear-License-2014, GPL-3.0, LGPL-2.1, LGPL-3.0, LGPL-2.0
  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. #ifndef INCLUDED_SC_SOURCE_UI_INC_INPUTHDL_HXX
  20. #define INCLUDED_SC_SOURCE_UI_INC_INPUTHDL_HXX
  21. #include <global.hxx>
  22. #include <address.hxx>
  23. #include <tools/solar.h>
  24. #include <typedstrdata.hxx>
  25. #include <tools/fract.hxx>
  26. #include <tools/gen.hxx>
  27. #include <tools/link.hxx>
  28. #include <vcl/vclptr.hxx>
  29. #include <editeng/svxenum.hxx>
  30. #include "viewdata.hxx"
  31. #include <set>
  32. #include <memory>
  33. #include <vector>
  34. class ScDocument;
  35. class ScTabViewShell;
  36. class ScInputWindow;
  37. class ScPatternAttr;
  38. class ScEditEngineDefaulter;
  39. class EditView;
  40. class EditTextObject;
  41. class ScInputHdlState;
  42. class ScRangeFindList;
  43. class Timer;
  44. class KeyEvent;
  45. class CommandEvent;
  46. class VclWindowEvent;
  47. namespace vcl { class Window; }
  48. struct ReferenceMark;
  49. struct ESelection;
  50. // ScInputHandler
  51. class ScInputHandler final
  52. {
  53. private:
  54. VclPtr<ScInputWindow> pInputWin;
  55. std::unique_ptr<ScEditEngineDefaulter> mpEditEngine; ///< Edited data in the sheet (when the user clicks into the sheet, and starts writing there).
  56. EditView* pTableView; // associated active EditView
  57. EditView* pTopView; // EditView in the input row
  58. std::unique_ptr<ScTypedCaseStrSet> pColumnData;
  59. std::unique_ptr<ScTypedCaseStrSet> pFormulaData;
  60. std::unique_ptr<ScTypedCaseStrSet> pFormulaDataPara;
  61. ScTypedCaseStrSet::const_iterator miAutoPosColumn;
  62. ScTypedCaseStrSet::const_iterator miAutoPosFormula;
  63. VclPtr<vcl::Window> pTipVisibleParent;
  64. void* nTipVisible;
  65. VclPtr<vcl::Window> pTipVisibleSecParent;
  66. void* nTipVisibleSec;
  67. OUString aManualTip;
  68. OUString aAutoSearch;
  69. OUString aCurrentText;
  70. OUString aFormText; // for autopilot function
  71. sal_Int32 nFormSelStart; // Selection for autopilot function
  72. sal_Int32 nFormSelEnd;
  73. sal_uInt16 nAutoPar; // autom.parentheses than can be overwritten
  74. ScAddress aCursorPos;
  75. ScInputMode eMode;
  76. bool bUseTab:1; // Scrolling possible
  77. bool bTextValid:1; // Text is not in edit engine
  78. bool bModified:1;
  79. bool bSelIsRef:1;
  80. bool bFormulaMode:1;
  81. bool bInRangeUpdate:1;
  82. bool bParenthesisShown:1;
  83. bool bCreatingFuncView:1;
  84. bool bInEnterHandler:1;
  85. bool bCommandErrorShown:1;
  86. bool bInOwnChange:1;
  87. bool bProtected:1;
  88. bool bCellHasPercentFormat:1;
  89. bool bLastIsSymbol:1;
  90. bool mbDocumentDisposing:1;
  91. sal_uLong nValidation;
  92. SvxCellHorJustify eAttrAdjust;
  93. Fraction aScaleX; // for ref MapMode
  94. Fraction aScaleY;
  95. ScTabViewShell* pRefViewSh;
  96. ScTabViewShell* pActiveViewSh;
  97. const ScPatternAttr* pLastPattern;
  98. std::unique_ptr<SfxItemSet>
  99. pEditDefaults;
  100. std::unique_ptr<ScInputHdlState>
  101. pLastState;
  102. std::unique_ptr<Timer> pDelayTimer;
  103. std::unique_ptr<ScRangeFindList>
  104. pRangeFindList;
  105. static bool bAutoComplete; // from app options
  106. static bool bOptLoaded;
  107. ::std::set< sal_Unicode > maFormulaChar; //fdo 75264
  108. private:
  109. void UpdateActiveView();
  110. void SyncViews( const EditView* pSourceView = nullptr );
  111. /**
  112. * @param cTyped typed character. If 0, look at existing document content
  113. * for text or number.
  114. * @param bInputActivated true if the cell input mode is activated (via
  115. * F2), false otherwise.
  116. * @param pTopEngine top window input line EditEngine. If not nullptr then
  117. * some default attributes are merged to it from the
  118. * table EditEngine.
  119. * @return true if the new edit mode has been started.
  120. */
  121. bool StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated,
  122. ScEditEngineDefaulter* pTopEngine );
  123. void RemoveSelection();
  124. void UpdateFormulaMode();
  125. static void InvalidateAttribs();
  126. void ImplCreateEditEngine();
  127. DECL_LINK( DelayTimer, Timer*, void );
  128. void GetColData();
  129. void UseColData();
  130. void NextAutoEntry( bool bBack );
  131. void UpdateAdjust( sal_Unicode cTyped );
  132. void GetFormulaData();
  133. void UseFormulaData();
  134. void NextFormulaEntry( bool bBack );
  135. void PasteFunctionData();
  136. void PasteManualTip();
  137. EditView* GetFuncEditView();
  138. void RemoveAdjust();
  139. void RemoveRangeFinder();
  140. void DeleteRangeFinder();
  141. void UpdateParenthesis();
  142. void UpdateAutoCorrFlag();
  143. void ResetAutoPar();
  144. void AutoParAdded();
  145. bool CursorAtClosingPar();
  146. void SkipClosingPar();
  147. bool GetFuncName( OUString& aStart, OUString& aResult ); // fdo75264
  148. void ShowArgumentsTip( OUString& rSelText );
  149. DECL_LINK( ModifyHdl, LinkParamNone*, void );
  150. DECL_LINK( ShowHideTipVisibleParentListener, VclWindowEvent&, void );
  151. DECL_LINK( ShowHideTipVisibleSecParentListener, VclWindowEvent&, void );
  152. public:
  153. ScInputHandler(const ScInputHandler&) = delete;
  154. const ScInputHandler& operator=(const ScInputHandler&) = delete;
  155. ScInputHandler();
  156. ~ScInputHandler();
  157. void SetMode( ScInputMode eNewMode, const OUString* pInitText = nullptr,
  158. ScEditEngineDefaulter* pTopEngine = nullptr );
  159. bool IsInputMode() const { return (eMode != SC_INPUT_NONE); }
  160. bool IsEditMode() const { return (eMode != SC_INPUT_NONE &&
  161. eMode != SC_INPUT_TYPE); }
  162. bool IsTopMode() const { return (eMode == SC_INPUT_TOP); }
  163. const OUString& GetEditString();
  164. const OUString& GetFormString() const { return aFormText; }
  165. const ScAddress& GetCursorPos() const { return aCursorPos; }
  166. bool GetTextAndFields( ScEditEngineDefaulter& rDestEngine );
  167. void MergeLanguageAttributes( ScEditEngineDefaulter& rDestEngine ) const;
  168. bool KeyInput( const KeyEvent& rKEvt, bool bStartEdit );
  169. void EnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL );
  170. void CancelHandler();
  171. void SetReference( const ScRange& rRef, const ScDocument& rDoc );
  172. void AddRefEntry();
  173. void InputCommand( const CommandEvent& rCEvt );
  174. void InsertFunction( const OUString& rFuncName, bool bAddPar = true );
  175. void ClearText();
  176. void InputSelection( const EditView* pView );
  177. void InputChanged( const EditView* pView, bool bFromNotify );
  178. void ViewShellGone(const ScTabViewShell* pViewSh);
  179. void SetRefViewShell(ScTabViewShell* pRefVsh) {pRefViewSh=pRefVsh;}
  180. void NotifyChange( const ScInputHdlState* pState, bool bForce = false,
  181. ScTabViewShell* pSourceSh = nullptr,
  182. bool bStopEditing = true);
  183. void UpdateCellAdjust( SvxCellHorJustify eJust );
  184. void ResetDelayTimer(); //BugId 54702
  185. void HideTip();
  186. void HideTipBelow();
  187. void ShowTipCursor();
  188. void ShowTip( const OUString& rText ); // at Cursor
  189. void ShowTipBelow( const OUString& rText );
  190. void ShowFuncList( const ::std::vector< OUString > & rFuncStrVec );
  191. void SetRefScale( const Fraction& rX, const Fraction& rY );
  192. void UpdateRefDevice();
  193. EditView* GetActiveView();
  194. EditView* GetTableView() { return pTableView; }
  195. EditView* GetTopView() { return pTopView; }
  196. bool DataChanging( sal_Unicode cTyped = 0, bool bFromCommand = false );
  197. void DataChanged( bool bFromTopNotify = false, bool bSetModified = true );
  198. bool TakesReturn() const { return ( nTipVisible != nullptr ); }
  199. bool GetModified() const { return bModified; }
  200. void SetModified() { bModified = true; }
  201. bool GetSelIsRef() const { return bSelIsRef; }
  202. void SetSelIsRef(bool bSet) { bSelIsRef = bSet; }
  203. void ShowRefFrame();
  204. ScRangeFindList* GetRangeFindList() { return pRangeFindList.get(); }
  205. void UpdateRange( sal_uInt16 nIndex, const ScRange& rNew );
  206. // Communication with the autopilot function
  207. void InputGetSelection ( sal_Int32& rStart, sal_Int32& rEnd );
  208. void InputSetSelection ( sal_Int32 nStart, sal_Int32 nEnd );
  209. void InputReplaceSelection ( const OUString& rStr );
  210. void InputTurnOffWinEngine();
  211. bool IsFormulaMode() const { return bFormulaMode; }
  212. ScInputWindow* GetInputWindow() { return pInputWin; }
  213. void SetInputWindow( ScInputWindow* pNew );
  214. void StopInputWinEngine( bool bAll );
  215. bool IsInEnterHandler() const { return bInEnterHandler; }
  216. bool IsInOwnChange() const { return bInOwnChange; }
  217. bool IsModalMode( const SfxObjectShell* pDocSh );
  218. void ForgetLastPattern();
  219. void UpdateSpellSettings( bool bFromStartTab = false );
  220. void FormulaPreview();
  221. Size GetTextSize(); // in 1/100mm
  222. // actually private, public for SID_INPUT_SUM
  223. void InitRangeFinder(const OUString& rFormula);
  224. void UpdateLokReferenceMarks();
  225. static void SendReferenceMarks( const SfxViewShell* pViewShell,
  226. const std::vector<ReferenceMark>& rReferenceMarks );
  227. void SetDocumentDisposing( bool b );
  228. static void SetAutoComplete(bool bSet) { bAutoComplete = bSet; }
  229. static ReferenceMark GetReferenceMark( ScViewData& rViewData, ScDocShell* pDocSh,
  230. long nX1, long nX2, long nY1, long nY2,
  231. long nTab, const Color& rColor );
  232. void LOKPasteFunctionData( sal_uInt32 nIndex );
  233. };
  234. // ScInputHdlState
  235. class ScInputHdlState
  236. {
  237. friend class ScInputHandler;
  238. public:
  239. ScInputHdlState( const ScAddress& rCurPos,
  240. const ScAddress& rStartPos,
  241. const ScAddress& rEndPos,
  242. const OUString& rString,
  243. const EditTextObject* pData );
  244. ScInputHdlState( const ScInputHdlState& rCpy );
  245. ~ScInputHdlState();
  246. ScInputHdlState& operator= ( const ScInputHdlState& r );
  247. bool operator==( const ScInputHdlState& r ) const;
  248. const ScAddress& GetPos() const { return aCursorPos; }
  249. const ScAddress& GetStartPos() const { return aStartPos; }
  250. const ScAddress& GetEndPos() const { return aEndPos; }
  251. const OUString& GetString() const { return aString; }
  252. const EditTextObject* GetEditData() const { return pEditData.get(); }
  253. private:
  254. ScAddress aCursorPos;
  255. ScAddress aStartPos;
  256. ScAddress aEndPos;
  257. OUString aString;
  258. std::unique_ptr<EditTextObject> pEditData;
  259. };
  260. #endif
  261. /* vim:set shiftwidth=4 softtabstop=4 expandtab: */