Kaydet (Commit) 7ac4c9dc authored tarafından Lionel Elie Mamane's avatar Lionel Elie Mamane

DB wizards (java): use system locale, not UI language, for parsing matters

Change-Id: Ieb00ef3b16cd6213c11298040b789444b3ee3a31
üst cd2f2e77
......@@ -200,26 +200,30 @@ public abstract class Configuration
}
}
public static String getOfficeLocaleString(XMultiServiceFactory xMSF)
public static String getLocaleString(XMultiServiceFactory xMSF, String root, String key)
{
String sLocale = PropertyNames.EMPTY_STRING;
try
{
Locale aLocLocale = new Locale();
Object oMasterKey = getConfigurationRoot(xMSF, "org.openoffice.Setup/L10N/", false);
sLocale = (String) Helper.getUnoObjectbyName(oMasterKey, "ooLocale");
Object oMasterKey = getConfigurationRoot(xMSF, root, false);
sLocale = (String) Helper.getUnoObjectbyName(oMasterKey, key);
}
catch (Exception exception)
{
exception.printStackTrace(System.err);
}
if (sLocale.length() == 0 && (!key.equals("Locale") || !root.equals("org.openoffice.System/L10N/")))
{
return getLocaleString(xMSF, "org.openoffice.System/L10N/", "Locale");
}
return sLocale;
}
public static Locale getOfficeLocale(XMultiServiceFactory xMSF)
public static Locale getLocale(XMultiServiceFactory xMSF, String root, String key)
{
Locale aLocLocale = new Locale();
String sLocale = getOfficeLocaleString(xMSF);
String sLocale = getLocaleString(xMSF, root, key);
String[] sLocaleList = JavaTools.ArrayoutofString(sLocale, "-");
aLocLocale.Language = sLocaleList[0];
if (sLocaleList.length > 1)
......@@ -229,18 +233,24 @@ public abstract class Configuration
return aLocLocale;
}
public static String getOfficeLinguistic(XMultiServiceFactory xMSF)
public static Locale getLocale(XMultiServiceFactory xMSF)
{
try
{
Object oMasterKey = getConfigurationRoot(xMSF, "org.openoffice.Setup/L10N/", false);
return (String) Helper.getUnoObjectbyName(oMasterKey, "ooLocale");
}
catch (Exception exception)
{
exception.printStackTrace();
return null;
}
return getLocale(xMSF, "org.openoffice.Setup/L10N/", "ooSetupSystemLocale");
}
public static Locale getUILocale(XMultiServiceFactory xMSF)
{
return getLocale(xMSF, "org.openoffice.Setup/L10N/", "ooLocale");
}
public static String getLocaleString(XMultiServiceFactory xMSF)
{
return getLocaleString(xMSF, "org.openoffice.Setup/L10N/", "ooSetupSystemLocale");
}
public static String getUILocaleString(XMultiServiceFactory xMSF)
{
return getLocaleString(xMSF, "org.openoffice.Setup/L10N/", "ooLocale");
}
/**
......
......@@ -169,7 +169,7 @@ public class DBMetaData
{
XNumberFormatsSupplier xNumberFormatsSupplier = (XNumberFormatsSupplier) AnyConverter.toObject(XNumberFormatsSupplier.class, xDataSourcePropertySet.getPropertyValue("NumberFormatsSupplier"));
//TODO get the locale from the datasource
aLocale = Configuration.getOfficeLocale(xMSF);
aLocale = Configuration.getLocale(xMSF);
oNumberFormatter = new NumberFormatter(xMSF, xNumberFormatsSupplier, aLocale);
lDateCorrection = oNumberFormatter.getNullDateCorrection();
}
......@@ -529,7 +529,7 @@ public class DBMetaData
}
if (this.isSQL92CheckEnabled())
{
return Desktop.removeSpecialCharacters(xMSF, Configuration.getOfficeLocale(xMSF), _sname);
return Desktop.removeSpecialCharacters(xMSF, Configuration.getLocale(xMSF), _sname);
}
return _sname;
}
......
......@@ -74,7 +74,7 @@ public class CGTable
}
for (int i = 0; i < fieldnames.length; i++)
{
fieldnames[i] = Desktop.removeSpecialCharacters(xMSF, Configuration.getOfficeLocale(xMSF), fieldnames[i]);
fieldnames[i] = Desktop.removeSpecialCharacters(xMSF, Configuration.getLocale(xMSF), fieldnames[i]);
}
return fieldnames;
}
......
......@@ -70,7 +70,7 @@ public class ScenarioSelector extends FieldSelection implements XItemListener, X
super(_CurUnoDialog, TableWizard.SOMAINPAGE, 91, 108, 230, 80, _reslblFields, _reslblSelFields, 41209, true);
CurTableWizardUnoDialog = _CurUnoDialog;
xMSF = CurUnoDialog.xMSF;
aLocale = Configuration.getOfficeLocale(xMSF);
aLocale = Configuration.getLocale(xMSF);
curtabledescriptor = _curtabledescriptor;
imaxcolumnchars = this.curtabledescriptor.getMaxColumnNameLength();
bcolumnnameislimited = (imaxcolumnchars > 0) && (imaxcolumnchars < 16);
......
......@@ -283,7 +283,7 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener
scomposedtablename = curFinalizer.getComposedTableName(tablename);
if (this.curTableDescriptor.isSQL92CheckEnabled())
{
Desktop.removeSpecialCharacters(curTableDescriptor.xMSF, Configuration.getOfficeLocale(this.curTableDescriptor.xMSF), tablename);
Desktop.removeSpecialCharacters(curTableDescriptor.xMSF, Configuration.getLocale(this.curTableDescriptor.xMSF), tablename);
}
if ( tablename.length() > 0 )
{
......@@ -422,7 +422,7 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener
{
Object otextcomponent = UnoDialog.getModel(aTextEvent.Source);
String sName = (String) Helper.getUnoPropertyValue(otextcomponent, "Text");
sName = Desktop.removeSpecialCharacters(curTableDescriptor.xMSF, Configuration.getOfficeLocale(curTableDescriptor.xMSF), sName);
sName = Desktop.removeSpecialCharacters(curTableDescriptor.xMSF, Configuration.getLocale(curTableDescriptor.xMSF), sName);
Helper.setUnoPropertyValue(otextcomponent, "Text", sName);
}
}
......
......@@ -326,7 +326,7 @@ public class CommandFieldSelection extends FieldSelection implements Comparator<
{
if (this.aCollator == null)
{
com.sun.star.lang.Locale aOfficeLocale = Configuration.getOfficeLocale(this.CurDBMetaData.xMSF);
com.sun.star.lang.Locale aOfficeLocale = Configuration.getLocale(this.CurDBMetaData.xMSF);
java.util.Locale aJavaLocale = new java.util.Locale(aOfficeLocale.Language, aOfficeLocale.Country, aOfficeLocale.Variant);
//Get the Collator for US English and set its strength to PRIMARY
this.aCollator = Collator.getInstance(aJavaLocale);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment