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