LCOV - code coverage report
Current view: top level - editeng/source/uno - UnoForbiddenCharsTable.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 36 53 67.9 %
Date: 2015-06-13 12:38:46 Functions: 6 10 60.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 <editeng/UnoForbiddenCharsTable.hxx>
      21             : #include <editeng/forbiddencharacterstable.hxx>
      22             : #include <osl/mutex.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <editeng/unolingu.hxx>
      25             : 
      26             : using namespace ::com::sun::star;
      27             : using namespace ::com::sun::star::uno;
      28             : using namespace ::com::sun::star::container;
      29             : using namespace ::com::sun::star::lang;
      30             : using namespace ::com::sun::star::i18n;
      31             : using namespace ::cppu;
      32             : 
      33         511 : SvxUnoForbiddenCharsTable::SvxUnoForbiddenCharsTable(::rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars) :
      34         511 :     mxForbiddenChars( xForbiddenChars )
      35             : {
      36         511 : }
      37             : 
      38         509 : SvxUnoForbiddenCharsTable::~SvxUnoForbiddenCharsTable()
      39             : {
      40         509 : }
      41             : 
      42           0 : void SvxUnoForbiddenCharsTable::onChange()
      43             : {
      44           0 : }
      45             : 
      46          14 : ForbiddenCharacters SvxUnoForbiddenCharsTable::getForbiddenCharacters( const lang::Locale& rLocale )
      47             :     throw(NoSuchElementException, RuntimeException, std::exception)
      48             : {
      49          14 :     SolarMutexGuard aGuard;
      50             : 
      51          14 :     if(!mxForbiddenChars.is())
      52           0 :         throw RuntimeException();
      53             : 
      54          14 :     const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
      55          14 :     const ForbiddenCharacters* pForbidden = mxForbiddenChars->GetForbiddenCharacters( eLang, false );
      56          14 :     if(!pForbidden)
      57           0 :         throw NoSuchElementException();
      58             : 
      59          14 :     return *pForbidden;
      60             : }
      61             : 
      62          18 : sal_Bool SvxUnoForbiddenCharsTable::hasForbiddenCharacters( const lang::Locale& rLocale )
      63             :     throw(RuntimeException, std::exception)
      64             : {
      65          18 :     SolarMutexGuard aGuard;
      66             : 
      67          18 :     if(!mxForbiddenChars.is())
      68           0 :         return sal_False;
      69             : 
      70          18 :     const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
      71          18 :     const ForbiddenCharacters* pForbidden = mxForbiddenChars->GetForbiddenCharacters( eLang, false );
      72             : 
      73          18 :     return NULL != pForbidden;
      74             : }
      75             : 
      76          99 : void SvxUnoForbiddenCharsTable::setForbiddenCharacters(const lang::Locale& rLocale, const ForbiddenCharacters& rForbiddenCharacters )
      77             :     throw(RuntimeException, std::exception)
      78             : {
      79          99 :     SolarMutexGuard aGuard;
      80             : 
      81          99 :     if(!mxForbiddenChars.is())
      82           0 :         throw RuntimeException();
      83             : 
      84          99 :     const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
      85          99 :     mxForbiddenChars->SetForbiddenCharacters( eLang, rForbiddenCharacters );
      86             : 
      87          99 :     onChange();
      88          99 : }
      89             : 
      90           0 : void SvxUnoForbiddenCharsTable::removeForbiddenCharacters( const lang::Locale& rLocale )
      91             :     throw(RuntimeException, std::exception)
      92             : {
      93           0 :     SolarMutexGuard aGuard;
      94             : 
      95           0 :     if(!mxForbiddenChars.is())
      96           0 :         throw RuntimeException();
      97             : 
      98           0 :     const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
      99           0 :     mxForbiddenChars->ClearForbiddenCharacters( eLang );
     100             : 
     101           0 :     onChange();
     102           0 : }
     103             : 
     104             : // XSupportedLocales
     105         116 : Sequence< lang::Locale > SAL_CALL SvxUnoForbiddenCharsTable::getLocales()
     106             :     throw(RuntimeException, std::exception)
     107             : {
     108         116 :     SolarMutexGuard aGuard;
     109             : 
     110         116 :     const sal_Int32 nCount = mxForbiddenChars.is() ? mxForbiddenChars->GetMap().size() : 0;
     111             : 
     112         116 :     Sequence< lang::Locale > aLocales( nCount );
     113         116 :     if( nCount )
     114             :     {
     115          11 :         lang::Locale* pLocales = aLocales.getArray();
     116             : 
     117          75 :         for( SvxForbiddenCharactersTable::Map::iterator it = mxForbiddenChars->GetMap().begin();
     118          50 :              it != mxForbiddenChars->GetMap().end(); ++it )
     119             :         {
     120          14 :             const sal_uLong nLanguage = it->first;
     121          14 :             *pLocales++ = LanguageTag( static_cast < LanguageType > (nLanguage) ).getLocale();
     122             :         }
     123             :     }
     124             : 
     125         116 :     return aLocales;
     126             : }
     127             : 
     128           0 : sal_Bool SAL_CALL SvxUnoForbiddenCharsTable::hasLocale( const lang::Locale& aLocale )
     129             :     throw(RuntimeException, std::exception)
     130             : {
     131           0 :     SolarMutexGuard aGuard;
     132             : 
     133           0 :     return hasForbiddenCharacters( aLocale );
     134             : }
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11