1d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3d119d52dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4d119d52dSAndrew Rist * or more contributor license agreements. See the NOTICE file
5d119d52dSAndrew Rist * distributed with this work for additional information
6d119d52dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7d119d52dSAndrew Rist * to you under the Apache License, Version 2.0 (the
8d119d52dSAndrew Rist * "License"); you may not use this file except in compliance
9d119d52dSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13d119d52dSAndrew Rist * Unless required by applicable law or agreed to in writing,
14d119d52dSAndrew Rist * software distributed under the License is distributed on an
15d119d52dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d119d52dSAndrew Rist * KIND, either express or implied. See the License for the
17d119d52dSAndrew Rist * specific language governing permissions and limitations
18d119d52dSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20d119d52dSAndrew Rist *************************************************************/
21d119d52dSAndrew Rist
22d119d52dSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #if defined UNX
28cdf0e10cSrcweir #include <limits.h>
29cdf0e10cSrcweir #else // UNX
30cdf0e10cSrcweir #include <stdlib.h>
31cdf0e10cSrcweir #define PATH_MAX _MAX_PATH
32cdf0e10cSrcweir #endif // UNX
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <sfx2/app.hxx>
35cdf0e10cSrcweir #include <sfx2/frame.hxx>
36cdf0e10cSrcweir #include <vos/process.hxx>
37cdf0e10cSrcweir #include <tools/simplerm.hxx>
38cdf0e10cSrcweir #include <tools/config.hxx>
39cdf0e10cSrcweir #include <basic/basrdll.hxx>
40cdf0e10cSrcweir #include <basic/sbmeth.hxx>
41cdf0e10cSrcweir #include <basic/sbmod.hxx>
42cdf0e10cSrcweir #include <svtools/asynclink.hxx>
43cdf0e10cSrcweir #include <svl/stritem.hxx>
44cdf0e10cSrcweir #include <vcl/sound.hxx>
45cdf0e10cSrcweir #include <svl/eitem.hxx>
46cdf0e10cSrcweir #include <svl/urlbmk.hxx>
47cdf0e10cSrcweir #include <vcl/msgbox.hxx>
48cdf0e10cSrcweir #include <svtools/sfxecode.hxx>
49cdf0e10cSrcweir #include <svtools/ehdl.hxx>
50cdf0e10cSrcweir
51cdf0e10cSrcweir #include <svl/svdde.hxx>
52cdf0e10cSrcweir #include <tools/urlobj.hxx>
53cdf0e10cSrcweir #include <unotools/tempfile.hxx>
54cdf0e10cSrcweir #include <osl/file.hxx>
55cdf0e10cSrcweir
56cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
57cdf0e10cSrcweir #include <svl/svstdarr.hxx>
58cdf0e10cSrcweir
59cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
60cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
61cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
62cdf0e10cSrcweir #include <com/sun/star/frame/XFrameActionListener.hpp>
63cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp>
64cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
65cdf0e10cSrcweir #include <com/sun/star/frame/FrameActionEvent.hpp>
66cdf0e10cSrcweir #include <com/sun/star/frame/FrameAction.hpp>
67cdf0e10cSrcweir #include <com/sun/star/loader/XImplementationLoader.hpp>
68cdf0e10cSrcweir #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
69cdf0e10cSrcweir #include <com/sun/star/mozilla/XPluginInstance.hpp>
70cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp>
71cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
72cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
73cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
74cdf0e10cSrcweir #include <com/sun/star/uri/XUriReferenceFactory.hpp>
75cdf0e10cSrcweir #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
76cdf0e10cSrcweir #include <basic/basmgr.hxx>
77cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
78cdf0e10cSrcweir #include <vcl/svapp.hxx>
79cdf0e10cSrcweir #include <rtl/logfile.hxx>
80cdf0e10cSrcweir #include <sfx2/appuno.hxx>
81cdf0e10cSrcweir #include "sfx2/sfxhelp.hxx"
82cdf0e10cSrcweir #include <sfx2/request.hxx>
83cdf0e10cSrcweir #include "sfxtypes.hxx"
84cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
85cdf0e10cSrcweir #include "arrdecl.hxx"
86cdf0e10cSrcweir #include <sfx2/progress.hxx>
87cdf0e10cSrcweir #include <sfx2/objsh.hxx>
88cdf0e10cSrcweir #include <sfx2/docfac.hxx>
89cdf0e10cSrcweir #include <sfx2/docfile.hxx>
90cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
91cdf0e10cSrcweir #include "fltfnc.hxx"
92cdf0e10cSrcweir #include "nfltdlg.hxx"
93cdf0e10cSrcweir #include <sfx2/new.hxx>
94cdf0e10cSrcweir #include <sfx2/bindings.hxx>
95cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
96cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
97cdf0e10cSrcweir #include <sfx2/genlink.hxx>
98cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
99cdf0e10cSrcweir #include "appdata.hxx"
100cdf0e10cSrcweir #include "openflag.hxx"
101cdf0e10cSrcweir #include "app.hrc"
102cdf0e10cSrcweir #include "virtmenu.hxx"
103cdf0e10cSrcweir #include <sfx2/module.hxx>
104cdf0e10cSrcweir #include <sfx2/event.hxx>
105cdf0e10cSrcweir #include "imestatuswindow.hxx"
106cdf0e10cSrcweir #include "workwin.hxx"
107cdf0e10cSrcweir #include <sfx2/module.hxx>
108cdf0e10cSrcweir #include <sfx2/tbxctrl.hxx>
109cdf0e10cSrcweir #include <sfx2/sfxdlg.hxx>
110cdf0e10cSrcweir #include "sfx2/stbitem.hxx"
111cdf0e10cSrcweir #include "eventsupplier.hxx"
112cdf0e10cSrcweir #include <sfx2/dockwin.hxx>
113cdf0e10cSrcweir #include <tools/svlibrary.hxx>
114cdf0e10cSrcweir
115cdf0e10cSrcweir #ifdef DBG_UTIL
116cdf0e10cSrcweir #include <sfx2/tbxctrl.hxx>
117cdf0e10cSrcweir #include <sfx2/mnuitem.hxx>
118cdf0e10cSrcweir #endif
119cdf0e10cSrcweir
120cdf0e10cSrcweir #if defined( WNT ) || defined( OS2 )
121cdf0e10cSrcweir #define DDE_AVAILABLE
122cdf0e10cSrcweir #endif
123cdf0e10cSrcweir
124cdf0e10cSrcweir #include <unotools/saveopt.hxx>
125cdf0e10cSrcweir #include <unotools/undoopt.hxx>
126cdf0e10cSrcweir #include <svtools/helpopt.hxx>
127cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
128cdf0e10cSrcweir #include <unotools/viewoptions.hxx>
129cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
130cdf0e10cSrcweir #include <unotools/historyoptions.hxx>
131cdf0e10cSrcweir #include <svtools/menuoptions.hxx>
132cdf0e10cSrcweir #include <svtools/miscopt.hxx>
133cdf0e10cSrcweir #include <unotools/useroptions.hxx>
134cdf0e10cSrcweir #include <unotools/startoptions.hxx>
135cdf0e10cSrcweir #include <unotools/securityoptions.hxx>
136cdf0e10cSrcweir #include <unotools/localisationoptions.hxx>
137cdf0e10cSrcweir #include <unotools/inetoptions.hxx>
138cdf0e10cSrcweir #include <unotools/fontoptions.hxx>
139cdf0e10cSrcweir #include <unotools/internaloptions.hxx>
140cdf0e10cSrcweir #include <unotools/workingsetoptions.hxx>
141cdf0e10cSrcweir #include <unotools/syslocaleoptions.hxx>
142cdf0e10cSrcweir #include <unotools/syslocale.hxx>
143cdf0e10cSrcweir #include <framework/addonsoptions.hxx>
144cdf0e10cSrcweir #include <svtools/ttprops.hxx>
145cdf0e10cSrcweir #include <unotools/extendedsecurityoptions.hxx>
146cdf0e10cSrcweir
147cdf0e10cSrcweir using namespace ::com::sun::star;
148cdf0e10cSrcweir
149cdf0e10cSrcweir // Static member
150cdf0e10cSrcweir SfxApplication* SfxApplication::pApp = NULL;
151cdf0e10cSrcweir static BasicDLL* pBasic = NULL;
152cdf0e10cSrcweir
153cdf0e10cSrcweir class SfxPropertyHandler : public PropertyHandler
154cdf0e10cSrcweir {
155cdf0e10cSrcweir virtual void Property( ApplicationProperty& );
156cdf0e10cSrcweir };
157cdf0e10cSrcweir
158cdf0e10cSrcweir static SfxPropertyHandler* pPropertyHandler = 0;
159cdf0e10cSrcweir
GetOrCreatePropertyHandler()160cdf0e10cSrcweir SfxPropertyHandler* GetOrCreatePropertyHandler()
161cdf0e10cSrcweir {
162cdf0e10cSrcweir if ( !pPropertyHandler )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
165cdf0e10cSrcweir if ( !pPropertyHandler )
166cdf0e10cSrcweir pPropertyHandler = new SfxPropertyHandler;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir return pPropertyHandler;
170cdf0e10cSrcweir }
171cdf0e10cSrcweir
Property(ApplicationProperty & rProp)172cdf0e10cSrcweir void SfxPropertyHandler::Property( ApplicationProperty& rProp )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir TTProperties* pTTProperties = PTR_CAST( TTProperties, &rProp );
175cdf0e10cSrcweir if ( pTTProperties )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir pTTProperties->nPropertyVersion = TT_PROPERTIES_VERSION;
178cdf0e10cSrcweir switch ( pTTProperties->nActualPR )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir case TT_PR_SLOTS:
181cdf0e10cSrcweir {
182cdf0e10cSrcweir pTTProperties->nSidOpenUrl = SID_OPENURL;
183cdf0e10cSrcweir pTTProperties->nSidFileName = SID_FILE_NAME;
184cdf0e10cSrcweir pTTProperties->nSidNewDocDirect = SID_NEWDOCDIRECT;
185cdf0e10cSrcweir pTTProperties->nSidCopy = SID_COPY;
186cdf0e10cSrcweir pTTProperties->nSidPaste = SID_PASTE;
187cdf0e10cSrcweir pTTProperties->nSidSourceView = SID_SOURCEVIEW;
188cdf0e10cSrcweir pTTProperties->nSidSelectAll = SID_SELECTALL;
189cdf0e10cSrcweir pTTProperties->nSidReferer = SID_REFERER;
190cdf0e10cSrcweir pTTProperties->nActualPR = 0;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir break;
193cdf0e10cSrcweir case TT_PR_DISPATCHER:
194cdf0e10cSrcweir {
195cdf0e10cSrcweir // interface for TestTool
196cdf0e10cSrcweir SfxViewFrame* pViewFrame=0;
197cdf0e10cSrcweir SfxDispatcher* pDispatcher=0;
198cdf0e10cSrcweir pViewFrame = SfxViewFrame::Current();
199cdf0e10cSrcweir if ( !pViewFrame )
200cdf0e10cSrcweir pViewFrame = SfxViewFrame::GetFirst();
201cdf0e10cSrcweir if ( pViewFrame )
202cdf0e10cSrcweir pDispatcher = pViewFrame->GetDispatcher();
203cdf0e10cSrcweir else
204cdf0e10cSrcweir pDispatcher = NULL;
205cdf0e10cSrcweir if ( !pDispatcher )
206cdf0e10cSrcweir pTTProperties->nActualPR = TT_PR_ERR_NODISPATCHER;
207cdf0e10cSrcweir else
208cdf0e10cSrcweir {
209cdf0e10cSrcweir pDispatcher->SetExecuteMode(EXECUTEMODE_DIALOGASYNCHRON);
210cdf0e10cSrcweir if ( pTTProperties->mnSID == SID_NEWDOCDIRECT
211cdf0e10cSrcweir || pTTProperties->mnSID == SID_OPENDOC )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir SfxPoolItem** pArgs = pTTProperties->mppArgs;
214cdf0e10cSrcweir SfxAllItemSet aSet( SFX_APP()->GetPool() );
215cdf0e10cSrcweir if ( pArgs && *pArgs )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir for ( SfxPoolItem **pArg = pArgs; *pArg; ++pArg )
218cdf0e10cSrcweir aSet.Put( **pArg );
219cdf0e10cSrcweir }
220cdf0e10cSrcweir if ( pTTProperties->mnSID == SID_NEWDOCDIRECT )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir String aFactory = String::CreateFromAscii("private:factory/");
223cdf0e10cSrcweir if ( pArgs && *pArgs )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir SFX_ITEMSET_ARG( &aSet, pFactoryName, SfxStringItem, SID_NEWDOCDIRECT, sal_False );
226cdf0e10cSrcweir if ( pFactoryName )
227cdf0e10cSrcweir aFactory += pFactoryName->GetValue();
228cdf0e10cSrcweir else
229cdf0e10cSrcweir aFactory += String::CreateFromAscii("swriter");
230cdf0e10cSrcweir }
231cdf0e10cSrcweir else
232cdf0e10cSrcweir aFactory += String::CreateFromAscii("swriter");
233cdf0e10cSrcweir
234cdf0e10cSrcweir aSet.Put( SfxStringItem( SID_FILE_NAME, aFactory ) );
235cdf0e10cSrcweir aSet.ClearItem( SID_NEWDOCDIRECT );
236cdf0e10cSrcweir pTTProperties->mnSID = SID_OPENDOC;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir
239cdf0e10cSrcweir aSet.Put( SfxStringItem( SID_TARGETNAME, DEFINE_CONST_UNICODE("_blank") ) );
240cdf0e10cSrcweir if ( pDispatcher->ExecuteFunction( pTTProperties->mnSID, aSet, pTTProperties->mnMode )
241cdf0e10cSrcweir == EXECUTE_NO )
242cdf0e10cSrcweir pTTProperties->nActualPR = TT_PR_ERR_NOEXECUTE;
243cdf0e10cSrcweir else
244cdf0e10cSrcweir pTTProperties->nActualPR = 0;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir else
247cdf0e10cSrcweir {
248cdf0e10cSrcweir if ( pDispatcher->ExecuteFunction(
249cdf0e10cSrcweir pTTProperties->mnSID, pTTProperties->mppArgs, pTTProperties->mnMode )
250cdf0e10cSrcweir == EXECUTE_NO )
251cdf0e10cSrcweir pTTProperties->nActualPR = TT_PR_ERR_NOEXECUTE;
252cdf0e10cSrcweir else
253cdf0e10cSrcweir pTTProperties->nActualPR = 0;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir }
256cdf0e10cSrcweir }
257cdf0e10cSrcweir break;
258cdf0e10cSrcweir /*
259cdf0e10cSrcweir case TT_PR_IMG:
260cdf0e10cSrcweir {
261cdf0e10cSrcweir SvDataMemberObjectRef aDataObject = new SvDataMemberObject();
262cdf0e10cSrcweir SvData* pDataBmp = new SvData( FORMAT_BITMAP );
263cdf0e10cSrcweir pDataBmp->SetData( pTTProperties->mpBmp );
264cdf0e10cSrcweir aDataObject->Append( pDataBmp );
265cdf0e10cSrcweir aDataObject->CopyClipboard();
266cdf0e10cSrcweir pTTProperties->nActualPR = 0;
267cdf0e10cSrcweir }
268cdf0e10cSrcweir break;
269cdf0e10cSrcweir */
270cdf0e10cSrcweir default:
271cdf0e10cSrcweir {
272cdf0e10cSrcweir pTTProperties->nPropertyVersion = 0;
273cdf0e10cSrcweir }
274cdf0e10cSrcweir }
275cdf0e10cSrcweir return;
276cdf0e10cSrcweir }
277cdf0e10cSrcweir }
278cdf0e10cSrcweir
279cdf0e10cSrcweir #include <framework/imageproducer.hxx>
280cdf0e10cSrcweir #include <framework/acceleratorinfo.hxx>
281cdf0e10cSrcweir #include <framework/sfxhelperfunctions.hxx>
282cdf0e10cSrcweir #include "sfx2/imagemgr.hxx"
283cdf0e10cSrcweir #include "fwkhelper.hxx"
284cdf0e10cSrcweir
285cdf0e10cSrcweir ::osl::Mutex SfxApplication::gMutex;
286cdf0e10cSrcweir
GetOrCreate()287cdf0e10cSrcweir SfxApplication* SfxApplication::GetOrCreate()
288cdf0e10cSrcweir {
289cdf0e10cSrcweir // SFX on demand
290cdf0e10cSrcweir ::osl::MutexGuard aGuard(SfxApplication::gMutex);
291cdf0e10cSrcweir if ( !pApp )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir SfxApplication *pNew = new SfxApplication;
294cdf0e10cSrcweir
295cdf0e10cSrcweir //TODO/CLEANUP
296cdf0e10cSrcweir //ist das Mutex-Handling OK?
297cdf0e10cSrcweir static ::osl::Mutex aProtector;
298cdf0e10cSrcweir ::osl::MutexGuard aGuard2( aProtector );
299cdf0e10cSrcweir
300cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mb93783) ::SfxApplication::SetApp" );
301cdf0e10cSrcweir pApp = pNew;
302cdf0e10cSrcweir
303cdf0e10cSrcweir // at the moment a bug may occur when Initialize_Impl returns sal_False, but this is only temporary because all code that may cause such a
304cdf0e10cSrcweir // fault will be moved outside the SFX
305cdf0e10cSrcweir pApp->Initialize_Impl();
306cdf0e10cSrcweir
307cdf0e10cSrcweir ::framework::SetImageProducer( GetImage );
308cdf0e10cSrcweir ::framework::SetRefreshToolbars( RefreshToolbars );
309cdf0e10cSrcweir ::framework::SetToolBoxControllerCreator( SfxToolBoxControllerFactory );
310cdf0e10cSrcweir ::framework::SetStatusBarControllerCreator( SfxStatusBarControllerFactory );
311cdf0e10cSrcweir ::framework::SetDockingWindowCreator( SfxDockingWindowFactory );
312cdf0e10cSrcweir ::framework::SetIsDockingWindowVisible( IsDockingWindowVisible );
313cdf0e10cSrcweir ::framework::SetActivateToolPanel( &SfxViewFrame::ActivateToolPanel );
314cdf0e10cSrcweir
315cdf0e10cSrcweir SfxHelp* pSfxHelp = new SfxHelp;
316cdf0e10cSrcweir Application::SetHelp( pSfxHelp );
317cdf0e10cSrcweir if ( SvtHelpOptions().IsHelpTips() )
318cdf0e10cSrcweir Help::EnableQuickHelp();
319cdf0e10cSrcweir else
320cdf0e10cSrcweir Help::DisableQuickHelp();
321cdf0e10cSrcweir if ( SvtHelpOptions().IsHelpTips() && SvtHelpOptions().IsExtendedHelp() )
322cdf0e10cSrcweir Help::EnableBalloonHelp();
323cdf0e10cSrcweir else
324cdf0e10cSrcweir Help::DisableBalloonHelp();
325cdf0e10cSrcweir }
326cdf0e10cSrcweir return pApp;
327cdf0e10cSrcweir }
328cdf0e10cSrcweir
SfxApplication()329cdf0e10cSrcweir SfxApplication::SfxApplication()
330cdf0e10cSrcweir : pAppData_Impl( 0 )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mb93783) ::SfxApplication::SfxApplication" );
333cdf0e10cSrcweir
334cdf0e10cSrcweir SetName( DEFINE_CONST_UNICODE("StarOffice") );
335cdf0e10cSrcweir GetpApp()->SetPropertyHandler( GetOrCreatePropertyHandler() );
336cdf0e10cSrcweir
337cdf0e10cSrcweir SvtViewOptions::AcquireOptions();
338cdf0e10cSrcweir
339cdf0e10cSrcweir pAppData_Impl = new SfxAppData_Impl( this );
340cdf0e10cSrcweir pAppData_Impl->UpdateApplicationSettings( SvtMenuOptions().IsEntryHidingEnabled() );
341cdf0e10cSrcweir pAppData_Impl->m_xImeStatusWindow->init();
342cdf0e10cSrcweir pApp->PreInit();
343cdf0e10cSrcweir
344cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ initialize DDE" );
345cdf0e10cSrcweir
346cdf0e10cSrcweir #ifdef DDE_AVAILABLE
347cdf0e10cSrcweir #ifndef DBG_UTIL
348cdf0e10cSrcweir InitializeDde();
349cdf0e10cSrcweir #else
350cdf0e10cSrcweir if( !InitializeDde() )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir ByteString aStr( "Kein DDE-Service moeglich. Fehler: " );
353cdf0e10cSrcweir if( GetDdeService() )
354cdf0e10cSrcweir aStr += ByteString::CreateFromInt32(GetDdeService()->GetError());
355cdf0e10cSrcweir else
356cdf0e10cSrcweir aStr += '?';
357cdf0e10cSrcweir DBG_ASSERT( sal_False, aStr.GetBuffer() );
358cdf0e10cSrcweir }
359cdf0e10cSrcweir #endif
360cdf0e10cSrcweir #endif
361cdf0e10cSrcweir
362cdf0e10cSrcweir pBasic = new BasicDLL;
363cdf0e10cSrcweir StarBASIC::SetGlobalErrorHdl( LINK( this, SfxApplication, GlobalBasicErrorHdl_Impl ) );
364cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_TRACE( aLog, "} initialize DDE" );
365cdf0e10cSrcweir }
366cdf0e10cSrcweir
~SfxApplication()367cdf0e10cSrcweir SfxApplication::~SfxApplication()
368cdf0e10cSrcweir {
369cdf0e10cSrcweir OSL_ENSURE( GetObjectShells_Impl().Count() == 0, "Memory leak: some object shells were not removed!" );
370cdf0e10cSrcweir
371cdf0e10cSrcweir Broadcast( SfxSimpleHint(SFX_HINT_DYING) );
372cdf0e10cSrcweir
373cdf0e10cSrcweir SfxModule::DestroyModules_Impl();
374cdf0e10cSrcweir
375cdf0e10cSrcweir // delete global options
376cdf0e10cSrcweir SvtViewOptions::ReleaseOptions();
377cdf0e10cSrcweir delete pBasic;
378cdf0e10cSrcweir
379cdf0e10cSrcweir if ( !pAppData_Impl->bDowning )
380cdf0e10cSrcweir Deinitialize();
381cdf0e10cSrcweir
382cdf0e10cSrcweir delete pAppData_Impl;
383cdf0e10cSrcweir pApp = 0;
384cdf0e10cSrcweir }
385cdf0e10cSrcweir
386cdf0e10cSrcweir //====================================================================
387cdf0e10cSrcweir
GetLastDir_Impl() const388cdf0e10cSrcweir const String& SfxApplication::GetLastDir_Impl() const
389cdf0e10cSrcweir
390cdf0e10cSrcweir /* [Beschreibung]
391cdf0e10cSrcweir
392cdf0e10cSrcweir Interne Methode, mit der im SFx das zuletzt mit der Methode
393cdf0e10cSrcweir <SfxApplication::SetLastDir_Impl()> gesetzte Verzeichnis
394cdf0e10cSrcweir zurueckgegeben wird.
395cdf0e10cSrcweir
396cdf0e10cSrcweir Dieses ist i.d.R. das zuletzt durch den SfxFileDialog
397cdf0e10cSrcweir angesprochene Verzeichnis.
398cdf0e10cSrcweir
399cdf0e10cSrcweir [Querverweis]
400cdf0e10cSrcweir <SfxApplication::SetLastDir_Impl()>
401cdf0e10cSrcweir */
402cdf0e10cSrcweir
403cdf0e10cSrcweir {
404cdf0e10cSrcweir return pAppData_Impl->aLastDir;
405cdf0e10cSrcweir }
406cdf0e10cSrcweir
GetLastSaveDirectory() const407cdf0e10cSrcweir const String& SfxApplication::GetLastSaveDirectory() const
408cdf0e10cSrcweir
409cdf0e10cSrcweir /* [Beschreibung]
410cdf0e10cSrcweir
411cdf0e10cSrcweir Wie <SfxApplication::GetLastDir_Impl()>, nur extern
412cdf0e10cSrcweir
413cdf0e10cSrcweir [Querverweis]
414cdf0e10cSrcweir <SfxApplication::GetLastDir_Impl()>
415cdf0e10cSrcweir */
416cdf0e10cSrcweir
417cdf0e10cSrcweir {
418cdf0e10cSrcweir return GetLastDir_Impl();
419cdf0e10cSrcweir }
420cdf0e10cSrcweir
421cdf0e10cSrcweir //--------------------------------------------------------------------
422cdf0e10cSrcweir
SetLastDir_Impl(const String & rNewDir)423cdf0e10cSrcweir void SfxApplication::SetLastDir_Impl
424cdf0e10cSrcweir (
425cdf0e10cSrcweir const String& rNewDir /* kompletter Verzeichnis-Pfad als String */
426cdf0e10cSrcweir )
427cdf0e10cSrcweir
428cdf0e10cSrcweir /* [Beschreibung]
429cdf0e10cSrcweir
430cdf0e10cSrcweir Interne Methode, mit der ein Verzeichnis-Pfad gesetzt wird, der
431cdf0e10cSrcweir zuletzt (z.B. durch den SfxFileDialog) angesprochen wurde.
432cdf0e10cSrcweir
433cdf0e10cSrcweir [Querverweis]
434cdf0e10cSrcweir <SfxApplication::GetLastDir_Impl()>
435cdf0e10cSrcweir */
436cdf0e10cSrcweir
437cdf0e10cSrcweir {
438cdf0e10cSrcweir pAppData_Impl->aLastDir = rNewDir;
439cdf0e10cSrcweir }
440cdf0e10cSrcweir
441cdf0e10cSrcweir //--------------------------------------------------------------------
442cdf0e10cSrcweir
ResetLastDir()443cdf0e10cSrcweir void SfxApplication::ResetLastDir()
444cdf0e10cSrcweir {
445cdf0e10cSrcweir String aEmpty;
446cdf0e10cSrcweir pAppData_Impl->aLastDir = aEmpty;
447cdf0e10cSrcweir }
448cdf0e10cSrcweir
449cdf0e10cSrcweir //--------------------------------------------------------------------
450cdf0e10cSrcweir
GetDispatcher_Impl()451cdf0e10cSrcweir SfxDispatcher* SfxApplication::GetDispatcher_Impl()
452cdf0e10cSrcweir {
453cdf0e10cSrcweir return pAppData_Impl->pViewFrame? pAppData_Impl->pViewFrame->GetDispatcher(): pAppData_Impl->pAppDispat;
454cdf0e10cSrcweir }
455cdf0e10cSrcweir
456cdf0e10cSrcweir //--------------------------------------------------------------------
SetViewFrame_Impl(SfxViewFrame * pFrame)457cdf0e10cSrcweir void SfxApplication::SetViewFrame_Impl( SfxViewFrame *pFrame )
458cdf0e10cSrcweir {
459cdf0e10cSrcweir if ( pFrame != pAppData_Impl->pViewFrame )
460cdf0e10cSrcweir {
461cdf0e10cSrcweir // get the containerframes ( if one of the frames is an InPlaceFrame )
462cdf0e10cSrcweir SfxViewFrame *pOldContainerFrame = pAppData_Impl->pViewFrame;
463cdf0e10cSrcweir while ( pOldContainerFrame && pOldContainerFrame->GetParentViewFrame_Impl() )
464cdf0e10cSrcweir pOldContainerFrame = pOldContainerFrame->GetParentViewFrame_Impl();
465cdf0e10cSrcweir SfxViewFrame *pNewContainerFrame = pFrame;
466cdf0e10cSrcweir while ( pNewContainerFrame && pNewContainerFrame->GetParentViewFrame_Impl() )
467cdf0e10cSrcweir pNewContainerFrame = pNewContainerFrame->GetParentViewFrame_Impl();
468cdf0e10cSrcweir
469cdf0e10cSrcweir // DocWinActivate : both frames belong to the same TopWindow
470cdf0e10cSrcweir // TopWinActivate : both frames belong to different TopWindows
471cdf0e10cSrcweir // not used anymore!
472cdf0e10cSrcweir // sal_Bool bDocWinActivate = pOldContainerFrame && pNewContainerFrame &&
473cdf0e10cSrcweir // pOldContainerFrame->GetTopViewFrame() == pNewContainerFrame->GetTopViewFrame();
474cdf0e10cSrcweir sal_Bool bTaskActivate = pOldContainerFrame != pNewContainerFrame;
475cdf0e10cSrcweir
476cdf0e10cSrcweir if ( pOldContainerFrame )
477cdf0e10cSrcweir {
478cdf0e10cSrcweir if ( bTaskActivate )
479cdf0e10cSrcweir NotifyEvent( SfxViewEventHint( SFX_EVENT_DEACTIVATEDOC, GlobalEventConfig::GetEventName(STR_EVENT_DEACTIVATEDOC), pOldContainerFrame->GetObjectShell(), pOldContainerFrame->GetFrame().GetController() ) );
480cdf0e10cSrcweir pOldContainerFrame->DoDeactivate( bTaskActivate, pFrame );
481cdf0e10cSrcweir
482cdf0e10cSrcweir if( pOldContainerFrame->GetProgress() )
483cdf0e10cSrcweir pOldContainerFrame->GetProgress()->Suspend();
484cdf0e10cSrcweir }
485cdf0e10cSrcweir
486cdf0e10cSrcweir pAppData_Impl->pViewFrame = pFrame;
487cdf0e10cSrcweir
488cdf0e10cSrcweir //const SfxObjectShell* pSh = pViewFrame ? pViewFrame->GetObjectShell() : 0;
489cdf0e10cSrcweir //if ( !pSh )
490cdf0e10cSrcweir //{
491cdf0e10cSrcweir // // otherwise BaseURL is set in activation of document
492cdf0e10cSrcweir // INetURLObject aObject( SvtPathOptions().GetWorkPath() );
493cdf0e10cSrcweir // aObject.setFinalSlash();
494cdf0e10cSrcweir // INetURLObject::SetBaseURL( aObject.GetMainURL( INetURLObject::NO_DECODE ) );
495cdf0e10cSrcweir //}
496cdf0e10cSrcweir
497cdf0e10cSrcweir if( pNewContainerFrame )
498cdf0e10cSrcweir {
499cdf0e10cSrcweir pNewContainerFrame->DoActivate( bTaskActivate );
500cdf0e10cSrcweir if ( bTaskActivate && pNewContainerFrame->GetObjectShell() )
501cdf0e10cSrcweir {
502cdf0e10cSrcweir pNewContainerFrame->GetObjectShell()->PostActivateEvent_Impl( pNewContainerFrame );
503cdf0e10cSrcweir NotifyEvent(SfxViewEventHint(SFX_EVENT_ACTIVATEDOC, GlobalEventConfig::GetEventName(STR_EVENT_ACTIVATEDOC), pNewContainerFrame->GetObjectShell(), pNewContainerFrame->GetFrame().GetController() ) );
504cdf0e10cSrcweir }
505cdf0e10cSrcweir
506cdf0e10cSrcweir SfxProgress *pProgress = pNewContainerFrame->GetProgress();
507cdf0e10cSrcweir if ( pProgress )
508cdf0e10cSrcweir {
509cdf0e10cSrcweir if( pProgress->IsSuspended() )
510cdf0e10cSrcweir pProgress->Resume();
511cdf0e10cSrcweir else
512cdf0e10cSrcweir pProgress->SetState( pProgress->GetState() );
513cdf0e10cSrcweir }
514cdf0e10cSrcweir
515cdf0e10cSrcweir if ( pAppData_Impl->pViewFrame->GetViewShell() )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir SfxDispatcher* pDisp = pAppData_Impl->pViewFrame->GetDispatcher();
518cdf0e10cSrcweir pDisp->Flush();
519cdf0e10cSrcweir pDisp->Update_Impl(sal_True);
520cdf0e10cSrcweir }
521cdf0e10cSrcweir }
522cdf0e10cSrcweir }
523cdf0e10cSrcweir
524cdf0e10cSrcweir // even if the frame actually didn't change, ensure its document is forwarded
525cdf0e10cSrcweir // to SfxObjectShell::SetCurrentComponent.
526cdf0e10cSrcweir // Otherwise, the CurrentComponent might not be correct, in case it has meanwhile
527cdf0e10cSrcweir // been reset to some other document, by some non-SFX component.
528cdf0e10cSrcweir // #i49133# / 2007-12-19 / frank.schoenheit@sun.com
529cdf0e10cSrcweir if ( pFrame && pFrame->GetViewShell() )
530cdf0e10cSrcweir pFrame->GetViewShell()->SetCurrentDocument();
531cdf0e10cSrcweir }
532cdf0e10cSrcweir
533cdf0e10cSrcweir //--------------------------------------------------------------------
534cdf0e10cSrcweir
QuerySave_Impl(SfxObjectShell & rDoc,sal_Bool)535cdf0e10cSrcweir short SfxApplication::QuerySave_Impl( SfxObjectShell& rDoc, sal_Bool /*bAutoSave*/ )
536cdf0e10cSrcweir {
537cdf0e10cSrcweir if ( !rDoc.IsModified() )
538cdf0e10cSrcweir return RET_NO;
539cdf0e10cSrcweir
540cdf0e10cSrcweir String aMsg( SfxResId( STR_ISMODIFIED ) );
541cdf0e10cSrcweir aMsg.SearchAndReplaceAscii( "%1", rDoc.GetTitle() );
542cdf0e10cSrcweir
543cdf0e10cSrcweir SfxFrame& rFrame = SfxViewFrame::GetFirst(&rDoc)->GetFrame();
544cdf0e10cSrcweir rFrame.Appear();
545cdf0e10cSrcweir
546cdf0e10cSrcweir WinBits nBits = WB_YES_NO_CANCEL | WB_DEF_NO;
547cdf0e10cSrcweir QueryBox aBox( &rFrame.GetWindow(), nBits, aMsg );
548cdf0e10cSrcweir
549cdf0e10cSrcweir return aBox.Execute();
550cdf0e10cSrcweir }
551cdf0e10cSrcweir
552cdf0e10cSrcweir //---------------------------------------------------------------------
553cdf0e10cSrcweir
CreateResManager(const char * pPrefix)554cdf0e10cSrcweir ResMgr* SfxApplication::CreateResManager( const char *pPrefix )
555cdf0e10cSrcweir {
556*24c56ab9SHerbert Dürr return ResMgr::CreateResMgr( pPrefix);
557cdf0e10cSrcweir }
558cdf0e10cSrcweir
559cdf0e10cSrcweir //---------------------------------------------------------------------
560cdf0e10cSrcweir
CreateSimpleResManager()561cdf0e10cSrcweir SimpleResMgr* SfxApplication::CreateSimpleResManager()
562cdf0e10cSrcweir {
563cdf0e10cSrcweir SimpleResMgr *pRet;
564cdf0e10cSrcweir const AllSettings& rAllSettings = Application::GetSettings();
565cdf0e10cSrcweir ::com::sun::star::lang::Locale aLocale = rAllSettings.GetUILocale();
566cdf0e10cSrcweir pRet = new SimpleResMgr( CREATEVERSIONRESMGR_NAME(sfx), aLocale );
567cdf0e10cSrcweir
568cdf0e10cSrcweir return pRet;
569cdf0e10cSrcweir }
570cdf0e10cSrcweir
571cdf0e10cSrcweir //--------------------------------------------------------------------
572cdf0e10cSrcweir
GetSfxResManager()573cdf0e10cSrcweir ResMgr* SfxApplication::GetSfxResManager()
574cdf0e10cSrcweir {
575cdf0e10cSrcweir return SfxResId::GetResMgr();
576cdf0e10cSrcweir }
577cdf0e10cSrcweir
578cdf0e10cSrcweir //--------------------------------------------------------------------
579cdf0e10cSrcweir
GetSimpleResManager()580cdf0e10cSrcweir SimpleResMgr* SfxApplication::GetSimpleResManager()
581cdf0e10cSrcweir {
582cdf0e10cSrcweir if ( !pAppData_Impl->pSimpleResManager )
583cdf0e10cSrcweir pAppData_Impl->pSimpleResManager = CreateSimpleResManager();
584cdf0e10cSrcweir return pAppData_Impl->pSimpleResManager;
585cdf0e10cSrcweir }
586cdf0e10cSrcweir
587cdf0e10cSrcweir //------------------------------------------------------------------------
588cdf0e10cSrcweir
SetProgress_Impl(SfxProgress * pProgress)589cdf0e10cSrcweir void SfxApplication::SetProgress_Impl
590cdf0e10cSrcweir (
591cdf0e10cSrcweir SfxProgress *pProgress
592cdf0e10cSrcweir
593cdf0e10cSrcweir )
594cdf0e10cSrcweir {
595cdf0e10cSrcweir DBG_ASSERT( ( !pAppData_Impl->pProgress && pProgress ) ||
596cdf0e10cSrcweir ( pAppData_Impl->pProgress && !pProgress ),
597cdf0e10cSrcweir "Progress acitivation/deacitivation mismatch" );
598cdf0e10cSrcweir
599cdf0e10cSrcweir if ( pAppData_Impl->pProgress && pProgress )
600cdf0e10cSrcweir {
601cdf0e10cSrcweir pAppData_Impl->pProgress->Suspend();
602cdf0e10cSrcweir pAppData_Impl->pProgress->UnLock();
603cdf0e10cSrcweir delete pAppData_Impl->pProgress;
604cdf0e10cSrcweir }
605cdf0e10cSrcweir
606cdf0e10cSrcweir pAppData_Impl->pProgress = pProgress;
607cdf0e10cSrcweir }
608cdf0e10cSrcweir
609cdf0e10cSrcweir //------------------------------------------------------------------------
610cdf0e10cSrcweir
GetFreeIndex()611cdf0e10cSrcweir sal_uInt16 SfxApplication::GetFreeIndex()
612cdf0e10cSrcweir {
613cdf0e10cSrcweir return pAppData_Impl->aIndexBitSet.GetFreeIndex()+1;
614cdf0e10cSrcweir }
615cdf0e10cSrcweir
616cdf0e10cSrcweir //------------------------------------------------------------------------
617cdf0e10cSrcweir
ReleaseIndex(sal_uInt16 i)618cdf0e10cSrcweir void SfxApplication::ReleaseIndex(sal_uInt16 i)
619cdf0e10cSrcweir {
620cdf0e10cSrcweir pAppData_Impl->aIndexBitSet.ReleaseIndex(i-1);
621cdf0e10cSrcweir }
622cdf0e10cSrcweir
623cdf0e10cSrcweir //--------------------------------------------------------------------
624cdf0e10cSrcweir
EnterAsynchronCall_Impl()625cdf0e10cSrcweir void SfxApplication::EnterAsynchronCall_Impl()
626cdf0e10cSrcweir {
627cdf0e10cSrcweir ++pAppData_Impl->nAsynchronCalls;
628cdf0e10cSrcweir }
629cdf0e10cSrcweir
630cdf0e10cSrcweir //--------------------------------------------------------------------
631cdf0e10cSrcweir
LeaveAsynchronCall_Impl()632cdf0e10cSrcweir void SfxApplication::LeaveAsynchronCall_Impl()
633cdf0e10cSrcweir {
634cdf0e10cSrcweir --pAppData_Impl->nAsynchronCalls;
635cdf0e10cSrcweir }
636cdf0e10cSrcweir
637cdf0e10cSrcweir //--------------------------------------------------------------------
638cdf0e10cSrcweir
IsInAsynchronCall_Impl() const639cdf0e10cSrcweir bool SfxApplication::IsInAsynchronCall_Impl() const
640cdf0e10cSrcweir {
641cdf0e10cSrcweir return pAppData_Impl->nAsynchronCalls > 0;
642cdf0e10cSrcweir }
643cdf0e10cSrcweir
644cdf0e10cSrcweir //--------------------------------------------------------------------
645cdf0e10cSrcweir
GetTopWindow() const646cdf0e10cSrcweir Window* SfxApplication::GetTopWindow() const
647cdf0e10cSrcweir {
648cdf0e10cSrcweir SfxWorkWindow* pWork = GetWorkWindow_Impl( SfxViewFrame::Current() );
649cdf0e10cSrcweir return pWork ? pWork->GetWindow() : NULL;
650cdf0e10cSrcweir }
651cdf0e10cSrcweir
652cdf0e10cSrcweir //--------------------------------------------------------------------
653cdf0e10cSrcweir
GetStatusIndicator() const654cdf0e10cSrcweir uno::Reference< task::XStatusIndicator > SfxApplication::GetStatusIndicator() const
655cdf0e10cSrcweir {
656cdf0e10cSrcweir if ( !pAppData_Impl->pViewFrame )
657cdf0e10cSrcweir return uno::Reference< task::XStatusIndicator >();
658cdf0e10cSrcweir
659cdf0e10cSrcweir SfxViewFrame *pTop = pAppData_Impl->pViewFrame;
660cdf0e10cSrcweir while ( pTop->GetParentViewFrame_Impl() )
661cdf0e10cSrcweir pTop = pTop->GetParentViewFrame_Impl();
662cdf0e10cSrcweir
663cdf0e10cSrcweir return pTop->GetFrame().GetWorkWindow_Impl()->GetStatusIndicator();
664cdf0e10cSrcweir }
665cdf0e10cSrcweir
GetTbxCtrlFactories_Impl() const666cdf0e10cSrcweir SfxTbxCtrlFactArr_Impl& SfxApplication::GetTbxCtrlFactories_Impl() const
667cdf0e10cSrcweir {
668cdf0e10cSrcweir return *pAppData_Impl->pTbxCtrlFac;
669cdf0e10cSrcweir }
670cdf0e10cSrcweir
GetStbCtrlFactories_Impl() const671cdf0e10cSrcweir SfxStbCtrlFactArr_Impl& SfxApplication::GetStbCtrlFactories_Impl() const
672cdf0e10cSrcweir {
673cdf0e10cSrcweir return *pAppData_Impl->pStbCtrlFac;
674cdf0e10cSrcweir }
675cdf0e10cSrcweir
GetMenuCtrlFactories_Impl() const676cdf0e10cSrcweir SfxMenuCtrlFactArr_Impl& SfxApplication::GetMenuCtrlFactories_Impl() const
677cdf0e10cSrcweir {
678cdf0e10cSrcweir return *pAppData_Impl->pMenuCtrlFac;
679cdf0e10cSrcweir }
680cdf0e10cSrcweir
GetViewFrames_Impl() const681cdf0e10cSrcweir SfxViewFrameArr_Impl& SfxApplication::GetViewFrames_Impl() const
682cdf0e10cSrcweir {
683cdf0e10cSrcweir return *pAppData_Impl->pViewFrames;
684cdf0e10cSrcweir }
685cdf0e10cSrcweir
GetViewShells_Impl() const686cdf0e10cSrcweir SfxViewShellArr_Impl& SfxApplication::GetViewShells_Impl() const
687cdf0e10cSrcweir {
688cdf0e10cSrcweir return *pAppData_Impl->pViewShells;
689cdf0e10cSrcweir }
690cdf0e10cSrcweir
GetObjectShells_Impl() const691cdf0e10cSrcweir SfxObjectShellArr_Impl& SfxApplication::GetObjectShells_Impl() const
692cdf0e10cSrcweir {
693cdf0e10cSrcweir return *pAppData_Impl->pObjShells;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir
Invalidate(sal_uInt16 nId)696cdf0e10cSrcweir void SfxApplication::Invalidate( sal_uInt16 nId )
697cdf0e10cSrcweir {
698cdf0e10cSrcweir for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst(); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame ) )
699cdf0e10cSrcweir Invalidate_Impl( pFrame->GetBindings(), nId );
700cdf0e10cSrcweir }
701cdf0e10cSrcweir
702cdf0e10cSrcweir #define DOSTRING( x ) #x
703cdf0e10cSrcweir #define STRING( x ) DOSTRING( x )
704cdf0e10cSrcweir
705cdf0e10cSrcweir typedef long (SAL_CALL *basicide_handle_basic_error)(void*);
706cdf0e10cSrcweir typedef rtl_uString* (SAL_CALL *basicide_choose_macro)(void*, sal_Bool, rtl_uString*);
707cdf0e10cSrcweir typedef void* (SAL_CALL *basicide_macro_organizer)(sal_Int16);
708cdf0e10cSrcweir
thisModule()709cdf0e10cSrcweir extern "C" { static void SAL_CALL thisModule() {} }
710cdf0e10cSrcweir
IMPL_LINK(SfxApplication,GlobalBasicErrorHdl_Impl,StarBASIC *,pStarBasic)711cdf0e10cSrcweir IMPL_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, pStarBasic )
712cdf0e10cSrcweir {
713cdf0e10cSrcweir // get basctl dllname
714cdf0e10cSrcweir static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) );
715cdf0e10cSrcweir
716cdf0e10cSrcweir // load module
717cdf0e10cSrcweir oslModule handleMod = osl_loadModuleRelative(
718cdf0e10cSrcweir &thisModule, aLibName.pData, 0 );
719cdf0e10cSrcweir
720cdf0e10cSrcweir // get symbol
721cdf0e10cSrcweir ::rtl::OUString aSymbol( RTL_CONSTASCII_USTRINGPARAM( "basicide_handle_basic_error" ) );
722cdf0e10cSrcweir basicide_handle_basic_error pSymbol = (basicide_handle_basic_error) osl_getFunctionSymbol( handleMod, aSymbol.pData );
723cdf0e10cSrcweir
724cdf0e10cSrcweir // call basicide_handle_basic_error in basctl
725cdf0e10cSrcweir long nRet = pSymbol( pStarBasic );
726cdf0e10cSrcweir
727cdf0e10cSrcweir return nRet;
728cdf0e10cSrcweir }
729cdf0e10cSrcweir
IsXScriptURL(const String & rScriptURL)730cdf0e10cSrcweir sal_Bool SfxApplication::IsXScriptURL( const String& rScriptURL )
731cdf0e10cSrcweir {
732cdf0e10cSrcweir sal_Bool result = sal_False;
733cdf0e10cSrcweir
734cdf0e10cSrcweir ::com::sun::star::uno::Reference
735cdf0e10cSrcweir < ::com::sun::star::lang::XMultiServiceFactory > xSMgr =
736cdf0e10cSrcweir ::comphelper::getProcessServiceFactory();
737cdf0e10cSrcweir
738cdf0e10cSrcweir ::com::sun::star::uno::Reference
739cdf0e10cSrcweir < ::com::sun::star::uri::XUriReferenceFactory >
740cdf0e10cSrcweir xFactory( xSMgr->createInstance(
741cdf0e10cSrcweir ::rtl::OUString::createFromAscii(
742cdf0e10cSrcweir "com.sun.star.uri.UriReferenceFactory" ) ),
743cdf0e10cSrcweir ::com::sun::star::uno::UNO_QUERY );
744cdf0e10cSrcweir
745cdf0e10cSrcweir if ( xFactory.is() )
746cdf0e10cSrcweir {
747cdf0e10cSrcweir try
748cdf0e10cSrcweir {
749cdf0e10cSrcweir ::com::sun::star::uno::Reference
750cdf0e10cSrcweir < ::com::sun::star::uri::XVndSunStarScriptUrl >
751cdf0e10cSrcweir xUrl( xFactory->parse( rScriptURL ),
752cdf0e10cSrcweir ::com::sun::star::uno::UNO_QUERY );
753cdf0e10cSrcweir
754cdf0e10cSrcweir if ( xUrl.is() )
755cdf0e10cSrcweir {
756cdf0e10cSrcweir result = sal_True;
757cdf0e10cSrcweir }
758cdf0e10cSrcweir }
759cdf0e10cSrcweir catch ( ::com::sun::star::uno::RuntimeException& )
760cdf0e10cSrcweir {
761cdf0e10cSrcweir // ignore, will just return FALSE
762cdf0e10cSrcweir }
763cdf0e10cSrcweir }
764cdf0e10cSrcweir return result;
765cdf0e10cSrcweir }
766cdf0e10cSrcweir
767cdf0e10cSrcweir ::rtl::OUString
ChooseScript()768cdf0e10cSrcweir SfxApplication::ChooseScript()
769cdf0e10cSrcweir {
770cdf0e10cSrcweir ::rtl::OUString aScriptURL;
771cdf0e10cSrcweir
772cdf0e10cSrcweir SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
773cdf0e10cSrcweir if ( pFact )
774cdf0e10cSrcweir {
775cdf0e10cSrcweir OSL_TRACE("create selector dialog");
776cdf0e10cSrcweir
777cdf0e10cSrcweir const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
778cdf0e10cSrcweir const SfxFrame* pFrame = pViewFrame ? &pViewFrame->GetFrame() : NULL;
779cdf0e10cSrcweir uno::Reference< frame::XFrame > xFrame( pFrame ? pFrame->GetFrameInterface() : uno::Reference< frame::XFrame >() );
780cdf0e10cSrcweir
781cdf0e10cSrcweir AbstractScriptSelectorDialog* pDlg =
782cdf0e10cSrcweir pFact->CreateScriptSelectorDialog( NULL, sal_False, xFrame );
783cdf0e10cSrcweir
784cdf0e10cSrcweir OSL_TRACE("done, now exec it");
785cdf0e10cSrcweir
786cdf0e10cSrcweir sal_uInt16 nRet = pDlg->Execute();
787cdf0e10cSrcweir
788cdf0e10cSrcweir OSL_TRACE("has returned");
789cdf0e10cSrcweir
790cdf0e10cSrcweir if ( nRet == RET_OK )
791cdf0e10cSrcweir {
792cdf0e10cSrcweir aScriptURL = pDlg->GetScriptURL();
793cdf0e10cSrcweir }
794cdf0e10cSrcweir
795cdf0e10cSrcweir delete pDlg;
796cdf0e10cSrcweir }
797cdf0e10cSrcweir return aScriptURL;
798cdf0e10cSrcweir }
799cdf0e10cSrcweir
MacroOrganizer(sal_Int16 nTabId)800cdf0e10cSrcweir void SfxApplication::MacroOrganizer( sal_Int16 nTabId )
801cdf0e10cSrcweir {
802cdf0e10cSrcweir // get basctl dllname
803cdf0e10cSrcweir static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) );
804cdf0e10cSrcweir
805cdf0e10cSrcweir // load module
806cdf0e10cSrcweir oslModule handleMod = osl_loadModuleRelative(
807cdf0e10cSrcweir &thisModule, aLibName.pData, 0 );
808cdf0e10cSrcweir
809cdf0e10cSrcweir // get symbol
810cdf0e10cSrcweir ::rtl::OUString aSymbol( RTL_CONSTASCII_USTRINGPARAM( "basicide_macro_organizer" ) );
811cdf0e10cSrcweir basicide_macro_organizer pSymbol = (basicide_macro_organizer) osl_getFunctionSymbol( handleMod, aSymbol.pData );
812cdf0e10cSrcweir
813cdf0e10cSrcweir // call basicide_choose_macro in basctl
814cdf0e10cSrcweir pSymbol( nTabId );
815cdf0e10cSrcweir }
816cdf0e10cSrcweir
CallBasic(const String & rCode,BasicManager * pMgr,SbxArray * pArgs,SbxValue * pRet)817cdf0e10cSrcweir ErrCode SfxApplication::CallBasic( const String& rCode, BasicManager* pMgr, SbxArray* pArgs, SbxValue* pRet )
818cdf0e10cSrcweir {
819cdf0e10cSrcweir return pMgr->ExecuteMacro( rCode, pArgs, pRet);
820cdf0e10cSrcweir }
821