1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: i18n_wrp.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
40 #if defined(SOLARIS) && !defined(__GNUC__)
45 #include <sal/alloca.h>
50 #include <X11/Xlibint.h>
53 #define XIIIMP_LIB "xiiimp.so.2"
56 #define XIIIMP_PATH "/usr/openwin/lib/locale/common/" XIIIMP_LIB
58 #define XIIIMP_PATH "/usr/lib/im/" XIIIMP_LIB
62 typedef XIM (*OpenFunction
)(Display
*, XrmDatabase
, char*, char*, XIMArg
*);
65 /* global variables */
66 static void *g_dlmodule
= 0;
67 static OpenFunction g_open_im
= (OpenFunction
)NULL
;
69 /* utility function to transform vararg list into an array of XIMArg */
72 XvaCountArgs( XIMArg
*pInArgs
)
77 while ( (pName
= pInArgs
->name
) != NULL
)
79 pValue
= pInArgs
->value
;
81 if ( strcmp(pName
, XNVaNestedList
) == 0 )
83 nArgs
+= XvaCountArgs( (XIMArg
*)pValue
);
96 XvaCountArgs( va_list pInArgs
)
101 while ( (pName
= va_arg(pInArgs
, char*)) != NULL
)
103 pValue
= va_arg(pInArgs
, char*);
105 if ( strcmp(pName
, XNVaNestedList
) == 0 )
107 nArgs
+= XvaCountArgs( (XIMArg
*)pValue
);
119 XvaGetArgs( XIMArg
*pInArgs
, XIMArg
*pOutArgs
)
121 char *pName
, *pValue
;
123 while ( (pName
= pInArgs
->name
) != NULL
)
125 pValue
= pInArgs
->value
;
127 if ( strcmp(pName
, XNVaNestedList
) == 0 )
129 pOutArgs
= XvaGetArgs( (XIMArg
*)pValue
, pOutArgs
);
133 pOutArgs
->name
= pName
;
134 pOutArgs
->value
= pValue
;
144 XvaGetArgs( va_list pInArgs
, XIMArg
*pOutArgs
)
146 char *pName
, *pValue
;
148 while ((pName
= va_arg(pInArgs
, char*)) != NULL
)
150 pValue
= va_arg(pInArgs
, char*);
152 if ( strcmp(pName
, XNVaNestedList
) == 0 )
154 pOutArgs
= XvaGetArgs( (XIMArg
*)pValue
, pOutArgs
);
158 pOutArgs
->name
= pName
;
159 pOutArgs
->value
= pValue
;
164 pOutArgs
->name
= NULL
;
165 pOutArgs
->value
= NULL
;
169 /* Puplic functions */
175 XvaOpenIM(Display
*display
, XrmDatabase rdb
,
176 char *res_name
, char *res_class
, ...)
183 * so count the stuff dangling here
186 #if defined(SOLARIS) && !defined(__GNUC__)
189 va_start(variable
, res_class
);
191 total_count
= XvaCountArgs(variable
);
196 /* call a new open IM method */
198 XIMArg
* args
= (XIMArg
*)alloca( (total_count
+ 1) * sizeof(XIMArg
) );
201 * now package it up so we can set it along
203 #if defined(SOLARIS) && !defined(__GNUC__)
206 va_start(variable
, res_class
);
208 XvaGetArgs( variable
, args
);
213 g_dlmodule
= dlopen(XIIIMP_LIB
, RTLD_LAZY
);
216 g_dlmodule
= dlopen(XIIIMP_PATH
, RTLD_LAZY
);
220 g_open_im
= (OpenFunction
)(long)dlsym(g_dlmodule
, "__XOpenIM");
224 xim
= (*g_open_im
)(display
, (XrmDatabase
)rdb
,
225 (char*)res_name
, (char *)res_class
, (XIMArg
*)args
);
233 // in #if to prevent warning "warning: label 'legacy_XIM' defined but not used"
237 xim
= XOpenIM(display
, rdb
, res_name
, res_class
);
243 * Close the connection to the input manager, and free the XIM structure
246 Status
XvaCloseIM(XIM
)
252 /* assuming one XvaOpenIM call */
254 g_dlmodule
= (void*)0;
255 g_open_im
= (OpenFunction
)NULL
;