LCOV - code coverage report
Current view: top level - libreoffice/framework/source/accelerators - moduleacceleratorconfiguration.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 34 2.9 %
Date: 2012-12-27 Functions: 1 18 5.6 %
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/moduleacceleratorconfiguration.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/lang/XSingleServiceFactory.hpp>
      31             : #include <com/sun/star/embed/ElementModes.hpp>
      32             : 
      33             : #include <comphelper/sequenceashashmap.hxx>
      34             : #include <vcl/svapp.hxx>
      35             : 
      36             : #include <comphelper/configurationhelper.hxx>
      37             : 
      38             : #include <com/sun/star/util/XChangesNotifier.hpp>
      39             : 
      40             : #include <rtl/logfile.hxx>
      41             : 
      42             : #include <rtl/logfile.h>
      43             : 
      44             : 
      45             : namespace framework
      46             : {
      47             : 
      48             : //-----------------------------------------------
      49             : // XInterface, XTypeProvider, XServiceInfo
      50           0 : DEFINE_XINTERFACE_2(ModuleAcceleratorConfiguration              ,
      51             :                     XCUBasedAcceleratorConfiguration                    ,
      52             :                     DIRECT_INTERFACE(css::lang::XServiceInfo)   ,
      53             :                     DIRECT_INTERFACE(css::lang::XInitialization))
      54             : 
      55           0 : DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(ModuleAcceleratorConfiguration,
      56             :                                       XCUBasedAcceleratorConfiguration      ,
      57             :                                       css::lang::XServiceInfo       ,
      58             :                                       css::lang::XInitialization    )
      59             : 
      60         105 : DEFINE_XSERVICEINFO_MULTISERVICE(ModuleAcceleratorConfiguration                   ,
      61             :                                  ::cppu::OWeakObject                              ,
      62             :                                  SERVICENAME_MODULEACCELERATORCONFIGURATION       ,
      63             :                                  IMPLEMENTATIONNAME_MODULEACCELERATORCONFIGURATION)
      64             : 
      65           0 : DEFINE_INIT_SERVICE(ModuleAcceleratorConfiguration,
      66             :                     {
      67             :                         /*Attention
      68             :                         I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
      69             :                         to create a new instance of this class by our own supported service factory.
      70             :                         see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
      71             :                         */
      72             :                     }
      73             :                    )
      74             : 
      75             : //-----------------------------------------------
      76           0 : ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
      77           0 :     : XCUBasedAcceleratorConfiguration(xSMGR)
      78             : {
      79             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration" );
      80           0 : }
      81             : 
      82             : //-----------------------------------------------
      83           0 : ModuleAcceleratorConfiguration::~ModuleAcceleratorConfiguration()
      84             : {
      85           0 : }
      86             : 
      87             : //-----------------------------------------------
      88           0 : void SAL_CALL ModuleAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& lArguments)
      89             :     throw(css::uno::Exception       ,
      90             :           css::uno::RuntimeException)
      91             : {
      92             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::initialize" );
      93             :     // SAFE -> ----------------------------------
      94           0 :     WriteGuard aWriteLock(m_aLock);
      95             : 
      96           0 :     ::comphelper::SequenceAsHashMap lArgs(lArguments);
      97           0 :     m_sModule = lArgs.getUnpackedValueOrDefault(::rtl::OUString("ModuleIdentifier"), ::rtl::OUString());
      98           0 :     m_sLocale = lArgs.getUnpackedValueOrDefault(::rtl::OUString("Locale")          , ::rtl::OUString("x-default"));
      99             : 
     100           0 :     if (m_sModule.isEmpty())
     101             :         throw css::uno::RuntimeException(
     102             :                 ::rtl::OUString("The module dependend accelerator configuration service was initialized with an empty module identifier!"),
     103           0 :                 static_cast< ::cppu::OWeakObject* >(this));
     104             : 
     105           0 :     aWriteLock.unlock();
     106             :     // <- SAFE ----------------------------------
     107             : 
     108           0 :     impl_ts_fillCache();
     109           0 : }
     110             : 
     111             : //-----------------------------------------------
     112           0 : void ModuleAcceleratorConfiguration::impl_ts_fillCache()
     113             : {
     114             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::impl_ts_fillCache" );
     115             :     // SAFE -> ----------------------------------
     116           0 :     ReadGuard aReadLock(m_aLock);
     117           0 :     m_sModuleCFG = m_sModule;
     118           0 :     aReadLock.unlock();
     119             :     // <- SAFE ----------------------------------
     120             : 
     121             :     // get current office locale ... but dont cache it.
     122             :     // Otherwise we must be listener on the configuration layer
     123             :     // which seems to superflous for this small implementation .-)
     124           0 :     ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
     125             : 
     126             :     // May be the current app module does not have any
     127             :     // accelerator config? Handle it gracefully :-)
     128             :     try
     129             :     {
     130           0 :         m_sGlobalOrModules = CFG_ENTRY_MODULES;
     131           0 :         XCUBasedAcceleratorConfiguration::reload();
     132             : 
     133           0 :         css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
     134           0 :         m_xCfgListener = new WeakChangesListener(this);
     135           0 :         xBroadcaster->addChangesListener(m_xCfgListener);
     136             :     }
     137           0 :     catch(const css::uno::RuntimeException&)
     138           0 :         { throw; }
     139           0 :     catch(const css::uno::Exception&)
     140           0 :         {}
     141           0 : }
     142             : 
     143             : } // namespace framework
     144             : 
     145             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10