LCOV - code coverage report
Current view: top level - editeng/source/uno - UnoForbiddenCharsTable.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 37 54 68.5 %
Date: 2014-11-03 Functions: 8 12 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 <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         660 : SvxUnoForbiddenCharsTable::SvxUnoForbiddenCharsTable(::rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars) :
      34         660 :     mxForbiddenChars( xForbiddenChars )
      35             : {
      36         660 : }
      37             : 
      38         658 : SvxUnoForbiddenCharsTable::~SvxUnoForbiddenCharsTable()
      39             : {
      40         658 : }
      41             : 
      42           0 : void SvxUnoForbiddenCharsTable::onChange()
      43             : {
      44           0 : }
      45             : 
      46          12 : ForbiddenCharacters SvxUnoForbiddenCharsTable::getForbiddenCharacters( const Locale& rLocale )
      47             :     throw(NoSuchElementException, RuntimeException, std::exception)
      48             : {
      49          12 :     SolarMutexGuard aGuard;
      50             : 
      51          12 :     if(!mxForbiddenChars.is())
      52           0 :         throw RuntimeException();
      53             : 
      54          12 :     const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
      55          12 :     const ForbiddenCharacters* pForbidden = mxForbiddenChars->GetForbiddenCharacters( eLang, false );
      56          12 :     if(!pForbidden)
      57           0 :         throw NoSuchElementException();
      58             : 
      59          12 :     return *pForbidden;
      60             : }
      61             : 
      62          20 : sal_Bool SvxUnoForbiddenCharsTable::hasForbiddenCharacters( const Locale& rLocale )
      63             :     throw(RuntimeException, std::exception)
      64             : {
      65          20 :     SolarMutexGuard aGuard;
      66             : 
      67          20 :     if(!mxForbiddenChars.is())
      68           0 :         return sal_False;
      69             : 
      70          20 :     const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
      71          20 :     const ForbiddenCharacters* pForbidden = mxForbiddenChars->GetForbiddenCharacters( eLang, false );
      72             : 
      73          20 :     return NULL != pForbidden;
      74             : }
      75             : 
      76          92 : void SvxUnoForbiddenCharsTable::setForbiddenCharacters(const Locale& rLocale, const ForbiddenCharacters& rForbiddenCharacters )
      77             :     throw(RuntimeException, std::exception)
      78             : {
      79          92 :     SolarMutexGuard aGuard;
      80             : 
      81          92 :     if(!mxForbiddenChars.is())
      82           0 :         throw RuntimeException();
      83             : 
      84          92 :     const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
      85          92 :     mxForbiddenChars->SetForbiddenCharacters( eLang, rForbiddenCharacters );
      86             : 
      87          92 :     onChange();
      88          92 : }
      89             : 
      90           0 : void SvxUnoForbiddenCharsTable::removeForbiddenCharacters( const 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         128 : Sequence< Locale > SAL_CALL SvxUnoForbiddenCharsTable::getLocales()
     106             :     throw(RuntimeException, std::exception)
     107             : {
     108         128 :     SolarMutexGuard aGuard;
     109             : 
     110         128 :     const sal_Int32 nCount = mxForbiddenChars.is() ? mxForbiddenChars->GetMap().size() : 0;
     111             : 
     112         128 :     Sequence< Locale > aLocales( nCount );
     113         128 :     if( nCount )
     114             :     {
     115          12 :         Locale* pLocales = aLocales.getArray();
     116             : 
     117          72 :         for( SvxForbiddenCharactersTable::Map::iterator it = mxForbiddenChars->GetMap().begin();
     118          48 :              it != mxForbiddenChars->GetMap().end(); ++it )
     119             :         {
     120          12 :             const sal_uLong nLanguage = it->first;
     121          12 :             *pLocales++ = LanguageTag( static_cast < LanguageType > (nLanguage) ).getLocale();
     122             :         }
     123             :     }
     124             : 
     125         128 :     return aLocales;
     126             : }
     127             : 
     128           0 : sal_Bool SAL_CALL SvxUnoForbiddenCharsTable::hasLocale( const Locale& aLocale )
     129             :     throw(RuntimeException, std::exception)
     130             : {
     131           0 :     SolarMutexGuard aGuard;
     132             : 
     133           0 :     return hasForbiddenCharacters( aLocale );
     134         669 : }
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10