diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-03-08 09:04:14 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-03-08 12:02:38 +0000 |
commit | 0c816004eac48a7ac5d571fdf9a46db9fc497958 (patch) | |
tree | 0d92d0d05ee8cf0db7756c9ae8cbd9e90180198d /sw | |
parent | 80b0a3a7b647b3d60379344a37a5f9b15a2bbfe9 (diff) |
tidy up SwBreakIt
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/breakit.hxx | 17 | ||||
-rw-r--r-- | sw/source/core/bastyp/breakit.cxx | 36 |
2 files changed, 23 insertions, 30 deletions
diff --git a/sw/inc/breakit.hxx b/sw/inc/breakit.hxx index 93186f55cbd3..5fa2bd5c3ac5 100644 --- a/sw/inc/breakit.hxx +++ b/sw/inc/breakit.hxx @@ -29,23 +29,21 @@ #ifndef _BREAKIT_HXX #define _BREAKIT_HXX -#include <tools/solar.h> -#include <i18npool/lang.h> +#include <boost/noncopyable.hpp> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/i18n/XBreakIterator.hpp> #include <com/sun/star/i18n/XScriptTypeDetector.hpp> #include <com/sun/star/i18n/ForbiddenCharacters.hdl> +#include <i18npool/lang.h> #include <swdllapi.h> -class String; - /************************************************************************* * class SwBreakIt *************************************************************************/ -class SW_DLLPUBLIC SwBreakIt +class SW_DLLPUBLIC SwBreakIt : private ::boost::noncopyable { com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMSF; mutable com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > xBreak; @@ -61,11 +59,6 @@ class SW_DLLPUBLIC SwBreakIt void createBreakIterator() const; - // forbidden and not implemented. - SwBreakIt(); - SwBreakIt( const SwBreakIt &); - SwBreakIt & operator= ( const SwBreakIt &); - // private (see @ _Create, _Delete). explicit SwBreakIt( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rxMSF); @@ -100,8 +93,8 @@ public: return *m_pForbidden; } - sal_uInt16 GetRealScriptOfText( const String& rTxt, xub_StrLen nPos ) const; - sal_uInt16 GetAllScriptsOfText( const String& rTxt ) const; + sal_uInt16 GetRealScriptOfText( const rtl::OUString& rTxt, sal_Int32 nPos ) const; + sal_uInt16 GetAllScriptsOfText( const rtl::OUString& rTxt ) const; sal_Int32 getGraphemeCount(const rtl::OUString& rStr) const; }; diff --git a/sw/source/core/bastyp/breakit.cxx b/sw/source/core/bastyp/breakit.cxx index 9b4476fa4d59..313fdcac9cb7 100644 --- a/sw/source/core/bastyp/breakit.cxx +++ b/sw/source/core/bastyp/breakit.cxx @@ -97,34 +97,34 @@ void SwBreakIt::_GetForbidden( const LanguageType aLang ) m_pForbidden = new i18n::ForbiddenCharacters( aWrap.getForbiddenCharacters() ); } -sal_uInt16 SwBreakIt::GetRealScriptOfText( const String& rTxt, - xub_StrLen nPos ) const +sal_uInt16 SwBreakIt::GetRealScriptOfText( const rtl::OUString& rTxt, sal_Int32 nPos ) const { createBreakIterator(); sal_uInt16 nScript = i18n::ScriptType::WEAK; - if( xBreak.is() && rTxt.Len() ) + if( xBreak.is() && !rTxt.isEmpty() ) { - if( nPos && nPos == rTxt.Len() ) + if( nPos && nPos == rTxt.getLength() ) --nPos; nScript = xBreak->getScriptType( rTxt, nPos ); sal_Int32 nChgPos = 0; - if ( i18n::ScriptType::WEAK == nScript && nPos + 1 < rTxt.Len() ) + if ( i18n::ScriptType::WEAK == nScript && nPos + 1 < rTxt.getLength() ) { // A weak character followed by a mark may be meant to combine with // the mark, so prefer the following character's script - switch ( u_charType(rTxt.GetChar(nPos + 1) ) ) { - case U_NON_SPACING_MARK: - case U_ENCLOSING_MARK: - case U_COMBINING_SPACING_MARK: - nScript = xBreak->getScriptType( rTxt, nPos+1 ); - break; + switch (u_charType(rTxt[nPos + 1])) + { + case U_NON_SPACING_MARK: + case U_ENCLOSING_MARK: + case U_COMBINING_SPACING_MARK: + nScript = xBreak->getScriptType( rTxt, nPos+1 ); + break; } } if( i18n::ScriptType::WEAK == nScript && nPos && 0 < (nChgPos = xBreak->beginOfScript( rTxt, nPos, nScript )) ) nScript = xBreak->getScriptType( rTxt, nChgPos-1 ); - if( i18n::ScriptType::WEAK == nScript && rTxt.Len() > + if( i18n::ScriptType::WEAK == nScript && rTxt.getLength() > ( nChgPos = xBreak->endOfScript( rTxt, nPos, nScript ) ) && 0 <= nChgPos ) nScript = xBreak->getScriptType( rTxt, nChgPos ); @@ -134,7 +134,7 @@ sal_uInt16 SwBreakIt::GetRealScriptOfText( const String& rTxt, return nScript; } -sal_uInt16 SwBreakIt::GetAllScriptsOfText( const String& rTxt ) const +sal_uInt16 SwBreakIt::GetAllScriptsOfText( const rtl::OUString& rTxt ) const { const sal_uInt16 coAllScripts = ( SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | @@ -143,15 +143,15 @@ sal_uInt16 SwBreakIt::GetAllScriptsOfText( const String& rTxt ) const sal_uInt16 nRet = 0, nScript; if( !xBreak.is() ) nRet = coAllScripts; - else if( rTxt.Len() ) + else if( !rTxt.isEmpty() ) { - for( xub_StrLen n = 0, nEnd = rTxt.Len(); n < nEnd; - n = static_cast<xub_StrLen>(xBreak->endOfScript( rTxt, n, nScript )) ) + for( sal_Int32 n = 0, nEnd = rTxt.getLength(); n < nEnd; + n = xBreak->endOfScript(rTxt, n, nScript) ) { switch( nScript = xBreak->getScriptType( rTxt, n ) ) { - case i18n::ScriptType::LATIN: nRet |= SCRIPTTYPE_LATIN; break; - case i18n::ScriptType::ASIAN: nRet |= SCRIPTTYPE_ASIAN; break; + case i18n::ScriptType::LATIN: nRet |= SCRIPTTYPE_LATIN; break; + case i18n::ScriptType::ASIAN: nRet |= SCRIPTTYPE_ASIAN; break; case i18n::ScriptType::COMPLEX: nRet |= SCRIPTTYPE_COMPLEX; break; case i18n::ScriptType::WEAK: if( !nRet ) |