1*bae3752eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*bae3752eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*bae3752eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*bae3752eSAndrew Rist * distributed with this work for additional information 6*bae3752eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*bae3752eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*bae3752eSAndrew Rist * "License"); you may not use this file except in compliance 9*bae3752eSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*bae3752eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*bae3752eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*bae3752eSAndrew Rist * software distributed under the License is distributed on an 15*bae3752eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*bae3752eSAndrew Rist * KIND, either express or implied. See the License for the 17*bae3752eSAndrew Rist * specific language governing permissions and limitations 18*bae3752eSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*bae3752eSAndrew Rist *************************************************************/ 21*bae3752eSAndrew Rist 22*bae3752eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _unotools_LINGUCFG_HXX_ 25cdf0e10cSrcweir #define _unotools_LINGUCFG_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "unotools/unotoolsdllapi.h" 28cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValues.hpp> 29cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 30cdf0e10cSrcweir #include <com/sun/star/uno/Any.h> 31cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp> 32cdf0e10cSrcweir #include <com/sun/star/util/XChangesBatch.hpp> 33cdf0e10cSrcweir #include <tools/solar.h> 34cdf0e10cSrcweir #include <rtl/ustring.hxx> 35cdf0e10cSrcweir #include <unotools/configitem.hxx> 36cdf0e10cSrcweir #include <osl/mutex.hxx> 37cdf0e10cSrcweir #include <unotools/options.hxx> 38cdf0e10cSrcweir #include <i18npool/lang.h> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <vector> 41cdf0e10cSrcweir 42cdf0e10cSrcweir class SvtLinguConfigItem; 43cdf0e10cSrcweir 44cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 45cdf0e10cSrcweir 46cdf0e10cSrcweir struct UNOTOOLS_DLLPUBLIC SvtLinguOptions 47cdf0e10cSrcweir { 48cdf0e10cSrcweir ::com::sun::star::uno::Sequence< rtl::OUString > aActiveDics; 49cdf0e10cSrcweir ::com::sun::star::uno::Sequence< rtl::OUString > aActiveConvDics; 50cdf0e10cSrcweir 51cdf0e10cSrcweir sal_Bool bROActiveDics; 52cdf0e10cSrcweir sal_Bool bROActiveConvDics; 53cdf0e10cSrcweir 54cdf0e10cSrcweir // Hyphenator service specific options 55cdf0e10cSrcweir sal_Int16 nHyphMinLeading, 56cdf0e10cSrcweir nHyphMinTrailing, 57cdf0e10cSrcweir nHyphMinWordLength; 58cdf0e10cSrcweir 59cdf0e10cSrcweir sal_Bool bROHyphMinLeading, 60cdf0e10cSrcweir bROHyphMinTrailing, 61cdf0e10cSrcweir bROHyphMinWordLength; 62cdf0e10cSrcweir 63cdf0e10cSrcweir // misc options (non-service specific) 64cdf0e10cSrcweir sal_Int16 nDefaultLanguage; 65cdf0e10cSrcweir sal_Int16 nDefaultLanguage_CJK; 66cdf0e10cSrcweir sal_Int16 nDefaultLanguage_CTL; 67cdf0e10cSrcweir 68cdf0e10cSrcweir sal_Bool bRODefaultLanguage; 69cdf0e10cSrcweir sal_Bool bRODefaultLanguage_CJK; 70cdf0e10cSrcweir sal_Bool bRODefaultLanguage_CTL; 71cdf0e10cSrcweir 72cdf0e10cSrcweir // spelling options (non-service specific) 73cdf0e10cSrcweir sal_Bool bIsSpellSpecial; 74cdf0e10cSrcweir sal_Bool bIsSpellAuto; 75cdf0e10cSrcweir sal_Bool bIsSpellReverse; 76cdf0e10cSrcweir 77cdf0e10cSrcweir sal_Bool bROIsSpellSpecial; 78cdf0e10cSrcweir sal_Bool bROIsSpellAuto; 79cdf0e10cSrcweir sal_Bool bROIsSpellReverse; 80cdf0e10cSrcweir 81cdf0e10cSrcweir // hyphenation options (non-service specific) 82cdf0e10cSrcweir sal_Bool bIsHyphSpecial; 83cdf0e10cSrcweir sal_Bool bIsHyphAuto; 84cdf0e10cSrcweir 85cdf0e10cSrcweir sal_Bool bROIsHyphSpecial; 86cdf0e10cSrcweir sal_Bool bROIsHyphAuto; 87cdf0e10cSrcweir 88cdf0e10cSrcweir // common to SpellChecker, Hyphenator and Thesaurus service 89cdf0e10cSrcweir sal_Bool bIsUseDictionaryList; 90cdf0e10cSrcweir sal_Bool bIsIgnoreControlCharacters; 91cdf0e10cSrcweir 92cdf0e10cSrcweir sal_Bool bROIsUseDictionaryList; 93cdf0e10cSrcweir sal_Bool bROIsIgnoreControlCharacters; 94cdf0e10cSrcweir 95cdf0e10cSrcweir // SpellChecker service specific options 96cdf0e10cSrcweir sal_Bool bIsSpellWithDigits, 97cdf0e10cSrcweir bIsSpellUpperCase, 98cdf0e10cSrcweir bIsSpellCapitalization; 99cdf0e10cSrcweir 100cdf0e10cSrcweir sal_Bool bROIsSpellWithDigits, 101cdf0e10cSrcweir bROIsSpellUpperCase, 102cdf0e10cSrcweir bROIsSpellCapitalization; 103cdf0e10cSrcweir 104cdf0e10cSrcweir // text conversion specific options 105cdf0e10cSrcweir sal_Bool bIsIgnorePostPositionalWord; 106cdf0e10cSrcweir sal_Bool bIsAutoCloseDialog; 107cdf0e10cSrcweir sal_Bool bIsShowEntriesRecentlyUsedFirst; 108cdf0e10cSrcweir sal_Bool bIsAutoReplaceUniqueEntries; 109cdf0e10cSrcweir sal_Bool bIsDirectionToSimplified; 110cdf0e10cSrcweir sal_Bool bIsUseCharacterVariants; 111cdf0e10cSrcweir sal_Bool bIsTranslateCommonTerms; 112cdf0e10cSrcweir sal_Bool bIsReverseMapping; 113cdf0e10cSrcweir 114cdf0e10cSrcweir sal_Bool bROIsIgnorePostPositionalWord; 115cdf0e10cSrcweir sal_Bool bROIsAutoCloseDialog; 116cdf0e10cSrcweir sal_Bool bROIsShowEntriesRecentlyUsedFirst; 117cdf0e10cSrcweir sal_Bool bROIsAutoReplaceUniqueEntries; 118cdf0e10cSrcweir sal_Bool bROIsDirectionToSimplified; 119cdf0e10cSrcweir sal_Bool bROIsUseCharacterVariants; 120cdf0e10cSrcweir sal_Bool bROIsTranslateCommonTerms; 121cdf0e10cSrcweir sal_Bool bROIsReverseMapping; 122cdf0e10cSrcweir 123cdf0e10cSrcweir // check value need to determine if the configuration needs to updatet 124cdf0e10cSrcweir // or not (used for a quick check if data files have been changed/added 125cdf0e10cSrcweir // or deleted 126cdf0e10cSrcweir sal_Int32 nDataFilesChangedCheckValue; 127cdf0e10cSrcweir sal_Bool bRODataFilesChangedCheckValue; 128cdf0e10cSrcweir 129cdf0e10cSrcweir sal_Bool bIsGrammarAuto; 130cdf0e10cSrcweir sal_Bool bIsGrammarInteractive; 131cdf0e10cSrcweir 132cdf0e10cSrcweir sal_Bool bROIsGrammarAuto; 133cdf0e10cSrcweir sal_Bool bROIsGrammarInteractive; 134cdf0e10cSrcweir 135cdf0e10cSrcweir SvtLinguOptions(); 136cdf0e10cSrcweir }; 137cdf0e10cSrcweir 138cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 139cdf0e10cSrcweir 140cdf0e10cSrcweir struct UNOTOOLS_DLLPUBLIC SvtLinguConfigDictionaryEntry 141cdf0e10cSrcweir { 142cdf0e10cSrcweir // the URL's pointing to the location of the files the dictionary consists of 143cdf0e10cSrcweir com::sun::star::uno::Sequence< rtl::OUString > aLocations; 144cdf0e10cSrcweir // the name of the dictionary format implement 145cdf0e10cSrcweir rtl::OUString aFormatName; 146cdf0e10cSrcweir // the list of languages (ISO names) the dictionary can be used for 147cdf0e10cSrcweir com::sun::star::uno::Sequence< rtl::OUString > aLocaleNames; 148cdf0e10cSrcweir }; 149cdf0e10cSrcweir 150cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 151cdf0e10cSrcweir 152cdf0e10cSrcweir class UNOTOOLS_DLLPUBLIC SvtLinguConfig: public utl::detail::Options 153cdf0e10cSrcweir { 154cdf0e10cSrcweir // returns static object 155cdf0e10cSrcweir UNOTOOLS_DLLPRIVATE SvtLinguConfigItem & GetConfigItem(); 156cdf0e10cSrcweir GetConfigItem() const157cdf0e10cSrcweir SvtLinguConfigItem & GetConfigItem() const { return const_cast< SvtLinguConfig * >( this )->GetConfigItem(); } 158cdf0e10cSrcweir 159cdf0e10cSrcweir // configuration update access for the 'Linguistic' main node 160cdf0e10cSrcweir mutable com::sun::star::uno::Reference< com::sun::star::util::XChangesBatch > m_xMainUpdateAccess; 161cdf0e10cSrcweir 162cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::util::XChangesBatch > GetMainUpdateAccess() const; 163cdf0e10cSrcweir 164cdf0e10cSrcweir com::sun::star::uno::Sequence< rtl::OUString > GetCurrentOrLastActiveDicts_Impl( const rtl::OUString &rPropName ) const; 165cdf0e10cSrcweir void SetCurrentOrLastActiveDicts_Impl( const rtl::OUString &rPropName, const com::sun::star::uno::Sequence< rtl::OUString > &rDictionaries ) const; 166cdf0e10cSrcweir 167cdf0e10cSrcweir rtl::OUString GetVendorImageUrl_Impl( const rtl::OUString &rServiceImplName, const rtl::OUString &rImageName ) const; 168cdf0e10cSrcweir 169cdf0e10cSrcweir // disallow copy-constructor and assignment-operator for now 170cdf0e10cSrcweir SvtLinguConfig( const SvtLinguConfig & ); 171cdf0e10cSrcweir SvtLinguConfig & operator = ( const SvtLinguConfig & ); 172cdf0e10cSrcweir 173cdf0e10cSrcweir public: 174cdf0e10cSrcweir SvtLinguConfig(); 175cdf0e10cSrcweir virtual ~SvtLinguConfig(); 176cdf0e10cSrcweir 177cdf0e10cSrcweir // 178cdf0e10cSrcweir // borrowed from utl::ConfigItem 179cdf0e10cSrcweir // 180cdf0e10cSrcweir com::sun::star::uno::Sequence< rtl::OUString > 181cdf0e10cSrcweir GetNodeNames( const rtl::OUString &rNode ); 182cdf0e10cSrcweir // 183cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::uno::Any > 184cdf0e10cSrcweir GetProperties( 185cdf0e10cSrcweir const com::sun::star::uno::Sequence< rtl::OUString > &rNames ); 186cdf0e10cSrcweir // 187cdf0e10cSrcweir sal_Bool 188cdf0e10cSrcweir ReplaceSetProperties( 189cdf0e10cSrcweir const rtl::OUString &rNode, 190cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > rValues ); 191cdf0e10cSrcweir 192cdf0e10cSrcweir com::sun::star::uno::Any 193cdf0e10cSrcweir GetProperty( const rtl::OUString &rPropertyName ) const; 194cdf0e10cSrcweir com::sun::star::uno::Any 195cdf0e10cSrcweir GetProperty( sal_Int32 nPropertyHandle ) const; 196cdf0e10cSrcweir 197cdf0e10cSrcweir sal_Bool SetProperty( const rtl::OUString &rPropertyName, 198cdf0e10cSrcweir const com::sun::star::uno::Any &rValue ); 199cdf0e10cSrcweir sal_Bool SetProperty( sal_Int32 nPropertyHandle, 200cdf0e10cSrcweir const com::sun::star::uno::Any &rValue ); 201cdf0e10cSrcweir 202cdf0e10cSrcweir sal_Bool GetOptions( SvtLinguOptions &rOptions ) const; 203cdf0e10cSrcweir sal_Bool SetOptions( const SvtLinguOptions &rOptions ); 204cdf0e10cSrcweir 205cdf0e10cSrcweir sal_Bool IsReadOnly( const rtl::OUString &rPropertyName ) const; 206cdf0e10cSrcweir sal_Bool IsReadOnly( sal_Int32 nPropertyHandle ) const; 207cdf0e10cSrcweir 208cdf0e10cSrcweir //! 209cdf0e10cSrcweir //! the following functions work on the 'ServiceManager' sub node of the 210cdf0e10cSrcweir //! linguistic configuration only 211cdf0e10cSrcweir //! 212cdf0e10cSrcweir sal_Bool GetElementNamesFor( const rtl::OUString &rNodeName, com::sun::star::uno::Sequence< rtl::OUString > &rElementNames ) const; 213cdf0e10cSrcweir // 214cdf0e10cSrcweir sal_Bool GetSupportedDictionaryFormatsFor( const rtl::OUString &rSetName, const rtl::OUString &rSetEntry, com::sun::star::uno::Sequence< rtl::OUString > &rFormatList ) const; 215cdf0e10cSrcweir void SetOrCreateSupportedDictionaryFormatsFor( const rtl::OUString &rSetName, const rtl::OUString &rSetEntry, const com::sun::star::uno::Sequence< rtl::OUString > &rFormatList ) const; 216cdf0e10cSrcweir // 217cdf0e10cSrcweir sal_Bool GetDictionaryEntry( const rtl::OUString &rNodeName, SvtLinguConfigDictionaryEntry &rDicEntry ) const; 218cdf0e10cSrcweir void SetOrCreateDictionaryEntry( const rtl::OUString &rNodeName, const SvtLinguConfigDictionaryEntry &rDicEntry ) const; 219cdf0e10cSrcweir // 220cdf0e10cSrcweir com::sun::star::uno::Sequence< rtl::OUString > GetDisabledDictionaries() const; 221cdf0e10cSrcweir void SetDisabledDictionaries( const com::sun::star::uno::Sequence< rtl::OUString > &rDictionaries ) const; 222cdf0e10cSrcweir // 223cdf0e10cSrcweir std::vector< SvtLinguConfigDictionaryEntry > GetActiveDictionariesByFormat( const rtl::OUString &rFormatName ); 224cdf0e10cSrcweir 225cdf0e10cSrcweir // functions returning file URLs to the respective images (if found) and empty string otherwise 226cdf0e10cSrcweir ::rtl::OUString GetSpellAndGrammarDialogImage( const ::rtl::OUString &rServiceImplName, bool bHighContrast = false ) const; 227cdf0e10cSrcweir ::rtl::OUString GetSpellAndGrammarContextSuggestionImage( const ::rtl::OUString &rServiceImplName, bool bHighContrast = false ) const; 228cdf0e10cSrcweir ::rtl::OUString GetSpellAndGrammarContextDictionaryImage( const ::rtl::OUString &rServiceImplName, bool bHighContrast = false ) const; 229cdf0e10cSrcweir ::rtl::OUString GetThesaurusDialogImage( const ::rtl::OUString &rServiceImplName, bool bHighContrast = false ) const; 230cdf0e10cSrcweir ::rtl::OUString GetSynonymsContextImage( const ::rtl::OUString &rServiceImplName, bool bHighContrast = false ) const; 231cdf0e10cSrcweir 232cdf0e10cSrcweir bool HasVendorImages( const char *pImageName ) const; 233cdf0e10cSrcweir bool HasGrammarChecker() const; 234cdf0e10cSrcweir }; 235cdf0e10cSrcweir 236cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 237cdf0e10cSrcweir 238cdf0e10cSrcweir #endif 239cdf0e10cSrcweir 240