Line data Source code
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 :
20 : #ifndef INCLUDED_SC_INC_SCMOD_HXX
21 : #define INCLUDED_SC_INC_SCMOD_HXX
22 :
23 : #include "scdllapi.h"
24 : #include "scdll.hxx"
25 : #include <vcl/timer.hxx>
26 : #include <svl/lstner.hxx>
27 : #include "global.hxx"
28 : #include "shellids.hxx"
29 : #include <unotools/options.hxx>
30 : #include <tools/shl.hxx>
31 :
32 : #include <map>
33 : #include <list>
34 : #include <algorithm>
35 : #include <stack>
36 :
37 : class KeyEvent;
38 : class EditView;
39 : class SfxErrorHandler;
40 : class SvtAccessibilityOptions;
41 : class SvtCTLOptions;
42 : class SvtUserOptions;
43 :
44 : namespace svtools { class ColorConfig; }
45 :
46 : class ScRange;
47 : class ScDocument;
48 : class ScViewCfg;
49 : class ScDocCfg;
50 : class ScAppCfg;
51 : class ScDefaultsCfg;
52 : class ScFormulaCfg;
53 : class ScInputCfg;
54 : class ScPrintCfg;
55 : class ScViewOptions;
56 : class ScDocOptions;
57 : class ScAppOptions;
58 : class ScDefaultsOptions;
59 : class ScFormulaOptions;
60 : class ScInputOptions;
61 : class ScPrintOptions;
62 : class ScInputHandler;
63 : class ScTabViewShell;
64 : class ScMessagePool;
65 : class EditFieldInfo;
66 : class ScNavipiCfg;
67 : class ScAddInCfg;
68 : class ScTransferObj;
69 : class ScDrawTransferObj;
70 : class ScSelectionTransferObj;
71 : class ScFormEditData;
72 : class ScMarkData;
73 : struct ScDragData;
74 : struct ScClipData;
75 : class ScAnyRefModalDlg;
76 :
77 : // for internal Drag&Drop:
78 :
79 : #define SC_DROP_NAVIGATOR 1
80 : #define SC_DROP_TABLE 2
81 :
82 : class ScModule: public SfxModule, public SfxListener, utl::ConfigurationListener
83 : {
84 : Timer aIdleTimer;
85 : Timer aSpellTimer;
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;
113 :
114 : std::map<sal_uInt16, std::list<vcl::Window*> > m_mapRefWindow;
115 : std::stack<ScAnyRefModalDlg*> maAnyRefDlgStack;
116 : public:
117 76 : SFX_DECL_INTERFACE(SCID_APP)
118 :
119 : private:
120 : /// SfxInterface initializer.
121 : static void InitInterface_Impl();
122 :
123 : public:
124 : ScModule( SfxObjectFactory* pFact );
125 : virtual ~ScModule();
126 :
127 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
128 : virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ) SAL_OVERRIDE;
129 : void DeleteCfg();
130 :
131 : // moved by the application
132 :
133 : DECL_LINK( IdleHandler, void* ); // Timer instead of idle
134 : DECL_LINK( SpellTimerHdl, void* );
135 : DECL_LINK( CalcFieldValueHdl, EditFieldInfo* );
136 :
137 : void Execute( SfxRequest& rReq );
138 : void GetState( SfxItemSet& rSet );
139 : void HideDisabledSlots( SfxItemSet& rSet );
140 :
141 : void AnythingChanged();
142 :
143 : // Drag & Drop:
144 22 : const ScDragData& GetDragData() const { return *mpDragData;}
145 : void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
146 : void ResetDragObject();
147 : void SetDragLink(
148 : const OUString& rDoc, const OUString& rTab, const OUString& rArea );
149 : void SetDragJump(
150 : ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText );
151 :
152 : // clipboard:
153 2802 : const ScClipData& GetClipData() const { return *mpClipData;}
154 : void SetClipObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
155 :
156 : ScDocument* GetClipDoc(); // called from document - should be removed later
157 :
158 : // X selection:
159 5448 : ScSelectionTransferObj* GetSelectionTransfer() const { return pSelTransfer; }
160 : void SetSelectionTransfer( ScSelectionTransferObj* pNew );
161 :
162 0 : void SetWaterCan( bool bNew ) { bIsWaterCan = bNew; }
163 0 : bool GetIsWaterCan() const { return bIsWaterCan; }
164 :
165 0 : void SetInEditCommand( bool bNew ) { bIsInEditCommand = bNew; }
166 : bool IsInEditCommand() const { return bIsInEditCommand; }
167 :
168 0 : void SetInExecuteDrop( bool bNew ) { bIsInExecuteDrop = bNew; }
169 0 : bool IsInExecuteDrop() const { return bIsInExecuteDrop; }
170 :
171 : // Options:
172 : const ScViewOptions& GetViewOptions ();
173 : SC_DLLPUBLIC const ScDocOptions& GetDocOptions ();
174 : SC_DLLPUBLIC const ScAppOptions& GetAppOptions ();
175 : SC_DLLPUBLIC const ScDefaultsOptions& GetDefaultsOptions ();
176 : SC_DLLPUBLIC const ScFormulaOptions& GetFormulaOptions ();
177 : const ScInputOptions& GetInputOptions ();
178 : SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions ();
179 : void SetViewOptions ( const ScViewOptions& rOpt );
180 : SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt );
181 : SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt );
182 : void SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
183 : SC_DLLPUBLIC void SetFormulaOptions ( const ScFormulaOptions& rOpt );
184 : void SetInputOptions ( const ScInputOptions& rOpt );
185 : void SetPrintOptions ( const ScPrintOptions& rOpt );
186 : void InsertEntryToLRUList(sal_uInt16 nFIndex);
187 : void RecentFunctionsChanged();
188 :
189 : static void GetSpellSettings( sal_uInt16& rDefLang, sal_uInt16& rCjkLang, sal_uInt16& rCtlLang,
190 : bool& rAutoSpell );
191 : static void SetAutoSpellProperty( bool bSet );
192 : static bool HasThesaurusLanguage( sal_uInt16 nLang );
193 :
194 : sal_uInt16 GetOptDigitLanguage(); // from CTL options
195 :
196 : ScNavipiCfg& GetNavipiCfg();
197 : ScAddInCfg& GetAddInCfg();
198 : svtools::ColorConfig& GetColorConfig();
199 : SvtAccessibilityOptions& GetAccessOptions();
200 : SvtCTLOptions& GetCTLOptions();
201 : SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
202 :
203 : void ModifyOptions( const SfxItemSet& rOptSet );
204 :
205 : // InputHandler:
206 : bool IsEditMode(); // not for SC_INPUT_TYPE
207 : bool IsInputMode(); // also for SC_INPUT_TYPE
208 : void SetInputMode( ScInputMode eMode, const OUString* pInitText = NULL );
209 : bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false );
210 : SC_DLLPUBLIC void InputEnterHandler( sal_uInt8 nBlockMode = 0 );
211 : void InputCancelHandler();
212 : void InputSelection( EditView* pView );
213 : void InputChanged( EditView* pView );
214 : ScInputHandler* GetInputHdl( ScTabViewShell* pViewSh = NULL, bool bUseRef = true );
215 :
216 : void SetRefInputHdl( ScInputHandler* pNew );
217 546 : ScInputHandler* GetRefInputHdl() { return pRefInputHandler;}
218 :
219 : void ViewShellGone(ScTabViewShell* pViewSh);
220 : void ViewShellChanged();
221 : // communication with function-autopilot
222 : void InputGetSelection( sal_Int32& rStart, sal_Int32& rEnd );
223 : void InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd );
224 : void InputReplaceSelection( const OUString& rStr );
225 : void InputTurnOffWinEngine();
226 : OUString InputGetFormulaStr();
227 : void ActivateInputWindow( const OUString* pStr = NULL,
228 : bool bMatrix = false );
229 :
230 : void InitFormEditData();
231 : void ClearFormEditData();
232 1700 : ScFormEditData* GetFormEditData() { return pFormEditData; }
233 :
234 : // input of reference:
235 : SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = NULL );
236 : bool IsModalMode(SfxObjectShell* pDocSh = NULL);
237 : bool IsFormulaMode();
238 : bool IsRefDialogOpen();
239 : bool IsTableLocked();
240 : void SetReference( const ScRange& rRef, ScDocument* pDoc,
241 : const ScMarkData* pMarkData = NULL );
242 : void AddRefEntry();
243 : void EndReference();
244 4 : sal_uInt16 GetCurRefDlgId() const { return nCurRefDlgId; }
245 :
246 : // virtual methods for the options dialog
247 : virtual SfxItemSet* CreateItemSet( sal_uInt16 nId ) SAL_OVERRIDE;
248 : virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) SAL_OVERRIDE;
249 : virtual SfxTabPage* CreateTabPage( sal_uInt16 nId, vcl::Window* pParent, const SfxItemSet& rSet ) SAL_OVERRIDE;
250 :
251 0 : void SetInSharedDocLoading( bool bNew ) { mbIsInSharedDocLoading = bNew; }
252 0 : bool IsInSharedDocLoading() const { return mbIsInSharedDocLoading; }
253 0 : void SetInSharedDocSaving( bool bNew ) { mbIsInSharedDocSaving = bNew; }
254 0 : bool IsInSharedDocSaving() const { return mbIsInSharedDocSaving; }
255 :
256 : SC_DLLPUBLIC bool RegisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd );
257 : SC_DLLPUBLIC bool UnregisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd );
258 : SC_DLLPUBLIC vcl::Window * Find1RefWindow( sal_uInt16 nSlotId, vcl::Window *pWndAncestor );
259 :
260 : ScAnyRefModalDlg* GetCurrentAnyRefDlg();
261 : void PushNewAnyRefDlg( ScAnyRefModalDlg* pDlg );
262 : void PopAnyRefDlg();
263 : };
264 :
265 : #define SC_MOD() ( *(ScModule**) GetAppData(SHL_CALC) )
266 :
267 : void global_InitAppOptions();
268 :
269 : #endif
270 :
271 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|