1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _I18N_BREAKITERATOR_UNICODE_HXX_
24 #define _I18N_BREAKITERATOR_UNICODE_HXX_
25 
26 #include <breakiteratorImpl.hxx>
27 
28 #include "warnings_guard_unicode_brkiter.h"
29 
30 namespace com { namespace sun { namespace star { namespace i18n {
31 
32 #define LOAD_CHARACTER_BREAKITERATOR    0
33 #define LOAD_WORD_BREAKITERATOR         1
34 #define LOAD_SENTENCE_BREAKITERATOR     2
35 #define LOAD_LINE_BREAKITERATOR         3
36 
37 //	----------------------------------------------------
38 //	class BreakIterator_Unicode
39 //	----------------------------------------------------
40 class BreakIterator_Unicode : public BreakIteratorImpl
41 {
42 public:
43 	BreakIterator_Unicode();
44 	~BreakIterator_Unicode();
45 
46 	virtual sal_Int32 SAL_CALL previousCharacters( const rtl::OUString& Text, sal_Int32 nStartPos,
47 		const com::sun::star::lang::Locale& nLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount,
48 		sal_Int32& nDone ) throw(com::sun::star::uno::RuntimeException);
49 	virtual sal_Int32 SAL_CALL nextCharacters( const rtl::OUString& Text, sal_Int32 nStartPos,
50 		const com::sun::star::lang::Locale& rLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount,
51 		sal_Int32& nDone ) throw(com::sun::star::uno::RuntimeException);
52 
53 	virtual Boundary SAL_CALL previousWord( const rtl::OUString& Text, sal_Int32 nStartPos,
54 		const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType) throw(com::sun::star::uno::RuntimeException);
55 	virtual Boundary SAL_CALL nextWord( const rtl::OUString& Text, sal_Int32 nStartPos,
56 		const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType) throw(com::sun::star::uno::RuntimeException);
57 	virtual Boundary SAL_CALL getWordBoundary( const rtl::OUString& Text, sal_Int32 nPos,
58 		const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType, sal_Bool bDirection )
59 		throw(com::sun::star::uno::RuntimeException);
60 
61 	virtual sal_Int32 SAL_CALL beginOfSentence( const rtl::OUString& Text, sal_Int32 nStartPos,
62 		const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException);
63 	virtual sal_Int32 SAL_CALL endOfSentence( const rtl::OUString& Text, sal_Int32 nStartPos,
64 		const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException);
65 
66 	virtual LineBreakResults SAL_CALL getLineBreak( const rtl::OUString& Text, sal_Int32 nStartPos,
67 		const com::sun::star::lang::Locale& nLocale, sal_Int32 nMinBreakPos,
68 		const LineBreakHyphenationOptions& hOptions, const LineBreakUserOptions& bOptions )
69 		throw(com::sun::star::uno::RuntimeException);
70 
71 	//XServiceInfo
72 	virtual rtl::OUString SAL_CALL getImplementationName() throw( com::sun::star::uno::RuntimeException );
73 	virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
74 		throw( com::sun::star::uno::RuntimeException );
75 	virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames()
76 		throw( com::sun::star::uno::RuntimeException );
77 
78 protected:
79 	const sal_Char *cBreakIterator, *wordRule, *lineRule;
80 	Boundary result; // for word break iterator
81 
82     struct BI_Data {
83         UnicodeString aICUText;
84         icu::BreakIterator *aBreakIterator;
85 
BI_Datacom::sun::star::i18n::BreakIterator_Unicode::BI_Data86         BI_Data() : aICUText(), aBreakIterator(NULL) {}
87     } character, word, sentence, line, *icuBI;
88 
89     com::sun::star::lang::Locale aLocale;
90     sal_Int16 aBreakType, aWordType;
91 
92     void SAL_CALL loadICUBreakIterator(const com::sun::star::lang::Locale& rLocale,
93         sal_Int16 rBreakType, sal_Int16 rWordType, const sal_Char* name, const rtl::OUString& rText) throw(com::sun::star::uno::RuntimeException);
94 };
95 
96 } } } }
97 
98 #endif
99