Branch libreoffice-5-0-4
[LibreOffice.git] / i18npool / inc / breakiteratorImpl.hxx
blobbeb857243e7bcc3a0ddc52341372a23084c2ba4e
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/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>
35 #include <vector>
37 namespace com { namespace sun { namespace star { namespace i18n {
40 // class BreakIterator
42 class BreakIteratorImpl : public cppu::WeakImplHelper2
44 XBreakIterator,
45 com::sun::star::lang::XServiceInfo
48 public:
49 BreakIteratorImpl( const com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext >& rxContext );
50 BreakIteratorImpl();
51 virtual ~BreakIteratorImpl();
53 virtual sal_Int32 SAL_CALL nextCharacters( const 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, std::exception) SAL_OVERRIDE;
56 virtual sal_Int32 SAL_CALL previousCharacters( const 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, std::exception) SAL_OVERRIDE;
60 virtual Boundary SAL_CALL previousWord( const OUString& Text, sal_Int32 nStartPos,
61 const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
62 virtual Boundary SAL_CALL nextWord( const OUString& Text, sal_Int32 nStartPos,
63 const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
64 virtual Boundary SAL_CALL getWordBoundary( const 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, std::exception) SAL_OVERRIDE;
68 virtual sal_Bool SAL_CALL isBeginWord( const OUString& Text, sal_Int32 nPos,
69 const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
70 virtual sal_Bool SAL_CALL isEndWord( const OUString& Text, sal_Int32 nPos,
71 const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
72 virtual sal_Int16 SAL_CALL getWordType( const OUString& Text, sal_Int32 nPos,
73 const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
75 virtual sal_Int32 SAL_CALL beginOfSentence( const OUString& Text, sal_Int32 nStartPos,
76 const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
77 virtual sal_Int32 SAL_CALL endOfSentence( const OUString& Text, sal_Int32 nStartPos,
78 const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 virtual LineBreakResults SAL_CALL getLineBreak( const 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, std::exception) SAL_OVERRIDE;
85 virtual sal_Int16 SAL_CALL getScriptType( const OUString& Text, sal_Int32 nPos )
86 throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 virtual sal_Int32 SAL_CALL beginOfScript( const OUString& Text, sal_Int32 nStartPos,
88 sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 virtual sal_Int32 SAL_CALL endOfScript( const OUString& Text, sal_Int32 nStartPos,
90 sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 virtual sal_Int32 SAL_CALL previousScript( const OUString& Text, sal_Int32 nStartPos,
92 sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
93 virtual sal_Int32 SAL_CALL nextScript( const OUString& Text, sal_Int32 nStartPos,
94 sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 virtual sal_Int32 SAL_CALL beginOfCharBlock( const OUString& Text, sal_Int32 nStartPos,
97 const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 virtual sal_Int32 SAL_CALL endOfCharBlock( const OUString& Text, sal_Int32 nStartPos,
99 const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 virtual sal_Int32 SAL_CALL previousCharBlock( const OUString& Text, sal_Int32 nStartPos,
101 const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 virtual sal_Int32 SAL_CALL nextCharBlock( const OUString& Text, sal_Int32 nStartPos,
103 const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
105 //XServiceInfo
106 virtual OUString SAL_CALL getImplementationName() throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
107 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
108 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
109 virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
110 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
112 static sal_Int16 SAL_CALL getScriptClass(sal_uInt32 currentChar);
113 protected:
114 Boundary result; // for word break iterator
116 private :
118 struct lookupTableItem {
119 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;
123 std::vector<lookupTableItem*> lookupTable;
124 com::sun::star::lang::Locale aLocale;
125 com::sun::star::uno::Reference < XBreakIterator > xBI;
126 com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xContext;
128 bool SAL_CALL createLocaleSpecificBreakIterator( const 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 OUString& Text,
133 sal_Int32 nStartPos, bool forward, bool skipWhiteSpace)
134 throw(com::sun::star::uno::RuntimeException);
138 } // i18n
139 } // star
140 } // sun
141 } // com
144 #endif // INCLUDED_I18NPOOL_INC_BREAKITERATORIMPL_HXX
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */