summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalte Timmermann <mt@openoffice.org>2001-08-03 12:52:39 +0000
committerMalte Timmermann <mt@openoffice.org>2001-08-03 12:52:39 +0000
commitfde3aeed122f3d0ecf559c4af1b6d23a97628459 (patch)
tree023d38e59269e97e386ff72607946d3320edd978
parent411b3e3ecbe09da50d96d5dff2a4675771137342 (diff)
#89855# I18nHelper
-rw-r--r--vcl/prj/d.lst1
-rw-r--r--vcl/source/app/i18nhelp.cxx197
-rw-r--r--vcl/source/app/makefile.mk8
-rw-r--r--vcl/source/app/settings.cxx65
4 files changed, 266 insertions, 5 deletions
diff --git a/vcl/prj/d.lst b/vcl/prj/d.lst
index 998615296544..b5dd765b76e5 100644
--- a/vcl/prj/d.lst
+++ b/vcl/prj/d.lst
@@ -182,6 +182,7 @@ hedabu: ..\inc\atom.hxx %_DEST%\inc%_EXT%\vcl\atom.hxx
hedabu: ..\inc\threadex.hxx %_DEST%\inc%_EXT%\vcl\threadex.hxx
hedabu: ..\inc\evntpost.hxx %_DEST%\inc%_EXT%\vcl\evntpost.hxx
hedabu: ..\inc\unohelp.hxx %_DEST%\inc%_EXT%\vcl\unohelp.hxx
+hedabu: ..\inc\i18nhelp.hxx %_DEST%\inc%_EXT%\vcl\i18nhelp.hxx
hedabu: ..\inc\dndhelp.hxx %_DEST%\inc%_EXT%\vcl\dndhelp.hxx
hedabu: ..\unx\inc\salconfig.hxx %_DEST%\inc%_EXT%\vcl\unx\salconfig.hxx
diff --git a/vcl/source/app/i18nhelp.cxx b/vcl/source/app/i18nhelp.cxx
new file mode 100644
index 000000000000..00aca05f7a6d
--- /dev/null
+++ b/vcl/source/app/i18nhelp.cxx
@@ -0,0 +1,197 @@
+/*************************************************************************
+ *
+ * $RCSfile: i18nhelp.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mt $ $Date: 2001-08-03 13:46:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+
+#include <i18nhelp.hxx>
+
+/*
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+
+
+#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
+#include <comphelper/processfactory.hxx>
+#endif
+*/
+
+// #include <cppuhelper/servicefactory.hxx>
+
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_I18N_TRANSLITERATIONMODULES_HPP_
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#endif
+
+#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
+#include <unotools/localedatawrapper.hxx>
+#endif
+
+#ifndef _UNOTOOLS_TRANSLITERATIONWRAPPER_HXX
+#include <unotools/transliterationwrapper.hxx>
+#endif
+
+#ifndef _ISOLANG_HXX
+#include <tools/isolang.hxx>
+#endif
+
+using namespace ::com::sun::star;
+
+vcl::I18nHelper::I18nHelper( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMSF, const ::com::sun::star::lang::Locale& rLocale )
+{
+ mxMSF = rxMSF;
+ maLocale = rLocale;
+ mpLocaleDataWrapper = NULL;
+ mpTransliterationWrapper= NULL;
+ mbTransliterateIgnoreCase = sal_False;
+}
+
+vcl::I18nHelper::~I18nHelper()
+{
+}
+
+void vcl::I18nHelper::ImplDestroyWrappers()
+{
+ delete mpLocaleDataWrapper;
+ mpLocaleDataWrapper = NULL;
+
+ delete mpTransliterationWrapper;
+ mpTransliterationWrapper= NULL;
+}
+
+utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() const
+{
+ if ( !mpTransliterationWrapper )
+ {
+ sal_Int32 nModules = i18n::TransliterationModules_IGNORE_WIDTH;
+ if ( mbTransliterateIgnoreCase )
+ nModules |= i18n::TransliterationModules_IGNORE_CASE;
+ ((vcl::I18nHelper*)this)->mpTransliterationWrapper = new utl::TransliterationWrapper( mxMSF, (i18n::TransliterationModules)nModules );
+ ((vcl::I18nHelper*)this)->mpTransliterationWrapper->loadModuleIfNeeded( ConvertIsoNamesToLanguage( maLocale.Language, maLocale.Country ) );
+ }
+ return *mpTransliterationWrapper;
+}
+
+void vcl::I18nHelper::setLocale( const ::com::sun::star::lang::Locale& rLocale )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( ((vcl::I18nHelper*)this)->maMutex );
+
+// if ( maLocale != rLocale )
+ {
+ maLocale = rLocale;
+ ImplDestroyWrappers();
+ }
+}
+
+const ::com::sun::star::lang::Locale& vcl::I18nHelper::getLocale() const
+{
+ return maLocale;
+}
+
+sal_Bool vcl::I18nHelper::equals( const String& rStr1, sal_Int32 nPos1, sal_Int32 nCount1, const String& rStr2, sal_Int32 nPos2, sal_Int32 nCount2, sal_Bool bIgnoreCase ) const
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( ((vcl::I18nHelper*)this)->maMutex );
+
+ // !!! TRANSLITERATION DOESN'T WORK !!!
+ /*
+ if ( bIgnoreCase != mbTransliterateIgnoreCase )
+ {
+ // Change mbTransliterateIgnoreCase and destroy the warpper, next call to
+ // ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase
+ ((vcl::I18nHelper*)this)->mbTransliterateIgnoreCase = bIgnoreCase;
+ delete ((vcl::I18nHelper*)this)->mpTransliterationWrapper;
+ ((vcl::I18nHelper*)this)->mpTransliterationWrapper = NULL;
+ }
+
+ if ( nCount1 > ( rStr1.Len() - nPos1 ) )
+ nCount1 = rStr1.Len() - nPos1;
+ if ( nCount2 > ( rStr2.Len() - nPos2 ) )
+ nCount2 = rStr2.Len() - nPos2;
+
+
+ sal_Int32 nMatch1, nMatch2;
+ return ImplGetTransliterationWrapper().equals( rStr1, nPos1, nCount1, nMatch1, rStr2, nPos2, nCount2, nMatch2 );
+ */
+
+ BOOL bEqual;
+ if ( bIgnoreCase )
+ {
+ bEqual = String( rStr1, nPos1, nCount1 ).EqualsIgnoreCaseAscii( rStr2, nPos2, nCount2 );
+ }
+ else
+ {
+ bEqual = String( rStr1, nPos1, nCount1 ).Equals( rStr2, nPos2, nCount2 );
+ }
+ return bEqual;
+}
+
+
+String vcl::I18nHelper::getDate( const Date& rDate, sal_Bool bLongFormat ) const
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( ((vcl::I18nHelper*)this)->maMutex );
+
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ return String();
+}
diff --git a/vcl/source/app/makefile.mk b/vcl/source/app/makefile.mk
index 0919d16ba78c..8ad80a6e6f5f 100644
--- a/vcl/source/app/makefile.mk
+++ b/vcl/source/app/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.6 $
+# $Revision: 1.7 $
#
-# last change: $Author: pl $ $Date: 2001-06-28 13:33:35 $
+# last change: $Author: mt $ $Date: 2001-08-03 13:47:44 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -92,7 +92,8 @@ SLOFILES= $(SLO)$/access.obj \
$(SLO)$/system.obj \
$(SLO)$/timer.obj \
$(SLO)$/dndhelp.obj \
- $(SLO)$/unohelp.obj
+ $(SLO)$/unohelp.obj \
+ $(SLO)$/i18nhelp.obj
.IF "$(remote)"!=""
EXCEPTIONSFILES= \
@@ -113,6 +114,7 @@ EXCEPTIONSFILES= \
$(SLO)$/svapp.obj \
$(SLO)$/dndhelp.obj \
$(SLO)$/unohelp.obj \
+ $(SLO)$/i18nhelp.obj \
$(SLO)$/svmain.obj
.ENDIF
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index d0091b190152..8a6cafaad2a8 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: settings.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: th $ $Date: 2001-07-10 07:43:31 $
+ * last change: $Author: mt $ $Date: 2001-08-03 13:52:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -78,6 +78,10 @@
#include <settings.hxx>
#endif
+#ifndef _VCL_I18NHELP_HXX
+#include <i18nhelp.hxx>
+#endif
+
#include <unohelp.hxx>
#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
#include <unotools/localedatawrapper.hxx>
@@ -1436,6 +1440,8 @@ ImplAllSettingsData::ImplAllSettingsData()
mpUILocaleDataWrapper = NULL;
mpCollatorWrapper = NULL;
mpUICollatorWrapper = NULL;
+ mpI18nHelper = NULL;
+ mpUII18nHelper = NULL;
}
// -----------------------------------------------------------------------
@@ -1465,6 +1471,8 @@ ImplAllSettingsData::ImplAllSettingsData( const ImplAllSettingsData& rData ) :
mpUILocaleDataWrapper = NULL;
mpCollatorWrapper = NULL;
mpUICollatorWrapper = NULL;
+ mpI18nHelper = NULL;
+ mpUII18nHelper = NULL;
}
// -----------------------------------------------------------------------
@@ -1479,6 +1487,10 @@ ImplAllSettingsData::~ImplAllSettingsData()
delete mpCollatorWrapper;
if ( mpUICollatorWrapper )
delete mpUICollatorWrapper;
+ if ( mpI18nHelper )
+ delete mpI18nHelper;
+ if ( mpI18nHelper )
+ delete mpUII18nHelper;
}
// -----------------------------------------------------------------------
@@ -1662,6 +1674,16 @@ ULONG AllSettings::Update( ULONG nFlags, const AllSettings& rSet )
delete mpData->mpUILocaleDataWrapper;
mpData->mpUILocaleDataWrapper = NULL;
}
+ if ( mpData->mpI18nHelper )
+ {
+ delete mpData->mpI18nHelper;
+ mpData->mpI18nHelper = NULL;
+ }
+ if ( mpData->mpUII18nHelper )
+ {
+ delete mpData->mpUII18nHelper;
+ mpData->mpUII18nHelper = NULL;
+ }
}
}
@@ -1783,6 +1805,11 @@ void AllSettings::SetLocale( const ::com::sun::star::lang::Locale& rLocale )
delete mpData->mpLocaleDataWrapper;
mpData->mpLocaleDataWrapper = NULL;
}
+ if ( mpData->mpI18nHelper )
+ {
+ delete mpData->mpI18nHelper;
+ mpData->mpI18nHelper = NULL;
+ }
}
// -----------------------------------------------------------------------
@@ -1803,6 +1830,11 @@ void AllSettings::SetUILocale( const ::com::sun::star::lang::Locale& rLocale )
delete mpData->mpUILocaleDataWrapper;
mpData->mpUILocaleDataWrapper = NULL;
}
+ if ( mpData->mpUII18nHelper )
+ {
+ delete mpData->mpUII18nHelper;
+ mpData->mpUII18nHelper = NULL;
+ }
}
// -----------------------------------------------------------------------
@@ -1821,6 +1853,11 @@ void AllSettings::SetLanguage( LanguageType eLang )
delete mpData->mpLocaleDataWrapper;
mpData->mpLocaleDataWrapper = NULL;
}
+ if ( mpData->mpI18nHelper )
+ {
+ delete mpData->mpI18nHelper;
+ mpData->mpI18nHelper = NULL;
+ }
}
// -----------------------------------------------------------------------
@@ -1839,6 +1876,11 @@ void AllSettings::SetUILanguage( LanguageType eLang )
delete mpData->mpUILocaleDataWrapper;
mpData->mpUILocaleDataWrapper = NULL;
}
+ if ( mpData->mpUII18nHelper )
+ {
+ delete mpData->mpUII18nHelper;
+ mpData->mpUII18nHelper = NULL;
+ }
}
// -----------------------------------------------------------------------
@@ -1912,6 +1954,25 @@ const LocaleDataWrapper& AllSettings::GetUILocaleDataWrapper() const
}
// -----------------------------------------------------------------------
+
+const vcl::I18nHelper& AllSettings::GetLocaleI18nHelper() const
+{
+ if ( !mpData->mpI18nHelper )
+ ((AllSettings*)this)->mpData->mpI18nHelper = new vcl::I18nHelper( vcl::unohelper::GetMultiServiceFactory(), GetLocale() );
+ return *mpData->mpI18nHelper;
+}
+
+// -----------------------------------------------------------------------
+
+const vcl::I18nHelper& AllSettings::GetUILocaleI18nHelper() const
+{
+ if ( !mpData->mpUII18nHelper )
+ ((AllSettings*)this)->mpData->mpUII18nHelper = new vcl::I18nHelper( vcl::unohelper::GetMultiServiceFactory(), GetUILocale() );
+ return *mpData->mpUII18nHelper;
+}
+
+
+// -----------------------------------------------------------------------
/*
const CollatorWrapper& AllSettings::GetCollatorWrapper() const
{