diff options
author | Noel Grandin <noel@peralex.com> | 2012-10-15 15:20:48 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-10-23 15:27:49 +0200 |
commit | c0f865c9b5a34b272c9e0b22d18969554265914a (patch) | |
tree | ee4bc2c0579245e92f51c82d91136e32cce7c9ca /editeng | |
parent | e41f21b4165e40e1564cc75928b4b085ce7072e1 (diff) |
fdo#46808, use service constructor for i18n::BreakIterator
Note that I found a pre-existing bug in linguistic/source/gciterator.cxx
but I was not able to fix it, because doing so appears to expose
bugs elsewhere!
Change-Id: I17fb9108d98a98d0ae13fe5a8e043d2db5b27a6a
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 5 | ||||
-rw-r--r-- | editeng/source/misc/hangulhanja.cxx | 56 |
2 files changed, 27 insertions, 34 deletions
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 57ae2ea69344..854c4da9c941 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -70,6 +70,7 @@ #include <set> #include <math.h> #include <vcl/metric.hxx> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/text/CharacterCompressionType.hpp> #include <vcl/pdfextoutdevdata.hxx> @@ -4318,8 +4319,8 @@ Reference < i18n::XBreakIterator > ImpEditEngine::ImplGetBreakIterator() const { if ( !xBI.is() ) { - Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); - xBI.set( xMSF->createInstance( OUString( "com.sun.star.i18n.BreakIterator" ) ), UNO_QUERY ); + Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + xBI = i18n::BreakIterator::create( xContext ); } return xBI; } diff --git a/editeng/source/misc/hangulhanja.cxx b/editeng/source/misc/hangulhanja.cxx index 86bf60a38ffd..2c2d736cc7a8 100644 --- a/editeng/source/misc/hangulhanja.cxx +++ b/editeng/source/misc/hangulhanja.cxx @@ -34,8 +34,9 @@ #include <set> #include <map> +#include <comphelper/processfactory.hxx> #include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/i18n/UnicodeScript.hpp> #include <com/sun/star/i18n/XTextConversion.hpp> @@ -614,38 +615,29 @@ namespace editeng try { // get the break iterator service - ::rtl::OUString sBreakIteratorService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.BreakIterator" ) ); - Reference< XInterface > xBI( m_xORB->createInstance( ::rtl::OUString( sBreakIteratorService ) ) ); - Reference< XBreakIterator > xBreakIter( xBI, UNO_QUERY ); - if ( !xBreakIter.is() ) - { - ShowServiceNotAvailableError( m_pUIParent, sBreakIteratorService, sal_True ); - } - else - { - sal_Int32 nNextAsianScript = xBreakIter->beginOfScript( m_sCurrentPortion, m_nCurrentStartIndex, com::sun::star::i18n::ScriptType::ASIAN ); - if ( -1 == nNextAsianScript ) - nNextAsianScript = xBreakIter->nextScript( m_sCurrentPortion, m_nCurrentStartIndex, com::sun::star::i18n::ScriptType::ASIAN ); - if ( ( nNextAsianScript >= m_nCurrentStartIndex ) && ( nNextAsianScript < m_sCurrentPortion.getLength() ) ) - { // found asian text - - // determine if it's Hangul - CharClass aCharClassificaton( m_xORB, m_aSourceLocale ); - sal_Int16 nScript = aCharClassificaton.getScript( m_sCurrentPortion, sal::static_int_cast< sal_uInt16 >(nNextAsianScript) ); - if ( ( UnicodeScript_kHangulJamo == nScript ) - || ( UnicodeScript_kHangulCompatibilityJamo == nScript ) - || ( UnicodeScript_kHangulSyllable == nScript ) - ) - { - rDirection = HHC::eHangulToHanja; - } - else - { - rDirection = HHC::eHanjaToHangul; - } - - bSuccess = true; + Reference< XBreakIterator > xBreakIter = BreakIterator::create( comphelper::getComponentContext(m_xORB) ); + sal_Int32 nNextAsianScript = xBreakIter->beginOfScript( m_sCurrentPortion, m_nCurrentStartIndex, com::sun::star::i18n::ScriptType::ASIAN ); + if ( -1 == nNextAsianScript ) + nNextAsianScript = xBreakIter->nextScript( m_sCurrentPortion, m_nCurrentStartIndex, com::sun::star::i18n::ScriptType::ASIAN ); + if ( ( nNextAsianScript >= m_nCurrentStartIndex ) && ( nNextAsianScript < m_sCurrentPortion.getLength() ) ) + { // found asian text + + // determine if it's Hangul + CharClass aCharClassificaton( m_xORB, m_aSourceLocale ); + sal_Int16 nScript = aCharClassificaton.getScript( m_sCurrentPortion, sal::static_int_cast< sal_uInt16 >(nNextAsianScript) ); + if ( ( UnicodeScript_kHangulJamo == nScript ) + || ( UnicodeScript_kHangulCompatibilityJamo == nScript ) + || ( UnicodeScript_kHangulSyllable == nScript ) + ) + { + rDirection = HHC::eHangulToHanja; } + else + { + rDirection = HHC::eHanjaToHangul; + } + + bSuccess = true; } } catch( const Exception& ) |