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