LCOV - code coverage report
Current view: top level - framework/source/accelerators - globalacceleratorconfiguration.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 35 0.0 %
Date: 2014-04-14 Functions: 0 9 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 <accelerators/acceleratorconfiguration.hxx>
      21             : #include <accelerators/presethandler.hxx>
      22             : #include <helper/mischelper.hxx>
      23             : 
      24             : #include <acceleratorconst.h>
      25             : 
      26             : #include <com/sun/star/util/XChangesNotifier.hpp>
      27             : #include <com/sun/star/lang/XServiceInfo.hpp>
      28             : 
      29             : #include <cppuhelper/supportsservice.hxx>
      30             : #include <rtl/ref.hxx>
      31             : #include <vcl/svapp.hxx>
      32             : #include <i18nlangtag/languagetag.hxx>
      33             : 
      34             : using namespace framework;
      35             : 
      36             : namespace {
      37             : 
      38             : /**
      39             :     implements a read/write access to the global
      40             :     accelerator configuration.
      41             :  */
      42             : typedef ::cppu::ImplInheritanceHelper1<
      43             :              XCUBasedAcceleratorConfiguration,
      44             :              css::lang::XServiceInfo > GlobalAcceleratorConfiguration_BASE;
      45             : class GlobalAcceleratorConfiguration : public GlobalAcceleratorConfiguration_BASE
      46             : {
      47             : public:
      48             : 
      49             :     /** initialize this instance and fill the internal cache.
      50             : 
      51             :         @param  xSMGR
      52             :                 reference to an uno service manager, which is used internally.
      53             :      */
      54             :     GlobalAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext);
      55             : 
      56             :     /** TODO */
      57           0 :     virtual ~GlobalAcceleratorConfiguration() {}
      58             : 
      59           0 :     virtual OUString SAL_CALL getImplementationName()
      60             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      61             :     {
      62           0 :         return OUString("com.sun.star.comp.framework.GlobalAcceleratorConfiguration");
      63             :     }
      64             : 
      65           0 :     virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
      66             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      67             :     {
      68           0 :         return cppu::supportsService(this, ServiceName);
      69             :     }
      70             : 
      71           0 :     virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
      72             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      73             :     {
      74           0 :         css::uno::Sequence< OUString > aSeq(1);
      75           0 :         aSeq[0] = OUString("com.sun.star.ui.GlobalAcceleratorConfiguration");
      76           0 :         return aSeq;
      77             :     }
      78             : 
      79             :     // XComponent
      80             :     virtual  void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      81             : 
      82             :     /// This has to be called after when the instance is acquire()'d.
      83             :     void fillCache();
      84             : 
      85             : private:
      86             : 
      87             :     OUString m_sLocale;
      88             : 
      89             :     /** helper to listen for configuration changes without ownership cycle problems */
      90             :     css::uno::Reference< css::util::XChangesListener > m_xCfgListener;
      91             : };
      92             : 
      93           0 : GlobalAcceleratorConfiguration::GlobalAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
      94           0 :     : GlobalAcceleratorConfiguration_BASE(xContext)
      95             : {
      96           0 : }
      97             : 
      98           0 : void GlobalAcceleratorConfiguration::fillCache()
      99             : {
     100             :     /** read all data into the cache. */
     101             : 
     102             : #if 0
     103             :     // get current office locale ... but dont cache it.
     104             :     // Otherwise we must be listener on the configuration layer
     105             :     // which seems to superflous for this small implementation .-)
     106             :     // XXX: what is this good for? it was a comphelper::Locale but unused
     107             :     LanguageTag aLanguageTag(m_sLocale);
     108             : #endif
     109             : 
     110             :     // May be there exists no accelerator config? Handle it gracefully :-)
     111             :     try
     112             :     {
     113           0 :         m_sGlobalOrModules = CFG_ENTRY_GLOBAL;
     114           0 :         XCUBasedAcceleratorConfiguration::reload();
     115             : 
     116           0 :         css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
     117           0 :         m_xCfgListener = new WeakChangesListener(this);
     118           0 :         xBroadcaster->addChangesListener(m_xCfgListener);
     119             :     }
     120           0 :     catch(const css::uno::RuntimeException&)
     121           0 :         { throw; }
     122           0 :     catch(const css::uno::Exception&)
     123             :         {}
     124           0 : }
     125             : 
     126             : // XComponent.dispose(),  #i120029#, to release the cyclic reference
     127             : 
     128           0 : void SAL_CALL GlobalAcceleratorConfiguration::dispose()
     129             :     throw(css::uno::RuntimeException, std::exception)
     130             : {
     131             :     try
     132             :     {
     133           0 :         css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
     134           0 :         if ( xBroadcaster.is() )
     135           0 :             xBroadcaster->removeChangesListener(static_cast< css::util::XChangesListener* >(this));
     136             :     }
     137           0 :     catch(const css::uno::RuntimeException&)
     138           0 :     { throw; }
     139           0 :     catch(const css::uno::Exception&)
     140             :     {}
     141           0 : }
     142             : 
     143             : }
     144             : 
     145             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     146           0 : com_sun_star_comp_framework_GlobalAcceleratorConfiguration_get_implementation(
     147             :     css::uno::XComponentContext *context,
     148             :     css::uno::Sequence<css::uno::Any> const &)
     149             : {
     150           0 :     GlobalAcceleratorConfiguration *inst = new GlobalAcceleratorConfiguration(context);
     151           0 :     css::uno::XInterface *acquired_inst = cppu::acquire(inst);
     152             : 
     153           0 :     inst->fillCache();
     154             : 
     155           0 :     return acquired_inst;
     156             : }
     157             : 
     158             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10