1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/misc.hxx>
23 #include <osl/mutex.hxx>
26 #include <tools/debug.hxx>
27 #include <unotools/localedatawrapper.hxx>
31 using namespace com::sun::star
;
32 using namespace com::sun::star::lang
;
33 using namespace com::sun::star::uno
;
34 using namespace com::sun::star::linguistic2
;
41 HyphenatedWord::HyphenatedWord(const OUString
&rWord
, LanguageType nLang
, sal_Int16 nHPos
,
42 const OUString
&rHyphWord
, sal_Int16 nPos
) :
44 aHyphenatedWord (rHyphWord
),
46 nHyphenationPos (nHPos
),
49 OUString
aSingleQuote( GetLocaleDataWrapper( nLanguage
).getQuotationMarkEnd() );
50 DBG_ASSERT( 1 == aSingleQuote
.getLength(), "unexpected length of quotation mark" );
51 if (!aSingleQuote
.isEmpty())
53 // ignore typographical apostrophes (which got replaced in original
54 // word when being checked for hyphenation) in results.
55 OUString
aTmpWord( rWord
);
56 OUString
aTmpHyphWord( rHyphWord
);
57 aTmpWord
= aTmpWord
.replace( aSingleQuote
[0], '\'' );
58 aTmpHyphWord
= aTmpHyphWord
.replace( aSingleQuote
[0], '\'' );
59 bIsAltSpelling
= aTmpWord
!= aTmpHyphWord
;
62 bIsAltSpelling
= rWord
!= rHyphWord
;
66 HyphenatedWord::~HyphenatedWord()
71 OUString SAL_CALL
HyphenatedWord::getWord()
77 Locale SAL_CALL
HyphenatedWord::getLocale()
79 return LanguageTag::convertToLocale( nLanguage
);
83 sal_Int16 SAL_CALL
HyphenatedWord::getHyphenationPos()
85 return nHyphenationPos
;
89 OUString SAL_CALL
HyphenatedWord::getHyphenatedWord()
91 return aHyphenatedWord
;
95 sal_Int16 SAL_CALL
HyphenatedWord::getHyphenPos()
101 sal_Bool SAL_CALL
HyphenatedWord::isAlternativeSpelling()
103 return bIsAltSpelling
;
107 PossibleHyphens::PossibleHyphens(OUString aWord_
, LanguageType nLang
,
109 const Sequence
< sal_Int16
> &rPositions
) :
110 aWord (std::move(aWord_
)),
111 aWordWithHyphens(std::move(aHyphWord
)),
112 aOrigHyphenPos (rPositions
),
118 PossibleHyphens::~PossibleHyphens()
123 OUString SAL_CALL
PossibleHyphens::getWord()
129 Locale SAL_CALL
PossibleHyphens::getLocale()
131 return LanguageTag::convertToLocale( nLanguage
);
135 OUString SAL_CALL
PossibleHyphens::getPossibleHyphens()
137 return aWordWithHyphens
;
141 Sequence
< sal_Int16
> SAL_CALL
PossibleHyphens::getHyphenationPositions()
143 return aOrigHyphenPos
;
146 css::uno::Reference
<css::linguistic2::XHyphenatedWord
> HyphenatedWord::CreateHyphenatedWord(
147 const OUString
&rWord
, LanguageType nLang
, sal_Int16 nHyphenationPos
,
148 const OUString
&rHyphenatedWord
, sal_Int16 nHyphenPos
)
150 return new HyphenatedWord( rWord
, nLang
, nHyphenationPos
, rHyphenatedWord
, nHyphenPos
);
153 css::uno::Reference
< css::linguistic2::XPossibleHyphens
> PossibleHyphens::CreatePossibleHyphens
154 (const OUString
&rWord
, LanguageType nLang
,
155 const OUString
&rHyphWord
,
156 const css::uno::Sequence
< sal_Int16
> &rPositions
)
158 return new PossibleHyphens( rWord
, nLang
, rHyphWord
, rPositions
);
162 } // namespace linguistic
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */