fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / linguistic / misc.hxx
blob8e7b4b1353f1320421691b61cdd5936adbb84e3e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _LINGUISTIC_MISC_HXX_
21 #define _LINGUISTIC_MISC_HXX_
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>
34 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
35 #include <cppuhelper/implbase1.hxx> // helper for implementations
36 #include <unotools/pathoptions.hxx>
37 #include <i18nlangtag/lang.h>
38 #include <tools/string.hxx>
39 #include <unotools/charclass.hxx>
40 #include <osl/thread.h>
41 #include <osl/mutex.hxx>
42 #include <linguistic/lngdllapi.h>
44 namespace com { namespace sun { namespace star { namespace beans {
45 class XPropertySet;
46 class XFastPropertySet;
47 }}}}
49 namespace com { namespace sun { namespace star { namespace frame {
50 class XDesktop2;
51 }}}}
53 class LocaleDataWrapper;
56 #define SN_GRAMMARCHECKER "com.sun.star.linguistic2.Proofreader"
57 #define SN_SPELLCHECKER "com.sun.star.linguistic2.SpellChecker"
58 #define SN_HYPHENATOR "com.sun.star.linguistic2.Hyphenator"
59 #define SN_THESAURUS "com.sun.star.linguistic2.Thesaurus"
62 namespace linguistic
65 /// Flags to be used with the multi-path related functions
66 /// @see GetDictionaryPaths
67 #define PATH_FLAG_INTERNAL 0x01
68 #define PATH_FLAG_USER 0x02
69 #define PATH_FLAG_WRITABLE 0x04
70 #define PATH_FLAG_ALL (PATH_FLAG_INTERNAL | PATH_FLAG_USER | PATH_FLAG_WRITABLE)
73 // AddEntryToDic return values
74 #define DIC_ERR_NONE 0
75 #define DIC_ERR_FULL 1
76 #define DIC_ERR_READONLY 2
77 #define DIC_ERR_UNKNOWN 3
78 #define DIC_ERR_NOT_EXISTS 4
80 // values asigned to capitalization types
81 enum CapType
83 CAPTYPE_UNKNOWN,
84 CAPTYPE_NOCAP,
85 CAPTYPE_INITCAP,
86 CAPTYPE_ALLCAP,
87 CAPTYPE_MIXED
90 LNG_DLLPUBLIC ::osl::Mutex& GetLinguMutex();
92 LocaleDataWrapper & GetLocaleDataWrapper( sal_Int16 nLang );
94 sal_Int32 LevDistance( const OUString &rTxt1, const OUString &rTxt2 );
96 /** Convert Locale to LanguageType for legacy handling.
97 Linguistic specific handling of an empty locale denoting LANGUAGE_NONE.
98 Does not resolve empty locale as system locale.
100 LNG_DLLPUBLIC LanguageType LinguLocaleToLanguage( const ::com::sun::star::lang::Locale& rLocale );
102 /** Convert LanguageType to Locale for legacy handling.
103 Linguistic specific handling of LANGUAGE_NONE resulting in an empty locale.
104 Avoid use!
106 LNG_DLLPUBLIC ::com::sun::star::lang::Locale LinguLanguageToLocale( LanguageType nLanguage );
108 /** Checks if a LanguageType is one of the values that denote absence of
109 language or undetermined language or multiple languages, in short all
110 values used in linguistic context that do not denote a specific language.
112 LNG_DLLPUBLIC bool LinguIsUnspecified( LanguageType nLanguage );
114 ::com::sun::star::uno::Sequence< sal_Int16 >
115 LocaleSeqToLangSeq( ::com::sun::star::uno::Sequence<
116 ::com::sun::star::lang::Locale > &rLocaleSeq );
118 // checks if file pointed to by rURL is readonly
119 // and may also check return if such a file exists or not
120 sal_Bool IsReadOnly( const String &rURL, sal_Bool *pbExist = 0 );
122 // checks if a file with the given URL exists
123 sal_Bool FileExists( const String &rURL );
126 OUString GetDictionaryWriteablePath();
127 ::com::sun::star::uno::Sequence< OUString > GetDictionaryPaths( sal_Int16 nPathFlags = PATH_FLAG_ALL );
129 /// @returns an URL for a new and writable dictionary rDicName.
130 /// The URL will point to the path given by 'GetDictionaryWriteablePath'
131 LNG_DLLPUBLIC String GetWritableDictionaryURL( const String &rDicName );
133 LNG_DLLPUBLIC sal_Int32 GetPosInWordToCheck( const OUString &rTxt, sal_Int32 nPos );
135 ::com::sun::star::uno::Reference<
136 ::com::sun::star::linguistic2::XHyphenatedWord >
137 RebuildHyphensAndControlChars( const OUString &rOrigWord,
138 ::com::sun::star::uno::Reference<
139 ::com::sun::star::linguistic2::XHyphenatedWord > &rxHyphWord );
142 LNG_DLLPUBLIC sal_Bool IsUpper( const String &rText, xub_StrLen nPos, xub_StrLen nLen, sal_Int16 nLanguage );
144 inline sal_Bool IsUpper( const String &rText, sal_Int16 nLanguage ) { return IsUpper( rText, 0, rText.Len(), nLanguage ); }
145 LNG_DLLPUBLIC CapType SAL_CALL capitalType(const OUString&, CharClass *);
147 String ToLower( const String &rText, sal_Int16 nLanguage );
148 LNG_DLLPUBLIC sal_Bool HasDigits( const OUString &rText );
149 LNG_DLLPUBLIC sal_Bool IsNumeric( const String &rText );
152 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > GetOneInstanceService( const char *pServiceName );
153 LNG_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLinguProperties > GetLinguProperties();
154 ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList > GetDictionaryList();
155 ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > GetIgnoreAllList();
158 sal_Bool IsUseDicList( const ::com::sun::star::beans::PropertyValues &rProperties,
159 const ::com::sun::star::uno::Reference<
160 ::com::sun::star::beans::XPropertySet > &rxPropSet );
162 sal_Bool IsIgnoreControlChars( const ::com::sun::star::beans::PropertyValues &rProperties,
163 const ::com::sun::star::uno::Reference<
164 ::com::sun::star::beans::XPropertySet > &rxPropSet );
166 ::com::sun::star::uno::Reference<
167 ::com::sun::star::linguistic2::XDictionaryEntry >
168 SearchDicList(
169 const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList >& rDicList,
170 const OUString& rWord, sal_Int16 nLanguage,
171 sal_Bool bSearchPosDics, sal_Bool bSearchSpellEntry );
173 LNG_DLLPUBLIC sal_uInt8 AddEntryToDic(
174 ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > &rxDic,
175 const OUString &rWord, sal_Bool bIsNeg,
176 const OUString &rRplcTxt, sal_Int16 nRplcLang,
177 sal_Bool bStripDot = sal_True );
179 LNG_DLLPUBLIC sal_Bool SaveDictionaries( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList > &xDicList );
181 // AppExitLstnr:
182 // virtual base class that calls it AtExit function when the application
183 // (ie the Desktop) is about to terminate
185 class AppExitListener :
186 public cppu::WeakImplHelper1
188 ::com::sun::star::frame::XTerminateListener
191 ::com::sun::star::uno::Reference<
192 ::com::sun::star::frame::XDesktop2 > xDesktop;
194 public:
195 AppExitListener();
196 virtual ~AppExitListener();
198 virtual void AtExit() = 0;
200 void Activate();
201 void Deactivate();
203 // XEventListener
204 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
206 // XTerminateListener
207 virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
208 virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException);
211 } // namespace linguistic
213 #endif
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */