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" // ScInputMode
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 :
38 : class KeyEvent;
39 : class EditView;
40 : class SfxErrorHandler;
41 : class SvtAccessibilityOptions;
42 : class SvtCTLOptions;
43 : class SvtUserOptions;
44 :
45 : namespace svtools { class ColorConfig; }
46 :
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;
76 : class ScAnyRefModalDlg;
77 :
78 : //==================================================================
79 :
80 : // for internal Drag&Drop:
81 :
82 : #define SC_DROP_NAVIGATOR 1
83 : #define SC_DROP_TABLE 2
84 :
85 : //==================================================================
86 :
87 : class ScModule: public SfxModule, public SfxListener, utl::ConfigurationListener
88 : {
89 : Timer aIdleTimer;
90 : Timer aSpellTimer;
91 : ScDragData* mpDragData;
92 : ScClipData* mpClipData;
93 : ScSelectionTransferObj* pSelTransfer;
94 : ScMessagePool* pMessagePool;
95 : // there is no global InputHandler anymore, each View has it's own
96 : ScInputHandler* pRefInputHandler;
97 : ScViewCfg* pViewCfg;
98 : ScDocCfg* pDocCfg;
99 : ScAppCfg* pAppCfg;
100 : ScDefaultsCfg* pDefaultsCfg;
101 : ScFormulaCfg* pFormulaCfg;
102 : ScInputCfg* pInputCfg;
103 : ScPrintCfg* pPrintCfg;
104 : ScNavipiCfg* pNavipiCfg;
105 : ScAddInCfg* pAddInCfg;
106 : svtools::ColorConfig* pColorConfig;
107 : SvtAccessibilityOptions* pAccessOptions;
108 : SvtCTLOptions* pCTLOptions;
109 : SvtUserOptions* pUserOptions;
110 : SfxErrorHandler* pErrorHdl;
111 : ScFormEditData* pFormEditData;
112 : sal_uInt16 nCurRefDlgId;
113 : bool bIsWaterCan:1;
114 : bool bIsInEditCommand:1;
115 : bool bIsInExecuteDrop:1;
116 : bool mbIsInSharedDocLoading:1;
117 : bool mbIsInSharedDocSaving:1;
118 :
119 : std::map<sal_uInt16, std::list<Window*> > m_mapRefWindow;
120 : std::stack<ScAnyRefModalDlg*> maAnyRefDlgStack;
121 : public:
122 5 : SFX_DECL_INTERFACE(SCID_APP)
123 :
124 : ScModule( SfxObjectFactory* pFact );
125 : virtual ~ScModule();
126 :
127 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
128 : virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
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 : const ScDragData& GetDragData() const;
145 : void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
146 : void ResetDragObject();
147 : void SetDragLink(
148 : const rtl::OUString& rDoc, const rtl::OUString& rTab, const rtl::OUString& rArea );
149 : void SetDragJump(
150 : ScDocument* pLocalDoc, const rtl::OUString& rTarget, const rtl::OUString& rText );
151 :
152 : // clipboard:
153 : const ScClipData& GetClipData() const;
154 : void SetClipObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
155 :
156 : ScDocument* GetClipDoc(); // called from document - should be removed later
157 :
158 : // X selection:
159 0 : 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 : 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 : 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 : sal_Bool& rAutoSpell );
191 : static void SetAutoSpellProperty( sal_Bool bSet );
192 : static sal_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 : SvtUserOptions& GetUserOptions();
202 :
203 : void ModifyOptions( const SfxItemSet& rOptSet );
204 :
205 : // InputHandler:
206 : sal_Bool IsEditMode(); // not for SC_INPUT_TYPE
207 : sal_Bool IsInputMode(); // also for SC_INPUT_TYPE
208 : void SetInputMode( ScInputMode eMode );
209 : sal_Bool InputKeyEvent( const KeyEvent& rKEvt, sal_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, sal_Bool bUseRef = sal_True );
215 :
216 : void SetRefInputHdl( ScInputHandler* pNew );
217 : ScInputHandler* GetRefInputHdl();
218 :
219 : void ViewShellGone(ScTabViewShell* pViewSh);
220 : void ViewShellChanged();
221 : // communication with function-autopilot
222 : void InputGetSelection( xub_StrLen& rStart, xub_StrLen& rEnd );
223 : void InputSetSelection( xub_StrLen nStart, xub_StrLen nEnd );
224 : void InputReplaceSelection( const String& rStr );
225 : String InputGetFormulaStr();
226 : void ActivateInputWindow( const String* pStr = NULL,
227 : sal_Bool bMatrix = false );
228 :
229 : void InitFormEditData();
230 : void ClearFormEditData();
231 0 : ScFormEditData* GetFormEditData() { return pFormEditData; }
232 :
233 : // input of reference:
234 : SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, sal_Bool bVis, SfxViewFrame* pViewFrm = NULL );
235 : sal_Bool IsModalMode(SfxObjectShell* pDocSh = NULL);
236 : sal_Bool IsFormulaMode();
237 : sal_Bool IsRefDialogOpen();
238 : sal_Bool IsTableLocked();
239 : void SetReference( const ScRange& rRef, ScDocument* pDoc,
240 : const ScMarkData* pMarkData = NULL );
241 : void AddRefEntry();
242 : void EndReference();
243 0 : sal_uInt16 GetCurRefDlgId() const { return nCurRefDlgId; }
244 :
245 : // virtual methods for the options dialog
246 : virtual SfxItemSet* CreateItemSet( sal_uInt16 nId );
247 : virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
248 : virtual SfxTabPage* CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet );
249 :
250 0 : void SetInSharedDocLoading( bool bNew ) { mbIsInSharedDocLoading = bNew; }
251 0 : bool IsInSharedDocLoading() const { return mbIsInSharedDocLoading; }
252 0 : void SetInSharedDocSaving( bool bNew ) { mbIsInSharedDocSaving = bNew; }
253 0 : bool IsInSharedDocSaving() const { return mbIsInSharedDocSaving; }
254 :
255 : SC_DLLPUBLIC sal_Bool RegisterRefWindow( sal_uInt16 nSlotId, Window *pWnd );
256 : SC_DLLPUBLIC sal_Bool UnregisterRefWindow( sal_uInt16 nSlotId, Window *pWnd );
257 : SC_DLLPUBLIC sal_Bool IsAliveRefDlg( sal_uInt16 nSlotId, Window *pWnd );
258 : SC_DLLPUBLIC Window * Find1RefWindow( sal_uInt16 nSlotId, 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 : #endif
268 :
269 :
270 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|