diff options
23 files changed, 207 insertions, 281 deletions
diff --git a/comphelper/source/misc/accessibletexthelper.cxx b/comphelper/source/misc/accessibletexthelper.cxx index ed85437a180e..6098abc2e3c8 100644 --- a/comphelper/source/misc/accessibletexthelper.cxx +++ b/comphelper/source/misc/accessibletexthelper.cxx @@ -19,6 +19,7 @@ #include <comphelper/accessibletexthelper.hxx> #include <com/sun/star/accessibility/AccessibleTextType.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/CharacterIteratorMode.hpp> #include <com/sun/star/i18n/WordType.hpp> #include <com/sun/star/i18n/KCharacterType.hpp> @@ -58,12 +59,8 @@ namespace comphelper { if ( !m_xBreakIter.is() ) { - Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - if ( xMSF.is() ) - { - m_xBreakIter = Reference< i18n::XBreakIterator > - ( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.BreakIterator" ) ) ), UNO_QUERY ); - } + Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + m_xBreakIter = i18n::BreakIterator::create(xContext); } return m_xBreakIter; diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx index d35a3faff0ec..2fe8a3f508f8 100644 --- a/comphelper/source/misc/string.cxx +++ b/comphelper/source/misc/string.cxx @@ -34,6 +34,7 @@ #include <comphelper/stlunosequence.hxx> #include <comphelper/stl_types.hxx> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/CharType.hpp> @@ -349,9 +350,7 @@ NaturalStringSorter::NaturalStringSorter( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.Collator")), rContext), uno::UNO_QUERY_THROW); m_xCollator->loadDefaultCollator(m_aLocale, 0); - m_xBI = uno::Reference< i18n::XBreakIterator >(xFactory->createInstanceWithContext( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.BreakIterator")), rContext), - uno::UNO_QUERY_THROW); + m_xBI = i18n::BreakIterator::create( rContext ); } namespace diff --git a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx index 1c6fca4b8200..68ebc91d9add 100644 --- a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx @@ -36,7 +36,7 @@ #include <com/sun/star/i18n/WordType.hpp> #include <drawinglayer/primitive2d/texteffectprimitive2d.hxx> #include <drawinglayer/primitive2d/shadowprimitive2d.hxx> -#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <drawinglayer/primitive2d/textlineprimitive2d.hxx> #include <drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx> @@ -206,11 +206,11 @@ namespace drawinglayer if(!xLocalBreakIterator.is()) { - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF(::comphelper::getProcessServiceFactory()); - xLocalBreakIterator.set(xMSF->createInstance("com.sun.star.i18n.BreakIterator"), ::com::sun::star::uno::UNO_QUERY); + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext(::comphelper::getProcessComponentContext()); + xLocalBreakIterator = com::sun::star::i18n::BreakIterator::create(xContext); } - if(xLocalBreakIterator.is() && getTextLength()) + if( getTextLength() ) { // init word iterator, get first word and truncate to possibilities ::com::sun::star::i18n::Boundary aNextWordBoundary(xLocalBreakIterator->getWordBoundary( diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 5f7d8e75c8fb..1ccfc5f9aa6c 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -56,6 +56,7 @@ #include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx> #include <comphelper/processfactory.hxx> #include <rtl/ustring.hxx> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/CharacterIteratorMode.hpp> #include <com/sun/star/i18n/WordType.hpp> #include <drawinglayer/primitive2d/controlprimitive2d.hxx> @@ -1097,46 +1098,43 @@ namespace drawinglayer // support for TEXT_ MetaFile actions only for decorated texts if(!mxBreakIterator.is()) { - uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF(::comphelper::getProcessServiceFactory()); - mxBreakIterator.set(xMSF->createInstance("com.sun.star.i18n.BreakIterator"), uno::UNO_QUERY); + uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + mxBreakIterator = i18n::BreakIterator::create(xContext); } - if(mxBreakIterator.is()) - { - const rtl::OUString& rTxt = rTextCandidate.getText(); - const sal_Int32 nTextLength(rTextCandidate.getTextLength()); // rTxt.getLength()); + const rtl::OUString& rTxt = rTextCandidate.getText(); + const sal_Int32 nTextLength(rTextCandidate.getTextLength()); // rTxt.getLength()); - if(nTextLength) + if(nTextLength) + { + const ::com::sun::star::lang::Locale& rLocale = rTextCandidate.getLocale(); + const sal_Int32 nTextPosition(rTextCandidate.getTextPosition()); + + sal_Int32 nDone; + sal_Int32 nNextCellBreak(mxBreakIterator->nextCharacters(rTxt, nTextPosition, rLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 0, nDone)); + ::com::sun::star::i18n::Boundary nNextWordBoundary(mxBreakIterator->getWordBoundary(rTxt, nTextPosition, rLocale, ::com::sun::star::i18n::WordType::ANY_WORD, sal_True)); + sal_Int32 nNextSentenceBreak(mxBreakIterator->endOfSentence(rTxt, nTextPosition, rLocale)); + const rtl::OString aCommentStringA(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOC")); + const rtl::OString aCommentStringB(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOW")); + const rtl::OString aCommentStringC(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOS")); + + for(sal_Int32 i(nTextPosition); i < nTextPosition + nTextLength; i++) { - const ::com::sun::star::lang::Locale& rLocale = rTextCandidate.getLocale(); - const sal_Int32 nTextPosition(rTextCandidate.getTextPosition()); - - sal_Int32 nDone; - sal_Int32 nNextCellBreak(mxBreakIterator->nextCharacters(rTxt, nTextPosition, rLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 0, nDone)); - ::com::sun::star::i18n::Boundary nNextWordBoundary(mxBreakIterator->getWordBoundary(rTxt, nTextPosition, rLocale, ::com::sun::star::i18n::WordType::ANY_WORD, sal_True)); - sal_Int32 nNextSentenceBreak(mxBreakIterator->endOfSentence(rTxt, nTextPosition, rLocale)); - const rtl::OString aCommentStringA(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOC")); - const rtl::OString aCommentStringB(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOW")); - const rtl::OString aCommentStringC(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOS")); - - for(sal_Int32 i(nTextPosition); i < nTextPosition + nTextLength; i++) + // create the entries for the respective break positions + if(i == nNextCellBreak) + { + mpMetaFile->AddAction(new MetaCommentAction(aCommentStringA, i - nTextPosition)); + nNextCellBreak = mxBreakIterator->nextCharacters(rTxt, i, rLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); + } + if(i == nNextWordBoundary.endPos) + { + mpMetaFile->AddAction(new MetaCommentAction(aCommentStringB, i - nTextPosition)); + nNextWordBoundary = mxBreakIterator->getWordBoundary(rTxt, i + 1, rLocale, ::com::sun::star::i18n::WordType::ANY_WORD, sal_True); + } + if(i == nNextSentenceBreak) { - // create the entries for the respective break positions - if(i == nNextCellBreak) - { - mpMetaFile->AddAction(new MetaCommentAction(aCommentStringA, i - nTextPosition)); - nNextCellBreak = mxBreakIterator->nextCharacters(rTxt, i, rLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); - } - if(i == nNextWordBoundary.endPos) - { - mpMetaFile->AddAction(new MetaCommentAction(aCommentStringB, i - nTextPosition)); - nNextWordBoundary = mxBreakIterator->getWordBoundary(rTxt, i + 1, rLocale, ::com::sun::star::i18n::WordType::ANY_WORD, sal_True); - } - if(i == nNextSentenceBreak) - { - mpMetaFile->AddAction(new MetaCommentAction(aCommentStringC, i - nTextPosition)); - nNextSentenceBreak = mxBreakIterator->endOfSentence(rTxt, i + 1, rLocale); - } + mpMetaFile->AddAction(new MetaCommentAction(aCommentStringC, i - nTextPosition)); + nNextSentenceBreak = mxBreakIterator->endOfSentence(rTxt, i + 1, rLocale); } } } 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& ) diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx index 1352508f5835..c7e86955a9a2 100644 --- a/filter/source/flash/swfwriter1.cxx +++ b/filter/source/flash/swfwriter1.cxx @@ -27,6 +27,7 @@ ************************************************************************/ +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <comphelper/processfactory.hxx> @@ -2065,8 +2066,8 @@ Reference < XBreakIterator > Writer::Impl_GetBreakIterator() { if ( !mxBreakIterator.is() ) { - Reference< XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); - mxBreakIterator.set( xMSF->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.BreakIterator" )) ), UNO_QUERY ); + Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + mxBreakIterator = BreakIterator::create(xContext); } return mxBreakIterator; } diff --git a/i18npool/Library_i18nsearch.mk b/i18npool/Library_i18nsearch.mk index d4499c8cade1..b587e13f52c2 100644 --- a/i18npool/Library_i18nsearch.mk +++ b/i18npool/Library_i18nsearch.mk @@ -39,6 +39,7 @@ $(eval $(call gb_Library_set_include,i18nsearch,\ $(eval $(call gb_Library_use_sdk_api,i18nsearch)) $(eval $(call gb_Library_use_libraries,i18nsearch,\ + comphelper \ cppu \ cppuhelper \ i18nregexp \ diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx index 8c2d554884ec..115e481959e6 100644 --- a/i18npool/source/search/textsearch.cxx +++ b/i18npool/source/search/textsearch.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <comphelper/processfactory.hxx> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/UnicodeType.hpp> #include <com/sun/star/util/SearchFlags.hpp> #include <com/sun/star/i18n/WordType.hpp> @@ -150,12 +151,7 @@ void TextSearch::setOptions( const SearchOptions& rOptions ) throw( RuntimeExcep if ( !xBreak.is() ) { - Reference < XInterface > xI = xMSF->createInstance( - OUString("com.sun.star.i18n.BreakIterator")); - if( xI.is() ) - xI->queryInterface( ::getCppuType( - (const Reference< XBreakIterator >*)0)) - >>= xBreak; + xBreak = BreakIterator::create(comphelper::getComponentContext(xMSF)); } sSrchStr = aSrchPara.searchString; diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 79f0f39e32fa..f324e514e0fa 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -23,7 +23,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -749,13 +749,13 @@ sal_Int32 GrammarCheckingIterator::GetSuggestedEndOfSentence( { // internal method; will always be called with locked mutex + // FIXME! this is a bug, the xBreakIterator var is hiding an issue! + // But if I fix it, the sw/complex tests start failing. uno::Reference< i18n::XBreakIterator > xBreakIterator; if (!m_xBreakIterator.is()) { - uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - if ( xMSF.is() ) - xBreakIterator = uno::Reference < i18n::XBreakIterator >( xMSF->createInstance( - "com.sun.star.i18n.BreakIterator" ), uno::UNO_QUERY ); + uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + xBreakIterator = i18n::BreakIterator::create(xContext); } sal_Int32 nTextLen = rText.getLength(); sal_Int32 nEndPosition = nTextLen; diff --git a/sc/source/core/data/documen6.cxx b/sc/source/core/data/documen6.cxx index 544950fd7181..4b14697a8c33 100644 --- a/sc/source/core/data/documen6.cxx +++ b/sc/source/core/data/documen6.cxx @@ -29,9 +29,10 @@ #include "scitems.hxx" #include <editeng/scripttypeitem.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/lang/XMultiServiceFactory.hpp> +#include <comphelper/processfactory.hxx> #include "document.hxx" #include "cell.hxx" @@ -43,8 +44,6 @@ using namespace com::sun::star; -#define SC_BREAKITER_SERVICE "com.sun.star.i18n.BreakIterator" - // // this file is compiled with exceptions enabled // put functions here that need exceptions! @@ -58,10 +57,7 @@ const uno::Reference< i18n::XBreakIterator >& ScDocument::GetBreakIterator() pScriptTypeData = new ScScriptTypeData; if ( !pScriptTypeData->xBreakIter.is() ) { - uno::Reference< uno::XInterface > xInterface = xServiceManager->createInstance( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_BREAKITER_SERVICE )) ); - pScriptTypeData->xBreakIter = uno::Reference< i18n::XBreakIterator >( xInterface, uno::UNO_QUERY ); - OSL_ENSURE( pScriptTypeData->xBreakIter.is(), "can't get BreakIterator" ); + pScriptTypeData->xBreakIter = i18n::BreakIterator::create( comphelper::getComponentContext(xServiceManager) ); } return pScriptTypeData->xBreakIter; } diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx index 65fbb4ad17f3..78fe9adb607b 100644 --- a/sd/source/core/CustomAnimationEffect.cxx +++ b/sd/source/core/CustomAnimationEffect.cxx @@ -54,7 +54,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> #include <com/sun/star/lang/Locale.hpp> -#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/CharacterIteratorMode.hpp> #include <com/sun/star/i18n/WordType.hpp> #include <com/sun/star/presentation/TextAnimationType.hpp> @@ -317,65 +317,61 @@ sal_Int32 CustomAnimationEffect::getNumberOfSubitems( const Any& aTarget, sal_In if( xShape.is() ) { // TODO/LATER: Optimize this, don't create a break iterator each time - Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); - Reference < i18n::XBreakIterator > xBI( xMSF->createInstance( "com.sun.star.i18n.BreakIterator" ), UNO_QUERY ); - DBG_ASSERT( xBI.is(), "sd::CustomAnimationEffect::getNumberOfSubitems(), could not create a 'com.sun.star.i18n.BreakIterator'!" ); + Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + Reference < i18n::XBreakIterator > xBI = i18n::BreakIterator::create(xContext); - if( xBI.is() ) + Reference< XEnumerationAccess > xEA( xShape, UNO_QUERY_THROW ); + Reference< XEnumeration > xEnumeration( xEA->createEnumeration(), UNO_QUERY_THROW ); + Locale aLocale; + const OUString aStrLocaleName( "CharLocale" ); + Reference< XTextRange > xParagraph; + + sal_Int32 nPara = 0; + while( xEnumeration->hasMoreElements() ) { - Reference< XEnumerationAccess > xEA( xShape, UNO_QUERY_THROW ); - Reference< XEnumeration > xEnumeration( xEA->createEnumeration(), UNO_QUERY_THROW ); - Locale aLocale; - const OUString aStrLocaleName( "CharLocale" ); - Reference< XTextRange > xParagraph; + xEnumeration->nextElement() >>= xParagraph; - sal_Int32 nPara = 0; - while( xEnumeration->hasMoreElements() ) + // skip this if its not the only paragraph we want to count + if( (nOnlyPara != -1) && (nOnlyPara != nPara ) ) + continue; + + if( nIterateType == TextAnimationType::BY_PARAGRAPH ) { - xEnumeration->nextElement() >>= xParagraph; + nSubItems++; + } + else + { + const OUString aText( xParagraph->getString() ); + Reference< XPropertySet > xSet( xParagraph, UNO_QUERY_THROW ); + xSet->getPropertyValue( aStrLocaleName ) >>= aLocale; - // skip this if its not the only paragraph we want to count - if( (nOnlyPara != -1) && (nOnlyPara != nPara ) ) - continue; + sal_Int32 nPos; + const sal_Int32 nEndPos = aText.getLength(); - if( nIterateType == TextAnimationType::BY_PARAGRAPH ) + if( nIterateType == TextAnimationType::BY_WORD ) { - nSubItems++; + for( nPos = 0; nPos < nEndPos; nPos++ ) + { + nPos = xBI->getWordBoundary(aText, nPos, aLocale, i18n::WordType::ANY_WORD, sal_True).endPos; + nSubItems++; + } + break; } else { - const OUString aText( xParagraph->getString() ); - Reference< XPropertySet > xSet( xParagraph, UNO_QUERY_THROW ); - xSet->getPropertyValue( aStrLocaleName ) >>= aLocale; - - sal_Int32 nPos; - const sal_Int32 nEndPos = aText.getLength(); - - if( nIterateType == TextAnimationType::BY_WORD ) + sal_Int32 nDone; + for( nPos = 0; nPos < nEndPos; nPos++ ) { - for( nPos = 0; nPos < nEndPos; nPos++ ) - { - nPos = xBI->getWordBoundary(aText, nPos, aLocale, i18n::WordType::ANY_WORD, sal_True).endPos; - nSubItems++; - } - break; - } - else - { - sal_Int32 nDone; - for( nPos = 0; nPos < nEndPos; nPos++ ) - { - nPos = xBI->nextCharacters(aText, nPos, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 0, nDone); - nSubItems++; - } + nPos = xBI->nextCharacters(aText, nPos, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 0, nDone); + nSubItems++; } } + } - if( nPara == nOnlyPara ) - break; + if( nPara == nOnlyPara ) + break; - nPara++; - } + nPara++; } } } diff --git a/sd/source/filter/eppt/pptx-text.cxx b/sd/source/filter/eppt/pptx-text.cxx index f1bc0dd32e1f..bd8d8d4812c9 100644 --- a/sd/source/filter/eppt/pptx-text.cxx +++ b/sd/source/filter/eppt/pptx-text.cxx @@ -34,7 +34,7 @@ #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XIndexReplace.hpp> -#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/ScriptDirection.hpp> #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/text/FontRelief.hpp> @@ -1298,13 +1298,9 @@ FontCollection::~FontCollection() FontCollection::FontCollection() : pVDev ( NULL ) { - com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > - xMSF = ::comphelper::getProcessServiceFactory(); - com::sun::star::uno::Reference< com::sun::star::uno::XInterface > - xInterface = xMSF->createInstance( "com.sun.star.i18n.BreakIterator" ); - if ( xInterface.is() ) - xPPTBreakIter = com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > - ( xInterface, com::sun::star::uno::UNO_QUERY ); + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + xContext = ::comphelper::getProcessComponentContext(); + xPPTBreakIter = com::sun::star::i18n::BreakIterator::create( xContext ); } short FontCollection::GetScriptDirection( const rtl::OUString& rString ) const diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index 33d8db9d2a23..4333dabab350 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -29,7 +29,7 @@ #include "basegfx/polygon/b2dpolypolygontools.hxx" #include "basegfx/range/b2drange.hxx" -#include "com/sun/star/i18n/XBreakIterator.hpp" +#include "com/sun/star/i18n/BreakIterator.hpp" #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "comphelper/processfactory.hxx" #include "com/sun/star/i18n/ScriptType.hpp" @@ -46,15 +46,12 @@ using namespace ::com::sun::star::uno; namespace pdfi { -const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& DrawXmlOptimizer::GetBreakIterator() +const Reference< XBreakIterator >& DrawXmlOptimizer::GetBreakIterator() { if ( !mxBreakIter.is() ) { Reference< XComponentContext > xContext( this->m_rProcessor.m_xContext, uno::UNO_SET_THROW ); - Reference< XMultiComponentFactory > xMSF( xContext->getServiceManager(), uno::UNO_SET_THROW ); - Reference < XInterface > xInterface = xMSF->createInstanceWithContext(::rtl::OUString("com.sun.star.i18n.BreakIterator"), xContext); - - mxBreakIter = uno::Reference< i18n::XBreakIterator >( xInterface, uno::UNO_QUERY ); + mxBreakIter = BreakIterator::create(xContext); } return mxBreakIter; } diff --git a/sdext/source/presenter/PresenterTextView.cxx b/sdext/source/presenter/PresenterTextView.cxx index 4277b554b301..6599f4fbfa81 100644 --- a/sdext/source/presenter/PresenterTextView.cxx +++ b/sdext/source/presenter/PresenterTextView.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/accessibility/AccessibleTextType.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/CharType.hpp> #include <com/sun/star/i18n/CharacterIteratorMode.hpp> #include <com/sun/star/i18n/CTLScriptType.hpp> @@ -90,11 +91,7 @@ PresenterTextView::PresenterTextView ( return; // Create the break iterator that we use to break text into lines. - mxBreakIterator = Reference<i18n::XBreakIterator>( - xFactory->createInstanceWithContext( - A2S("com.sun.star.i18n.BreakIterator"), - rxContext), - UNO_QUERY_THROW); + mxBreakIterator = i18n::BreakIterator::create(rxContext); // Create the script type detector that is used to split paragraphs into // portions of the same text direction. diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx index da4394481002..f46c72e9e67c 100644 --- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx @@ -56,6 +56,7 @@ #include <numeric> #include <algorithm> #include <comphelper/processfactory.hxx> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/ScriptType.hpp> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -833,19 +834,14 @@ SdrObject* CreateSdrObjectFromParagraphOutlines( const FWData& rFWData, const Sd return pRet; } -::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > EnhancedCustomShapeFontWork::mxBreakIterator = 0; +Reference < i18n::XBreakIterator > EnhancedCustomShapeFontWork::mxBreakIterator = 0; Reference < i18n::XBreakIterator > EnhancedCustomShapeFontWork::GetBreakIterator() { if ( !mxBreakIterator.is() ) { - Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - Reference < XInterface > xI = xMSF->createInstance( rtl::OUString("com.sun.star.i18n.BreakIterator") ); - if ( xI.is() ) - { - Any x = xI->queryInterface( ::getCppuType((const Reference< i18n::XBreakIterator >*)0) ); - x >>= mxBreakIterator; - } + Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + mxBreakIterator = i18n::BreakIterator::create(xContext); } return mxBreakIterator; } diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx index cc775a58e55d..2c37904575ea 100644 --- a/svx/source/dialog/fntctrl.cxx +++ b/svx/source/dialog/fntctrl.cxx @@ -33,7 +33,7 @@ #include <vcl/svapp.hxx> #include <unicode/uchar.h> #include <com/sun/star/uno/Reference.h> -#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <comphelper/processfactory.hxx> @@ -87,6 +87,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using ::com::sun::star::i18n::XBreakIterator; +using ::com::sun::star::i18n::BreakIterator; // ----------------------------------------------------------------------- // small helper functions to set fonts @@ -251,55 +252,50 @@ void FontPrevWin_Impl::CheckScript() if( !xBreak.is() ) { - Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - xBreak = Reference< XBreakIterator >(xMSF->createInstance( - ::rtl::OUString("com.sun.star.i18n.BreakIterator") ),UNO_QUERY); + Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + xBreak = BreakIterator::create(xContext); } - assert(xBreak.is()); // no can do without breakiter - if( xBreak.is() ) + sal_uInt16 nScript = xBreak->getScriptType( aText, 0 ); + sal_uInt16 nChg = 0; + if( com::sun::star::i18n::ScriptType::WEAK == nScript ) { - sal_uInt16 nScript = xBreak->getScriptType( aText, 0 ); - sal_uInt16 nChg = 0; - if( com::sun::star::i18n::ScriptType::WEAK == nScript ) - { - nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript ); - if( nChg < aText.Len() ) - nScript = xBreak->getScriptType( aText, nChg ); - else - nScript = com::sun::star::i18n::ScriptType::LATIN; - } + nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript ); + if( nChg < aText.Len() ) + nScript = xBreak->getScriptType( aText, nChg ); + else + nScript = com::sun::star::i18n::ScriptType::LATIN; + } - do + do + { + nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript ); + if (nChg < aText.Len() && nChg > 0 && + (com::sun::star::i18n::ScriptType::WEAK == + xBreak->getScriptType(aText, nChg - 1))) { - nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript ); - if (nChg < aText.Len() && nChg > 0 && - (com::sun::star::i18n::ScriptType::WEAK == - xBreak->getScriptType(aText, nChg - 1))) + int8_t nType = u_charType(aText.GetChar(nChg) ); + if (nType == U_NON_SPACING_MARK || nType == U_ENCLOSING_MARK || + nType == U_COMBINING_SPACING_MARK ) { - int8_t nType = u_charType(aText.GetChar(nChg) ); - if (nType == U_NON_SPACING_MARK || nType == U_ENCLOSING_MARK || - nType == U_COMBINING_SPACING_MARK ) - { - aScriptChg.push_back( nChg - 1 ); - } - else - { - aScriptChg.push_back( nChg ); - } + aScriptChg.push_back( nChg - 1 ); } else { aScriptChg.push_back( nChg ); } - aScriptType.push_back( nScript ); - aTextWidth.push_back( 0 ); + } + else + { + aScriptChg.push_back( nChg ); + } + aScriptType.push_back( nScript ); + aTextWidth.push_back( 0 ); - if( nChg < aText.Len() ) - nScript = xBreak->getScriptType( aText, nChg ); - else - break; - } while( sal_True ); - } + if( nChg < aText.Len() ) + nScript = xBreak->getScriptType( aText, nChg ); + else + break; + } while( sal_True ); } /* diff --git a/svx/source/svdraw/svdotextpathdecomposition.cxx b/svx/source/svdraw/svdotextpathdecomposition.cxx index f0935bb0ae0c..889052801ae0 100644 --- a/svx/source/svdraw/svdotextpathdecomposition.cxx +++ b/svx/source/svdraw/svdotextpathdecomposition.cxx @@ -41,7 +41,7 @@ #include <vcl/virdev.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/i18n/ScriptType.hpp> -#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <comphelper/processfactory.hxx> #include <com/sun/star/i18n/CharacterIteratorMode.hpp> #include <editeng/unolingu.hxx> @@ -270,14 +270,8 @@ namespace mrShadowDecomposition(rShadowDecomposition) { // prepare BreakIterator - Reference < XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - Reference < XInterface > xInterface = xMSF->createInstance(::rtl::OUString("com.sun.star.i18n.BreakIterator")); - - if(xInterface.is()) - { - Any x = xInterface->queryInterface(::getCppuType((const Reference< XBreakIterator >*)0)); - x >>= mxBreak; - } + Reference < XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + mxBreak = com::sun::star::i18n::BreakIterator::create(xContext); } void HandlePair(const basegfx::B2DPolygon rPolygonCandidate, const ::std::vector< const impPathTextPortion* >& rTextPortions) diff --git a/sw/source/core/bastyp/breakit.cxx b/sw/source/core/bastyp/breakit.cxx index 805b34210ecb..7ed2c5749ba6 100644 --- a/sw/source/core/bastyp/breakit.cxx +++ b/sw/source/core/bastyp/breakit.cxx @@ -31,11 +31,13 @@ #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/i18n/CharacterIteratorMode.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <editeng/unolingu.hxx> #include <editeng/scripttypeitem.hxx> #include <unicode/uchar.h> #include <unotools/localedatawrapper.hxx> +#include <comphelper/processfactory.hxx> using namespace com::sun::star; @@ -75,9 +77,7 @@ SwBreakIt::~SwBreakIt() void SwBreakIt::createBreakIterator() const { if ( m_xMSF.is() && !xBreak.is() ) - xBreak.set(m_xMSF->createInstance(::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.BreakIterator"))), - uno::UNO_QUERY); + xBreak.set( i18n::BreakIterator::create(comphelper::getComponentContext(m_xMSF)) ); } void SwBreakIt::_GetLocale( const LanguageType aLang ) diff --git a/sw/source/ui/chrdlg/drpcps.cxx b/sw/source/ui/chrdlg/drpcps.cxx index f96a2e7cd6fc..cd44c3c258f8 100644 --- a/sw/source/ui/chrdlg/drpcps.cxx +++ b/sw/source/ui/chrdlg/drpcps.cxx @@ -44,7 +44,7 @@ #include <sfx2/printer.hxx> #include <com/sun/star/i18n/ScriptType.hpp> #include <editeng/scripttypeitem.hxx> -#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <comphelper/processfactory.hxx> #include "charatr.hxx" @@ -411,34 +411,30 @@ void SwDropCapsPict::CheckScript( void ) maScriptChanges.clear(); if( !xBreak.is() ) { - Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - xBreak = Reference< I18N::XBreakIterator >(xMSF->createInstance( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.BreakIterator")) ),UNO_QUERY); + Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + xBreak = I18N::BreakIterator::create(xContext); } - if( xBreak.is() ) + sal_uInt16 nScript = xBreak->getScriptType( maText, 0 ); + sal_uInt16 nChg = 0; + if( I18N_SCRIPTTYPE::WEAK == nScript ) { - sal_uInt16 nScript = xBreak->getScriptType( maText, 0 ); - sal_uInt16 nChg = 0; - if( I18N_SCRIPTTYPE::WEAK == nScript ) - { - nChg = (xub_StrLen)xBreak->endOfScript( maText, nChg, nScript ); - if( nChg < maText.Len() ) - nScript = xBreak->getScriptType( maText, nChg ); - else - nScript = I18N_SCRIPTTYPE::LATIN; - } + nChg = (xub_StrLen)xBreak->endOfScript( maText, nChg, nScript ); + if( nChg < maText.Len() ) + nScript = xBreak->getScriptType( maText, nChg ); + else + nScript = I18N_SCRIPTTYPE::LATIN; + } - do - { - nChg = (xub_StrLen)xBreak->endOfScript( maText, nChg, nScript ); - maScriptChanges.push_back( _ScriptInfo(0, nScript, nChg) ); + do + { + nChg = (xub_StrLen)xBreak->endOfScript( maText, nChg, nScript ); + maScriptChanges.push_back( _ScriptInfo(0, nScript, nChg) ); - if( nChg < maText.Len() ) - nScript = xBreak->getScriptType( maText, nChg ); - else - break; - } while( sal_True ); - } + if( nChg < maText.Len() ) + nScript = xBreak->getScriptType( maText, nChg ); + else + break; + } while( sal_True ); } Size SwDropCapsPict::CalcTextSize( void ) diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx index 91df248269ce..cfcde7ec58bb 100644 --- a/sw/source/ui/table/tautofmt.cxx +++ b/sw/source/ui/table/tautofmt.cxx @@ -32,7 +32,7 @@ #include <vcl/svapp.hxx> #include <svl/zforlist.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <comphelper/processfactory.hxx> #include <svtools/scriptedtext.hxx> #include <svtools/accessibilityoptions.hxx> @@ -559,10 +559,7 @@ AutoFmtPreview::AutoFmtPreview(Window* pParent) : OSL_ENSURE( m_xMSF.is(), "AutoFmtPreview: no MultiServiceFactory"); if ( m_xMSF.is() ) { - m_xBreak = uno::Reference< i18n::XBreakIterator >( - m_xMSF->createInstance ( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.BreakIterator")) ), - uno::UNO_QUERY); + m_xBreak = i18n::BreakIterator::create(comphelper::getComponentContext(m_xMSF)); } pNumFmt = new SvNumberFormatter( m_xMSF, LANGUAGE_SYSTEM ); diff --git a/vcl/source/app/unohelp.cxx b/vcl/source/app/unohelp.cxx index 329159250b95..a7ba55577b07 100644 --- a/vcl/source/app/unohelp.cxx +++ b/vcl/source/app/unohelp.cxx @@ -42,7 +42,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <comphelper/processfactory.hxx> -#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/XCharacterClassification.hpp> #include <com/sun/star/awt/XExtendedToolkit.hpp> #include <com/sun/star/accessibility/AccessibleEventObject.hpp> @@ -136,18 +136,8 @@ uno::Reference< lang::XMultiServiceFactory > vcl::unohelper::GetMultiServiceFact uno::Reference < i18n::XBreakIterator > vcl::unohelper::CreateBreakIterator() { - uno::Reference < i18n::XBreakIterator > xB; - uno::Reference< lang::XMultiServiceFactory > xMSF = GetMultiServiceFactory(); - if ( xMSF.is() ) - { - uno::Reference < uno::XInterface > xI = xMSF->createInstance( ::rtl::OUString("com.sun.star.i18n.BreakIterator") ); - if ( xI.is() ) - { - uno::Any x = xI->queryInterface( ::getCppuType((const uno::Reference< i18n::XBreakIterator >*)0) ); - x >>= xB; - } - } - return xB; + uno::Reference< uno::XComponentContext > xContext = comphelper::getComponentContext(GetMultiServiceFactory()); + return i18n::BreakIterator::create(xContext); } uno::Reference < i18n::XCharacterClassification > vcl::unohelper::CreateCharacterClassification() diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index a8d018e8a7be..40d75bf7b43f 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -46,7 +46,7 @@ #include <osl/mutex.hxx> -#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/BreakIterator.hpp> #include <com/sun/star/i18n/CharacterIteratorMode.hpp> #include <com/sun/star/i18n/WordType.hpp> #include <cppuhelper/weak.hxx> @@ -857,18 +857,8 @@ uno::Reference < i18n::XBreakIterator > Edit::ImplGetBreakIterator() const //!! since we don't want to become incompatible in the next minor update //!! where this code will get integrated into, xISC will be a local //!! variable instead of a class member! - uno::Reference < i18n::XBreakIterator > xBI; -// if ( !xBI.is() ) - { - uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - uno::Reference < XInterface > xI = xMSF->createInstance( OUString("com.sun.star.i18n.BreakIterator") ); - if ( xI.is() ) - { - Any x = xI->queryInterface( ::getCppuType((const uno::Reference< i18n::XBreakIterator >*)0) ); - x >>= xBI; - } - } - return xBI; + uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + return i18n::BreakIterator::create(xContext); } // ----------------------------------------------------------------------- |