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