merge the formfield patch from ooo-build
[ooovba.git] / extensions / source / oooimprovecore / core.cxx
blob2d6fc581f3a692fa732494a9a9eff099d8852112
1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * Copyright 2008 by Sun Microsystems, Inc.
6 * OpenOffice.org - a multi-platform office productivity suite
8 * $RCSfile: core.cxx,v $
10 * $Revision: 1.3.34.1 $
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.
28 ************************************************************************/
30 // MARKER(update_precomp.py): autogen include statement, do not remove
31 #include "precompiled_extensions.hxx"
33 #include <com/sun/star/oooimprovement/XCore.hpp>
35 #include "oooimprovecore_module.hxx"
36 #include <com/sun/star/frame/XTerminateListener.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/oooimprovement/XCoreController.hpp>
40 #include <com/sun/star/uno/XComponentContext.hpp>
41 #include <comphelper/componentmodule.hxx>
42 #include <comphelper/configurationhelper.hxx>
43 #include <comphelper/processfactory.hxx>
44 #include <comphelper/uieventslogger.hxx>
45 #include <cppuhelper/implbase3.hxx>
46 #include <svx/svxdlg.hxx>
47 #include <vcl/svapp.hxx>
48 #include <vos/mutex.hxx>
49 #include <svtools/itemset.hxx>
50 #include <svtools/stritem.hxx>
51 #include <sfx2/app.hxx>
52 #include <svx/dialogs.hrc>
53 #include <sfx2/sfxsids.hrc>
55 using namespace ::com::sun::star::oooimprovement;
56 using ::com::sun::star::frame::XTerminateListener;
57 using ::com::sun::star::lang::EventObject;
58 using ::com::sun::star::lang::XMultiServiceFactory;
59 using ::com::sun::star::lang::XServiceInfo;
60 using ::com::sun::star::uno::Reference;
61 using ::com::sun::star::uno::RuntimeException;
62 using ::com::sun::star::uno::Sequence;
63 using ::com::sun::star::uno::UNO_QUERY;
64 using ::com::sun::star::uno::XComponentContext;
65 using ::com::sun::star::uno::XInterface;
66 using ::comphelper::UiEventsLogger;
67 using ::rtl::OUString;
69 // declaration
70 namespace oooimprovecore
72 class Core : public ::cppu::WeakImplHelper3<XCore,XServiceInfo,XTerminateListener>
74 public:
75 // XServiceInfo - static version
76 static OUString SAL_CALL getImplementationName_static();
77 static Sequence<OUString> SAL_CALL getSupportedServiceNames_static();
78 static Reference<XInterface> Create(const Reference<XComponentContext>& context );
80 protected:
81 Core(const Reference<XComponentContext>&);
82 virtual ~Core();
84 // XCore
85 virtual sal_Int32 SAL_CALL getSessionLogEventCount() throw(RuntimeException);
86 virtual sal_Bool SAL_CALL getUiEventsLoggerEnabled() throw(RuntimeException);
87 virtual void SAL_CALL inviteUser() throw(RuntimeException);
89 // XServiceInfo
90 virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
91 virtual sal_Bool SAL_CALL supportsService(const OUString& service_name) throw(RuntimeException);
92 virtual Sequence<OUString> SAL_CALL getSupportedServiceNames() throw(RuntimeException);
94 // XTerminateListener
95 virtual void SAL_CALL queryTermination(const EventObject&) throw(RuntimeException);
96 virtual void SAL_CALL notifyTermination(const EventObject&) throw(RuntimeException);
98 // XEventListener
99 virtual void SAL_CALL disposing(const EventObject&) throw(RuntimeException);
104 // implementation
105 namespace oooimprovecore
108 Core::Core(const Reference<XComponentContext>&)
111 Core::~Core()
114 sal_Int32 SAL_CALL Core::getSessionLogEventCount() throw(RuntimeException)
115 { return UiEventsLogger::getSessionLogEventCount(); }
117 sal_Bool SAL_CALL Core::getUiEventsLoggerEnabled() throw(RuntimeException)
118 { return UiEventsLogger::isEnabled(); }
120 void SAL_CALL Core::inviteUser() throw(RuntimeException)
122 Reference<XMultiServiceFactory> xServiceFactory = ::comphelper::getProcessServiceFactory();
124 OUString help_url;
125 Reference<XCoreController> core_c(
126 xServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.oooimprovement.CoreController")),
127 UNO_QUERY);
128 if(core_c.is())
129 ::comphelper::ConfigurationHelper::readDirectKey(
130 xServiceFactory,
131 OUString::createFromAscii("/org.openoffice.Office.OOoImprovement.Settings"),
132 OUString::createFromAscii("Participation"),
133 OUString::createFromAscii("HelpUrl"),
134 ::comphelper::ConfigurationHelper::E_READONLY) >>= help_url;
135 else
136 help_url = OUString::createFromAscii("http://www.openoffice.org");
138 ::vos::OGuard aGuard( Application::GetSolarMutex() );
139 SfxAllItemSet aSet( SFX_APP()->GetPool() );
140 aSet.Put( SfxStringItem( SID_CURRENT_URL, help_url ) );
141 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
142 if ( pFact )
144 SfxAbstractDialog *pDlg = pFact->CreateSfxDialog( NULL, aSet, 0, RID_SVXPAGE_IMPROVEMENT );
145 pDlg->Execute();
146 delete pDlg;
151 sal_Bool SAL_CALL Core::supportsService(const OUString& service_name) throw(RuntimeException)
153 const Sequence<OUString> service_names(getSupportedServiceNames());
154 for (sal_Int32 idx = service_names.getLength()-1; idx>=0; --idx)
155 if(service_name == service_names[idx]) return sal_True;
156 return sal_False;
159 OUString SAL_CALL Core::getImplementationName() throw(RuntimeException)
160 { return getImplementationName_static(); }
162 Sequence<OUString> SAL_CALL Core::getSupportedServiceNames() throw(RuntimeException)
163 { return getSupportedServiceNames_static(); }
165 OUString SAL_CALL Core::getImplementationName_static()
166 { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovecore.Core"); }
168 Sequence<OUString> SAL_CALL Core::getSupportedServiceNames_static()
170 Sequence<OUString> aServiceNames(1);
171 aServiceNames[0] = OUString::createFromAscii("com.sun.star.oooimprovement.Core");
172 return aServiceNames;
175 void Core::queryTermination(const EventObject&) throw(RuntimeException)
178 void Core::notifyTermination(const EventObject&) throw(RuntimeException)
180 UiEventsLogger::disposing();
183 void Core::disposing(const EventObject&) throw(RuntimeException)
186 Reference<XInterface> Core::Create(const Reference<XComponentContext>& context)
187 { return *(new Core(context)); }
189 void createRegistryInfo_Core()
191 static OAutoRegistration<Core> auto_reg;