bump product version to 4.1.6.2
[LibreOffice.git] / linguistic / source / hyphdta.cxx
blob76d91ef5a2b1acca87f9d1e3e073a7ff8bd3672f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "linguistic/hyphdta.hxx"
22 #include "linguistic/lngprops.hxx"
23 #include "linguistic/misc.hxx"
24 #include <osl/mutex.hxx>
27 #include <rtl/ustrbuf.hxx>
28 #include <tools/debug.hxx>
29 #include <svl/lngmisc.hxx>
30 #include <unotools/localedatawrapper.hxx>
32 using namespace osl;
33 using namespace com::sun::star;
34 using namespace com::sun::star::lang;
35 using namespace com::sun::star::uno;
36 using namespace com::sun::star::linguistic2;
39 namespace linguistic
43 HyphenatedWord::HyphenatedWord(const OUString &rWord, sal_Int16 nLang, sal_Int16 nHPos,
44 const OUString &rHyphWord, sal_Int16 nPos ) :
45 aWord (rWord),
46 aHyphenatedWord (rHyphWord),
47 nHyphPos (nPos),
48 nHyphenationPos (nHPos),
49 nLanguage (nLang)
51 String aSingleQuote( GetLocaleDataWrapper( nLanguage ).getQuotationMarkEnd() );
52 DBG_ASSERT( 1 == aSingleQuote.Len(), "unexpectend length of quotation mark" );
53 if (aSingleQuote.Len())
55 // ignore typographical apostrophes (which got replaced in original
56 // word when being checked for hyphenation) in results.
57 OUString aTmpWord( rWord );
58 OUString aTmpHyphWord( rHyphWord );
59 aTmpWord = aTmpWord .replace( aSingleQuote.GetChar(0), '\'' );
60 aTmpHyphWord = aTmpHyphWord.replace( aSingleQuote.GetChar(0), '\'' );
61 bIsAltSpelling = aTmpWord != aTmpHyphWord;
63 else
64 bIsAltSpelling = rWord != rHyphWord;
68 HyphenatedWord::~HyphenatedWord()
73 OUString SAL_CALL HyphenatedWord::getWord()
74 throw(RuntimeException)
76 MutexGuard aGuard( GetLinguMutex() );
77 return aWord;
81 Locale SAL_CALL HyphenatedWord::getLocale()
82 throw(RuntimeException)
84 MutexGuard aGuard( GetLinguMutex() );
86 return LanguageTag( nLanguage ).getLocale();
90 sal_Int16 SAL_CALL HyphenatedWord::getHyphenationPos()
91 throw(RuntimeException)
93 MutexGuard aGuard( GetLinguMutex() );
94 return nHyphenationPos;
98 OUString SAL_CALL HyphenatedWord::getHyphenatedWord()
99 throw(RuntimeException)
101 MutexGuard aGuard( GetLinguMutex() );
102 return aHyphenatedWord;
106 sal_Int16 SAL_CALL HyphenatedWord::getHyphenPos()
107 throw(RuntimeException)
109 MutexGuard aGuard( GetLinguMutex() );
110 return nHyphPos;
114 sal_Bool SAL_CALL HyphenatedWord::isAlternativeSpelling()
115 throw(RuntimeException)
117 MutexGuard aGuard( GetLinguMutex() );
118 return bIsAltSpelling;
124 PossibleHyphens::PossibleHyphens(const OUString &rWord, sal_Int16 nLang,
125 const OUString &rHyphWord,
126 const Sequence< sal_Int16 > &rPositions) :
127 aWord (rWord),
128 aWordWithHyphens(rHyphWord),
129 aOrigHyphenPos (rPositions),
130 nLanguage (nLang)
135 PossibleHyphens::~PossibleHyphens()
140 OUString SAL_CALL PossibleHyphens::getWord()
141 throw(RuntimeException)
143 MutexGuard aGuard( GetLinguMutex() );
144 return aWord;
148 Locale SAL_CALL PossibleHyphens::getLocale()
149 throw(RuntimeException)
151 MutexGuard aGuard( GetLinguMutex() );
152 return LanguageTag( nLanguage ).getLocale();
156 OUString SAL_CALL PossibleHyphens::getPossibleHyphens()
157 throw(RuntimeException)
159 MutexGuard aGuard( GetLinguMutex() );
160 return aWordWithHyphens;
164 Sequence< sal_Int16 > SAL_CALL PossibleHyphens::getHyphenationPositions()
165 throw(RuntimeException)
167 MutexGuard aGuard( GetLinguMutex() );
168 return aOrigHyphenPos;
171 com::sun::star::uno::Reference <com::sun::star::linguistic2::XHyphenatedWord> HyphenatedWord::CreateHyphenatedWord(
172 const OUString &rWord, sal_Int16 nLang, sal_Int16 nHyphenationPos,
173 const OUString &rHyphenatedWord, sal_Int16 nHyphenPos )
175 return new HyphenatedWord( rWord, nLang, nHyphenationPos, rHyphenatedWord, nHyphenPos );
178 com::sun::star::uno::Reference < com::sun::star::linguistic2::XPossibleHyphens > PossibleHyphens::CreatePossibleHyphens
179 (const OUString &rWord, sal_Int16 nLang,
180 const OUString &rHyphWord,
181 const ::com::sun::star::uno::Sequence< sal_Int16 > &rPositions)
183 return new PossibleHyphens( rWord, nLang, rHyphWord, rPositions );
188 } // namespace linguistic
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */