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