1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Meta" script:language="StarBasic">REM ***** BASIC *****
' #
' # This file is part of the LibreOffice project.
' #
' # This Source Code Form is subject to the terms of the Mozilla Public
' # License, v. 2.0. If a copy of the MPL was not distributed with this
' # file, You can obtain one at http://mozilla.org/MPL/2.0/.
' #
' # This file incorporates work covered by the following license notice:
' #
' # Licensed to the Apache Software Foundation (ASF) under one or more
' # contributor license agreements. See the NOTICE file distributed
' # with this work for additional information regarding copyright
' # ownership. The ASF licenses this file to you under the Apache
' # License, Version 2.0 (the "License"); you may not use this file
' # except in compliance with the License. You may obtain a copy of
' # the License at http://www.apache.org/licenses/LICENSE-2.0 .
' #
Dim oDialog AS Object
Dim document AS Object
' Fetches the meta values from the document and executes the dialog
Sub Main
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
document = StarDesktop.CurrentComponent
BasicLibraries.LoadLibrary("HelpAuthoring")
oDialog = LoadDialog("HelpAuthoring", "dlgMeta")
oDialogModel = oDialog.Model
'oTxtFName = oDialog.GetControl("txtFileName")
'oTxtFName.Text = document.DocumentInfo.PropertyValues(29).Value
'oTxtFName.Text = document.DocumentInfo.GetPropertyValue("Description")
' If oTxtFName.Text = "" Then
' msgbox "The document must be saved first."+chr(13)+"Please save the document and call this dialog again."
' oDialog.dispose
' Exit Sub
' End If
oTxtTitle = oDialog.GetControl("txtTitle")
oTxtTitle.Text = document.DocumentProperties.Title
oOpIndInc = oDialog.GetControl("opIndexInclude")
oOpIndExc = oDialog.GetControl("opIndexExclude")
'oCbFileStatus = oDialog.GetControl("cbFileStatus")
'arItems = Array("DRAFT","FINAL","PUBLISH","STALLED","DEPRECATED")
'oCbFileStatus.AddItems(arItems,ubound(arItems))
'sStatus = document.DocumentInfo.GetPropertyValue("Keywords")
'If (InStr("DRAFT FINAL PUBLISH STALLED DEPRECATED",sStatus)=0) Then
' oCbFileStatus.SetText("DRAFT")
'Else
' oCbFileStatus.SetText(sStatus)
'End If
' If document.DocumentInfo.GetUserFieldValue(GetUserFieldNumber("Indexer")) = "exclude" then
If document.DocumentProperties.UserDefinedProperties.Indexer = "exclude" then
oOpIndExc.State = True
Else
oOpIndInc.State = True
End If
'oTxtTopicID = oDialog.GetControl("txtTopicID")
'oTxtTopicID.Text = document.DocumentInfo.GetUserFieldValue(1)
'oTxtComment = oDialog.GetControl("txtComment")
'oTxtComment.Text = document.DocumentInfo.GetUserFieldValue(GetUserFieldNumber("Comment"))
'oTxtEdited = oDialog.GetControl("txtLastEdited")
'oTxtEdited.Text = document.DocumentInfo.GetUserFieldValue(3)
If oDialog.Execute() = 1 Then ' update the meta data
document.DocumentProperties.Title = oTxtTitle.Text
'document.DocumentInfo.SetUserFieldValue(1,oTxtTopicID.Text)
'document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Comment"),oTxtComment.Text)
'document.DocumentInfo.SetUserFieldValue(3,oTxtEdited.Text)
'document.DocumentInfo.SetPropertyValue("Keywords",oCbFileStatus.Text)
'If (oCbFileStatus.Text = "PUBLISH") Then
REM... Check for paras without ID: If there are any, this cannot be PUBLISH!
'End If
If oOpIndExc.State = True Then
'document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Indexer"),"exclude")
document.DocumentProperties.UserDefinedProperties.Indexer = "exclude"
Else
' document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Indexer"),"include")
document.DocumentProperties.UserDefinedProperties.Indexer = "include"
End If
End If
oDialog.dispose
end sub
' Normalizes the values for title and topic id
' (if the fields are empty or contain invalid values)
Sub NormalizeMeta (Event As Object)
Select Case Event.Source.Model.Name
Case "txtTitle":
If Event.Source.Text = "" Then
msgbox "Topic title must not be empty!"+chr(13)+"Resetting to default value."
End If
SetTopicTitle(Event.Source.Text)
Case "txtTopicID":
If Event.Source.Text = "" Then
msgbox "Topic ID must not be empty!"+chr(13)+"Resetting to default value."
End If
SetTopicID(Event.Source.Text)
End Select
End Sub
' Sets the value in the Topic ID dialog field
Sub SetTopicID(txt As String)
oTxtTopicID = oDialog.GetControl("txtTopicID")
If txt = "" Then
oTxtTopicID.Text = AlphaNum(document.DocumentInfo.PropertyValues(29).Value)
' oTxtTopicID.Text = AlphaNum(document.DocumentProperties.UserDefinedProperties.Comments) ' OH need to find what is this...
Else
oTxtTopicID.Text = AlphaNum(txt)
End If
End Sub
Sub Test
On Error Resume Next
document = StarDesktop.CurrentComponent
' showprop document
msgbox document.URL
End Sub
' Sets the value in the Topic title dialog field
Sub SetTopicTitle(txt As String)
dim strg As String
oTxtTitle = oDialog.GetControl("txtTitle")
If txt ="" Then
Enum = document.Text.createEnumeration
Do While Enum.hasMoreElements
TextElement = Enum.nextElement
If TextElement.supportsService("com.sun.star.text.Paragraph") Then
If Left(TextElement.ParaStyleName,8)="hlp_head" Then
Enum2 = TextElement.createEnumeration
While Enum2.hasMoreElements
TextPortion = Enum2.nextElement
If Not(TextPortion.TextPortionType="TextField") Then
strg = strg + TextPortion.String
End If
Wend
oTxtTitle.Text = strg
Exit Do
End If
End If
Loop
Else
oTxtTitle.Text = txt
End If
End Sub
' Sets the value in the Topic title field when
' "Fetch" button is pressed
Sub FetchTopicTitle
SetTopicTitle("")
End Sub
' Sets the value in the Topic ID dialog field when
' "Suggest" button is pressed
Sub SuggestTopicID
SetTopicID("")
End Sub
Sub ChangeStatus
oCbFileStatus = oDialog.GetControl("cbFileStatus")
sStatus = document.DocumentInfo.GetPropertyValue("Keywords")
If (oCbFileStatus.Text = "PUBLISH") Then
nNoID = 0 ' DEBUG
If nNoID <> 0 Then
msgbox "There are "+nNoID+" new paragraphs in the file."+chr(13)+"File status PUBLISH invalid."+chr(13)+"Setting back to "+sStatus, 48, "D'oh!"
End If
End If
End Sub
</script:module>
|