xref: /aoo41x/main/sc/inc/scmod.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_SCMOD_HXX
29 #define SC_SCMOD_HXX
30 
31 #include "scdllapi.h"
32 #include "scdll.hxx"
33 #include <vcl/timer.hxx>
34 #include <svl/lstner.hxx>
35 #include "global.hxx"		// ScInputMode
36 #include "markdata.hxx"		//ScMarkData
37 #include "shellids.hxx"
38 #include <unotools/options.hxx>
39 #include <tools/shl.hxx>
40 
41 //<!--Added by PengYunQuan for Validity Cell Range Picker
42 #include <map>
43 #include <list>
44 #include <algorithm>
45 //-->Added by PengYunQuan for Validity Cell Range Picker
46 
47 
48 class KeyEvent;
49 class SdrModel;
50 class SdrView;
51 class EditView;
52 class SfxErrorHandler;
53 class SvxErrorHandler;
54 class SvtAccessibilityOptions;
55 class SvtCTLOptions;
56 class SvtUserOptions;
57 
58 namespace svtools { class ColorConfig; }
59 
60 class ScRange;
61 class ScDocument;
62 class ScViewCfg;
63 class ScDocCfg;
64 class ScAppCfg;
65 class ScInputCfg;
66 class ScPrintCfg;
67 class ScViewOptions;
68 class ScDocOptions;
69 class ScAppOptions;
70 class ScInputOptions;
71 class ScPrintOptions;
72 class ScInputHandler;
73 class ScInputWindow;
74 class ScTabViewShell;
75 class ScFunctionDlg;
76 class ScArgDlgBase;
77 class ScEditFunctionDlg;
78 class ScMessagePool;
79 class EditFieldInfo;
80 class ScNavipiCfg;
81 class ScAddInCfg;
82 
83 class ScTransferObj;
84 class ScDrawTransferObj;
85 class ScSelectionTransferObj;
86 
87 class ScFormEditData;
88 
89 //==================================================================
90 
91 //		for internal Drag&Drop:
92 
93 #define SC_DROP_NAVIGATOR		1
94 #define SC_DROP_TABLE			2
95 
96 struct ScDragData
97 {
98 	ScTransferObj*		pCellTransfer;
99 	ScDrawTransferObj*	pDrawTransfer;
100 
101 	String				aLinkDoc;
102 	String				aLinkTable;
103 	String				aLinkArea;
104 	ScDocument*			pJumpLocalDoc;
105 	String				aJumpTarget;
106 	String				aJumpText;
107 };
108 
109 struct ScClipData
110 {
111 	ScTransferObj*		pCellClipboard;
112 	ScDrawTransferObj*	pDrawClipboard;
113 };
114 
115 //==================================================================
116 
117 
118 class ScModule: public SfxModule, public SfxListener, utl::ConfigurationListener
119 {
120 	Timer				aIdleTimer;
121 	Timer				aSpellTimer;
122 	ScDragData			aDragData;
123 	ScClipData			aClipData;
124 	ScSelectionTransferObj* pSelTransfer;
125 	ScMessagePool*      pMessagePool;
126 	//	globalen InputHandler gibt's nicht mehr, jede View hat einen
127 	ScInputHandler*     pRefInputHandler;
128 	ScViewCfg*			pViewCfg;
129 	ScDocCfg*			pDocCfg;
130 	ScAppCfg*           pAppCfg;
131 	ScInputCfg*			pInputCfg;
132 	ScPrintCfg*			pPrintCfg;
133 	ScNavipiCfg*		pNavipiCfg;
134     ScAddInCfg*         pAddInCfg;
135     svtools::ColorConfig*   pColorConfig;
136 	SvtAccessibilityOptions* pAccessOptions;
137 	SvtCTLOptions*		pCTLOptions;
138     SvtUserOptions*     pUserOptions;
139 	SfxErrorHandler*	pErrorHdl;
140 	SvxErrorHandler* 	pSvxErrorHdl;
141 	ScFormEditData*		pFormEditData;
142 	sal_uInt16				nCurRefDlgId;
143 	sal_Bool				bIsWaterCan;
144 	sal_Bool				bIsInEditCommand;
145     sal_Bool                bIsInExecuteDrop;
146     bool                mbIsInSharedDocLoading;
147     bool                mbIsInSharedDocSaving;
148 
149 	//<!--Added by PengYunQuan for Validity Cell Range Picker
150 	std::map<sal_uInt16, std::list<Window*> > m_mapRefWindow;
151 	//-->Added by PengYunQuan for Validity Cell Range Picker
152 public:
153 					SFX_DECL_INTERFACE(SCID_APP)
154 
155 					ScModule( SfxObjectFactory* pFact );
156 	virtual			~ScModule();
157 
158 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
159 	virtual void		ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
160 	void				DeleteCfg();
161 
162 						// von der Applikation verschoben:
163 
164 	DECL_LINK( IdleHandler,		Timer* );	// Timer statt idle
165 	DECL_LINK( SpellTimerHdl,	Timer* );
166 	DECL_LINK( CalcFieldValueHdl, EditFieldInfo* );
167 
168 	void				Execute( SfxRequest& rReq );
169 	void 				GetState( SfxItemSet& rSet );
170     void                HideDisabledSlots( SfxItemSet& rSet );
171 
172 	void				AnythingChanged();
173 
174 	//	Drag & Drop:
175 	const ScDragData&	GetDragData() const		{ return aDragData; }
176 	void				SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
177 	void				ResetDragObject();
178 	void				SetDragLink( const String& rDoc, const String& rTab, const String& rArea );
179 	void				SetDragJump( ScDocument* pLocalDoc,
180 									const String& rTarget, const String& rText );
181 
182 	//	clipboard:
183 	const ScClipData&	GetClipData() const		{ return aClipData; }
184 	void				SetClipObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
185 
186 	ScDocument*			GetClipDoc();		// called from document - should be removed later
187 
188 	//	X selection:
189 	ScSelectionTransferObj*	GetSelectionTransfer() const	{ return pSelTransfer; }
190 	void				SetSelectionTransfer( ScSelectionTransferObj* pNew );
191 
192 	void				SetWaterCan( sal_Bool bNew )	{ bIsWaterCan = bNew; }
193 	sal_Bool				GetIsWaterCan() const 		{ return bIsWaterCan; }
194 
195 	void				SetInEditCommand( sal_Bool bNew )	{ bIsInEditCommand = bNew; }
196 	sal_Bool				IsInEditCommand() const 		{ return bIsInEditCommand; }
197 
198     void                SetInExecuteDrop( sal_Bool bNew )   { bIsInExecuteDrop = bNew; }
199     sal_Bool                IsInExecuteDrop() const         { return bIsInExecuteDrop; }
200 
201 	// Options:
202 	const ScViewOptions&	GetViewOptions	();
203 	const ScDocOptions&		GetDocOptions	();
204 SC_DLLPUBLIC	const ScAppOptions&		GetAppOptions	();
205 	const ScInputOptions&	GetInputOptions	();
206 SC_DLLPUBLIC	const ScPrintOptions&	GetPrintOptions	();
207 	void					SetViewOptions	( const ScViewOptions& rOpt );
208 	void					SetDocOptions	( const ScDocOptions& rOpt );
209 SC_DLLPUBLIC	void					SetAppOptions	( const ScAppOptions& rOpt );
210 	void					SetInputOptions	( const ScInputOptions& rOpt );
211 	void					SetPrintOptions	( const ScPrintOptions& rOpt );
212 	void					InsertEntryToLRUList(sal_uInt16 nFIndex);
213 	void					RecentFunctionsChanged();
214 
215 	static void			GetSpellSettings( sal_uInt16& rDefLang, sal_uInt16& rCjkLang, sal_uInt16& rCtlLang,
216                                         sal_Bool& rAutoSpell );
217 	static void			SetAutoSpellProperty( sal_Bool bSet );
218 	static sal_Bool			HasThesaurusLanguage( sal_uInt16 nLang );
219 
220 	sal_uInt16				GetOptDigitLanguage();		// from CTL options
221 
222 	ScNavipiCfg&		GetNavipiCfg();
223     ScAddInCfg&         GetAddInCfg();
224     svtools::ColorConfig&   GetColorConfig();
225 	SvtAccessibilityOptions& GetAccessOptions();
226 	SvtCTLOptions&		GetCTLOptions();
227     SvtUserOptions&     GetUserOptions();
228 
229 	void				ModifyOptions( const SfxItemSet& rOptSet );
230 
231 	//	InputHandler:
232 	sal_Bool                IsEditMode();	// nicht bei SC_INPUT_TYPE
233 	sal_Bool                IsInputMode();	// auch bei SC_INPUT_TYPE
234 	void                SetInputMode( ScInputMode eMode );
235 	sal_Bool                InputKeyEvent( const KeyEvent& rKEvt, sal_Bool bStartEdit = sal_False );
236 	SC_DLLPUBLIC void                InputEnterHandler( sal_uInt8 nBlockMode = 0 );
237 	void                InputCancelHandler();
238 	void                InputSelection( EditView* pView );
239 	void                InputChanged( EditView* pView );
240 	ScInputHandler*		GetInputHdl( ScTabViewShell* pViewSh = NULL, sal_Bool bUseRef = sal_True );
241 
242 	void				SetRefInputHdl( ScInputHandler* pNew );
243 	ScInputHandler*		GetRefInputHdl();
244 
245 	void				ViewShellGone(ScTabViewShell* pViewSh);
246 	void				ViewShellChanged();
247 	// Kommunikation mit Funktionsautopilot
248 	void				InputGetSelection( xub_StrLen& rStart, xub_StrLen& rEnd );
249 	void			 	InputSetSelection( xub_StrLen nStart, xub_StrLen nEnd );
250 	void			 	InputReplaceSelection( const String& rStr );
251 	String				InputGetFormulaStr();
252 	void				ActivateInputWindow( const String* pStr = NULL,
253 												sal_Bool bMatrix = sal_False );
254 
255 	void				InitFormEditData();
256 	void				ClearFormEditData();
257 	ScFormEditData*		GetFormEditData()		{ return pFormEditData; }
258 
259 	//	Referenzeingabe:
260 	//<!--Added by PengYunQuan for Validity Cell Range Picker
261 	//void				SetRefDialog( sal_uInt16 nId, sal_Bool bVis, SfxViewFrame* pViewFrm = NULL );
262 	SC_DLLPUBLIC void				SetRefDialog( sal_uInt16 nId, sal_Bool bVis, SfxViewFrame* pViewFrm = NULL );
263 	//-->Added by PengYunQuan for Validity Cell Range Picker
264 	sal_Bool                IsModalMode(SfxObjectShell* pDocSh = NULL);
265 	sal_Bool                IsFormulaMode();
266 	sal_Bool                IsRefDialogOpen();
267 	sal_Bool				IsTableLocked();
268 	void				SetReference( const ScRange& rRef, ScDocument* pDoc,
269 										const ScMarkData* pMarkData = NULL );
270 	void				AddRefEntry();
271 	void                EndReference();
272 	sal_uInt16				GetCurRefDlgId() const					{ return nCurRefDlgId; }
273 
274 	//virtuelle Methoden fuer den Optionendialog
275 	virtual SfxItemSet*	 CreateItemSet( sal_uInt16 nId );
276 	virtual void		 ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
277 	virtual	SfxTabPage*	 CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet );
278 
279     void                SetInSharedDocLoading( bool bNew )  { mbIsInSharedDocLoading = bNew; }
280     bool                IsInSharedDocLoading() const        { return mbIsInSharedDocLoading; }
281     void                SetInSharedDocSaving( bool bNew )   { mbIsInSharedDocSaving = bNew; }
282     bool                IsInSharedDocSaving() const         { return mbIsInSharedDocSaving; }
283 
284     SC_DLLPUBLIC sal_Bool   RegisterRefWindow( sal_uInt16 nSlotId, Window *pWnd );
285     SC_DLLPUBLIC sal_Bool   UnregisterRefWindow( sal_uInt16 nSlotId, Window *pWnd );
286     SC_DLLPUBLIC sal_Bool   IsAliveRefDlg( sal_uInt16 nSlotId, Window *pWnd );
287     SC_DLLPUBLIC Window * Find1RefWindow( sal_uInt16 nSlotId, Window *pWndAncestor );
288     SC_DLLPUBLIC Window * Find1RefWindow( Window *pWndAncestor );
289 };
290 
291 #define SC_MOD() ( *(ScModule**) GetAppData(SHL_CALC) )
292 
293 #endif
294 
295 
296