1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 * OpenOffice.org - a multi-platform office productivity suite
8 * This file is part of OpenOffice.org.
10 * OpenOffice.org is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License version 3
12 * only, as published by the Free Software Foundation.
14 * OpenOffice.org is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License version 3 for more details
18 * (a copy is included in the LICENSE file that accompanied this code).
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with OpenOffice.org. If not, see
22 * <http://www.openoffice.org/license.html>
23 * for a copy of the LGPLv3 License.
25 ************************************************************************/
27 // MARKER(update_precomp.py): autogen include statement, do not remove
28 #include "precompiled_extensions.hxx"
30 #include <com/sun/star/oooimprovement/XCore.hpp>
32 #include "oooimprovecore_module.hxx"
33 #include <com/sun/star/frame/XTerminateListener.hpp>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/oooimprovement/XCoreController.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
38 #include <comphelper/componentmodule.hxx>
39 #include <comphelper/configurationhelper.hxx>
40 #include <comphelper/processfactory.hxx>
41 #include <comphelper/uieventslogger.hxx>
42 #include <cppuhelper/implbase3.hxx>
43 #include <svx/svxdlg.hxx>
44 #include <vcl/svapp.hxx>
45 #include <vos/mutex.hxx>
46 #include <svl/itemset.hxx>
47 #include <svl/stritem.hxx>
48 #include <sfx2/app.hxx>
49 #include <svx/dialogs.hrc>
50 #include <sfx2/sfxsids.hrc>
52 using namespace ::com::sun::star::oooimprovement
;
53 using ::com::sun::star::frame::XTerminateListener
;
54 using ::com::sun::star::lang::EventObject
;
55 using ::com::sun::star::lang::XMultiServiceFactory
;
56 using ::com::sun::star::lang::XServiceInfo
;
57 using ::com::sun::star::uno::Reference
;
58 using ::com::sun::star::uno::RuntimeException
;
59 using ::com::sun::star::uno::Sequence
;
60 using ::com::sun::star::uno::UNO_QUERY
;
61 using ::com::sun::star::uno::XComponentContext
;
62 using ::com::sun::star::uno::XInterface
;
63 using ::comphelper::UiEventsLogger
;
64 using ::rtl::OUString
;
67 namespace oooimprovecore
69 class Core
: public ::cppu::WeakImplHelper3
<XCore
,XServiceInfo
,XTerminateListener
>
72 // XServiceInfo - static version
73 static OUString SAL_CALL
getImplementationName_static();
74 static Sequence
<OUString
> SAL_CALL
getSupportedServiceNames_static();
75 static Reference
<XInterface
> Create(const Reference
<XComponentContext
>& context
);
78 Core(const Reference
<XComponentContext
>&);
82 virtual sal_Int32 SAL_CALL
getSessionLogEventCount() throw(RuntimeException
);
83 virtual sal_Bool SAL_CALL
getUiEventsLoggerEnabled() throw(RuntimeException
);
84 virtual void SAL_CALL
inviteUser() throw(RuntimeException
);
87 virtual OUString SAL_CALL
getImplementationName() throw(RuntimeException
);
88 virtual sal_Bool SAL_CALL
supportsService(const OUString
& service_name
) throw(RuntimeException
);
89 virtual Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() throw(RuntimeException
);
92 virtual void SAL_CALL
queryTermination(const EventObject
&) throw(RuntimeException
);
93 virtual void SAL_CALL
notifyTermination(const EventObject
&) throw(RuntimeException
);
96 virtual void SAL_CALL
disposing(const EventObject
&) throw(RuntimeException
);
102 namespace oooimprovecore
105 Core::Core(const Reference
<XComponentContext
>&)
111 sal_Int32 SAL_CALL
Core::getSessionLogEventCount() throw(RuntimeException
)
112 { return UiEventsLogger::getSessionLogEventCount(); }
114 sal_Bool SAL_CALL
Core::getUiEventsLoggerEnabled() throw(RuntimeException
)
115 { return UiEventsLogger::isEnabled(); }
117 void SAL_CALL
Core::inviteUser() throw(RuntimeException
)
119 Reference
<XMultiServiceFactory
> xServiceFactory
= ::comphelper::getProcessServiceFactory();
122 Reference
<XCoreController
> core_c(
123 xServiceFactory
->createInstance(OUString::createFromAscii("com.sun.star.oooimprovement.CoreController")),
126 ::comphelper::ConfigurationHelper::readDirectKey(
128 OUString::createFromAscii("/org.openoffice.Office.OOoImprovement.Settings"),
129 OUString::createFromAscii("Participation"),
130 OUString::createFromAscii("HelpUrl"),
131 ::comphelper::ConfigurationHelper::E_READONLY
) >>= help_url
;
133 help_url
= OUString::createFromAscii("http://www.openoffice.org");
135 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
136 SfxAllItemSet
aSet( SFX_APP()->GetPool() );
137 aSet
.Put( SfxStringItem( SID_CURRENT_URL
, help_url
) );
138 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
141 SfxAbstractDialog
*pDlg
= pFact
->CreateSfxDialog( NULL
, aSet
, 0, RID_SVXPAGE_IMPROVEMENT
);
148 sal_Bool SAL_CALL
Core::supportsService(const OUString
& service_name
) throw(RuntimeException
)
150 const Sequence
<OUString
> service_names(getSupportedServiceNames());
151 for (sal_Int32 idx
= service_names
.getLength()-1; idx
>=0; --idx
)
152 if(service_name
== service_names
[idx
]) return sal_True
;
156 OUString SAL_CALL
Core::getImplementationName() throw(RuntimeException
)
157 { return getImplementationName_static(); }
159 Sequence
<OUString
> SAL_CALL
Core::getSupportedServiceNames() throw(RuntimeException
)
160 { return getSupportedServiceNames_static(); }
162 OUString SAL_CALL
Core::getImplementationName_static()
163 { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovecore.Core"); }
165 Sequence
<OUString
> SAL_CALL
Core::getSupportedServiceNames_static()
167 Sequence
<OUString
> aServiceNames(1);
168 aServiceNames
[0] = OUString::createFromAscii("com.sun.star.oooimprovement.Core");
169 return aServiceNames
;
172 void Core::queryTermination(const EventObject
&) throw(RuntimeException
)
175 void Core::notifyTermination(const EventObject
&) throw(RuntimeException
)
177 UiEventsLogger::disposing();
180 void Core::disposing(const EventObject
&) throw(RuntimeException
)
183 Reference
<XInterface
> Core::Create(const Reference
<XComponentContext
>& context
)
184 { return *(new Core(context
)); }
186 void createRegistryInfo_Core()
188 static OAutoRegistration
<Core
> auto_reg
;