[Libreoffice-commits] .: 2 commits - connectivity/source officecfg/registry sc/source
Muthu Subramanian
sumuthu at kemper.freedesktop.org
Fri Dec 16 06:45:19 PST 2011
connectivity/source/drivers/dbase/DTable.cxx | 11 ++
officecfg/registry/schema/org/openoffice/Office/Calc.xcs | 26 ++++++
sc/source/ui/docshell/docsh8.cxx | 4 +
sc/source/ui/unoobj/filtuno.cxx | 60 ++++++++++++++-
4 files changed, 99 insertions(+), 2 deletions(-)
New commits:
commit fc0bbb4fec98e7133541938306518c4fc9233e29
Author: Muthu Subramanian <sumuthu at suse.com>
Date: Fri Dec 16 20:43:54 2011 +0530
fdo#33602: Preserving dbf import/export charset.
diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index efe840c..79ebc2e 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1029,6 +1029,32 @@
<info>
<desc>Contains the dialogs settings.</desc>
</info>
+ <group oor:name="DBFImport">
+ <info>
+ <desc>Contains settings for DBF Import dialog</desc>
+ </info>
+ <prop oor:name="CharSet" oor:type="xs:int">
+ <info>
+ <author>muthusuba</author>
+ <desc>Charset/Language</desc>
+ <label>CharSet</label>
+ </info>
+ <value>-1</value>
+ </prop>
+ </group>
+ <group oor:name="DBFExport">
+ <info>
+ <desc>Contains settings for DBF Export dialog</desc>
+ </info>
+ <prop oor:name="CharSet" oor:type="xs:int">
+ <info>
+ <author>muthusuba</author>
+ <desc>Charset/Language</desc>
+ <label>CharSet</label>
+ </info>
+ <value>-1</value>
+ </prop>
+ </group>
<group oor:name="CSVImport">
<info>
<desc>Contains setting for Text CSV Import</desc>
diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
index 8d16f38..6c1a651 100644
--- a/sc/source/ui/unoobj/filtuno.cxx
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -51,8 +51,15 @@
#include <memory>
+#include <optutil.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+
using namespace ::com::sun::star;
using ::rtl::OUStringBuffer;
+using namespace rtl;
+using namespace com::sun::star::uno;
//------------------------------------------------------------------------
@@ -66,6 +73,55 @@ SC_SIMPLE_SERVICE_INFO( ScFilterOptionsObj, SCFILTEROPTIONSOBJ_IMPLNAME, SCFILTE
#define SC_UNONAME_FILTEROPTIONS "FilterOptions"
#define SC_UNONAME_INPUTSTREAM "InputStream"
+
+#define DBF_CHAR_SET "CharSet"
+#define DBF_SEP_PATH_IMPORT "Office.Calc/Dialogs/DBFImport"
+#define DBF_SEP_PATH_EXPORT "Office.Calc/Dialogs/DBFExport"
+
+//------------------------------------------------------------------------
+
+static void load_CharSet( rtl_TextEncoding &nCharSet, bool bExport )
+{
+ sal_Int32 nChar;
+ Sequence<Any> aValues;
+ const Any *pProperties;
+ Sequence<OUString> aNames(1);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii(
+ bExport?DBF_SEP_PATH_EXPORT:DBF_SEP_PATH_IMPORT ) );
+
+ pNames[0] = OUString::createFromAscii( DBF_CHAR_SET );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getConstArray();
+
+ // Default choice
+ nCharSet = RTL_TEXTENCODING_IBM_850;
+
+ if( pProperties[0].hasValue() )
+ {
+ pProperties[0] >>= nChar;
+ if( nChar >= 0)
+ nCharSet = (rtl_TextEncoding) nChar;
+ }
+}
+
+static void save_CharSet( rtl_TextEncoding nCharSet, bool bExport )
+{
+ Sequence<Any> aValues;
+ Any *pProperties;
+ Sequence<OUString> aNames(1);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii(
+ bExport?DBF_SEP_PATH_EXPORT:DBF_SEP_PATH_IMPORT ) );
+
+ pNames[0] = OUString::createFromAscii( DBF_CHAR_SET );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getArray();
+ pProperties[0] <<= (sal_Int32) nCharSet;
+
+ aItem.PutProperties(aNames, aValues);
+}
+
//------------------------------------------------------------------------
ScFilterOptionsObj::ScFilterOptionsObj() :
@@ -250,8 +306,7 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException)
// dBase import
aTitle = ScGlobal::GetRscString( STR_IMPORT_DBF );
}
- // common for dBase import/export
- eEncoding = RTL_TEXTENCODING_IBM_850;
+ load_CharSet( eEncoding, bExport );
bDBEnc = sal_True;
}
else if ( aFilterString == ScDocShell::GetDifFilterName() )
@@ -279,6 +334,7 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException)
if ( pDlg->Execute() == RET_OK )
{
pDlg->GetImportOptions( aOptions );
+ save_CharSet( aOptions.eCharSet, bExport );
if ( bAscii )
aFilterOptions = aOptions.BuildString();
else
commit b00c4ec0967f8712d721b31ccb2dd0778c9e973b
Author: Muthu Subramanian <sumuthu at suse.com>
Date: Fri Dec 16 20:41:02 2011 +0530
Adding more dbf file types.
Uses info from comments in i18728.
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 7200ac2..5e5b9e2 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -268,6 +268,14 @@ void ODbaseTable::readHeader()
//case 0x69: m_eEncoding = ; break; // Mazovia (Polish) MS-DOS
case 0x6A: m_eEncoding = RTL_TEXTENCODING_IBM_737; break; // Greek MS-DOS (437G)
case 0x6B: m_eEncoding = RTL_TEXTENCODING_IBM_857; break; // Turkish MS-DOS
+ case 0x6C: m_eEncoding = RTL_TEXTENCODING_IBM_863; break; // MS-DOS, Canada
+ case 0x78: m_eEncoding = RTL_TEXTENCODING_MS_950; break; // Windows, Traditional Chinese
+ case 0x79: m_eEncoding = RTL_TEXTENCODING_MS_949; break; // Windows, Korean (Hangul)
+ case 0x7A: m_eEncoding = RTL_TEXTENCODING_MS_936; break; // Windows, Simplified Chinese
+ case 0x7B: m_eEncoding = RTL_TEXTENCODING_MS_932; break; // Windows, Japanese (Shift-jis)
+ case 0x7C: m_eEncoding = RTL_TEXTENCODING_MS_874; break; // Windows, Thai
+ case 0x7D: m_eEncoding = RTL_TEXTENCODING_MS_1255; break; // Windows, Hebrew
+ case 0x7E: m_eEncoding = RTL_TEXTENCODING_MS_1256; break; // Windows, Arabic
case 0x96: m_eEncoding = RTL_TEXTENCODING_APPLE_CYRILLIC; break; // Russian Macintosh
case 0x97: m_eEncoding = RTL_TEXTENCODING_APPLE_CENTEURO; break; // Eastern European Macintosh
case 0x98: m_eEncoding = RTL_TEXTENCODING_APPLE_GREEK; break; // Greek Macintosh
@@ -275,7 +283,10 @@ void ODbaseTable::readHeader()
case 0xC9: m_eEncoding = RTL_TEXTENCODING_MS_1251; break; // Russian Windows
case 0xCA: m_eEncoding = RTL_TEXTENCODING_MS_1254; break; // Turkish Windows
case 0xCB: m_eEncoding = RTL_TEXTENCODING_MS_1253; break; // Greek Windows
+ case 0xCC: m_eEncoding = RTL_TEXTENCODING_MS_1257; break; // Windows, Baltic
default:
+ // Default Encoding
+ m_eEncoding = RTL_TEXTENCODING_IBM_850;
break;
}
}
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 5529579..207f0f0 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -309,6 +309,10 @@ sal_uLong ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet
long i;
long nColCount = 0;
+ // Try to get the Text Encoding from the driver
+ if( eCharSet == RTL_TEXTENCODING_IBM_850 )
+ eCharSet = RTL_TEXTENCODING_DONTKNOW;
+
try
{
String aTabName;
More information about the Libreoffice-commits
mailing list