Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / i18npool / inc / breakiteratorImpl.hxx
blob38fa40fe80b4f61bfcffd1eea207615094277c29
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_I18NPOOL_INC_BREAKITERATORIMPL_HXX
20 #define INCLUDED_I18NPOOL_INC_BREAKITERATORIMPL_HXX
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/i18n/XBreakIterator.hpp>
24 #include <cppuhelper/implbase.hxx>
26 #include <vector>
28 namespace com::sun::star::uno { class XComponentContext; }
30 namespace i18npool {
33 // class BreakIterator
35 class BreakIteratorImpl : public cppu::WeakImplHelper
37 css::i18n::XBreakIterator,
38 css::lang::XServiceInfo
41 public:
42 BreakIteratorImpl( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
43 BreakIteratorImpl();
44 virtual ~BreakIteratorImpl() override;
46 virtual sal_Int32 SAL_CALL nextCharacters( const OUString& Text, sal_Int32 nStartPos,
47 const css::lang::Locale& rLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount,
48 sal_Int32& nDone ) override;
49 virtual sal_Int32 SAL_CALL previousCharacters( const OUString& Text, sal_Int32 nStartPos,
50 const css::lang::Locale& nLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount,
51 sal_Int32& nDone ) override;
53 virtual css::i18n::Boundary SAL_CALL previousWord( const OUString& Text, sal_Int32 nStartPos,
54 const css::lang::Locale& nLocale, sal_Int16 WordType) override;
55 virtual css::i18n::Boundary SAL_CALL nextWord( const OUString& Text, sal_Int32 nStartPos,
56 const css::lang::Locale& nLocale, sal_Int16 WordType) override;
57 virtual css::i18n::Boundary SAL_CALL getWordBoundary( const OUString& Text, sal_Int32 nPos,
58 const css::lang::Locale& nLocale, sal_Int16 WordType, sal_Bool bDirection ) override;
60 virtual sal_Bool SAL_CALL isBeginWord( const OUString& Text, sal_Int32 nPos,
61 const css::lang::Locale& nLocale, sal_Int16 WordType ) override;
62 virtual sal_Bool SAL_CALL isEndWord( const OUString& Text, sal_Int32 nPos,
63 const css::lang::Locale& nLocale, sal_Int16 WordType ) override;
64 virtual sal_Int16 SAL_CALL getWordType( const OUString& Text, sal_Int32 nPos,
65 const css::lang::Locale& nLocale ) override;
67 virtual sal_Int32 SAL_CALL beginOfSentence( const OUString& Text, sal_Int32 nStartPos,
68 const css::lang::Locale& nLocale ) override;
69 virtual sal_Int32 SAL_CALL endOfSentence( const OUString& Text, sal_Int32 nStartPos,
70 const css::lang::Locale& nLocale ) override;
72 virtual css::i18n::LineBreakResults SAL_CALL getLineBreak( const OUString& Text, sal_Int32 nStartPos,
73 const css::lang::Locale& nLocale, sal_Int32 nMinBreakPos,
74 const css::i18n::LineBreakHyphenationOptions& hOptions,
75 const css::i18n::LineBreakUserOptions& bOptions ) override;
77 virtual sal_Int16 SAL_CALL getScriptType( const OUString& Text, sal_Int32 nPos ) override;
78 virtual sal_Int32 SAL_CALL beginOfScript( const OUString& Text, sal_Int32 nStartPos,
79 sal_Int16 ScriptType ) override;
80 virtual sal_Int32 SAL_CALL endOfScript( const OUString& Text, sal_Int32 nStartPos,
81 sal_Int16 ScriptType ) override;
82 virtual sal_Int32 SAL_CALL previousScript( const OUString& Text, sal_Int32 nStartPos,
83 sal_Int16 ScriptType ) override;
84 virtual sal_Int32 SAL_CALL nextScript( const OUString& Text, sal_Int32 nStartPos,
85 sal_Int16 ScriptType ) override;
87 virtual sal_Int32 SAL_CALL beginOfCharBlock( const OUString& Text, sal_Int32 nStartPos,
88 const css::lang::Locale& nLocale, sal_Int16 CharType ) override;
89 virtual sal_Int32 SAL_CALL endOfCharBlock( const OUString& Text, sal_Int32 nStartPos,
90 const css::lang::Locale& nLocale, sal_Int16 CharType ) override;
91 virtual sal_Int32 SAL_CALL previousCharBlock( const OUString& Text, sal_Int32 nStartPos,
92 const css::lang::Locale& nLocale, sal_Int16 CharType ) override;
93 virtual sal_Int32 SAL_CALL nextCharBlock( const OUString& Text, sal_Int32 nStartPos,
94 const css::lang::Locale& nLocale, sal_Int16 CharType ) override;
96 //XServiceInfo
97 virtual OUString SAL_CALL getImplementationName() override;
98 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
99 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
101 static sal_Int16 getScriptClass(sal_uInt32 currentChar);
102 protected:
103 css::i18n::Boundary result; // for word break iterator
105 private:
107 struct lookupTableItem {
108 lookupTableItem(const css::lang::Locale& _aLocale, css::uno::Reference < XBreakIterator > const & _xBI) : aLocale(_aLocale), xBI(_xBI) {};
109 css::lang::Locale aLocale;
110 css::uno::Reference < XBreakIterator > xBI;
112 std::vector<lookupTableItem> lookupTable;
113 css::lang::Locale aLocale;
114 css::uno::Reference < XBreakIterator > xBI;
115 css::uno::Reference < css::uno::XComponentContext > m_xContext;
117 /// @throws css::uno::RuntimeException
118 bool createLocaleSpecificBreakIterator( const OUString& aLocaleName );
119 /// @throws css::uno::RuntimeException
120 css::uno::Reference < XBreakIterator > getLocaleSpecificBreakIterator( const css::lang::Locale& rLocale );
124 } // i18npool
127 #endif // INCLUDED_I18NPOOL_INC_BREAKITERATORIMPL_HXX
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */