1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: appdata.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
33 #include <tools/cachestr.hxx>
34 #include <tools/config.hxx>
35 #ifndef _INETSTRM_HXX //autogen
36 #include <svtools/inetstrm.hxx>
38 #include <svtools/stritem.hxx>
40 #define _SVSTDARR_STRINGS
41 #include <svtools/svstdarr.hxx>
42 #include <vos/mutex.hxx>
44 #include <vcl/menu.hxx>
45 #include <vcl/msgbox.hxx>
46 #include <svtools/dateitem.hxx>
47 #include <vcl/menu.hxx>
48 #include <vcl/wrkwin.hxx>
49 #include "comphelper/processfactory.hxx"
51 #include <sfx2/viewfrm.hxx>
52 #include "appdata.hxx"
53 #include <sfx2/dispatch.hxx>
54 #include <sfx2/event.hxx>
55 #include "sfxtypes.hxx"
56 #include <sfx2/doctempl.hxx>
57 #include "arrdecl.hxx"
58 #include <sfx2/docfac.hxx>
59 #include <sfx2/docfile.hxx>
60 #include <sfx2/request.hxx>
61 #include "referers.hxx"
63 #include "sfxresid.hxx"
64 #include "objshimp.hxx"
65 #include <sfx2/appuno.hxx>
66 #include "imestatuswindow.hxx"
67 #include "appbaslib.hxx"
69 #include <basic/basicmanagerrepository.hxx>
70 #include <basic/basmgr.hxx>
72 using ::basic::BasicManagerRepository
;
73 using ::basic::BasicManagerCreationListener
;
74 using ::com::sun::star::uno::Reference
;
75 using ::com::sun::star::frame::XModel
;
76 using ::com::sun::star::uno::XInterface
;
78 class SfxBasicManagerCreationListener
: public ::basic::BasicManagerCreationListener
81 SfxAppData_Impl
& m_rAppData
;
84 SfxBasicManagerCreationListener( SfxAppData_Impl
& _rAppData
) :m_rAppData( _rAppData
) { }
86 virtual void onBasicManagerCreated( const Reference
< XModel
>& _rxForDocument
, BasicManager
& _rBasicManager
);
89 void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference
< XModel
>& _rxForDocument
, BasicManager
& _rBasicManager
)
91 if ( _rxForDocument
== NULL
)
92 m_rAppData
.OnApplicationBasicManagerCreated( _rBasicManager
);
95 SfxAppData_Impl::SfxAppData_Impl( SfxApplication
* pApp
) :
101 pTopFrames( new SfxFrameArr_Impl
),
110 pDisabledSlotList( 0 ),
117 pTemplateCommon( 0 ),
124 m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(
125 *pApp
, comphelper::getProcessServiceFactory()))
132 , pSimpleResManager(0)
133 , pBasicManager( new SfxBasicManagerHolder
)
134 , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
142 , bDowning( sal_True
)
143 , bInQuit( sal_False
)
144 , bInvalidateOnUnlock( sal_False
)
145 , bODFVersionWarningLater( sal_False
)
148 BasicManagerRepository::registerCreationListener( *pBasMgrListener
);
151 SfxAppData_Impl::~SfxAppData_Impl()
157 delete pBasicManager
;
159 BasicManagerRepository::revokeCreationListener( *pBasMgrListener
);
160 delete pBasMgrListener
;
163 void SfxAppData_Impl::UpdateApplicationSettings( sal_Bool bDontHide
)
165 AllSettings aAllSet
= Application::GetSettings();
166 StyleSettings aStyleSet
= aAllSet
.GetStyleSettings();
167 sal_uInt32 nStyleOptions
= aStyleSet
.GetOptions();
169 nStyleOptions
&= ~STYLE_OPTION_HIDEDISABLED
;
171 nStyleOptions
|= STYLE_OPTION_HIDEDISABLED
;
172 aStyleSet
.SetOptions( nStyleOptions
);
173 aAllSet
.SetStyleSettings( aStyleSet
);
174 Application::SetSettings( aAllSet
);
177 SfxDocumentTemplates
* SfxAppData_Impl::GetDocumentTemplates()
180 pTemplates
= new SfxDocumentTemplates
;
182 pTemplates
->ReInitFromComponent();
186 void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager
& _rBasicManager
)
188 pBasicManager
->reset( &_rBasicManager
);
190 // global constants, additionally to the ones already added by createApplicationBasicManager:
192 Reference
< XInterface
> xCurrentComponent
= SfxObjectShell::GetCurrentComponent();
193 _rBasicManager
.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent
) );