merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / basic / mod / sw / XMLExporter / sw_XMLExporter.xba
blob60dca7351d04535bcebccb3597a8d0e52756d24d
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.
9 '
10 ' Copyright 2008 by Sun Microsystems, Inc.
12 ' OpenOffice.org - a multi-platform office productivity suite
14 ' $RCSfile: sw_XMLExporter.xba,v $
16 ' $Revision: 1.3 $
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:
41 option explicit
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
56 Sub CreateObj()
58 '*************************************************************************
59 ' COMPONENT:
60 ' sw.XMLExporter
61 '*************************************************************************
62 On Error Goto ErrHndl
63 Dim initArgs(0) As Object
64 Dim oMSF As Object
65 Dim filter As Variant
66 Dim printXML As Boolean
67 Dim Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7 As Variant
68 Dim expString As String
69 Dim oText As Object
70 Dim oCursor As Object
72 printXML = true
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")
85 filter = Array( _
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()
112 oSrcDocument = oDoc
114 Exit Sub
115 ErrHndl:
116 Test.Exception()
117 End Sub
119 Global oDocHandler As Object
121 Function checkFilter() As Boolean
122 checkFilter = oDocHandler.getByName("XMLIsCorrect")
123 Out.Log(oDocHandler.getByName("XMLCode"))
124 End Function
125 </script:module>