Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/document/XEmbeddedScripts.hpp>
21 : #include <com/sun/star/drawing/ModuleDispatcher.hpp>
22 : #include <com/sun/star/embed/XStorage.hpp>
23 : #include <com/sun/star/embed/ElementModes.hpp>
24 : #include <com/sun/star/frame/Desktop.hpp>
25 : #include <com/sun/star/frame/DispatchResultEvent.hpp>
26 : #include <com/sun/star/frame/DispatchResultState.hpp>
27 : #include <com/sun/star/frame/DispatchHelper.hpp>
28 : #include <com/sun/star/frame/XDesktop.hpp>
29 : #include <com/sun/star/frame/XFramesSupplier.hpp>
30 : #include <com/sun/star/frame/XLayoutManager.hpp>
31 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 : #include <com/sun/star/lang/IllegalArgumentException.hpp>
33 : #include <com/sun/star/sdbc/DriverManager.hpp>
34 : #include <com/sun/star/system/SystemShellExecute.hpp>
35 : #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
36 : #include <com/sun/star/system/SystemShellExecuteException.hpp>
37 : #include <com/sun/star/task/XJobExecutor.hpp>
38 : #include <com/sun/star/text/ModuleDispatcher.hpp>
39 : #include <com/sun/star/ui/dialogs/AddressBookSourcePilot.hpp>
40 : #include <com/sun/star/uno/Reference.hxx>
41 : #include <com/sun/star/util/XCloseable.hpp>
42 : #include <com/sun/star/util/CloseVetoException.hpp>
43 : #include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
44 :
45 : #include <com/sun/star/frame/XComponentLoader.hpp>
46 :
47 : #include <comphelper/processfactory.hxx>
48 : #include <comphelper/storagehelper.hxx>
49 : #include "comphelper/configurationhelper.hxx"
50 :
51 : #include <svtools/addresstemplate.hxx>
52 : #include <svtools/miscopt.hxx>
53 : #include <svtools/restartdialog.hxx>
54 : #include <svl/visitem.hxx>
55 : #include <unotools/intlwrapper.hxx>
56 :
57 : #include <unotools/configmgr.hxx>
58 : #include <tools/diagnose_ex.h>
59 : #include <vcl/msgbox.hxx>
60 : #include <svl/intitem.hxx>
61 : #include <svl/eitem.hxx>
62 : #include <svl/stritem.hxx>
63 : #include <basic/sbstar.hxx>
64 : #include <basic/basmgr.hxx>
65 : #include <basic/basrdll.hxx>
66 : #include <svtools/sfxecode.hxx>
67 : #include <svtools/ehdl.hxx>
68 : #include <vcl/help.hxx>
69 : #include <vcl/stdtext.hxx>
70 : #include <rtl/ustrbuf.hxx>
71 : #include <osl/file.hxx>
72 :
73 : #include <unotools/pathoptions.hxx>
74 : #include <unotools/moduleoptions.hxx>
75 : #include <svtools/helpopt.hxx>
76 : #include <toolkit/helper/vclunohelper.hxx>
77 : #include <tools/shl.hxx>
78 : #include <unotools/bootstrap.hxx>
79 : #include <rtl/bootstrap.hxx>
80 : #include <cppuhelper/exc_hlp.hxx>
81 :
82 : #include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
83 : #include <com/sun/star/frame/ModuleManager.hpp>
84 : #include <com/sun/star/beans/XPropertySet.hpp>
85 :
86 : #include "frmload.hxx"
87 : #include "referers.hxx"
88 : #include <sfx2/app.hxx>
89 : #include <sfx2/request.hxx>
90 : #include <sfx2/dispatch.hxx>
91 : #include <sfx2/bindings.hxx>
92 : #include <sfx2/msg.hxx>
93 : #include <sfx2/objface.hxx>
94 : #include <sfx2/objitem.hxx>
95 : #include <sfx2/objsh.hxx>
96 : #include <sfx2/hintpost.hxx>
97 : #include <sfx2/viewsh.hxx>
98 : #include <sfx2/docfac.hxx>
99 : #include <sfx2/docfile.hxx>
100 : #include <sfx2/docfilt.hxx>
101 : #include <sfx2/new.hxx>
102 : #include "sfxtypes.hxx"
103 : #include <sfx2/tabdlg.hxx>
104 : #include "arrdecl.hxx"
105 : #include "fltfnc.hxx"
106 : #include <sfx2/sfx.hrc>
107 : #include "app.hrc"
108 : #include <sfx2/passwd.hxx>
109 : #include "sfx2/sfxresid.hxx"
110 : #include <sfx2/childwin.hxx>
111 : #include "appdata.hxx"
112 : #include "sfx2/minfitem.hxx"
113 : #include <sfx2/event.hxx>
114 : #include <sfx2/module.hxx>
115 : #include <sfx2/viewfrm.hxx>
116 : #include "sfxpicklist.hxx"
117 : #include "imestatuswindow.hxx"
118 : #include <sfx2/sfxdlg.hxx>
119 : #include <sfx2/dialogs.hrc>
120 : #include "sorgitm.hxx"
121 : #include "sfx2/sfxhelp.hxx"
122 : #include <sfx2/zoomitem.hxx>
123 : #include "templatedlg.hxx"
124 :
125 : using namespace ::com::sun::star;
126 : using namespace ::com::sun::star::beans;
127 : using namespace ::com::sun::star::uno;
128 : using namespace ::com::sun::star::frame;
129 : using namespace ::com::sun::star::container;
130 : using namespace ::com::sun::star::util;
131 : using namespace ::com::sun::star::script;
132 : using namespace ::com::sun::star::system;
133 : using namespace ::com::sun::star::lang;
134 : using namespace ::com::sun::star::document;
135 :
136 : namespace
137 : {
138 : // lp#527938, debian#602953, fdo#33266, i#105408
139 0 : static bool lcl_isBaseAvailable()
140 : {
141 : try
142 : {
143 : // if we get com::sun::star::sdbc::DriverManager, libsdbc2 is there
144 : // and the bibliography is assumed to work
145 0 : return com::sun::star::sdbc::DriverManager::create(comphelper::getProcessComponentContext()).is();
146 : }
147 0 : catch (Exception & e)
148 : {
149 : SAL_INFO(
150 : "sfx2.appl",
151 : "assuming Base to be missing; caught " << e.Message);
152 0 : return false;
153 : }
154 : }
155 0 : static void lcl_tryLoadBibliography()
156 : {
157 : // lp#527938, debian#602953, fdo#33266, i#105408
158 : // make sure we actually can instanciate services from base first
159 0 : if(!lcl_isBaseAvailable())
160 : {
161 : try
162 : {
163 : using namespace org::freedesktop::PackageKit;
164 : using namespace svtools;
165 0 : Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext()));
166 0 : Sequence< OUString > vPackages(1);
167 0 : vPackages[0] = "libreoffice-base";
168 0 : OUString sInteraction;
169 0 : xSyncDbusSessionHelper->InstallPackageNames(0, vPackages, sInteraction);
170 : // Ill be back (hopefully)!
171 0 : SolarMutexGuard aGuard;
172 0 : executeRestartDialog(comphelper::getProcessComponentContext(), NULL, RESTART_REASON_BIBLIOGRAPHY_INSTALL);
173 : }
174 0 : catch (const Exception & e)
175 : {
176 : SAL_INFO(
177 : "sfx2.appl",
178 : "trying to install LibreOffice Base, caught " << e.Message);
179 : }
180 0 : return;
181 : }
182 :
183 : try // fdo#48775
184 : {
185 0 : SfxStringItem aURL(SID_FILE_NAME, OUString(".component:Bibliography/View1"));
186 0 : SfxStringItem aRef(SID_REFERER, OUString("private:user"));
187 0 : SfxStringItem aTarget(SID_TARGETNAME, OUString("_blank"));
188 0 : SfxViewFrame::Current()->GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aURL, &aRef, &aTarget, 0L);
189 : }
190 0 : catch (const Exception & e)
191 : {
192 : SAL_INFO( "sfx2.appl",
193 : "trying to load bibliography database, caught " << e.Message);
194 : }
195 : }
196 : }
197 : /// Find the correct location of the document (LICENSE.odt, etc.), and return
198 : /// it in rURL if found.
199 0 : static sal_Bool checkURL( const char *pName, const char *pExt, OUString &rURL )
200 : {
201 : using namespace osl;
202 0 : DirectoryItem aDirItem;
203 :
204 0 : rURL = OUString( "$BRAND_BASE_DIR/" );
205 0 : rURL += OUString::createFromAscii( pName );
206 0 : rURL += OUString::createFromAscii( pExt );
207 0 : rtl::Bootstrap::expandMacros( rURL );
208 :
209 0 : if (!rURL.isEmpty())
210 0 : return DirectoryItem::get( rURL, aDirItem ) == DirectoryItem::E_None;
211 : else
212 0 : return sal_False;
213 : }
214 :
215 : /// Displays CREDITS or LICENSE in any of the available version
216 0 : static void showDocument( const char* pBaseName )
217 : {
218 : try {
219 0 : Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
220 0 : Sequence < com::sun::star::beans::PropertyValue > args(2);
221 0 : args[0].Name = OUString("ViewOnly");
222 0 : args[0].Value <<= sal_True;
223 0 : args[1].Name = OUString("ReadOnly");
224 0 : args[1].Value <<= sal_True;
225 :
226 0 : OUString aURL;
227 0 : if ( checkURL ( pBaseName, ".odt", aURL ) ||
228 0 : checkURL ( pBaseName, ".html", aURL ) ||
229 0 : checkURL ( pBaseName, "", aURL ) ) {
230 0 : xDesktop->loadComponentFromURL( aURL, OUString("_blank"), 0, args );
231 0 : }
232 0 : } catch (const ::com::sun::star::uno::Exception &) {
233 : }
234 0 : }
235 :
236 : namespace
237 : {
238 0 : class LicenseDialog : public ModalDialog
239 : {
240 : private:
241 : DECL_LINK(ShowHdl, void *);
242 : public:
243 : LicenseDialog(Window *pParent=NULL);
244 : };
245 :
246 0 : LicenseDialog::LicenseDialog(Window *pParent)
247 0 : : ModalDialog(pParent, "LicenseDialog", "sfx/ui/licensedialog.ui")
248 : {
249 0 : get<PushButton>("show")->SetClickHdl(LINK(this, LicenseDialog, ShowHdl));
250 0 : }
251 :
252 0 : IMPL_LINK_NOARG(LicenseDialog, ShowHdl)
253 : {
254 0 : EndDialog(RET_OK);
255 0 : showDocument("LICENSE");
256 0 : return 0;
257 : }
258 : }
259 :
260 0 : void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
261 : {
262 0 : bool bDone = false;
263 0 : switch ( rReq.GetSlot() )
264 : {
265 : case SID_SETOPTIONS:
266 : {
267 0 : if( rReq.GetArgs() )
268 0 : SetOptions_Impl( *rReq.GetArgs() );
269 0 : break;
270 : }
271 :
272 : case SID_QUITAPP:
273 : case SID_EXITANDRETURN:
274 : case SID_LOGOUT:
275 : {
276 : // protect against reentrant calls
277 0 : if ( pAppData_Impl->bInQuit )
278 0 : return;
279 :
280 0 : if ( rReq.GetSlot() == SID_LOGOUT )
281 : {
282 0 : for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
283 : pObjSh; pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
284 : {
285 0 : if ( !pObjSh->IsModified() )
286 0 : continue;
287 :
288 0 : SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pObjSh );
289 0 : if ( !pFrame || !pFrame->GetWindow().IsReallyVisible() )
290 0 : continue;
291 :
292 0 : if ( pObjSh->PrepareClose(2) )
293 0 : pObjSh->SetModified( sal_False );
294 : else
295 0 : return;
296 : }
297 :
298 0 : SfxStringItem aNameItem( SID_FILE_NAME, OUString("vnd.sun.star.cmd:logout") );
299 0 : SfxStringItem aReferer( SID_REFERER, "private/user" );
300 0 : pAppData_Impl->pAppDispat->Execute( SID_OPENDOC, SFX_CALLMODE_SLOT, &aNameItem, &aReferer, 0L );
301 0 : return;
302 : }
303 :
304 : // aus verschachtelten Requests nach 100ms nochmal probieren
305 0 : if( Application::GetDispatchLevel() > 1 )
306 : {
307 : /* Dont save the request for closing the application and try it later
308 : again. This is an UI bound functionality ... and the user will try it again
309 : if the dialog is closed. But we shouldnt close the application automaticly
310 : if this dialog is closed by the user ...
311 : So we ignore this request now and wait for a new user decision.
312 : */
313 : OSL_TRACE( "QueryExit => sal_False (DispatchLevel == %u)", Application::GetDispatchLevel() );
314 0 : return;
315 : }
316 :
317 : // block reentrant calls
318 0 : pAppData_Impl->bInQuit = sal_True;
319 0 : Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() );
320 :
321 0 : rReq.ForgetAllArgs();
322 :
323 : // if terminate() failed, pAppData_Impl->bInQuit will now be sal_False, allowing further calls of SID_QUITAPP
324 0 : sal_Bool bTerminated = xDesktop->terminate();
325 0 : if (!bTerminated)
326 : // if terminate() was successful, SfxApplication is now dead!
327 0 : pAppData_Impl->bInQuit = sal_False;
328 :
329 : // Set return value, terminate if possible
330 0 : rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bTerminated ) );
331 0 : return;
332 : }
333 :
334 : case SID_CONFIG:
335 : case SID_TOOLBOXOPTIONS:
336 : case SID_CONFIGSTATUSBAR:
337 : case SID_CONFIGMENU:
338 : case SID_CONFIGACCEL:
339 : case SID_CONFIGEVENT:
340 : {
341 : SfxAbstractDialogFactory* pFact =
342 0 : SfxAbstractDialogFactory::Create();
343 :
344 0 : if ( pFact )
345 : {
346 0 : SFX_REQUEST_ARG(rReq, pStringItem,
347 : SfxStringItem, SID_CONFIG, sal_False);
348 :
349 : SfxItemSet aSet(
350 0 : GetPool(), SID_CONFIG, SID_CONFIG );
351 :
352 0 : if ( pStringItem )
353 : {
354 : aSet.Put( SfxStringItem(
355 0 : SID_CONFIG, pStringItem->GetValue() ) );
356 : }
357 :
358 0 : Reference< XFrame > xFrame;
359 0 : const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
360 0 : SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
361 0 : if ( pFrameItem )
362 0 : xFrame = pFrameItem->GetFrame();
363 :
364 : SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog(
365 : RID_SVXDLG_CUSTOMIZE,
366 0 : NULL, &aSet, xFrame );
367 :
368 0 : if ( pDlg )
369 : {
370 0 : const short nRet = pDlg->Execute();
371 :
372 0 : if ( nRet )
373 0 : bDone = true;
374 :
375 0 : delete pDlg;
376 0 : }
377 : }
378 0 : break;
379 : }
380 :
381 : case SID_CLOSEDOCS:
382 : case SID_CLOSEWINS:
383 : {
384 :
385 0 : Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
386 0 : Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY );
387 0 : if ( !xTasks.is() )
388 0 : break;
389 :
390 0 : sal_Int32 n=0;
391 : do
392 : {
393 0 : if ( xTasks->getCount() <= n )
394 0 : break;
395 :
396 0 : Any aAny = xTasks->getByIndex(n);
397 0 : Reference < XCloseable > xTask;
398 0 : aAny >>= xTask;
399 : try
400 : {
401 0 : xTask->close(sal_True);
402 0 : n++;
403 : }
404 0 : catch( CloseVetoException& )
405 : {
406 0 : }
407 : }
408 : while( true );
409 :
410 0 : sal_Bool bOk = ( n == 0);
411 0 : rReq.SetReturnValue( SfxBoolItem( 0, bOk ) );
412 0 : bDone = true;
413 0 : break;
414 : }
415 :
416 : case SID_SAVEDOCS:
417 : {
418 0 : sal_Bool bOK = sal_True;
419 0 : for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
420 : pObjSh;
421 : pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
422 : {
423 0 : SfxRequest aReq( SID_SAVEDOC, 0, pObjSh->GetPool() );
424 0 : if ( pObjSh->IsModified() )
425 : {
426 0 : pObjSh->ExecuteSlot( aReq );
427 0 : SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, aReq.GetReturnValue() );
428 0 : if ( !pItem || !pItem->GetValue() )
429 0 : bOK = sal_False;
430 : }
431 0 : }
432 :
433 0 : rReq.SetReturnValue( SfxBoolItem( 0, bOK ) );
434 0 : rReq.Done();
435 0 : break;
436 : }
437 :
438 : case SID_SEND_FEEDBACK:
439 : {
440 0 : OUString module = SfxHelp::GetCurrentModuleIdentifier();
441 0 : OUString sURL("http://hub.libreoffice.org/send-feedback/?LOversion=" + utl::ConfigManager::getAboutBoxProductVersion() +
442 0 : "&LOlocale=" + utl::ConfigManager::getLocale() + "&LOmodule=" + module.copy(module.lastIndexOf('.') + 1 ) );
443 : try
444 : {
445 : uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
446 0 : com::sun::star::system::SystemShellExecute::create(::comphelper::getProcessComponentContext()) );
447 0 : xSystemShellExecute->execute( sURL, OUString(), com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY );
448 : }
449 0 : catch ( uno::Exception& )
450 : {
451 : }
452 0 : break;
453 : }
454 :
455 : case SID_SHOW_LICENSE:
456 : {
457 0 : LicenseDialog aDialog;
458 0 : aDialog.Execute();
459 0 : break;
460 : }
461 :
462 : case SID_SHOW_CREDITS:
463 : {
464 0 : showDocument( "CREDITS" );
465 0 : break;
466 : }
467 :
468 : // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
469 : case SID_HELPINDEX:
470 : {
471 0 : Help* pHelp = Application::GetHelp();
472 0 : if ( pHelp )
473 : {
474 0 : pHelp->Start( OUString(".uno:HelpIndex"), NULL ); // show start page
475 0 : bDone = true;
476 : }
477 0 : break;
478 : }
479 :
480 : // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
481 : case SID_HELPTIPS:
482 : {
483 : // Evaluate Parameter
484 0 : SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPTIPS, sal_False);
485 : bool bOn = pOnItem
486 0 : ? ((SfxBoolItem*)pOnItem)->GetValue()
487 0 : : !Help::IsQuickHelpEnabled();
488 :
489 0 : if ( bOn )
490 0 : Help::EnableQuickHelp();
491 : else
492 0 : Help::DisableQuickHelp();
493 0 : SvtHelpOptions().SetHelpTips( bOn );
494 0 : Invalidate(SID_HELPTIPS);
495 0 : bDone = true;
496 :
497 : // Record if possible
498 0 : if ( !rReq.IsAPI() )
499 0 : rReq.AppendItem( SfxBoolItem( SID_HELPTIPS, bOn) );
500 0 : break;
501 : }
502 : // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
503 : case SID_EXTENDEDHELP:
504 : {
505 0 : Help::StartExtHelp();
506 0 : break;
507 : }
508 : case SID_HELPBALLOONS:
509 : {
510 : // Evaluate Parameter
511 0 : SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPBALLOONS, sal_False);
512 : bool bOn = pOnItem
513 0 : ? ((SfxBoolItem*)pOnItem)->GetValue()
514 0 : : !Help::IsBalloonHelpEnabled();
515 :
516 0 : if ( bOn )
517 0 : Help::EnableBalloonHelp();
518 : else
519 0 : Help::DisableBalloonHelp();
520 0 : SvtHelpOptions().SetExtendedHelp( bOn );
521 0 : Invalidate(SID_HELPBALLOONS);
522 0 : bDone = true;
523 :
524 : // Record if possible
525 0 : if ( !rReq.IsAPI() )
526 0 : rReq.AppendItem( SfxBoolItem( SID_HELPBALLOONS, bOn) );
527 0 : break;
528 : }
529 :
530 : // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
531 : case SID_ABOUT:
532 : {
533 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
534 0 : if ( pFact )
535 : {
536 0 : VclAbstractDialog* pDlg = pFact->CreateVclDialog( 0, RID_DEFAULTABOUT );
537 0 : pDlg->Execute();
538 0 : delete pDlg;
539 0 : bDone = true;
540 : }
541 0 : break;
542 : }
543 :
544 : case SID_TEMPLATE_MANAGER:
545 : {
546 0 : SfxTemplateManagerDlg dlg;
547 0 : dlg.Execute();
548 0 : bDone = true;
549 0 : break;
550 : }
551 :
552 : case SID_TEMPLATE_ADDRESSBOKSOURCE:
553 : {
554 0 : svt::AddressBookSourceDialog aDialog(GetTopWindow(), ::comphelper::getProcessComponentContext());
555 0 : aDialog.Execute();
556 0 : bDone = true;
557 0 : break;
558 : }
559 :
560 : #ifndef DISABLE_SCRIPTING
561 : case SID_BASICSTOP:
562 0 : StarBASIC::Stop();
563 0 : break;
564 :
565 : case SID_BASICBREAK :
566 0 : BASIC_DLL()->BasicBreak();
567 0 : break;
568 : #endif
569 :
570 : case SID_CRASH :
571 : {
572 : // Provoke a crash:
573 0 : char * crash = 0;
574 0 : *crash = 0;
575 0 : break;
576 : }
577 :
578 : case SID_SHOW_IME_STATUS_WINDOW:
579 0 : if (pAppData_Impl->m_xImeStatusWindow->canToggle())
580 : {
581 : SfxBoolItem const * pItem = static_cast< SfxBoolItem const * >(
582 : rReq.GetArg(SID_SHOW_IME_STATUS_WINDOW, false,
583 0 : TYPE(SfxBoolItem)));
584 : bool bShow = pItem == 0
585 0 : ? !pAppData_Impl->m_xImeStatusWindow->isShowing()
586 0 : : ( pItem->GetValue() == sal_True );
587 0 : pAppData_Impl->m_xImeStatusWindow->show(bShow);
588 0 : if (pItem == 0)
589 : rReq.AppendItem(SfxBoolItem(SID_SHOW_IME_STATUS_WINDOW,
590 0 : bShow));
591 : }
592 0 : bDone = true;
593 0 : break;
594 :
595 : case SID_ZOOM_50_PERCENT:
596 : case SID_ZOOM_75_PERCENT:
597 : case SID_ZOOM_100_PERCENT:
598 : case SID_ZOOM_150_PERCENT:
599 : case SID_ZOOM_200_PERCENT:
600 : case SID_ZOOM_OPTIMAL:
601 : case SID_ZOOM_ENTIRE_PAGE:
602 : case SID_ZOOM_PAGE_WIDTH:
603 : {
604 : // make sure aZoom is initialized with a proper value if SetType
605 : // doesn't work
606 0 : SvxZoomItem aZoom( SVX_ZOOM_PERCENT, 100 );
607 :
608 0 : switch (rReq.GetSlot())
609 : {
610 : case SID_ZOOM_50_PERCENT:
611 0 : aZoom.SetValue(50);
612 0 : break;
613 : case SID_ZOOM_75_PERCENT:
614 0 : aZoom.SetValue(75);
615 0 : break;
616 : case SID_ZOOM_100_PERCENT:
617 0 : aZoom.SetValue(100);
618 0 : break;
619 : case SID_ZOOM_150_PERCENT:
620 0 : aZoom.SetValue(150);
621 0 : break;
622 : case SID_ZOOM_200_PERCENT:
623 0 : aZoom.SetValue(200);
624 0 : break;
625 : case SID_ZOOM_OPTIMAL:
626 0 : aZoom.SetType( SVX_ZOOM_OPTIMAL );
627 0 : break;
628 : case SID_ZOOM_ENTIRE_PAGE:
629 0 : aZoom.SetType( SVX_ZOOM_WHOLEPAGE );
630 0 : break;
631 : case SID_ZOOM_PAGE_WIDTH:
632 0 : aZoom.SetType( SVX_ZOOM_PAGEWIDTH );
633 0 : break;
634 : }
635 :
636 0 : SfxViewFrame::Current()->GetDispatcher()->Execute(SID_ATTR_ZOOM, SFX_CALLMODE_ASYNCHRON, &aZoom, 0L);
637 :
638 0 : break;
639 : }
640 : case SID_AVAILABLE_TOOLBARS:
641 : {
642 : SfxStringItem const * pToolbarName = static_cast< SfxStringItem const *>(
643 0 : rReq.GetArg(SID_AVAILABLE_TOOLBARS, false, TYPE(SfxStringItem)));
644 :
645 0 : if ( pToolbarName )
646 : {
647 0 : Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() );
648 0 : Reference< XFrame > xFrame = xDesktop->getActiveFrame();
649 :
650 0 : Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
651 0 : Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
652 0 : if ( xPropSet.is() )
653 : {
654 : try
655 : {
656 0 : Any aValue = xPropSet->getPropertyValue("LayoutManager");
657 0 : aValue >>= xLayoutManager;
658 : }
659 0 : catch ( const ::com::sun::star::uno::RuntimeException& )
660 : {
661 0 : throw;
662 : }
663 0 : catch ( ::com::sun::star::uno::Exception& )
664 : {
665 : }
666 : }
667 :
668 0 : if ( xLayoutManager.is() )
669 : {
670 0 : OUString aToolbarResName( "private:resource/toolbar/" );
671 0 : OUStringBuffer aBuf( aToolbarResName );
672 0 : aBuf.append( pToolbarName->GetValue() );
673 :
674 : // Evaluate Parameter
675 0 : OUString aToolbarName( aBuf.makeStringAndClear() );
676 0 : sal_Bool bShow( !xLayoutManager->isElementVisible( aToolbarName ));
677 :
678 0 : if ( bShow )
679 : {
680 0 : xLayoutManager->createElement( aToolbarName );
681 0 : xLayoutManager->showElement( aToolbarName );
682 : }
683 : else
684 0 : xLayoutManager->hideElement( aToolbarName );
685 0 : }
686 : }
687 :
688 0 : bDone = true;
689 0 : break;
690 : }
691 :
692 : default:
693 0 : break;
694 : }
695 :
696 0 : if ( bDone )
697 0 : rReq.Done();
698 : }
699 :
700 : //--------------------------------------------------------------------
701 :
702 1556 : void SfxApplication::MiscState_Impl(SfxItemSet &rSet)
703 : {
704 1556 : const sal_uInt16 *pRanges = rSet.GetRanges();
705 : DBG_ASSERT(pRanges && *pRanges, "Set without range");
706 4676 : while ( *pRanges )
707 : {
708 3128 : for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
709 : {
710 1564 : switch(nWhich)
711 : {
712 : case SID_TEMPLATE_ADDRESSBOKSOURCE:
713 0 : if ( !SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE) )
714 0 : rSet.Put(SfxVisibilityItem(nWhich, sal_False));
715 0 : break;
716 : case SID_EXITANDRETURN:
717 : case SID_QUITAPP:
718 : {
719 0 : if ( pAppData_Impl->nDocModalMode )
720 0 : rSet.DisableItem(nWhich);
721 : else
722 0 : rSet.Put(SfxStringItem(nWhich, SfxResId(STR_QUITAPP).toString()));
723 0 : break;
724 : }
725 :
726 : case SID_CONFIG:
727 : case SID_TOOLBOXOPTIONS:
728 : case SID_CONFIGSTATUSBAR:
729 : case SID_CONFIGMENU:
730 : case SID_CONFIGACCEL:
731 : case SID_CONFIGEVENT:
732 : {
733 1 : if( SvtMiscOptions().DisableUICustomization() )
734 0 : rSet.DisableItem(nWhich);
735 1 : break;
736 : }
737 :
738 : #ifndef DISABLE_SCRIPTING
739 : case SID_BASICSTOP:
740 0 : if ( !StarBASIC::IsRunning() )
741 0 : rSet.DisableItem(nWhich);
742 0 : break;
743 : #endif
744 :
745 : case SID_HELPTIPS:
746 : {
747 0 : rSet.Put( SfxBoolItem( SID_HELPTIPS, Help::IsQuickHelpEnabled() ) );
748 : }
749 0 : break;
750 : case SID_HELPBALLOONS:
751 : {
752 0 : rSet.Put( SfxBoolItem( SID_HELPBALLOONS, Help::IsBalloonHelpEnabled() ) );
753 : }
754 0 : break;
755 :
756 : case SID_EXTENDEDHELP:
757 : {
758 : }
759 1532 : break;
760 :
761 : case SID_CLOSEDOCS:
762 : case SID_CLOSEWINS:
763 : {
764 0 : Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
765 0 : Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY );
766 0 : if ( !xTasks.is() || !xTasks->getCount() )
767 0 : rSet.DisableItem(nWhich);
768 0 : break;
769 : }
770 :
771 : case SID_SAVEDOCS:
772 : {
773 0 : sal_Bool bModified = sal_False;
774 0 : for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
775 : pObjSh;
776 : pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
777 : {
778 0 : if ( pObjSh->IsModified() )
779 : {
780 0 : bModified = sal_True;
781 0 : break;
782 : }
783 : }
784 :
785 0 : if ( !bModified )
786 0 : rSet.DisableItem( nWhich );
787 0 : break;
788 : }
789 :
790 : case SID_SHOW_IME_STATUS_WINDOW:
791 4 : if (pAppData_Impl->m_xImeStatusWindow->canToggle())
792 : rSet.Put(SfxBoolItem(
793 : SID_SHOW_IME_STATUS_WINDOW,
794 : pAppData_Impl->m_xImeStatusWindow->
795 0 : isShowing()));
796 : else
797 4 : rSet.DisableItem(SID_SHOW_IME_STATUS_WINDOW);
798 4 : break;
799 :
800 : case SID_TEMPLATE_MANAGER:
801 : {
802 0 : SvtMiscOptions aMiscOptions;
803 0 : if ( !aMiscOptions.IsExperimentalMode() )
804 : {
805 0 : rSet.DisableItem( nWhich );
806 0 : rSet.Put( SfxVisibilityItem( nWhich, sal_False ) );
807 0 : }
808 : }
809 0 : break;
810 :
811 : case SID_ZOOM_50_PERCENT:
812 : case SID_ZOOM_75_PERCENT:
813 : case SID_ZOOM_100_PERCENT:
814 : case SID_ZOOM_150_PERCENT:
815 : case SID_ZOOM_200_PERCENT:
816 : case SID_ZOOM_OPTIMAL:
817 : case SID_ZOOM_ENTIRE_PAGE:
818 : case SID_ZOOM_PAGE_WIDTH:
819 : {
820 : const SfxPoolItem *pItem;
821 26 : SfxItemState aState = SfxViewFrame::Current()->GetDispatcher()->QueryState(SID_ATTR_ZOOM, pItem);
822 26 : if ( aState == SFX_ITEM_DISABLED )
823 0 : rSet.DisableItem( nWhich );
824 : }
825 26 : break;
826 :
827 : default:
828 1 : break;
829 : }
830 : }
831 :
832 1564 : ++pRanges;
833 : }
834 1556 : }
835 :
836 : #ifndef DISABLE_SCRIPTING
837 :
838 : #ifndef DISABLE_DYNLOADING
839 :
840 : typedef rtl_uString* (SAL_CALL *basicide_choose_macro)(XModel*, sal_Bool, rtl_uString*);
841 : typedef void (SAL_CALL *basicide_macro_organizer)( sal_Int16 );
842 :
843 0 : extern "C" { static void SAL_CALL thisModule() {} }
844 :
845 : #else
846 :
847 : extern "C" rtl_uString* basicide_choose_macro(XModel*, sal_Bool, rtl_uString*);
848 : extern "C" void basicide_macro_organizer( sal_Int16 );
849 :
850 : #endif
851 :
852 0 : OUString ChooseMacro( const Reference< XModel >& rxLimitToDocument, sal_Bool bChooseOnly, const OUString& rMacroDesc = OUString() )
853 : {
854 : #ifndef DISABLE_DYNLOADING
855 : // get basctl dllname
856 0 : static OUString aLibName( SVLIBRARY( "basctl" ) );
857 :
858 : // load module
859 : oslModule handleMod = osl_loadModuleRelative(
860 0 : &thisModule, aLibName.pData, 0 );
861 :
862 : // get symbol
863 0 : OUString aSymbol( "basicide_choose_macro" );
864 0 : basicide_choose_macro pSymbol = (basicide_choose_macro) osl_getFunctionSymbol( handleMod, aSymbol.pData );
865 : #else
866 : #define pSymbol basicide_choose_macro
867 : #endif
868 :
869 : // call basicide_choose_macro in basctl
870 0 : rtl_uString* pScriptURL = pSymbol( rxLimitToDocument.get(), bChooseOnly, rMacroDesc.pData );
871 0 : OUString aScriptURL( pScriptURL );
872 0 : rtl_uString_release( pScriptURL );
873 0 : return aScriptURL;
874 :
875 : #ifdef DISABLE_DYNLOADING
876 : #undef pSymbol
877 : #endif
878 : }
879 :
880 0 : void MacroOrganizer( sal_Int16 nTabId )
881 : {
882 : #ifndef DISABLE_DYNLOADING
883 : // get basctl dllname
884 0 : static OUString aLibName( SVLIBRARY( "basctl" ) );
885 :
886 : // load module
887 : oslModule handleMod = osl_loadModuleRelative(
888 0 : &thisModule, aLibName.pData, 0 );
889 :
890 : // get symbol
891 0 : OUString aSymbol( "basicide_macro_organizer" );
892 0 : basicide_macro_organizer pSymbol = (basicide_macro_organizer) osl_getFunctionSymbol( handleMod, aSymbol.pData );
893 : // call basicide_macro_organizer in basctl
894 0 : pSymbol( nTabId );
895 : #else
896 : basicide_macro_organizer( nTabId );
897 : #endif
898 :
899 0 : }
900 :
901 : #endif
902 :
903 :
904 : #define RID_ERRBOX_MODULENOTINSTALLED (RID_OFA_START + 72)
905 :
906 4502 : ResMgr* SfxApplication::GetOffResManager_Impl()
907 : {
908 4502 : if ( !pAppData_Impl->pOfaResMgr )
909 133 : pAppData_Impl->pOfaResMgr = CreateResManager( "ofa");
910 4502 : return pAppData_Impl->pOfaResMgr;
911 : }
912 :
913 : namespace
914 : {
915 : #ifndef DISABLE_SCRIPTING
916 0 : Window* lcl_getDialogParent( const Reference< XFrame >& _rxFrame, Window* _pFallback )
917 : {
918 0 : if ( !_rxFrame.is() )
919 0 : return _pFallback;
920 :
921 : try
922 : {
923 0 : Reference< awt::XWindow > xContainerWindow( _rxFrame->getContainerWindow(), UNO_SET_THROW );
924 0 : Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
925 : OSL_ENSURE( pWindow, "lcl_getDialogParent: cool, somebody implemented a VCL-less toolkit!" );
926 :
927 0 : if ( pWindow )
928 0 : return pWindow->GetSystemWindow();
929 : }
930 0 : catch( const Exception& )
931 : {
932 : DBG_UNHANDLED_EXCEPTION();
933 : }
934 0 : return _pFallback;
935 : }
936 :
937 0 : const OUString& lcl_getBasicIDEServiceName()
938 : {
939 0 : static const OUString s_sBasicName( "com.sun.star.script.BasicIDE" );
940 0 : return s_sBasicName;
941 : }
942 :
943 0 : SfxViewFrame* lcl_getBasicIDEViewFrame( SfxObjectShell* i_pBasicIDE )
944 : {
945 0 : SfxViewFrame* pView = SfxViewFrame::GetFirst( i_pBasicIDE );
946 0 : while ( pView )
947 : {
948 0 : if ( pView->GetObjectShell()->GetFactory().GetDocumentServiceName() == lcl_getBasicIDEServiceName() )
949 0 : break;
950 0 : pView = SfxViewFrame::GetNext( *pView, i_pBasicIDE );
951 : }
952 0 : return pView;
953 : }
954 0 : Reference< XFrame > lcl_findStartModuleFrame( const Reference<XComponentContext> & rxContext )
955 : {
956 : try
957 : {
958 0 : Reference < XDesktop2 > xDesktop = Desktop::create( rxContext );
959 0 : Reference < XIndexAccess > xContainer( xDesktop->getFrames(), UNO_QUERY_THROW );
960 :
961 0 : Reference< XModuleManager2 > xCheck = ModuleManager::create(rxContext);
962 :
963 0 : sal_Int32 nCount = xContainer->getCount();
964 0 : for ( sal_Int32 i=0; i<nCount; ++i )
965 : {
966 : try
967 : {
968 0 : Reference < XFrame > xFrame( xContainer->getByIndex(i), UNO_QUERY_THROW );
969 0 : OUString sModule = xCheck->identify( xFrame );
970 0 : if ( sModule == "com.sun.star.frame.StartModule" )
971 0 : return xFrame;
972 : }
973 0 : catch( const UnknownModuleException& )
974 : {
975 : // silence
976 : }
977 0 : catch(const Exception&)
978 : {
979 : // re-throw, caught below
980 0 : throw;
981 : }
982 0 : }
983 : }
984 0 : catch( const Exception& )
985 : {
986 : DBG_UNHANDLED_EXCEPTION();
987 : }
988 0 : return NULL;
989 : }
990 : #endif // !DISABLE_SCRIPTING
991 : }
992 :
993 0 : static OUString getConfigurationStringValue(
994 : const OUString& rPackage,
995 : const OUString& rRelPath,
996 : const OUString& rKey,
997 : const OUString& rDefaultValue )
998 : {
999 0 : OUString aDefVal( rDefaultValue );
1000 :
1001 : try
1002 : {
1003 : ::comphelper::ConfigurationHelper::readDirectKey(
1004 : comphelper::getProcessComponentContext(),
1005 : rPackage,
1006 : rRelPath,
1007 : rKey,
1008 0 : ::comphelper::ConfigurationHelper::E_READONLY) >>= aDefVal;
1009 : }
1010 0 : catch(const com::sun::star::uno::RuntimeException&)
1011 0 : { throw; }
1012 0 : catch(const com::sun::star::uno::Exception&)
1013 : {}
1014 :
1015 0 : return aDefVal;
1016 : }
1017 :
1018 0 : void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
1019 : {
1020 0 : switch ( rReq.GetSlot() )
1021 : {
1022 : case SID_OPTIONS_TREEDIALOG:
1023 : {
1024 0 : String sPageURL;
1025 0 : SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, SID_OPTIONS_PAGEURL, sal_False );
1026 0 : if ( pURLItem )
1027 0 : sPageURL = pURLItem->GetValue();
1028 0 : const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl();
1029 0 : const SfxPoolItem* pItem = NULL;
1030 0 : Reference < XFrame > xFrame;
1031 0 : if ( pArgs && pArgs->GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET )
1032 : {
1033 : OSL_ENSURE( pItem->ISA( SfxUnoFrameItem ), "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" );
1034 0 : xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame();
1035 : }
1036 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1037 0 : if ( pFact )
1038 : {
1039 : VclAbstractDialog* pDlg =
1040 0 : pFact->CreateFrameDialog( NULL, xFrame, rReq.GetSlot(), sPageURL );
1041 0 : short nRet = pDlg->Execute();
1042 0 : delete pDlg;
1043 0 : SfxViewFrame* pView = SfxViewFrame::GetFirst();
1044 0 : while ( pView )
1045 : {
1046 0 : if (nRet == RET_OK)
1047 : {
1048 0 : SfxObjectShell* pObjSh = pView->GetObjectShell();
1049 0 : if (pObjSh)
1050 0 : pObjSh->SetConfigOptionsChecked(false);
1051 : }
1052 0 : pView->GetBindings().InvalidateAll(sal_False);
1053 0 : pView = SfxViewFrame::GetNext( *pView );
1054 : }
1055 : }
1056 0 : break;
1057 : }
1058 :
1059 : case SID_MORE_DICTIONARIES:
1060 : {
1061 : try
1062 : {
1063 : uno::Reference< uno::XComponentContext > xContext =
1064 0 : ::comphelper::getProcessComponentContext();
1065 : uno::Reference< css::system::XSystemShellExecute > xSystemShell(
1066 0 : css::system::SystemShellExecute::create(xContext) );
1067 :
1068 : // read repository URL from configuration
1069 : OUString sTemplRepoURL =
1070 : getConfigurationStringValue(
1071 : OUString("org.openoffice.Office.Common"),
1072 : OUString("Dictionaries"),
1073 : OUString("RepositoryURL"),
1074 0 : OUString());
1075 :
1076 0 : if ( xSystemShell.is() && !sTemplRepoURL.isEmpty() )
1077 : {
1078 0 : OUStringBuffer aURLBuf( sTemplRepoURL );
1079 0 : aURLBuf.appendAscii(RTL_CONSTASCII_STRINGPARAM("?lang="));
1080 :
1081 : // read locale from configuration
1082 : OUString sLocale = getConfigurationStringValue(
1083 : OUString("org.openoffice.Setup"),
1084 : OUString("L10N"),
1085 : OUString("ooLocale"),
1086 0 : OUString("en-US"));
1087 :
1088 0 : aURLBuf.append( sLocale );
1089 0 : xSystemShell->execute(
1090 : aURLBuf.makeStringAndClear(),
1091 : OUString(),
1092 0 : css::system::SystemShellExecuteFlags::URIS_ONLY );
1093 0 : }
1094 : }
1095 0 : catch( const ::com::sun::star::uno::Exception& )
1096 : {
1097 : SAL_WARN( "sfx2.appl", "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES): caught an exception!" );
1098 : }
1099 0 : break;
1100 : }
1101 : #ifndef DISABLE_SCRIPTING
1102 : case SID_BASICIDE_APPEAR:
1103 : {
1104 0 : SfxViewFrame* pView = lcl_getBasicIDEViewFrame( NULL );
1105 0 : if ( !pView )
1106 : {
1107 0 : SfxObjectShell* pBasicIDE = SfxObjectShell::CreateObject( lcl_getBasicIDEServiceName() );
1108 0 : pBasicIDE->DoInitNew( 0 );
1109 0 : pBasicIDE->SetModified( sal_False );
1110 : try
1111 : {
1112 : // load the Basic IDE via direct access to the SFX frame loader. A generic loadComponentFromURL
1113 : // (which could be done via SfxViewFrame::LoadDocumentIntoFrame) is not feasible here, since the Basic IDE
1114 : // does not really play nice with the framework's concept. For instance, it is a "singleton document",
1115 : // which conflicts, at the latest, with the framework's concept of loading into _blank frames.
1116 : // So, since we know that our frame loader can handle it, we skip the generic framework loader
1117 : // mechanism, and the type detection (which doesn't know about the Basic IDE).
1118 0 : Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
1119 : Reference< XSynchronousFrameLoader > xLoader(
1120 0 : xContext->getServiceManager()->createInstanceWithContext(SfxFrameLoader_Impl::impl_getStaticImplementationName(), xContext),
1121 0 : UNO_QUERY_THROW );
1122 0 : ::comphelper::NamedValueCollection aLoadArgs;
1123 0 : aLoadArgs.put( "Model", pBasicIDE->GetModel() );
1124 0 : aLoadArgs.put( "URL", OUString( "private:factory/sbasic" ) );
1125 :
1126 0 : Reference< XFrame > xTargetFrame( lcl_findStartModuleFrame( xContext ) );
1127 0 : if ( !xTargetFrame.is() )
1128 0 : xTargetFrame = SfxFrame::CreateBlankFrame();
1129 0 : ENSURE_OR_THROW( xTargetFrame.is(), "could not obtain a frameto load the Basic IDE into!" );
1130 :
1131 0 : xLoader->load( aLoadArgs.getPropertyValues(), xTargetFrame );
1132 : }
1133 0 : catch( const Exception& )
1134 : {
1135 : DBG_UNHANDLED_EXCEPTION();
1136 : }
1137 :
1138 0 : pView = lcl_getBasicIDEViewFrame( pBasicIDE );
1139 0 : if ( pView )
1140 0 : pView->SetName( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC:1" ) ) );
1141 : }
1142 :
1143 0 : if ( pView )
1144 0 : pView->GetFrame().Appear();
1145 :
1146 0 : const SfxItemSet* pArgs = rReq.GetArgs();
1147 0 : if ( pArgs && pView )
1148 : {
1149 0 : SfxViewShell* pViewShell = pView->GetViewShell();
1150 0 : SfxObjectShell* pObjShell = pView->GetObjectShell();
1151 0 : if ( pViewShell && pObjShell )
1152 : {
1153 0 : SfxRequest aReq( SID_BASICIDE_SHOWWINDOW, SFX_CALLMODE_SYNCHRON, pObjShell->GetPool() );
1154 0 : aReq.SetArgs( *pArgs );
1155 0 : pViewShell->ExecuteSlot( aReq );
1156 : }
1157 : }
1158 :
1159 0 : rReq.Done();
1160 : }
1161 0 : break;
1162 :
1163 : case SID_BASICCHOOSER:
1164 : {
1165 0 : const SfxItemSet* pArgs = rReq.GetArgs();
1166 : const SfxPoolItem* pItem;
1167 0 : sal_Bool bChooseOnly = sal_False;
1168 0 : Reference< XModel > xLimitToModel;
1169 0 : if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_RECORDMACRO, sal_False, &pItem) )
1170 : {
1171 0 : sal_Bool bRecord = ((SfxBoolItem*)pItem)->GetValue();
1172 0 : if ( bRecord )
1173 : {
1174 : // !Hack
1175 0 : bChooseOnly = sal_False;
1176 0 : SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
1177 : OSL_ENSURE( pCurrentShell, "macro recording outside an SFX document?" );
1178 0 : if ( pCurrentShell )
1179 0 : xLimitToModel = pCurrentShell->GetModel();
1180 : }
1181 : }
1182 :
1183 0 : rReq.SetReturnValue( SfxStringItem( rReq.GetSlot(), ChooseMacro( xLimitToModel, bChooseOnly ) ) );
1184 0 : rReq.Done();
1185 : }
1186 0 : break;
1187 :
1188 : case SID_MACROORGANIZER:
1189 : {
1190 : OSL_TRACE("handling SID_MACROORGANIZER");
1191 0 : const SfxItemSet* pArgs = rReq.GetArgs();
1192 : const SfxPoolItem* pItem;
1193 0 : sal_Int16 nTabId = 0;
1194 0 : if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_MACROORGANIZER, sal_False, &pItem) )
1195 : {
1196 0 : nTabId = ((SfxUInt16Item*)pItem)->GetValue();
1197 : }
1198 :
1199 0 : SfxApplication::MacroOrganizer( nTabId );
1200 0 : rReq.Done();
1201 : }
1202 0 : break;
1203 :
1204 : case SID_RUNMACRO:
1205 : {
1206 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1207 : OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg");
1208 :
1209 0 : Reference< XFrame > xFrame;
1210 0 : const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
1211 0 : SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
1212 0 : if ( pFrameItem )
1213 0 : xFrame = pFrameItem->GetFrame();
1214 :
1215 0 : if ( !xFrame.is() )
1216 : {
1217 0 : const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1218 0 : if ( pViewFrame )
1219 0 : xFrame = pViewFrame->GetFrame().GetFrameInterface();
1220 : }
1221 :
1222 : do // artificial loop for flow control
1223 : {
1224 : AbstractScriptSelectorDialog* pDlg = pFact->CreateScriptSelectorDialog(
1225 0 : lcl_getDialogParent( xFrame, GetTopWindow() ), sal_False, xFrame );
1226 : OSL_ENSURE( pDlg, "SfxApplication::OfaExec_Impl( SID_RUNMACRO ): no dialog!" );
1227 0 : if ( !pDlg )
1228 0 : break;
1229 0 : pDlg->SetRunLabel();
1230 :
1231 0 : short nDialogResult = pDlg->Execute();
1232 0 : if ( !nDialogResult )
1233 : {
1234 0 : delete pDlg;
1235 0 : break;
1236 : }
1237 :
1238 0 : Sequence< Any > args;
1239 0 : Sequence< sal_Int16 > outIndex;
1240 0 : Sequence< Any > outArgs;
1241 0 : Any ret;
1242 :
1243 0 : Reference< XInterface > xScriptContext;
1244 :
1245 0 : Reference< XController > xController;
1246 0 : if ( xFrame.is() )
1247 0 : xController = xFrame->getController();
1248 0 : if ( xController.is() )
1249 0 : xScriptContext = xController->getModel();
1250 0 : if ( !xScriptContext.is() )
1251 0 : xScriptContext = xController;
1252 :
1253 0 : SfxObjectShell::CallXScript( xScriptContext, pDlg->GetScriptURL(), args, ret, outIndex, outArgs );
1254 0 : delete pDlg;
1255 : }
1256 : while ( false );
1257 0 : rReq.Done();
1258 : }
1259 0 : break;
1260 :
1261 : case SID_SCRIPTORGANIZER:
1262 : {
1263 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1264 : OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg");
1265 0 : const SfxItemSet* pArgs = rReq.GetArgs();
1266 : const SfxPoolItem* pItem;
1267 0 : String aLanguage;
1268 0 : if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_SCRIPTORGANIZER, sal_False, &pItem) )
1269 : {
1270 0 : aLanguage = ((SfxScriptOrganizerItem*)pItem)->getLanguage();
1271 : }
1272 :
1273 0 : OUString aLang( aLanguage );
1274 : OSL_TRACE("SfxApplication::OfaExec_Impl: about to create dialog for: %s", OUStringToOString( aLang , RTL_TEXTENCODING_ASCII_US ).pData->buffer);
1275 : // not sure about the Window*
1276 0 : VclAbstractDialog* pDlg = pFact->CreateSvxScriptOrgDialog( GetTopWindow(), aLanguage );
1277 0 : if( pDlg )
1278 : {
1279 0 : pDlg->Execute();
1280 0 : delete pDlg;
1281 : }
1282 : else
1283 : {
1284 : OSL_TRACE("no dialog!!!");
1285 : }
1286 0 : rReq.Done();
1287 : }
1288 0 : break;
1289 : #endif // !DISABLE_SCRIPTING
1290 :
1291 : case SID_OFFICE_CHECK_PLZ:
1292 : {
1293 0 : sal_Bool bRet = sal_False;
1294 0 : SFX_REQUEST_ARG(rReq, pStringItem, SfxStringItem, rReq.GetSlot(), sal_False);
1295 :
1296 0 : if ( pStringItem )
1297 : {
1298 0 : bRet = sal_True /*!!!SfxIniManager::CheckPLZ( aPLZ )*/;
1299 : }
1300 : #ifndef DISABLE_SCRIPTING
1301 : else
1302 0 : SbxBase::SetError( SbxERR_WRONG_ARGS );
1303 : #endif
1304 0 : rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bRet ) );
1305 : }
1306 0 : break;
1307 :
1308 : case SID_AUTO_CORRECT_DLG:
1309 : {
1310 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1311 0 : if ( pFact )
1312 : {
1313 0 : SfxItemSet aSet(GetPool(), SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG);
1314 0 : const SfxPoolItem* pItem=NULL;
1315 0 : const SfxItemSet* pSet = rReq.GetArgs();
1316 0 : SfxItemPool* pSetPool = pSet ? pSet->GetPool() : NULL;
1317 0 : if ( pSet && pSet->GetItemState( pSetPool->GetWhich( SID_AUTO_CORRECT_DLG ), sal_False, &pItem ) == SFX_ITEM_SET )
1318 0 : aSet.Put( *pItem );
1319 :
1320 0 : SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( RID_OFA_AUTOCORR_DLG, NULL, &aSet, NULL );
1321 0 : pDlg->Execute();
1322 0 : delete pDlg;
1323 : }
1324 :
1325 0 : break;
1326 : }
1327 :
1328 : case SID_SD_AUTOPILOT :
1329 : case SID_NEWSD :
1330 : {
1331 0 : SvtModuleOptions aModuleOpt;
1332 0 : if ( !aModuleOpt.IsImpress() )
1333 : {
1334 0 : ErrorBox( 0, ResId( RID_ERRBOX_MODULENOTINSTALLED, *GetOffResManager_Impl() )).Execute();
1335 0 : return;
1336 : }
1337 :
1338 0 : Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
1339 0 : Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext );
1340 :
1341 0 : OUString aCmd = OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
1342 0 : Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
1343 0 : Sequence < beans::PropertyValue > aSeq;
1344 0 : if ( rReq.GetArgs() )
1345 0 : TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
1346 0 : Any aResult = xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aSeq );
1347 0 : frame::DispatchResultEvent aEvent;
1348 0 : sal_Bool bSuccess = (aResult >>= aEvent) &&
1349 0 : (aEvent.State == frame::DispatchResultState::SUCCESS);
1350 0 : rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
1351 : }
1352 0 : break;
1353 :
1354 : case FN_LABEL :
1355 : case FN_BUSINESS_CARD :
1356 : case FN_XFORMS_INIT :
1357 : {
1358 0 : Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
1359 0 : Reference< frame::XDispatchProvider > xProv = text::ModuleDispatcher::create( xContext );
1360 :
1361 0 : OUString aCmd = OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
1362 0 : Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
1363 0 : Sequence < beans::PropertyValue > aSeq;
1364 0 : if ( rReq.GetArgs() )
1365 0 : TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
1366 0 : Any aResult = xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aSeq );
1367 0 : frame::DispatchResultEvent aEvent;
1368 0 : sal_Bool bSuccess = (aResult >>= aEvent) &&
1369 0 : (aEvent.State == frame::DispatchResultState::SUCCESS);
1370 0 : rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
1371 : }
1372 0 : break;
1373 :
1374 : case SID_ADDRESS_DATA_SOURCE:
1375 : {
1376 : try
1377 : {
1378 0 : Reference< uno::XComponentContext > xORB = ::comphelper::getProcessComponentContext();
1379 0 : Reference< ui::dialogs::XExecutableDialog > xDialog;
1380 0 : xDialog = ui::dialogs::AddressBookSourcePilot::createWithParent(xORB, 0);
1381 0 : xDialog->execute();
1382 : }
1383 0 : catch(const ::com::sun::star::uno::Exception&)
1384 : {
1385 : DBG_UNHANDLED_EXCEPTION();
1386 : }
1387 : }
1388 0 : break;
1389 :
1390 : case SID_COMP_BIBLIOGRAPHY:
1391 0 : lcl_tryLoadBibliography();
1392 0 : break;
1393 : }
1394 : }
1395 :
1396 0 : void SfxApplication::OfaState_Impl(SfxItemSet &rSet)
1397 : {
1398 0 : SvtModuleOptions aModuleOpt;
1399 :
1400 0 : if( !aModuleOpt.IsWriter())
1401 : {
1402 0 : rSet.DisableItem( FN_LABEL );
1403 0 : rSet.DisableItem( FN_BUSINESS_CARD );
1404 0 : rSet.DisableItem( FN_XFORMS_INIT );
1405 : }
1406 :
1407 0 : if ( !aModuleOpt.IsImpress() )
1408 0 : rSet.DisableItem( SID_SD_AUTOPILOT );
1409 408 : }
1410 :
1411 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|