[Libreoffice-commits] core.git: wizards/source
Jean-Pierre Ledure
jp at ledure.be
Sun Dec 13 02:33:50 PST 2015
wizards/source/access2base/Database.xba | 29 +++++++++++++++++++----------
wizards/source/access2base/DoCmd.xba | 2 +-
2 files changed, 20 insertions(+), 11 deletions(-)
New commits:
commit 9d3adaaac8839b71f3960ebebbf5fa193f906219
Author: Jean-Pierre Ledure <jp at ledure.be>
Date: Sun Dec 13 11:29:49 2015 +0100
Access2Base - OutputTo action - support encoding in csv files
Change-Id: Icc4a631d67c3d4acf67de1cb38018c37602a16eb
diff --git a/wizards/source/access2base/Database.xba b/wizards/source/access2base/Database.xba
index 81a233e..05e7335 100644
--- a/wizards/source/access2base/Database.xba
+++ b/wizards/source/access2base/Database.xba
@@ -621,7 +621,7 @@ Const cstThisSub = "Database.OutputTo"
If IsMissing(pvTemplateFile) Then pvTemplateFile = ""
If Not Utils._CheckArgument(pvTemplateFile, 6, vbString) Then Goto Exit_Function
If IsMissing(pvEncoding) Then pvEncoding = 0
- If Not Utils._CheckArgument(pvEncoding, 7, _AddNumeric(), Array(0, acUTF8Encoding)) Then Goto Exit_Function
+ If Not Utils._CheckArgument(pvEncoding, 7, _AddNumeric()) Then Goto Exit_Function
If IsMissing(pvQuality) Then pvQuality = acExportQualityPrint
If Not Utils._CheckArgument(pvQuality, 7, _AddNumeric(), Array(acExportQualityPrint, acExportQualityScreen)) Then Goto Exit_Function
@@ -674,7 +674,7 @@ Dim sOutputFormat As String, iTemplate As Integer, iOutputFile As Integer, bOutp
Case UCase(acFormatXLS), "XLSX"
bOutput = _OutputToCalc(oTable, sOutputFile, acFormatXLSX)
Case UCase(acFormatTXT), "TXT", "CSV"
- bOutput = _OutputToCalc(oTable, sOutputFile, acFormatTXT)
+ bOutput = _OutputToCalc(oTable, sOutputFile, acFormatTXT, pvEncoding)
End Select
oTable.Dispose()
@@ -1010,7 +1010,7 @@ Error_Function:
End Function ' DFunction V1.1.0
REM -----------------------------------------------------------------------------------------------------------------------
-Private Function _FilterOptionsDefault() As String
+Private Function _FilterOptionsDefault(ByVal plEncoding As Long) As String
' Return the default FilterOptions string for table/query export to csv
Dim sFieldSeparator as string
@@ -1020,7 +1020,7 @@ Const cstTextDelimitor = """"
If _DecimalPoint() = "," Then sFieldSeparator = ";" Else sFieldSeparator = cstComma
_FilteroptionsDefault = Trim(Str(Asc(sFieldSeparator))) _
& cstComma & Trim(Str(Asc(cstTextDelimitor))) _
- & cstComma & Trim(Str(acUTF8Encoding)) _
+ & cstComma & Trim(Str(plEncoding)) _
& cstComma & "1"
End Function ' _FilterOptionsDefault V1.4.0
@@ -1296,7 +1296,11 @@ Dim i As Integer, l As Long
End Function ' _OutputStringToHTML V1.4.0
REM -----------------------------------------------------------------------------------------------------------------------
-Private Function _OutputToCalc(poData As Object, ByVal psOutputFile As String, psFilter As String) As Boolean
+Private Function _OutputToCalc(poData As Object _
+ , ByVal psOutputFile As String _
+ , ByVal psFilter As String _
+ , Optional ByVal plEncoding As Long _
+ ) As Boolean
' https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Database_Import
' https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options
@@ -1306,6 +1310,7 @@ Dim oRange As Object, i As Integer, iCol As Integer, oColumns As Object
If _ErrorHandler() Then On Local Error Goto Error_Function
_OutputToCalc = False
+ If IsMissing(plEncoding) Then plEncoding = acUTF8Encoding
' Create a new OO-Calc-Document
Set oCalcDoc = StarDesktop.LoadComponentFromURL( _
"private:factory/scalc" _
@@ -1344,14 +1349,18 @@ Dim oRange As Object, i As Integer, iCol As Integer, oColumns As Object
For i = 0 To iCol - 1
oColumns.getByIndex(i).OptimalWidth = True
Next i
+ oCalcDoc.storeAsUrl(psOutputFile, Array( _
+ _MakePropertyValue("FilterName", psFilter) _
+ , _MakePropertyValue("Overwrite", True) _
+ ))
Case Else
+ oCalcDoc.storeAsUrl(psOutputFile, Array( _
+ _MakePropertyValue("FilterName", psFilter) _
+ , _MakePropertyValue("FilterOptions", _FilterOptionsDefault(plEncoding)) _
+ , _MakePropertyValue("Overwrite", True) _
+ ))
End Select
- oCalcDoc.storeAsUrl(psOutputFile, Array( _
- _MakePropertyValue("FilterName", psFilter) _
- , _MakePropertyValue("FilterOptions", _FilterOptionsDefault()) _
- , _MakePropertyValue("Overwrite", True) _
- ))
oCalcDoc.close(False)
_OutputToCalc = True
diff --git a/wizards/source/access2base/DoCmd.xba b/wizards/source/access2base/DoCmd.xba
index ff3d5ae..1b6e481 100644
--- a/wizards/source/access2base/DoCmd.xba
+++ b/wizards/source/access2base/DoCmd.xba
@@ -1243,7 +1243,7 @@ Const cstThisSub = "OutputTo"
If IsMissing(pvTemplateFile) Then pvTemplateFile = ""
If Not Utils._CheckArgument(pvTemplateFile, 6, vbString) Then Goto Exit_Function
If IsMissing(pvEncoding) Then pvEncoding = 0
- If Not Utils._CheckArgument(pvEncoding, 7, _AddNumeric(), Array(0, acUTF8Encoding)) Then Goto Exit_Function
+ If Not Utils._CheckArgument(pvEncoding, 7, _AddNumeric()) Then Goto Exit_Function
If IsMissing(pvQuality) Then pvQuality = acExportQualityPrint
If Not Utils._CheckArgument(pvQuality, 7, _AddNumeric(), Array(acExportQualityPrint, acExportQualityScreen)) Then Goto Exit_Function
More information about the Libreoffice-commits
mailing list