LCOV - code coverage report
Current view: top level - unotools/source/i18n - numberformatcodewrapper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 22 25 88.0 %
Date: 2012-08-25 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 13 32 40.6 %

           Branch data     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                 :            : 
      21                 :            : #include <unotools/numberformatcodewrapper.hxx>
      22                 :            : #include <tools/debug.hxx>
      23                 :            : #include "instance.hxx"
      24                 :            : 
      25                 :            : using namespace ::com::sun::star;
      26                 :            : using namespace ::com::sun::star::i18n;
      27                 :            : using namespace ::com::sun::star::uno;
      28                 :            : 
      29                 :            : 
      30                 :      16910 : NumberFormatCodeWrapper::NumberFormatCodeWrapper(
      31                 :            :             const Reference< lang::XMultiServiceFactory > & xSF,
      32                 :            :             const lang::Locale& rLocale
      33                 :            :             )
      34                 :            :         :
      35                 :      16910 :         xSMgr( xSF )
      36                 :            : {
      37         [ +  - ]:      16910 :     setLocale( rLocale );
      38                 :            :     xNFC = Reference< XNumberFormatCode > (
      39                 :            :         intl_createInstance( xSMgr, "com.sun.star.i18n.NumberFormatMapper",
      40 [ +  - ][ +  - ]:      16910 :                              "NumberFormatCodeWrapper" ), uno::UNO_QUERY );
                 [ +  - ]
      41                 :            :     DBG_ASSERT( xNFC.is(), "NumberFormatCodeWrapper: no NumberFormatMapper" );
      42                 :      16910 : }
      43                 :            : 
      44                 :            : 
      45                 :      16910 : NumberFormatCodeWrapper::~NumberFormatCodeWrapper()
      46                 :            : {
      47                 :      16910 : }
      48                 :            : 
      49                 :            : 
      50                 :      19350 : void NumberFormatCodeWrapper::setLocale( const ::com::sun::star::lang::Locale& rLocale )
      51                 :            : {
      52                 :      19350 :     aLocale = rLocale;
      53                 :      19350 : }
      54                 :            : 
      55                 :            : 
      56                 :            : ::com::sun::star::i18n::NumberFormatCode
      57                 :       7203 : NumberFormatCodeWrapper::getFormatCode( sal_Int16 formatIndex ) const
      58                 :            : {
      59                 :            :     try
      60                 :            :     {
      61         [ +  - ]:       7203 :         if ( xNFC.is() )
      62 [ +  - ][ +  - ]:       7203 :             return xNFC->getFormatCode( formatIndex, aLocale );
      63                 :            :     }
      64                 :          0 :     catch ( const Exception& )
      65                 :            :     {
      66                 :            :         SAL_WARN( "unotools.i18n", "getFormatCode: Exception caught!" );
      67                 :            :     }
      68         [ #  # ]:       7203 :     return ::com::sun::star::i18n::NumberFormatCode();
      69                 :            : }
      70                 :            : 
      71                 :            : 
      72                 :            : ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode >
      73                 :      26787 : NumberFormatCodeWrapper::getAllFormatCode( sal_Int16 formatUsage ) const
      74                 :            : {
      75                 :            :     try
      76                 :            :     {
      77         [ +  - ]:      26787 :         if ( xNFC.is() )
      78 [ +  - ][ +  - ]:      26787 :             return xNFC->getAllFormatCode( formatUsage, aLocale );
      79                 :            :     }
      80                 :          0 :     catch ( const Exception& )
      81                 :            :     {
      82                 :            :         SAL_WARN( "unotools.i18n", "getAllFormatCode: Exception caught!" );
      83                 :            :     }
      84         [ #  # ]:      26787 :     return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode > (0);
      85                 :            : }
      86                 :            : 
      87                 :            : 
      88                 :            : ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode >
      89                 :       2440 : NumberFormatCodeWrapper::getAllFormatCodes() const
      90                 :            : {
      91                 :            :     try
      92                 :            :     {
      93         [ +  - ]:       2440 :         if ( xNFC.is() )
      94 [ +  - ][ +  - ]:       2440 :             return xNFC->getAllFormatCodes( aLocale );
      95                 :            :     }
      96                 :          0 :     catch ( const Exception& )
      97                 :            :     {
      98                 :            :         SAL_WARN( "unotools.i18n", "getAllFormatCodes: Exception caught!" );
      99                 :            :     }
     100         [ #  # ]:       2440 :     return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode > (0);
     101                 :            : }
     102                 :            : 
     103                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10