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_SPELLDTA_HXX_ 25 #define _LINGUISTIC_SPELLDTA_HXX_ 26 27 #include <vector> 28 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp> 29 #include <com/sun/star/linguistic2/XSetSpellAlternatives.hpp> 30 31 #include <tools/solar.h> 32 33 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type 34 #include <cppuhelper/implbase2.hxx> 35 #include <linguistic/lngdllapi.h> 36 37 namespace com { namespace sun { namespace star { 38 namespace linguistic2 { 39 class XDictionaryList; 40 } 41 } } } 42 43 44 namespace linguistic 45 { 46 47 /////////////////////////////////////////////////////////////////////////// 48 49 ::com::sun::star::uno::Reference< 50 ::com::sun::star::linguistic2::XSpellAlternatives > 51 MergeProposals( 52 ::com::sun::star::uno::Reference< 53 ::com::sun::star::linguistic2::XSpellAlternatives > &rxAlt1, 54 ::com::sun::star::uno::Reference< 55 ::com::sun::star::linguistic2::XSpellAlternatives > &rxAlt2 ); 56 57 ::com::sun::star::uno::Sequence< ::rtl::OUString > 58 MergeProposalSeqs( 59 ::com::sun::star::uno::Sequence< ::rtl::OUString > &rAlt1, 60 ::com::sun::star::uno::Sequence< ::rtl::OUString > &rAlt2, 61 sal_Bool bAllowDuplicates ); 62 63 void SeqRemoveNegEntries( 64 ::com::sun::star::uno::Sequence< ::rtl::OUString > &rSeq, 65 ::com::sun::star::uno::Reference< 66 ::com::sun::star::linguistic2::XDictionaryList > &rxDicList, 67 sal_Int16 nLanguage ); 68 69 sal_Bool SeqHasEntry( 70 const ::com::sun::star::uno::Sequence< ::rtl::OUString > &rSeq, 71 const ::rtl::OUString &rTxt); 72 73 /////////////////////////////////////////////////////////////////////////// 74 75 void SearchSimilarText( const rtl::OUString &rText, sal_Int16 nLanguage, 76 ::com::sun::star::uno::Reference< 77 ::com::sun::star::linguistic2::XDictionaryList > &xDicList, 78 std::vector< rtl::OUString > & rDicListProps ); 79 80 /////////////////////////////////////////////////////////////////////////// 81 82 83 class SpellAlternatives : 84 public cppu::WeakImplHelper2 85 < 86 ::com::sun::star::linguistic2::XSpellAlternatives, 87 ::com::sun::star::linguistic2::XSetSpellAlternatives 88 > 89 { 90 ::com::sun::star::uno::Sequence< ::rtl::OUString > aAlt; // list of alternatives, may be empty. 91 ::rtl::OUString aWord; 92 sal_Int16 nType; // type of failure 93 sal_Int16 nLanguage; 94 95 // disallow copy-constructor and assignment-operator for now 96 SpellAlternatives(const SpellAlternatives &); 97 SpellAlternatives & operator = (const SpellAlternatives &); 98 99 public: 100 SpellAlternatives(); 101 SpellAlternatives(const ::rtl::OUString &rWord, sal_Int16 nLang, sal_Int16 nFailureType, 102 const ::rtl::OUString &rRplcWord ); 103 SpellAlternatives(const ::rtl::OUString &rWord, sal_Int16 nLang, sal_Int16 nFailureType, 104 const ::com::sun::star::uno::Sequence< ::rtl::OUString > &rAlternatives ); 105 virtual ~SpellAlternatives(); 106 107 // XSpellAlternatives 108 virtual ::rtl::OUString SAL_CALL getWord( ) throw (::com::sun::star::uno::RuntimeException); 109 virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::uno::RuntimeException); 110 virtual ::sal_Int16 SAL_CALL getFailureType( ) throw (::com::sun::star::uno::RuntimeException); 111 virtual ::sal_Int16 SAL_CALL getAlternativesCount( ) throw (::com::sun::star::uno::RuntimeException); 112 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAlternatives( ) throw (::com::sun::star::uno::RuntimeException); 113 114 // XSetSpellAlternatives 115 virtual void SAL_CALL setAlternatives( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aAlternatives ) throw (::com::sun::star::uno::RuntimeException); 116 virtual void SAL_CALL setFailureType( ::sal_Int16 nFailureType ) throw (::com::sun::star::uno::RuntimeException); 117 118 // non-interface specific functions 119 void SetWordLanguage(const ::rtl::OUString &rWord, sal_Int16 nLang); 120 void SetFailureType(sal_Int16 nTypeP); 121 void SetAlternatives( const ::com::sun::star::uno::Sequence< ::rtl::OUString > &rAlt ); 122 static com::sun::star::uno::Reference < com::sun::star::linguistic2::XSpellAlternatives > LNG_DLLPUBLIC CreateSpellAlternatives( 123 const ::rtl::OUString &rWord, sal_Int16 nLang, sal_Int16 nTypeP, const ::com::sun::star::uno::Sequence< ::rtl::OUString > &rAlt ); 124 }; 125 126 127 /////////////////////////////////////////////////////////////////////////// 128 129 } // namespace linguistic 130 131 #endif 132 133