1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/XMultiServiceFactory.hpp>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/beans/PropertyValues.hpp>
25 #include <com/sun/star/i18n/XBreakIterator.hpp>
26 #include <com/sun/star/i18n/WordType.hpp>
27 #include <com/sun/star/i18n/BreakType.hpp>
28 #include <com/sun/star/i18n/ScriptType.hpp>
29 #include <com/sun/star/i18n/CharacterIteratorMode.hpp>
30 #include <com/sun/star/i18n/CharType.hpp>
31 #include <com/sun/star/i18n/XLocaleData.hpp>
32 #include <com/sun/star/uno/XComponentContext.hpp>
33 #include <cppuhelper/implbase.hxx>
40 // class BreakIterator
42 class BreakIteratorImpl
: public cppu::WeakImplHelper
44 css::i18n::XBreakIterator
,
45 css::lang::XServiceInfo
49 BreakIteratorImpl( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
51 virtual ~BreakIteratorImpl() override
;
53 virtual sal_Int32 SAL_CALL
nextCharacters( const OUString
& Text
, sal_Int32 nStartPos
,
54 const css::lang::Locale
& rLocale
, sal_Int16 nCharacterIteratorMode
, sal_Int32 nCount
,
55 sal_Int32
& nDone
) override
;
56 virtual sal_Int32 SAL_CALL
previousCharacters( const OUString
& Text
, sal_Int32 nStartPos
,
57 const css::lang::Locale
& nLocale
, sal_Int16 nCharacterIteratorMode
, sal_Int32 nCount
,
58 sal_Int32
& nDone
) override
;
60 virtual css::i18n::Boundary SAL_CALL
previousWord( const OUString
& Text
, sal_Int32 nStartPos
,
61 const css::lang::Locale
& nLocale
, sal_Int16 WordType
) override
;
62 virtual css::i18n::Boundary SAL_CALL
nextWord( const OUString
& Text
, sal_Int32 nStartPos
,
63 const css::lang::Locale
& nLocale
, sal_Int16 WordType
) override
;
64 virtual css::i18n::Boundary SAL_CALL
getWordBoundary( const OUString
& Text
, sal_Int32 nPos
,
65 const css::lang::Locale
& nLocale
, sal_Int16 WordType
, sal_Bool bDirection
) override
;
67 virtual sal_Bool SAL_CALL
isBeginWord( const OUString
& Text
, sal_Int32 nPos
,
68 const css::lang::Locale
& nLocale
, sal_Int16 WordType
) override
;
69 virtual sal_Bool SAL_CALL
isEndWord( const OUString
& Text
, sal_Int32 nPos
,
70 const css::lang::Locale
& nLocale
, sal_Int16 WordType
) override
;
71 virtual sal_Int16 SAL_CALL
getWordType( const OUString
& Text
, sal_Int32 nPos
,
72 const css::lang::Locale
& nLocale
) override
;
74 virtual sal_Int32 SAL_CALL
beginOfSentence( const OUString
& Text
, sal_Int32 nStartPos
,
75 const css::lang::Locale
& nLocale
) override
;
76 virtual sal_Int32 SAL_CALL
endOfSentence( const OUString
& Text
, sal_Int32 nStartPos
,
77 const css::lang::Locale
& nLocale
) override
;
79 virtual css::i18n::LineBreakResults SAL_CALL
getLineBreak( const OUString
& Text
, sal_Int32 nStartPos
,
80 const css::lang::Locale
& nLocale
, sal_Int32 nMinBreakPos
,
81 const css::i18n::LineBreakHyphenationOptions
& hOptions
,
82 const css::i18n::LineBreakUserOptions
& bOptions
) override
;
84 virtual sal_Int16 SAL_CALL
getScriptType( const OUString
& Text
, sal_Int32 nPos
) override
;
85 virtual sal_Int32 SAL_CALL
beginOfScript( const OUString
& Text
, sal_Int32 nStartPos
,
86 sal_Int16 ScriptType
) override
;
87 virtual sal_Int32 SAL_CALL
endOfScript( const OUString
& Text
, sal_Int32 nStartPos
,
88 sal_Int16 ScriptType
) override
;
89 virtual sal_Int32 SAL_CALL
previousScript( const OUString
& Text
, sal_Int32 nStartPos
,
90 sal_Int16 ScriptType
) override
;
91 virtual sal_Int32 SAL_CALL
nextScript( const OUString
& Text
, sal_Int32 nStartPos
,
92 sal_Int16 ScriptType
) override
;
94 virtual sal_Int32 SAL_CALL
beginOfCharBlock( const OUString
& Text
, sal_Int32 nStartPos
,
95 const css::lang::Locale
& nLocale
, sal_Int16 CharType
) override
;
96 virtual sal_Int32 SAL_CALL
endOfCharBlock( const OUString
& Text
, sal_Int32 nStartPos
,
97 const css::lang::Locale
& nLocale
, sal_Int16 CharType
) override
;
98 virtual sal_Int32 SAL_CALL
previousCharBlock( const OUString
& Text
, sal_Int32 nStartPos
,
99 const css::lang::Locale
& nLocale
, sal_Int16 CharType
) override
;
100 virtual sal_Int32 SAL_CALL
nextCharBlock( const OUString
& Text
, sal_Int32 nStartPos
,
101 const css::lang::Locale
& nLocale
, sal_Int16 CharType
) override
;
104 virtual OUString SAL_CALL
getImplementationName() override
;
105 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
106 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
108 static sal_Int16
getScriptClass(sal_uInt32 currentChar
);
110 css::i18n::Boundary result
; // for word break iterator
114 struct lookupTableItem
{
115 lookupTableItem(const css::lang::Locale
& _aLocale
, css::uno::Reference
< XBreakIterator
> const & _xBI
) : aLocale(_aLocale
), xBI(_xBI
) {};
116 css::lang::Locale aLocale
;
117 css::uno::Reference
< XBreakIterator
> xBI
;
119 std::vector
<lookupTableItem
> lookupTable
;
120 css::lang::Locale aLocale
;
121 css::uno::Reference
< XBreakIterator
> xBI
;
122 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
124 /// @throws css::uno::RuntimeException
125 bool createLocaleSpecificBreakIterator( const OUString
& aLocaleName
);
126 /// @throws css::uno::RuntimeException
127 css::uno::Reference
< XBreakIterator
> getLocaleSpecificBreakIterator( const css::lang::Locale
& rLocale
);
134 #endif // INCLUDED_I18NPOOL_INC_BREAKITERATORIMPL_HXX
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */