xref: /trunk/main/sfx2/inc/sfx2/app.hxx (revision 7168672c)
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 #ifndef _SFXAPP_HXX
24 #define _SFXAPP_HXX
25 
26 #include "sal/config.h"
27 #include "sfx2/dllapi.h"
28 #include "sal/types.h"
29 #include <tools/solar.h>
30 #include <tools/errcode.hxx>
31 #include <svl/smplhint.hxx>
32 #include <svl/poolitem.hxx>
33 #include <vcl/image.hxx>
34 #include <tools/ref.hxx>
35 #include <com/sun/star/uno/Reference.hxx>
36 #include <com/sun/star/script/XLibraryContainer.hpp>
37 #include <com/sun/star/task/XStatusIndicator.hpp>
38 
39 // too many files including sfx2/app.hxx use VCL Application class but don't include the
40 // header file because in former times SfxApplication was derived from it
41 #include <vcl/svapp.hxx>
42 
43 #include <sfx2/shell.hxx>
44 
45 class Timer;
46 class ApplicationEvent;
47 class WorkWindow;
48 class ISfxTemplateCommon;
49 class BasicManager;
50 class DdeService;
51 class GenLink;
52 class PrinterDialog;
53 class Point;
54 class Rectangle;
55 class AppSettings;
56 struct SfxChildWinContextFactory;
57 class SfxAppData_Impl;
58 class SfxBindings;
59 class SfxChildWinFactArr_Impl;
60 class SfxChildWindow;
61 class SfxDispatcher;
62 class SfxEventConfiguration;
63 class SfxEventHint;
64 class SfxItemSet;
65 class SfxMacroConfig;
66 class SfxMedium;
67 class SfxMediumList;
68 class SfxMenuCtrlFactArr_Impl;
69 class SfxNewFileDialog;
70 class SfxObjectShell;
71 class SfxObjectShellArr_Impl;
72 class SfxOptions;
73 class SfxProgress;
74 class SfxResourceManager;
75 class SfxSlotPool;
76 class SfxStbCtrlFactArr_Impl;
77 class SfxTbxCtrlFactArr_Impl;
78 class SfxTemplateDialog;
79 class SfxViewFrame;
80 class SfxViewFrameArr_Impl;
81 class SfxViewShell;
82 class SfxViewShellArr_Impl;
83 class StarBASIC;
84 class SfxWorkWindow;
85 class SfxFilterMatcher;
86 class SvUShorts;
87 class SfxModule;
88 class SfxModuleArr_Impl;
89 class Window;
90 class INetURLObject;
91 struct SfxConstant;
92 struct SfxChildWinFactory;
93 struct SfxMenuCtrlFactory;
94 struct SfxStbCtrlFactory;
95 struct SfxTbxCtrlFactory;
96 class SimpleResMgr;
97 class ModalDialog;
98 class SbxArray;
99 class SbxValue;
100 
101 namespace sfx2
102 {
103 	class SvLinkSource;
104 }
105 
106 //====================================================================
107 
108 class SfxLinkItem : public SfxPoolItem
109 {
110     Link aLink;
111 public:
Clone(SfxItemPool * =0) const112     virtual SfxPoolItem*     Clone( SfxItemPool* = 0 ) const
113     {   return new SfxLinkItem( *this ); }
operator ==(const SfxPoolItem & rL) const114     virtual int              operator==( const SfxPoolItem& rL) const
115     {   return ((SfxLinkItem&)rL).aLink == aLink; }
SfxLinkItem(sal_uInt16 nWhichId,const Link & rValue)116     SfxLinkItem( sal_uInt16 nWhichId, const Link& rValue ) : SfxPoolItem( nWhichId )
117     {   aLink = rValue; }
GetValue() const118     const Link&              GetValue() const { return aLink; }
119 };
120 
121 //TODO/CLEANUP
122 //wird anscheinend nur in SfxPickList/SfxFrameLoader benutzt
123 DECL_OBJHINT( SfxStringHint, String );
124 
125 /*
126 typedef SfxPoolItem* (*SfxItemCreateFunc)();
127 class SfxItemFactory_Impl;
128 class SfxItemFactoryList
129 {
130     List aList;
131 public:
132     ~SfxItemFactoryList();
133 
134     SfxItemFactory_Impl* GetFactory_Impl( const SvGlobalName& rName ) const;
135     SfxItemFactory_Impl* GetFactory_Impl( TypeId ) const;
136     const SvGlobalName* GetGlobalName( const SfxPoolItem* pItem ) const;
137     SfxPoolItem* Create(
138         const SvGlobalName& rName, sal_uInt16 nId, SvStream* pStrm = 0) const;
139     void         RegisterItemFactory(
140         const SvGlobalName& rName, SfxItemCreateFunc );
141 };
142 
143 #define REGISTER_ITEM( ItemClass, aGlobName )                                 \
144 RegisterItemFactory( aGlobName, ( SfxItemCreateFunc) ItemClass::StaticType() );
145 */
146 
147 #ifndef SFX_DECL_OBJECTSHELL_DEFINED
148 #define SFX_DECL_OBJECTSHELL_DEFINED
149 SV_DECL_REF(SfxObjectShell)
150 #endif
151 
152 class SfxObjectShellLock;
153 
154 class SFX2_DLLPUBLIC SfxApplication: public SfxShell
155 {
156     SAL_DLLPRIVATE static ::osl::Mutex gMutex;
157 	SAL_DLLPRIVATE static SfxApplication* pApp;
158 
159     SfxAppData_Impl*            pAppData_Impl;
160 
161     DECL_DLLPRIVATE_LINK(       GlobalBasicErrorHdl_Impl, StarBASIC* );
162     SAL_DLLPRIVATE sal_Bool     SaveAll_Impl(sal_Bool bPrompt = sal_False, sal_Bool bAutoSave = sal_False);
163     SAL_DLLPRIVATE short        QuerySave_Impl(SfxObjectShell &, sal_Bool bAutoSave = sal_False);
164 
165     static SfxApplication*      Create();
166     void                        Init();
167     void                        Exit();
168     void                		SettingsChange( sal_uInt16, const AppSettings & );
169     void                        Main( );
170     void                		PreInit( );
171     void                		Quit();
172     void                        Deinitialize();
173 
174 public:
175                                 TYPEINFO();
176                                 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXAPP)
177 
178 								SfxApplication();
179                                 ~SfxApplication();
180 	static SfxApplication*		GetOrCreate();
181 
182     // Resource Manager
183     SfxResourceManager&         GetResourceManager() const;
184     ResMgr*                     GetSfxResManager();
185 	SimpleResMgr*				GetSimpleResManager();
186 	static ResMgr*              CreateResManager( const char *pPrefix );
187 	SimpleResMgr*				CreateSimpleResManager();
188 
189     // DDE
190     long                		DdeExecute( const String& rCmd );
191 	long						DdeGetData( const String& rItem,
192 											const String& rMimeType,
193 										::com::sun::star::uno::Any & rValue );
194 	long						DdeSetData( const String& rItem,
195 											const String& rMimeType,
196 								const ::com::sun::star::uno::Any & rValue );
197     ::sfx2::SvLinkSource*       DdeCreateLinkSource( const String& rItem );
198     sal_Bool                        InitializeDde();
199     const DdeService*           GetDdeService() const;
200     DdeService*                 GetDdeService();
201     void                        AddDdeTopic( SfxObjectShell* );
202     void                        RemoveDdeTopic( SfxObjectShell* );
203 
204     // "static" methods
205     sal_uIntPtr                       LoadTemplate( SfxObjectShellLock& xDoc, const String& rFileName, sal_Bool bCopy=sal_True, SfxItemSet* pArgs = 0 );
206     ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > GetStatusIndicator() const;
207     SfxTemplateDialog*          GetTemplateDialog();
208     Window*                     GetTopWindow() const;
209 
210     // TODO/CLEANUP: make currently selected family a view property and so we don't need to query the status from the "TemplateCommon"
211     ISfxTemplateCommon*         GetCurrentTemplateCommon( SfxBindings& );
212 
213     // members
214     SfxFilterMatcher&           GetFilterMatcher();
215     SfxProgress*                GetProgress() const;
216     const String&               GetLastSaveDirectory() const;
217     sal_uInt16                  GetFreeIndex();
218     void                        ReleaseIndex(sal_uInt16 i);
219 
220     // Basic/Scripting
221     static sal_Bool				IsXScriptURL( const String& rScriptURL );
222     static ::rtl::OUString		ChooseScript();
223     static void         		MacroOrganizer( sal_Int16 nTabId );
224     static ErrCode              CallBasic( const String&, BasicManager*, SbxArray *pArgs, SbxValue *pRet );
CallAppBasic(const String & i_macroName,SbxArray * i_args=NULL,SbxValue * i_ret=NULL)225     static ErrCode              CallAppBasic( const String& i_macroName, SbxArray* i_args = NULL, SbxValue* i_ret = NULL )
226                                 { return CallBasic( i_macroName, SfxApplication::GetOrCreate()->GetBasicManager(), i_args, i_ret ); }
227     BasicManager*               GetBasicManager();
228 	com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer >
229 								GetDialogContainer();
230 	com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer >
231 								GetBasicContainer();
232     StarBASIC*                  GetBasic();
233     sal_uInt16                  SaveBasicManager() const;
234     sal_uInt16                  SaveBasicAndDialogContainer() const;
235     void                        RegisterBasicConstants( const char *pPrefix,
236                                                         const SfxConstant *pConsts,
237                                                         sal_uInt16 nCount );
238 
239     // misc.
240     sal_Bool                        GetOptions(SfxItemSet &);
241     void                        SetOptions(const SfxItemSet &);
242     virtual void                Invalidate(sal_uInt16 nId = 0);
243     void                        NotifyEvent(const SfxEventHint& rEvent, bool bSynchron = true );
244     sal_Bool                        IsDowning() const;
245     sal_Bool                        IsSecureURL( const INetURLObject &rURL, const String *pReferer ) const;
246     static SfxObjectShellRef    DocAlreadyLoaded( const String &rName,
247                                                   sal_Bool bSilent,
248                                                   sal_Bool bActivate,
249                                                   sal_Bool bForbidVisible = sal_False,
250                                                   const String* pPostStr = 0);
251     void                        ResetLastDir();
252 
253 //#if 0 // _SOLAR__PRIVATE
Get()254 	SAL_DLLPRIVATE static SfxApplication* Get() { return pApp;}
255     SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl();
256     SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl();
257 
258     SAL_DLLPRIVATE sal_Bool    		QueryExit_Impl();
259     SAL_DLLPRIVATE void         SetOptions_Impl(const SfxItemSet &);
260     SAL_DLLPRIVATE bool         Initialize_Impl();
261 
Get_Impl() const262     SAL_DLLPRIVATE SfxAppData_Impl* Get_Impl() const { return pAppData_Impl; }
263 
264     // Object-Factories/global arrays
265     SAL_DLLPRIVATE void         RegisterChildWindow_Impl(SfxModule*, SfxChildWinFactory*);
266     SAL_DLLPRIVATE void         RegisterChildWindowContext_Impl(SfxModule*, sal_uInt16, SfxChildWinContextFactory*);
267     SAL_DLLPRIVATE void         RegisterStatusBarControl_Impl(SfxModule*, SfxStbCtrlFactory*);
268     SAL_DLLPRIVATE void         RegisterMenuControl_Impl(SfxModule*, SfxMenuCtrlFactory*);
269     SAL_DLLPRIVATE void         RegisterToolBoxControl_Impl( SfxModule*, SfxTbxCtrlFactory*);
270     SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl& GetTbxCtrlFactories_Impl() const;
271     SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl& GetStbCtrlFactories_Impl() const;
272     SAL_DLLPRIVATE SfxMenuCtrlFactArr_Impl& GetMenuCtrlFactories_Impl() const;
273     SAL_DLLPRIVATE SfxChildWinFactArr_Impl& GetChildWinFactories_Impl() const;
274     SAL_DLLPRIVATE SfxViewFrameArr_Impl& GetViewFrames_Impl() const;
275     SAL_DLLPRIVATE SfxViewShellArr_Impl& GetViewShells_Impl() const;
276     SAL_DLLPRIVATE SfxObjectShellArr_Impl& GetObjectShells_Impl() const;
277     SAL_DLLPRIVATE void         SetViewFrame_Impl(SfxViewFrame *pViewFrame);
278 
279     // Slot Methods
280     // TODO/CLEANUP: still needed?
281     SAL_DLLPRIVATE void         NewDocDirectExec_Impl(SfxRequest &);
282     SAL_DLLPRIVATE void         NewDocExec_Impl(SfxRequest &);
283     SAL_DLLPRIVATE void         OpenDocExec_Impl(SfxRequest &);
284     SAL_DLLPRIVATE void         MiscExec_Impl(SfxRequest &);
285     SAL_DLLPRIVATE void         MiscState_Impl(SfxItemSet &);
286     SAL_DLLPRIVATE void         PropExec_Impl(SfxRequest &);
287     SAL_DLLPRIVATE void         PropState_Impl(SfxItemSet &);
288     SAL_DLLPRIVATE void         INetExecute_Impl(SfxRequest &);
289     SAL_DLLPRIVATE void         INetState_Impl(SfxItemSet &);
290     SAL_DLLPRIVATE void         OfaExec_Impl(SfxRequest &);
291     SAL_DLLPRIVATE void         OfaState_Impl(SfxItemSet &);
292 
293     SAL_DLLPRIVATE void         SetProgress_Impl(SfxProgress *);
294     SAL_DLLPRIVATE const String& GetLastDir_Impl() const;
295     SAL_DLLPRIVATE void         SetLastDir_Impl( const String & );
296 
297     SAL_DLLPRIVATE void         EnterAsynchronCall_Impl();
298     SAL_DLLPRIVATE bool         IsInAsynchronCall_Impl() const;
299     SAL_DLLPRIVATE void         LeaveAsynchronCall_Impl();
300     SAL_DLLPRIVATE void         Registrations_Impl();
301     SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(const SfxViewFrame *pFrame=0) const;
302 
303     // TODO/CLEANUP: still needed?
304     SAL_DLLPRIVATE SvUShorts*   GetDisabledSlotList_Impl();
305     SAL_DLLPRIVATE SfxSlotPool& GetAppSlotPool_Impl() const;
306     SAL_DLLPRIVATE SfxModule*   GetModule_Impl();
307 	SAL_DLLPRIVATE ResMgr*		GetOffResManager_Impl();
308 //#endif
309 };
310 
311 #define SFX_APP() SfxGetpApp()
312 
313 //--------------------------------------------------------------------
314 
SfxGetpApp()315 inline SfxApplication* SfxGetpApp()
316 {
317     return SfxApplication::GetOrCreate();
318 }
319 
320 #endif
321 
322 
323