These multi-lingual IMs have been always disabled for Linux

Where not-Linux was in practice solaris. We can be pretty sure that the
ismultlingual path is effectively unused. so following that chain of logic
quite a bit can go.
This commit is contained in:
Caolán McNamara
2011-09-05 16:37:00 +01:00
parent 66ec27f691
commit 8b0287543d
10 changed files with 71 additions and 225 deletions
-1
View File
@@ -86,7 +86,6 @@ typedef enum {
typedef struct {
SalFrame* pFrame;
Bool bIsMultilingual;
preedit_status_t eState;
preedit_text_t aText;
SalExtTextInputEvent aInputEv;
-2
View File
@@ -38,7 +38,6 @@ class SalI18N_InputContext
private:
Bool mbUseable; // system supports current locale ?
Bool mbMultiLingual; // system supports iiimp ?
XIC maContext;
XIMStyle mnSupportedStatusStyle;
@@ -66,7 +65,6 @@ private:
public:
Bool UseContext() { return mbUseable; }
Bool IsMultiLingual() { return mbMultiLingual; }
Bool IsPreeditMode() { return maClientData.eState == ePreeditStatusActive; }
XIC GetContext() { return maContext; }
-3
View File
@@ -39,14 +39,12 @@ class VCLPLUG_GEN_PUBLIC SalI18N_InputMethod
{
Bool mbUseable; // system supports locale as well as status
// and preedit style ?
Bool mbMultiLingual; // system supports iiimp
XIM maMethod;
XIMCallback maDestroyCallback;
XIMStyles *mpStyles;
public:
Bool IsMultiLingual() { return mbMultiLingual; }
Bool PosixLocale();
Bool UseMethod() { return mbUseable; }
XIM GetMethod() { return maMethod; }
@@ -55,7 +53,6 @@ public:
XIMStyles *GetSupportedStyles() { return mpStyles; }
Bool SetLocale( const char* pLocale = "" );
Bool FilterEvent( XEvent *pEvent, XLIB_Window window );
Bool AddConnectionWatch (Display *pDisplay, void *pConnectionHandler);
SalI18N_InputMethod();
~SalI18N_InputMethod();
+68 -95
View File
@@ -164,100 +164,91 @@ enlarge_buffer ( preedit_text_t *ptext, int nnewlimit )
//
void
Preedit_InsertText(preedit_text_t *pText, XIMText *pInsertText, int where,
Bool isMultilingual)
Preedit_InsertText(preedit_text_t *pText, XIMText *pInsertText, int where)
{
sal_Unicode *pInsertTextString;
int nInsertTextLength = 0;
XIMFeedback *pInsertTextCharStyle = pInsertText->feedback;
sal_Unicode *pInsertTextString;
int nInsertTextLength = 0;
XIMFeedback *pInsertTextCharStyle = pInsertText->feedback;
nInsertTextLength = pInsertText->length;
nInsertTextLength = pInsertText->length;
if (isMultilingual)
// can't handle wchar_t strings, so convert to multibyte chars first
char *pMBString;
size_t nMBLength;
if (pInsertText->encoding_is_wchar)
{
XIMUnicodeText *pUniText = (XIMUnicodeText*)pInsertText;
pInsertTextString = pUniText->string.utf16_char;
}
wchar_t *pWCString = pInsertText->string.wide_char;
size_t nBytes = wcstombs ( NULL, pWCString, 1024 /* dont care */);
pMBString = (char*)alloca( nBytes + 1 );
nMBLength = wcstombs ( pMBString, pWCString, nBytes + 1);
}
else
{
// can't handle wchar_t strings, so convert to multibyte chars first
char *pMBString;
size_t nMBLength;
if (pInsertText->encoding_is_wchar)
{
wchar_t *pWCString = pInsertText->string.wide_char;
size_t nBytes = wcstombs ( NULL, pWCString, 1024 /* dont care */);
pMBString = (char*)alloca( nBytes + 1 );
nMBLength = wcstombs ( pMBString, pWCString, nBytes + 1);
}
else
{
pMBString = pInsertText->string.multi_byte;
nMBLength = strlen(pMBString); // xxx
}
pMBString = pInsertText->string.multi_byte;
nMBLength = strlen(pMBString); // xxx
}
// convert multibyte chars to unicode
rtl_TextEncoding nEncoding = osl_getThreadTextEncoding();
// convert multibyte chars to unicode
rtl_TextEncoding nEncoding = osl_getThreadTextEncoding();
if (nEncoding != RTL_TEXTENCODING_UNICODE)
{
rtl_TextToUnicodeConverter aConverter =
rtl_createTextToUnicodeConverter( nEncoding );
rtl_TextToUnicodeContext aContext =
rtl_createTextToUnicodeContext(aConverter);
if (nEncoding != RTL_TEXTENCODING_UNICODE)
{
rtl_TextToUnicodeConverter aConverter =
rtl_createTextToUnicodeConverter( nEncoding );
rtl_TextToUnicodeContext aContext =
rtl_createTextToUnicodeContext(aConverter);
sal_Size nBufferSize = nInsertTextLength * 2;
sal_Size nBufferSize = nInsertTextLength * 2;
pInsertTextString = (sal_Unicode*)alloca(nBufferSize);
pInsertTextString = (sal_Unicode*)alloca(nBufferSize);
sal_uInt32 nConversionInfo;
sal_Size nConvertedChars;
sal_uInt32 nConversionInfo;
sal_Size nConvertedChars;
rtl_convertTextToUnicode( aConverter, aContext,
pMBString, nMBLength,
pInsertTextString, nBufferSize,
RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE
| RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE,
&nConversionInfo, &nConvertedChars );
rtl_convertTextToUnicode( aConverter, aContext,
pMBString, nMBLength,
pInsertTextString, nBufferSize,
RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE
| RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE,
&nConversionInfo, &nConvertedChars );
rtl_destroyTextToUnicodeContext(aConverter, aContext);
rtl_destroyTextToUnicodeConverter(aConverter);
rtl_destroyTextToUnicodeContext(aConverter, aContext);
rtl_destroyTextToUnicodeConverter(aConverter);
}
else
{
pInsertTextString = (sal_Unicode*)pMBString;
}
}
}
else
{
pInsertTextString = (sal_Unicode*)pMBString;
}
// enlarge target text-buffer if necessary
if (pText->nSize <= (pText->nLength + nInsertTextLength))
enlarge_buffer(pText, pText->nLength + nInsertTextLength);
// enlarge target text-buffer if necessary
if (pText->nSize <= (pText->nLength + nInsertTextLength))
enlarge_buffer(pText, pText->nLength + nInsertTextLength);
// insert text: displace old mem and put new bytes in
int from = where;
int to = where + nInsertTextLength;
int howmany = pText->nLength - where;
// insert text: displace old mem and put new bytes in
int from = where;
int to = where + nInsertTextLength;
int howmany = pText->nLength - where;
memmove((void*)(pText->pUnicodeBuffer + to),
(void*)(pText->pUnicodeBuffer + from),
howmany * sizeof(sal_Unicode));
memmove((void*)(pText->pCharStyle + to),
(void*)(pText->pCharStyle + from),
howmany * sizeof(XIMFeedback));
memmove((void*)(pText->pUnicodeBuffer + to),
(void*)(pText->pUnicodeBuffer + from),
howmany * sizeof(sal_Unicode));
memmove((void*)(pText->pCharStyle + to),
(void*)(pText->pCharStyle + from),
howmany * sizeof(XIMFeedback));
to = from;
howmany = nInsertTextLength;
to = from;
howmany = nInsertTextLength;
memcpy((void*)(pText->pUnicodeBuffer + to), (void*)pInsertTextString,
howmany * sizeof(sal_Unicode));
memcpy((void*)(pText->pCharStyle + to), (void*)pInsertTextCharStyle,
howmany * sizeof(XIMFeedback));
memcpy((void*)(pText->pUnicodeBuffer + to), (void*)pInsertTextString,
howmany * sizeof(sal_Unicode));
memcpy((void*)(pText->pCharStyle + to), (void*)pInsertTextCharStyle,
howmany * sizeof(XIMFeedback));
pText->nLength += howmany;
pText->nLength += howmany;
// NULL-terminate the string
pText->pUnicodeBuffer[pText->nLength] = (sal_Unicode)0;
// NULL-terminate the string
pText->pUnicodeBuffer[pText->nLength] = (sal_Unicode)0;
}
//
@@ -372,7 +363,7 @@ PreeditDrawCallback(XIC ic, XPointer client_data,
&& (call_data->text->string.wide_char != NULL))
{
Preedit_InsertText(&(pPreeditData->aText), call_data->text,
call_data->chg_first, pPreeditData->bIsMultilingual);
call_data->chg_first);
}
else
// handle text replacement by deletion and insertion of text,
@@ -383,7 +374,7 @@ PreeditDrawCallback(XIC ic, XPointer client_data,
Preedit_DeleteText(&(pPreeditData->aText),
call_data->chg_first, call_data->chg_length);
Preedit_InsertText(&(pPreeditData->aText), call_data->text,
call_data->chg_first, pPreeditData->bIsMultilingual);
call_data->chg_first);
}
else
// not really a text update, only attributes are concerned
@@ -567,27 +558,9 @@ StatusDoneCallback (XIC, XPointer, XPointer)
}
void
StatusDrawCallback (XIC ic, XPointer client_data, XIMStatusDrawCallbackStruct *call_data)
StatusDrawCallback (XIC, XPointer, XIMStatusDrawCallbackStruct *call_data)
{
preedit_data_t* pPreeditData = (preedit_data_t*)client_data;
if( pPreeditData->bIsMultilingual )
{
// IIIMP
XIMUnicodeText *cbtext = (XIMUnicodeText *)call_data->data.text;
::vcl::I18NStatus::get().setStatusText( String( cbtext->string.utf16_char, call_data->data.text->length ) );
XIMUnicodeCharacterSubset* pSubset = NULL;
if( ! XGetICValues( ic,
XNUnicodeCharacterSubset, & pSubset,
NULL )
&& pSubset )
{
::vcl::I18NStatus::get().changeIM( String( ByteString( pSubset->name ), RTL_TEXTENCODING_UTF8 ) );
#if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "got XNUnicodeCharacterSubset\n %d\n %d\n %s\n %d\n", pSubset->index, pSubset->subset_id, pSubset->name, pSubset->is_active );
#endif
}
}
else if( call_data->type == XIMTextType )
if( call_data->type == XIMTextType )
{
String aText;
if( call_data->data.text )
-34
View File
@@ -187,7 +187,6 @@ SalI18N_InputContext::SalI18N_InputContext ( SalFrame *pFrame ) :
SalI18N_InputMethod *pInputMethod;
pInputMethod = GetX11SalData()->GetDisplay()->GetInputMethod();
mbMultiLingual = pInputMethod->IsMultiLingual();
mnSupportedPreeditStyle = XIMPreeditCallbacks | XIMPreeditPosition
| XIMPreeditNothing | XIMPreeditNone;
@@ -200,7 +199,6 @@ SalI18N_InputContext::SalI18N_InputContext ( SalFrame *pFrame ) :
// for status callbacks and commit string callbacks
#define PREEDIT_BUFSZ 16
maClientData.bIsMultilingual = mbMultiLingual;
maClientData.eState = ePreeditStatusStartPending;
maClientData.pFrame = pFrame;
maClientData.aText.pUnicodeBuffer =
@@ -359,7 +357,6 @@ SalI18N_InputContext::SalI18N_InputContext ( SalFrame *pFrame ) :
#endif
mbUseable = False;
mbMultiLingual = False;
if ( mpAttributes != NULL )
XFree( mpAttributes );
@@ -379,17 +376,6 @@ SalI18N_InputContext::SalI18N_InputContext ( SalFrame *pFrame ) :
maClientData.aText.pCharStyle = NULL;
}
if ( maContext != NULL && mbMultiLingual )
{
maCommitStringCallback.callback = (XIMProc)::CommitStringCallback;
maCommitStringCallback.client_data = (XPointer)&maClientData;
maSwitchIMCallback.callback = (XIMProc)::SwitchIMCallback;
maSwitchIMCallback.client_data = (XPointer)&maClientData;
XSetICValues( maContext,
XNCommitStringCallback, &maCommitStringCallback,
XNSwitchIMNotifyCallback, &maSwitchIMCallback,
NULL );
}
if ( maContext != NULL)
{
maDestroyCallback.callback = (XIMProc)IC_IMDestroyCallback;
@@ -398,21 +384,6 @@ SalI18N_InputContext::SalI18N_InputContext ( SalFrame *pFrame ) :
XNDestroyCallback, &maDestroyCallback,
NULL );
}
if( mbMultiLingual )
{
// set initial IM status
XIMUnicodeCharacterSubset* pSubset = NULL;
if( ! XGetICValues( maContext,
XNUnicodeCharacterSubset, & pSubset,
NULL )
&& pSubset )
{
String aCurrent( ByteString( pSubset->name ), RTL_TEXTENCODING_UTF8 );
::vcl::I18NStatus::get().changeIM( aCurrent );
::vcl::I18NStatus::get().setStatusText( aCurrent );
}
}
}
// ---------------------------------------------------------------------------
@@ -454,11 +425,6 @@ SalI18N_InputContext::Map( SalFrame *pFrame )
maContext = XCreateIC( pInputMethod->GetMethod(),
XNVaNestedList, mpAttributes,
NULL );
if ( maContext != NULL && mbMultiLingual )
XSetICValues( maContext,
XNCommitStringCallback, &maCommitStringCallback,
XNSwitchIMNotifyCallback, &maSwitchIMCallback,
NULL );
}
if( maClientData.pFrame != pFrame )
SetICFocus( pFrame );
+2 -81
View File
@@ -268,8 +268,6 @@ SalI18N_InputMethod::SetLocale( const char* pLocale )
Bool
SalI18N_InputMethod::PosixLocale()
{
if (mbMultiLingual)
return False;
if (maMethod)
return IsPosixLocale (XLocaleOfIM (maMethod));
return False;
@@ -282,7 +280,6 @@ SalI18N_InputMethod::PosixLocale()
// ------------------------------------------------------------------------
SalI18N_InputMethod::SalI18N_InputMethod( ) : mbUseable( bUseInputMethodDefault ),
mbMultiLingual( False ),
maMethod( (XIM)NULL ),
mpStyles( (XIMStyles*)NULL )
{
@@ -376,58 +373,7 @@ SalI18N_InputMethod::CreateMethod ( Display *pDisplay )
{
if ( mbUseable )
{
const bool bTryMultiLingual =
#ifdef LINUX
false;
#else
true;
#endif
if ( bTryMultiLingual && getenv("USE_XOPENIM") == NULL )
{
mbMultiLingual = True; // set ml-input flag to create input-method
maMethod = XvaOpenIM(pDisplay, NULL, NULL, NULL,
XNMultiLingualInput, mbMultiLingual, /* dummy */
(void *)0);
// get ml-input flag from input-method
if ( maMethod == (XIM)NULL )
mbMultiLingual = False;
else
if ( XGetIMValues(maMethod,
XNMultiLingualInput, &mbMultiLingual, NULL ) != NULL )
mbMultiLingual = False;
if( mbMultiLingual )
{
XIMUnicodeCharacterSubsets* subsets;
if( XGetIMValues( maMethod,
XNQueryUnicodeCharacterSubset, &subsets, NULL ) == NULL )
{
#if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "IM reports %d subsets: ", subsets->count_subsets );
#endif
I18NStatus& rStatus( I18NStatus::get() );
rStatus.clearChoices();
for( int i = 0; i < subsets->count_subsets; i++ )
{
#if OSL_DEBUG_LEVEL > 1
fprintf( stderr,"\"%s\" ", subsets->supported_subsets[i].name );
#endif
rStatus.addChoice( String( subsets->supported_subsets[i].name, RTL_TEXTENCODING_UTF8 ), &subsets->supported_subsets[i] );
}
#if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "\n" );
#endif
}
#if OSL_DEBUG_LEVEL > 1
else
fprintf( stderr, "query subsets failed\n" );
#endif
}
}
else
{
maMethod = XOpenIM(pDisplay, NULL, NULL, NULL);
mbMultiLingual = False;
}
maMethod = XOpenIM(pDisplay, NULL, NULL, NULL);
if ((maMethod == (XIM)NULL) && (getenv("XMODIFIERS") != NULL))
{
@@ -435,7 +381,6 @@ SalI18N_InputMethod::CreateMethod ( Display *pDisplay )
osl_clearEnvironment(envVar.pData);
XSetLocaleModifiers("");
maMethod = XOpenIM(pDisplay, NULL, NULL, NULL);
mbMultiLingual = False;
}
if ( maMethod != (XIM)NULL )
@@ -444,8 +389,7 @@ SalI18N_InputMethod::CreateMethod ( Display *pDisplay )
!= NULL)
mbUseable = False;
#if OSL_DEBUG_LEVEL > 1
fprintf(stderr, "Creating %s-Lingual InputMethod\n",
mbMultiLingual ? "Multi" : "Mono" );
fprintf(stderr, "Creating Mono-Lingual InputMethod\n" );
PrintInputStyle( mpStyles );
#endif
}
@@ -510,7 +454,6 @@ void
SalI18N_InputMethod::HandleDestroyIM()
{
mbUseable = False;
mbMultiLingual = False;
maMethod = NULL;
}
@@ -596,26 +539,4 @@ InputMethod_ConnectionWatchProc (Display *pDisplay, XPointer pClientData,
}
}
Bool
SalI18N_InputMethod::AddConnectionWatch(Display *pDisplay, void *pConnectionHandler)
{
// sanity check
if (pDisplay == NULL || pConnectionHandler == NULL)
return False;
// if we are not ml all the extended text input comes on the stock X queue,
// so there is no need to monitor additional file descriptors.
#ifndef SOLARIS
if (!mbMultiLingual || !mbUseable)
return False;
#endif
// pConnectionHandler must be really a pointer to a SalXLib
Status nStatus = XAddConnectionWatch (pDisplay, InputMethod_ConnectionWatchProc,
(XPointer)pConnectionHandler);
return (Bool)nStatus;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-1
View File
@@ -464,7 +464,6 @@ void SalXLib::Init()
SalDisplay *pSalDisplay = new SalX11Display( pDisp );
pInputMethod->CreateMethod( pDisp );
pInputMethod->AddConnectionWatch( pDisp, (void*)this );
pSalDisplay->SetInputMethod( pInputMethod );
PushXErrorLevel( true );
+1 -6
View File
@@ -3369,12 +3369,7 @@ long X11SalFrame::HandleKeyEvent( XKeyEvent *pEvent )
if( aDeleteWatch.isDeleted() )
return 0;
rtl_TextEncoding nEncoding;
if (mpInputContext != NULL && mpInputContext->IsMultiLingual() )
nEncoding = RTL_TEXTENCODING_UTF8;
else
nEncoding = osl_getThreadTextEncoding();
rtl_TextEncoding nEncoding = osl_getThreadTextEncoding();
sal_Unicode *pBuffer;
sal_Unicode *pString;
-1
View File
@@ -184,7 +184,6 @@ void KDEXLib::Init()
SalDisplay *pSalDisplay = new SalKDEDisplay( pDisp );
pInputMethod->CreateMethod( pDisp );
pInputMethod->AddConnectionWatch( pDisp, (void*)this );
pSalDisplay->SetInputMethod( pInputMethod );
PushXErrorLevel( true );
-1
View File
@@ -178,7 +178,6 @@ void KDEXLib::Init()
SalKDEDisplay *pSalDisplay = new SalKDEDisplay(pDisp);
pInputMethod->CreateMethod( pDisp );
pInputMethod->AddConnectionWatch( pDisp, (void*)this );
pSalDisplay->SetInputMethod( pInputMethod );
PushXErrorLevel( true );