update credits
[LibreOffice.git] / sc / inc / scmod.hxx
blob936fb436abb8d45e64ce5fc99fde705f6276ce12
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 "scdll.hxx"
25 #include <vcl/timer.hxx>
26 #include <vcl/idle.hxx>
27 #include <svl/lstner.hxx>
28 #include "global.hxx"
29 #include "shellids.hxx"
30 #include <unotools/options.hxx>
31 #include <tools/shl.hxx>
33 #include <map>
34 #include <list>
35 #include <algorithm>
36 #include <stack>
38 class KeyEvent;
39 class EditView;
40 class SfxErrorHandler;
41 class SvtAccessibilityOptions;
42 class SvtCTLOptions;
43 class SvtUserOptions;
45 namespace svtools { class ColorConfig; }
47 class ScRange;
48 class ScDocument;
49 class ScViewCfg;
50 class ScDocCfg;
51 class ScAppCfg;
52 class ScDefaultsCfg;
53 class ScFormulaCfg;
54 class ScInputCfg;
55 class ScPrintCfg;
56 class ScViewOptions;
57 class ScDocOptions;
58 class ScAppOptions;
59 class ScDefaultsOptions;
60 class ScFormulaOptions;
61 class ScInputOptions;
62 class ScPrintOptions;
63 class ScInputHandler;
64 class ScTabViewShell;
65 class ScMessagePool;
66 class EditFieldInfo;
67 class ScNavipiCfg;
68 class ScAddInCfg;
69 class ScTransferObj;
70 class ScDrawTransferObj;
71 class ScSelectionTransferObj;
72 class ScFormEditData;
73 class ScMarkData;
74 struct ScDragData;
75 struct ScClipData;
77 // for internal Drag&Drop:
79 #define SC_DROP_NAVIGATOR 1
80 #define SC_DROP_TABLE 2
82 class ScModule: public SfxModule, public SfxListener, utl::ConfigurationListener
84 Timer aIdleTimer;
85 Idle aSpellIdle;
86 ScDragData* mpDragData;
87 ScClipData* mpClipData;
88 ScSelectionTransferObj* pSelTransfer;
89 ScMessagePool* pMessagePool;
90 // there is no global InputHandler anymore, each View has it's own
91 ScInputHandler* pRefInputHandler;
92 ScViewCfg* pViewCfg;
93 ScDocCfg* pDocCfg;
94 ScAppCfg* pAppCfg;
95 ScDefaultsCfg* pDefaultsCfg;
96 ScFormulaCfg* pFormulaCfg;
97 ScInputCfg* pInputCfg;
98 ScPrintCfg* pPrintCfg;
99 ScNavipiCfg* pNavipiCfg;
100 ScAddInCfg* pAddInCfg;
101 svtools::ColorConfig* pColorConfig;
102 SvtAccessibilityOptions* pAccessOptions;
103 SvtCTLOptions* pCTLOptions;
104 SvtUserOptions* pUserOptions;
105 SfxErrorHandler* pErrorHdl;
106 ScFormEditData* pFormEditData;
107 sal_uInt16 nCurRefDlgId;
108 bool bIsWaterCan:1;
109 bool bIsInEditCommand:1;
110 bool bIsInExecuteDrop:1;
111 bool mbIsInSharedDocLoading:1;
112 bool mbIsInSharedDocSaving:1;
114 std::map<sal_uInt16, std::list<VclPtr<vcl::Window> > > m_mapRefWindow;
115 public:
116 SFX_DECL_INTERFACE(SCID_APP)
118 private:
119 /// SfxInterface initializer.
120 static void InitInterface_Impl();
122 public:
123 ScModule( SfxObjectFactory* pFact );
124 virtual ~ScModule();
126 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
127 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ) SAL_OVERRIDE;
128 void DeleteCfg();
130 // moved by the application
132 DECL_LINK_TYPED( IdleHandler, Timer*, void ); // Timer instead of idle
133 DECL_LINK_TYPED( SpellTimerHdl, Idle*, void );
134 DECL_LINK( CalcFieldValueHdl, EditFieldInfo* );
136 void Execute( SfxRequest& rReq );
137 void GetState( SfxItemSet& rSet );
138 static void HideDisabledSlots( SfxItemSet& rSet );
140 void AnythingChanged();
142 // Drag & Drop:
143 const ScDragData& GetDragData() const { return *mpDragData;}
144 void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
145 void ResetDragObject();
146 void SetDragLink(
147 const OUString& rDoc, const OUString& rTab, const OUString& rArea );
148 void SetDragJump(
149 ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText );
151 // clipboard:
152 const ScClipData& GetClipData() const { return *mpClipData;}
153 void SetClipObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
155 static ScDocument* GetClipDoc(); // called from document - should be removed later
157 // X selection:
158 ScSelectionTransferObj* GetSelectionTransfer() const { return pSelTransfer; }
159 void SetSelectionTransfer( ScSelectionTransferObj* pNew );
161 void SetWaterCan( bool bNew ) { bIsWaterCan = bNew; }
162 bool GetIsWaterCan() const { return bIsWaterCan; }
164 void SetInEditCommand( bool bNew ) { bIsInEditCommand = bNew; }
165 bool IsInEditCommand() const { return bIsInEditCommand; }
167 void SetInExecuteDrop( bool bNew ) { bIsInExecuteDrop = bNew; }
168 bool IsInExecuteDrop() const { return bIsInExecuteDrop; }
170 // Options:
171 const ScViewOptions& GetViewOptions ();
172 SC_DLLPUBLIC const ScDocOptions& GetDocOptions ();
173 SC_DLLPUBLIC const ScAppOptions& GetAppOptions ();
174 SC_DLLPUBLIC const ScDefaultsOptions& GetDefaultsOptions ();
175 SC_DLLPUBLIC const ScFormulaOptions& GetFormulaOptions ();
176 SC_DLLPUBLIC const ScInputOptions& GetInputOptions ();
177 SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions ();
178 void SetViewOptions ( const ScViewOptions& rOpt );
179 SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt );
180 SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt );
181 void SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
182 SC_DLLPUBLIC void SetFormulaOptions ( const ScFormulaOptions& rOpt );
183 SC_DLLPUBLIC void SetInputOptions ( const ScInputOptions& rOpt );
184 void SetPrintOptions ( const ScPrintOptions& rOpt );
185 void InsertEntryToLRUList(sal_uInt16 nFIndex);
186 static void RecentFunctionsChanged();
188 static void GetSpellSettings( sal_uInt16& rDefLang, sal_uInt16& rCjkLang, sal_uInt16& rCtlLang,
189 bool& rAutoSpell );
190 static void SetAutoSpellProperty( bool bSet );
191 static bool HasThesaurusLanguage( sal_uInt16 nLang );
193 sal_uInt16 GetOptDigitLanguage(); // from CTL options
195 ScNavipiCfg& GetNavipiCfg();
196 ScAddInCfg& GetAddInCfg();
197 svtools::ColorConfig& GetColorConfig();
198 SvtAccessibilityOptions& GetAccessOptions();
199 SvtCTLOptions& GetCTLOptions();
200 SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
202 void ModifyOptions( const SfxItemSet& rOptSet );
204 // InputHandler:
205 bool IsEditMode(); // not for SC_INPUT_TYPE
206 bool IsInputMode(); // also for SC_INPUT_TYPE
207 void SetInputMode( ScInputMode eMode, const OUString* pInitText = NULL );
208 bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false );
209 SC_DLLPUBLIC void InputEnterHandler( sal_uInt8 nBlockMode = 0 );
210 void InputCancelHandler();
211 void InputSelection( EditView* pView );
212 void InputChanged( EditView* pView );
213 ScInputHandler* GetInputHdl( ScTabViewShell* pViewSh = NULL, bool bUseRef = true );
215 void SetRefInputHdl( ScInputHandler* pNew );
216 ScInputHandler* GetRefInputHdl() { return pRefInputHandler;}
218 void ViewShellGone(ScTabViewShell* pViewSh);
219 void ViewShellChanged();
220 // communication with function-autopilot
221 void InputGetSelection( sal_Int32& rStart, sal_Int32& rEnd );
222 void InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd );
223 void InputReplaceSelection( const OUString& rStr );
224 void InputTurnOffWinEngine();
225 OUString InputGetFormulaStr();
226 void ActivateInputWindow( const OUString* pStr = NULL,
227 bool bMatrix = false );
229 void InitFormEditData();
230 void ClearFormEditData();
231 ScFormEditData* GetFormEditData() { return pFormEditData; }
233 // input of reference:
234 SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = NULL );
235 bool IsModalMode(SfxObjectShell* pDocSh = NULL);
236 bool IsFormulaMode();
237 bool IsRefDialogOpen();
238 bool IsTableLocked();
239 void SetReference( const ScRange& rRef, ScDocument* pDoc,
240 const ScMarkData* pMarkData = NULL );
241 void AddRefEntry();
242 void EndReference();
243 sal_uInt16 GetCurRefDlgId() const { return nCurRefDlgId; }
245 // virtual methods for the options dialog
246 virtual SfxItemSet* CreateItemSet( sal_uInt16 nId ) SAL_OVERRIDE;
247 virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) SAL_OVERRIDE;
248 virtual VclPtr<SfxTabPage> CreateTabPage( sal_uInt16 nId, vcl::Window* pParent, const SfxItemSet& rSet ) SAL_OVERRIDE;
250 void SetInSharedDocLoading( bool bNew ) { mbIsInSharedDocLoading = bNew; }
251 bool IsInSharedDocLoading() const { return mbIsInSharedDocLoading; }
252 void SetInSharedDocSaving( bool bNew ) { mbIsInSharedDocSaving = bNew; }
253 bool IsInSharedDocSaving() const { return mbIsInSharedDocSaving; }
255 SC_DLLPUBLIC bool RegisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd );
256 SC_DLLPUBLIC bool UnregisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd );
257 SC_DLLPUBLIC vcl::Window * Find1RefWindow( sal_uInt16 nSlotId, vcl::Window *pWndAncestor );
260 #define SC_MOD() ( *reinterpret_cast<ScModule**>(GetAppData(SHL_CALC)) )
262 void global_InitAppOptions();
264 #endif
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */