From c0f865c9b5a34b272c9e0b22d18969554265914a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 15 Oct 2012 15:20:48 +0200 Subject: 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 --- sd/source/core/CustomAnimationEffect.cxx | 86 +++++++++++++++----------------- sd/source/filter/eppt/pptx-text.cxx | 12 ++--- 2 files changed, 45 insertions(+), 53 deletions(-) (limited to 'sd') 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 #include #include -#include +#include #include #include #include @@ -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 #include #include -#include +#include #include #include #include @@ -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 -- cgit