1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: app.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
38 #define PATH_MAX _MAX_PATH
41 #include <sfx2/app.hxx>
42 #include <sfx2/frame.hxx>
43 #include <vos/process.hxx>
44 #include <tools/simplerm.hxx>
45 #include <tools/config.hxx>
46 #include <basic/basrdll.hxx>
47 #include <svtools/asynclink.hxx>
48 #include <svtools/stritem.hxx>
49 #ifndef _SOUND_HXX //autogen
50 #include <vcl/sound.hxx>
52 #include <svtools/eitem.hxx>
53 #include <svtools/urlbmk.hxx>
54 #ifndef _MSGBOX_HXX //autogen
55 #include <vcl/msgbox.hxx>
57 #include <svtools/sfxecode.hxx>
58 #include <svtools/ehdl.hxx>
60 #include <svtools/svdde.hxx>
61 #include <tools/urlobj.hxx>
62 #include <unotools/tempfile.hxx>
63 #include <osl/file.hxx>
67 #define _SVSTDARR_STRINGSDTOR
68 #include <svtools/svstdarr.hxx>
70 #include <com/sun/star/uno/Sequence.hxx>
71 #include <com/sun/star/uno/Any.hxx>
72 #include <com/sun/star/lang/XInitialization.hpp>
73 #include <com/sun/star/frame/XFrameActionListener.hpp>
74 #include <com/sun/star/frame/XComponentLoader.hpp>
75 #include <com/sun/star/frame/XFrame.hpp>
76 #include <com/sun/star/frame/FrameActionEvent.hpp>
77 #include <com/sun/star/frame/FrameAction.hpp>
78 #include <com/sun/star/loader/XImplementationLoader.hpp>
79 #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
80 #include <com/sun/star/mozilla/XPluginInstance.hpp>
81 #include <com/sun/star/frame/XFramesSupplier.hpp>
82 #include <com/sun/star/container/XIndexAccess.hpp>
83 #include <com/sun/star/beans/XPropertySet.hpp>
84 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
85 #include <comphelper/processfactory.hxx>
87 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
88 #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
90 #include <basic/basmgr.hxx>
91 #include <toolkit/helper/vclunohelper.hxx>
92 #include <vcl/svapp.hxx>
94 #include <rtl/logfile.hxx>
96 #include <sfx2/appuno.hxx>
97 #include "sfxhelp.hxx"
98 #include <sfx2/request.hxx>
99 #include "sfxtypes.hxx"
100 #include "sfxresid.hxx"
101 #include "arrdecl.hxx"
102 #include <sfx2/progress.hxx>
103 #include <sfx2/objsh.hxx>
104 #include <sfx2/docfac.hxx>
105 #include <sfx2/docfile.hxx>
106 #include <sfx2/docfilt.hxx>
107 #include "fltfnc.hxx"
108 #include "nfltdlg.hxx"
109 #include <sfx2/new.hxx>
110 #include <sfx2/bindings.hxx>
111 #include <sfx2/dispatch.hxx>
112 #include <sfx2/viewsh.hxx>
113 #include <sfx2/genlink.hxx>
114 #include <sfx2/topfrm.hxx>
115 #include "appdata.hxx"
116 #include "openflag.hxx"
118 #include "virtmenu.hxx"
119 #include <sfx2/module.hxx>
120 #include <sfx2/event.hxx>
121 #include "imestatuswindow.hxx"
122 #include "workwin.hxx"
123 #include <sfx2/module.hxx>
124 #include <sfx2/tbxctrl.hxx>
125 #include <sfx2/sfxdlg.hxx>
126 #include "stbitem.hxx"
127 #include "eventsupplier.hxx"
128 #include <sfx2/dockwin.hxx>
131 #include <sfx2/tbxctrl.hxx>
132 #include <sfx2/mnuitem.hxx>
135 #if defined( WIN ) || defined( WNT ) || defined( OS2 )
136 #define DDE_AVAILABLE
139 #include <svtools/saveopt.hxx>
140 #include <svtools/undoopt.hxx>
141 #include <svtools/helpopt.hxx>
142 #include <svtools/pathoptions.hxx>
143 #include <svtools/viewoptions.hxx>
144 #include <svtools/moduleoptions.hxx>
145 #include <svtools/historyoptions.hxx>
146 #include <svtools/menuoptions.hxx>
147 #include <svtools/addxmltostorageoptions.hxx>
148 #include <svtools/miscopt.hxx>
149 #include <svtools/useroptions.hxx>
150 #include <svtools/startoptions.hxx>
151 #include <svtools/securityoptions.hxx>
152 #include <svtools/localisationoptions.hxx>
153 #include <svtools/inetoptions.hxx>
154 #include <svtools/fontoptions.hxx>
155 #include <svtools/internaloptions.hxx>
156 #include <svtools/workingsetoptions.hxx>
157 #include <svtools/syslocaleoptions.hxx>
158 #include <svtools/syslocale.hxx>
159 #include <framework/addonsoptions.hxx>
160 #include <svtools/ttprops.hxx>
161 #include <svtools/extendedsecurityoptions.hxx>
163 using namespace ::com::sun::star
;
166 SfxApplication
* SfxApplication::pApp
= NULL
;
167 static BasicDLL
* pBasic
= NULL
;
169 class SfxPropertyHandler
: public PropertyHandler
171 virtual void Property( ApplicationProperty
& );
174 static SfxPropertyHandler
* pPropertyHandler
= 0;
176 SfxPropertyHandler
* GetOrCreatePropertyHandler()
178 if ( !pPropertyHandler
)
180 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
181 if ( !pPropertyHandler
)
182 pPropertyHandler
= new SfxPropertyHandler
;
185 return pPropertyHandler
;
188 void SfxPropertyHandler::Property( ApplicationProperty
& rProp
)
190 TTProperties
* pTTProperties
= PTR_CAST( TTProperties
, &rProp
);
193 pTTProperties
->nPropertyVersion
= TT_PROPERTIES_VERSION
;
194 switch ( pTTProperties
->nActualPR
)
198 pTTProperties
->nSidOpenUrl
= SID_OPENURL
;
199 pTTProperties
->nSidFileName
= SID_FILE_NAME
;
200 pTTProperties
->nSidNewDocDirect
= SID_NEWDOCDIRECT
;
201 pTTProperties
->nSidCopy
= SID_COPY
;
202 pTTProperties
->nSidPaste
= SID_PASTE
;
203 pTTProperties
->nSidSourceView
= SID_SOURCEVIEW
;
204 pTTProperties
->nSidSelectAll
= SID_SELECTALL
;
205 pTTProperties
->nSidReferer
= SID_REFERER
;
206 pTTProperties
->nActualPR
= 0;
209 case TT_PR_DISPATCHER
:
211 // interface for TestTool
212 SfxViewFrame
* pViewFrame
=0;
213 SfxDispatcher
* pDispatcher
=0;
214 pViewFrame
= SfxViewFrame::Current();
216 pViewFrame
= SfxViewFrame::GetFirst();
218 pDispatcher
= pViewFrame
->GetDispatcher();
222 pTTProperties
->nActualPR
= TT_PR_ERR_NODISPATCHER
;
225 pDispatcher
->SetExecuteMode(EXECUTEMODE_DIALOGASYNCHRON
);
226 if ( pTTProperties
->mnSID
== SID_NEWDOCDIRECT
227 || pTTProperties
->mnSID
== SID_OPENDOC
)
229 SfxPoolItem
** pArgs
= pTTProperties
->mppArgs
;
230 SfxAllItemSet
aSet( SFX_APP()->GetPool() );
231 if ( pArgs
&& *pArgs
)
233 for ( SfxPoolItem
**pArg
= pArgs
; *pArg
; ++pArg
)
236 if ( pTTProperties
->mnSID
== SID_NEWDOCDIRECT
)
238 String aFactory
= String::CreateFromAscii("private:factory/");
239 if ( pArgs
&& *pArgs
)
241 SFX_ITEMSET_ARG( &aSet
, pFactoryName
, SfxStringItem
, SID_NEWDOCDIRECT
, FALSE
);
243 aFactory
+= pFactoryName
->GetValue();
245 aFactory
+= String::CreateFromAscii("swriter");
248 aFactory
+= String::CreateFromAscii("swriter");
250 aSet
.Put( SfxStringItem( SID_FILE_NAME
, aFactory
) );
251 aSet
.ClearItem( SID_NEWDOCDIRECT
);
252 pTTProperties
->mnSID
= SID_OPENDOC
;
255 aSet
.Put( SfxStringItem( SID_TARGETNAME
, DEFINE_CONST_UNICODE("_blank") ) );
256 if ( pDispatcher
->ExecuteFunction( pTTProperties
->mnSID
, aSet
, pTTProperties
->mnMode
)
258 pTTProperties
->nActualPR
= TT_PR_ERR_NOEXECUTE
;
260 pTTProperties
->nActualPR
= 0;
264 if ( pDispatcher
->ExecuteFunction(
265 pTTProperties
->mnSID
, pTTProperties
->mppArgs
, pTTProperties
->mnMode
)
267 pTTProperties
->nActualPR
= TT_PR_ERR_NOEXECUTE
;
269 pTTProperties
->nActualPR
= 0;
277 SvDataMemberObjectRef aDataObject = new SvDataMemberObject();
278 SvData* pDataBmp = new SvData( FORMAT_BITMAP );
279 pDataBmp->SetData( pTTProperties->mpBmp );
280 aDataObject->Append( pDataBmp );
281 aDataObject->CopyClipboard();
282 pTTProperties->nActualPR = 0;
288 pTTProperties
->nPropertyVersion
= 0;
295 #include <framework/imageproducer.hxx>
296 #include <framework/acceleratorinfo.hxx>
297 #include <framework/sfxhelperfunctions.hxx>
298 #include "imagemgr.hxx"
299 #include "fwkhelper.hxx"
301 ::osl::Mutex
SfxApplication::gMutex
;
303 SfxApplication
* SfxApplication::GetOrCreate()
306 ::osl::MutexGuard
aGuard(SfxApplication::gMutex
);
309 SfxApplication
*pNew
= new SfxApplication
;
312 //ist das Mutex-Handling OK?
313 static ::osl::Mutex aProtector
;
314 ::osl::MutexGuard
aGuard2( aProtector
);
316 RTL_LOGFILE_CONTEXT( aLog
, "sfx2 (mb93783) ::SfxApplication::SetApp" );
319 // at the moment a bug may occur when Initialize_Impl returns FALSE, but this is only temporary because all code that may cause such a
320 // fault will be moved outside the SFX
321 pApp
->Initialize_Impl();
323 ::framework::SetImageProducer( GetImage
);
324 ::framework::SetRefreshToolbars( RefreshToolbars
);
325 ::framework::SetToolBoxControllerCreator( SfxToolBoxControllerFactory
);
326 ::framework::SetStatusBarControllerCreator( SfxStatusBarControllerFactory
);
327 ::framework::SetDockingWindowCreator( SfxDockingWindowFactory
);
328 ::framework::SetIsDockingWindowVisible( IsDockingWindowVisible
);
330 SfxHelp
* pSfxHelp
= new SfxHelp
;
331 Application::SetHelp( pSfxHelp
);
332 if ( SvtHelpOptions().IsHelpTips() )
333 Help::EnableQuickHelp();
335 Help::DisableQuickHelp();
336 if ( SvtHelpOptions().IsHelpTips() && SvtHelpOptions().IsExtendedHelp() )
337 Help::EnableBalloonHelp();
339 Help::DisableBalloonHelp();
344 SfxApplication::SfxApplication()
347 RTL_LOGFILE_CONTEXT( aLog
, "sfx2 (mb93783) ::SfxApplication::SfxApplication" );
349 SetName( DEFINE_CONST_UNICODE("StarOffice") );
350 GetpApp()->SetPropertyHandler( GetOrCreatePropertyHandler() );
352 SvtViewOptions::AcquireOptions();
354 pAppData_Impl
= new SfxAppData_Impl( this );
355 pAppData_Impl
->UpdateApplicationSettings( SvtMenuOptions().IsEntryHidingEnabled() );
356 pAppData_Impl
->m_xImeStatusWindow
->init();
359 RTL_LOGFILE_CONTEXT_TRACE( aLog
, "{ initialize DDE" );
365 if( !InitializeDde() )
367 ByteString
aStr( "Kein DDE-Service moeglich. Fehler: " );
368 if( GetDdeService() )
369 aStr
+= ByteString::CreateFromInt32(GetDdeService()->GetError());
372 DBG_ASSERT( sal_False
, aStr
.GetBuffer() );
377 if ( !InitLabelResMgr( "iso" ) )
378 // no "iso" resource -> search for "ooo" resource
379 InitLabelResMgr( "ooo", true );
380 pBasic
= new BasicDLL
;
382 StarBASIC::SetGlobalErrorHdl( LINK( this, SfxApplication
, GlobalBasicErrorHdl_Impl
) );
386 RTL_LOGFILE_CONTEXT_TRACE( aLog
, "} initialize DDE" );
389 SfxApplication::~SfxApplication()
391 Broadcast( SfxSimpleHint(SFX_HINT_DYING
) );
393 SfxModule::DestroyModules_Impl();
395 // delete global options
396 SvtViewOptions::ReleaseOptions();
399 if ( !pAppData_Impl
->bDowning
)
402 delete pAppData_Impl
;
406 //====================================================================
408 const String
& SfxApplication::GetLastDir_Impl() const
412 Interne Methode, mit der im SFx das zuletzt mit der Methode
413 <SfxApplication::SetLastDir_Impl()> gesetzte Verzeichnis
416 Dieses ist i.d.R. das zuletzt durch den SfxFileDialog
417 angesprochene Verzeichnis.
420 <SfxApplication::SetLastDir_Impl()>
424 return pAppData_Impl
->aLastDir
;
427 const String
& SfxApplication::GetLastSaveDirectory() const
431 Wie <SfxApplication::GetLastDir_Impl()>, nur extern
434 <SfxApplication::GetLastDir_Impl()>
438 return GetLastDir_Impl();
441 //--------------------------------------------------------------------
443 void SfxApplication::SetLastDir_Impl
445 const String
& rNewDir
/* kompletter Verzeichnis-Pfad als String */
450 Interne Methode, mit der ein Verzeichnis-Pfad gesetzt wird, der
451 zuletzt (z.B. durch den SfxFileDialog) angesprochen wurde.
454 <SfxApplication::GetLastDir_Impl()>
458 pAppData_Impl
->aLastDir
= rNewDir
;
461 //--------------------------------------------------------------------
463 void SfxApplication::ResetLastDir()
466 pAppData_Impl
->aLastDir
= aEmpty
;
469 //--------------------------------------------------------------------
471 SfxDispatcher
* SfxApplication::GetDispatcher_Impl()
473 return pAppData_Impl
->pViewFrame
? pAppData_Impl
->pViewFrame
->GetDispatcher(): pAppData_Impl
->pAppDispat
;
476 //--------------------------------------------------------------------
477 void SfxApplication::SetViewFrame_Impl( SfxViewFrame
*pFrame
)
479 if( pFrame
&& !pFrame
->IsSetViewFrameAllowed_Impl() )
482 if ( pFrame
!= pAppData_Impl
->pViewFrame
)
484 // get the containerframes ( if one of the frames is an InPlaceFrame )
485 SfxViewFrame
*pOldContainerFrame
= pAppData_Impl
->pViewFrame
;
486 while ( pOldContainerFrame
&& pOldContainerFrame
->GetParentViewFrame_Impl() )
487 pOldContainerFrame
= pOldContainerFrame
->GetParentViewFrame_Impl();
488 SfxViewFrame
*pNewContainerFrame
= pFrame
;
489 while ( pNewContainerFrame
&& pNewContainerFrame
->GetParentViewFrame_Impl() )
490 pNewContainerFrame
= pNewContainerFrame
->GetParentViewFrame_Impl();
492 // DocWinActivate : both frames belong to the same TopWindow
493 // TopWinActivate : both frames belong to different TopWindows
495 // BOOL bDocWinActivate = pOldContainerFrame && pNewContainerFrame &&
496 // pOldContainerFrame->GetTopViewFrame() == pNewContainerFrame->GetTopViewFrame();
497 BOOL bTaskActivate
= pOldContainerFrame
!= pNewContainerFrame
;
498 if ( pAppData_Impl
->pViewFrame
)
501 // prepare UI for deacivation
502 pAppData_Impl
->pViewFrame
->GetFrame()->Deactivate_Impl();
505 if ( pOldContainerFrame
)
508 NotifyEvent( SfxEventHint( SFX_EVENT_DEACTIVATEDOC
, pOldContainerFrame
->GetObjectShell() ) );
509 pOldContainerFrame
->DoDeactivate( bTaskActivate
, pFrame
);
511 if( pOldContainerFrame
->GetProgress() )
512 pOldContainerFrame
->GetProgress()->Suspend();
515 pAppData_Impl
->pViewFrame
= pFrame
;
517 //const SfxObjectShell* pSh = pViewFrame ? pViewFrame->GetObjectShell() : 0;
520 // // otherwise BaseURL is set in activation of document
521 // INetURLObject aObject( SvtPathOptions().GetWorkPath() );
522 // aObject.setFinalSlash();
523 // INetURLObject::SetBaseURL( aObject.GetMainURL( INetURLObject::NO_DECODE ) );
526 if( pNewContainerFrame
)
528 pNewContainerFrame
->DoActivate( bTaskActivate
);
529 if ( bTaskActivate
&& pNewContainerFrame
->GetObjectShell() )
531 pNewContainerFrame
->GetObjectShell()->PostActivateEvent_Impl( pNewContainerFrame
);
532 NotifyEvent(SfxEventHint(SFX_EVENT_ACTIVATEDOC
, pNewContainerFrame
->GetObjectShell() ) );
535 SfxProgress
*pProgress
= pNewContainerFrame
->GetProgress();
538 if( pProgress
->IsSuspended() )
541 pProgress
->SetState( pProgress
->GetState() );
544 if ( pAppData_Impl
->pViewFrame
->GetViewShell() )
546 SfxDispatcher
* pDisp
= pAppData_Impl
->pViewFrame
->GetDispatcher();
548 pDisp
->Update_Impl(sal_True
);
553 // even if the frame actually didn't change, ensure its document is forwarded
554 // to SfxObjectShell::SetCurrentComponent.
555 // Otherwise, the CurrentComponent might not be correct, in case it has meanwhile
556 // been reset to some other document, by some non-SFX component.
557 // #i49133# / 2007-12-19 / frank.schoenheit@sun.com
558 if ( pFrame
&& pFrame
->GetViewShell() )
559 pFrame
->GetViewShell()->SetCurrentDocument();
562 //--------------------------------------------------------------------
564 short SfxApplication::QuerySave_Impl( SfxObjectShell
& rDoc
, sal_Bool
/*bAutoSave*/ )
566 if ( !rDoc
.IsModified() )
569 String
aMsg( SfxResId( STR_ISMODIFIED
) );
570 aMsg
.SearchAndReplaceAscii( "%1", rDoc
.GetTitle() );
572 SfxFrame
*pFrame
= SfxViewFrame::GetFirst(&rDoc
)->GetFrame();
575 WinBits nBits
= WB_YES_NO_CANCEL
| WB_DEF_NO
;
576 QueryBox
aBox( &pFrame
->GetWindow(), nBits
, aMsg
);
578 return aBox
.Execute();
581 //---------------------------------------------------------------------
583 ResMgr
* SfxApplication::CreateResManager( const char *pPrefix
)
585 String aMgrName
= String::CreateFromAscii( pPrefix
);
586 return ResMgr::CreateResMgr(U2S(aMgrName
));
589 //---------------------------------------------------------------------
591 SimpleResMgr
* SfxApplication::CreateSimpleResManager()
594 const AllSettings
& rAllSettings
= Application::GetSettings();
595 ::com::sun::star::lang::Locale aLocale
= rAllSettings
.GetUILocale();
596 pRet
= new SimpleResMgr( CREATEVERSIONRESMGR_NAME(sfx
), aLocale
);
601 //--------------------------------------------------------------------
603 ResMgr
* SfxApplication::GetSfxResManager()
605 return SfxResId::GetResMgr();
608 //--------------------------------------------------------------------
610 ResMgr
* SfxApplication::GetLabelResManager() const
612 return pAppData_Impl
->pLabelResMgr
;
615 //--------------------------------------------------------------------
617 SimpleResMgr
* SfxApplication::GetSimpleResManager()
619 if ( !pAppData_Impl
->pSimpleResManager
)
620 pAppData_Impl
->pSimpleResManager
= CreateSimpleResManager();
621 return pAppData_Impl
->pSimpleResManager
;
624 //------------------------------------------------------------------------
626 void SfxApplication::SetProgress_Impl
628 SfxProgress
*pProgress
632 DBG_ASSERT( ( !pAppData_Impl
->pProgress
&& pProgress
) ||
633 ( pAppData_Impl
->pProgress
&& !pProgress
),
634 "Progress acitivation/deacitivation mismatch" );
636 if ( pAppData_Impl
->pProgress
&& pProgress
)
638 pAppData_Impl
->pProgress
->Suspend();
639 pAppData_Impl
->pProgress
->UnLock();
640 delete pAppData_Impl
->pProgress
;
643 pAppData_Impl
->pProgress
= pProgress
;
646 //------------------------------------------------------------------------
648 sal_uInt16
SfxApplication::GetFreeIndex()
650 return pAppData_Impl
->aIndexBitSet
.GetFreeIndex()+1;
653 //------------------------------------------------------------------------
655 void SfxApplication::ReleaseIndex(sal_uInt16 i
)
657 pAppData_Impl
->aIndexBitSet
.ReleaseIndex(i
-1);
660 //--------------------------------------------------------------------
662 void SfxApplication::EnterAsynchronCall_Impl()
664 ++pAppData_Impl
->nAsynchronCalls
;
667 //--------------------------------------------------------------------
669 void SfxApplication::LeaveAsynchronCall_Impl()
671 --pAppData_Impl
->nAsynchronCalls
;
674 //--------------------------------------------------------------------
676 FASTBOOL
SfxApplication::IsInAsynchronCall_Impl() const
678 return pAppData_Impl
->nAsynchronCalls
> 0;
681 //--------------------------------------------------------------------
683 Window
* SfxApplication::GetTopWindow() const
685 SfxWorkWindow
* pWork
= GetWorkWindow_Impl( SfxViewFrame::Current() );
686 return pWork
? pWork
->GetWindow() : NULL
;
689 //--------------------------------------------------------------------
691 uno::Reference
< task::XStatusIndicator
> SfxApplication::GetStatusIndicator() const
693 if ( !pAppData_Impl
->pViewFrame
)
694 return uno::Reference
< task::XStatusIndicator
>();
696 SfxViewFrame
*pTop
= pAppData_Impl
->pViewFrame
;
697 while ( pTop
->GetParentViewFrame_Impl() )
698 pTop
= pTop
->GetParentViewFrame_Impl();
700 return pTop
->GetFrame()->GetWorkWindow_Impl()->GetStatusIndicator();
703 SfxTbxCtrlFactArr_Impl
& SfxApplication::GetTbxCtrlFactories_Impl() const
705 return *pAppData_Impl
->pTbxCtrlFac
;
708 SfxStbCtrlFactArr_Impl
& SfxApplication::GetStbCtrlFactories_Impl() const
710 return *pAppData_Impl
->pStbCtrlFac
;
713 SfxMenuCtrlFactArr_Impl
& SfxApplication::GetMenuCtrlFactories_Impl() const
715 return *pAppData_Impl
->pMenuCtrlFac
;
718 SfxViewFrameArr_Impl
& SfxApplication::GetViewFrames_Impl() const
720 return *pAppData_Impl
->pViewFrames
;
723 SfxViewShellArr_Impl
& SfxApplication::GetViewShells_Impl() const
725 return *pAppData_Impl
->pViewShells
;
728 SfxObjectShellArr_Impl
& SfxApplication::GetObjectShells_Impl() const
730 return *pAppData_Impl
->pObjShells
;
733 void SfxApplication::Invalidate( USHORT nId
)
735 for( SfxViewFrame
* pFrame
= SfxViewFrame::GetFirst(); pFrame
; pFrame
= SfxViewFrame::GetNext( *pFrame
) )
736 Invalidate_Impl( pFrame
->GetBindings(), nId
);
739 #define DOSTRING( x ) #x
740 #define STRING( x ) DOSTRING( x )
742 typedef long (SAL_CALL
*basicide_handle_basic_error
)(void*);
743 typedef rtl_uString
* (SAL_CALL
*basicide_choose_macro
)(void*, BOOL
, rtl_uString
*);
744 typedef void* (SAL_CALL
*basicide_macro_organizer
)(INT16
);
746 extern "C" { static void SAL_CALL
thisModule() {} }
748 IMPL_LINK( SfxApplication
, GlobalBasicErrorHdl_Impl
, StarBASIC
*, pStarBasic
)
750 // get basctl dllname
751 String sLibName
= String::CreateFromAscii( STRING( DLL_NAME
) );
752 sLibName
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "sfx" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "basctl" ) ) );
753 ::rtl::OUString
aLibName( sLibName
);
756 oslModule handleMod
= osl_loadModuleRelative(
757 &thisModule
, aLibName
.pData
, 0 );
760 ::rtl::OUString
aSymbol( RTL_CONSTASCII_USTRINGPARAM( "basicide_handle_basic_error" ) );
761 basicide_handle_basic_error pSymbol
= (basicide_handle_basic_error
) osl_getFunctionSymbol( handleMod
, aSymbol
.pData
);
763 // call basicide_handle_basic_error in basctl
764 long nRet
= pSymbol
? pSymbol( pStarBasic
) : 0;
769 sal_Bool
SfxApplication::IsXScriptURL( const String
& rScriptURL
)
771 sal_Bool result
= FALSE
;
773 ::com::sun::star::uno::Reference
774 < ::com::sun::star::lang::XMultiServiceFactory
> xSMgr
=
775 ::comphelper::getProcessServiceFactory();
777 ::com::sun::star::uno::Reference
778 < ::com::sun::star::uri::XUriReferenceFactory
>
779 xFactory( xSMgr
->createInstance(
780 ::rtl::OUString::createFromAscii(
781 "com.sun.star.uri.UriReferenceFactory" ) ),
782 ::com::sun::star::uno::UNO_QUERY
);
788 ::com::sun::star::uno::Reference
789 < ::com::sun::star::uri::XVndSunStarScriptUrl
>
790 xUrl( xFactory
->parse( rScriptURL
),
791 ::com::sun::star::uno::UNO_QUERY
);
798 catch ( ::com::sun::star::uno::RuntimeException
& )
800 // ignore, will just return FALSE
807 SfxApplication::ChooseScript()
809 ::rtl::OUString aScriptURL
;
811 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
814 OSL_TRACE("create selector dialog");
816 const SfxViewFrame
* pViewFrame
= SfxViewFrame::Current();
817 const SfxFrame
* pFrame
= pViewFrame
? pViewFrame
->GetFrame() : NULL
;
818 uno::Reference
< frame::XFrame
> xFrame( pFrame
? pFrame
->GetFrameInterface() : uno::Reference
< frame::XFrame
>() );
820 AbstractScriptSelectorDialog
* pDlg
=
821 pFact
->CreateScriptSelectorDialog( NULL
, FALSE
, xFrame
);
823 OSL_TRACE("done, now exec it");
825 USHORT nRet
= pDlg
->Execute();
827 OSL_TRACE("has returned");
829 if ( nRet
== RET_OK
)
831 aScriptURL
= pDlg
->GetScriptURL();
839 void SfxApplication::MacroOrganizer( INT16 nTabId
)
841 // get basctl dllname
842 String sLibName
= String::CreateFromAscii( STRING( DLL_NAME
) );
843 sLibName
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "sfx" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "basctl" ) ) );
844 ::rtl::OUString
aLibName( sLibName
);
847 oslModule handleMod
= osl_loadModuleRelative(
848 &thisModule
, aLibName
.pData
, 0 );
851 ::rtl::OUString
aSymbol( RTL_CONSTASCII_USTRINGPARAM( "basicide_macro_organizer" ) );
852 basicide_macro_organizer pSymbol
= (basicide_macro_organizer
) osl_getFunctionSymbol( handleMod
, aSymbol
.pData
);
854 // call basicide_choose_macro in basctl