Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/i18npool/inc/breakiteratorImpl.hxx
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
#pragma once
20
21
#include <i18npool/breakiterator.hxx>
22
23
#include <utility>
24
#include <vector>
25
26
namespace com::sun::star::uno { class XComponentContext; }
27
28
namespace i18npool {
29
30
class BreakIteratorImpl : public BreakIterator
31
{
32
public:
33
    BreakIteratorImpl( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
34
    BreakIteratorImpl();
35
    virtual ~BreakIteratorImpl() override;
36
37
    virtual sal_Int32 SAL_CALL nextCharacters( const OUString& Text, sal_Int32 nStartPos,
38
        const css::lang::Locale& rLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount,
39
        sal_Int32& nDone ) override;
40
    virtual sal_Int32 SAL_CALL previousCharacters( const OUString& Text, sal_Int32 nStartPos,
41
        const css::lang::Locale& nLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount,
42
        sal_Int32& nDone ) override;
43
44
    virtual css::i18n::Boundary SAL_CALL previousWord( const OUString& Text, sal_Int32 nStartPos,
45
        const css::lang::Locale& nLocale, sal_Int16 WordType) override;
46
    virtual css::i18n::Boundary SAL_CALL nextWord( const OUString& Text, sal_Int32 nStartPos,
47
        const css::lang::Locale& nLocale, sal_Int16 WordType) override;
48
    virtual css::i18n::Boundary SAL_CALL getWordBoundary( const OUString& Text, sal_Int32 nPos,
49
        const css::lang::Locale& nLocale, sal_Int16 WordType, sal_Bool bDirection ) override;
50
51
    virtual sal_Bool SAL_CALL isBeginWord( const OUString& Text, sal_Int32 nPos,
52
        const css::lang::Locale& nLocale, sal_Int16 WordType ) override;
53
    virtual sal_Bool SAL_CALL isEndWord( const OUString& Text, sal_Int32 nPos,
54
        const css::lang::Locale& nLocale, sal_Int16 WordType ) override;
55
    virtual sal_Int16 SAL_CALL getWordType( const OUString& Text, sal_Int32 nPos,
56
        const css::lang::Locale& nLocale ) override;
57
58
    virtual sal_Int32 SAL_CALL beginOfSentence( const OUString& Text, sal_Int32 nStartPos,
59
        const css::lang::Locale& nLocale ) override;
60
    virtual sal_Int32 SAL_CALL endOfSentence( const OUString& Text, sal_Int32 nStartPos,
61
        const css::lang::Locale& nLocale ) override;
62
63
    virtual css::i18n::LineBreakResults SAL_CALL getLineBreak( const OUString& Text, sal_Int32 nStartPos,
64
        const css::lang::Locale& nLocale, sal_Int32 nMinBreakPos,
65
        const css::i18n::LineBreakHyphenationOptions& hOptions,
66
        const css::i18n::LineBreakUserOptions& bOptions ) override;
67
68
    virtual sal_Int16 SAL_CALL getScriptType( const OUString& Text, sal_Int32 nPos ) override;
69
    virtual sal_Int32 SAL_CALL beginOfScript( const OUString& Text, sal_Int32 nStartPos,
70
        sal_Int16 ScriptType ) override;
71
    virtual sal_Int32 SAL_CALL endOfScript( const OUString& Text, sal_Int32 nStartPos,
72
        sal_Int16 ScriptType ) override;
73
    virtual sal_Int32 SAL_CALL previousScript( const OUString& Text, sal_Int32 nStartPos,
74
        sal_Int16 ScriptType ) override;
75
    virtual sal_Int32 SAL_CALL nextScript( const OUString& Text, sal_Int32 nStartPos,
76
        sal_Int16 ScriptType ) override;
77
78
    virtual sal_Int32 SAL_CALL beginOfCharBlock( const OUString& Text, sal_Int32 nStartPos,
79
        const css::lang::Locale& nLocale, sal_Int16 CharType ) override;
80
    virtual sal_Int32 SAL_CALL endOfCharBlock( const OUString& Text, sal_Int32 nStartPos,
81
        const css::lang::Locale& nLocale, sal_Int16 CharType ) override;
82
    virtual sal_Int32 SAL_CALL previousCharBlock( const OUString& Text, sal_Int32 nStartPos,
83
        const css::lang::Locale& nLocale, sal_Int16 CharType ) override;
84
    virtual sal_Int32 SAL_CALL nextCharBlock( const OUString& Text, sal_Int32 nStartPos,
85
        const css::lang::Locale& nLocale, sal_Int16 CharType ) override;
86
87
    //XServiceInfo
88
    virtual OUString SAL_CALL getImplementationName() override;
89
    virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
90
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
91
92
    virtual sal_Int32 endOfScript( std::u16string_view Text, sal_Int32 nStartPos, sal_Int16 ScriptType ) override;
93
    virtual sal_Int32 beginOfScript( std::u16string_view Text, sal_Int32 nStartPos, sal_Int16 ScriptType ) override;
94
95
    static sal_Int16 getScriptClass(sal_uInt32 currentChar);
96
protected:
97
    css::i18n::Boundary result; // for word break iterator
98
99
private:
100
101
    struct lookupTableItem {
102
873k
        lookupTableItem(css::lang::Locale _aLocale, css::uno::Reference < XBreakIterator > _xBI) : aLocale(std::move(_aLocale)), xBI(std::move(_xBI)) {};
103
        css::lang::Locale aLocale;
104
        css::uno::Reference < XBreakIterator > xBI;
105
    };
106
    std::vector<lookupTableItem>                        lookupTable;
107
    css::lang::Locale                                   aLocale;
108
    css::uno::Reference < XBreakIterator >              xBI;
109
    css::uno::Reference < css::uno::XComponentContext > m_xContext;
110
111
    /// @throws css::uno::RuntimeException
112
    bool createLocaleSpecificBreakIterator( const OUString& aLocaleName );
113
    /// @throws css::uno::RuntimeException
114
    const css::uno::Reference < XBreakIterator > & getLocaleSpecificBreakIterator( const css::lang::Locale& rLocale );
115
116
};
117
118
} // i18npool
119
120
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */