1*3b8558fdSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*3b8558fdSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*3b8558fdSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*3b8558fdSAndrew Rist * distributed with this work for additional information
6*3b8558fdSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*3b8558fdSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*3b8558fdSAndrew Rist * "License"); you may not use this file except in compliance
9*3b8558fdSAndrew Rist * with the License. You may obtain a copy of the License at
10*3b8558fdSAndrew Rist *
11*3b8558fdSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*3b8558fdSAndrew Rist *
13*3b8558fdSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*3b8558fdSAndrew Rist * software distributed under the License is distributed on an
15*3b8558fdSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3b8558fdSAndrew Rist * KIND, either express or implied. See the License for the
17*3b8558fdSAndrew Rist * specific language governing permissions and limitations
18*3b8558fdSAndrew Rist * under the License.
19*3b8558fdSAndrew Rist *
20*3b8558fdSAndrew Rist *************************************************************/
21*3b8558fdSAndrew Rist
22*3b8558fdSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_linguistic.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "linguistic/hyphdta.hxx"
28cdf0e10cSrcweir #include "linguistic/lngprops.hxx"
29cdf0e10cSrcweir #include "linguistic/misc.hxx"
30cdf0e10cSrcweir #include <osl/mutex.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
34cdf0e10cSrcweir #include <tools/debug.hxx>
35cdf0e10cSrcweir #include <svl/lngmisc.hxx>
36cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
37cdf0e10cSrcweir
38cdf0e10cSrcweir //using namespace utl;
39cdf0e10cSrcweir using namespace osl;
40cdf0e10cSrcweir using namespace rtl;
41cdf0e10cSrcweir using namespace com::sun::star;
42cdf0e10cSrcweir //using namespace com::sun::star::beans;
43cdf0e10cSrcweir using namespace com::sun::star::lang;
44cdf0e10cSrcweir using namespace com::sun::star::uno;
45cdf0e10cSrcweir using namespace com::sun::star::linguistic2;
46cdf0e10cSrcweir
47cdf0e10cSrcweir namespace linguistic
48cdf0e10cSrcweir {
49cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
50cdf0e10cSrcweir
51cdf0e10cSrcweir
HyphenatedWord(const OUString & rWord,sal_Int16 nLang,sal_Int16 nHPos,const OUString & rHyphWord,sal_Int16 nPos)52cdf0e10cSrcweir HyphenatedWord::HyphenatedWord(const OUString &rWord, sal_Int16 nLang, sal_Int16 nHPos,
53cdf0e10cSrcweir const OUString &rHyphWord, sal_Int16 nPos ) :
54cdf0e10cSrcweir aWord (rWord),
55cdf0e10cSrcweir aHyphenatedWord (rHyphWord),
56cdf0e10cSrcweir nHyphPos (nPos),
57cdf0e10cSrcweir nHyphenationPos (nHPos),
58cdf0e10cSrcweir nLanguage (nLang)
59cdf0e10cSrcweir {
60cdf0e10cSrcweir String aSingleQuote( GetLocaleDataWrapper( nLanguage ).getQuotationMarkEnd() );
61cdf0e10cSrcweir DBG_ASSERT( 1 == aSingleQuote.Len(), "unexpectend length of quotation mark" );
62cdf0e10cSrcweir if (aSingleQuote.Len())
63cdf0e10cSrcweir {
64cdf0e10cSrcweir // ignore typographical apostrophes (which got replaced in original
65cdf0e10cSrcweir // word when being checked for hyphenation) in results.
66cdf0e10cSrcweir OUString aTmpWord( rWord );
67cdf0e10cSrcweir OUString aTmpHyphWord( rHyphWord );
68cdf0e10cSrcweir aTmpWord = aTmpWord .replace( aSingleQuote.GetChar(0), '\'' );
69cdf0e10cSrcweir aTmpHyphWord = aTmpHyphWord.replace( aSingleQuote.GetChar(0), '\'' );
70cdf0e10cSrcweir bIsAltSpelling = aTmpWord != aTmpHyphWord;
71cdf0e10cSrcweir }
72cdf0e10cSrcweir else
73cdf0e10cSrcweir bIsAltSpelling = rWord != rHyphWord;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
76cdf0e10cSrcweir
~HyphenatedWord()77cdf0e10cSrcweir HyphenatedWord::~HyphenatedWord()
78cdf0e10cSrcweir {
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
81cdf0e10cSrcweir
getWord()82cdf0e10cSrcweir OUString SAL_CALL HyphenatedWord::getWord()
83cdf0e10cSrcweir throw(RuntimeException)
84cdf0e10cSrcweir {
85cdf0e10cSrcweir MutexGuard aGuard( GetLinguMutex() );
86cdf0e10cSrcweir return aWord;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
89cdf0e10cSrcweir
getLocale()90cdf0e10cSrcweir Locale SAL_CALL HyphenatedWord::getLocale()
91cdf0e10cSrcweir throw(RuntimeException)
92cdf0e10cSrcweir {
93cdf0e10cSrcweir MutexGuard aGuard( GetLinguMutex() );
94cdf0e10cSrcweir
95cdf0e10cSrcweir Locale aRes;
96cdf0e10cSrcweir return LanguageToLocale( aRes, nLanguage );
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
99cdf0e10cSrcweir
getHyphenationPos()100cdf0e10cSrcweir sal_Int16 SAL_CALL HyphenatedWord::getHyphenationPos()
101cdf0e10cSrcweir throw(RuntimeException)
102cdf0e10cSrcweir {
103cdf0e10cSrcweir MutexGuard aGuard( GetLinguMutex() );
104cdf0e10cSrcweir return nHyphenationPos;
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
107cdf0e10cSrcweir
getHyphenatedWord()108cdf0e10cSrcweir OUString SAL_CALL HyphenatedWord::getHyphenatedWord()
109cdf0e10cSrcweir throw(RuntimeException)
110cdf0e10cSrcweir {
111cdf0e10cSrcweir MutexGuard aGuard( GetLinguMutex() );
112cdf0e10cSrcweir return aHyphenatedWord;
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
115cdf0e10cSrcweir
getHyphenPos()116cdf0e10cSrcweir sal_Int16 SAL_CALL HyphenatedWord::getHyphenPos()
117cdf0e10cSrcweir throw(RuntimeException)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir MutexGuard aGuard( GetLinguMutex() );
120cdf0e10cSrcweir return nHyphPos;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir
123cdf0e10cSrcweir
isAlternativeSpelling()124cdf0e10cSrcweir sal_Bool SAL_CALL HyphenatedWord::isAlternativeSpelling()
125cdf0e10cSrcweir throw(RuntimeException)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir MutexGuard aGuard( GetLinguMutex() );
128cdf0e10cSrcweir return bIsAltSpelling;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir
131cdf0e10cSrcweir
132cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
133cdf0e10cSrcweir
134cdf0e10cSrcweir
PossibleHyphens(const OUString & rWord,sal_Int16 nLang,const OUString & rHyphWord,const Sequence<sal_Int16> & rPositions)135cdf0e10cSrcweir PossibleHyphens::PossibleHyphens(const OUString &rWord, sal_Int16 nLang,
136cdf0e10cSrcweir const OUString &rHyphWord,
137cdf0e10cSrcweir const Sequence< sal_Int16 > &rPositions) :
138cdf0e10cSrcweir aWord (rWord),
139cdf0e10cSrcweir aWordWithHyphens(rHyphWord),
140cdf0e10cSrcweir aOrigHyphenPos (rPositions),
141cdf0e10cSrcweir nLanguage (nLang)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir
~PossibleHyphens()146cdf0e10cSrcweir PossibleHyphens::~PossibleHyphens()
147cdf0e10cSrcweir {
148cdf0e10cSrcweir }
149cdf0e10cSrcweir
150cdf0e10cSrcweir
getWord()151cdf0e10cSrcweir OUString SAL_CALL PossibleHyphens::getWord()
152cdf0e10cSrcweir throw(RuntimeException)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir MutexGuard aGuard( GetLinguMutex() );
155cdf0e10cSrcweir return aWord;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
158cdf0e10cSrcweir
getLocale()159cdf0e10cSrcweir Locale SAL_CALL PossibleHyphens::getLocale()
160cdf0e10cSrcweir throw(RuntimeException)
161cdf0e10cSrcweir {
162cdf0e10cSrcweir MutexGuard aGuard( GetLinguMutex() );
163cdf0e10cSrcweir return CreateLocale( nLanguage );
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
166cdf0e10cSrcweir
getPossibleHyphens()167cdf0e10cSrcweir OUString SAL_CALL PossibleHyphens::getPossibleHyphens()
168cdf0e10cSrcweir throw(RuntimeException)
169cdf0e10cSrcweir {
170cdf0e10cSrcweir MutexGuard aGuard( GetLinguMutex() );
171cdf0e10cSrcweir return aWordWithHyphens;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir
getHyphenationPositions()175cdf0e10cSrcweir Sequence< sal_Int16 > SAL_CALL PossibleHyphens::getHyphenationPositions()
176cdf0e10cSrcweir throw(RuntimeException)
177cdf0e10cSrcweir {
178cdf0e10cSrcweir MutexGuard aGuard( GetLinguMutex() );
179cdf0e10cSrcweir return aOrigHyphenPos;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir
182cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
183cdf0e10cSrcweir
184cdf0e10cSrcweir } // namespace linguistic
185cdf0e10cSrcweir
186