LCOV - code coverage report
Current view: top level - framework/source/accelerators - moduleacceleratorconfiguration.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 31 34 91.2 %
Date: 2012-08-25 Functions: 14 18 77.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 37 147 25.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <accelerators/moduleacceleratorconfiguration.hxx>
      30                 :            : 
      31                 :            : #include <threadhelp/readguard.hxx>
      32                 :            : #include <threadhelp/writeguard.hxx>
      33                 :            : #include "helper/mischelper.hxx"
      34                 :            : 
      35                 :            : #include <acceleratorconst.h>
      36                 :            : #include <services.h>
      37                 :            : 
      38                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      39                 :            : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      40                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      41                 :            : 
      42                 :            : #include <comphelper/sequenceashashmap.hxx>
      43                 :            : #include <vcl/svapp.hxx>
      44                 :            : 
      45                 :            : #include <comphelper/configurationhelper.hxx>
      46                 :            : 
      47                 :            : #include <com/sun/star/util/XChangesNotifier.hpp>
      48                 :            : 
      49                 :            : #include <rtl/logfile.hxx>
      50                 :            : 
      51                 :            : #include <rtl/logfile.h>
      52                 :            : 
      53                 :            : 
      54                 :            : namespace framework
      55                 :            : {
      56                 :            : 
      57                 :            : //-----------------------------------------------
      58                 :            : // XInterface, XTypeProvider, XServiceInfo
      59 [ +  + ][ +  - ]:     169316 : DEFINE_XINTERFACE_2(ModuleAcceleratorConfiguration              ,
      60                 :            :                     XCUBasedAcceleratorConfiguration                    ,
      61                 :            :                     DIRECT_INTERFACE(css::lang::XServiceInfo)   ,
      62                 :            :                     DIRECT_INTERFACE(css::lang::XInitialization))
      63                 :            : 
      64 [ #  # ][ #  # ]:          0 : DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(ModuleAcceleratorConfiguration,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      65                 :            :                                       XCUBasedAcceleratorConfiguration      ,
      66                 :            :                                       css::lang::XServiceInfo       ,
      67                 :            :                                       css::lang::XInitialization    )
      68                 :            : 
      69 [ +  - ][ +  - ]:       1781 : DEFINE_XSERVICEINFO_MULTISERVICE(ModuleAcceleratorConfiguration                   ,
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
                 [ #  # ]
      70                 :            :                                  ::cppu::OWeakObject                              ,
      71                 :            :                                  SERVICENAME_MODULEACCELERATORCONFIGURATION       ,
      72                 :            :                                  IMPLEMENTATIONNAME_MODULEACCELERATORCONFIGURATION)
      73                 :            : 
      74                 :         92 : DEFINE_INIT_SERVICE(ModuleAcceleratorConfiguration,
      75                 :            :                     {
      76                 :            :                         /*Attention
      77                 :            :                         I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
      78                 :            :                         to create a new instance of this class by our own supported service factory.
      79                 :            :                         see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
      80                 :            :                         */
      81                 :            :                     }
      82                 :            :                    )
      83                 :            : 
      84                 :            : //-----------------------------------------------
      85                 :         92 : ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
      86         [ +  - ]:         92 :     : XCUBasedAcceleratorConfiguration(xSMGR)
      87                 :            : {
      88                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration" );
      89                 :         92 : }
      90                 :            : 
      91                 :            : //-----------------------------------------------
      92                 :         92 : ModuleAcceleratorConfiguration::~ModuleAcceleratorConfiguration()
      93                 :            : {
      94         [ -  + ]:        184 : }
      95                 :            : 
      96                 :            : //-----------------------------------------------
      97                 :         92 : void SAL_CALL ModuleAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& lArguments)
      98                 :            :     throw(css::uno::Exception       ,
      99                 :            :           css::uno::RuntimeException)
     100                 :            : {
     101                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::initialize" );
     102                 :            :     // SAFE -> ----------------------------------
     103         [ +  - ]:         92 :     WriteGuard aWriteLock(m_aLock);
     104                 :            : 
     105         [ +  - ]:         92 :     ::comphelper::SequenceAsHashMap lArgs(lArguments);
     106         [ +  - ]:         92 :     m_sModule = lArgs.getUnpackedValueOrDefault(::rtl::OUString("ModuleIdentifier"), ::rtl::OUString());
     107         [ +  - ]:         92 :     m_sLocale = lArgs.getUnpackedValueOrDefault(::rtl::OUString("Locale")          , ::rtl::OUString("x-default"));
     108                 :            : 
     109         [ -  + ]:         92 :     if (m_sModule.isEmpty())
     110                 :            :         throw css::uno::RuntimeException(
     111                 :            :                 ::rtl::OUString("The module dependend accelerator configuration service was initialized with an empty module identifier!"),
     112 [ #  # ][ #  # ]:          0 :                 static_cast< ::cppu::OWeakObject* >(this));
     113                 :            : 
     114         [ +  - ]:         92 :     aWriteLock.unlock();
     115                 :            :     // <- SAFE ----------------------------------
     116                 :            : 
     117 [ +  - ][ +  - ]:         92 :     impl_ts_fillCache();
                 [ +  - ]
     118                 :         92 : }
     119                 :            : 
     120                 :            : //-----------------------------------------------
     121                 :         92 : void ModuleAcceleratorConfiguration::impl_ts_fillCache()
     122                 :            : {
     123                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ModuleAcceleratorConfiguration::impl_ts_fillCache" );
     124                 :            :     // SAFE -> ----------------------------------
     125         [ +  - ]:         92 :     ReadGuard aReadLock(m_aLock);
     126                 :         92 :     m_sModuleCFG = m_sModule;
     127         [ +  - ]:         92 :     aReadLock.unlock();
     128                 :            :     // <- SAFE ----------------------------------
     129                 :            : 
     130                 :            :     // get current office locale ... but dont cache it.
     131                 :            :     // Otherwise we must be listener on the configuration layer
     132                 :            :     // which seems to superflous for this small implementation .-)
     133         [ +  - ]:         92 :     ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
     134                 :            : 
     135                 :            :     // May be the current app module does not have any
     136                 :            :     // accelerator config? Handle it gracefully :-)
     137                 :            :     try
     138                 :            :     {
     139                 :         92 :         m_sGlobalOrModules = CFG_ENTRY_MODULES;
     140         [ +  + ]:         92 :         XCUBasedAcceleratorConfiguration::reload();
     141                 :            : 
     142         [ +  - ]:         90 :         css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
     143 [ +  - ][ +  - ]:         90 :         m_xCfgListener = new WeakChangesListener(this);
         [ +  - ][ +  - ]
     144 [ +  - ][ +  - ]:         92 :         xBroadcaster->addChangesListener(m_xCfgListener);
     145                 :            :     }
     146      [ -  -  + ]:          2 :     catch(const css::uno::RuntimeException&)
     147                 :          0 :         { throw; }
     148         [ +  - ]:          2 :     catch(const css::uno::Exception&)
     149 [ +  - ][ +  - ]:         92 :         {}
     150                 :         92 : }
     151                 :            : 
     152                 :            : } // namespace framework
     153                 :            : 
     154                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10