LCOV - code coverage report
Current view: top level - sw/inc - breakit.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 13 100.0 %
Date: 2012-08-25 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 8 100.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _BREAKIT_HXX
      30                 :            : #define _BREAKIT_HXX
      31                 :            : 
      32                 :            : #include <boost/noncopyable.hpp>
      33                 :            : #include <com/sun/star/uno/Reference.h>
      34                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      35                 :            : #include <com/sun/star/i18n/XBreakIterator.hpp>
      36                 :            : #include <com/sun/star/i18n/XScriptTypeDetector.hpp>
      37                 :            : #include <com/sun/star/i18n/ForbiddenCharacters.hpp>
      38                 :            : #include <i18npool/lang.h>
      39                 :            : #include <swdllapi.h>
      40                 :            : 
      41                 :            : /*************************************************************************
      42                 :            :  *                      class SwBreakIt
      43                 :            :  *************************************************************************/
      44                 :            : 
      45                 :            : 
      46                 :            : class SW_DLLPUBLIC SwBreakIt : private ::boost::noncopyable
      47                 :            : {
      48                 :            :     com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMSF;
      49                 :            :     mutable com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > xBreak;
      50                 :            : 
      51                 :            :     com::sun::star::lang::Locale * m_pLocale;
      52                 :            :     com::sun::star::i18n::ForbiddenCharacters * m_pForbidden;
      53                 :            : 
      54                 :            :     LanguageType aLast;          ///< language of the current locale
      55                 :            :     LanguageType aForbiddenLang; ///< language of the current forbiddenChar struct
      56                 :            : 
      57                 :            :     void _GetLocale( const LanguageType aLang );
      58                 :            :     void _GetForbidden( const LanguageType  aLang );
      59                 :            : 
      60                 :            :     void createBreakIterator() const;
      61                 :            : 
      62                 :            :     // private (see @ _Create, _Delete).
      63                 :            :     explicit SwBreakIt(
      64                 :            :         const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rxMSF);
      65                 :            :     ~SwBreakIt();
      66                 :            : 
      67                 :            : public:
      68                 :            :     // private (see @ source/core/bastyp/init.cxx).
      69                 :            :     static void _Create(
      70                 :            :         const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rxMSF);
      71                 :            :     static void _Delete();
      72                 :            : 
      73                 :            : public:
      74                 :            :     static SwBreakIt * Get();
      75                 :            : 
      76                 :     987466 :     com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > GetBreakIter()
      77                 :            :     {
      78                 :     987466 :         createBreakIterator();
      79                 :     987466 :         return xBreak;
      80                 :            :     }
      81                 :            : 
      82                 :     349986 :     const com::sun::star::lang::Locale& GetLocale( const LanguageType aLang )
      83                 :            :     {
      84 [ +  + ][ +  + ]:     349986 :         if( !m_pLocale || aLast != aLang )
      85                 :        795 :             _GetLocale( aLang );
      86                 :     349986 :         return *m_pLocale;
      87                 :            :     }
      88                 :            : 
      89                 :      39611 :     const com::sun::star::i18n::ForbiddenCharacters& GetForbidden( const LanguageType aLang )
      90                 :            :     {
      91 [ +  + ][ +  + ]:      39611 :         if( !m_pForbidden || aForbiddenLang != aLang )
      92                 :         37 :             _GetForbidden( aLang );
      93                 :      39611 :         return *m_pForbidden;
      94                 :            :     }
      95                 :            : 
      96                 :            :     sal_uInt16 GetRealScriptOfText( const rtl::OUString& rTxt, sal_Int32 nPos ) const;
      97                 :            :     sal_uInt16 GetAllScriptsOfText( const rtl::OUString& rTxt ) const;
      98                 :            : 
      99                 :            :     sal_Int32 getGraphemeCount(const rtl::OUString& rStr,
     100                 :            :         sal_Int32 nStart, sal_Int32 nEnd) const;
     101                 :      69284 :     sal_Int32 getGraphemeCount(const rtl::OUString& rStr) const
     102                 :            :     {
     103                 :      69284 :         return getGraphemeCount(rStr, 0, rStr.getLength());
     104                 :            :     }
     105                 :            : };
     106                 :            : 
     107                 :            : #define SW_BREAKITER()  SwBreakIt::Get()
     108                 :            : 
     109                 :            : // @@@ backward compatibility @@@
     110                 :            : SW_DLLPUBLIC extern SwBreakIt* pBreakIt;
     111                 :            : 
     112                 :            : #endif
     113                 :            : 
     114                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10