LCOV - code coverage report
Current view: top level - libreoffice/framework/source/accelerators - globalacceleratorconfiguration.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 23 73.9 %
Date: 2012-12-17 Functions: 12 18 66.7 %
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/globalacceleratorconfiguration.hxx>
      21             : 
      22             : #include <threadhelp/readguard.hxx>
      23             : #include <threadhelp/writeguard.hxx>
      24             : #include "helper/mischelper.hxx"
      25             : 
      26             : #include <acceleratorconst.h>
      27             : #include <services.h>
      28             : 
      29             : #include <com/sun/star/beans/XPropertySet.hpp>
      30             : #include <com/sun/star/embed/ElementModes.hpp>
      31             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      32             : #include <com/sun/star/container/XNameAccess.hpp>
      33             : #include <com/sun/star/util/XChangesNotifier.hpp>
      34             : 
      35             : #include <vcl/svapp.hxx>
      36             : #include <comphelper/locale.hxx>
      37             : #include <comphelper/configurationhelper.hxx>
      38             : 
      39             : 
      40             : namespace framework
      41             : {
      42             : 
      43             : //-----------------------------------------------
      44             : // XInterface, XTypeProvider, XServiceInfo
      45         340 : DEFINE_XINTERFACE_2(GlobalAcceleratorConfiguration           ,
      46             :                     XCUBasedAcceleratorConfiguration                 ,
      47             :                     DIRECT_INTERFACE(css::lang::XServiceInfo),
      48             :                     DIRECT_INTERFACE(css::lang::XInitialization))
      49           0 : DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(GlobalAcceleratorConfiguration,
      50             :                                       XCUBasedAcceleratorConfiguration      ,
      51             :                                       css::lang::XServiceInfo       ,
      52             :                                       css::lang::XInitialization)
      53             : 
      54         528 : DEFINE_XSERVICEINFO_MULTISERVICE(GlobalAcceleratorConfiguration                   ,
      55             :                                  ::cppu::OWeakObject                              ,
      56             :                                  DECLARE_ASCII("com.sun.star.ui.GlobalAcceleratorConfiguration"),
      57             :                                  IMPLEMENTATIONNAME_GLOBALACCELERATORCONFIGURATION)
      58             : 
      59           4 : DEFINE_INIT_SERVICE(GlobalAcceleratorConfiguration,
      60             :                     {
      61             :                         /*Attention
      62             :                         I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
      63             :                         to create a new instance of this class by our own supported service factory.
      64             :                         see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
      65             :                         */
      66             :                         impl_ts_fillCache();
      67             :                     }
      68             :                    )
      69             : 
      70             : //-----------------------------------------------
      71           4 : GlobalAcceleratorConfiguration::GlobalAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
      72           4 :     : XCUBasedAcceleratorConfiguration(xSMGR)
      73             : {
      74           4 : }
      75             : 
      76             : //-----------------------------------------------
      77           8 : GlobalAcceleratorConfiguration::~GlobalAcceleratorConfiguration()
      78             : {
      79           8 : }
      80             : 
      81           0 : void SAL_CALL GlobalAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& /*lArguments*/)
      82             :     throw(css::uno::Exception       ,
      83             :           css::uno::RuntimeException)
      84             : {
      85           0 : }
      86             : 
      87             : //-----------------------------------------------
      88           4 : void GlobalAcceleratorConfiguration::impl_ts_fillCache()
      89             : {
      90             :     // get current office locale ... but dont cache it.
      91             :     // Otherwise we must be listener on the configuration layer
      92             :     // which seems to superflous for this small implementation .-)
      93           4 :     ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
      94             : 
      95             :     // May be there exists no accelerator config? Handle it gracefully :-)
      96             :     try
      97             :     {
      98           4 :         m_sGlobalOrModules = CFG_ENTRY_GLOBAL;
      99           4 :         XCUBasedAcceleratorConfiguration::reload();
     100             : 
     101           4 :         css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
     102           4 :         m_xCfgListener = new WeakChangesListener(this);
     103           4 :         xBroadcaster->addChangesListener(m_xCfgListener);
     104             :     }
     105           0 :     catch(const css::uno::RuntimeException&)
     106           0 :         { throw; }
     107           0 :     catch(const css::uno::Exception&)
     108           4 :         {}
     109           4 : }
     110             : 
     111             : } // namespace framework
     112             : 
     113             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10