LCOV - code coverage report
Current view: top level - sw/inc - breakit.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 25 0.0 %
Date: 2014-04-14 Functions: 0 7 0.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             : #ifndef INCLUDED_SW_INC_BREAKIT_HXX
      21             : #define INCLUDED_SW_INC_BREAKIT_HXX
      22             : 
      23             : #include <boost/noncopyable.hpp>
      24             : #include <com/sun/star/uno/Reference.h>
      25             : #include <com/sun/star/uno/XComponentContext.hpp>
      26             : #include <com/sun/star/i18n/XBreakIterator.hpp>
      27             : #include <com/sun/star/i18n/XScriptTypeDetector.hpp>
      28             : #include <com/sun/star/i18n/ForbiddenCharacters.hpp>
      29             : #include <i18nlangtag/languagetag.hxx>
      30             : #include <swdllapi.h>
      31             : 
      32             : /*************************************************************************
      33             :  *                      class SwBreakIt
      34             :  *************************************************************************/
      35             : 
      36             : class SW_DLLPUBLIC SwBreakIt : private ::boost::noncopyable
      37             : {
      38             :     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
      39             :     mutable com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > xBreak;
      40             : 
      41             :     LanguageTag * m_pLanguageTag;   ///< language tag of the current locale
      42             :     com::sun::star::i18n::ForbiddenCharacters * m_pForbidden;
      43             : 
      44             :     LanguageType aForbiddenLang; ///< language of the current forbiddenChar struct
      45             : 
      46             :     void _GetLocale( const LanguageType aLang );
      47             :     void _GetLocale( const LanguageTag& rLanguageTag );
      48             :     void _GetForbidden( const LanguageType  aLang );
      49             : 
      50             :     void createBreakIterator() const;
      51             : 
      52             :     // private (see @ _Create, _Delete).
      53             :     explicit SwBreakIt(
      54             :         const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & rxContext);
      55             :     ~SwBreakIt();
      56             : 
      57             : public:
      58             :     // private (see @ source/core/bastyp/init.cxx).
      59             :     static void _Create(
      60             :         const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & rxContext);
      61             :     static void _Delete();
      62             : 
      63             : public:
      64             :     static SwBreakIt * Get();
      65             : 
      66           0 :     com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > GetBreakIter()
      67             :     {
      68           0 :         createBreakIterator();
      69           0 :         return xBreak;
      70             :     }
      71             : 
      72           0 :     const com::sun::star::lang::Locale& GetLocale( const LanguageType aLang )
      73             :     {
      74           0 :         if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != aLang )
      75           0 :             _GetLocale( aLang );
      76           0 :         return m_pLanguageTag->getLocale();
      77             :     }
      78             : 
      79           0 :     const com::sun::star::lang::Locale& GetLocale( const LanguageTag& rLanguageTag )
      80             :     {
      81             :         // Use LanguageType comparison instead of LanguageTag::operator!=()
      82             :         // because here the LanguageTag is already a known LanguageType value
      83             :         // assigned, so LanguageTag does not need to convert to BCP47 for
      84             :         // comparison.
      85           0 :         if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != rLanguageTag.getLanguageType() )
      86           0 :             _GetLocale( rLanguageTag );
      87           0 :         return m_pLanguageTag->getLocale();
      88             :     }
      89             : 
      90           0 :     const LanguageTag& GetLanguageTag( const LanguageType aLang )
      91             :     {
      92           0 :         if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != aLang )
      93           0 :             _GetLocale( aLang );
      94           0 :         return *m_pLanguageTag;
      95             :     }
      96             : 
      97           0 :     const LanguageTag& GetLanguageTag( const LanguageTag& rLanguageTag )
      98             :     {
      99             :         // Use LanguageType comparison instead of LanguageTag::operator!=()
     100             :         // because here the LanguageTag is already a known LanguageType value
     101             :         // assigned, so LanguageTag does not need to convert to BCP47 for
     102             :         // comparison.
     103           0 :         if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != rLanguageTag.getLanguageType() )
     104           0 :             _GetLocale( rLanguageTag );
     105           0 :         return *m_pLanguageTag;
     106             :     }
     107             : 
     108           0 :     const com::sun::star::i18n::ForbiddenCharacters& GetForbidden( const LanguageType aLang )
     109             :     {
     110           0 :         if( !m_pForbidden || aForbiddenLang != aLang )
     111           0 :             _GetForbidden( aLang );
     112           0 :         return *m_pForbidden;
     113             :     }
     114             : 
     115             :     sal_uInt16 GetRealScriptOfText( const OUString& rTxt, sal_Int32 nPos ) const;
     116             :     sal_uInt16 GetAllScriptsOfText( const OUString& rTxt ) const;
     117             : 
     118             :     sal_Int32 getGraphemeCount(const OUString& rStr,
     119             :         sal_Int32 nStart, sal_Int32 nEnd) const;
     120           0 :     sal_Int32 getGraphemeCount(const OUString& rStr) const
     121             :     {
     122           0 :         return getGraphemeCount(rStr, 0, rStr.getLength());
     123             :     }
     124             : };
     125             : 
     126             : #define SW_BREAKITER()  SwBreakIt::Get()
     127             : 
     128             : // @@@ backward compatibility @@@
     129             : SW_DLLPUBLIC extern SwBreakIt* g_pBreakIt;
     130             : 
     131             : #endif
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10