Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/linguistic/source/hyphdta.cxx
Line
Count
Source
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
21
#include <linguistic/hyphdta.hxx>
22
#include <linguistic/misc.hxx>
23
#include <osl/mutex.hxx>
24
25
26
#include <tools/debug.hxx>
27
#include <unotools/localedatawrapper.hxx>
28
#include <utility>
29
30
using namespace com::sun::star;
31
using namespace com::sun::star::lang;
32
using namespace com::sun::star::uno;
33
using namespace com::sun::star::linguistic2;
34
35
36
namespace linguistic
37
{
38
39
40
HyphenatedWord::HyphenatedWord(const OUString &rWord, LanguageType nLang, sal_Int16 nHPos,
41
                               const OUString &rHyphWord, sal_Int16 nPos ) :
42
0
    aWord           (rWord),
43
0
    aHyphenatedWord (rHyphWord),
44
0
    nHyphPos        (nPos),
45
0
    nHyphenationPos (nHPos),
46
0
    nLanguage       (nLang)
47
0
{
48
0
    OUString aSingleQuote( GetLocaleDataWrapper( nLanguage ).getQuotationMarkEnd() );
49
0
    DBG_ASSERT( 1 == aSingleQuote.getLength(), "unexpected length of quotation mark" );
50
0
    if (!aSingleQuote.isEmpty())
51
0
    {
52
        // ignore typographical apostrophes (which got replaced in original
53
        // word when being checked for hyphenation) in results.
54
0
        OUString aTmpWord( rWord );
55
0
        OUString aTmpHyphWord( rHyphWord );
56
0
        aTmpWord        = aTmpWord    .replace( aSingleQuote[0], '\'' );
57
0
        aTmpHyphWord    = aTmpHyphWord.replace( aSingleQuote[0], '\'' );
58
0
        bIsAltSpelling  = aTmpWord != aTmpHyphWord;
59
0
    }
60
0
    else
61
0
        bIsAltSpelling = rWord != rHyphWord;
62
0
}
63
64
65
HyphenatedWord::~HyphenatedWord()
66
0
{
67
0
}
68
69
70
OUString SAL_CALL HyphenatedWord::getWord()
71
0
{
72
0
    return aWord;
73
0
}
74
75
76
Locale SAL_CALL HyphenatedWord::getLocale()
77
0
{
78
0
    return LanguageTag::convertToLocale( nLanguage );
79
0
}
80
81
82
sal_Int16 SAL_CALL HyphenatedWord::getHyphenationPos()
83
0
{
84
0
    return nHyphenationPos;
85
0
}
86
87
88
OUString SAL_CALL HyphenatedWord::getHyphenatedWord()
89
0
{
90
0
    return aHyphenatedWord;
91
0
}
92
93
94
sal_Int16 SAL_CALL HyphenatedWord::getHyphenPos()
95
0
{
96
0
    return nHyphPos;
97
0
}
98
99
100
sal_Bool SAL_CALL HyphenatedWord::isAlternativeSpelling()
101
0
{
102
0
    return bIsAltSpelling;
103
0
}
104
105
106
PossibleHyphens::PossibleHyphens(OUString aWord_, LanguageType nLang,
107
            OUString aHyphWord,
108
            const Sequence< sal_Int16 > &rPositions) :
109
0
    aWord           (std::move(aWord_)),
110
0
    aWordWithHyphens(std::move(aHyphWord)),
111
0
    aOrigHyphenPos  (rPositions),
112
0
    nLanguage       (nLang)
113
0
{
114
0
}
115
116
117
PossibleHyphens::~PossibleHyphens()
118
0
{
119
0
}
120
121
122
OUString SAL_CALL PossibleHyphens::getWord()
123
0
{
124
0
    return aWord;
125
0
}
126
127
128
Locale SAL_CALL PossibleHyphens::getLocale()
129
0
{
130
0
    return LanguageTag::convertToLocale( nLanguage );
131
0
}
132
133
134
OUString SAL_CALL PossibleHyphens::getPossibleHyphens()
135
0
{
136
0
    return aWordWithHyphens;
137
0
}
138
139
140
Sequence< sal_Int16 > SAL_CALL PossibleHyphens::getHyphenationPositions()
141
0
{
142
0
    return aOrigHyphenPos;
143
0
}
144
145
css::uno::Reference <css::linguistic2::XHyphenatedWord> HyphenatedWord::CreateHyphenatedWord(
146
        const OUString &rWord, LanguageType nLang, sal_Int16 nHyphenationPos,
147
        const OUString &rHyphenatedWord, sal_Int16 nHyphenPos )
148
0
{
149
0
    return new HyphenatedWord( rWord, nLang, nHyphenationPos, rHyphenatedWord, nHyphenPos );
150
0
}
151
152
css::uno::Reference < css::linguistic2::XPossibleHyphens > PossibleHyphens::CreatePossibleHyphens
153
        (const OUString &rWord, LanguageType nLang,
154
         const OUString &rHyphWord,
155
         const css::uno::Sequence< sal_Int16 > &rPositions)
156
0
{
157
0
    return new PossibleHyphens( rWord, nLang, rHyphWord, rPositions );
158
0
}
159
160
161
}   // namespace linguistic
162
163
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */