| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> |
| <!--*********************************************************** |
| * |
| * 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 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| * |
| ***********************************************************--> |
| <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Meta" script:language="StarBasic">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 |
| </script:module> |