tdf#125800: accessing cond format props in UNO throws error
[LibreOffice.git] / sc / inc / scmod.hxx
blob363a9dd2a35440b625d990e10d9d15b3fa216080
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_SC_INC_SCMOD_HXX
21 #define INCLUDED_SC_INC_SCMOD_HXX
23 #include "scdllapi.h"
24 #include <o3tl/deleter.hxx>
25 #include <vcl/timer.hxx>
26 #include <vcl/idle.hxx>
27 #include <svl/lstner.hxx>
28 #include <sfx2/app.hxx>
29 #include <sfx2/module.hxx>
30 #include "global.hxx"
31 #include "shellids.hxx"
32 #include <unotools/options.hxx>
33 #include <com/sun/star/uno/Reference.h>
35 #include <vector>
36 #include <map>
37 #include <memory>
39 class KeyEvent;
40 class EditView;
41 class SfxErrorHandler;
42 class SvtAccessibilityOptions;
43 class SvtCTLOptions;
44 class SvtUserOptions;
46 namespace svtools { class ColorConfig; }
47 namespace ooo { namespace vba { class XSinkCaller; } }
48 namespace com { namespace sun { namespace star { namespace uno { class Any; } } } }
49 namespace com { namespace sun { namespace star { namespace uno { template <typename > class Sequence; } } } }
51 class ScRange;
52 class ScDocument;
53 class ScViewCfg;
54 class ScDocCfg;
55 class ScAppCfg;
56 class ScDefaultsCfg;
57 class ScFormulaCfg;
58 class ScInputCfg;
59 class ScPrintCfg;
60 class ScViewOptions;
61 class ScDocOptions;
62 class ScAppOptions;
63 class ScDefaultsOptions;
64 class ScFormulaOptions;
65 class ScInputOptions;
66 class ScPrintOptions;
67 class ScInputHandler;
68 class ScTabViewShell;
69 class ScMessagePool;
70 class EditFieldInfo;
71 class ScNavipiCfg;
72 class ScAddInCfg;
73 class ScTransferObj;
74 class ScDrawTransferObj;
75 class ScSelectionTransferObj;
76 class ScFormEditData;
77 class ScMarkData;
78 struct ScDragData;
79 class SfxDialogController;
81 class SAL_DLLPUBLIC_RTTI ScModule: public SfxModule, public SfxListener, public utl::ConfigurationListener
83 Timer m_aIdleTimer;
84 Idle m_aSpellIdle;
85 std::unique_ptr<ScDragData> m_pDragData;
86 ScSelectionTransferObj* m_pSelTransfer;
87 ScMessagePool* m_pMessagePool;
88 // there is no global InputHandler anymore, each View has its own
89 ScInputHandler* m_pRefInputHandler;
90 std::unique_ptr<ScViewCfg, o3tl::default_delete<ScViewCfg>> m_pViewCfg;
91 std::unique_ptr<ScDocCfg, o3tl::default_delete<ScDocCfg>> m_pDocCfg;
92 std::unique_ptr<ScAppCfg, o3tl::default_delete<ScAppCfg>> m_pAppCfg;
93 std::unique_ptr<ScDefaultsCfg> m_pDefaultsCfg;
94 std::unique_ptr<ScFormulaCfg> m_pFormulaCfg;
95 std::unique_ptr<ScInputCfg> m_pInputCfg;
96 std::unique_ptr<ScPrintCfg> m_pPrintCfg;
97 std::unique_ptr<ScNavipiCfg> m_pNavipiCfg;
98 std::unique_ptr<ScAddInCfg> m_pAddInCfg;
99 std::unique_ptr<svtools::ColorConfig> m_pColorConfig;
100 std::unique_ptr<SvtAccessibilityOptions> m_pAccessOptions;
101 std::unique_ptr<SvtCTLOptions> m_pCTLOptions;
102 std::unique_ptr<SvtUserOptions> m_pUserOptions;
103 std::unique_ptr<SfxErrorHandler> m_pErrorHdl;
104 std::unique_ptr<ScFormEditData> m_pFormEditData;
105 sal_uInt16 m_nCurRefDlgId;
106 bool m_bIsWaterCan:1;
107 bool m_bIsInEditCommand:1;
108 bool m_bIsInExecuteDrop:1;
109 bool m_bIsInSharedDocLoading:1;
110 bool m_bIsInSharedDocSaving:1;
112 // a way to find existing Dialogs for a given parent Window of the slot type
113 std::map<sal_uInt16, std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>>> m_mapRefController;
115 css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller;
117 public:
118 SFX_DECL_INTERFACE(SCID_APP)
120 private:
121 /// SfxInterface initializer.
122 static void InitInterface_Impl();
124 public:
125 ScModule( SfxObjectFactory* pFact );
126 virtual ~ScModule() override;
128 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
129 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
130 void DeleteCfg();
132 // moved by the application
134 DECL_LINK( IdleHandler, Timer*, void ); // Timer instead of idle
135 DECL_LINK( SpellTimerHdl, Timer*, void );
136 DECL_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
138 void Execute( SfxRequest& rReq );
139 void GetState( SfxItemSet& rSet );
140 static void HideDisabledSlots( SfxItemSet& rSet );
142 void AnythingChanged();
144 // Drag & Drop:
145 const ScDragData& GetDragData() const { return *m_pDragData;}
146 void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
147 void ResetDragObject();
148 void SetDragLink(
149 const OUString& rDoc, const OUString& rTab, const OUString& rArea );
150 void SetDragJump(
151 ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText );
153 static ScDocument* GetClipDoc(); // called from document - should be removed later
155 // X selection:
156 ScSelectionTransferObj* GetSelectionTransfer() const { return m_pSelTransfer; }
157 void SetSelectionTransfer( ScSelectionTransferObj* pNew );
159 void SetWaterCan( bool bNew ) { m_bIsWaterCan = bNew; }
160 bool GetIsWaterCan() const { return m_bIsWaterCan; }
162 void SetInEditCommand( bool bNew ) { m_bIsInEditCommand = bNew; }
164 void SetInExecuteDrop( bool bNew ) { m_bIsInExecuteDrop = bNew; }
165 bool IsInExecuteDrop() const { return m_bIsInExecuteDrop; }
167 // Options:
168 const ScViewOptions& GetViewOptions ();
169 SC_DLLPUBLIC const ScDocOptions& GetDocOptions ();
170 SC_DLLPUBLIC const ScAppOptions& GetAppOptions ();
171 SC_DLLPUBLIC const ScDefaultsOptions& GetDefaultsOptions ();
172 SC_DLLPUBLIC const ScFormulaOptions& GetFormulaOptions ();
173 SC_DLLPUBLIC const ScInputOptions& GetInputOptions ();
174 SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions ();
175 void SetViewOptions ( const ScViewOptions& rOpt );
176 SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt );
177 SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt );
178 void SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
179 SC_DLLPUBLIC void SetFormulaOptions ( const ScFormulaOptions& rOpt );
180 SC_DLLPUBLIC void SetInputOptions ( const ScInputOptions& rOpt );
181 void SetPrintOptions ( const ScPrintOptions& rOpt );
182 void InsertEntryToLRUList(sal_uInt16 nFIndex);
184 static void GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang,
185 bool& rAutoSpell );
186 static void SetAutoSpellProperty( bool bSet );
187 static bool HasThesaurusLanguage( LanguageType nLang );
189 LanguageType GetOptDigitLanguage(); // from CTL options
191 ScNavipiCfg& GetNavipiCfg();
192 ScAddInCfg& GetAddInCfg();
193 svtools::ColorConfig& GetColorConfig();
194 SvtAccessibilityOptions& GetAccessOptions();
195 SvtCTLOptions& GetCTLOptions();
196 SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
198 void ModifyOptions( const SfxItemSet& rOptSet );
200 // InputHandler:
201 bool IsEditMode(); // not for SC_INPUT_TYPE
202 bool IsInputMode(); // also for SC_INPUT_TYPE
203 void SetInputMode( ScInputMode eMode, const OUString* pInitText = nullptr );
204 bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false );
205 SC_DLLPUBLIC void InputEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL );
206 void InputCancelHandler();
207 void InputSelection( const EditView* pView );
208 void InputChanged( const EditView* pView );
209 ScInputHandler* GetInputHdl( ScTabViewShell* pViewSh = nullptr, bool bUseRef = true );
211 void SetRefInputHdl( ScInputHandler* pNew );
212 ScInputHandler* GetRefInputHdl() { return m_pRefInputHandler;}
214 void ViewShellGone(const ScTabViewShell* pViewSh);
215 void ViewShellChanged(bool bStopEditing);
216 // communication with function-autopilot
217 void InputGetSelection( sal_Int32& rStart, sal_Int32& rEnd );
218 void InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd );
219 void InputReplaceSelection( const OUString& rStr );
220 void InputTurnOffWinEngine();
221 OUString InputGetFormulaStr();
222 void ActivateInputWindow( const OUString* pStr = nullptr,
223 bool bMatrix = false );
225 void InitFormEditData();
226 void ClearFormEditData();
227 ScFormEditData* GetFormEditData() { return m_pFormEditData.get(); }
229 // input of reference:
230 SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = nullptr );
231 bool IsModalMode(SfxObjectShell* pDocSh = nullptr);
232 bool IsFormulaMode();
233 bool IsRefDialogOpen();
234 bool IsTableLocked();
235 void SetReference( const ScRange& rRef, ScDocument* pDoc,
236 const ScMarkData* pMarkData = nullptr );
237 void AddRefEntry();
238 void EndReference();
239 sal_uInt16 GetCurRefDlgId() const { return m_nCurRefDlgId; }
241 // virtual methods for the options dialog
242 virtual std::unique_ptr<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
243 virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
244 virtual VclPtr<SfxTabPage> CreateTabPage( sal_uInt16 nId, TabPageParent pParent, const SfxItemSet& rSet ) override;
245 virtual std::unique_ptr<SfxStyleFamilies> CreateStyleFamilies() override;
247 void SetInSharedDocLoading( bool bNew ) { m_bIsInSharedDocLoading = bNew; }
248 bool IsInSharedDocLoading() const { return m_bIsInSharedDocLoading; }
249 void SetInSharedDocSaving( bool bNew ) { m_bIsInSharedDocSaving = bNew; }
250 bool IsInSharedDocSaving() const { return m_bIsInSharedDocSaving; }
252 SC_DLLPUBLIC void RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd, weld::Window* pWndAncestor);
253 SC_DLLPUBLIC void UnregisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd);
254 SC_DLLPUBLIC std::shared_ptr<SfxDialogController> Find1RefWindow(sal_uInt16 nSlotId, weld::Window *pWndAncestor);
256 SC_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
257 SC_DLLPUBLIC void CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments);
260 #define SC_MOD() ( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule::Calc)) )
262 void global_InitAppOptions();
264 #endif
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */