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