1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"sw_XMLExporter" script:
language=
"StarBasic">
6 '*************************************************************************
8 ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10 ' Copyright
2008 by Sun Microsystems, Inc.
12 ' OpenOffice.org - a multi-platform office productivity suite
14 ' $RCSfile: sw_XMLExporter.xba,v $
18 ' This file is part of OpenOffice.org.
20 ' OpenOffice.org is free software: you can redistribute it and/or modify
21 ' it under the terms of the GNU Lesser General Public License version
3
22 ' only, as published by the Free Software Foundation.
24 ' OpenOffice.org is distributed in the hope that it will be useful,
25 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
26 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ' GNU Lesser General Public License version
3 for more details
28 ' (a copy is included in the LICENSE file that accompanied this code).
30 ' You should have received a copy of the GNU Lesser General Public License
31 ' version
3 along with OpenOffice.org. If not, see
32 '
<http://www.openoffice.org/license.html
>
33 ' for a copy of the LGPLv3 License.
35 '*************************************************************************
36 '*************************************************************************
40 ' Be sure that all variables are dimensioned:
44 ' REQUIRED VARIABLES for interface/service tests:
46 ' Required for com.sun.star.lang.XInitialization:
47 Global aInitArgs() As Variant
49 ' Required for com.sun.star.document.XFilter:
50 Global oFilterDescriptor As Variant
52 ' Required for com.sun.star.document.XExporter:
53 Global oSrcDocument As Object
58 '*************************************************************************
61 '*************************************************************************
63 Dim initArgs(
0) As Object
66 Dim printXML As Boolean
67 Dim Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7 As Variant
68 Dim expString As String
73 expString =
"XMLExporter"
74 oMSF = getProcessServiceManager()
75 oDoc = utils.createDocument(
"swriter", cObjectName)
76 oDocHandler = oMSF.createInstanceWithArguments(
"basichelper.DocumentHandler", Array(printXML))
78 Tag1 = Array(
"office:document")
79 Tag2 = Array(
"office:meta")
80 Tag3 = Array(
"office:settings")
81 Tag4 = Array(
"office:script")
82 Tag5 = Array(
"office:styles")
83 Tag6 = Array(
"office:body")
84 Tag7 = Array(
"text:p")
86 Array(
"TagExists", Tag1), _
87 Array(
"TagEnclosed", Tag2, Tag1), _
88 Array(
"TagEnclosed", Tag3, Tag1), _
89 Array(
"TagEnclosed", Tag4, Tag1), _
90 Array(
"TagEnclosed", Tag5, Tag1), _
91 Array(
"TagEnclosed", Tag6, Tag1), _
92 Array(
"CharsEnclosed", Tag7, expString) _
95 oDocHandler.initialize(filter)
97 initArgs(
0) = oDocHandler
98 aInitArgs = initArgs()
99 oObj = oMSF.createInstanceWithArguments(
"com.sun.star.comp.Writer.XMLExporter", initArgs())
101 oText = oDoc.getText()
102 oCursor = oText.createTextCursor()
103 oText.insertString(oCursor, expString, false)
105 oObj.setSourceDocument(oDoc)
107 Dim aFilterDescr(
0) As New com.sun.star.beans.PropertyValue
108 aFilterDescr(
0).Name =
"FilterName"
109 aFilterDescr(
0).Value =
"swriter: StarOffice XML (text)"
110 oFilterDescriptor = aFilterDescr()
119 Global oDocHandler As Object
121 Function checkFilter() As Boolean
122 checkFilter = oDocHandler.getByName(
"XMLIsCorrect")
123 Out.Log(oDocHandler.getByName(
"XMLCode"))