fd0#46808, convert some getProcessServiceFactory

... to getProcessComponentContext

Change-Id: I8d5c2be0186db963ba8aac31e1b527145b8bca2b
This commit is contained in:
Noel Grandin
2013-01-09 15:50:03 +02:00
parent 49cf14a3ca
commit 09cf6fe83a
3 changed files with 98 additions and 110 deletions

View File

@@ -46,7 +46,6 @@ MediaWindowBaseImpl::MediaWindowBaseImpl( MediaWindow* pMediaWindow )
MediaWindowBaseImpl::~MediaWindowBaseImpl()
{
uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
}
// -------------------------------------------------------------------------
@@ -54,42 +53,37 @@ MediaWindowBaseImpl::~MediaWindowBaseImpl()
uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const ::rtl::OUString& rURL )
{
uno::Reference< media::XPlayer > xPlayer;
uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
if( xFactory.is() )
{
static const char * aServiceManagers[] = {
AVMEDIA_MANAGER_SERVICE_NAME,
static const char * aServiceManagers[] = {
AVMEDIA_MANAGER_SERVICE_NAME,
// a fallback path just for gstreamer which has
// two significant versions deployed at once ...
#ifdef AVMEDIA_MANAGER_SERVICE_NAME_OLD
AVMEDIA_MANAGER_SERVICE_NAME_OLD
AVMEDIA_MANAGER_SERVICE_NAME_OLD
#endif
};
};
for( sal_uInt32 i = 0; !xPlayer.is() && i < SAL_N_ELEMENTS( aServiceManagers ); ++i )
{
const rtl::OUString aServiceName( aServiceManagers[ i ],
strlen( aServiceManagers[ i ] ),
RTL_TEXTENCODING_ASCII_US );
for( sal_uInt32 i = 0; !xPlayer.is() && i < SAL_N_ELEMENTS( aServiceManagers ); ++i )
{
const rtl::OUString aServiceName( aServiceManagers[ i ],
strlen( aServiceManagers[ i ] ),
RTL_TEXTENCODING_ASCII_US );
uno::Reference< ::com::sun::star::media::XManager > xManager;
try {
xManager = uno::Reference< ::com::sun::star::media::XManager >(
xFactory->createInstance( aServiceName ), uno::UNO_QUERY );
if( xManager.is() )
xPlayer = uno::Reference< media::XPlayer >( xManager->createPlayer( rURL ),
uno::UNO_QUERY );
else
SAL_WARN( "avmedia",
"failed to create media player service " << aServiceName );
} catch ( const uno::Exception &e ) {
SAL_WARN(
"avmedia",
"couldn't create media player " AVMEDIA_MANAGER_SERVICE_NAME
", exception '" << e.Message << '\'');
}
try {
uno::Reference< media::XManager > xManager (
xContext->getServiceManager()->createInstanceWithContext(aServiceName, xContext),
uno::UNO_QUERY );
if( xManager.is() )
xPlayer = uno::Reference< media::XPlayer >( xManager->createPlayer( rURL ),
uno::UNO_QUERY );
else
SAL_WARN( "avmedia",
"failed to create media player service " << aServiceName );
} catch ( const uno::Exception &e ) {
SAL_WARN( "avmedia",
"couldn't create media player " AVMEDIA_MANAGER_SERVICE_NAME
", exception '" << e.Message << '\'');
}
}
@@ -233,7 +227,7 @@ bool MediaWindowBaseImpl::setZoom( ::com::sun::star::media::ZoomLevel eLevel )
::com::sun::star::media::ZoomLevel MediaWindowBaseImpl::getZoom() const
{
return( mxPlayerWindow.is() ? mxPlayerWindow->getZoomLevel() : ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE );
return( mxPlayerWindow.is() ? mxPlayerWindow->getZoomLevel() : media::ZoomLevel_NOT_AVAILABLE );
}
// ---------------------------------------------------------------------

View File

@@ -62,19 +62,16 @@ namespace drawinglayer
{
if(!aUnoControlTypeName.isEmpty())
{
uno::Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
uno::Reference< awt::XControl > xXControl(
xContext->getServiceManager()->createInstanceWithContext(aUnoControlTypeName, xContext), uno::UNO_QUERY);
if(xFactory.is())
if(xXControl.is())
{
uno::Reference< awt::XControl > xXControl(xFactory->createInstance(aUnoControlTypeName), uno::UNO_QUERY);
xXControl->setModel(getControlModel());
if(xXControl.is())
{
xXControl->setModel(getControlModel());
// remember XControl
mxXControl = xXControl;
}
// remember XControl
mxXControl = xXControl;
}
}
}

View File

@@ -19,7 +19,7 @@
#include <drawinglayer/primitive2d/textbreakuphelper.hxx>
#include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
#include <com/sun/star/i18n/XBreakIterator.hpp>
#include <com/sun/star/i18n/BreakIterator.hpp>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/i18n/CharacterIteratorMode.hdl>
#include <com/sun/star/i18n/WordType.hpp>
@@ -193,93 +193,90 @@ namespace drawinglayer
if(!xBreakIterator.is())
{
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF(::comphelper::getProcessServiceFactory());
xBreakIterator.set(xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.i18n.BreakIterator")), ::com::sun::star::uno::UNO_QUERY);
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
xBreakIterator = ::com::sun::star::i18n::BreakIterator::create(xContext);
}
if(xBreakIterator.is())
const rtl::OUString& rTxt = mrSource.getText();
const sal_Int32 nTextLength(mrSource.getTextLength());
const ::com::sun::star::lang::Locale& rLocale = mrSource.getLocale();
const sal_Int32 nTextPosition(mrSource.getTextPosition());
sal_Int32 nCurrent(nTextPosition);
switch(aBreakupUnit)
{
const rtl::OUString& rTxt = mrSource.getText();
const sal_Int32 nTextLength(mrSource.getTextLength());
const ::com::sun::star::lang::Locale& rLocale = mrSource.getLocale();
const sal_Int32 nTextPosition(mrSource.getTextPosition());
sal_Int32 nCurrent(nTextPosition);
switch(aBreakupUnit)
case BreakupUnit_character:
{
case BreakupUnit_character:
{
sal_Int32 nDone;
sal_Int32 nNextCellBreak(xBreakIterator->nextCharacters(rTxt, nTextPosition, rLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 0, nDone));
sal_Int32 a(nTextPosition);
sal_Int32 nDone;
sal_Int32 nNextCellBreak(xBreakIterator->nextCharacters(rTxt, nTextPosition, rLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 0, nDone));
sal_Int32 a(nTextPosition);
for(; a < nTextPosition + nTextLength; a++)
for(; a < nTextPosition + nTextLength; a++)
{
if(a == nNextCellBreak)
{
if(a == nNextCellBreak)
{
breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
nCurrent = a;
nNextCellBreak = xBreakIterator->nextCharacters(rTxt, a, rLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
}
breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
nCurrent = a;
nNextCellBreak = xBreakIterator->nextCharacters(rTxt, a, rLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
}
breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
break;
}
case BreakupUnit_word:
{
::com::sun::star::i18n::Boundary nNextWordBoundary(xBreakIterator->getWordBoundary(rTxt, nTextPosition, rLocale, ::com::sun::star::i18n::WordType::ANY_WORD, sal_True));
sal_Int32 a(nTextPosition);
for(; a < nTextPosition + nTextLength; a++)
breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
break;
}
case BreakupUnit_word:
{
::com::sun::star::i18n::Boundary nNextWordBoundary(xBreakIterator->getWordBoundary(rTxt, nTextPosition, rLocale, ::com::sun::star::i18n::WordType::ANY_WORD, sal_True));
sal_Int32 a(nTextPosition);
for(; a < nTextPosition + nTextLength; a++)
{
if(a == nNextWordBoundary.endPos)
{
if(a == nNextWordBoundary.endPos)
if(a > nCurrent)
{
if(a > nCurrent)
breakupPortion(aTempResult, nCurrent, a - nCurrent, true);
}
nCurrent = a;
// skip spaces (maybe enhanced with a bool later if needed)
{
const sal_Int32 nEndOfSpaces(xBreakIterator->endOfCharBlock(rTxt, a, rLocale, ::com::sun::star::i18n::CharType::SPACE_SEPARATOR));
if(nEndOfSpaces > a)
{
breakupPortion(aTempResult, nCurrent, a - nCurrent, true);
nCurrent = nEndOfSpaces;
}
nCurrent = a;
// skip spaces (maybe enhanced with a bool later if needed)
{
const sal_Int32 nEndOfSpaces(xBreakIterator->endOfCharBlock(rTxt, a, rLocale, ::com::sun::star::i18n::CharType::SPACE_SEPARATOR));
if(nEndOfSpaces > a)
{
nCurrent = nEndOfSpaces;
}
}
nNextWordBoundary = xBreakIterator->getWordBoundary(rTxt, a + 1, rLocale, ::com::sun::star::i18n::WordType::ANY_WORD, sal_True);
}
}
if(a > nCurrent)
{
breakupPortion(aTempResult, nCurrent, a - nCurrent, true);
nNextWordBoundary = xBreakIterator->getWordBoundary(rTxt, a + 1, rLocale, ::com::sun::star::i18n::WordType::ANY_WORD, sal_True);
}
break;
}
case BreakupUnit_sentence:
if(a > nCurrent)
{
sal_Int32 nNextSentenceBreak(xBreakIterator->endOfSentence(rTxt, nTextPosition, rLocale));
sal_Int32 a(nTextPosition);
for(; a < nTextPosition + nTextLength; a++)
{
if(a == nNextSentenceBreak)
{
breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
nCurrent = a;
nNextSentenceBreak = xBreakIterator->endOfSentence(rTxt, a + 1, rLocale);
}
}
breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
break;
breakupPortion(aTempResult, nCurrent, a - nCurrent, true);
}
break;
}
case BreakupUnit_sentence:
{
sal_Int32 nNextSentenceBreak(xBreakIterator->endOfSentence(rTxt, nTextPosition, rLocale));
sal_Int32 a(nTextPosition);
for(; a < nTextPosition + nTextLength; a++)
{
if(a == nNextSentenceBreak)
{
breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
nCurrent = a;
nNextSentenceBreak = xBreakIterator->endOfSentence(rTxt, a + 1, rLocale);
}
}
breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
break;
}
}