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_HYPHDTA_HXX_
25 #define _LINGUISTIC_HYPHDTA_HXX_
26 
27 #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
28 #include <com/sun/star/linguistic2/XPossibleHyphens.hpp>
29 #include <tools/solar.h>
30 #include <uno/lbnames.h>			// CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
31 #include <cppuhelper/implbase1.hxx>	// helper for implementations
32 #include <linguistic/lngdllapi.h>
33 
34 namespace linguistic
35 {
36 
37 ///////////////////////////////////////////////////////////////////////////
38 
39 class HyphenatedWord :
40 	public cppu::WeakImplHelper1
41 	<
42 		::com::sun::star::linguistic2::XHyphenatedWord
43 	>
44 {
45 	::rtl::OUString		aWord;
46 	::rtl::OUString		aHyphenatedWord;
47 	sal_Int16				nHyphPos;
48 	sal_Int16				nHyphenationPos;
49 	sal_Int16				nLanguage;
50 	sal_Bool				bIsAltSpelling;
51 
52 	// disallow copy-constructor and assignment-operator for now
53 	HyphenatedWord(const HyphenatedWord &);
54 	HyphenatedWord & operator = (const HyphenatedWord &);
55 
56 public:
57 	HyphenatedWord(const ::rtl::OUString &rWord, sal_Int16 nLang, sal_Int16 nHyphenationPos,
58 				   const ::rtl::OUString &rHyphenatedWord, sal_Int16 nHyphenPos );
59 	virtual ~HyphenatedWord();
60 
61 	// XHyphenatedWord
62     virtual ::rtl::OUString SAL_CALL
63 		getWord()
64 			throw(::com::sun::star::uno::RuntimeException);
65     virtual ::com::sun::star::lang::Locale SAL_CALL
66 		getLocale()
67 			throw(::com::sun::star::uno::RuntimeException);
68     virtual sal_Int16 SAL_CALL
69 		getHyphenationPos()
70 			throw(::com::sun::star::uno::RuntimeException);
71     virtual ::rtl::OUString SAL_CALL
72 		getHyphenatedWord()
73 			throw(::com::sun::star::uno::RuntimeException);
74     virtual sal_Int16 SAL_CALL
75 		getHyphenPos()
76 			throw(::com::sun::star::uno::RuntimeException);
77     virtual sal_Bool SAL_CALL
78 		isAlternativeSpelling()
79 			throw(::com::sun::star::uno::RuntimeException);
80 
GetWord()81     ::rtl::OUString GetWord()           { return aWord; }
GetHyphenatedWord()82     ::rtl::OUString GetHyphenatedWord() { return aHyphenatedWord; }
GetLanguage()83     sal_Int16           GetLanguage()       { return nLanguage; }
SetWord(::rtl::OUString & rTxt)84     void            SetWord( ::rtl::OUString &rTxt )            { aWord = rTxt; }
SetHyphenatedWord(::rtl::OUString & rTxt)85     void            SetHyphenatedWord( ::rtl::OUString &rTxt )  { aHyphenatedWord = rTxt; }
SetLanguage(sal_Int16 nLang)86     void            SetLanguage( sal_Int16 nLang )                  { nLanguage = nLang; }
87 	static com::sun::star::uno::Reference <com::sun::star::linguistic2::XHyphenatedWord> LNG_DLLPUBLIC CreateHyphenatedWord(
88 		const ::rtl::OUString &rWord, sal_Int16 nLang, sal_Int16 nHyphenationPos,
89 		const ::rtl::OUString &rHyphenatedWord, sal_Int16 nHyphenPos );
90 };
91 
92 
93 ///////////////////////////////////////////////////////////////////////////
94 
95 class PossibleHyphens :
96 	public cppu::WeakImplHelper1
97 	<
98 		::com::sun::star::linguistic2::XPossibleHyphens
99 	>
100 {
101 	::rtl::OUString				aWord;
102 	::rtl::OUString				aWordWithHyphens;
103 	::com::sun::star::uno::Sequence< sal_Int16 >	aOrigHyphenPos;
104 	sal_Int16						nLanguage;
105 
106 	// disallow copy-constructor and assignment-operator for now
107 	PossibleHyphens(const PossibleHyphens &);
108 	PossibleHyphens & operator = (const PossibleHyphens &);
109 
110 public:
111 	PossibleHyphens(const ::rtl::OUString &rWord, sal_Int16 nLang,
112 			const ::rtl::OUString &rHyphWord,
113 			const ::com::sun::star::uno::Sequence< sal_Int16 > &rPositions);
114 	virtual ~PossibleHyphens();
115 
116 	// XPossibleHyphens
117     virtual ::rtl::OUString SAL_CALL
118 		getWord()
119 			throw(::com::sun::star::uno::RuntimeException);
120     virtual ::com::sun::star::lang::Locale SAL_CALL
121 		getLocale()
122 			throw(::com::sun::star::uno::RuntimeException);
123     virtual ::rtl::OUString SAL_CALL
124 		getPossibleHyphens()
125 			throw(::com::sun::star::uno::RuntimeException);
126     virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL
127 		getHyphenationPositions()
128 			throw(::com::sun::star::uno::RuntimeException);
129 
GetWord()130     ::rtl::OUString GetWord()       { return aWord; }
GetLanguage()131     sal_Int16           GetLanguage()   { return nLanguage; }
SetWord(::rtl::OUString & rTxt)132     void            SetWord( ::rtl::OUString &rTxt )    { aWord = rTxt; }
SetLanguage(sal_Int16 nLang)133     void            SetLanguage( sal_Int16 nLang )          { nLanguage = nLang; }
134 
135 	static com::sun::star::uno::Reference < com::sun::star::linguistic2::XPossibleHyphens > LNG_DLLPUBLIC CreatePossibleHyphens
136 		(const ::rtl::OUString &rWord, sal_Int16 nLang,
137 		 const ::rtl::OUString &rHyphWord,
138 		 const ::com::sun::star::uno::Sequence< sal_Int16 > &rPositions);
139 };
140 
141 
142 ///////////////////////////////////////////////////////////////////////////
143 
144 } // namespace linguistic
145 
146 #endif
147 
148