1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _I18N_BREAKITERATOR_HXX_ 28 #define _I18N_BREAKITERATOR_HXX_ 29 30 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 31 #include <comphelper/processfactory.hxx> 32 #include <com/sun/star/lang/XServiceInfo.hpp> 33 #include <com/sun/star/beans/PropertyValues.hpp> 34 #include <com/sun/star/i18n/XBreakIterator.hpp> 35 #include <com/sun/star/i18n/WordType.hpp> 36 #include <com/sun/star/i18n/BreakType.hpp> 37 #include <com/sun/star/i18n/ScriptType.hpp> 38 #include <com/sun/star/i18n/CharacterIteratorMode.hpp> 39 #include <com/sun/star/i18n/CharType.hpp> 40 #include <com/sun/star/i18n/XLocaleData.hpp> 41 #include <cppuhelper/implbase2.hxx> // helper for implementations 42 43 #include <vector> 44 45 namespace com { namespace sun { namespace star { namespace i18n { 46 47 // ---------------------------------------------------- 48 // class BreakIterator 49 // ---------------------------------------------------- 50 class BreakIteratorImpl : public cppu::WeakImplHelper2 51 < 52 XBreakIterator, 53 com::sun::star::lang::XServiceInfo 54 > 55 { 56 public: 57 BreakIteratorImpl( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF ); 58 BreakIteratorImpl(); 59 ~BreakIteratorImpl(); 60 61 virtual sal_Int32 SAL_CALL nextCharacters( const rtl::OUString& Text, sal_Int32 nStartPos, 62 const com::sun::star::lang::Locale& rLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, 63 sal_Int32& nDone ) throw(com::sun::star::uno::RuntimeException); 64 virtual sal_Int32 SAL_CALL previousCharacters( const rtl::OUString& Text, sal_Int32 nStartPos, 65 const com::sun::star::lang::Locale& nLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, 66 sal_Int32& nDone ) throw(com::sun::star::uno::RuntimeException); 67 68 virtual Boundary SAL_CALL previousWord( const rtl::OUString& Text, sal_Int32 nStartPos, 69 const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType) throw(com::sun::star::uno::RuntimeException); 70 virtual Boundary SAL_CALL nextWord( const rtl::OUString& Text, sal_Int32 nStartPos, 71 const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType) throw(com::sun::star::uno::RuntimeException); 72 virtual Boundary SAL_CALL getWordBoundary( const rtl::OUString& Text, sal_Int32 nPos, 73 const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType, sal_Bool bDirection ) 74 throw(com::sun::star::uno::RuntimeException); 75 76 virtual sal_Bool SAL_CALL isBeginWord( const rtl::OUString& Text, sal_Int32 nPos, 77 const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType ) throw(com::sun::star::uno::RuntimeException); 78 virtual sal_Bool SAL_CALL isEndWord( const rtl::OUString& Text, sal_Int32 nPos, 79 const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType ) throw(com::sun::star::uno::RuntimeException); 80 virtual sal_Int16 SAL_CALL getWordType( const rtl::OUString& Text, sal_Int32 nPos, 81 const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException); 82 83 virtual sal_Int32 SAL_CALL beginOfSentence( const rtl::OUString& Text, sal_Int32 nStartPos, 84 const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException); 85 virtual sal_Int32 SAL_CALL endOfSentence( const rtl::OUString& Text, sal_Int32 nStartPos, 86 const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException); 87 88 virtual LineBreakResults SAL_CALL getLineBreak( const rtl::OUString& Text, sal_Int32 nStartPos, 89 const com::sun::star::lang::Locale& nLocale, sal_Int32 nMinBreakPos, 90 const LineBreakHyphenationOptions& hOptions, const LineBreakUserOptions& bOptions ) 91 throw(com::sun::star::uno::RuntimeException); 92 93 virtual sal_Int16 SAL_CALL getScriptType( const rtl::OUString& Text, sal_Int32 nPos ) 94 throw(com::sun::star::uno::RuntimeException); 95 virtual sal_Int32 SAL_CALL beginOfScript( const rtl::OUString& Text, sal_Int32 nStartPos, 96 sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException); 97 virtual sal_Int32 SAL_CALL endOfScript( const rtl::OUString& Text, sal_Int32 nStartPos, 98 sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException); 99 virtual sal_Int32 SAL_CALL previousScript( const rtl::OUString& Text, sal_Int32 nStartPos, 100 sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException); 101 virtual sal_Int32 SAL_CALL nextScript( const rtl::OUString& Text, sal_Int32 nStartPos, 102 sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException); 103 104 virtual sal_Int32 SAL_CALL beginOfCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos, 105 const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException); 106 virtual sal_Int32 SAL_CALL endOfCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos, 107 const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException); 108 virtual sal_Int32 SAL_CALL previousCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos, 109 const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException); 110 virtual sal_Int32 SAL_CALL nextCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos, 111 const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException); 112 113 //XServiceInfo 114 virtual rtl::OUString SAL_CALL getImplementationName() throw( com::sun::star::uno::RuntimeException ); 115 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) 116 throw( com::sun::star::uno::RuntimeException ); 117 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() 118 throw( com::sun::star::uno::RuntimeException ); 119 120 static sal_Int16 SAL_CALL getScriptClass(sal_uInt32 currentChar); 121 protected: 122 Boundary result; // for word break iterator 123 124 private : 125 126 struct lookupTableItem { 127 lookupTableItem(const com::sun::star::lang::Locale& _aLocale, com::sun::star::uno::Reference < XBreakIterator >& _xBI) : aLocale(_aLocale), xBI(_xBI) {}; 128 com::sun::star::lang::Locale aLocale; 129 com::sun::star::uno::Reference < XBreakIterator > xBI; 130 }; 131 std::vector<lookupTableItem*> lookupTable; 132 com::sun::star::lang::Locale aLocale; 133 com::sun::star::uno::Reference < XBreakIterator > xBI; 134 135 com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF; 136 sal_Bool SAL_CALL createLocaleSpecificBreakIterator( const rtl::OUString& aLocaleName ) 137 throw( com::sun::star::uno::RuntimeException ); 138 com::sun::star::uno::Reference < XBreakIterator > SAL_CALL getLocaleSpecificBreakIterator( const com::sun::star::lang::Locale& rLocale ) 139 throw( com::sun::star::uno::RuntimeException ); 140 const com::sun::star::lang::Locale& SAL_CALL getLocaleByScriptType(const com::sun::star::lang::Locale& rLocale, const rtl::OUString& Text, 141 sal_Int32 nStartPos, sal_Bool forward, sal_Bool skipWhiteSpace) 142 throw(com::sun::star::uno::RuntimeException); 143 144 }; 145 146 } // i18n 147 } // star 148 } // sun 149 } // com 150 151 152 #endif // _I18N_BREAKITERATOR_HXX_ 153