1 /*************************************************************************
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3  *
4  * Copyright 2000, 2010 Oracle and/or its affiliates.
5  *
6  * OpenOffice.org - a multi-platform office productivity suite
7  *
8  * This file is part of OpenOffice.org.
9  *
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.
13  *
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).
19  *
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.
24  *
25  ************************************************************************/
26 
27 // MARKER(update_precomp.py): autogen include statement, do not remove
28 #include "precompiled_extensions.hxx"
29 
30 #include "corecontroller.hxx"
31 #include "config.hxx"
32 
33 using ::rtl::OUString;
34 using namespace ::com::sun::star::lang;
35 using namespace ::com::sun::star::uno;
36 
37 
38 namespace oooimprovement
39 {
40     CoreController::CoreController(const Reference<XMultiServiceFactory>& sf)
41         : m_ServiceFactory(sf)
42     { }
43 
44     CoreController::~CoreController()
45     { }
46 
47     sal_Bool SAL_CALL CoreController::enablingUiEventsLoggerAllowed(sal_Int16 version) throw(RuntimeException)
48     {
49         Config config(m_ServiceFactory);
50         if(version==1 && config.getEnablingAllowed() && config.getShowedInvitation() && config.getInvitationAccepted())
51             return true;
52         return false;
53     }
54 
55     sal_Bool SAL_CALL CoreController::showBuiltinOptionsPage(sal_Int16 version) throw(RuntimeException)
56     {
57         Config config(m_ServiceFactory);
58         if(version==1 && config.getEnablingAllowed())
59             return true;
60         return false;
61     }
62 
63     sal_Bool SAL_CALL CoreController::supportsService(const OUString& service_name) throw(RuntimeException)
64     {
65         const Sequence<OUString> service_names(getSupportedServiceNames());
66         for (sal_Int32 idx = service_names.getLength()-1; idx>=0; --idx)
67             if(service_name == service_names[idx]) return sal_True;
68         return sal_False;
69     }
70 
71     OUString SAL_CALL CoreController::getImplementationName() throw(RuntimeException)
72     { return getImplementationName_static(); }
73 
74     Sequence<OUString> SAL_CALL CoreController::getSupportedServiceNames() throw(RuntimeException)
75     { return getSupportedServiceNames_static(); }
76 
77     OUString SAL_CALL CoreController::getImplementationName_static()
78     { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovement.CoreController"); }
79 
80     Sequence<OUString> SAL_CALL CoreController::getSupportedServiceNames_static()
81     {
82         Sequence<OUString> aServiceNames(1);
83         aServiceNames[0] = OUString::createFromAscii("com.sun.star.oooimprovement.CoreController");
84         return aServiceNames;
85     }
86 
87     Reference<XInterface> SAL_CALL CoreController::Create(const Reference<XMultiServiceFactory>& sm)
88     { return *(new CoreController(sm)); }
89 }
90