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="sm_XMLMetaImporter" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31' Be sure that all variables are dimensioned:
32option explicit
33
34
35' REQUIRED VARIABLES for interface/service tests:
36
37' Required for com.sun.star.xml.sax.XDocumentHandler
38  Global vXMLData As Variant
39
40' Required for procedure CheckImport
41  Global sTitle, sName, sValue As String
42
43' Required for  com.sun.star.document.XImporter:
44  Global oSrcDocument As Object
45
46
47
48Sub CreateObj()
49
50'*************************************************************************
51' COMPONENT:
52' sm.XMLMetaImporter
53'*************************************************************************
54On Error Goto ErrHndl
55    oDoc = utils.createDocument("smath", cObjectName)
56    oObj = createUnoService("com.sun.star.comp.Math.XMLMetaImporter")
57
58    oSrcDocument = oDoc
59    oObj.setTargetDocument(oDoc)
60
61    sTitle = "XMLMetaImporter Title"
62    sName = "XMLMetaImporter"
63    sValue = "XMLMetaImporter_Value"
64    vXMLData = Array( _
65        Array("start", "office:document-meta", _
66                "xmlns:office", "CDATA", "http://openoffice.org/2000/office", _
67                "xmlns:meta", "CDATA", "http://openoffice.org/2000/meta", _
68                "xmlns:xlink", "CDATA", "http://www.w3.org/1999/xlink", _
69                "xmlns:dc", "CDATA", "http://purl.org/dc/elements/1.1/"), _
70        Array("start", "office:meta"), _
71        Array("start", "dc:title"), _
72        Array("chars", sTitle), _
73        Array("end", "dc:title"), _
74        Array("start", "meta:user-defined", _
75                "meta:name", "CDATA", sName), _
76        Array("chars", sValue), _
77        Array("end", "meta:user-defined"), _
78        Array("end", "office:meta"), _
79        Array("end", "office:document-meta"))
80Exit Sub
81ErrHndl:
82    Test.Exception()
83End Sub
84
85Function CheckImport() As Boolean
86    out.log("checking of import...")
87    Dim res As Boolean
88    Dim i As Integer
89    Dim docInfo As Object
90    Dim fieldValue, fieldName, title as String
91    docInfo = oDoc.getDocumentInfo()
92    res = false
93    For i = 0 to docInfo.getUserFieldCount() - 1
94        fieldName = docInfo.getUserFieldName(i)
95        fieldValue = docInfo.getUserFieldValue(i)
96        out.log("Field name: " + fieldName + " Value: " + fieldValue)
97        If (fieldName = sName) and (fieldValue = sValue) then
98            res = true
99        EndIf
100    Next i
101
102    title = docInfo.getPropertyValue("Title")
103    out.log("Title: " + title)
104    res = res and (title = sTitle)
105    out.log("checking result: " + res)
106    CheckImport() = res
107End Function
108</script:module>
109