Branch data Line data Source code
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 : : #ifndef _I18N_BREAKITERATOR_HXX_
20 : : #define _I18N_BREAKITERATOR_HXX_
21 : :
22 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
23 : : #include <comphelper/processfactory.hxx>
24 : : #include <com/sun/star/lang/XServiceInfo.hpp>
25 : : #include <com/sun/star/beans/PropertyValues.hpp>
26 : : #include <com/sun/star/i18n/XBreakIterator.hpp>
27 : : #include <com/sun/star/i18n/WordType.hpp>
28 : : #include <com/sun/star/i18n/BreakType.hpp>
29 : : #include <com/sun/star/i18n/ScriptType.hpp>
30 : : #include <com/sun/star/i18n/CharacterIteratorMode.hpp>
31 : : #include <com/sun/star/i18n/CharType.hpp>
32 : : #include <com/sun/star/i18n/XLocaleData.hpp>
33 : : #include <cppuhelper/implbase2.hxx> // helper for implementations
34 : :
35 : : #include <vector>
36 : :
37 : : namespace com { namespace sun { namespace star { namespace i18n {
38 : :
39 : : // ----------------------------------------------------
40 : : // class BreakIterator
41 : : // ----------------------------------------------------
42 : : class BreakIteratorImpl : public cppu::WeakImplHelper2
43 : : <
44 : : XBreakIterator,
45 : : com::sun::star::lang::XServiceInfo
46 : : >
47 : : {
48 : : public:
49 : : BreakIteratorImpl( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
50 : : BreakIteratorImpl();
51 : : ~BreakIteratorImpl();
52 : :
53 : : virtual sal_Int32 SAL_CALL nextCharacters( const rtl::OUString& Text, sal_Int32 nStartPos,
54 : : const com::sun::star::lang::Locale& rLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount,
55 : : sal_Int32& nDone ) throw(com::sun::star::uno::RuntimeException);
56 : : virtual sal_Int32 SAL_CALL previousCharacters( const rtl::OUString& Text, sal_Int32 nStartPos,
57 : : const com::sun::star::lang::Locale& nLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount,
58 : : sal_Int32& nDone ) throw(com::sun::star::uno::RuntimeException);
59 : :
60 : : virtual Boundary SAL_CALL previousWord( const rtl::OUString& Text, sal_Int32 nStartPos,
61 : : const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType) throw(com::sun::star::uno::RuntimeException);
62 : : virtual Boundary SAL_CALL nextWord( const rtl::OUString& Text, sal_Int32 nStartPos,
63 : : const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType) throw(com::sun::star::uno::RuntimeException);
64 : : virtual Boundary SAL_CALL getWordBoundary( const rtl::OUString& Text, sal_Int32 nPos,
65 : : const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType, sal_Bool bDirection )
66 : : throw(com::sun::star::uno::RuntimeException);
67 : :
68 : : virtual sal_Bool SAL_CALL isBeginWord( const rtl::OUString& Text, sal_Int32 nPos,
69 : : const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType ) throw(com::sun::star::uno::RuntimeException);
70 : : virtual sal_Bool SAL_CALL isEndWord( const rtl::OUString& Text, sal_Int32 nPos,
71 : : const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType ) throw(com::sun::star::uno::RuntimeException);
72 : : virtual sal_Int16 SAL_CALL getWordType( const rtl::OUString& Text, sal_Int32 nPos,
73 : : const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException);
74 : :
75 : : virtual sal_Int32 SAL_CALL beginOfSentence( const rtl::OUString& Text, sal_Int32 nStartPos,
76 : : const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException);
77 : : virtual sal_Int32 SAL_CALL endOfSentence( const rtl::OUString& Text, sal_Int32 nStartPos,
78 : : const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException);
79 : :
80 : : virtual LineBreakResults SAL_CALL getLineBreak( const rtl::OUString& Text, sal_Int32 nStartPos,
81 : : const com::sun::star::lang::Locale& nLocale, sal_Int32 nMinBreakPos,
82 : : const LineBreakHyphenationOptions& hOptions, const LineBreakUserOptions& bOptions )
83 : : throw(com::sun::star::uno::RuntimeException);
84 : :
85 : : virtual sal_Int16 SAL_CALL getScriptType( const rtl::OUString& Text, sal_Int32 nPos )
86 : : throw(com::sun::star::uno::RuntimeException);
87 : : virtual sal_Int32 SAL_CALL beginOfScript( const rtl::OUString& Text, sal_Int32 nStartPos,
88 : : sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException);
89 : : virtual sal_Int32 SAL_CALL endOfScript( const rtl::OUString& Text, sal_Int32 nStartPos,
90 : : sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException);
91 : : virtual sal_Int32 SAL_CALL previousScript( const rtl::OUString& Text, sal_Int32 nStartPos,
92 : : sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException);
93 : : virtual sal_Int32 SAL_CALL nextScript( const rtl::OUString& Text, sal_Int32 nStartPos,
94 : : sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException);
95 : :
96 : : virtual sal_Int32 SAL_CALL beginOfCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos,
97 : : const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException);
98 : : virtual sal_Int32 SAL_CALL endOfCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos,
99 : : const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException);
100 : : virtual sal_Int32 SAL_CALL previousCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos,
101 : : const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException);
102 : : virtual sal_Int32 SAL_CALL nextCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos,
103 : : const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException);
104 : :
105 : : //XServiceInfo
106 : : virtual rtl::OUString SAL_CALL getImplementationName() throw( com::sun::star::uno::RuntimeException );
107 : : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
108 : : throw( com::sun::star::uno::RuntimeException );
109 : : virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames()
110 : : throw( com::sun::star::uno::RuntimeException );
111 : :
112 : : static sal_Int16 SAL_CALL getScriptClass(sal_uInt32 currentChar);
113 : : protected:
114 : : Boundary result; // for word break iterator
115 : :
116 : : private :
117 : :
118 : 4053 : struct lookupTableItem {
119 : 4081 : lookupTableItem(const com::sun::star::lang::Locale& _aLocale, com::sun::star::uno::Reference < XBreakIterator >& _xBI) : aLocale(_aLocale), xBI(_xBI) {};
120 : : com::sun::star::lang::Locale aLocale;
121 : : com::sun::star::uno::Reference < XBreakIterator > xBI;
122 : : };
123 : : std::vector<lookupTableItem*> lookupTable;
124 : : com::sun::star::lang::Locale aLocale;
125 : : com::sun::star::uno::Reference < XBreakIterator > xBI;
126 : :
127 : : com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF;
128 : : sal_Bool SAL_CALL createLocaleSpecificBreakIterator( const rtl::OUString& aLocaleName )
129 : : throw( com::sun::star::uno::RuntimeException );
130 : : com::sun::star::uno::Reference < XBreakIterator > SAL_CALL getLocaleSpecificBreakIterator( const com::sun::star::lang::Locale& rLocale )
131 : : throw( com::sun::star::uno::RuntimeException );
132 : : const com::sun::star::lang::Locale& SAL_CALL getLocaleByScriptType(const com::sun::star::lang::Locale& rLocale, const rtl::OUString& Text,
133 : : sal_Int32 nStartPos, sal_Bool forward, sal_Bool skipWhiteSpace)
134 : : throw(com::sun::star::uno::RuntimeException);
135 : :
136 : : };
137 : :
138 : : } // i18n
139 : : } // star
140 : : } // sun
141 : : } // com
142 : :
143 : :
144 : : #endif // _I18N_BREAKITERATOR_HXX_
145 : :
146 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|