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