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 SC_SCMOD_HXX
21 : #define SC_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<Window*> > m_mapRefWindow;
115 : std::stack<ScAnyRefModalDlg*> maAnyRefDlgStack;
116 : public:
117 0 : SFX_DECL_INTERFACE(SCID_APP)
118 :
119 : ScModule( SfxObjectFactory* pFact );
120 : virtual ~ScModule();
121 :
122 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
123 : virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ) SAL_OVERRIDE;
124 : void DeleteCfg();
125 :
126 : // moved by the application
127 :
128 : DECL_LINK( IdleHandler, void* ); // Timer instead of idle
129 : DECL_LINK( SpellTimerHdl, void* );
130 : DECL_LINK( CalcFieldValueHdl, EditFieldInfo* );
131 :
132 : void Execute( SfxRequest& rReq );
133 : void GetState( SfxItemSet& rSet );
134 : void HideDisabledSlots( SfxItemSet& rSet );
135 :
136 : void AnythingChanged();
137 :
138 : // Drag & Drop:
139 : const ScDragData& GetDragData() const;
140 : void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
141 : void ResetDragObject();
142 : void SetDragLink(
143 : const OUString& rDoc, const OUString& rTab, const OUString& rArea );
144 : void SetDragJump(
145 : ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText );
146 :
147 : // clipboard:
148 : const ScClipData& GetClipData() const;
149 : void SetClipObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
150 :
151 : ScDocument* GetClipDoc(); // called from document - should be removed later
152 :
153 : // X selection:
154 0 : ScSelectionTransferObj* GetSelectionTransfer() const { return pSelTransfer; }
155 : void SetSelectionTransfer( ScSelectionTransferObj* pNew );
156 :
157 0 : void SetWaterCan( bool bNew ) { bIsWaterCan = bNew; }
158 0 : bool GetIsWaterCan() const { return bIsWaterCan; }
159 :
160 0 : void SetInEditCommand( bool bNew ) { bIsInEditCommand = bNew; }
161 : bool IsInEditCommand() const { return bIsInEditCommand; }
162 :
163 0 : void SetInExecuteDrop( bool bNew ) { bIsInExecuteDrop = bNew; }
164 0 : bool IsInExecuteDrop() const { return bIsInExecuteDrop; }
165 :
166 : // Options:
167 : const ScViewOptions& GetViewOptions ();
168 : SC_DLLPUBLIC const ScDocOptions& GetDocOptions ();
169 : SC_DLLPUBLIC const ScAppOptions& GetAppOptions ();
170 : SC_DLLPUBLIC const ScDefaultsOptions& GetDefaultsOptions ();
171 : SC_DLLPUBLIC const ScFormulaOptions& GetFormulaOptions ();
172 : const ScInputOptions& GetInputOptions ();
173 : SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions ();
174 : void SetViewOptions ( const ScViewOptions& rOpt );
175 : SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt );
176 : SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt );
177 : void SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
178 : SC_DLLPUBLIC void SetFormulaOptions ( const ScFormulaOptions& rOpt );
179 : void SetInputOptions ( const ScInputOptions& rOpt );
180 : void SetPrintOptions ( const ScPrintOptions& rOpt );
181 : void InsertEntryToLRUList(sal_uInt16 nFIndex);
182 : void RecentFunctionsChanged();
183 :
184 : static void GetSpellSettings( sal_uInt16& rDefLang, sal_uInt16& rCjkLang, sal_uInt16& rCtlLang,
185 : bool& rAutoSpell );
186 : static void SetAutoSpellProperty( bool bSet );
187 : static bool HasThesaurusLanguage( sal_uInt16 nLang );
188 :
189 : sal_uInt16 GetOptDigitLanguage(); // from CTL options
190 :
191 : ScNavipiCfg& GetNavipiCfg();
192 : ScAddInCfg& GetAddInCfg();
193 : svtools::ColorConfig& GetColorConfig();
194 : SvtAccessibilityOptions& GetAccessOptions();
195 : SvtCTLOptions& GetCTLOptions();
196 : SvtUserOptions& GetUserOptions();
197 :
198 : void ModifyOptions( const SfxItemSet& rOptSet );
199 :
200 : // InputHandler:
201 : bool IsEditMode(); // not for SC_INPUT_TYPE
202 : bool IsInputMode(); // also for SC_INPUT_TYPE
203 : void SetInputMode( ScInputMode eMode );
204 : bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false );
205 : SC_DLLPUBLIC void InputEnterHandler( sal_uInt8 nBlockMode = 0 );
206 : void InputCancelHandler();
207 : void InputSelection( EditView* pView );
208 : void InputChanged( EditView* pView );
209 : ScInputHandler* GetInputHdl( ScTabViewShell* pViewSh = NULL, bool bUseRef = true );
210 :
211 : void SetRefInputHdl( ScInputHandler* pNew );
212 : ScInputHandler* GetRefInputHdl();
213 :
214 : void ViewShellGone(ScTabViewShell* pViewSh);
215 : void ViewShellChanged();
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 = NULL,
223 : bool bMatrix = false );
224 :
225 : void InitFormEditData();
226 : void ClearFormEditData();
227 0 : ScFormEditData* GetFormEditData() { return pFormEditData; }
228 :
229 : // input of reference:
230 : SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = NULL );
231 : bool IsModalMode(SfxObjectShell* pDocSh = NULL);
232 : bool IsFormulaMode();
233 : bool IsRefDialogOpen();
234 : bool IsTableLocked();
235 : void SetReference( const ScRange& rRef, ScDocument* pDoc,
236 : const ScMarkData* pMarkData = NULL );
237 : void AddRefEntry();
238 : void EndReference();
239 0 : sal_uInt16 GetCurRefDlgId() const { return nCurRefDlgId; }
240 :
241 : // virtual methods for the options dialog
242 : virtual SfxItemSet* CreateItemSet( sal_uInt16 nId ) SAL_OVERRIDE;
243 : virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) SAL_OVERRIDE;
244 : virtual SfxTabPage* CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet ) SAL_OVERRIDE;
245 :
246 0 : void SetInSharedDocLoading( bool bNew ) { mbIsInSharedDocLoading = bNew; }
247 0 : bool IsInSharedDocLoading() const { return mbIsInSharedDocLoading; }
248 0 : void SetInSharedDocSaving( bool bNew ) { mbIsInSharedDocSaving = bNew; }
249 0 : bool IsInSharedDocSaving() const { return mbIsInSharedDocSaving; }
250 :
251 : SC_DLLPUBLIC bool RegisterRefWindow( sal_uInt16 nSlotId, Window *pWnd );
252 : SC_DLLPUBLIC bool UnregisterRefWindow( sal_uInt16 nSlotId, Window *pWnd );
253 : SC_DLLPUBLIC bool IsAliveRefDlg( sal_uInt16 nSlotId, Window *pWnd );
254 : SC_DLLPUBLIC Window * Find1RefWindow( sal_uInt16 nSlotId, Window *pWndAncestor );
255 :
256 : ScAnyRefModalDlg* GetCurrentAnyRefDlg();
257 : void PushNewAnyRefDlg( ScAnyRefModalDlg* pDlg );
258 : void PopAnyRefDlg();
259 : };
260 :
261 : #define SC_MOD() ( *(ScModule**) GetAppData(SHL_CALC) )
262 :
263 : #endif
264 :
265 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|