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 _LINGUISTIC_MISC_HXX_
30 : : #define _LINGUISTIC_MISC_HXX_
31 : :
32 : : #include <com/sun/star/uno/Sequence.h>
33 : : #include <com/sun/star/uno/Reference.h>
34 : : #include <com/sun/star/beans/PropertyValues.hpp>
35 : : #include <com/sun/star/frame/XTerminateListener.hpp>
36 : : #include <com/sun/star/lang/Locale.hpp>
37 : : #include <com/sun/star/lang/XComponent.hpp>
38 : : #include <com/sun/star/linguistic2/XDictionaryEntry.hpp>
39 : : #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
40 : : #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
41 : :
42 : : #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
43 : : #include <cppuhelper/implbase1.hxx> // helper for implementations
44 : : #include <unotools/pathoptions.hxx>
45 : : #include <i18npool/lang.h>
46 : : #include <tools/string.hxx>
47 : : #include <unotools/charclass.hxx>
48 : : #include <osl/thread.h>
49 : : #include <osl/mutex.hxx>
50 : : #include <linguistic/lngdllapi.h>
51 : :
52 : : namespace com { namespace sun { namespace star { namespace beans {
53 : : class XPropertySet;
54 : : class XFastPropertySet;
55 : : }}}}
56 : :
57 : : namespace com { namespace sun { namespace star { namespace frame {
58 : : class XDesktop;
59 : : }}}}
60 : :
61 : : class LocaleDataWrapper;
62 : :
63 : :
64 : : #define SN_GRAMMARCHECKER "com.sun.star.linguistic2.Proofreader"
65 : : #define SN_GRAMMARCHECKINGITERATOR "com.sun.star.linguistic2.ProofreadingIterator"
66 : : #define SN_SPELLCHECKER "com.sun.star.linguistic2.SpellChecker"
67 : : #define SN_HYPHENATOR "com.sun.star.linguistic2.Hyphenator"
68 : : #define SN_THESAURUS "com.sun.star.linguistic2.Thesaurus"
69 : : #define SN_LINGU_SERVCICE_MANAGER "com.sun.star.linguistic2.LinguServiceManager"
70 : : #define SN_LINGU_PROPERTIES "com.sun.star.linguistic2.LinguProperties"
71 : : #define SN_DICTIONARY_LIST "com.sun.star.linguistic2.DictionaryList"
72 : : #define SN_DESKTOP "com.sun.star.frame.Desktop"
73 : :
74 : :
75 : : namespace linguistic
76 : : {
77 : :
78 : : // ascii to OUString conversion
79 : : #define A2OU(x) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( x ))
80 : :
81 : : /// Flags to be used with the multi-path related functions
82 : : /// @see GetDictionaryPaths
83 : : #define PATH_FLAG_INTERNAL 0x01
84 : : #define PATH_FLAG_USER 0x02
85 : : #define PATH_FLAG_WRITABLE 0x04
86 : : #define PATH_FLAG_ALL (PATH_FLAG_INTERNAL | PATH_FLAG_USER | PATH_FLAG_WRITABLE)
87 : :
88 : :
89 : : // AddEntryToDic return values
90 : : #define DIC_ERR_NONE 0
91 : : #define DIC_ERR_FULL 1
92 : : #define DIC_ERR_READONLY 2
93 : : #define DIC_ERR_UNKNOWN 3
94 : : #define DIC_ERR_NOT_EXISTS 4
95 : :
96 : :
97 : : LNG_DLLPUBLIC ::osl::Mutex& GetLinguMutex();
98 : :
99 : : LocaleDataWrapper & GetLocaleDataWrapper( sal_Int16 nLang );
100 : :
101 : : sal_Int32 LevDistance( const rtl::OUString &rTxt1, const rtl::OUString &rTxt2 );
102 : :
103 : : ::com::sun::star::lang::Locale
104 : : CreateLocale( LanguageType eLang );
105 : :
106 : : LNG_DLLPUBLIC LanguageType
107 : : LocaleToLanguage( const ::com::sun::star::lang::Locale& rLocale );
108 : :
109 : : ::com::sun::star::lang::Locale&
110 : : LanguageToLocale( ::com::sun::star::lang::Locale& rLocale, LanguageType eLang );
111 : :
112 : : ::com::sun::star::uno::Sequence< sal_Int16 >
113 : : LocaleSeqToLangSeq( ::com::sun::star::uno::Sequence<
114 : : ::com::sun::star::lang::Locale > &rLocaleSeq );
115 : :
116 : : // checks if file pointed to by rURL is readonly
117 : : // and may also check return if such a file exists or not
118 : : sal_Bool IsReadOnly( const String &rURL, sal_Bool *pbExist = 0 );
119 : :
120 : : // checks if a file with the given URL exists
121 : : sal_Bool FileExists( const String &rURL );
122 : :
123 : :
124 : : ::rtl::OUString GetDictionaryWriteablePath();
125 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > GetDictionaryPaths( sal_Int16 nPathFlags = PATH_FLAG_ALL );
126 : :
127 : : /// @returns an URL for a new and writable dictionary rDicName.
128 : : /// The URL will point to the path given by 'GetDictionaryWriteablePath'
129 : : LNG_DLLPUBLIC String GetWritableDictionaryURL( const String &rDicName );
130 : :
131 : : LNG_DLLPUBLIC sal_Int32 GetPosInWordToCheck( const rtl::OUString &rTxt, sal_Int32 nPos );
132 : :
133 : : ::com::sun::star::uno::Reference<
134 : : ::com::sun::star::linguistic2::XHyphenatedWord >
135 : : RebuildHyphensAndControlChars( const rtl::OUString &rOrigWord,
136 : : ::com::sun::star::uno::Reference<
137 : : ::com::sun::star::linguistic2::XHyphenatedWord > &rxHyphWord );
138 : :
139 : :
140 : : LNG_DLLPUBLIC sal_Bool IsUpper( const String &rText, xub_StrLen nPos, xub_StrLen nLen, sal_Int16 nLanguage );
141 : :
142 : 12613 : inline sal_Bool IsUpper( const String &rText, sal_Int16 nLanguage ) { return IsUpper( rText, 0, rText.Len(), nLanguage ); }
143 : :
144 : : String ToLower( const String &rText, sal_Int16 nLanguage );
145 : : LNG_DLLPUBLIC sal_Bool HasDigits( const ::rtl::OUString &rText );
146 : : LNG_DLLPUBLIC sal_Bool IsNumeric( const String &rText );
147 : :
148 : :
149 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > GetOneInstanceService( const char *pServiceName );
150 : : LNG_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetLinguProperties();
151 : : ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList > GetSearchableDictionaryList();
152 : : ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryList > GetDictionaryList();
153 : : ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > GetIgnoreAllList();
154 : :
155 : :
156 : : sal_Bool IsUseDicList( const ::com::sun::star::beans::PropertyValues &rProperties,
157 : : const ::com::sun::star::uno::Reference<
158 : : ::com::sun::star::beans::XPropertySet > &rxPropSet );
159 : :
160 : : sal_Bool IsIgnoreControlChars( const ::com::sun::star::beans::PropertyValues &rProperties,
161 : : const ::com::sun::star::uno::Reference<
162 : : ::com::sun::star::beans::XPropertySet > &rxPropSet );
163 : :
164 : : ::com::sun::star::uno::Reference<
165 : : ::com::sun::star::linguistic2::XDictionaryEntry >
166 : : SearchDicList(
167 : : const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryList >& rDicList,
168 : : const ::rtl::OUString& rWord, sal_Int16 nLanguage,
169 : : sal_Bool bSearchPosDics, sal_Bool bSearchSpellEntry );
170 : :
171 : : LNG_DLLPUBLIC sal_uInt8 AddEntryToDic(
172 : : ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > &rxDic,
173 : : const ::rtl::OUString &rWord, sal_Bool bIsNeg,
174 : : const ::rtl::OUString &rRplcTxt, sal_Int16 nRplcLang,
175 : : sal_Bool bStripDot = sal_True );
176 : :
177 : : LNG_DLLPUBLIC sal_Bool SaveDictionaries( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryList > &xDicList );
178 : :
179 : : // AppExitLstnr:
180 : : // virtual base class that calls it AtExit function when the application
181 : : // (ie the Desktop) is about to terminate
182 : :
183 : : class AppExitListener :
184 : : public cppu::WeakImplHelper1
185 : : <
186 : : ::com::sun::star::frame::XTerminateListener
187 : : >
188 : : {
189 : : ::com::sun::star::uno::Reference<
190 : : ::com::sun::star::frame::XDesktop > xDesktop;
191 : :
192 : : public:
193 : : AppExitListener();
194 : : virtual ~AppExitListener();
195 : :
196 : : virtual void AtExit() = 0;
197 : :
198 : : void Activate();
199 : : void Deactivate();
200 : :
201 : : // XEventListener
202 : : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
203 : :
204 : : // XTerminateListener
205 : : virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
206 : : virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException);
207 : : };
208 : :
209 : : } // namespace linguistic
210 : :
211 : : #endif
212 : :
213 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|