REM ***** BASIC ***** 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.DocumentInfo.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 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.DocumentInfo.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") Else document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("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) 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