Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / i18npool / inc / breakiterator_unicode.hxx
blob22bcbb75179797cf33e4d6f9862c652c3ab2f9fc
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_BREAKITERATOR_UNICODE_HXX
20 #define INCLUDED_I18NPOOL_INC_BREAKITERATOR_UNICODE_HXX
22 #include <breakiteratorImpl.hxx>
24 #include <unicode/brkiter.h>
26 namespace com { namespace sun { namespace star { namespace i18n {
28 #define LOAD_CHARACTER_BREAKITERATOR 0
29 #define LOAD_WORD_BREAKITERATOR 1
30 #define LOAD_SENTENCE_BREAKITERATOR 2
31 #define LOAD_LINE_BREAKITERATOR 3
34 // class BreakIterator_Unicode
36 class BreakIterator_Unicode : public BreakIteratorImpl
38 public:
39 BreakIterator_Unicode();
40 virtual ~BreakIterator_Unicode();
42 virtual sal_Int32 SAL_CALL previousCharacters( const OUString& Text, sal_Int32 nStartPos,
43 const css::lang::Locale& nLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount,
44 sal_Int32& nDone ) throw(css::uno::RuntimeException, std::exception) override;
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 ) throw(css::uno::RuntimeException, std::exception) override;
49 virtual Boundary SAL_CALL previousWord( const OUString& Text, sal_Int32 nStartPos,
50 const css::lang::Locale& nLocale, sal_Int16 WordType) throw(css::uno::RuntimeException, std::exception) override;
51 virtual Boundary SAL_CALL nextWord( const OUString& Text, sal_Int32 nStartPos,
52 const css::lang::Locale& nLocale, sal_Int16 WordType) throw(css::uno::RuntimeException, std::exception) override;
53 virtual Boundary SAL_CALL getWordBoundary( const OUString& Text, sal_Int32 nPos,
54 const css::lang::Locale& nLocale, sal_Int16 WordType, sal_Bool bDirection )
55 throw(css::uno::RuntimeException, std::exception) override;
57 virtual sal_Int32 SAL_CALL beginOfSentence( const OUString& Text, sal_Int32 nStartPos,
58 const css::lang::Locale& nLocale ) throw(css::uno::RuntimeException, std::exception) override;
59 virtual sal_Int32 SAL_CALL endOfSentence( const OUString& Text, sal_Int32 nStartPos,
60 const css::lang::Locale& nLocale ) throw(css::uno::RuntimeException, std::exception) override;
62 virtual LineBreakResults SAL_CALL getLineBreak( const OUString& Text, sal_Int32 nStartPos,
63 const css::lang::Locale& nLocale, sal_Int32 nMinBreakPos,
64 const LineBreakHyphenationOptions& hOptions, const LineBreakUserOptions& bOptions )
65 throw(css::uno::RuntimeException, std::exception) override;
67 //XServiceInfo
68 virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override;
69 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
70 throw( css::uno::RuntimeException, std::exception ) override;
71 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
72 throw( css::uno::RuntimeException, std::exception ) override;
74 protected:
75 const sal_Char *cBreakIterator, *lineRule;
76 Boundary result; // for word break iterator
78 struct BI_Data
80 OUString aICUText;
81 UText* ut;
82 icu::BreakIterator* aBreakIterator;
83 css::lang::Locale maLocale;
85 BI_Data() : ut(nullptr), aBreakIterator(nullptr)
88 ~BI_Data()
90 utext_close(ut);
93 } character, sentence, line, *icuBI;
94 BI_Data words[4]; // 4 is css::i18n::WordType enumeration size
96 void SAL_CALL loadICUBreakIterator(const css::lang::Locale& rLocale,
97 sal_Int16 rBreakType, sal_Int16 rWordType, const sal_Char* name, const OUString& rText) throw(css::uno::RuntimeException);
100 } } } }
102 #endif
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */