fdo#46808, Adapt i18n::Transliteration UNO service to new style

Simply make the service implement XExtendedTransliteration, since all
of the implementatins already do that.

Change-Id: If03bf56a8d33931ad0230743a4603e2ae9b104ac
This commit is contained in:
Noel Grandin 2012-11-02 09:46:12 +02:00 committed by Stephan Bergmann
parent ec1c96a9b6
commit d2c45d0460
23 changed files with 66 additions and 83 deletions

View File

@ -42,7 +42,7 @@ namespace
public:
lclTransliterationWrapper()
: m_aTransliteration(
comphelper::getProcessServiceFactory(),
comphelper::getProcessComponentContext(),
com::sun::star::i18n::TransliterationModules_IGNORE_CASE )
{
const LanguageType eOfficeLanguage = Application::GetSettings().GetLanguage();

View File

@ -1626,9 +1626,9 @@ RTLFUNC(StrComp)
::utl::TransliterationWrapper* pTransliterationWrapper = GetSbData()->pTransliterationWrapper;
if( !pTransliterationWrapper )
{
uno::Reference< lang::XMultiServiceFactory > xSMgr = getProcessServiceFactory();
uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
pTransliterationWrapper = GetSbData()->pTransliterationWrapper =
new ::utl::TransliterationWrapper( xSMgr,
new ::utl::TransliterationWrapper( xContext,
i18n::TransliterationModules_IGNORE_CASE |
i18n::TransliterationModules_IGNORE_KANA |
i18n::TransliterationModules_IGNORE_WIDTH );
@ -4082,8 +4082,8 @@ RTLFUNC(StrConv)
String aNewStr( aOldStr );
if( nType != 0 )
{
uno::Reference< lang::XMultiServiceFactory > xSMgr = getProcessServiceFactory();
::utl::TransliterationWrapper aTransliterationWrapper( xSMgr,nType );
uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
::utl::TransliterationWrapper aTransliterationWrapper( xContext, nType );
uno::Sequence<sal_Int32> aOffsets;
aTransliterationWrapper.loadModuleIfNeeded( nLanguage );
aNewStr = aTransliterationWrapper.transliterate( aOldStr, nLanguage, 0, nOldLen, &aOffsets );

View File

@ -2704,7 +2704,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
sal_Bool bLenChanged = sal_False;
EditUndoTransliteration* pUndo = NULL;
utl::TransliterationWrapper aTranslitarationWrapper( ::comphelper::getProcessServiceFactory(), nTransliterationMode );
utl::TransliterationWrapper aTranslitarationWrapper( ::comphelper::getProcessComponentContext(), nTransliterationMode );
sal_Bool bConsiderLanguage = aTranslitarationWrapper.needLanguageForTheMode();
for ( sal_uInt16 nNode = nStartNode; nNode <= nEndNode; nNode++ )

View File

@ -196,7 +196,7 @@ static LocaleDataWrapper& GetLocaleDataWrapper( sal_uInt16 nLang )
static TransliterationWrapper& GetIgnoreTranslWrapper()
{
static int bIsInit = 0;
static TransliterationWrapper aWrp( GetProcessFact(),
static TransliterationWrapper aWrp( ::comphelper::getProcessComponentContext(),
::com::sun::star::i18n::TransliterationModules_IGNORE_KANA |
::com::sun::star::i18n::TransliterationModules_IGNORE_WIDTH );
if( !bIsInit )

View File

@ -40,6 +40,7 @@
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
#include <com/sun/star/i18n/KCharacterType.hpp>
#include <com/sun/star/i18n/Transliteration.hpp>
#include <com/sun/star/registry/XRegistryKey.hpp>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/weak.hxx>
@ -112,19 +113,12 @@ void TextSearch::setOptions( const SearchOptions& rOptions ) throw( RuntimeExcep
{
if( !xTranslit.is() )
{
Reference < XInterface > xI = xMSF->createInstance(
OUString(
"com.sun.star.i18n.Transliteration"));
if ( xI.is() )
xI->queryInterface( ::getCppuType(
(const Reference< XExtendedTransliteration >*)0))
>>= xTranslit;
xTranslit.set( Transliteration::create( comphelper::getComponentContext(xMSF) ) );
}
// Load transliteration module
if( xTranslit.is() )
xTranslit->loadModule(
(TransliterationModules)( aSrchPara.transliterateFlags & SIMPLE_TRANS_MASK ),
aSrchPara.Locale);
xTranslit->loadModule(
(TransliterationModules)( aSrchPara.transliterateFlags & SIMPLE_TRANS_MASK ),
aSrchPara.Locale);
}
else if( xTranslit.is() )
xTranslit = 0;
@ -134,19 +128,12 @@ void TextSearch::setOptions( const SearchOptions& rOptions ) throw( RuntimeExcep
{
if( !xTranslit2.is() )
{
Reference < XInterface > xI = xMSF->createInstance(
OUString(
"com.sun.star.i18n.Transliteration"));
if ( xI.is() )
xI->queryInterface( ::getCppuType(
(const Reference< XExtendedTransliteration >*)0))
>>= xTranslit2;
xTranslit2.set( Transliteration::create( comphelper::getComponentContext(xMSF) ) );
}
// Load transliteration module
if( xTranslit2.is() )
xTranslit2->loadModule(
(TransliterationModules)( aSrchPara.transliterateFlags & COMPLEX_TRANS_MASK ),
aSrchPara.Locale);
xTranslit2->loadModule(
(TransliterationModules)( aSrchPara.transliterateFlags & COMPLEX_TRANS_MASK ),
aSrchPara.Locale);
}
if ( !xBreak.is() )

View File

@ -155,6 +155,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/i18n,\
BreakIterator \
LocaleCalendar \
LocaleData \
Transliteration \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/linguistic2,\
LanguageGuessing \
@ -871,7 +872,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/i18n,\
NumberFormatMapper \
OrdinalSuffix \
TextConversion \
Transliteration \
))
$(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/image,\
ImageMap \

View File

@ -28,12 +28,7 @@ module com { module sun { module star { module i18n {
/// Transliteration of characters, such as case folding
published service Transliteration
{
interface com::sun::star::i18n::XTransliteration;
[optional] interface com::sun::star::i18n::XExtendedTransliteration;
};
published service Transliteration : XExtendedTransliteration;
}; }; }; };

Binary file not shown.

View File

@ -1512,7 +1512,7 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp
{
OSL_ENSURE( rMultiMark.IsMultiMarked(), "TransliterateText: no selection" );
utl::TransliterationWrapper aTranslitarationWrapper( xServiceManager, nType );
utl::TransliterationWrapper aTranslitarationWrapper( comphelper::getComponentContext(xServiceManager), nType );
bool bConsiderLanguage = aTranslitarationWrapper.needLanguageForTheMode();
sal_uInt16 nLanguage = LANGUAGE_SYSTEM;

View File

@ -1117,7 +1117,7 @@ utl::TransliterationWrapper* ScGlobal::GetpTransliteration()
{
const LanguageType eOfficeLanguage = Application::GetSettings().GetLanguage();
pTransliteration = new ::utl::TransliterationWrapper(
::comphelper::getProcessServiceFactory(), SC_TRANSLITERATION_IGNORECASE );
::comphelper::getProcessComponentContext(), SC_TRANSLITERATION_IGNORECASE );
pTransliteration->loadModuleIfNeeded( eOfficeLanguage );
}
OSL_ENSURE(
@ -1165,7 +1165,7 @@ CollatorWrapper* ScGlobal::GetCaseCollator()
if ( !pCaseTransliteration )
{
const LanguageType eOfficeLanguage = Application::GetSettings().GetLanguage();
pCaseTransliteration = new ::utl::TransliterationWrapper(::comphelper::getProcessServiceFactory(), SC_TRANSLITERATION_CASESENSE );
pCaseTransliteration = new ::utl::TransliterationWrapper(::comphelper::getProcessComponentContext(), SC_TRANSLITERATION_CASESENSE );
pCaseTransliteration->loadModuleIfNeeded( eOfficeLanguage );
}
return pCaseTransliteration;

View File

@ -179,7 +179,7 @@ void ScCellKeywordTranslator::transKeyword(rtl::OUString& rName, const Locale* p
}
ScCellKeywordTranslator::ScCellKeywordTranslator() :
maTransWrapper( ::comphelper::getProcessServiceFactory(),
maTransWrapper( ::comphelper::getProcessComponentContext(),
i18n::TransliterationModules_LOWERCASE_UPPERCASE )
{
init();

View File

@ -3248,7 +3248,7 @@ void ScInterpreter::ScChar()
static ::rtl::OUString lcl_convertIntoHalfWidth( const ::rtl::OUString & rStr )
{
static bool bFirstASCCall = true;
static utl::TransliterationWrapper aTrans( ::comphelper::getProcessServiceFactory(), 0 );
static utl::TransliterationWrapper aTrans( ::comphelper::getProcessComponentContext(), 0 );
if( bFirstASCCall )
{
@ -3263,7 +3263,7 @@ static ::rtl::OUString lcl_convertIntoHalfWidth( const ::rtl::OUString & rStr )
static ::rtl::OUString lcl_convertIntoFullWidth( const ::rtl::OUString & rStr )
{
static bool bFirstJISCall = true;
static utl::TransliterationWrapper aTrans( ::comphelper::getProcessServiceFactory(), 0 );
static utl::TransliterationWrapper aTrans( ::comphelper::getProcessComponentContext(), 0 );
if( bFirstJISCall )
{

View File

@ -1293,7 +1293,7 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
// For date recognition
::utl::TransliterationWrapper aTransliteration(
pDoc->GetServiceManager(), SC_TRANSLITERATION_IGNORECASE );
comphelper::getComponentContext(pDoc->GetServiceManager()), SC_TRANSLITERATION_IGNORECASE );
aTransliteration.loadModuleIfNeeded( eDocLang );
CalendarWrapper aCalendar( comphelper::getComponentContext(pDoc->GetServiceManager()) );
aCalendar.loadDefaultCalendar(
@ -1303,7 +1303,7 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
if ( eDocLang != LANGUAGE_ENGLISH_US )
{
pEnglishTransliteration = new ::utl::TransliterationWrapper (
pDoc->GetServiceManager(), SC_TRANSLITERATION_IGNORECASE );
comphelper::getComponentContext(pDoc->GetServiceManager()), SC_TRANSLITERATION_IGNORECASE );
aTransliteration.loadModuleIfNeeded( LANGUAGE_ENGLISH_US );
pEnglishCalendar = new CalendarWrapper ( comphelper::getComponentContext(pDoc->GetServiceManager()) );
pEnglishCalendar->loadDefaultCalendar(

View File

@ -32,6 +32,15 @@
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
namespace comphelper {
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
getComponentContext(
com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
const & factory);
}
/*
On demand instanciation and initialization of several i18n wrappers,
helping the number formatter to not perform worse than it already does.
@ -300,7 +309,7 @@ public:
if ( !bValid )
{
if ( !pPtr )
pPtr = new ::utl::TransliterationWrapper( xSMgr, nType );
pPtr = new ::utl::TransliterationWrapper( comphelper::getComponentContext(xSMgr), nType );
pPtr->loadModuleIfNeeded( eLanguage );
bValid = true;
}
@ -310,7 +319,7 @@ public:
const ::utl::TransliterationWrapper* getForModule( const String& rModule, LanguageType eLang ) const
{
if ( !pPtr )
pPtr = new ::utl::TransliterationWrapper( xSMgr, nType );
pPtr = new ::utl::TransliterationWrapper( comphelper::getComponentContext(xSMgr), nType );
pPtr->loadModuleByImplName( rModule, eLang );
bValid = false; // reforce settings change in get()
return pPtr;

View File

@ -865,9 +865,9 @@ namespace
public:
TransWrp()
{
uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
xTransWrp.reset(new ::utl::TransliterationWrapper( xMSF,
xTransWrp.reset(new ::utl::TransliterationWrapper( xContext,
i18n::TransliterationModules_IGNORE_CASE |
i18n::TransliterationModules_IGNORE_KANA |
i18n::TransliterationModules_IGNORE_WIDTH ));

View File

@ -1126,7 +1126,7 @@ void SwEditShell::SetExtTextInputData( const CommandExtTextInputData& rData )
void SwEditShell::TransliterateText( sal_uInt32 nType )
{
utl::TransliterationWrapper aTrans( ::comphelper::getProcessServiceFactory(), nType );
utl::TransliterationWrapper aTrans( ::comphelper::getProcessComponentContext(), nType );
StartAllAction();
SET_CURR_SHELL( this );

View File

@ -382,7 +382,7 @@ void SwUndoTransliterate::RepeatImpl(::sw::RepeatContext & rContext)
void SwUndoTransliterate::DoTransliterate(SwDoc & rDoc, SwPaM & rPam)
{
utl::TransliterationWrapper aTrans( ::comphelper::getProcessServiceFactory(), nType );
utl::TransliterationWrapper aTrans( ::comphelper::getProcessComponentContext(), nType );
rDoc.TransliterateText( rPam, aTrans );
}

View File

@ -25,8 +25,8 @@
#include <com/sun/star/i18n/XExtendedTransliteration.hpp>
namespace com { namespace sun { namespace star {
namespace lang {
class XMultiServiceFactory;
namespace uno {
class XComponentContext;
}
}}}
@ -35,8 +35,6 @@ namespace utl
class UNOTOOLS_DLLPUBLIC TransliterationWrapper
{
::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory > xSMgr;
::com::sun::star::uno::Reference<
::com::sun::star::i18n::XExtendedTransliteration > xTrans;
::com::sun::star::lang::Locale aLocale;
@ -53,7 +51,7 @@ class UNOTOOLS_DLLPUBLIC TransliterationWrapper
public:
TransliterationWrapper( const ::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory > & xSF,
::com::sun::star::uno::XComponentContext > & rxContext,
sal_uInt32 nType );
~TransliterationWrapper();

View File

@ -24,6 +24,7 @@
#include "instance.hxx"
#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
#include <com/sun/star/i18n/Transliteration.hpp>
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::i18n;
@ -31,14 +32,11 @@ using namespace ::com::sun::star::uno;
using namespace ::utl;
TransliterationWrapper::TransliterationWrapper(
const Reference< XMultiServiceFactory > & xSF,
const Reference< XComponentContext > & rxContext,
sal_uInt32 nTyp )
: xSMgr( xSF ), nType( nTyp ), nLanguage( 0 ), bFirstCall( sal_True )
: nType( nTyp ), nLanguage( 0 ), bFirstCall( sal_True )
{
xTrans = Reference< XExtendedTransliteration > (
intl_createInstance( xSMgr, "com.sun.star.i18n.Transliteration",
"TransliterationWrapper" ), UNO_QUERY );
DBG_ASSERT( xTrans.is(), "TransliterationWrapper: no Transliteraion available" );
xTrans = Transliteration::create(rxContext);
}

View File

@ -27,6 +27,7 @@
************************************************************************/
#include "comphelper/processfactory.hxx"
#include "unotools/localedatawrapper.hxx"
#include "unotools/transliterationwrapper.hxx"
@ -72,7 +73,7 @@ utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() co
if ( mbTransliterateIgnoreCase )
nModules |= i18n::TransliterationModules_IGNORE_CASE;
((vcl::I18nHelper*)this)->mpTransliterationWrapper = new utl::TransliterationWrapper( mxMSF, (i18n::TransliterationModules)nModules );
((vcl::I18nHelper*)this)->mpTransliterationWrapper = new utl::TransliterationWrapper( comphelper::getComponentContext(mxMSF), (i18n::TransliterationModules)nModules );
((vcl::I18nHelper*)this)->mpTransliterationWrapper->loadModuleIfNeeded( MsLangId::convertLocaleToLanguage( maLocale ) );
}
return *mpTransliterationWrapper;

View File

@ -258,7 +258,7 @@ class ResultSetForQueryFactory
{
private:
uno::Reference< lang::XMultiServiceFactory > m_xSMgr;
uno::Reference< uno::XComponentContext > m_xContext;
uno::Reference< ucb::XContentProvider > m_xProvider;
sal_Int32 m_nOpenMode;
uno::Sequence< beans::Property > m_seq;
@ -270,14 +270,14 @@ private:
public:
ResultSetForQueryFactory(
const uno::Reference< lang::XMultiServiceFactory >& xSMgr,
const uno::Reference< uno::XComponentContext >& rxContext,
const uno::Reference< ucb::XContentProvider >& xProvider,
sal_Int32 nOpenMode,
const uno::Sequence< beans::Property >& seq,
const uno::Sequence< ucb::NumberedSortingInfo >& seqSort,
URLParameter aURLParameter,
Databases* pDatabases )
: m_xSMgr( xSMgr ),
: m_xContext( rxContext ),
m_xProvider( xProvider ),
m_nOpenMode( nOpenMode ),
m_seq( seq ),
@ -289,7 +289,7 @@ public:
ResultSetBase* createResultSet()
{
return new ResultSetForQuery( m_xSMgr,
return new ResultSetForQuery( m_xContext,
m_xProvider,
m_nOpenMode,
m_seq,
@ -420,7 +420,7 @@ uno::Any SAL_CALL Content::execute(
aOpenCommand,
Environment,
new ResultSetForQueryFactory(
m_xSMgr,
comphelper::getComponentContext(m_xSMgr),
m_xProvider.get(),
aOpenCommand.Mode,
aOpenCommand.Properties,

View File

@ -29,7 +29,7 @@
#include <comphelper/processfactory.hxx>
#include <com/sun/star/ucb/Command.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/i18n/XExtendedTransliteration.hpp>
#include <com/sun/star/i18n/Transliteration.hpp>
#include <com/sun/star/ucb/XCommandProcessor.hpp>
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/script/XInvocation.hpp>
@ -88,25 +88,22 @@ struct HitItem
}
};
ResultSetForQuery::ResultSetForQuery( const uno::Reference< lang::XMultiServiceFactory >& xMSF,
ResultSetForQuery::ResultSetForQuery( const uno::Reference< uno::XComponentContext >& rxContext,
const uno::Reference< XContentProvider >& xProvider,
sal_Int32 nOpenMode,
const uno::Sequence< beans::Property >& seq,
const uno::Sequence< NumberedSortingInfo >& seqSort,
URLParameter& aURLParameter,
Databases* pDatabases )
: ResultSetBase( comphelper::getComponentContext(xMSF),xProvider,nOpenMode,seq,seqSort ),
: ResultSetBase( rxContext,xProvider,nOpenMode,seq,seqSort ),
m_aURLParameter( aURLParameter )
{
Reference< XTransliteration > xTrans(
xMSF->createInstance( rtl::OUString( "com.sun.star.i18n.Transliteration" ) ),
UNO_QUERY );
Reference< XExtendedTransliteration > xTrans = Transliteration::create( rxContext );
Locale aLocale( aURLParameter.get_language(),
rtl::OUString(),
rtl::OUString() );
if(xTrans.is())
xTrans->loadModule(TransliterationModules_UPPERCASE_LOWERCASE,
aLocale );
xTrans->loadModule(TransliterationModules_UPPERCASE_LOWERCASE,
aLocale );
vector< vector< rtl::OUString > > queryList;
{
@ -121,11 +118,9 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference< lang::XMultiServiceF
vector< rtl::OUString > currentQuery;
rtl::OUString tmp(query.copy( 0,idx ));
rtl:: OUString toliterate = tmp;
if(xTrans.is()) {
Sequence<sal_Int32> aSeq;
toliterate = xTrans->transliterate(
tmp,0,tmp.getLength(),aSeq);
}
Sequence<sal_Int32> aSeq;
toliterate = xTrans->transliterate(
tmp,0,tmp.getLength(),aSeq);
currentQuery.push_back( toliterate );
queryList.push_back( currentQuery );

View File

@ -19,7 +19,7 @@
#ifndef _RESULTSETFORQUERY_HXX
#define _RESULTSETFORQUERY_HXX
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/ucb/XContentProvider.hpp>
#include <com/sun/star/beans/Property.hpp>
#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
@ -36,7 +36,7 @@ namespace chelp {
{
public:
ResultSetForQuery( const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory>& xMSF,
ResultSetForQuery( const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>& rxContext,
const com::sun::star::uno::Reference<com::sun::star::ucb::XContentProvider>& xProvider,
sal_Int32 nOpenMode,
const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& seq,