LCOV - code coverage report
Current view: top level - include/linguistic - misc.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 1 100.0 %
Date: 2014-11-03 Functions: 1 1 100.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_LINGUISTIC_MISC_HXX
      21             : #define INCLUDED_LINGUISTIC_MISC_HXX
      22             : 
      23             : #include <com/sun/star/uno/Sequence.h>
      24             : #include <com/sun/star/uno/Reference.h>
      25             : #include <com/sun/star/beans/PropertyValues.hpp>
      26             : #include <com/sun/star/frame/XTerminateListener.hpp>
      27             : #include <com/sun/star/lang/Locale.hpp>
      28             : #include <com/sun/star/lang/XComponent.hpp>
      29             : #include <com/sun/star/linguistic2/XDictionaryEntry.hpp>
      30             : #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
      31             : #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
      32             : #include <com/sun/star/linguistic2/XLinguProperties.hpp>
      33             : 
      34             : #include <cppuhelper/implbase1.hxx>
      35             : #include <unotools/pathoptions.hxx>
      36             : #include <i18nlangtag/lang.h>
      37             : #include <rtl/ustring.hxx>
      38             : #include <unotools/charclass.hxx>
      39             : #include <osl/thread.h>
      40             : #include <osl/mutex.hxx>
      41             : #include <linguistic/lngdllapi.h>
      42             : 
      43             : namespace com { namespace sun { namespace star { namespace beans {
      44             :     class XPropertySet;
      45             :     class XFastPropertySet;
      46             : }}}}
      47             : 
      48             : namespace com { namespace sun { namespace star { namespace frame {
      49             :     class XDesktop2;
      50             : }}}}
      51             : 
      52             : class LocaleDataWrapper;
      53             : 
      54             : 
      55             : #define SN_GRAMMARCHECKER           "com.sun.star.linguistic2.Proofreader"
      56             : #define SN_SPELLCHECKER             "com.sun.star.linguistic2.SpellChecker"
      57             : #define SN_HYPHENATOR               "com.sun.star.linguistic2.Hyphenator"
      58             : #define SN_THESAURUS                "com.sun.star.linguistic2.Thesaurus"
      59             : 
      60             : 
      61             : namespace linguistic
      62             : {
      63             : 
      64             : /// Flags to be used with the multi-path related functions
      65             : /// @see GetDictionaryPaths
      66             : #define PATH_FLAG_INTERNAL  0x01
      67             : #define PATH_FLAG_USER      0x02
      68             : #define PATH_FLAG_WRITABLE  0x04
      69             : #define PATH_FLAG_ALL       (PATH_FLAG_INTERNAL | PATH_FLAG_USER | PATH_FLAG_WRITABLE)
      70             : 
      71             : 
      72             : // AddEntryToDic return values
      73             : #define DIC_ERR_NONE        0
      74             : #define DIC_ERR_FULL        1
      75             : #define DIC_ERR_READONLY    2
      76             : #define DIC_ERR_UNKNOWN     3
      77             : #define DIC_ERR_NOT_EXISTS  4
      78             : 
      79             : // values asigned to capitalization types
      80             : enum CapType
      81             : {
      82             :     CAPTYPE_UNKNOWN,
      83             :     CAPTYPE_NOCAP,
      84             :     CAPTYPE_INITCAP,
      85             :     CAPTYPE_ALLCAP,
      86             :     CAPTYPE_MIXED
      87             : };
      88             : 
      89             : LNG_DLLPUBLIC ::osl::Mutex& GetLinguMutex();
      90             : 
      91             : LocaleDataWrapper & GetLocaleDataWrapper( sal_Int16 nLang );
      92             : 
      93             : sal_Int32 LevDistance( const OUString &rTxt1, const OUString &rTxt2 );
      94             : 
      95             : /** Convert Locale to LanguageType for legacy handling.
      96             :     Linguistic specific handling of an empty locale denoting LANGUAGE_NONE.
      97             :     Does not resolve empty locale as system locale.
      98             :  */
      99             : LNG_DLLPUBLIC LanguageType LinguLocaleToLanguage( const ::com::sun::star::lang::Locale& rLocale );
     100             : 
     101             : /** Convert LanguageType to Locale for legacy handling.
     102             :     Linguistic specific handling of LANGUAGE_NONE resulting in an empty locale.
     103             :     Avoid use!
     104             :  */
     105             : LNG_DLLPUBLIC ::com::sun::star::lang::Locale LinguLanguageToLocale( LanguageType nLanguage );
     106             : 
     107             : /** Checks if a LanguageType is one of the values that denote absence of
     108             :     language or undetermined language or multiple languages, in short all
     109             :     values used in linguistic context that do not denote a specific language.
     110             :  */
     111             : LNG_DLLPUBLIC bool LinguIsUnspecified( LanguageType nLanguage );
     112             : 
     113             : /** The same as LinguIsUnspecified(LanguageType) but taking a BCP 47 language
     114             :     tag string instead. */
     115             : LNG_DLLPUBLIC bool LinguIsUnspecified( const OUString & rBcp47 );
     116             : 
     117             : ::com::sun::star::uno::Sequence< sal_Int16 >
     118             :     LocaleSeqToLangSeq( ::com::sun::star::uno::Sequence<
     119             :         ::com::sun::star::lang::Locale > &rLocaleSeq );
     120             : 
     121             : // checks if file pointed to by rURL is readonly
     122             : // and may also check return if such a file exists or not
     123             : bool    IsReadOnly( const OUString &rURL, bool *pbExist = 0 );
     124             : 
     125             : // checks if a file with the given URL exists
     126             : bool    FileExists( const OUString &rURL );
     127             : 
     128             : 
     129             : OUString     GetDictionaryWriteablePath();
     130             : ::com::sun::star::uno::Sequence< OUString > GetDictionaryPaths( sal_Int16 nPathFlags = PATH_FLAG_ALL );
     131             : 
     132             : /// @returns an URL for a new and writable dictionary rDicName.
     133             : ///     The URL will point to the path given by 'GetDictionaryWriteablePath'
     134             : LNG_DLLPUBLIC OUString  GetWritableDictionaryURL( const OUString &rDicName );
     135             : 
     136             : LNG_DLLPUBLIC sal_Int32 GetPosInWordToCheck( const OUString &rTxt, sal_Int32 nPos );
     137             : 
     138             : ::com::sun::star::uno::Reference<
     139             :     ::com::sun::star::linguistic2::XHyphenatedWord >
     140             :             RebuildHyphensAndControlChars( const OUString &rOrigWord,
     141             :                 ::com::sun::star::uno::Reference<
     142             :                     ::com::sun::star::linguistic2::XHyphenatedWord > &rxHyphWord );
     143             : 
     144             : 
     145             : LNG_DLLPUBLIC bool        IsUpper( const OUString &rText, sal_Int32 nPos, sal_Int32 nLen, sal_Int16 nLanguage );
     146             : 
     147        6805 : inline bool        IsUpper( const OUString &rText, sal_Int16 nLanguage )     { return IsUpper( rText, 0, rText.getLength(), nLanguage ); }
     148             : LNG_DLLPUBLIC CapType SAL_CALL capitalType(const OUString&, CharClass *);
     149             : 
     150             : OUString      ToLower( const OUString &rText, sal_Int16 nLanguage );
     151             : LNG_DLLPUBLIC bool      HasDigits( const OUString &rText );
     152             : LNG_DLLPUBLIC bool      IsNumeric( const OUString &rText );
     153             : 
     154             : 
     155             : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > GetOneInstanceService( const char *pServiceName );
     156             : LNG_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLinguProperties > GetLinguProperties();
     157             : ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList > GetDictionaryList();
     158             : ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > GetIgnoreAllList();
     159             : 
     160             : 
     161             : bool IsUseDicList( const ::com::sun::star::beans::PropertyValues &rProperties,
     162             :         const ::com::sun::star::uno::Reference<
     163             :             ::com::sun::star::beans::XPropertySet > &rxPropSet );
     164             : 
     165             : bool IsIgnoreControlChars( const ::com::sun::star::beans::PropertyValues &rProperties,
     166             :         const ::com::sun::star::uno::Reference<
     167             :             ::com::sun::star::beans::XPropertySet > &rxPropSet );
     168             : 
     169             : ::com::sun::star::uno::Reference<
     170             :     ::com::sun::star::linguistic2::XDictionaryEntry >
     171             :         SearchDicList(
     172             :             const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList >& rDicList,
     173             :             const OUString& rWord, sal_Int16 nLanguage,
     174             :             bool bSearchPosDics, bool bSearchSpellEntry );
     175             : 
     176             : LNG_DLLPUBLIC sal_uInt8 AddEntryToDic(
     177             :     ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary >  &rxDic,
     178             :     const OUString &rWord, bool bIsNeg,
     179             :     const OUString &rRplcTxt, sal_Int16 nRplcLang,
     180             :     bool bStripDot = true );
     181             : 
     182             : LNG_DLLPUBLIC bool SaveDictionaries( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList > &xDicList );
     183             : 
     184             : // AppExitLstnr:
     185             : // virtual base class that calls it AtExit function when the application
     186             : // (ie the Desktop) is about to terminate
     187             : 
     188             : class AppExitListener :
     189             :     public cppu::WeakImplHelper1
     190             :     <
     191             :         ::com::sun::star::frame::XTerminateListener
     192             :     >
     193             : {
     194             :     ::com::sun::star::uno::Reference<
     195             :         ::com::sun::star::frame::XDesktop2 >     xDesktop;
     196             : 
     197             : public:
     198             :     AppExitListener();
     199             :     virtual ~AppExitListener();
     200             : 
     201             :     virtual void    AtExit() = 0;
     202             : 
     203             :     void            Activate();
     204             :     void            Deactivate();
     205             : 
     206             :     // XEventListener
     207             :     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     208             : 
     209             :     // XTerminateListener
     210             :     virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     211             :     virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     212             : };
     213             : 
     214             : }   // namespace linguistic
     215             : 
     216             : #endif
     217             : 
     218             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10