1rem *************************************************************
2rem
3rem  Licensed to the Apache Software Foundation (ASF) under one
4rem  or more contributor license agreements.  See the NOTICE file
5rem  distributed with this work for additional information
6rem  regarding copyright ownership.  The ASF licenses this file
7rem  to you under the Apache License, Version 2.0 (the
8rem  "License"); you may not use this file except in compliance
9rem  with the License.  You may obtain a copy of the License at
10rem
11rem    http://www.apache.org/licenses/LICENSE-2.0
12rem
13rem  Unless required by applicable law or agreed to in writing,
14rem  software distributed under the License is distributed on an
15rem  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16rem  KIND, either express or implied.  See the License for the
17rem  specific language governing permissions and limitations
18rem  under the License.
19rem
20rem *************************************************************
21rem	_______________________________________________________________________________________________________________________________________
22rem	Test script for registering or changing filter of our configuration.
23rem	_______________________________________________________________________________________________________________________________________
24
25Sub Main
26	Dim	xFiterFactory	as object
27	Dim	sFilterName		as string
28
29	xFilterFactory = createUNOService("com.sun.star.document.FilterFactory")
30
31	sFilterName = "MeinFilter_5"
32
33rem	AddFilter		( xFilterFactory, sFilterName	)
34	ReadFilter		( xFilterFactory, sFilterName	)
35rem	QueryFilters	( xFilterFactory				)
36
37	xFilterFactory.flush()
38
39End Sub
40
41rem *************************************************************************************************************
42Sub AddFilter( xFilterFactory, sFilterName )
43	Dim	lProperties(8)	as new com.sun.star.beans.PropertyValue
44	Dim	lUserData  (1)	as string
45
46	lUserData(1) = "Userdata von TestFilter"
47
48	lProperties(0).Name		=	"Type"
49	lProperties(0).Value	=	"bmp_MS_Windows"
50
51	lProperties(1).Name		=	"UIName"
52	lProperties(1).Value	=	sFilterName
53
54	lProperties(2).Name		=	"DocumentService"
55	lProperties(2).Value	=	"com.sun.star.text.TextDocument"
56
57	lProperties(3).Name		=	"FilterService"
58	lProperties(3).Value	=	"com.sun.star.comp.framework.TestFilter"
59
60	lProperties(4).Name		=	"Flags"
61	lProperties(4).Value	=	256
62
63	lProperties(5).Name		=	"UserData"
64	lProperties(5).Value	=	lUserData()
65
66	lProperties(6).Name		=	"FileFormatVersion"
67	lProperties(6).Value	=	0
68
69	lProperties(7).Name		=	"TemplateName"
70	lProperties(7).Value	=	""
71
72	xFilterFactory.insertByName( sFilterName, lProperties() )
73End Sub
74
75rem *************************************************************************************************************
76Sub ReadFilter( xFilterFactory, sFilterName )
77rem	Dim	lFilters()	as com.sun.star.beans.PropertyValue
78	Dim	sOut		as string
79	Dim	nCount		as integer
80
81	lProperties = xFilterFactory.getByName( sFilterName )
82
83	sOut = ""
84	for nCount=0 to ubound(lProperties()) step 1
85		sOut = sOut + lProperties(nCount).Name
86		sOut = sOut + " = "
87rem #85829# Disable follow if statement to produce bug!
88rem		if( lProperties(nCount).Name <> "UserData" ) then
89			sOut = sOut + lProperties(nCount).Value
90rem		endif
91		sOut = sOut + chr(13)
92	next nCount
93
94	msgbox sOut
95End Sub
96
97rem *************************************************************************************************************
98Sub QueryFilters( xFilterFactory )
99	Dim	lFilters()	as string
100	Dim	sQuery		as string
101	Dim	sOut		as string
102	Dim	nCount		as integer
103
104	sQuery = "_filterquery_defaultfilter"
105rem	sQuery = "_filterquery_textdocument_withdefault"
106
107	lFilters() = xFilterFactory.getByName( sQuery )
108
109	sOut = ""
110	for nCount=0 to ubound( lFilters() )
111		sOut = sOut + lFilters(nCount) + chr(13)
112	next nCount
113
114	msgbox sOut
115End Sub
116