1*1d2dbeb0SAndrew Rist /************************************************************** 2*1d2dbeb0SAndrew Rist * 3*1d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1d2dbeb0SAndrew Rist * distributed with this work for additional information 6*1d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 9*1d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 10*1d2dbeb0SAndrew Rist * 11*1d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*1d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 15*1d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 17*1d2dbeb0SAndrew Rist * specific language governing permissions and limitations 18*1d2dbeb0SAndrew Rist * under the License. 19*1d2dbeb0SAndrew Rist * 20*1d2dbeb0SAndrew Rist *************************************************************/ 21*1d2dbeb0SAndrew Rist 22*1d2dbeb0SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _BREAKIT_HXX 25cdf0e10cSrcweir #define _BREAKIT_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <tools/solar.h> 28cdf0e10cSrcweir #include <i18npool/lang.h> 29cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 30cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 31cdf0e10cSrcweir #include <com/sun/star/i18n/XBreakIterator.hpp> 32cdf0e10cSrcweir #include <com/sun/star/i18n/XScriptTypeDetector.hpp> 33cdf0e10cSrcweir #include <com/sun/star/i18n/ForbiddenCharacters.hdl> 34cdf0e10cSrcweir #include <swdllapi.h> 35cdf0e10cSrcweir 36cdf0e10cSrcweir class String; 37cdf0e10cSrcweir 38cdf0e10cSrcweir /************************************************************************* 39cdf0e10cSrcweir * class SwBreakIt 40cdf0e10cSrcweir *************************************************************************/ 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir class SW_DLLPUBLIC SwBreakIt 44cdf0e10cSrcweir { 45cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMSF; 46cdf0e10cSrcweir mutable com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > xBreak; 47cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::i18n::XScriptTypeDetector > xCTLDetect; 48cdf0e10cSrcweir 49cdf0e10cSrcweir 50cdf0e10cSrcweir com::sun::star::lang::Locale * m_pLocale; 51cdf0e10cSrcweir com::sun::star::i18n::ForbiddenCharacters * m_pForbidden; 52cdf0e10cSrcweir 53cdf0e10cSrcweir LanguageType aLast; // language of the current locale 54cdf0e10cSrcweir LanguageType aForbiddenLang; // language of the current forbiddenChar struct 55cdf0e10cSrcweir 56cdf0e10cSrcweir void _GetLocale( const LanguageType aLang ); 57cdf0e10cSrcweir void _GetForbidden( const LanguageType aLang ); 58cdf0e10cSrcweir 59cdf0e10cSrcweir void createBreakIterator() const; 60cdf0e10cSrcweir void createScriptTypeDetector(); 61cdf0e10cSrcweir 62cdf0e10cSrcweir // forbidden and not implemented. 63cdf0e10cSrcweir SwBreakIt(); 64cdf0e10cSrcweir SwBreakIt( const SwBreakIt &); 65cdf0e10cSrcweir SwBreakIt & operator= ( const SwBreakIt &); 66cdf0e10cSrcweir 67cdf0e10cSrcweir // private (see @ _Create, _Delete). 68cdf0e10cSrcweir explicit SwBreakIt( 69cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rxMSF); 70cdf0e10cSrcweir ~SwBreakIt(); 71cdf0e10cSrcweir 72cdf0e10cSrcweir public: 73cdf0e10cSrcweir // private (see @ source/core/bastyp/init.cxx). 74cdf0e10cSrcweir static void _Create( 75cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rxMSF); 76cdf0e10cSrcweir static void _Delete(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir public: 79cdf0e10cSrcweir static SwBreakIt * Get(); 80cdf0e10cSrcweir GetBreakIter()81cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > GetBreakIter() 82cdf0e10cSrcweir { 83cdf0e10cSrcweir createBreakIterator(); 84cdf0e10cSrcweir return xBreak; 85cdf0e10cSrcweir } 86cdf0e10cSrcweir GetScriptTypeDetector()87cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::i18n::XScriptTypeDetector > GetScriptTypeDetector() 88cdf0e10cSrcweir { 89cdf0e10cSrcweir createScriptTypeDetector(); 90cdf0e10cSrcweir return xCTLDetect; 91cdf0e10cSrcweir } 92cdf0e10cSrcweir GetLocale(const LanguageType aLang)93cdf0e10cSrcweir const com::sun::star::lang::Locale& GetLocale( const LanguageType aLang ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir if( !m_pLocale || aLast != aLang ) 96cdf0e10cSrcweir _GetLocale( aLang ); 97cdf0e10cSrcweir return *m_pLocale; 98cdf0e10cSrcweir } 99cdf0e10cSrcweir GetForbidden(const LanguageType aLang)100cdf0e10cSrcweir const com::sun::star::i18n::ForbiddenCharacters& GetForbidden( const LanguageType aLang ) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir if( !m_pForbidden || aForbiddenLang != aLang ) 103cdf0e10cSrcweir _GetForbidden( aLang ); 104cdf0e10cSrcweir return *m_pForbidden; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir sal_uInt16 GetRealScriptOfText( const String& rTxt, xub_StrLen nPos ) const; 108cdf0e10cSrcweir sal_uInt16 GetAllScriptsOfText( const String& rTxt ) const; 109cdf0e10cSrcweir }; 110cdf0e10cSrcweir 111cdf0e10cSrcweir #define SW_BREAKITER() SwBreakIt::Get() 112cdf0e10cSrcweir #define SW_XBREAKITER() SW_BREAKITER()->GetBreakIter() 113cdf0e10cSrcweir 114cdf0e10cSrcweir // @@@ backward compatibility @@@ 115cdf0e10cSrcweir SW_DLLPUBLIC extern SwBreakIt* pBreakIt; 116cdf0e10cSrcweir 117cdf0e10cSrcweir #endif 118cdf0e10cSrcweir 119