update dev300-m58
[ooovba.git] / sw / inc / breakit.hxx
blob5901718c7e9870a6e729eaec623317f8fc0524f6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: breakit.hxx,v $
10 * $Revision: 1.12.112.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _BREAKIT_HXX
32 #define _BREAKIT_HXX
34 #include <tools/solar.h>
35 #include <i18npool/lang.h>
36 #include <com/sun/star/uno/Reference.h>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/i18n/XBreakIterator.hpp>
39 #include <com/sun/star/i18n/XScriptTypeDetector.hpp>
40 #include <com/sun/star/i18n/ForbiddenCharacters.hdl>
41 #include <swdllapi.h>
43 class String;
45 /*************************************************************************
46 * class SwBreakIt
47 *************************************************************************/
50 class SW_DLLPUBLIC SwBreakIt
52 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMSF;
53 mutable com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > xBreak;
54 com::sun::star::uno::Reference< com::sun::star::i18n::XScriptTypeDetector > xCTLDetect;
57 com::sun::star::lang::Locale * m_pLocale;
58 com::sun::star::i18n::ForbiddenCharacters * m_pForbidden;
60 LanguageType aLast; // language of the current locale
61 LanguageType aForbiddenLang; // language of the current forbiddenChar struct
63 void _GetLocale( const LanguageType aLang );
64 void _GetForbidden( const LanguageType aLang );
66 void createBreakIterator() const;
67 void createScriptTypeDetector();
69 // forbidden and not implemented.
70 SwBreakIt();
71 SwBreakIt( const SwBreakIt &);
72 SwBreakIt & operator= ( const SwBreakIt &);
74 // private (see @ _Create, _Delete).
75 explicit SwBreakIt(
76 const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rxMSF);
77 ~SwBreakIt();
79 public:
80 // private (see @ source/core/bastyp/init.cxx).
81 static void _Create(
82 const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rxMSF);
83 static void _Delete();
85 public:
86 static SwBreakIt * Get();
88 com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > GetBreakIter()
90 createBreakIterator();
91 return xBreak;
94 com::sun::star::uno::Reference< com::sun::star::i18n::XScriptTypeDetector > GetScriptTypeDetector()
96 createScriptTypeDetector();
97 return xCTLDetect;
100 const com::sun::star::lang::Locale& GetLocale( const LanguageType aLang )
102 if( !m_pLocale || aLast != aLang )
103 _GetLocale( aLang );
104 return *m_pLocale;
107 const com::sun::star::i18n::ForbiddenCharacters& GetForbidden( const LanguageType aLang )
109 if( !m_pForbidden || aForbiddenLang != aLang )
110 _GetForbidden( aLang );
111 return *m_pForbidden;
114 USHORT GetRealScriptOfText( const String& rTxt, xub_StrLen nPos ) const;
115 USHORT GetAllScriptsOfText( const String& rTxt ) const;
118 #define SW_BREAKITER() SwBreakIt::Get()
119 #define SW_XBREAKITER() SW_BREAKITER()->GetBreakIter()
121 // @@@ backward compatibility @@@
122 SW_DLLPUBLIC extern SwBreakIt* pBreakIt;
124 #endif