1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: c_import_general.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 08:05:50 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/************************************************************************
34 '** owner : oliver.craemer@sun.com
36 '** short description : Imports every Document from a given path (gsSourcePath variable)
38 '*************************************************************************
40 ' #1 tLoadAllDocuments (gsSourcePath as string )
41 ' #1 tLoadSpreadsheetDocument
44 '\*******************************************************************
46 sub tLoadAllDocuments ( gsSourcePath as string )
50 printlog "Source path: " & gsSourcePath
51 'Get the files into a list.
52 Call GetAllFileList(gsSourcePath, "*.*" , gsSourceDocument())
53 x = ListCount(gsSourceDocument())
54 printlog "- " + x + " steps will be done"
56 printlog "(" & i & "/" & x & "): " & gsSourceDocument(i)
57 Call tLoadSpreadsheetDocument(gsSourceDocument(i))
62 '-------------------------------------------------------------------------------
64 testcase tLoadSpreadsheetDocument (SourceFile)
65 Dim sOnlyFileName as string
66 Dim sOnlyFileExtension as string
67 Dim sTempFileName as String
70 sTempFileName = SourceFile
71 sOnlyFileName = DateiOhneExt(DateiExtract(SourceFile)
72 sOnlyFileExtension = GetExtention(sTempFileName)
73 select case sOnlyFileName
74 case "so3tmpl", "so4tmpl", "so5tmpl" :
75 printlog "Test case: " & sOnlyFileName & "." & sOnlyFileExtension
77 case else printlog "Test case: " & sOnlyFileName & "." & sOnlyFileExtension
79 'Maybe file name is empty
80 if sOnlyFileName > "" then
81 'Some extensions make no sense to load
82 if sOnlyFileExtension <> "so" AND sOnlyFileExtension <> "tmp" AND sOnlyFileExtension <> "dbt" then
83 if fCalcFileOpen(SourceFile) AND IsItLoaded()then
84 if (hIsNamedDocLoaded (SourceFile)) then
89 warnlog sOnlyFileName + " document has not been loaded correctly [hIsNamedDocLoaded]!"
90 if GetDocumentCount > 1 then
91 Do Until GetDocumentCount = 1
97 warnlog sOnlyFileName + " document has not been loaded correctly [fCalcFileOpen; IsItLoaded]!"
98 if GetDocumentCount > 1 then
99 Do Until GetDocumentCount = 1
105 printlog "(" + sOnlyFileName + "." + sOnlyFileExtension + ") won't be loaded because of excluded extensions .so and .tmp."
106 if GetDocumentCount > 1 then
107 Do Until GetDocumentCount = 1
115 '-------------------------------------------------------------------------------
117 function fCalcFileOpen (sDocName as string, optional bLinked as boolean) as boolean
118 Dim sSourceFile as String
119 'Loads the spreadsheet documents like hLoadDocument but with special handling of
120 'spreadsheet import filter dialogs, like ASCII, Lotus, dBase, CSV, ...
121 sSourceFile = ConvertPath ( sDocName )
124 if hFileExists (sSourceFile) = FALSE then
125 warnlog "fCalcFileOpen: '" + sSourceFile + "' does not exists!"
126 fCalcFileOpen = FALSE
132 Dateiname.SetText(sSourceFile)
137 'If .txt ASCII-filter dialog will come up.
138 Kontext "AsciiFilterOptionen"
139 if AsciiFilterOptionen.Exists(1) then
140 printlog "- ASCII filter dialog is up!"
141 AsciiFilterOptionen.Ok
144 'If Lotus 1-2-3 or dBase files will be opend the import characters
147 if ExportCalc.Exists(1) then
148 printlog "- Import character set selection dialog is up!"
152 'Importing detected (e.g. extension .csv) CSV files will bring
153 ' up the Text import dialog
155 if TextImport.Exists(1) then
156 printlog "- Text import dialog is up!"
161 if Active.Exists(3) then
162 if IsMissing(bLinked) then
163 warnlog "fCalcFileOpen: " + Active.GetText
165 printlog "fCalcFileOpen: " + Active.GetText
170 if IsMissing(bLinked) then
171 'e.g. Links won't be updated
174 'e.g. Links will be updated
179 if OeffnenDlg.Exists(1) then
181 fCalcFileOpen = FALSE
182 Warnlog "fCalcFileOpen: The File-Open-Dialog is open!"