diff -Naur sal/osl/unx/makefile.mk sal_new/osl/unx/makefile.mk --- sal/osl/unx/makefile.mk 2006-11-06 15:52:21.000000000 +0100 +++ sal_new/osl/unx/makefile.mk 2007-01-18 23:59:12.000000000 +0100 @@ -110,6 +110,10 @@ $(OBJ)$/file_stat.obj #.ENDIF +.IF "$(OS)"=="MACOSX" +SLOFILES += $(SLO)$/osxlocale.obj +.ENDIF + .IF "$(OS)"=="SOLARIS" || "$(OS)"=="FREEBSD" || "$(OS)"=="NETBSD" || "$(OS)$(CPU)"=="LINUXS" SLOFILES += $(SLO)$/backtrace.obj OBJFILES += $(OBJ)$/backtrace.obj diff -Naur sal/osl/unx/nlsupport.c sal_new/osl/unx/nlsupport.c --- sal/osl/unx/nlsupport.c 2006-07-25 11:40:46.000000000 +0200 +++ sal_new/osl/unx/nlsupport.c 2007-01-19 10:14:35.000000000 +0100 @@ -837,12 +837,11 @@ } #ifdef MACOSX -#include -#include -#include +#include #include +#include -/* OS X locale discovery function from dylib */ +/* OS X locale discovery function */ int (*pGetOSXLocale)( char *, sal_uInt32 ); /***************************************************************************** return the current process locale @@ -869,35 +868,24 @@ { /* Load the locale discovery library if we are running on OS X */ - const sal_Char *aLocaleLibName = "libsalsystools" SAL_DLLEXTENSION; const sal_Char *aGetOSXLocaleFunctionName = "macosx_getLocale"; - oslModule pLocaleLib; void *pFunc; int err; - pLocaleLib = osl_psz_loadModule( aLocaleLibName, SAL_LOADMODULE_DEFAULT ); - if( pLocaleLib ) + /* Grab a pointer to the locale function and call it */ + pFunc = dlsym( RTLD_DEFAULT, aGetOSXLocaleFunctionName ); + if( pFunc ) { - /* Grab a pointer to the locale function and call it */ - pFunc = osl_psz_getSymbol( pLocaleLib, aGetOSXLocaleFunctionName ); - if( pFunc ) - { - pGetOSXLocale = ( int(*)(char *, sal_uInt32) )( pFunc ); - locale = (char *)malloc( 20 ); - if ( locale ) - err = (*pGetOSXLocale)( locale, 20 ); - else - fprintf( stderr, "nlsupport.c: locale allocation returned NULL!\n" ); - } + pGetOSXLocale = ( int(*)(char *, sal_uInt32) )( pFunc ); + locale = (char *)malloc( 20 ); + if ( locale ) + err = (*pGetOSXLocale)( locale, 20 ); else - fprintf( stderr, "Could not load the OS X locale discovery function! (%s)\n", aGetOSXLocaleFunctionName ); + fprintf( stderr, "nlsupport.c: locale allocation returned NULL!\n" ); } else - fprintf( stderr, "Could not load the OS X locale discovery library! (%s)\n", aLocaleLibName ); - - /* Let go of the module, we don't need it anymore */ - osl_unloadModule( pLocaleLib ); - } + fprintf( stderr, "Could not load the OS X locale discovery function! (%s)\n", aGetOSXLocaleFunctionName ); + } } /* handle the case where OS specific method of finding locale fails */ diff -Naur sal/osl/unx/osxlocale.cxx sal_new/osl/unx/osxlocale.cxx --- sal/osl/unx/osxlocale.cxx 1970-01-01 01:00:00.000000000 +0100 +++ sal_new/osl/unx/osxlocale.cxx 2006-09-17 11:06:24.000000000 +0200 @@ -0,0 +1,132 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: osxlocale.cxx,v $ + * + * $Revision: 1.4 $ + * + * last change: $Author: obo $ $Date: 2006/09/17 09:06:24 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sal.hxx" + +#include +#include + +#include +#include +#include +#include + +namespace /* private */ +{ + template + class CFGuard + { + public: + explicit CFGuard(T& rT) : rT_(rT) {} + ~CFGuard() { if (rT_) CFRelease(rT_); } + private: + T& rT_; + }; + + typedef CFGuard CFArrayGuard; + typedef CFGuard CFStringGuard; + typedef CFGuard CFPropertyListGuard; + + /** Get the current process locale from system + */ + CFStringRef getProcessLocale() + { + CFPropertyListRef pref = CFPreferencesCopyAppValue(CFSTR("AppleLocale"), kCFPreferencesCurrentApplication); + CFPropertyListGuard proplGuard(pref); + + if (pref == NULL) // return fallback value 'en_US' + return CFStringCreateWithCString(kCFAllocatorDefault, "en_US", kCFStringEncodingASCII); + + CFStringRef sref = (CFGetTypeID(pref) == CFArrayGetTypeID()) ? (CFStringRef)CFArrayGetValueAtIndex((CFArrayRef)pref, 0) : (CFStringRef)pref; + + // NOTE: this API is only available with Mac OS X >=10.3. We need to use it because + // Apple used non-ISO values on systems <10.2 like "German" for instance but didn't + // upgrade those values during upgrade to newer Mac OS X versions. See also #i54337# + return CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorDefault, sref); + } +} // namespace private + +/** Grab current locale from system. +*/ +extern "C" int macosx_getLocale(char *locale, sal_uInt32 bufferLen) +{ + CFStringRef sref = getProcessLocale(); + CFStringGuard sGuard(sref); + + assert(sref != NULL && "osxlocale.cxx: getProcessLocale must return a non-NULL value"); + + // split the string into substrings; the first two (if there are two) substrings + // are language and country + CFArrayRef subs = CFStringCreateArrayBySeparatingStrings(NULL, sref, CFSTR("_")); + CFArrayGuard arrGuard(subs); + + CFStringRef lang = (CFStringRef)CFArrayGetValueAtIndex(subs, 0); + CFStringGetCString(lang, locale, bufferLen, kCFStringEncodingASCII); + + // country also available? Assumption: if the array contains more than one + // value the second value is always the country! + if (CFArrayGetCount(subs) > 1) + { + strlcat(locale, "_", bufferLen - strlen(locale)); + + CFStringRef country = (CFStringRef)CFArrayGetValueAtIndex(subs, 1); + CFStringGetCString(country, locale + strlen(locale), bufferLen - strlen(locale), kCFStringEncodingASCII); + } + // Append 'UTF-8' to the locale because the Mac OS X file + // system interface is UTF-8 based and sal tries to determine + // the file system locale from the locale information + strlcat(locale, ".UTF-8", bufferLen - strlen(locale)); + + return noErr; +} + + + +/* + * macxp_OSXConvertCFEncodingToIANACharSetName + * + * Convert a CoreFoundation text encoding to an IANA charset name. + */ +extern "C" int macxp_OSXConvertCFEncodingToIANACharSetName( char *buffer, unsigned int bufferLen, CFStringEncoding cfEncoding ) +{ + CFStringRef sCFEncodingName; + + sCFEncodingName = CFStringConvertEncodingToIANACharSetName( cfEncoding ); + CFStringGetCString( sCFEncodingName, buffer, bufferLen, cfEncoding ); + + return( noErr ); +} + diff -Naur sal/prj/build.lst sal_new/prj/build.lst --- sal/prj/build.lst 2006-10-30 10:00:03.000000000 +0100 +++ sal_new/prj/build.lst 2007-01-18 22:35:56.000000000 +0100 @@ -3,7 +3,6 @@ sa sal\inc nmake - all sa_inc NULL sa sal\typesconfig nmake - u sa_tc sa_inc NULL sa sal\cpprt nmake - u sa_cpprt sa_util sa_inc NULL -sa sal\systools\macxp_extras\x11osx nmake - u sa_mxpext_x11osx sa_tc.u sa_inc NULL sa sal\rtl\source nmake - all sa_rtl sa_tc.u sa_inc NULL sa sal\textenc nmake - all sa_textenc sa_tc.u sa_inc NULL sa sal\systools\win32\uwinapi nmake - n sa_uwinapi sa_inc NULL diff -Naur sal/systools/macxp_extras/x11osx/makefile.mk sal_new/systools/macxp_extras/x11osx/makefile.mk --- sal/systools/macxp_extras/x11osx/makefile.mk 2006-04-06 13:54:20.000000000 +0200 +++ sal_new/systools/macxp_extras/x11osx/makefile.mk 1970-01-01 01:00:00.000000000 +0100 @@ -1,73 +0,0 @@ -#************************************************************************* -# -# OpenOffice.org - a multi-platform office productivity suite -# -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.4 $ -# -# last change: $Author: vg $ $Date: 2006/04/06 11:54:20 $ -# -# The Contents of this file are made available subject to -# the terms of GNU Lesser General Public License Version 2.1. -# -# -# GNU Lesser General Public License Version 2.1 -# ============================================= -# Copyright 2005 by Sun Microsystems, Inc. -# 901 San Antonio Road, Palo Alto, CA 94303, USA -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License version 2.1, as published by the Free Software Foundation. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, -# MA 02111-1307 USA -# -#************************************************************************* - -PRJ=..$/..$/.. -PRJINC=..$/..$/.. -PRJNAME=sal -TARGET=salsystools - -# --- Settings ---------------------------------- -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/version.mk - -.IF "$(OS)"!="MACOSX" - -dummy: - @echo "Nothing to build for OS $(OS)" - -.ELSE # "$(OS)"!="MACOSX" - -# --- Files ------------------------------------- - -SLOFILES=\ - $(SLO)$/osxlocale.obj - -# --- Library ----------------------------------- - -SHL1TARGET=$(TARGET) -SHL1OBJS=$(SLOFILES) -NOSHAREDSTATICLIB=TRUE -NOCREATESTATICLIB=TRUE -SHL1STDLIBS=\ - -framework CoreServices - -SHL1DEPN= - -.ENDIF # "$(OS)"!="MACOSX" - -# --- Targets ---------------------------------- - -.INCLUDE : target.mk - diff -Naur sal/systools/macxp_extras/x11osx/osxlocale.cxx sal_new/systools/macxp_extras/x11osx/osxlocale.cxx --- sal/systools/macxp_extras/x11osx/osxlocale.cxx 2006-09-17 11:06:24.000000000 +0200 +++ sal_new/systools/macxp_extras/x11osx/osxlocale.cxx 1970-01-01 01:00:00.000000000 +0100 @@ -1,132 +0,0 @@ -/************************************************************************* - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: osxlocale.cxx,v $ - * - * $Revision: 1.4 $ - * - * last change: $Author: obo $ $Date: 2006/09/17 09:06:24 $ - * - * The Contents of this file are made available subject to - * the terms of GNU Lesser General Public License Version 2.1. - * - * - * GNU Lesser General Public License Version 2.1 - * ============================================= - * Copyright 2005 by Sun Microsystems, Inc. - * 901 San Antonio Road, Palo Alto, CA 94303, USA - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sal.hxx" - -#include -#include - -#include -#include -#include -#include - -namespace /* private */ -{ - template - class CFGuard - { - public: - explicit CFGuard(T& rT) : rT_(rT) {} - ~CFGuard() { if (rT_) CFRelease(rT_); } - private: - T& rT_; - }; - - typedef CFGuard CFArrayGuard; - typedef CFGuard CFStringGuard; - typedef CFGuard CFPropertyListGuard; - - /** Get the current process locale from system - */ - CFStringRef getProcessLocale() - { - CFPropertyListRef pref = CFPreferencesCopyAppValue(CFSTR("AppleLocale"), kCFPreferencesCurrentApplication); - CFPropertyListGuard proplGuard(pref); - - if (pref == NULL) // return fallback value 'en_US' - return CFStringCreateWithCString(kCFAllocatorDefault, "en_US", kCFStringEncodingASCII); - - CFStringRef sref = (CFGetTypeID(pref) == CFArrayGetTypeID()) ? (CFStringRef)CFArrayGetValueAtIndex((CFArrayRef)pref, 0) : (CFStringRef)pref; - - // NOTE: this API is only available with Mac OS X >=10.3. We need to use it because - // Apple used non-ISO values on systems <10.2 like "German" for instance but didn't - // upgrade those values during upgrade to newer Mac OS X versions. See also #i54337# - return CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorDefault, sref); - } -} // namespace private - -/** Grab current locale from system. -*/ -extern "C" int macosx_getLocale(char *locale, sal_uInt32 bufferLen) -{ - CFStringRef sref = getProcessLocale(); - CFStringGuard sGuard(sref); - - assert(sref != NULL && "osxlocale.cxx: getProcessLocale must return a non-NULL value"); - - // split the string into substrings; the first two (if there are two) substrings - // are language and country - CFArrayRef subs = CFStringCreateArrayBySeparatingStrings(NULL, sref, CFSTR("_")); - CFArrayGuard arrGuard(subs); - - CFStringRef lang = (CFStringRef)CFArrayGetValueAtIndex(subs, 0); - CFStringGetCString(lang, locale, bufferLen, kCFStringEncodingASCII); - - // country also available? Assumption: if the array contains more than one - // value the second value is always the country! - if (CFArrayGetCount(subs) > 1) - { - strlcat(locale, "_", bufferLen - strlen(locale)); - - CFStringRef country = (CFStringRef)CFArrayGetValueAtIndex(subs, 1); - CFStringGetCString(country, locale + strlen(locale), bufferLen - strlen(locale), kCFStringEncodingASCII); - } - // Append 'UTF-8' to the locale because the Mac OS X file - // system interface is UTF-8 based and sal tries to determine - // the file system locale from the locale information - strlcat(locale, ".UTF-8", bufferLen - strlen(locale)); - - return noErr; -} - - - -/* - * macxp_OSXConvertCFEncodingToIANACharSetName - * - * Convert a CoreFoundation text encoding to an IANA charset name. - */ -extern "C" int macxp_OSXConvertCFEncodingToIANACharSetName( char *buffer, unsigned int bufferLen, CFStringEncoding cfEncoding ) -{ - CFStringRef sCFEncodingName; - - sCFEncodingName = CFStringConvertEncodingToIANACharSetName( cfEncoding ); - CFStringGetCString( sCFEncodingName, buffer, bufferLen, cfEncoding ); - - return( noErr ); -} -