1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
24 #include <vcl/timer.hxx>
25 #include <vcl/idle.hxx>
26 #include <svl/lstner.hxx>
27 #include <sfx2/module.hxx>
29 #include "shellids.hxx"
30 #include <unotools/options.hxx>
31 #include <com/sun/star/uno/Reference.h>
39 class SfxErrorHandler
;
40 class SvtAccessibilityOptions
;
44 namespace svtools
{ class ColorConfig
; }
45 namespace ooo
{ namespace vba
{ class XSinkCaller
; } }
46 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{ class Any
; } } } }
47 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{ template <typename
> class Sequence
; } } } }
61 class ScDefaultsOptions
;
62 class ScFormulaOptions
;
72 class ScDrawTransferObj
;
73 class ScSelectionTransferObj
;
78 class ScModule
: public SfxModule
, public SfxListener
, public utl::ConfigurationListener
82 std::unique_ptr
<ScDragData
> m_pDragData
;
83 ScSelectionTransferObj
* m_pSelTransfer
;
84 ScMessagePool
* m_pMessagePool
;
85 // there is no global InputHandler anymore, each View has its own
86 ScInputHandler
* m_pRefInputHandler
;
87 std::unique_ptr
<ScViewCfg
> m_pViewCfg
;
88 std::unique_ptr
<ScDocCfg
> m_pDocCfg
;
89 std::unique_ptr
<ScAppCfg
> m_pAppCfg
;
90 std::unique_ptr
<ScDefaultsCfg
> m_pDefaultsCfg
;
91 std::unique_ptr
<ScFormulaCfg
> m_pFormulaCfg
;
92 std::unique_ptr
<ScInputCfg
> m_pInputCfg
;
93 std::unique_ptr
<ScPrintCfg
> m_pPrintCfg
;
94 std::unique_ptr
<ScNavipiCfg
> m_pNavipiCfg
;
95 std::unique_ptr
<ScAddInCfg
> m_pAddInCfg
;
96 std::unique_ptr
<svtools::ColorConfig
> m_pColorConfig
;
97 std::unique_ptr
<SvtAccessibilityOptions
> m_pAccessOptions
;
98 std::unique_ptr
<SvtCTLOptions
> m_pCTLOptions
;
99 std::unique_ptr
<SvtUserOptions
> m_pUserOptions
;
100 std::unique_ptr
<SfxErrorHandler
> m_pErrorHdl
;
101 std::unique_ptr
<ScFormEditData
> m_pFormEditData
;
102 sal_uInt16 m_nCurRefDlgId
;
103 bool m_bIsWaterCan
:1;
104 bool m_bIsInEditCommand
:1;
105 bool m_bIsInExecuteDrop
:1;
106 bool m_bIsInSharedDocLoading
:1;
107 bool m_bIsInSharedDocSaving
:1;
109 std::map
<sal_uInt16
, std::vector
<VclPtr
<vcl::Window
> > > m_mapRefWindow
;
111 css::uno::Reference
< ooo::vba::XSinkCaller
> mxAutomationApplicationEventsCaller
;
114 SFX_DECL_INTERFACE(SCID_APP
)
117 /// SfxInterface initializer.
118 static void InitInterface_Impl();
121 ScModule( SfxObjectFactory
* pFact
);
122 virtual ~ScModule() override
;
124 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
125 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster
*, ConfigurationHints
) override
;
128 // moved by the application
130 DECL_LINK( IdleHandler
, Timer
*, void ); // Timer instead of idle
131 DECL_LINK( SpellTimerHdl
, Timer
*, void );
132 DECL_LINK( CalcFieldValueHdl
, EditFieldInfo
*, void );
134 void Execute( SfxRequest
& rReq
);
135 void GetState( SfxItemSet
& rSet
);
136 static void HideDisabledSlots( SfxItemSet
& rSet
);
138 void AnythingChanged();
141 const ScDragData
& GetDragData() const { return *m_pDragData
;}
142 void SetDragObject( ScTransferObj
* pCellObj
, ScDrawTransferObj
* pDrawObj
);
143 void ResetDragObject();
145 const OUString
& rDoc
, const OUString
& rTab
, const OUString
& rArea
);
147 ScDocument
* pLocalDoc
, const OUString
& rTarget
, const OUString
& rText
);
149 static ScDocument
* GetClipDoc(); // called from document - should be removed later
152 ScSelectionTransferObj
* GetSelectionTransfer() const { return m_pSelTransfer
; }
153 void SetSelectionTransfer( ScSelectionTransferObj
* pNew
);
155 void SetWaterCan( bool bNew
) { m_bIsWaterCan
= bNew
; }
156 bool GetIsWaterCan() const { return m_bIsWaterCan
; }
158 void SetInEditCommand( bool bNew
) { m_bIsInEditCommand
= bNew
; }
160 void SetInExecuteDrop( bool bNew
) { m_bIsInExecuteDrop
= bNew
; }
161 bool IsInExecuteDrop() const { return m_bIsInExecuteDrop
; }
164 const ScViewOptions
& GetViewOptions ();
165 SC_DLLPUBLIC
const ScDocOptions
& GetDocOptions ();
166 SC_DLLPUBLIC
const ScAppOptions
& GetAppOptions ();
167 SC_DLLPUBLIC
const ScDefaultsOptions
& GetDefaultsOptions ();
168 SC_DLLPUBLIC
const ScFormulaOptions
& GetFormulaOptions ();
169 SC_DLLPUBLIC
const ScInputOptions
& GetInputOptions ();
170 SC_DLLPUBLIC
const ScPrintOptions
& GetPrintOptions ();
171 void SetViewOptions ( const ScViewOptions
& rOpt
);
172 SC_DLLPUBLIC
void SetDocOptions ( const ScDocOptions
& rOpt
);
173 SC_DLLPUBLIC
void SetAppOptions ( const ScAppOptions
& rOpt
);
174 void SetDefaultsOptions ( const ScDefaultsOptions
& rOpt
);
175 SC_DLLPUBLIC
void SetFormulaOptions ( const ScFormulaOptions
& rOpt
);
176 SC_DLLPUBLIC
void SetInputOptions ( const ScInputOptions
& rOpt
);
177 void SetPrintOptions ( const ScPrintOptions
& rOpt
);
178 void InsertEntryToLRUList(sal_uInt16 nFIndex
);
180 static void GetSpellSettings( LanguageType
& rDefLang
, LanguageType
& rCjkLang
, LanguageType
& rCtlLang
,
182 static void SetAutoSpellProperty( bool bSet
);
183 static bool HasThesaurusLanguage( LanguageType nLang
);
185 LanguageType
GetOptDigitLanguage(); // from CTL options
187 ScNavipiCfg
& GetNavipiCfg();
188 ScAddInCfg
& GetAddInCfg();
189 svtools::ColorConfig
& GetColorConfig();
190 SvtAccessibilityOptions
& GetAccessOptions();
191 SvtCTLOptions
& GetCTLOptions();
192 SC_DLLPUBLIC SvtUserOptions
& GetUserOptions();
194 void ModifyOptions( const SfxItemSet
& rOptSet
);
197 bool IsEditMode(); // not for SC_INPUT_TYPE
198 bool IsInputMode(); // also for SC_INPUT_TYPE
199 void SetInputMode( ScInputMode eMode
, const OUString
* pInitText
= nullptr );
200 bool InputKeyEvent( const KeyEvent
& rKEvt
, bool bStartEdit
= false );
201 SC_DLLPUBLIC
void InputEnterHandler( ScEnterMode nBlockMode
= ScEnterMode::NORMAL
);
202 void InputCancelHandler();
203 void InputSelection( const EditView
* pView
);
204 void InputChanged( const EditView
* pView
);
205 ScInputHandler
* GetInputHdl( ScTabViewShell
* pViewSh
= nullptr, bool bUseRef
= true );
207 void SetRefInputHdl( ScInputHandler
* pNew
);
208 ScInputHandler
* GetRefInputHdl() { return m_pRefInputHandler
;}
210 void ViewShellGone(const ScTabViewShell
* pViewSh
);
211 void ViewShellChanged(bool bStopEditing
);
212 // communication with function-autopilot
213 void InputGetSelection( sal_Int32
& rStart
, sal_Int32
& rEnd
);
214 void InputSetSelection( sal_Int32 nStart
, sal_Int32 nEnd
);
215 void InputReplaceSelection( const OUString
& rStr
);
216 void InputTurnOffWinEngine();
217 OUString
InputGetFormulaStr();
218 void ActivateInputWindow( const OUString
* pStr
= nullptr,
219 bool bMatrix
= false );
221 void InitFormEditData();
222 void ClearFormEditData();
223 ScFormEditData
* GetFormEditData() { return m_pFormEditData
.get(); }
225 // input of reference:
226 SC_DLLPUBLIC
void SetRefDialog( sal_uInt16 nId
, bool bVis
, SfxViewFrame
* pViewFrm
= nullptr );
227 bool IsModalMode(SfxObjectShell
* pDocSh
= nullptr);
228 bool IsFormulaMode();
229 bool IsRefDialogOpen();
230 bool IsTableLocked();
231 void SetReference( const ScRange
& rRef
, ScDocument
* pDoc
,
232 const ScMarkData
* pMarkData
= nullptr );
235 sal_uInt16
GetCurRefDlgId() const { return m_nCurRefDlgId
; }
237 // virtual methods for the options dialog
238 virtual std::unique_ptr
<SfxItemSet
> CreateItemSet( sal_uInt16 nId
) override
;
239 virtual void ApplyItemSet( sal_uInt16 nId
, const SfxItemSet
& rSet
) override
;
240 virtual VclPtr
<SfxTabPage
> CreateTabPage( sal_uInt16 nId
, TabPageParent pParent
, const SfxItemSet
& rSet
) override
;
241 virtual std::unique_ptr
<SfxStyleFamilies
> CreateStyleFamilies() override
;
243 void SetInSharedDocLoading( bool bNew
) { m_bIsInSharedDocLoading
= bNew
; }
244 bool IsInSharedDocLoading() const { return m_bIsInSharedDocLoading
; }
245 void SetInSharedDocSaving( bool bNew
) { m_bIsInSharedDocSaving
= bNew
; }
246 bool IsInSharedDocSaving() const { return m_bIsInSharedDocSaving
; }
248 SC_DLLPUBLIC
void RegisterRefWindow( sal_uInt16 nSlotId
, vcl::Window
*pWnd
);
249 SC_DLLPUBLIC
void UnregisterRefWindow( sal_uInt16 nSlotId
, vcl::Window
*pWnd
);
250 SC_DLLPUBLIC
vcl::Window
* Find1RefWindow( sal_uInt16 nSlotId
, vcl::Window
*pWndAncestor
);
252 SC_DLLPUBLIC
void RegisterAutomationApplicationEventsCaller(css::uno::Reference
< ooo::vba::XSinkCaller
> const& xCaller
);
253 SC_DLLPUBLIC
void CallAutomationApplicationEventSinks(const OUString
& Method
, css::uno::Sequence
< css::uno::Any
>& Arguments
);
256 #define SC_MOD() ( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule::Calc)) )
258 void global_InitAppOptions();
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */