LCOV - code coverage report
Current view: top level - libreoffice/i18npool/inc - collatorImpl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 8 37.5 %
Date: 2012-12-27 Functions: 2 3 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             : #ifndef _I18N_COLLATORIMPL_HXX_
      20             : #define _I18N_COLLATORIMPL_HXX_
      21             : 
      22             : #include <comphelper/processfactory.hxx>
      23             : #include <com/sun/star/uno/Reference.h>
      24             : #include <com/sun/star/i18n/XLocaleData4.hpp>
      25             : #include <com/sun/star/i18n/XCollator.hpp>
      26             : #include <com/sun/star/lang/Locale.hpp>
      27             : #include <cppuhelper/weak.hxx>
      28             : #include <cppuhelper/implbase2.hxx>
      29             : #include <com/sun/star/lang/XServiceInfo.hpp>
      30             : #include <sal/alloca.h>
      31             : #include <vector>
      32             : 
      33             : namespace com { namespace sun { namespace star { namespace i18n {
      34             : //      ----------------------------------------------------
      35             : //      class CollatorImpl
      36             : //      ----------------------------------------------------
      37             : class CollatorImpl : public cppu::WeakImplHelper2
      38             : <
      39             :     XCollator,
      40             :     com::sun::star::lang::XServiceInfo
      41             : >
      42             : {
      43             : public:
      44             : 
      45             :     // Constructors
      46             :     CollatorImpl( const com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext >& rxContext );
      47             :     // Destructor
      48             :     ~CollatorImpl();
      49             : 
      50             :     virtual sal_Int32 SAL_CALL compareSubstring(const rtl::OUString& s1, sal_Int32 off1, sal_Int32 len1,
      51             :         const rtl::OUString& s2, sal_Int32 off2, sal_Int32 len2) throw(com::sun::star::uno::RuntimeException);
      52             : 
      53             :     virtual sal_Int32 SAL_CALL compareString( const rtl::OUString& s1,
      54             :         const rtl::OUString& s2) throw(com::sun::star::uno::RuntimeException);
      55             : 
      56             :     virtual sal_Int32 SAL_CALL loadDefaultCollator( const lang::Locale& rLocale,  sal_Int32 collatorOptions)
      57             :         throw(com::sun::star::uno::RuntimeException);
      58             : 
      59             :     virtual sal_Int32 SAL_CALL loadCollatorAlgorithm(  const rtl::OUString& impl, const lang::Locale& rLocale,
      60             :         sal_Int32 collatorOptions) throw(com::sun::star::uno::RuntimeException);
      61             : 
      62             :     virtual void SAL_CALL loadCollatorAlgorithmWithEndUserOption( const rtl::OUString& impl, const lang::Locale& rLocale,
      63             :         const com::sun::star::uno::Sequence< sal_Int32 >& collatorOptions) throw(com::sun::star::uno::RuntimeException);
      64             : 
      65             :     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL listCollatorAlgorithms( const lang::Locale& rLocale )
      66             :         throw(com::sun::star::uno::RuntimeException);
      67             : 
      68             :     virtual com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL listCollatorOptions( const rtl::OUString& collatorAlgorithmName )
      69             :         throw(com::sun::star::uno::RuntimeException);
      70             : 
      71             :     //XServiceInfo
      72             :     virtual rtl::OUString SAL_CALL getImplementationName() throw( com::sun::star::uno::RuntimeException );
      73             :     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( com::sun::star::uno::RuntimeException );
      74             :     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( com::sun::star::uno::RuntimeException );
      75             : 
      76             : protected:
      77             :     lang::Locale nLocale;
      78             : private :
      79           3 :     struct lookupTableItem {
      80             :         lang::Locale aLocale;
      81             :         rtl::OUString algorithm;
      82             :         rtl::OUString service;
      83             :         com::sun::star::uno::Reference < XCollator > xC;
      84           8 :         lookupTableItem(const lang::Locale& rLocale, const rtl::OUString& _algorithm, const rtl::OUString& _service,
      85           8 :         com::sun::star::uno::Reference < XCollator >& _xC) : aLocale(rLocale), algorithm(_algorithm), service(_service), xC(_xC) {}
      86           0 :         sal_Bool SAL_CALL equals(const lang::Locale& rLocale, const rtl::OUString& _algorithm) {
      87           0 :         return aLocale.Language == rLocale.Language &&
      88           0 :             aLocale.Country == rLocale.Country &&
      89           0 :             aLocale.Variant == rLocale.Variant &&
      90           0 :             algorithm == _algorithm;
      91             :         }
      92             :     };
      93             :     std::vector<lookupTableItem*> lookupTable;
      94             :     lookupTableItem *cachedItem;
      95             : 
      96             :     // Service Factory
      97             :     com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xContext;
      98             :     // lang::Locale Data
      99             :     com::sun::star::uno::Reference < XLocaleData4 > mxLocaleData;
     100             : 
     101             :     sal_Bool SAL_CALL createCollator(const lang::Locale& rLocale, const rtl::OUString& serviceName,
     102             :         const rtl::OUString& rSortAlgorithm) throw(com::sun::star::uno::RuntimeException);
     103             :     void SAL_CALL loadCachedCollator(const lang::Locale& rLocale, const rtl::OUString& rSortAlgorithm)
     104             :         throw(com::sun::star::uno::RuntimeException);
     105             : };
     106             : 
     107             : } } } }
     108             : 
     109             : #endif
     110             : 
     111             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10