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="Meta" script:language="StarBasic">REM ***** BASIC ***** 4 5Dim oDialog AS Object 6Dim document AS Object 7 8' Fetches the meta values from the document and executes the dialog 9Sub Main 10 11 If not IsHelpFile Then 12 msgbox(strErr_NoHelpFile) 13 Exit Sub 14 End If 15 16 document = StarDesktop.CurrentComponent 17 18 BasicLibraries.LoadLibrary("HelpAuthoring") 19 oDialog = LoadDialog("HelpAuthoring", "dlgMeta") 20 oDialogModel = oDialog.Model 21 22 'oTxtFName = oDialog.GetControl("txtFileName") 23 'oTxtFName.Text = document.DocumentInfo.PropertyValues(29).Value 24 'oTxtFName.Text = document.DocumentInfo.GetPropertyValue("Description") 25 26' If oTxtFName.Text = "" Then 27' msgbox "The document must be saved first."+chr(13)+"Please save the document and call this dialog again." 28' oDialog.dispose 29' Exit Sub 30' End If 31 32 oTxtTitle = oDialog.GetControl("txtTitle") 33 oTxtTitle.Text = document.DocumentInfo.Title 34 35 oOpIndInc = oDialog.GetControl("opIndexInclude") 36 oOpIndExc = oDialog.GetControl("opIndexExclude") 37 38 39 'oCbFileStatus = oDialog.GetControl("cbFileStatus") 40 'arItems = Array("DRAFT","FINAL","PUBLISH","STALLED","DEPRECATED") 41 'oCbFileStatus.AddItems(arItems,ubound(arItems)) 42 'sStatus = document.DocumentInfo.GetPropertyValue("Keywords") 43 'If (InStr("DRAFT FINAL PUBLISH STALLED DEPRECATED",sStatus)=0) Then 44 ' oCbFileStatus.SetText("DRAFT") 45 'Else 46 ' oCbFileStatus.SetText(sStatus) 47 'End If 48 49 50 If document.DocumentInfo.GetUserFieldValue(GetUserFieldNumber("Indexer")) = "exclude" then 51 oOpIndExc.State = True 52 Else 53 oOpIndInc.State = True 54 End If 55 56 'oTxtTopicID = oDialog.GetControl("txtTopicID") 57 'oTxtTopicID.Text = document.DocumentInfo.GetUserFieldValue(1) 58 59 'oTxtComment = oDialog.GetControl("txtComment") 60 'oTxtComment.Text = document.DocumentInfo.GetUserFieldValue(GetUserFieldNumber("Comment")) 61 62 'oTxtEdited = oDialog.GetControl("txtLastEdited") 63 'oTxtEdited.Text = document.DocumentInfo.GetUserFieldValue(3) 64 65 If oDialog.Execute() = 1 Then ' update the meta data 66 document.DocumentInfo.Title = oTxtTitle.Text 67 'document.DocumentInfo.SetUserFieldValue(1,oTxtTopicID.Text) 68 'document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Comment"),oTxtComment.Text) 69 'document.DocumentInfo.SetUserFieldValue(3,oTxtEdited.Text) 70 'document.DocumentInfo.SetPropertyValue("Keywords",oCbFileStatus.Text) 71 72 'If (oCbFileStatus.Text = "PUBLISH") Then 73 REM... Check for paras without ID: If there are any, this cannot be PUBLISH! 74 75 'End If 76 77 If oOpIndExc.State = True Then 78 document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Indexer"),"exclude") 79 Else 80 document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Indexer"),"include") 81 End If 82 End If 83 oDialog.dispose 84end sub 85 86' Normalizes the values for title and topic id 87' (if the fields are empty or contain invalid values) 88Sub NormalizeMeta (Event As Object) 89 Select Case Event.Source.Model.Name 90 Case "txtTitle": 91 If Event.Source.Text = "" Then 92 msgbox "Topic title must not be empty!"+chr(13)+"Resetting to default value." 93 End If 94 SetTopicTitle(Event.Source.Text) 95 Case "txtTopicID": 96 If Event.Source.Text = "" Then 97 msgbox "Topic ID must not be empty!"+chr(13)+"Resetting to default value." 98 End If 99 SetTopicID(Event.Source.Text) 100 End Select 101End Sub 102 103' Sets the value in the Topic ID dialog field 104Sub SetTopicID(txt As String) 105 oTxtTopicID = oDialog.GetControl("txtTopicID") 106 If txt = "" Then 107 oTxtTopicID.Text = AlphaNum(document.DocumentInfo.PropertyValues(29).Value) 108 Else 109 oTxtTopicID.Text = AlphaNum(txt) 110 End If 111End Sub 112 113Sub Test 114 On Error Resume Next 115 document = StarDesktop.CurrentComponent 116' showprop document 117 msgbox document.URL 118 119End Sub 120 121' Sets the value in the Topic title dialog field 122Sub SetTopicTitle(txt As String) 123 dim strg As String 124 oTxtTitle = oDialog.GetControl("txtTitle") 125 126 If txt ="" Then 127 Enum = document.Text.createEnumeration 128 129 Do While Enum.hasMoreElements 130 TextElement = Enum.nextElement 131 If TextElement.supportsService("com.sun.star.text.Paragraph") Then 132 If Left(TextElement.ParaStyleName,8)="hlp_head" Then 133 Enum2 = TextElement.createEnumeration 134 While Enum2.hasMoreElements 135 TextPortion = Enum2.nextElement 136 If Not(TextPortion.TextPortionType="TextField") Then 137 strg = strg + TextPortion.String 138 End If 139 Wend 140 oTxtTitle.Text = strg 141 Exit Do 142 End If 143 End If 144 Loop 145 Else 146 oTxtTitle.Text = txt 147 End If 148End Sub 149 150' Sets the value in the Topic title field when 151' "Fetch" button is pressed 152Sub FetchTopicTitle 153 SetTopicTitle("") 154 155End Sub 156 157' Sets the value in the Topic ID dialog field when 158' "Suggest" button is pressed 159Sub SuggestTopicID 160 SetTopicID("") 161End Sub 162 163Sub ChangeStatus 164 oCbFileStatus = oDialog.GetControl("cbFileStatus") 165 sStatus = document.DocumentInfo.GetPropertyValue("Keywords") 166 If (oCbFileStatus.Text = "PUBLISH") Then 167 nNoID = 0 ' DEBUG 168 If nNoID <> 0 Then 169 msgbox "There are "+nNoID+" new paragraphs in the file."+chr(13)+"File status PUBLISH invalid."+chr(13)+"Setting back to "+sStatus, 48, "D'oh!" 170 End If 171 End If 172End Sub 173</script:module>