1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _LINGUISTIC_DEFS_HXX_ 25 #define _LINGUISTIC_DEFS_HXX_ 26 27 #include <com/sun/star/linguistic2/XSpellChecker.hpp> 28 #include <com/sun/star/linguistic2/XProofreader.hpp> 29 #include <com/sun/star/linguistic2/XHyphenator.hpp> 30 #include <com/sun/star/linguistic2/XThesaurus.hpp> 31 32 #include <boost/shared_ptr.hpp> 33 34 class SvStream; 35 36 37 /////////////////////////////////////////////////////////////////////////// 38 39 #define A2OU(x) ::rtl::OUString::createFromAscii( x ) 40 41 typedef boost::shared_ptr< SvStream > SvStreamPtr; 42 43 namespace css = ::com::sun::star; 44 45 /////////////////////////////////////////////////////////////////////////// 46 47 struct LangSvcEntries 48 { 49 css::uno::Sequence< ::rtl::OUString > aSvcImplNames; 50 51 sal_Int16 nLastTriedSvcIndex; 52 bool bAlreadyWarned; 53 bool bDoWarnAgain; 54 LangSvcEntriesLangSvcEntries55 LangSvcEntries() : nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false) {} 56 LangSvcEntriesLangSvcEntries57 inline LangSvcEntries( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) : 58 aSvcImplNames(rSvcImplNames), 59 nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false) 60 { 61 } 62 LangSvcEntriesLangSvcEntries63 inline LangSvcEntries( const ::rtl::OUString &rSvcImplName ) : 64 nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false) 65 { 66 aSvcImplNames.realloc(1); 67 aSvcImplNames[0] = rSvcImplName; 68 } 69 IsAlreadyWarnedLangSvcEntries70 bool IsAlreadyWarned() const { return bAlreadyWarned != 0; } SetAlreadyWarnedLangSvcEntries71 void SetAlreadyWarned( bool bVal ) { bAlreadyWarned = 0 != bVal; } IsDoWarnAgainLangSvcEntries72 bool IsDoWarnAgain() const { return bDoWarnAgain != 0; } SetDoWarnAgainLangSvcEntries73 void SetDoWarnAgain( bool bVal ) { bDoWarnAgain = 0 != bVal; } 74 ClearLangSvcEntries75 inline void Clear() 76 { 77 aSvcImplNames.realloc(0); 78 nLastTriedSvcIndex = -1; 79 bAlreadyWarned = false; 80 bDoWarnAgain = false; 81 } 82 }; 83 84 struct LangSvcEntries_Spell : public LangSvcEntries 85 { 86 css::uno::Sequence< css::uno::Reference< css::linguistic2::XSpellChecker > > aSvcRefs; 87 LangSvcEntries_SpellLangSvcEntries_Spell88 LangSvcEntries_Spell() : LangSvcEntries() {} LangSvcEntries_SpellLangSvcEntries_Spell89 LangSvcEntries_Spell( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) : LangSvcEntries( rSvcImplNames ) {} 90 }; 91 92 struct LangSvcEntries_Grammar : public LangSvcEntries 93 { 94 css::uno::Sequence< css::uno::Reference< css::linguistic2::XProofreader > > aSvcRefs; 95 LangSvcEntries_GrammarLangSvcEntries_Grammar96 LangSvcEntries_Grammar() : LangSvcEntries() {} LangSvcEntries_GrammarLangSvcEntries_Grammar97 LangSvcEntries_Grammar( const ::rtl::OUString &rSvcImplName ) : LangSvcEntries( rSvcImplName ) {} 98 }; 99 100 struct LangSvcEntries_Hyph : public LangSvcEntries 101 { 102 css::uno::Sequence< css::uno::Reference< css::linguistic2::XHyphenator > > aSvcRefs; 103 LangSvcEntries_HyphLangSvcEntries_Hyph104 LangSvcEntries_Hyph() : LangSvcEntries() {} LangSvcEntries_HyphLangSvcEntries_Hyph105 LangSvcEntries_Hyph( const ::rtl::OUString &rSvcImplName ) : LangSvcEntries( rSvcImplName ) {} 106 }; 107 108 struct LangSvcEntries_Thes : public LangSvcEntries 109 { 110 css::uno::Sequence< css::uno::Reference< css::linguistic2::XThesaurus > > aSvcRefs; 111 LangSvcEntries_ThesLangSvcEntries_Thes112 LangSvcEntries_Thes() : LangSvcEntries() {} LangSvcEntries_ThesLangSvcEntries_Thes113 LangSvcEntries_Thes( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) : LangSvcEntries( rSvcImplNames ) {} 114 }; 115 116 /////////////////////////////////////////////////////////////////////////// 117 118 // virtual base class for the different dispatchers 119 class LinguDispatcher 120 { 121 public: 122 enum DspType { DSP_SPELL, DSP_HYPH, DSP_THES, DSP_GRAMMAR }; 123 124 virtual void SetServiceList( const css::lang::Locale &rLocale, const css::uno::Sequence< rtl::OUString > &rSvcImplNames ) = 0; 125 virtual css::uno::Sequence< rtl::OUString > GetServiceList( const css::lang::Locale &rLocale ) const = 0; 126 virtual DspType GetDspType() const = 0; 127 }; 128 129 /////////////////////////////////////////////////////////////////////////// 130 131 #endif 132 133