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: docbook_001.inc,v $
13 '* last change: $Author: rt $ $Date: 2008-07-11 07:30:56 $
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 : helge.delfs@sun.com
36 '* short description : Library for DocBook XML Im-/Export Test
38 '\***********************************************************************
40 sub tDocBookXMLtestdocs
41 Dim sSourceDocuments(500) as string
42 Dim i as integer, iNumberOfDocuments as integer
44 printlog "Checking under Tools -> XML Filter Settings that the DocBook XSLT Filter has been installed."
45 printlog "If not install them from ../global/input/xslt_stylesheets/docbook_xhtml.jar"
46 if fInitialXMLSetting("docbook") = FALSE then
47 warnlog "The DocBook XSLT filter has not been installed!"
51 'Calculating how many documents are in that directory (max. 500)
52 if hDirectoryExists(sSourcePath) then
53 'Get the file list and put it in a list (max. 500 per directory!)
54 call GetAllFileList(sSourcePath, "*.xml" , sSourceDocuments())
55 iNumberOfDocuments = ListCount(sSourceDocuments())
56 printlog iNumberOfDocuments & " DocBook XML files found in " & sSourcePath & "."
57 if iNumberOfDocuments > 0 then
58 for i = 2 to iNumberOfDocuments
59 'Call the testcase with each document.
60 call fLoadDocBookXMLAndSaveIt(sSourceDocuments(i))
63 warnlog "Path " & sSourcePath & " contains no documents!"
66 warnlog "Path " & sSourcePath & " has not been found!"
70 '-------------------------------------------------------------------------
72 testcase fLoadDocBookXMLAndSaveIt(sSourceDocument as string)
73 Dim sExpFileName as string
74 Dim sFileName as string
76 sFileName = DateiExtract(sSourceDocument)
77 sExpFileName = sDestinationPath & sFileName
79 printlog "Load test document " & sFileName & "."
80 call hFileOpen (sSourceDocument)
81 printlog "If the document can not be loaded as XML file (wrong Doctype) it will be loaded as ASCII."
82 Kontext "AsciiFilterOptionen"
83 if AsciiFilterOptionen.Exists(2) then
84 AsciiFilterOptionen.Cancel
85 QAErrorLog "The DTD may be does not match. Work around is to load it as ASCII file."
88 printlog "If the Filter Selection dialog occours the try to select the 'DocBook' entry."
89 Kontext "FilterAuswahl"
90 if FilterAuswahl.Exists(2) then
91 QAErrorLog "Filter selection dialog occoured!"
92 Filter.Select "DocBook"
95 'If there is no document being loaded only the 'backing window' would be visible
96 if GetDocumentCount = 0 then
97 warnlog "Document " & sFileName & " has not been loaded! It won't be exported! verify manually!"
99 printlog "Save the test document as " & sExpFileName
100 if hFileSaveAsWithFilterKill(sExpFileName, "DocBook File") = TRUE then
101 printlog "Close the document also if there is a verification dialog."
103 printlog "Check the well formness of the saved document."
104 if XMLWellformed (sExpFileName) = FALSE then
105 warnlog "XML-file " & sExpFileName & " not well formed or does not exist!"
107 printlog "Open the exported document."
108 call hFileOpen (sExpFileName)
109 Kontext "FilterAuswahl"
110 if FilterAuswahl.Exists(2) then
111 QAErrorLog "Filter selection dialog occoured!"
112 Filter.Select "DocBook"
115 if GetDocumentCount = 0 then
116 warnlog "EXPORTED document " & sExpFileName & " has not been loaded! It won't be exported! verify manually!"
118 printlog "Close the exported document."
123 warnlog "Exporting XML file (" & sExpFileName & ") failed!"