LibreOffice Module linguistic (master) 1
hyphdta.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
22#include <linguistic/misc.hxx>
23#include <osl/mutex.hxx>
24
25
26#include <tools/debug.hxx>
28#include <utility>
29
30using namespace osl;
31using namespace com::sun::star;
32using namespace com::sun::star::lang;
33using namespace com::sun::star::uno;
34using namespace com::sun::star::linguistic2;
35
36
37namespace linguistic
38{
39
40
41HyphenatedWord::HyphenatedWord(const OUString &rWord, LanguageType nLang, sal_Int16 nHPos,
42 const OUString &rHyphWord, sal_Int16 nPos ) :
43 aWord (rWord),
44 aHyphenatedWord (rHyphWord),
45 nHyphPos (nPos),
46 nHyphenationPos (nHPos),
47 nLanguage (nLang)
48{
49 OUString aSingleQuote( GetLocaleDataWrapper( nLanguage ).getQuotationMarkEnd() );
50 DBG_ASSERT( 1 == aSingleQuote.getLength(), "unexpected length of quotation mark" );
51 if (!aSingleQuote.isEmpty())
52 {
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;
60 }
61 else
62 bIsAltSpelling = rWord != rHyphWord;
63}
64
65
67{
68}
69
70
71OUString SAL_CALL HyphenatedWord::getWord()
72{
73 return aWord;
74}
75
76
78{
80}
81
82
84{
85 return nHyphenationPos;
86}
87
88
90{
91 return aHyphenatedWord;
92}
93
94
95sal_Int16 SAL_CALL HyphenatedWord::getHyphenPos()
96{
97 return nHyphPos;
98}
99
100
102{
103 return bIsAltSpelling;
104}
105
106
108 OUString aHyphWord,
109 const Sequence< sal_Int16 > &rPositions) :
110 aWord (std::move(aWord_)),
111 aWordWithHyphens(std::move(aHyphWord)),
112 aOrigHyphenPos (rPositions),
113 nLanguage (nLang)
114{
115}
116
117
119{
120}
121
122
123OUString SAL_CALL PossibleHyphens::getWord()
124{
125 return aWord;
126}
127
128
130{
132}
133
134
136{
137 return aWordWithHyphens;
138}
139
140
142{
143 return aOrigHyphenPos;
144}
145
146css::uno::Reference <css::linguistic2::XHyphenatedWord> HyphenatedWord::CreateHyphenatedWord(
147 const OUString &rWord, LanguageType nLang, sal_Int16 nHyphenationPos,
148 const OUString &rHyphenatedWord, sal_Int16 nHyphenPos )
149{
151}
152
153css::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)
157{
158 return new PossibleHyphens( rWord, nLang, rHyphWord, rPositions );
159}
160
161
162} // namespace linguistic
163
164/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
virtual css::lang::Locale SAL_CALL getLocale() override
Definition: hyphdta.cxx:77
virtual ~HyphenatedWord() override
Definition: hyphdta.cxx:66
LanguageType nLanguage
Definition: hyphdta.hxx:40
static css::uno::Reference< css::linguistic2::XHyphenatedWord > LanguageType sal_Int16 const OUString sal_Int16 nHyphenPos
Definition: hyphdta.hxx:67
virtual sal_Bool SAL_CALL isAlternativeSpelling() override
Definition: hyphdta.cxx:101
virtual sal_Int16 SAL_CALL getHyphenationPos() override
Definition: hyphdta.cxx:83
virtual OUString SAL_CALL getWord() override
Definition: hyphdta.cxx:71
static css::uno::Reference< css::linguistic2::XHyphenatedWord > LanguageType nLang
Definition: hyphdta.hxx:66
virtual OUString SAL_CALL getHyphenatedWord() override
Definition: hyphdta.cxx:89
HyphenatedWord(const HyphenatedWord &)=delete
static css::uno::Reference< css::linguistic2::XHyphenatedWord > LanguageType sal_Int16 const OUString & rHyphenatedWord
Definition: hyphdta.hxx:67
virtual sal_Int16 SAL_CALL getHyphenPos() override
Definition: hyphdta.cxx:95
virtual css::uno::Sequence< sal_Int16 > SAL_CALL getHyphenationPositions() override
Definition: hyphdta.cxx:141
virtual ~PossibleHyphens() override
Definition: hyphdta.cxx:118
static css::uno::Reference< css::linguistic2::XPossibleHyphens > LanguageType const OUString const css::uno::Sequence< sal_Int16 > & rPositions
Definition: hyphdta.hxx:104
PossibleHyphens(const PossibleHyphens &)=delete
css::uno::Sequence< sal_Int16 > aOrigHyphenPos
Definition: hyphdta.hxx:79
static css::uno::Reference< css::linguistic2::XPossibleHyphens > LanguageType const OUString & rHyphWord
Definition: hyphdta.hxx:103
virtual OUString SAL_CALL getPossibleHyphens() override
Definition: hyphdta.cxx:135
virtual css::lang::Locale SAL_CALL getLocale() override
Definition: hyphdta.cxx:129
static css::uno::Reference< css::linguistic2::XPossibleHyphens > LanguageType nLang
Definition: hyphdta.hxx:102
virtual OUString SAL_CALL getWord() override
Definition: hyphdta.cxx:123
#define DBG_ASSERT(sCon, aError)
sal_uInt16 nPos
const LocaleDataWrapper & GetLocaleDataWrapper(LanguageType nLang)
Definition: misc.cxx:66
unsigned char sal_Bool