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