LCOV - code coverage report
Current view: top level - libreoffice/shell/source/backends/gconfbe - gconfbackend.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 44 0.0 %
Date: 2012-12-27 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "sal/config.h"
      21             : 
      22             : #include <cstddef>
      23             : 
      24             : #include "boost/noncopyable.hpp"
      25             : #include "com/sun/star/beans/Optional.hpp"
      26             : #include "com/sun/star/beans/PropertyVetoException.hpp"
      27             : #include "com/sun/star/beans/UnknownPropertyException.hpp"
      28             : #include "com/sun/star/beans/XPropertyChangeListener.hpp"
      29             : #include "com/sun/star/beans/XPropertySet.hpp"
      30             : #include "com/sun/star/beans/XPropertySetInfo.hpp"
      31             : #include "com/sun/star/beans/XVetoableChangeListener.hpp"
      32             : #include "com/sun/star/lang/IllegalArgumentException.hpp"
      33             : #include "com/sun/star/lang/WrappedTargetException.hpp"
      34             : #include "com/sun/star/lang/XMultiComponentFactory.hpp"
      35             : #include "com/sun/star/lang/XServiceInfo.hpp"
      36             : #include "com/sun/star/lang/WrappedTargetException.hpp"
      37             : #include "com/sun/star/uno/Any.hxx"
      38             : #include "com/sun/star/uno/Reference.hxx"
      39             : #include "com/sun/star/uno/RuntimeException.hpp"
      40             : #include "com/sun/star/uno/Sequence.hxx"
      41             : #include "com/sun/star/uno/XComponentContext.hpp"
      42             : #include "com/sun/star/uno/XCurrentContext.hpp"
      43             : #include "cppuhelper/factory.hxx"
      44             : #include "cppuhelper/implbase2.hxx"
      45             : #include "cppuhelper/implementationentry.hxx"
      46             : #include "cppuhelper/weak.hxx"
      47             : #include "rtl/string.h"
      48             : #include "rtl/ustring.h"
      49             : #include "rtl/ustring.hxx"
      50             : #include "sal/types.h"
      51             : #include "uno/current_context.hxx"
      52             : #include "uno/lbnames.h"
      53             : 
      54             : #include "gconfaccess.hxx"
      55             : 
      56             : namespace {
      57             : 
      58           0 : rtl::OUString SAL_CALL getServiceImplementationName() {
      59             :     return rtl::OUString(
      60             :         RTL_CONSTASCII_USTRINGPARAM(
      61           0 :             "com.sun.star.comp.configuration.backend.GconfBackend"));
      62             : }
      63             : 
      64           0 : css::uno::Sequence< rtl::OUString > SAL_CALL getServiceSupportedServiceNames() {
      65             :     rtl::OUString name(
      66             :         RTL_CONSTASCII_USTRINGPARAM(
      67           0 :             "com.sun.star.configuration.backend.GconfBackend"));
      68           0 :     return css::uno::Sequence< rtl::OUString >(&name, 1);
      69             : }
      70             : 
      71             : class Service:
      72             :     public cppu::WeakImplHelper2<
      73             :         css::lang::XServiceInfo, css::beans::XPropertySet >,
      74             :     private boost::noncopyable
      75             : {
      76             : public:
      77             :     Service();
      78             : 
      79             : private:
      80           0 :     virtual ~Service() {}
      81             : 
      82           0 :     virtual rtl::OUString SAL_CALL getImplementationName()
      83             :         throw (css::uno::RuntimeException)
      84           0 :     { return getServiceImplementationName(); }
      85             : 
      86           0 :     virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
      87             :         throw (css::uno::RuntimeException)
      88           0 :     { return ServiceName == getSupportedServiceNames()[0]; }
      89             : 
      90             :     virtual css::uno::Sequence< rtl::OUString > SAL_CALL
      91           0 :     getSupportedServiceNames() throw (css::uno::RuntimeException)
      92           0 :     { return getServiceSupportedServiceNames(); }
      93             : 
      94             :     virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
      95           0 :     getPropertySetInfo() throw (css::uno::RuntimeException)
      96           0 :     { return css::uno::Reference< css::beans::XPropertySetInfo >(); }
      97             : 
      98             :     virtual void SAL_CALL setPropertyValue(
      99             :         rtl::OUString const &, css::uno::Any const &)
     100             :         throw (
     101             :             css::beans::UnknownPropertyException,
     102             :             css::beans::PropertyVetoException,
     103             :             css::lang::IllegalArgumentException,
     104             :             css::lang::WrappedTargetException, css::uno::RuntimeException);
     105             : 
     106             :     virtual css::uno::Any SAL_CALL getPropertyValue(
     107             :         rtl::OUString const & PropertyName)
     108             :         throw (
     109             :             css::beans::UnknownPropertyException,
     110             :             css::lang::WrappedTargetException, css::uno::RuntimeException);
     111             : 
     112           0 :     virtual void SAL_CALL addPropertyChangeListener(
     113             :         rtl::OUString const &,
     114             :         css::uno::Reference< css::beans::XPropertyChangeListener > const &)
     115             :         throw (
     116             :             css::beans::UnknownPropertyException,
     117             :             css::lang::WrappedTargetException, css::uno::RuntimeException)
     118           0 :     {}
     119             : 
     120           0 :     virtual void SAL_CALL removePropertyChangeListener(
     121             :         rtl::OUString const &,
     122             :         css::uno::Reference< css::beans::XPropertyChangeListener > const &)
     123             :         throw (
     124             :             css::beans::UnknownPropertyException,
     125             :             css::lang::WrappedTargetException, css::uno::RuntimeException)
     126           0 :     {}
     127             : 
     128           0 :     virtual void SAL_CALL addVetoableChangeListener(
     129             :         rtl::OUString const &,
     130             :         css::uno::Reference< css::beans::XVetoableChangeListener > const &)
     131             :         throw (
     132             :             css::beans::UnknownPropertyException,
     133             :             css::lang::WrappedTargetException, css::uno::RuntimeException)
     134           0 :     {}
     135             : 
     136           0 :     virtual void SAL_CALL removeVetoableChangeListener(
     137             :         rtl::OUString const &,
     138             :         css::uno::Reference< css::beans::XVetoableChangeListener > const &)
     139             :         throw (
     140             :             css::beans::UnknownPropertyException,
     141             :             css::lang::WrappedTargetException, css::uno::RuntimeException)
     142           0 :     {}
     143             : 
     144             :     bool enabled_;
     145             : };
     146             : 
     147           0 : Service::Service(): enabled_(false) {
     148             :     css::uno::Reference< css::uno::XCurrentContext > context(
     149           0 :         css::uno::getCurrentContext());
     150           0 :     if (context.is()) {
     151           0 :         rtl::OUString desktop;
     152           0 :         context->getValueByName(
     153             :             rtl::OUString(
     154           0 :                 RTL_CONSTASCII_USTRINGPARAM("system.desktop-environment"))) >>=
     155           0 :             desktop;
     156           0 :         enabled_ = desktop == "GNOME";
     157           0 :     }
     158           0 : }
     159             : 
     160           0 : void Service::setPropertyValue(rtl::OUString const &, css::uno::Any const &)
     161             :     throw (
     162             :         css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
     163             :         css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
     164             :         css::uno::RuntimeException)
     165             : {
     166             :     throw css::lang::IllegalArgumentException(
     167             :         rtl::OUString(
     168             :             RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")),
     169           0 :         static_cast< cppu::OWeakObject * >(this), -1);
     170             : }
     171             : 
     172           0 : css::uno::Any Service::getPropertyValue(rtl::OUString const & PropertyName)
     173             :     throw (
     174             :         css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
     175             :         css::uno::RuntimeException)
     176             : {
     177           0 :     for (std::size_t i = 0; i < gconfaccess::nConfigurationValues; ++i)
     178             :     {
     179           0 :         if (PropertyName.equalsAsciiL(
     180             :                 gconfaccess::ConfigurationValues[i].OOoConfItem,
     181           0 :                 gconfaccess::ConfigurationValues[i].nOOoConfItemLen))
     182             :         {
     183             :             return css::uno::makeAny(
     184             :                 enabled_
     185             :                 ? gconfaccess::getValue(gconfaccess::ConfigurationValues[i])
     186           0 :                 : css::beans::Optional< css::uno::Any >());
     187             :         }
     188             :     }
     189             :     throw css::beans::UnknownPropertyException(
     190           0 :         PropertyName, static_cast< cppu::OWeakObject * >(this));
     191             : }
     192             : 
     193           0 : css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(
     194             :     SAL_UNUSED_PARAMETER css::uno::Reference< css::uno::XComponentContext >
     195             :         const &)
     196             : {
     197           0 :     return static_cast< cppu::OWeakObject * >(new Service);
     198             : }
     199             : 
     200             : static cppu::ImplementationEntry const services[] = {
     201             :     { &createInstance, &getServiceImplementationName,
     202             :       &getServiceSupportedServiceNames, &cppu::createSingleComponentFactory, 0,
     203             :       0 },
     204             :     { 0, 0, 0, 0, 0, 0 }
     205             : };
     206             : 
     207             : }
     208             : 
     209           0 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL gconfbe1_component_getFactory(
     210             :     char const * pImplName, void * pServiceManager, void * pRegistryKey)
     211             : {
     212             :     return cppu::component_getFactoryHelper(
     213           0 :         pImplName, pServiceManager, pRegistryKey, services);
     214             : }
     215             : 
     216             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10