1*f7bd9df4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f7bd9df4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f7bd9df4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f7bd9df4SAndrew Rist * distributed with this work for additional information 6*f7bd9df4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f7bd9df4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f7bd9df4SAndrew Rist * "License"); you may not use this file except in compliance 9*f7bd9df4SAndrew Rist * with the License. You may obtain a copy of the License at 10*f7bd9df4SAndrew Rist * 11*f7bd9df4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f7bd9df4SAndrew Rist * 13*f7bd9df4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f7bd9df4SAndrew Rist * software distributed under the License is distributed on an 15*f7bd9df4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f7bd9df4SAndrew Rist * KIND, either express or implied. See the License for the 17*f7bd9df4SAndrew Rist * specific language governing permissions and limitations 18*f7bd9df4SAndrew Rist * under the License. 19*f7bd9df4SAndrew Rist * 20*f7bd9df4SAndrew Rist *************************************************************/ 21*f7bd9df4SAndrew Rist 22*f7bd9df4SAndrew Rist 23cdf0e10cSrcweir #ifndef _I18N_BREAKITERATOR_HXX_ 24cdf0e10cSrcweir #define _I18N_BREAKITERATOR_HXX_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 27cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 28cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 29cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValues.hpp> 30cdf0e10cSrcweir #include <com/sun/star/i18n/XBreakIterator.hpp> 31cdf0e10cSrcweir #include <com/sun/star/i18n/WordType.hpp> 32cdf0e10cSrcweir #include <com/sun/star/i18n/BreakType.hpp> 33cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp> 34cdf0e10cSrcweir #include <com/sun/star/i18n/CharacterIteratorMode.hpp> 35cdf0e10cSrcweir #include <com/sun/star/i18n/CharType.hpp> 36cdf0e10cSrcweir #include <com/sun/star/i18n/XLocaleData.hpp> 37cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> // helper for implementations 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <vector> 40cdf0e10cSrcweir 41cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace i18n { 42cdf0e10cSrcweir 43cdf0e10cSrcweir // ---------------------------------------------------- 44cdf0e10cSrcweir // class BreakIterator 45cdf0e10cSrcweir // ---------------------------------------------------- 46cdf0e10cSrcweir class BreakIteratorImpl : public cppu::WeakImplHelper2 47cdf0e10cSrcweir < 48cdf0e10cSrcweir XBreakIterator, 49cdf0e10cSrcweir com::sun::star::lang::XServiceInfo 50cdf0e10cSrcweir > 51cdf0e10cSrcweir { 52cdf0e10cSrcweir public: 53cdf0e10cSrcweir BreakIteratorImpl( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF ); 54cdf0e10cSrcweir BreakIteratorImpl(); 55cdf0e10cSrcweir ~BreakIteratorImpl(); 56cdf0e10cSrcweir 57cdf0e10cSrcweir virtual sal_Int32 SAL_CALL nextCharacters( const rtl::OUString& Text, sal_Int32 nStartPos, 58cdf0e10cSrcweir const com::sun::star::lang::Locale& rLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, 59cdf0e10cSrcweir sal_Int32& nDone ) throw(com::sun::star::uno::RuntimeException); 60cdf0e10cSrcweir virtual sal_Int32 SAL_CALL previousCharacters( const rtl::OUString& Text, sal_Int32 nStartPos, 61cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, 62cdf0e10cSrcweir sal_Int32& nDone ) throw(com::sun::star::uno::RuntimeException); 63cdf0e10cSrcweir 64cdf0e10cSrcweir virtual Boundary SAL_CALL previousWord( const rtl::OUString& Text, sal_Int32 nStartPos, 65cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType) throw(com::sun::star::uno::RuntimeException); 66cdf0e10cSrcweir virtual Boundary SAL_CALL nextWord( const rtl::OUString& Text, sal_Int32 nStartPos, 67cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType) throw(com::sun::star::uno::RuntimeException); 68cdf0e10cSrcweir virtual Boundary SAL_CALL getWordBoundary( const rtl::OUString& Text, sal_Int32 nPos, 69cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType, sal_Bool bDirection ) 70cdf0e10cSrcweir throw(com::sun::star::uno::RuntimeException); 71cdf0e10cSrcweir 72cdf0e10cSrcweir virtual sal_Bool SAL_CALL isBeginWord( const rtl::OUString& Text, sal_Int32 nPos, 73cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType ) throw(com::sun::star::uno::RuntimeException); 74cdf0e10cSrcweir virtual sal_Bool SAL_CALL isEndWord( const rtl::OUString& Text, sal_Int32 nPos, 75cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale, sal_Int16 WordType ) throw(com::sun::star::uno::RuntimeException); 76cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getWordType( const rtl::OUString& Text, sal_Int32 nPos, 77cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException); 78cdf0e10cSrcweir 79cdf0e10cSrcweir virtual sal_Int32 SAL_CALL beginOfSentence( const rtl::OUString& Text, sal_Int32 nStartPos, 80cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException); 81cdf0e10cSrcweir virtual sal_Int32 SAL_CALL endOfSentence( const rtl::OUString& Text, sal_Int32 nStartPos, 82cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale ) throw(com::sun::star::uno::RuntimeException); 83cdf0e10cSrcweir 84cdf0e10cSrcweir virtual LineBreakResults SAL_CALL getLineBreak( const rtl::OUString& Text, sal_Int32 nStartPos, 85cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale, sal_Int32 nMinBreakPos, 86cdf0e10cSrcweir const LineBreakHyphenationOptions& hOptions, const LineBreakUserOptions& bOptions ) 87cdf0e10cSrcweir throw(com::sun::star::uno::RuntimeException); 88cdf0e10cSrcweir 89cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getScriptType( const rtl::OUString& Text, sal_Int32 nPos ) 90cdf0e10cSrcweir throw(com::sun::star::uno::RuntimeException); 91cdf0e10cSrcweir virtual sal_Int32 SAL_CALL beginOfScript( const rtl::OUString& Text, sal_Int32 nStartPos, 92cdf0e10cSrcweir sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException); 93cdf0e10cSrcweir virtual sal_Int32 SAL_CALL endOfScript( const rtl::OUString& Text, sal_Int32 nStartPos, 94cdf0e10cSrcweir sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException); 95cdf0e10cSrcweir virtual sal_Int32 SAL_CALL previousScript( const rtl::OUString& Text, sal_Int32 nStartPos, 96cdf0e10cSrcweir sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException); 97cdf0e10cSrcweir virtual sal_Int32 SAL_CALL nextScript( const rtl::OUString& Text, sal_Int32 nStartPos, 98cdf0e10cSrcweir sal_Int16 ScriptType ) throw(com::sun::star::uno::RuntimeException); 99cdf0e10cSrcweir 100cdf0e10cSrcweir virtual sal_Int32 SAL_CALL beginOfCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos, 101cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException); 102cdf0e10cSrcweir virtual sal_Int32 SAL_CALL endOfCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos, 103cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException); 104cdf0e10cSrcweir virtual sal_Int32 SAL_CALL previousCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos, 105cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException); 106cdf0e10cSrcweir virtual sal_Int32 SAL_CALL nextCharBlock( const rtl::OUString& Text, sal_Int32 nStartPos, 107cdf0e10cSrcweir const com::sun::star::lang::Locale& nLocale, sal_Int16 CharType ) throw(com::sun::star::uno::RuntimeException); 108cdf0e10cSrcweir 109cdf0e10cSrcweir //XServiceInfo 110cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getImplementationName() throw( com::sun::star::uno::RuntimeException ); 111cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) 112cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 113cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() 114cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir static sal_Int16 SAL_CALL getScriptClass(sal_uInt32 currentChar); 117cdf0e10cSrcweir protected: 118cdf0e10cSrcweir Boundary result; // for word break iterator 119cdf0e10cSrcweir 120cdf0e10cSrcweir private : 121cdf0e10cSrcweir 122cdf0e10cSrcweir struct lookupTableItem { lookupTableItemcom::sun::star::i18n::BreakIteratorImpl::lookupTableItem123cdf0e10cSrcweir lookupTableItem(const com::sun::star::lang::Locale& _aLocale, com::sun::star::uno::Reference < XBreakIterator >& _xBI) : aLocale(_aLocale), xBI(_xBI) {}; 124cdf0e10cSrcweir com::sun::star::lang::Locale aLocale; 125cdf0e10cSrcweir com::sun::star::uno::Reference < XBreakIterator > xBI; 126cdf0e10cSrcweir }; 127cdf0e10cSrcweir std::vector<lookupTableItem*> lookupTable; 128cdf0e10cSrcweir com::sun::star::lang::Locale aLocale; 129cdf0e10cSrcweir com::sun::star::uno::Reference < XBreakIterator > xBI; 130cdf0e10cSrcweir 131cdf0e10cSrcweir com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF; 132cdf0e10cSrcweir sal_Bool SAL_CALL createLocaleSpecificBreakIterator( const rtl::OUString& aLocaleName ) 133cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 134cdf0e10cSrcweir com::sun::star::uno::Reference < XBreakIterator > SAL_CALL getLocaleSpecificBreakIterator( const com::sun::star::lang::Locale& rLocale ) 135cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 136cdf0e10cSrcweir const com::sun::star::lang::Locale& SAL_CALL getLocaleByScriptType(const com::sun::star::lang::Locale& rLocale, const rtl::OUString& Text, 137cdf0e10cSrcweir sal_Int32 nStartPos, sal_Bool forward, sal_Bool skipWhiteSpace) 138cdf0e10cSrcweir throw(com::sun::star::uno::RuntimeException); 139cdf0e10cSrcweir 140cdf0e10cSrcweir }; 141cdf0e10cSrcweir 142cdf0e10cSrcweir } // i18n 143cdf0e10cSrcweir } // star 144cdf0e10cSrcweir } // sun 145cdf0e10cSrcweir } // com 146cdf0e10cSrcweir 147cdf0e10cSrcweir 148cdf0e10cSrcweir #endif // _I18N_BREAKITERATOR_HXX_ 149