xref: /AOO41X/main/sfx2/source/appl/appserv.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
30*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
31*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/frame/DispatchResultEvent.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/frame/DispatchResultState.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/task/XJobExecutor.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchHelper.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/util/CloseVetoException.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/document/XEmbeddedScripts.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/system/XSystemShellExecute.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/system/SystemShellExecuteException.hpp>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
51*cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
52*cdf0e10cSrcweir #include "comphelper/configurationhelper.hxx"
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #include <svtools/addresstemplate.hxx>
55*cdf0e10cSrcweir #include <svl/visitem.hxx>
56*cdf0e10cSrcweir #include <unotools/intlwrapper.hxx>
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir #include <unotools/configmgr.hxx>
59*cdf0e10cSrcweir #include <tools/config.hxx>
60*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
61*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
62*cdf0e10cSrcweir #include <svl/intitem.hxx>
63*cdf0e10cSrcweir #include <svl/eitem.hxx>
64*cdf0e10cSrcweir #include <svl/stritem.hxx>
65*cdf0e10cSrcweir #include <basic/sbstar.hxx>
66*cdf0e10cSrcweir #include <basic/basmgr.hxx>
67*cdf0e10cSrcweir #include <basic/basrdll.hxx>
68*cdf0e10cSrcweir #include <svtools/sfxecode.hxx>
69*cdf0e10cSrcweir #include <svtools/ehdl.hxx>
70*cdf0e10cSrcweir #include <vcl/help.hxx>
71*cdf0e10cSrcweir #include <vcl/stdtext.hxx>
72*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
75*cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
76*cdf0e10cSrcweir #include <unotools/regoptions.hxx>
77*cdf0e10cSrcweir #include <svtools/helpopt.hxx>
78*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
79*cdf0e10cSrcweir #include <tools/shl.hxx>
80*cdf0e10cSrcweir #include <unotools/bootstrap.hxx>
81*cdf0e10cSrcweir #include <vos/process.hxx>
82*cdf0e10cSrcweir #include <rtl/bootstrap.hxx>
83*cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx>
84*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir #include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
87*cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp>
88*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir #include "frmload.hxx"
91*cdf0e10cSrcweir #include "referers.hxx"
92*cdf0e10cSrcweir #include <sfx2/app.hxx>
93*cdf0e10cSrcweir #include <sfx2/request.hxx>
94*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
95*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
96*cdf0e10cSrcweir #include <sfx2/msg.hxx>
97*cdf0e10cSrcweir #include <sfx2/objface.hxx>
98*cdf0e10cSrcweir #include <sfx2/objitem.hxx>
99*cdf0e10cSrcweir #include <sfx2/objsh.hxx>
100*cdf0e10cSrcweir #include <sfx2/hintpost.hxx>
101*cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
102*cdf0e10cSrcweir #include <sfx2/docfac.hxx>
103*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
104*cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
105*cdf0e10cSrcweir #include "docvor.hxx"
106*cdf0e10cSrcweir #include <sfx2/new.hxx>
107*cdf0e10cSrcweir #include <sfx2/templdlg.hxx>
108*cdf0e10cSrcweir #include "sfxtypes.hxx"
109*cdf0e10cSrcweir #include <sfx2/tabdlg.hxx>
110*cdf0e10cSrcweir #include "arrdecl.hxx"
111*cdf0e10cSrcweir #include "fltfnc.hxx"
112*cdf0e10cSrcweir #include <sfx2/sfx.hrc>
113*cdf0e10cSrcweir #include "app.hrc"
114*cdf0e10cSrcweir #include <sfx2/passwd.hxx>
115*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
116*cdf0e10cSrcweir #include "arrdecl.hxx"
117*cdf0e10cSrcweir #include <sfx2/childwin.hxx>
118*cdf0e10cSrcweir #include "appdata.hxx"
119*cdf0e10cSrcweir #include "sfx2/minfitem.hxx"
120*cdf0e10cSrcweir #include <sfx2/event.hxx>
121*cdf0e10cSrcweir #include <sfx2/module.hxx>
122*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
123*cdf0e10cSrcweir #include "sfxpicklist.hxx"
124*cdf0e10cSrcweir #include "imestatuswindow.hxx"
125*cdf0e10cSrcweir #include <sfx2/sfxdlg.hxx>
126*cdf0e10cSrcweir #include <sfx2/dialogs.hrc>
127*cdf0e10cSrcweir #include "sorgitm.hxx"
128*cdf0e10cSrcweir #include "sfx2/sfxhelp.hxx"
129*cdf0e10cSrcweir #include <tools/svlibrary.hxx>
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir using namespace ::com::sun::star;
132*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
133*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
134*cdf0e10cSrcweir using namespace ::com::sun::star::frame;
135*cdf0e10cSrcweir using namespace ::com::sun::star::container;
136*cdf0e10cSrcweir using namespace ::com::sun::star::util;
137*cdf0e10cSrcweir using namespace ::com::sun::star::script;
138*cdf0e10cSrcweir using namespace ::com::sun::star::system;
139*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
140*cdf0e10cSrcweir using namespace ::com::sun::star::document;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir namespace css = com::sun::star;
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir //-------------------------------------------------------------------------
145*cdf0e10cSrcweir long QuitAgain_Impl( void* pObj, void* pArg )
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir 	SfxApplication* pApp = (SfxApplication*)pObj;
148*cdf0e10cSrcweir 	Timer* pTimer = (Timer*)pArg;
149*cdf0e10cSrcweir 	delete pTimer;
150*cdf0e10cSrcweir 	pApp->GetDispatcher_Impl()->Execute( SID_QUITAPP, SFX_CALLMODE_ASYNCHRON );
151*cdf0e10cSrcweir 	return 0;
152*cdf0e10cSrcweir }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir 	DBG_MEMTEST();
157*cdf0e10cSrcweir 	bool bDone = sal_False;
158*cdf0e10cSrcweir 	switch ( rReq.GetSlot() )
159*cdf0e10cSrcweir 	{
160*cdf0e10cSrcweir 		case SID_SETOPTIONS:
161*cdf0e10cSrcweir 		{
162*cdf0e10cSrcweir 			if( rReq.GetArgs() )
163*cdf0e10cSrcweir 				SetOptions_Impl( *rReq.GetArgs() );
164*cdf0e10cSrcweir 			break;
165*cdf0e10cSrcweir 		}
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 		case SID_QUITAPP:
168*cdf0e10cSrcweir 		case SID_EXITANDRETURN:
169*cdf0e10cSrcweir         case SID_LOGOUT:
170*cdf0e10cSrcweir 		{
171*cdf0e10cSrcweir             // protect against reentrant calls
172*cdf0e10cSrcweir             if ( pAppData_Impl->bInQuit )
173*cdf0e10cSrcweir                 return;
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir             if ( rReq.GetSlot() == SID_LOGOUT )
176*cdf0e10cSrcweir             {
177*cdf0e10cSrcweir                 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
178*cdf0e10cSrcweir                     pObjSh; pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
179*cdf0e10cSrcweir                 {
180*cdf0e10cSrcweir                     if ( !pObjSh->IsModified() )
181*cdf0e10cSrcweir                         continue;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir                     SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pObjSh );
184*cdf0e10cSrcweir                     if ( !pFrame || !pFrame->GetWindow().IsReallyVisible() )
185*cdf0e10cSrcweir                         continue;
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir                     if ( pObjSh->PrepareClose(2) )
188*cdf0e10cSrcweir                         pObjSh->SetModified( sal_False );
189*cdf0e10cSrcweir                     else
190*cdf0e10cSrcweir                         return;
191*cdf0e10cSrcweir                 }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir                 String aName = String::CreateFromAscii("vnd.sun.star.cmd:logout");
194*cdf0e10cSrcweir                 SfxStringItem aNameItem( SID_FILE_NAME, aName );
195*cdf0e10cSrcweir                 SfxStringItem aReferer( SID_REFERER, DEFINE_CONST_UNICODE( "private/user" ) );
196*cdf0e10cSrcweir                 pAppData_Impl->pAppDispat->Execute( SID_OPENDOC, SFX_CALLMODE_SLOT, &aNameItem, &aReferer, 0L );
197*cdf0e10cSrcweir                 return;
198*cdf0e10cSrcweir             }
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir             // aus verschachtelten Requests nach 100ms nochmal probieren
201*cdf0e10cSrcweir             if( Application::GetDispatchLevel() > 1 )
202*cdf0e10cSrcweir             {
203*cdf0e10cSrcweir                 /* Dont save the request for closing the application and try it later
204*cdf0e10cSrcweir                    again. This is an UI bound functionality ... and the user will  try it again
205*cdf0e10cSrcweir                    if the dialog is closed. But we shouldnt close the application automaticly
206*cdf0e10cSrcweir                    if this dialog is closed by the user ...
207*cdf0e10cSrcweir                    So we ignore this request now and wait for a new user decision.
208*cdf0e10cSrcweir                 */
209*cdf0e10cSrcweir                 DBG_TRACE1( "QueryExit => FALSE (DispatchLevel == %u)", Application::GetDispatchLevel() );
210*cdf0e10cSrcweir                 return;
211*cdf0e10cSrcweir             }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir             // block reentrant calls
214*cdf0e10cSrcweir             pAppData_Impl->bInQuit = sal_True;
215*cdf0e10cSrcweir             Reference < XDesktop > xDesktop ( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir             rReq.ForgetAllArgs();
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir             // if terminate() failed, pAppData_Impl->bInQuit will now be sal_False, allowing further calls of SID_QUITAPP
220*cdf0e10cSrcweir 			sal_Bool bTerminated = xDesktop->terminate();
221*cdf0e10cSrcweir 			if (!bTerminated)
222*cdf0e10cSrcweir 				// if terminate() was successful, SfxApplication is now dead!
223*cdf0e10cSrcweir 				pAppData_Impl->bInQuit = sal_False;
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 			// Returnwert setzten, ggf. terminieren
226*cdf0e10cSrcweir             rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bTerminated ) );
227*cdf0e10cSrcweir 			return;
228*cdf0e10cSrcweir 		}
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 		case SID_CONFIG:
231*cdf0e10cSrcweir 		case SID_TOOLBOXOPTIONS:
232*cdf0e10cSrcweir 		case SID_CONFIGSTATUSBAR:
233*cdf0e10cSrcweir 		case SID_CONFIGMENU:
234*cdf0e10cSrcweir 		case SID_CONFIGACCEL:
235*cdf0e10cSrcweir 		case SID_CONFIGEVENT:
236*cdf0e10cSrcweir 		{
237*cdf0e10cSrcweir 			SfxAbstractDialogFactory* pFact =
238*cdf0e10cSrcweir 				SfxAbstractDialogFactory::Create();
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 			if ( pFact )
241*cdf0e10cSrcweir 			{
242*cdf0e10cSrcweir 				SFX_REQUEST_ARG(rReq, pStringItem,
243*cdf0e10cSrcweir 					SfxStringItem, SID_CONFIG, sal_False);
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir 				SfxItemSet aSet(
246*cdf0e10cSrcweir 					GetPool(), SID_CONFIG, SID_CONFIG );
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 				if ( pStringItem )
249*cdf0e10cSrcweir 				{
250*cdf0e10cSrcweir 					aSet.Put( SfxStringItem(
251*cdf0e10cSrcweir 						SID_CONFIG, pStringItem->GetValue() ) );
252*cdf0e10cSrcweir 				}
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir                 Reference< XFrame > xFrame;
255*cdf0e10cSrcweir 				const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
256*cdf0e10cSrcweir                 SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
257*cdf0e10cSrcweir                 if ( pFrameItem )
258*cdf0e10cSrcweir                     xFrame = pFrameItem->GetFrame();
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir 				SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog(
261*cdf0e10cSrcweir 					RID_SVXDLG_CUSTOMIZE,
262*cdf0e10cSrcweir 					NULL, &aSet, xFrame );
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir 			  	if ( pDlg )
265*cdf0e10cSrcweir 				{
266*cdf0e10cSrcweir 					const short nRet = pDlg->Execute();
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir             		if ( nRet )
269*cdf0e10cSrcweir                 		bDone = sal_True;
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir             		delete pDlg;
272*cdf0e10cSrcweir 				}
273*cdf0e10cSrcweir 			}
274*cdf0e10cSrcweir 			break;
275*cdf0e10cSrcweir 		}
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir 		case SID_CLOSEDOCS:
278*cdf0e10cSrcweir 		case SID_CLOSEWINS:
279*cdf0e10cSrcweir 		{
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir             Reference < XFramesSupplier > xDesktop ( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
282*cdf0e10cSrcweir             Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY );
283*cdf0e10cSrcweir             if ( !xTasks.is() )
284*cdf0e10cSrcweir                 break;
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir             sal_Int32 n=0;
287*cdf0e10cSrcweir             do
288*cdf0e10cSrcweir             {
289*cdf0e10cSrcweir                 if ( xTasks->getCount() <= n )
290*cdf0e10cSrcweir                     break;
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir                 Any aAny = xTasks->getByIndex(n);
293*cdf0e10cSrcweir                 Reference < XCloseable > xTask;
294*cdf0e10cSrcweir                 aAny >>= xTask;
295*cdf0e10cSrcweir                 try
296*cdf0e10cSrcweir                 {
297*cdf0e10cSrcweir                     xTask->close(sal_True);
298*cdf0e10cSrcweir                     n++;
299*cdf0e10cSrcweir                 }
300*cdf0e10cSrcweir                 catch( CloseVetoException& )
301*cdf0e10cSrcweir                 {
302*cdf0e10cSrcweir                 }
303*cdf0e10cSrcweir             }
304*cdf0e10cSrcweir             while( sal_True );
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir             sal_Bool bOk = ( n == 0);
307*cdf0e10cSrcweir 			rReq.SetReturnValue( SfxBoolItem( 0, bOk ) );
308*cdf0e10cSrcweir 			bDone = sal_True;
309*cdf0e10cSrcweir 			break;
310*cdf0e10cSrcweir 		}
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 		case SID_SAVEDOCS:
313*cdf0e10cSrcweir 		{
314*cdf0e10cSrcweir 			sal_Bool bOK = sal_True;
315*cdf0e10cSrcweir 			sal_Bool bTmpDone = sal_True;
316*cdf0e10cSrcweir 			for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
317*cdf0e10cSrcweir 				  pObjSh;
318*cdf0e10cSrcweir 				  pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
319*cdf0e10cSrcweir 			{
320*cdf0e10cSrcweir 				SfxRequest aReq( SID_SAVEDOC, 0, pObjSh->GetPool() );
321*cdf0e10cSrcweir 				if ( pObjSh->IsModified() )
322*cdf0e10cSrcweir 				{
323*cdf0e10cSrcweir 					pObjSh->ExecuteSlot( aReq );
324*cdf0e10cSrcweir 					SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, aReq.GetReturnValue() );
325*cdf0e10cSrcweir 					bTmpDone = aReq.IsDone();
326*cdf0e10cSrcweir 					if ( !pItem || !pItem->GetValue() )
327*cdf0e10cSrcweir 						bOK = sal_False;
328*cdf0e10cSrcweir 				}
329*cdf0e10cSrcweir 			}
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 			rReq.SetReturnValue( SfxBoolItem( 0, bOK ) );
332*cdf0e10cSrcweir 			rReq.Done();
333*cdf0e10cSrcweir 			break;
334*cdf0e10cSrcweir 		}
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
337*cdf0e10cSrcweir         case SID_HELPINDEX:
338*cdf0e10cSrcweir         case SID_HELP_SUPPORTPAGE:
339*cdf0e10cSrcweir         {
340*cdf0e10cSrcweir             Help* pHelp = Application::GetHelp();
341*cdf0e10cSrcweir             if ( pHelp )
342*cdf0e10cSrcweir             {
343*cdf0e10cSrcweir                 if ( rReq.GetSlot() == SID_HELP_SUPPORTPAGE )
344*cdf0e10cSrcweir                 {
345*cdf0e10cSrcweir                     // show Support page with new URL
346*cdf0e10cSrcweir                     String sHelpURL = SfxHelp::CreateHelpURL( String::CreateFromAscii(".uno:HelpSupport"), String() );
347*cdf0e10cSrcweir                     String sParams = sHelpURL.Copy( sHelpURL.Search( '?' ) );
348*cdf0e10cSrcweir                     sHelpURL = String::CreateFromAscii("vnd.sun.star.help://shared/text/shared/05/00000001.xhp");
349*cdf0e10cSrcweir                     sHelpURL += sParams;
350*cdf0e10cSrcweir                     sHelpURL += String::CreateFromAscii("&UseDB=no");
351*cdf0e10cSrcweir                     pHelp->Start( sHelpURL, NULL );
352*cdf0e10cSrcweir                 }
353*cdf0e10cSrcweir                 else
354*cdf0e10cSrcweir                     pHelp->Start( String::CreateFromAscii(".uno:HelpIndex"), NULL ); // show start page
355*cdf0e10cSrcweir                 bDone = sal_True;
356*cdf0e10cSrcweir             }
357*cdf0e10cSrcweir             break;
358*cdf0e10cSrcweir         }
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
361*cdf0e10cSrcweir 		case SID_HELPTIPS:
362*cdf0e10cSrcweir 		{
363*cdf0e10cSrcweir 			// Parameter aus werten
364*cdf0e10cSrcweir 			SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPTIPS, sal_False);
365*cdf0e10cSrcweir 			bool bOn = pOnItem
366*cdf0e10cSrcweir 							? ((SfxBoolItem*)pOnItem)->GetValue()
367*cdf0e10cSrcweir 							: !Help::IsQuickHelpEnabled();
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir 			// ausf"uhren
370*cdf0e10cSrcweir 			if ( bOn )
371*cdf0e10cSrcweir 				Help::EnableQuickHelp();
372*cdf0e10cSrcweir 			else
373*cdf0e10cSrcweir 				Help::DisableQuickHelp();
374*cdf0e10cSrcweir 			SvtHelpOptions().SetHelpTips( bOn );
375*cdf0e10cSrcweir 			Invalidate(SID_HELPTIPS);
376*cdf0e10cSrcweir 			bDone = sal_True;
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir 			// ggf. recorden
379*cdf0e10cSrcweir 			if ( !rReq.IsAPI() )
380*cdf0e10cSrcweir 				rReq.AppendItem( SfxBoolItem( SID_HELPTIPS, bOn) );
381*cdf0e10cSrcweir 			break;
382*cdf0e10cSrcweir 		}
383*cdf0e10cSrcweir 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
384*cdf0e10cSrcweir 		case SID_EXTENDEDHELP:
385*cdf0e10cSrcweir 		{
386*cdf0e10cSrcweir 			Help::StartExtHelp();
387*cdf0e10cSrcweir 			break;
388*cdf0e10cSrcweir 		}
389*cdf0e10cSrcweir 		case SID_HELPBALLOONS:
390*cdf0e10cSrcweir 		{
391*cdf0e10cSrcweir 			// Parameter auswerten
392*cdf0e10cSrcweir 			SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPBALLOONS, sal_False);
393*cdf0e10cSrcweir 			bool bOn = pOnItem
394*cdf0e10cSrcweir 							? ((SfxBoolItem*)pOnItem)->GetValue()
395*cdf0e10cSrcweir 							: !Help::IsBalloonHelpEnabled();
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 			// ausf"uhren
398*cdf0e10cSrcweir 			if ( bOn )
399*cdf0e10cSrcweir 				Help::EnableBalloonHelp();
400*cdf0e10cSrcweir 			else
401*cdf0e10cSrcweir 				Help::DisableBalloonHelp();
402*cdf0e10cSrcweir 			SvtHelpOptions().SetExtendedHelp( bOn );
403*cdf0e10cSrcweir 			Invalidate(SID_HELPBALLOONS);
404*cdf0e10cSrcweir 			bDone = sal_True;
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir 			// ggf. recorden
407*cdf0e10cSrcweir 			if ( !rReq.IsAPI() )
408*cdf0e10cSrcweir 				rReq.AppendItem( SfxBoolItem( SID_HELPBALLOONS, bOn) );
409*cdf0e10cSrcweir 			break;
410*cdf0e10cSrcweir 		}
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
413*cdf0e10cSrcweir 		case SID_HELP_PI:
414*cdf0e10cSrcweir 		{
415*cdf0e10cSrcweir 			SvtHelpOptions aHelpOpt;
416*cdf0e10cSrcweir 			SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELP_PI, sal_False);
417*cdf0e10cSrcweir 			sal_Bool bOn = pOnItem
418*cdf0e10cSrcweir 							? ((SfxBoolItem*)pOnItem)->GetValue()
419*cdf0e10cSrcweir 							: !aHelpOpt.IsHelpAgentAutoStartMode();
420*cdf0e10cSrcweir 			aHelpOpt.SetHelpAgentAutoStartMode( bOn );
421*cdf0e10cSrcweir 			Invalidate(SID_HELP_PI);
422*cdf0e10cSrcweir 			bDone = sal_True;
423*cdf0e10cSrcweir 			break;
424*cdf0e10cSrcweir 		}
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
427*cdf0e10cSrcweir 		case SID_ABOUT:
428*cdf0e10cSrcweir 		{
429*cdf0e10cSrcweir  			SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
430*cdf0e10cSrcweir 			if ( pFact )
431*cdf0e10cSrcweir             {
432*cdf0e10cSrcweir                 VclAbstractDialog* pDlg = pFact->CreateVclDialog( 0, RID_DEFAULTABOUT );
433*cdf0e10cSrcweir 			    pDlg->Execute();
434*cdf0e10cSrcweir 			    delete pDlg;
435*cdf0e10cSrcweir 			    bDone = sal_True;
436*cdf0e10cSrcweir             }
437*cdf0e10cSrcweir 			break;
438*cdf0e10cSrcweir 		}
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
441*cdf0e10cSrcweir 		case SID_ORGANIZER:
442*cdf0e10cSrcweir 		{
443*cdf0e10cSrcweir 			SfxTemplateOrganizeDlg  *pDlg =
444*cdf0e10cSrcweir 				new SfxTemplateOrganizeDlg(NULL);
445*cdf0e10cSrcweir 			pDlg->Execute();
446*cdf0e10cSrcweir 			delete pDlg;
447*cdf0e10cSrcweir 			bDone = sal_True;
448*cdf0e10cSrcweir 			break;
449*cdf0e10cSrcweir 		}
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir 		case SID_TEMPLATE_ADDRESSBOKSOURCE:
452*cdf0e10cSrcweir 		{
453*cdf0e10cSrcweir 			svt::AddressBookSourceDialog aDialog(GetTopWindow(), ::comphelper::getProcessServiceFactory());
454*cdf0e10cSrcweir 			aDialog.Execute();
455*cdf0e10cSrcweir 			bDone = sal_True;
456*cdf0e10cSrcweir 			break;
457*cdf0e10cSrcweir 		}
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir 		case SID_BASICSTOP:
460*cdf0e10cSrcweir 			StarBASIC::Stop();
461*cdf0e10cSrcweir 			break;
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir         case SID_BASICBREAK :
464*cdf0e10cSrcweir             BASIC_DLL()->BasicBreak();
465*cdf0e10cSrcweir             break;
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir         case SID_CRASH :
468*cdf0e10cSrcweir         {
469*cdf0e10cSrcweir             // Provoke a crash:
470*cdf0e10cSrcweir             char * crash = 0;
471*cdf0e10cSrcweir             *crash = 0;
472*cdf0e10cSrcweir             break;
473*cdf0e10cSrcweir         }
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir         case SID_SHOW_IME_STATUS_WINDOW:
476*cdf0e10cSrcweir             if (pAppData_Impl->m_xImeStatusWindow->canToggle())
477*cdf0e10cSrcweir             {
478*cdf0e10cSrcweir                 SfxBoolItem const * pItem = static_cast< SfxBoolItem const * >(
479*cdf0e10cSrcweir                     rReq.GetArg(SID_SHOW_IME_STATUS_WINDOW, false,
480*cdf0e10cSrcweir                                 TYPE(SfxBoolItem)));
481*cdf0e10cSrcweir                 bool bShow = pItem == 0
482*cdf0e10cSrcweir                     ? !pAppData_Impl->m_xImeStatusWindow->isShowing()
483*cdf0e10cSrcweir                     : ( pItem->GetValue() == sal_True );
484*cdf0e10cSrcweir                 pAppData_Impl->m_xImeStatusWindow->show(bShow);
485*cdf0e10cSrcweir                 if (pItem == 0)
486*cdf0e10cSrcweir                     rReq.AppendItem(SfxBoolItem(SID_SHOW_IME_STATUS_WINDOW,
487*cdf0e10cSrcweir                                                 bShow));
488*cdf0e10cSrcweir             }
489*cdf0e10cSrcweir             bDone = true;
490*cdf0e10cSrcweir             break;
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir         case SID_AVAILABLE_TOOLBARS:
493*cdf0e10cSrcweir         {
494*cdf0e10cSrcweir             SfxStringItem const * pToolbarName = static_cast< SfxStringItem const *>(
495*cdf0e10cSrcweir                     rReq.GetArg(SID_AVAILABLE_TOOLBARS, false, TYPE(SfxStringItem)));
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir             if ( pToolbarName )
498*cdf0e10cSrcweir             {
499*cdf0e10cSrcweir                 com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame;
500*cdf0e10cSrcweir                 Reference < XFramesSupplier > xDesktop ( ::comphelper::getProcessServiceFactory()->createInstance(
501*cdf0e10cSrcweir                                                             DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
502*cdf0e10cSrcweir                 xFrame = xDesktop->getActiveFrame();
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir 	            Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
505*cdf0e10cSrcweir                 Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
506*cdf0e10cSrcweir 	            if ( xPropSet.is() )
507*cdf0e10cSrcweir 	            {
508*cdf0e10cSrcweir 		            try
509*cdf0e10cSrcweir 		            {
510*cdf0e10cSrcweir 			            Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
511*cdf0e10cSrcweir 			            aValue >>= xLayoutManager;
512*cdf0e10cSrcweir                     }
513*cdf0e10cSrcweir                     catch ( ::com::sun::star::uno::RuntimeException& e )
514*cdf0e10cSrcweir                     {
515*cdf0e10cSrcweir                         throw e;
516*cdf0e10cSrcweir                     }
517*cdf0e10cSrcweir                     catch ( ::com::sun::star::uno::Exception& )
518*cdf0e10cSrcweir                     {
519*cdf0e10cSrcweir                     }
520*cdf0e10cSrcweir                 }
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir                 if ( xLayoutManager.is() )
523*cdf0e10cSrcweir                 {
524*cdf0e10cSrcweir                     rtl::OUString aToolbarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/" ));
525*cdf0e10cSrcweir                     rtl::OUStringBuffer aBuf( aToolbarResName );
526*cdf0e10cSrcweir                     aBuf.append( pToolbarName->GetValue() );
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir                     // Parameter auswerten
529*cdf0e10cSrcweir                     rtl::OUString aToolbarName( aBuf.makeStringAndClear() );
530*cdf0e10cSrcweir                     sal_Bool bShow( !xLayoutManager->isElementVisible( aToolbarName ));
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir                     if ( bShow )
533*cdf0e10cSrcweir                     {
534*cdf0e10cSrcweir                         xLayoutManager->createElement( aToolbarName );
535*cdf0e10cSrcweir                         xLayoutManager->showElement( aToolbarName );
536*cdf0e10cSrcweir                     }
537*cdf0e10cSrcweir                     else
538*cdf0e10cSrcweir                         xLayoutManager->hideElement( aToolbarName );
539*cdf0e10cSrcweir                 }
540*cdf0e10cSrcweir             }
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir             bDone = true;
543*cdf0e10cSrcweir             break;
544*cdf0e10cSrcweir         }
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir         default:
547*cdf0e10cSrcweir             break;
548*cdf0e10cSrcweir 	}
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir 	if ( bDone )
551*cdf0e10cSrcweir 		rReq.Done();
552*cdf0e10cSrcweir }
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir //--------------------------------------------------------------------
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir void SfxApplication::MiscState_Impl(SfxItemSet &rSet)
557*cdf0e10cSrcweir {
558*cdf0e10cSrcweir 	DBG_MEMTEST();
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir 	LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
561*cdf0e10cSrcweir 	const sal_uInt16 *pRanges = rSet.GetRanges();
562*cdf0e10cSrcweir 	DBG_ASSERT(pRanges && *pRanges, "Set ohne Bereich");
563*cdf0e10cSrcweir 	while ( *pRanges )
564*cdf0e10cSrcweir 	{
565*cdf0e10cSrcweir 		for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
566*cdf0e10cSrcweir 		{
567*cdf0e10cSrcweir 			switch(nWhich)
568*cdf0e10cSrcweir 			{
569*cdf0e10cSrcweir                 case SID_TEMPLATE_ADDRESSBOKSOURCE:
570*cdf0e10cSrcweir                     if ( !SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE) )
571*cdf0e10cSrcweir                         rSet.Put(SfxVisibilityItem(nWhich, sal_False));
572*cdf0e10cSrcweir                     break;
573*cdf0e10cSrcweir 				case SID_EXITANDRETURN:
574*cdf0e10cSrcweir 				case SID_QUITAPP:
575*cdf0e10cSrcweir 				{
576*cdf0e10cSrcweir 					if ( pAppData_Impl->nDocModalMode )
577*cdf0e10cSrcweir 						rSet.DisableItem(nWhich);
578*cdf0e10cSrcweir 					else
579*cdf0e10cSrcweir                         rSet.Put(SfxStringItem(nWhich, String(SfxResId(STR_QUITAPP))));
580*cdf0e10cSrcweir 					break;
581*cdf0e10cSrcweir 				}
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir 				case SID_BASICSTOP:
584*cdf0e10cSrcweir 					if ( !StarBASIC::IsRunning() )
585*cdf0e10cSrcweir 						rSet.DisableItem(nWhich);
586*cdf0e10cSrcweir 					break;
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir 				case SID_HELPTIPS:
589*cdf0e10cSrcweir 				{
590*cdf0e10cSrcweir 					rSet.Put( SfxBoolItem( SID_HELPTIPS, Help::IsQuickHelpEnabled() ) );
591*cdf0e10cSrcweir 				}
592*cdf0e10cSrcweir 				break;
593*cdf0e10cSrcweir 				case SID_HELPBALLOONS:
594*cdf0e10cSrcweir 				{
595*cdf0e10cSrcweir 					rSet.Put( SfxBoolItem( SID_HELPBALLOONS, Help::IsBalloonHelpEnabled() ) );
596*cdf0e10cSrcweir 				}
597*cdf0e10cSrcweir 				break;
598*cdf0e10cSrcweir 				case SID_HELP_PI:
599*cdf0e10cSrcweir 				{
600*cdf0e10cSrcweir 					rSet.Put( SfxBoolItem( SID_HELP_PI, SvtHelpOptions().IsHelpAgentAutoStartMode() ) );
601*cdf0e10cSrcweir 				}
602*cdf0e10cSrcweir 				break;
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir 				case SID_EXTENDEDHELP:
605*cdf0e10cSrcweir 				{
606*cdf0e10cSrcweir 				}
607*cdf0e10cSrcweir 				break;
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir 				case SID_CLOSEDOCS:
610*cdf0e10cSrcweir 				case SID_CLOSEWINS:
611*cdf0e10cSrcweir 				{
612*cdf0e10cSrcweir                     Reference < XFramesSupplier > xDesktop ( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
613*cdf0e10cSrcweir                     Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY );
614*cdf0e10cSrcweir                     if ( !xTasks.is() || !xTasks->getCount() )
615*cdf0e10cSrcweir 						rSet.DisableItem(nWhich);
616*cdf0e10cSrcweir 					break;
617*cdf0e10cSrcweir 				}
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir 				case SID_SAVEDOCS:
620*cdf0e10cSrcweir 				{
621*cdf0e10cSrcweir 					sal_Bool bModified = sal_False;
622*cdf0e10cSrcweir 					for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
623*cdf0e10cSrcweir 						  pObjSh;
624*cdf0e10cSrcweir 						  pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
625*cdf0e10cSrcweir 					{
626*cdf0e10cSrcweir 						if ( pObjSh->IsModified() )
627*cdf0e10cSrcweir 						{
628*cdf0e10cSrcweir 							bModified = sal_True;
629*cdf0e10cSrcweir 							break;
630*cdf0e10cSrcweir 						}
631*cdf0e10cSrcweir 					}
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir 					if ( !bModified )
634*cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
635*cdf0e10cSrcweir 					break;
636*cdf0e10cSrcweir 				}
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir                 case SID_SHOW_IME_STATUS_WINDOW:
639*cdf0e10cSrcweir                     if (pAppData_Impl->m_xImeStatusWindow->canToggle())
640*cdf0e10cSrcweir                         rSet.Put(SfxBoolItem(
641*cdf0e10cSrcweir                                      SID_SHOW_IME_STATUS_WINDOW,
642*cdf0e10cSrcweir                                      pAppData_Impl->m_xImeStatusWindow->
643*cdf0e10cSrcweir                                          isShowing()));
644*cdf0e10cSrcweir                     else
645*cdf0e10cSrcweir                         rSet.DisableItem(SID_SHOW_IME_STATUS_WINDOW);
646*cdf0e10cSrcweir                     break;
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir                 default:
649*cdf0e10cSrcweir 					break;
650*cdf0e10cSrcweir 			}
651*cdf0e10cSrcweir 		}
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir 		++pRanges;
654*cdf0e10cSrcweir 	}
655*cdf0e10cSrcweir }
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir static const ::rtl::OUString& getProductRegistrationServiceName( )
658*cdf0e10cSrcweir {
659*cdf0e10cSrcweir 	static ::rtl::OUString s_sServiceName = ::rtl::OUString::createFromAscii( "com.sun.star.setup.ProductRegistration" );
660*cdf0e10cSrcweir 	return s_sServiceName;
661*cdf0e10cSrcweir }
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir typedef	rtl_uString* (SAL_CALL *basicide_choose_macro)(XModel*, sal_Bool, rtl_uString*);
664*cdf0e10cSrcweir typedef	void (SAL_CALL *basicide_macro_organizer)( sal_Int16 );
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir #define DOSTRING( x )			   			#x
667*cdf0e10cSrcweir #define STRING( x )				   			DOSTRING( x )
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir extern "C" { static void SAL_CALL thisModule() {} }
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir ::rtl::OUString ChooseMacro( const Reference< XModel >& rxLimitToDocument, sal_Bool bChooseOnly, const ::rtl::OUString& rMacroDesc = ::rtl::OUString() )
672*cdf0e10cSrcweir {
673*cdf0e10cSrcweir     // get basctl dllname
674*cdf0e10cSrcweir     static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) );
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir     // load module
677*cdf0e10cSrcweir 	oslModule handleMod = osl_loadModuleRelative(
678*cdf0e10cSrcweir         &thisModule, aLibName.pData, 0 );
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir     // get symbol
681*cdf0e10cSrcweir     ::rtl::OUString aSymbol( RTL_CONSTASCII_USTRINGPARAM( "basicide_choose_macro" ) );
682*cdf0e10cSrcweir     basicide_choose_macro pSymbol = (basicide_choose_macro) osl_getFunctionSymbol( handleMod, aSymbol.pData );
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir     // call basicide_choose_macro in basctl
685*cdf0e10cSrcweir     rtl_uString* pScriptURL = pSymbol( rxLimitToDocument.get(), bChooseOnly, rMacroDesc.pData );
686*cdf0e10cSrcweir     ::rtl::OUString aScriptURL( pScriptURL );
687*cdf0e10cSrcweir     rtl_uString_release( pScriptURL );
688*cdf0e10cSrcweir 	return aScriptURL;
689*cdf0e10cSrcweir }
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir void MacroOrganizer( sal_Int16 nTabId )
692*cdf0e10cSrcweir {
693*cdf0e10cSrcweir     // get basctl dllname
694*cdf0e10cSrcweir     static ::rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "basctl" ) ) );
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir     // load module
697*cdf0e10cSrcweir 	oslModule handleMod = osl_loadModuleRelative(
698*cdf0e10cSrcweir         &thisModule, aLibName.pData, 0 );
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir     // get symbol
701*cdf0e10cSrcweir     ::rtl::OUString aSymbol( RTL_CONSTASCII_USTRINGPARAM( "basicide_macro_organizer" ) );
702*cdf0e10cSrcweir     basicide_macro_organizer pSymbol = (basicide_macro_organizer) osl_getFunctionSymbol( handleMod, aSymbol.pData );
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir     // call basicide_macro_organizer in basctl
705*cdf0e10cSrcweir     pSymbol( nTabId );
706*cdf0e10cSrcweir }
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir #define RID_ERRBOX_MODULENOTINSTALLED     (RID_OFA_START + 72)
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir ResMgr* SfxApplication::GetOffResManager_Impl()
711*cdf0e10cSrcweir {
712*cdf0e10cSrcweir     if ( !pAppData_Impl->pOfaResMgr )
713*cdf0e10cSrcweir         pAppData_Impl->pOfaResMgr = CreateResManager( "ofa");
714*cdf0e10cSrcweir     return pAppData_Impl->pOfaResMgr;
715*cdf0e10cSrcweir }
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir namespace
718*cdf0e10cSrcweir {
719*cdf0e10cSrcweir     Window* lcl_getDialogParent( const Reference< XFrame >& _rxFrame, Window* _pFallback )
720*cdf0e10cSrcweir     {
721*cdf0e10cSrcweir         if ( !_rxFrame.is() )
722*cdf0e10cSrcweir             return _pFallback;
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir         try
725*cdf0e10cSrcweir         {
726*cdf0e10cSrcweir             Reference< awt::XWindow > xContainerWindow( _rxFrame->getContainerWindow(), UNO_SET_THROW );
727*cdf0e10cSrcweir             Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
728*cdf0e10cSrcweir             OSL_ENSURE( pWindow, "lcl_getDialogParent: cool, somebody implemented a VCL-less toolkit!" );
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir             if ( pWindow )
731*cdf0e10cSrcweir                 return pWindow->GetSystemWindow();
732*cdf0e10cSrcweir         }
733*cdf0e10cSrcweir         catch( const Exception& )
734*cdf0e10cSrcweir         {
735*cdf0e10cSrcweir         	DBG_UNHANDLED_EXCEPTION();
736*cdf0e10cSrcweir         }
737*cdf0e10cSrcweir         return _pFallback;
738*cdf0e10cSrcweir     }
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir     const ::rtl::OUString& lcl_getBasicIDEServiceName()
741*cdf0e10cSrcweir     {
742*cdf0e10cSrcweir         static const ::rtl::OUString s_sBasicName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.BasicIDE" ) );
743*cdf0e10cSrcweir         return s_sBasicName;
744*cdf0e10cSrcweir     }
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir     SfxViewFrame* lcl_getBasicIDEViewFrame( SfxObjectShell* i_pBasicIDE )
747*cdf0e10cSrcweir     {
748*cdf0e10cSrcweir         SfxViewFrame* pView = SfxViewFrame::GetFirst( i_pBasicIDE );
749*cdf0e10cSrcweir         while ( pView )
750*cdf0e10cSrcweir         {
751*cdf0e10cSrcweir             if ( pView->GetObjectShell()->GetFactory().GetDocumentServiceName() == lcl_getBasicIDEServiceName() )
752*cdf0e10cSrcweir                 break;
753*cdf0e10cSrcweir             pView = SfxViewFrame::GetNext( *pView, i_pBasicIDE );
754*cdf0e10cSrcweir         }
755*cdf0e10cSrcweir         return pView;
756*cdf0e10cSrcweir     }
757*cdf0e10cSrcweir     Reference< XFrame > lcl_findStartModuleFrame( const ::comphelper::ComponentContext& i_rContext )
758*cdf0e10cSrcweir     {
759*cdf0e10cSrcweir         try
760*cdf0e10cSrcweir         {
761*cdf0e10cSrcweir             Reference < XFramesSupplier > xSupplier( i_rContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW );
762*cdf0e10cSrcweir             Reference < XIndexAccess > xContainer( xSupplier->getFrames(), UNO_QUERY_THROW );
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir             Reference< XModuleManager > xCheck( i_rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir             sal_Int32 nCount = xContainer->getCount();
767*cdf0e10cSrcweir             for ( sal_Int32 i=0; i<nCount; ++i )
768*cdf0e10cSrcweir             {
769*cdf0e10cSrcweir                 try
770*cdf0e10cSrcweir                 {
771*cdf0e10cSrcweir                     Reference < XFrame > xFrame( xContainer->getByIndex(i), UNO_QUERY_THROW );
772*cdf0e10cSrcweir                     ::rtl::OUString sModule = xCheck->identify( xFrame );
773*cdf0e10cSrcweir                     if ( sModule.equalsAscii( "com.sun.star.frame.StartModule" ) )
774*cdf0e10cSrcweir                         return xFrame;
775*cdf0e10cSrcweir                 }
776*cdf0e10cSrcweir                 catch( const UnknownModuleException& )
777*cdf0e10cSrcweir                 {
778*cdf0e10cSrcweir                     // silence
779*cdf0e10cSrcweir                 }
780*cdf0e10cSrcweir                 catch(const Exception&)
781*cdf0e10cSrcweir                 {
782*cdf0e10cSrcweir                     // re-throw, caught below
783*cdf0e10cSrcweir                     throw;
784*cdf0e10cSrcweir                 }
785*cdf0e10cSrcweir             }
786*cdf0e10cSrcweir         }
787*cdf0e10cSrcweir         catch( const Exception& )
788*cdf0e10cSrcweir         {
789*cdf0e10cSrcweir                DBG_UNHANDLED_EXCEPTION();
790*cdf0e10cSrcweir         }
791*cdf0e10cSrcweir         return NULL;
792*cdf0e10cSrcweir     }
793*cdf0e10cSrcweir }
794*cdf0e10cSrcweir 
795*cdf0e10cSrcweir static ::rtl::OUString getConfigurationStringValue(
796*cdf0e10cSrcweir     const ::rtl::OUString& rPackage,
797*cdf0e10cSrcweir     const ::rtl::OUString& rRelPath,
798*cdf0e10cSrcweir     const ::rtl::OUString& rKey,
799*cdf0e10cSrcweir     const ::rtl::OUString& rDefaultValue )
800*cdf0e10cSrcweir {
801*cdf0e10cSrcweir     ::rtl::OUString aDefVal( rDefaultValue );
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir     try
804*cdf0e10cSrcweir     {
805*cdf0e10cSrcweir         ::comphelper::ConfigurationHelper::readDirectKey(
806*cdf0e10cSrcweir             comphelper::getProcessServiceFactory(),
807*cdf0e10cSrcweir             rPackage,
808*cdf0e10cSrcweir             rRelPath,
809*cdf0e10cSrcweir             rKey,
810*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::E_READONLY) >>= aDefVal;
811*cdf0e10cSrcweir     }
812*cdf0e10cSrcweir     catch(const com::sun::star::uno::RuntimeException& exRun)
813*cdf0e10cSrcweir     { throw exRun; }
814*cdf0e10cSrcweir     catch(const com::sun::star::uno::Exception&)
815*cdf0e10cSrcweir     {}
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir     return aDefVal;
818*cdf0e10cSrcweir }
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
821*cdf0e10cSrcweir {
822*cdf0e10cSrcweir 	DBG_MEMTEST();
823*cdf0e10cSrcweir 	switch ( rReq.GetSlot() )
824*cdf0e10cSrcweir 	{
825*cdf0e10cSrcweir 		case SID_OPTIONS_TREEDIALOG:
826*cdf0e10cSrcweir 		{
827*cdf0e10cSrcweir             String sPageURL;
828*cdf0e10cSrcweir             SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, SID_OPTIONS_PAGEURL, sal_False );
829*cdf0e10cSrcweir             if ( pURLItem )
830*cdf0e10cSrcweir                 sPageURL = pURLItem->GetValue();
831*cdf0e10cSrcweir             const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl();
832*cdf0e10cSrcweir             const SfxPoolItem* pItem = NULL;
833*cdf0e10cSrcweir             Reference < XFrame > xFrame;
834*cdf0e10cSrcweir             if ( pArgs && pArgs->GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET )
835*cdf0e10cSrcweir             {
836*cdf0e10cSrcweir                 OSL_ENSURE( pItem->ISA( SfxUnoFrameItem ), "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" );
837*cdf0e10cSrcweir                 xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame();
838*cdf0e10cSrcweir             }
839*cdf0e10cSrcweir 			SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
840*cdf0e10cSrcweir 			if ( pFact )
841*cdf0e10cSrcweir 			{
842*cdf0e10cSrcweir                 VclAbstractDialog* pDlg =
843*cdf0e10cSrcweir                     pFact->CreateFrameDialog( NULL, xFrame, rReq.GetSlot(), sPageURL );
844*cdf0e10cSrcweir 			  	pDlg->Execute();
845*cdf0e10cSrcweir 			  	delete pDlg;
846*cdf0e10cSrcweir 				SfxViewFrame* pView = SfxViewFrame::GetFirst();
847*cdf0e10cSrcweir 				while ( pView )
848*cdf0e10cSrcweir 				{
849*cdf0e10cSrcweir 					pView->GetBindings().InvalidateAll(sal_False);
850*cdf0e10cSrcweir 					pView = SfxViewFrame::GetNext( *pView );
851*cdf0e10cSrcweir 				}
852*cdf0e10cSrcweir 			}
853*cdf0e10cSrcweir 			break;
854*cdf0e10cSrcweir 		}
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir         case SID_MORE_DICTIONARIES:
857*cdf0e10cSrcweir         {
858*cdf0e10cSrcweir             try
859*cdf0e10cSrcweir             {
860*cdf0e10cSrcweir                 uno::Reference< lang::XMultiServiceFactory > xSMGR =
861*cdf0e10cSrcweir                     ::comphelper::getProcessServiceFactory();
862*cdf0e10cSrcweir                 uno::Reference< css::system::XSystemShellExecute > xSystemShell(
863*cdf0e10cSrcweir                     xSMGR->createInstance( DEFINE_CONST_UNICODE("com.sun.star.system.SystemShellExecute" ) ),
864*cdf0e10cSrcweir                     uno::UNO_QUERY_THROW );
865*cdf0e10cSrcweir 
866*cdf0e10cSrcweir                 // read repository URL from configuration
867*cdf0e10cSrcweir                 ::rtl::OUString sTemplRepoURL =
868*cdf0e10cSrcweir                     getConfigurationStringValue(
869*cdf0e10cSrcweir                         ::rtl::OUString::createFromAscii("org.openoffice.Office.Common"),
870*cdf0e10cSrcweir                         ::rtl::OUString::createFromAscii("Dictionaries"),
871*cdf0e10cSrcweir                         ::rtl::OUString::createFromAscii("RepositoryURL"),
872*cdf0e10cSrcweir                         ::rtl::OUString());
873*cdf0e10cSrcweir 
874*cdf0e10cSrcweir                 if ( xSystemShell.is() && sTemplRepoURL.getLength() > 0 )
875*cdf0e10cSrcweir                 {
876*cdf0e10cSrcweir                     ::rtl::OUStringBuffer aURLBuf( sTemplRepoURL );
877*cdf0e10cSrcweir                     aURLBuf.appendAscii( "?" );
878*cdf0e10cSrcweir                     aURLBuf.appendAscii( "lang=" );
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir                     // read locale from configuration
881*cdf0e10cSrcweir                     ::rtl::OUString sLocale = getConfigurationStringValue(
882*cdf0e10cSrcweir                         ::rtl::OUString::createFromAscii("org.openoffice.Setup"),
883*cdf0e10cSrcweir                         ::rtl::OUString::createFromAscii("L10N"),
884*cdf0e10cSrcweir                         ::rtl::OUString::createFromAscii("ooLocale"),
885*cdf0e10cSrcweir                         ::rtl::OUString::createFromAscii("en-US"));
886*cdf0e10cSrcweir 
887*cdf0e10cSrcweir                     aURLBuf.append( sLocale );
888*cdf0e10cSrcweir                     xSystemShell->execute(
889*cdf0e10cSrcweir                         aURLBuf.makeStringAndClear(),
890*cdf0e10cSrcweir                         ::rtl::OUString(),
891*cdf0e10cSrcweir                         css::system::SystemShellExecuteFlags::DEFAULTS );
892*cdf0e10cSrcweir                 }
893*cdf0e10cSrcweir             }
894*cdf0e10cSrcweir             catch( const ::com::sun::star::uno::Exception& )
895*cdf0e10cSrcweir             {
896*cdf0e10cSrcweir                 DBG_ERRORFILE( "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES): caught an exception!" );
897*cdf0e10cSrcweir             }
898*cdf0e10cSrcweir             break;
899*cdf0e10cSrcweir         }
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir 		case SID_ONLINE_REGISTRATION:
902*cdf0e10cSrcweir 		{
903*cdf0e10cSrcweir 			try
904*cdf0e10cSrcweir 			{
905*cdf0e10cSrcweir 				// create the ProductRegistration component
906*cdf0e10cSrcweir 				Reference< com::sun::star::lang::XMultiServiceFactory > xORB( ::comphelper::getProcessServiceFactory() );
907*cdf0e10cSrcweir 				Reference< com::sun::star::task::XJobExecutor > xProductRegistration;
908*cdf0e10cSrcweir 				if ( xORB.is() )
909*cdf0e10cSrcweir 					xProductRegistration = xProductRegistration.query( xORB->createInstance( getProductRegistrationServiceName() ) );
910*cdf0e10cSrcweir 				DBG_ASSERT( xProductRegistration.is(), "OfficeApplication::ExecuteApp_Impl: could not create the service!" );
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir 				// tell it that the user wants to register
913*cdf0e10cSrcweir 				if ( xProductRegistration.is() )
914*cdf0e10cSrcweir 				{
915*cdf0e10cSrcweir 					xProductRegistration->trigger( ::rtl::OUString::createFromAscii( "RegistrationRequired" ) );
916*cdf0e10cSrcweir 				}
917*cdf0e10cSrcweir 			}
918*cdf0e10cSrcweir 			catch( const ::com::sun::star::uno::Exception& )
919*cdf0e10cSrcweir 			{
920*cdf0e10cSrcweir 				DBG_ERROR( "OfficeApplication::ExecuteApp_Impl(SID_ONLINE_REGISTRATION): caught an exception!" );
921*cdf0e10cSrcweir 			}
922*cdf0e10cSrcweir 		}
923*cdf0e10cSrcweir 		break;
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir 		case SID_BASICIDE_APPEAR:
926*cdf0e10cSrcweir 		{
927*cdf0e10cSrcweir             SfxViewFrame* pView = lcl_getBasicIDEViewFrame( NULL );
928*cdf0e10cSrcweir             if ( !pView )
929*cdf0e10cSrcweir             {
930*cdf0e10cSrcweir                 SfxObjectShell* pBasicIDE = SfxObjectShell::CreateObject( lcl_getBasicIDEServiceName() );
931*cdf0e10cSrcweir                 pBasicIDE->DoInitNew( 0 );
932*cdf0e10cSrcweir                 pBasicIDE->SetModified( sal_False );
933*cdf0e10cSrcweir                 try
934*cdf0e10cSrcweir                 {
935*cdf0e10cSrcweir                     // load the Basic IDE via direct access to the SFX frame loader. A generic loadComponentFromURL
936*cdf0e10cSrcweir                     // (which could be done via SfxViewFrame::LoadDocumentIntoFrame) is not feasible here, since the Basic IDE
937*cdf0e10cSrcweir                     // does not really play nice with the framework's concept. For instance, it is a "singleton document",
938*cdf0e10cSrcweir                     // which conflicts, at the latest, with the framework's concept of loading into _blank frames.
939*cdf0e10cSrcweir                     // So, since we know that our frame loader can handle it, we skip the generic framework loader
940*cdf0e10cSrcweir                     // mechanism, and the type detection (which doesn't know about the Basic IDE).
941*cdf0e10cSrcweir                     ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
942*cdf0e10cSrcweir                     Reference< XSynchronousFrameLoader > xLoader( aContext.createComponent(
943*cdf0e10cSrcweir                         SfxFrameLoader_Impl::impl_getStaticImplementationName() ), UNO_QUERY_THROW );
944*cdf0e10cSrcweir                     ::comphelper::NamedValueCollection aLoadArgs;
945*cdf0e10cSrcweir                     aLoadArgs.put( "Model", pBasicIDE->GetModel() );
946*cdf0e10cSrcweir                     aLoadArgs.put( "URL", ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:factory/sbasic" ) ) );
947*cdf0e10cSrcweir 
948*cdf0e10cSrcweir                     Reference< XFrame > xTargetFrame( lcl_findStartModuleFrame( aContext ) );
949*cdf0e10cSrcweir                     if ( !xTargetFrame.is() )
950*cdf0e10cSrcweir                         xTargetFrame = SfxFrame::CreateBlankFrame();
951*cdf0e10cSrcweir                     ENSURE_OR_THROW( xTargetFrame.is(), "could not obtain a frameto load the Basic IDE into!" );
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir                     xLoader->load( aLoadArgs.getPropertyValues(), xTargetFrame );
954*cdf0e10cSrcweir                 }
955*cdf0e10cSrcweir                 catch( const Exception& )
956*cdf0e10cSrcweir                 {
957*cdf0e10cSrcweir                 	DBG_UNHANDLED_EXCEPTION();
958*cdf0e10cSrcweir                 }
959*cdf0e10cSrcweir 
960*cdf0e10cSrcweir                 pView = lcl_getBasicIDEViewFrame( pBasicIDE );
961*cdf0e10cSrcweir                 if ( pView )
962*cdf0e10cSrcweir                     pView->SetName( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC:1" ) ) );
963*cdf0e10cSrcweir             }
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir             if ( pView )
966*cdf0e10cSrcweir                 pView->GetFrame().Appear();
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir             const SfxItemSet* pArgs = rReq.GetArgs();
969*cdf0e10cSrcweir             if ( pArgs && pView )
970*cdf0e10cSrcweir             {
971*cdf0e10cSrcweir                 SfxViewShell* pViewShell = pView->GetViewShell();
972*cdf0e10cSrcweir                 SfxObjectShell* pObjShell = pView->GetObjectShell();
973*cdf0e10cSrcweir                 if ( pViewShell && pObjShell )
974*cdf0e10cSrcweir                 {
975*cdf0e10cSrcweir                     SfxRequest aReq( SID_BASICIDE_SHOWWINDOW, SFX_CALLMODE_SYNCHRON, pObjShell->GetPool() );
976*cdf0e10cSrcweir                     aReq.SetArgs( *pArgs );
977*cdf0e10cSrcweir                     pViewShell->ExecuteSlot( aReq );
978*cdf0e10cSrcweir                 }
979*cdf0e10cSrcweir             }
980*cdf0e10cSrcweir 
981*cdf0e10cSrcweir 			rReq.Done();
982*cdf0e10cSrcweir 		}
983*cdf0e10cSrcweir 		break;
984*cdf0e10cSrcweir 
985*cdf0e10cSrcweir 		case SID_BASICCHOOSER:
986*cdf0e10cSrcweir 		{
987*cdf0e10cSrcweir 			const SfxItemSet* pArgs = rReq.GetArgs();
988*cdf0e10cSrcweir 			const SfxPoolItem* pItem;
989*cdf0e10cSrcweir             sal_Bool bChooseOnly = sal_False;
990*cdf0e10cSrcweir             Reference< XModel > xLimitToModel;
991*cdf0e10cSrcweir             if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_RECORDMACRO, sal_False, &pItem) )
992*cdf0e10cSrcweir             {
993*cdf0e10cSrcweir                 sal_Bool bRecord = ((SfxBoolItem*)pItem)->GetValue();
994*cdf0e10cSrcweir                 if ( bRecord )
995*cdf0e10cSrcweir                 {
996*cdf0e10cSrcweir                     // !Hack
997*cdf0e10cSrcweir                     bChooseOnly = sal_False;
998*cdf0e10cSrcweir                     SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
999*cdf0e10cSrcweir                     OSL_ENSURE( pCurrentShell, "macro recording outside an SFX document?" );
1000*cdf0e10cSrcweir                     if ( pCurrentShell )
1001*cdf0e10cSrcweir                         xLimitToModel = pCurrentShell->GetModel();
1002*cdf0e10cSrcweir                 }
1003*cdf0e10cSrcweir             }
1004*cdf0e10cSrcweir 
1005*cdf0e10cSrcweir             rReq.SetReturnValue( SfxStringItem( rReq.GetSlot(), ChooseMacro( xLimitToModel, bChooseOnly ) ) );
1006*cdf0e10cSrcweir 			rReq.Done();
1007*cdf0e10cSrcweir 		}
1008*cdf0e10cSrcweir 		break;
1009*cdf0e10cSrcweir 
1010*cdf0e10cSrcweir 		case SID_MACROORGANIZER:
1011*cdf0e10cSrcweir 		{
1012*cdf0e10cSrcweir             OSL_TRACE("handling SID_MACROORGANIZER");
1013*cdf0e10cSrcweir 			const SfxItemSet* pArgs = rReq.GetArgs();
1014*cdf0e10cSrcweir 			const SfxPoolItem* pItem;
1015*cdf0e10cSrcweir             sal_Int16 nTabId = 0;
1016*cdf0e10cSrcweir             if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_MACROORGANIZER, sal_False, &pItem) )
1017*cdf0e10cSrcweir             {
1018*cdf0e10cSrcweir                 nTabId = ((SfxUInt16Item*)pItem)->GetValue();
1019*cdf0e10cSrcweir             }
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir             SfxApplication::MacroOrganizer( nTabId );
1022*cdf0e10cSrcweir 			rReq.Done();
1023*cdf0e10cSrcweir 		}
1024*cdf0e10cSrcweir 		break;
1025*cdf0e10cSrcweir 
1026*cdf0e10cSrcweir         case SID_RUNMACRO:
1027*cdf0e10cSrcweir         {
1028*cdf0e10cSrcweir             SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1029*cdf0e10cSrcweir             OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg");
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir             Reference< XFrame > xFrame;
1032*cdf0e10cSrcweir 			const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
1033*cdf0e10cSrcweir             SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
1034*cdf0e10cSrcweir             if ( pFrameItem )
1035*cdf0e10cSrcweir                 xFrame = pFrameItem->GetFrame();
1036*cdf0e10cSrcweir 
1037*cdf0e10cSrcweir             if ( !xFrame.is() )
1038*cdf0e10cSrcweir             {
1039*cdf0e10cSrcweir                 const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1040*cdf0e10cSrcweir                 if ( pViewFrame )
1041*cdf0e10cSrcweir                     xFrame = pViewFrame->GetFrame().GetFrameInterface();
1042*cdf0e10cSrcweir             }
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir             do  // artificial loop for flow control
1045*cdf0e10cSrcweir             {
1046*cdf0e10cSrcweir                 AbstractScriptSelectorDialog* pDlg = pFact->CreateScriptSelectorDialog(
1047*cdf0e10cSrcweir                     lcl_getDialogParent( xFrame, GetTopWindow() ), sal_False, xFrame );
1048*cdf0e10cSrcweir                 OSL_ENSURE( pDlg, "SfxApplication::OfaExec_Impl( SID_RUNMACRO ): no dialog!" );
1049*cdf0e10cSrcweir                 if ( !pDlg )
1050*cdf0e10cSrcweir                     break;
1051*cdf0e10cSrcweir                 pDlg->SetRunLabel();
1052*cdf0e10cSrcweir 
1053*cdf0e10cSrcweir                 short nDialogResult = pDlg->Execute();
1054*cdf0e10cSrcweir                 if ( !nDialogResult )
1055*cdf0e10cSrcweir                     break;
1056*cdf0e10cSrcweir 
1057*cdf0e10cSrcweir                 Sequence< Any > args;
1058*cdf0e10cSrcweir                 Sequence< sal_Int16 > outIndex;
1059*cdf0e10cSrcweir                 Sequence< Any > outArgs;
1060*cdf0e10cSrcweir                 Any ret;
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir                 Reference< XInterface > xScriptContext;
1063*cdf0e10cSrcweir 
1064*cdf0e10cSrcweir                 Reference< XController > xController;
1065*cdf0e10cSrcweir                 if ( xFrame.is() )
1066*cdf0e10cSrcweir                     xController = xFrame->getController();
1067*cdf0e10cSrcweir                 if ( xController.is() )
1068*cdf0e10cSrcweir                     xScriptContext = xController->getModel();
1069*cdf0e10cSrcweir                 if ( !xScriptContext.is() )
1070*cdf0e10cSrcweir                     xScriptContext = xController;
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir                 SfxObjectShell::CallXScript( xScriptContext, pDlg->GetScriptURL(), args, ret, outIndex, outArgs );
1073*cdf0e10cSrcweir             }
1074*cdf0e10cSrcweir             while ( false );
1075*cdf0e10cSrcweir 			rReq.Done();
1076*cdf0e10cSrcweir 		}
1077*cdf0e10cSrcweir         break;
1078*cdf0e10cSrcweir 
1079*cdf0e10cSrcweir         case SID_SCRIPTORGANIZER:
1080*cdf0e10cSrcweir         {
1081*cdf0e10cSrcweir             SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1082*cdf0e10cSrcweir             OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg");
1083*cdf0e10cSrcweir 			const SfxItemSet* pArgs = rReq.GetArgs();
1084*cdf0e10cSrcweir 			const SfxPoolItem* pItem;
1085*cdf0e10cSrcweir             String aLanguage;
1086*cdf0e10cSrcweir             if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_SCRIPTORGANIZER, sal_False, &pItem) )
1087*cdf0e10cSrcweir             {
1088*cdf0e10cSrcweir                 aLanguage = ((SfxScriptOrganizerItem*)pItem)->getLanguage();
1089*cdf0e10cSrcweir             }
1090*cdf0e10cSrcweir 
1091*cdf0e10cSrcweir             ::rtl::OUString aLang( aLanguage );
1092*cdf0e10cSrcweir             OSL_TRACE("SfxApplication::OfaExec_Impl: about to create dialog for: %s", ::rtl::OUStringToOString( aLang , RTL_TEXTENCODING_ASCII_US ).pData->buffer);
1093*cdf0e10cSrcweir             // not sure about the Window*
1094*cdf0e10cSrcweir             VclAbstractDialog* pDlg = pFact->CreateSvxScriptOrgDialog( GetTopWindow(), aLanguage );
1095*cdf0e10cSrcweir             if( pDlg )
1096*cdf0e10cSrcweir             {
1097*cdf0e10cSrcweir                 pDlg->Execute();
1098*cdf0e10cSrcweir             }
1099*cdf0e10cSrcweir             else
1100*cdf0e10cSrcweir             {
1101*cdf0e10cSrcweir                 OSL_TRACE("no dialog!!!");
1102*cdf0e10cSrcweir             }
1103*cdf0e10cSrcweir 			rReq.Done();
1104*cdf0e10cSrcweir 		}
1105*cdf0e10cSrcweir 		break;
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir 		case SID_OFFICE_CHECK_PLZ:
1108*cdf0e10cSrcweir 		{
1109*cdf0e10cSrcweir 			sal_Bool bRet = sal_False;
1110*cdf0e10cSrcweir 			SFX_REQUEST_ARG(rReq, pStringItem, SfxStringItem, rReq.GetSlot(), sal_False);
1111*cdf0e10cSrcweir 
1112*cdf0e10cSrcweir 			if ( pStringItem )
1113*cdf0e10cSrcweir 			{
1114*cdf0e10cSrcweir 				String aPLZ = pStringItem->GetValue();
1115*cdf0e10cSrcweir 				bRet = sal_True /*!!!SfxIniManager::CheckPLZ( aPLZ )*/;
1116*cdf0e10cSrcweir 			}
1117*cdf0e10cSrcweir 			else
1118*cdf0e10cSrcweir 				SbxBase::SetError( SbxERR_WRONG_ARGS );
1119*cdf0e10cSrcweir 			rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bRet ) );
1120*cdf0e10cSrcweir 		}
1121*cdf0e10cSrcweir 		break;
1122*cdf0e10cSrcweir 
1123*cdf0e10cSrcweir         case SID_AUTO_CORRECT_DLG:
1124*cdf0e10cSrcweir 		{
1125*cdf0e10cSrcweir 			SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1126*cdf0e10cSrcweir 			if ( pFact )
1127*cdf0e10cSrcweir 			{
1128*cdf0e10cSrcweir 				SfxItemSet aSet(GetPool(), SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG);
1129*cdf0e10cSrcweir 				const SfxPoolItem* pItem=NULL;
1130*cdf0e10cSrcweir 				const SfxItemSet* pSet = rReq.GetArgs();
1131*cdf0e10cSrcweir 				SfxItemPool* pSetPool = pSet ? pSet->GetPool() : NULL;
1132*cdf0e10cSrcweir 				if ( pSet && pSet->GetItemState( pSetPool->GetWhich( SID_AUTO_CORRECT_DLG ), sal_False, &pItem ) == SFX_ITEM_SET )
1133*cdf0e10cSrcweir 					aSet.Put( *pItem );
1134*cdf0e10cSrcweir 
1135*cdf0e10cSrcweir 			  	SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( RID_OFA_AUTOCORR_DLG, NULL, &aSet, NULL );
1136*cdf0e10cSrcweir 			  	pDlg->Execute();
1137*cdf0e10cSrcweir 			  	delete pDlg;
1138*cdf0e10cSrcweir 			}
1139*cdf0e10cSrcweir 
1140*cdf0e10cSrcweir 			break;
1141*cdf0e10cSrcweir 		}
1142*cdf0e10cSrcweir 
1143*cdf0e10cSrcweir 		case SID_SD_AUTOPILOT :
1144*cdf0e10cSrcweir 		case SID_NEWSD :
1145*cdf0e10cSrcweir 		{
1146*cdf0e10cSrcweir 			SvtModuleOptions aModuleOpt;
1147*cdf0e10cSrcweir 			if ( !aModuleOpt.IsImpress() )
1148*cdf0e10cSrcweir 			{
1149*cdf0e10cSrcweir 				ErrorBox( 0, ResId( RID_ERRBOX_MODULENOTINSTALLED, *GetOffResManager_Impl() )).Execute();
1150*cdf0e10cSrcweir 				return;
1151*cdf0e10cSrcweir 			}
1152*cdf0e10cSrcweir 
1153*cdf0e10cSrcweir 			Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
1154*cdf0e10cSrcweir 			Reference< com::sun::star::frame::XDispatchProvider > xProv(
1155*cdf0e10cSrcweir 				xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY );
1156*cdf0e10cSrcweir 
1157*cdf0e10cSrcweir 			if ( xProv.is() )
1158*cdf0e10cSrcweir 			{
1159*cdf0e10cSrcweir 				::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
1160*cdf0e10cSrcweir 				Reference< com::sun::star::frame::XDispatchHelper > xHelper(
1161*cdf0e10cSrcweir 					xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY );
1162*cdf0e10cSrcweir 				if ( xHelper.is() )
1163*cdf0e10cSrcweir 				{
1164*cdf0e10cSrcweir 					Sequence < com::sun::star::beans::PropertyValue > aSeq;
1165*cdf0e10cSrcweir 					if ( rReq.GetArgs() )
1166*cdf0e10cSrcweir 						TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
1167*cdf0e10cSrcweir 					Any aResult = xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aSeq );
1168*cdf0e10cSrcweir 					::com::sun::star::frame::DispatchResultEvent aEvent;
1169*cdf0e10cSrcweir 					sal_Bool bSuccess = (
1170*cdf0e10cSrcweir 										 (aResult >>= aEvent) &&
1171*cdf0e10cSrcweir                                          (aEvent.State == ::com::sun::star::frame::DispatchResultState::SUCCESS)
1172*cdf0e10cSrcweir 										);
1173*cdf0e10cSrcweir 					rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
1174*cdf0e10cSrcweir 				}
1175*cdf0e10cSrcweir 			}
1176*cdf0e10cSrcweir 		}
1177*cdf0e10cSrcweir 		break;
1178*cdf0e10cSrcweir 
1179*cdf0e10cSrcweir         case FN_LABEL :
1180*cdf0e10cSrcweir         case FN_BUSINESS_CARD :
1181*cdf0e10cSrcweir         case FN_XFORMS_INIT :
1182*cdf0e10cSrcweir 		{
1183*cdf0e10cSrcweir 			Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
1184*cdf0e10cSrcweir 			Reference< com::sun::star::frame::XDispatchProvider > xProv(
1185*cdf0e10cSrcweir 				xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.text.ModuleDispatcher")), UNO_QUERY );
1186*cdf0e10cSrcweir 
1187*cdf0e10cSrcweir 			if ( xProv.is() )
1188*cdf0e10cSrcweir 			{
1189*cdf0e10cSrcweir 				::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
1190*cdf0e10cSrcweir 				Reference< com::sun::star::frame::XDispatchHelper > xHelper(
1191*cdf0e10cSrcweir 					xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY );
1192*cdf0e10cSrcweir 				if ( xHelper.is() )
1193*cdf0e10cSrcweir 				{
1194*cdf0e10cSrcweir 					Sequence < com::sun::star::beans::PropertyValue > aSeq;
1195*cdf0e10cSrcweir 					if ( rReq.GetArgs() )
1196*cdf0e10cSrcweir 						TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
1197*cdf0e10cSrcweir 					Any aResult = xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aSeq );
1198*cdf0e10cSrcweir 					::com::sun::star::frame::DispatchResultEvent aEvent;
1199*cdf0e10cSrcweir 					sal_Bool bSuccess = (
1200*cdf0e10cSrcweir 										 (aResult >>= aEvent) &&
1201*cdf0e10cSrcweir                                          (aEvent.State == ::com::sun::star::frame::DispatchResultState::SUCCESS)
1202*cdf0e10cSrcweir 										);
1203*cdf0e10cSrcweir 					rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
1204*cdf0e10cSrcweir 				}
1205*cdf0e10cSrcweir 			}
1206*cdf0e10cSrcweir 		}
1207*cdf0e10cSrcweir 		break;
1208*cdf0e10cSrcweir 
1209*cdf0e10cSrcweir 		case SID_ADDRESS_DATA_SOURCE:
1210*cdf0e10cSrcweir 		{
1211*cdf0e10cSrcweir             ::rtl::OUString sDialogServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.AddressBookSourcePilot" ) );
1212*cdf0e10cSrcweir 			try
1213*cdf0e10cSrcweir 			{
1214*cdf0e10cSrcweir 				Reference< com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
1215*cdf0e10cSrcweir 				Reference< com::sun::star::ui::dialogs::XExecutableDialog > xDialog;
1216*cdf0e10cSrcweir 				if (xORB.is())
1217*cdf0e10cSrcweir 					xDialog = Reference< com::sun::star::ui::dialogs::XExecutableDialog >(xORB->createInstance(sDialogServiceName), UNO_QUERY);
1218*cdf0e10cSrcweir 				if (xDialog.is())
1219*cdf0e10cSrcweir 					xDialog->execute();
1220*cdf0e10cSrcweir 				else
1221*cdf0e10cSrcweir 					ShowServiceNotAvailableError(NULL, sDialogServiceName, sal_True);
1222*cdf0e10cSrcweir 			}
1223*cdf0e10cSrcweir 			catch(::com::sun::star::uno::Exception&)
1224*cdf0e10cSrcweir 			{
1225*cdf0e10cSrcweir 			}
1226*cdf0e10cSrcweir 		}
1227*cdf0e10cSrcweir 		break;
1228*cdf0e10cSrcweir 
1229*cdf0e10cSrcweir 		case SID_COMP_BIBLIOGRAPHY:
1230*cdf0e10cSrcweir 		{
1231*cdf0e10cSrcweir 			SfxStringItem aURL(SID_FILE_NAME, String::CreateFromAscii(".component:Bibliography/View1"));
1232*cdf0e10cSrcweir 			SfxStringItem aRef(SID_REFERER, String::CreateFromAscii("private:user"));
1233*cdf0e10cSrcweir 			SfxStringItem aTarget(SID_TARGETNAME, String::CreateFromAscii("_blank"));
1234*cdf0e10cSrcweir 			SfxViewFrame::Current()->GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aURL, &aRef, &aTarget, 0L);
1235*cdf0e10cSrcweir 		}
1236*cdf0e10cSrcweir 		break;
1237*cdf0e10cSrcweir 	}
1238*cdf0e10cSrcweir }
1239*cdf0e10cSrcweir 
1240*cdf0e10cSrcweir void SfxApplication::OfaState_Impl(SfxItemSet &rSet)
1241*cdf0e10cSrcweir {
1242*cdf0e10cSrcweir 	const sal_uInt16 *pRanges = rSet.GetRanges();
1243*cdf0e10cSrcweir 	DBG_ASSERT(pRanges && *pRanges, "Set ohne Bereich");
1244*cdf0e10cSrcweir 	while ( *pRanges )
1245*cdf0e10cSrcweir 	{
1246*cdf0e10cSrcweir 		for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
1247*cdf0e10cSrcweir 		{
1248*cdf0e10cSrcweir 			switch(nWhich)
1249*cdf0e10cSrcweir 			{
1250*cdf0e10cSrcweir 				case SID_ONLINE_REGISTRATION:
1251*cdf0e10cSrcweir 				{
1252*cdf0e10cSrcweir 					::utl::RegOptions aOptions;
1253*cdf0e10cSrcweir 					if ( !aOptions.allowMenu() )
1254*cdf0e10cSrcweir 						rSet.DisableItem( SID_ONLINE_REGISTRATION );
1255*cdf0e10cSrcweir 				}
1256*cdf0e10cSrcweir 				break;
1257*cdf0e10cSrcweir 			}
1258*cdf0e10cSrcweir 		}
1259*cdf0e10cSrcweir 	}
1260*cdf0e10cSrcweir 
1261*cdf0e10cSrcweir 	SvtModuleOptions aModuleOpt;
1262*cdf0e10cSrcweir 
1263*cdf0e10cSrcweir     if( !aModuleOpt.IsWriter())
1264*cdf0e10cSrcweir     {
1265*cdf0e10cSrcweir         rSet.DisableItem( FN_LABEL );
1266*cdf0e10cSrcweir         rSet.DisableItem( FN_BUSINESS_CARD );
1267*cdf0e10cSrcweir         rSet.DisableItem( FN_XFORMS_INIT );
1268*cdf0e10cSrcweir     }
1269*cdf0e10cSrcweir 
1270*cdf0e10cSrcweir 	if ( !aModuleOpt.IsImpress() )
1271*cdf0e10cSrcweir         rSet.DisableItem( SID_SD_AUTOPILOT );
1272*cdf0e10cSrcweir }
1273