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