1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_extensions.hxx"
26 
27 #include "corecontroller.hxx"
28 #include "config.hxx"
29 
30 using ::rtl::OUString;
31 using namespace ::com::sun::star::lang;
32 using namespace ::com::sun::star::uno;
33 
34 
35 namespace oooimprovement
36 {
CoreController(const Reference<XMultiServiceFactory> & sf)37     CoreController::CoreController(const Reference<XMultiServiceFactory>& sf)
38         : m_ServiceFactory(sf)
39     { }
40 
~CoreController()41     CoreController::~CoreController()
42     { }
43 
enablingUiEventsLoggerAllowed(sal_Int16 version)44     sal_Bool SAL_CALL CoreController::enablingUiEventsLoggerAllowed(sal_Int16 version) throw(RuntimeException)
45     {
46         Config config(m_ServiceFactory);
47         if(version==1 && config.getEnablingAllowed() && config.getShowedInvitation() && config.getInvitationAccepted())
48             return true;
49         return false;
50     }
51 
showBuiltinOptionsPage(sal_Int16 version)52     sal_Bool SAL_CALL CoreController::showBuiltinOptionsPage(sal_Int16 version) throw(RuntimeException)
53     {
54         Config config(m_ServiceFactory);
55         if(version==1 && config.getEnablingAllowed())
56             return true;
57         return false;
58     }
59 
supportsService(const OUString & service_name)60     sal_Bool SAL_CALL CoreController::supportsService(const OUString& service_name) throw(RuntimeException)
61     {
62         const Sequence<OUString> service_names(getSupportedServiceNames());
63         for (sal_Int32 idx = service_names.getLength()-1; idx>=0; --idx)
64             if(service_name == service_names[idx]) return sal_True;
65         return sal_False;
66     }
67 
getImplementationName()68     OUString SAL_CALL CoreController::getImplementationName() throw(RuntimeException)
69     { return getImplementationName_static(); }
70 
getSupportedServiceNames()71     Sequence<OUString> SAL_CALL CoreController::getSupportedServiceNames() throw(RuntimeException)
72     { return getSupportedServiceNames_static(); }
73 
getImplementationName_static()74     OUString SAL_CALL CoreController::getImplementationName_static()
75     { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovement.CoreController"); }
76 
getSupportedServiceNames_static()77     Sequence<OUString> SAL_CALL CoreController::getSupportedServiceNames_static()
78     {
79         Sequence<OUString> aServiceNames(1);
80         aServiceNames[0] = OUString::createFromAscii("com.sun.star.oooimprovement.CoreController");
81         return aServiceNames;
82     }
83 
Create(const Reference<XMultiServiceFactory> & sm)84     Reference<XInterface> SAL_CALL CoreController::Create(const Reference<XMultiServiceFactory>& sm)
85     { return *(new CoreController(sm)); }
86 }
87