diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2017-06-25 17:21:45 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2017-07-02 13:28:20 +0200 |
commit | 7f1465a9599e9665159dd2d823a6e9064cca5703 (patch) | |
tree | 4d0db6763f43e76819bdd877141bef20cf3c260e /include/connectivity | |
parent | 3f4a92cbfda902ea462aec7f6b06062a20b3042c (diff) |
tdf#108789 and others: overhaul DBase files encoding handling
- Calc: make the complete "what encoding to use" decision before
calling the connectivity driver, so that the driver has
no ambiguity about whether it should override our setting
or not.
To this end, factorise the part of the driver that reads
the encoding from the file header into dbtools.
- Calc: don't ask for encoding when the file's header give the encoding.
- don't confuse CP850 (the default) and "don't know", including:
* don't ignore CP850 user setting
* don't overwrite user setting with CP850
Thanks to Julien Nabet for the extensive collaboration on this.
Change-Id: Id80b7c505858b88f717b0ce6bd890527909e5fd1
Diffstat (limited to 'include/connectivity')
-rw-r--r-- | include/connectivity/dbtools.hxx | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/include/connectivity/dbtools.hxx b/include/connectivity/dbtools.hxx index 7f4719bd41c8..4b493ee98267 100644 --- a/include/connectivity/dbtools.hxx +++ b/include/connectivity/dbtools.hxx @@ -27,6 +27,7 @@ #include <unotools/sharedunocomponent.hxx> #include <connectivity/dbtoolsdllapi.hxx> #include <connectivity/FValue.hxx> +#include <tools/stream.hxx> namespace com { namespace sun { namespace star { @@ -786,9 +787,51 @@ namespace dbtools OUStringBuffer& _out_rSQLPredicate ); - } // namespace dbtools +namespace connectivity::dbase +{ + enum DBFType { dBaseIII = 0x03, + dBaseIV = 0x04, + dBaseV = 0x05, + VisualFoxPro = 0x30, + VisualFoxProAuto = 0x31, // Visual FoxPro with AutoIncrement field + dBaseFS = 0x43, + dBaseFSMemo = 0xB3, + dBaseIIIMemo = 0x83, + dBaseIVMemo = 0x8B, + dBaseIVMemoSQL = 0x8E, + FoxProMemo = 0xF5 + }; + + /** decode a DBase file's codepage byte to a RTL charset + @param _out_nCharset + in case of success, the decoded RTL charset is written there. + else, this is not written to. + @param nType + the file's type byte + @param nCodepage + the file's codepage byte + @return + true if a RTL charset was successfully decoded and written to _out_nCharset + false if nothing was written to _out_nCharset + */ + OOO_DLLPUBLIC_DBTOOLS bool dbfDecodeCharset(rtl_TextEncoding &_out_nCharset, sal_uInt8 nType, sal_uInt8 nCodepage); + + /** decode a DBase file's codepage byte to a RTL charset + @param _out_nCharset + in case of success, the decoded RTL charset is written there. + else, this is not written to. + @param dbf_Stream + pointer to a SvStream encapsulating the DBase file. + The stream will be rewinded and read from. + No guarantee is made on its position afterwards. Caller must reposition it itself. + @return + true if a RTL charset was successfully decoded and written to _out_nCharset + false if nothing was written to _out_nCharset + */ + OOO_DLLPUBLIC_DBTOOLS bool dbfReadCharset(rtl_TextEncoding &nCharSet, SvStream* dbf_Stream); +} // namespace connectivity::dbase #endif // INCLUDED_CONNECTIVITY_DBTOOLS_HXX |