11ecadb57SMathias Bauer<?xml version="1.0" encoding="UTF-8"?> 21ecadb57SMathias Bauer<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3*3e02b54dSAndrew Rist<!--*********************************************************** 4*3e02b54dSAndrew Rist * 5*3e02b54dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 6*3e02b54dSAndrew Rist * or more contributor license agreements. See the NOTICE file 7*3e02b54dSAndrew Rist * distributed with this work for additional information 8*3e02b54dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 9*3e02b54dSAndrew Rist * to you under the Apache License, Version 2.0 (the 10*3e02b54dSAndrew Rist * "License"); you may not use this file except in compliance 11*3e02b54dSAndrew Rist * with the License. You may obtain a copy of the License at 12*3e02b54dSAndrew Rist * 13*3e02b54dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 14*3e02b54dSAndrew Rist * 15*3e02b54dSAndrew Rist * Unless required by applicable law or agreed to in writing, 16*3e02b54dSAndrew Rist * software distributed under the License is distributed on an 17*3e02b54dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18*3e02b54dSAndrew Rist * KIND, either express or implied. See the License for the 19*3e02b54dSAndrew Rist * specific language governing permissions and limitations 20*3e02b54dSAndrew Rist * under the License. 21*3e02b54dSAndrew Rist * 22*3e02b54dSAndrew Rist ***********************************************************--> 231ecadb57SMathias Bauer<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Meta" script:language="StarBasic">REM ***** BASIC ***** 241ecadb57SMathias Bauer 251ecadb57SMathias BauerDim oDialog AS Object 261ecadb57SMathias BauerDim document AS Object 271ecadb57SMathias Bauer 281ecadb57SMathias Bauer' Fetches the meta values from the document and executes the dialog 291ecadb57SMathias BauerSub Main 301ecadb57SMathias Bauer 311ecadb57SMathias Bauer If not IsHelpFile Then 321ecadb57SMathias Bauer msgbox(strErr_NoHelpFile) 331ecadb57SMathias Bauer Exit Sub 341ecadb57SMathias Bauer End If 351ecadb57SMathias Bauer 361ecadb57SMathias Bauer document = StarDesktop.CurrentComponent 371ecadb57SMathias Bauer 381ecadb57SMathias Bauer BasicLibraries.LoadLibrary("HelpAuthoring") 391ecadb57SMathias Bauer oDialog = LoadDialog("HelpAuthoring", "dlgMeta") 401ecadb57SMathias Bauer oDialogModel = oDialog.Model 411ecadb57SMathias Bauer 421ecadb57SMathias Bauer 'oTxtFName = oDialog.GetControl("txtFileName") 431ecadb57SMathias Bauer 'oTxtFName.Text = document.DocumentInfo.PropertyValues(29).Value 441ecadb57SMathias Bauer 'oTxtFName.Text = document.DocumentInfo.GetPropertyValue("Description") 451ecadb57SMathias Bauer 461ecadb57SMathias Bauer' If oTxtFName.Text = "" Then 471ecadb57SMathias Bauer' msgbox "The document must be saved first."+chr(13)+"Please save the document and call this dialog again." 481ecadb57SMathias Bauer' oDialog.dispose 491ecadb57SMathias Bauer' Exit Sub 501ecadb57SMathias Bauer' End If 511ecadb57SMathias Bauer 521ecadb57SMathias Bauer oTxtTitle = oDialog.GetControl("txtTitle") 531ecadb57SMathias Bauer oTxtTitle.Text = document.DocumentInfo.Title 541ecadb57SMathias Bauer 551ecadb57SMathias Bauer oOpIndInc = oDialog.GetControl("opIndexInclude") 561ecadb57SMathias Bauer oOpIndExc = oDialog.GetControl("opIndexExclude") 571ecadb57SMathias Bauer 581ecadb57SMathias Bauer 591ecadb57SMathias Bauer 'oCbFileStatus = oDialog.GetControl("cbFileStatus") 601ecadb57SMathias Bauer 'arItems = Array("DRAFT","FINAL","PUBLISH","STALLED","DEPRECATED") 611ecadb57SMathias Bauer 'oCbFileStatus.AddItems(arItems,ubound(arItems)) 621ecadb57SMathias Bauer 'sStatus = document.DocumentInfo.GetPropertyValue("Keywords") 631ecadb57SMathias Bauer 'If (InStr("DRAFT FINAL PUBLISH STALLED DEPRECATED",sStatus)=0) Then 641ecadb57SMathias Bauer ' oCbFileStatus.SetText("DRAFT") 651ecadb57SMathias Bauer 'Else 661ecadb57SMathias Bauer ' oCbFileStatus.SetText(sStatus) 671ecadb57SMathias Bauer 'End If 681ecadb57SMathias Bauer 691ecadb57SMathias Bauer 701ecadb57SMathias Bauer If document.DocumentInfo.GetUserFieldValue(GetUserFieldNumber("Indexer")) = "exclude" then 711ecadb57SMathias Bauer oOpIndExc.State = True 721ecadb57SMathias Bauer Else 731ecadb57SMathias Bauer oOpIndInc.State = True 741ecadb57SMathias Bauer End If 751ecadb57SMathias Bauer 761ecadb57SMathias Bauer 'oTxtTopicID = oDialog.GetControl("txtTopicID") 771ecadb57SMathias Bauer 'oTxtTopicID.Text = document.DocumentInfo.GetUserFieldValue(1) 781ecadb57SMathias Bauer 791ecadb57SMathias Bauer 'oTxtComment = oDialog.GetControl("txtComment") 801ecadb57SMathias Bauer 'oTxtComment.Text = document.DocumentInfo.GetUserFieldValue(GetUserFieldNumber("Comment")) 811ecadb57SMathias Bauer 821ecadb57SMathias Bauer 'oTxtEdited = oDialog.GetControl("txtLastEdited") 831ecadb57SMathias Bauer 'oTxtEdited.Text = document.DocumentInfo.GetUserFieldValue(3) 841ecadb57SMathias Bauer 851ecadb57SMathias Bauer If oDialog.Execute() = 1 Then ' update the meta data 861ecadb57SMathias Bauer document.DocumentInfo.Title = oTxtTitle.Text 871ecadb57SMathias Bauer 'document.DocumentInfo.SetUserFieldValue(1,oTxtTopicID.Text) 881ecadb57SMathias Bauer 'document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Comment"),oTxtComment.Text) 891ecadb57SMathias Bauer 'document.DocumentInfo.SetUserFieldValue(3,oTxtEdited.Text) 901ecadb57SMathias Bauer 'document.DocumentInfo.SetPropertyValue("Keywords",oCbFileStatus.Text) 911ecadb57SMathias Bauer 921ecadb57SMathias Bauer 'If (oCbFileStatus.Text = "PUBLISH") Then 931ecadb57SMathias Bauer REM... Check for paras without ID: If there are any, this cannot be PUBLISH! 941ecadb57SMathias Bauer 951ecadb57SMathias Bauer 'End If 961ecadb57SMathias Bauer 971ecadb57SMathias Bauer If oOpIndExc.State = True Then 981ecadb57SMathias Bauer document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Indexer"),"exclude") 991ecadb57SMathias Bauer Else 1001ecadb57SMathias Bauer document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Indexer"),"include") 1011ecadb57SMathias Bauer End If 1021ecadb57SMathias Bauer End If 1031ecadb57SMathias Bauer oDialog.dispose 1041ecadb57SMathias Bauerend sub 1051ecadb57SMathias Bauer 1061ecadb57SMathias Bauer' Normalizes the values for title and topic id 1071ecadb57SMathias Bauer' (if the fields are empty or contain invalid values) 1081ecadb57SMathias BauerSub NormalizeMeta (Event As Object) 1091ecadb57SMathias Bauer Select Case Event.Source.Model.Name 1101ecadb57SMathias Bauer Case "txtTitle": 1111ecadb57SMathias Bauer If Event.Source.Text = "" Then 1121ecadb57SMathias Bauer msgbox "Topic title must not be empty!"+chr(13)+"Resetting to default value." 1131ecadb57SMathias Bauer End If 1141ecadb57SMathias Bauer SetTopicTitle(Event.Source.Text) 1151ecadb57SMathias Bauer Case "txtTopicID": 1161ecadb57SMathias Bauer If Event.Source.Text = "" Then 1171ecadb57SMathias Bauer msgbox "Topic ID must not be empty!"+chr(13)+"Resetting to default value." 1181ecadb57SMathias Bauer End If 1191ecadb57SMathias Bauer SetTopicID(Event.Source.Text) 1201ecadb57SMathias Bauer End Select 1211ecadb57SMathias BauerEnd Sub 1221ecadb57SMathias Bauer 1231ecadb57SMathias Bauer' Sets the value in the Topic ID dialog field 1241ecadb57SMathias BauerSub SetTopicID(txt As String) 1251ecadb57SMathias Bauer oTxtTopicID = oDialog.GetControl("txtTopicID") 1261ecadb57SMathias Bauer If txt = "" Then 1271ecadb57SMathias Bauer oTxtTopicID.Text = AlphaNum(document.DocumentInfo.PropertyValues(29).Value) 1281ecadb57SMathias Bauer Else 1291ecadb57SMathias Bauer oTxtTopicID.Text = AlphaNum(txt) 1301ecadb57SMathias Bauer End If 1311ecadb57SMathias BauerEnd Sub 1321ecadb57SMathias Bauer 1331ecadb57SMathias BauerSub Test 1341ecadb57SMathias Bauer On Error Resume Next 1351ecadb57SMathias Bauer document = StarDesktop.CurrentComponent 1361ecadb57SMathias Bauer' showprop document 1371ecadb57SMathias Bauer msgbox document.URL 1381ecadb57SMathias Bauer 1391ecadb57SMathias BauerEnd Sub 1401ecadb57SMathias Bauer 1411ecadb57SMathias Bauer' Sets the value in the Topic title dialog field 1421ecadb57SMathias BauerSub SetTopicTitle(txt As String) 1431ecadb57SMathias Bauer dim strg As String 1441ecadb57SMathias Bauer oTxtTitle = oDialog.GetControl("txtTitle") 1451ecadb57SMathias Bauer 1461ecadb57SMathias Bauer If txt ="" Then 1471ecadb57SMathias Bauer Enum = document.Text.createEnumeration 1481ecadb57SMathias Bauer 1491ecadb57SMathias Bauer Do While Enum.hasMoreElements 1501ecadb57SMathias Bauer TextElement = Enum.nextElement 1511ecadb57SMathias Bauer If TextElement.supportsService("com.sun.star.text.Paragraph") Then 1521ecadb57SMathias Bauer If Left(TextElement.ParaStyleName,8)="hlp_head" Then 1531ecadb57SMathias Bauer Enum2 = TextElement.createEnumeration 1541ecadb57SMathias Bauer While Enum2.hasMoreElements 1551ecadb57SMathias Bauer TextPortion = Enum2.nextElement 1561ecadb57SMathias Bauer If Not(TextPortion.TextPortionType="TextField") Then 1571ecadb57SMathias Bauer strg = strg + TextPortion.String 1581ecadb57SMathias Bauer End If 1591ecadb57SMathias Bauer Wend 1601ecadb57SMathias Bauer oTxtTitle.Text = strg 1611ecadb57SMathias Bauer Exit Do 1621ecadb57SMathias Bauer End If 1631ecadb57SMathias Bauer End If 1641ecadb57SMathias Bauer Loop 1651ecadb57SMathias Bauer Else 1661ecadb57SMathias Bauer oTxtTitle.Text = txt 1671ecadb57SMathias Bauer End If 1681ecadb57SMathias BauerEnd Sub 1691ecadb57SMathias Bauer 1701ecadb57SMathias Bauer' Sets the value in the Topic title field when 1711ecadb57SMathias Bauer' "Fetch" button is pressed 1721ecadb57SMathias BauerSub FetchTopicTitle 1731ecadb57SMathias Bauer SetTopicTitle("") 1741ecadb57SMathias Bauer 1751ecadb57SMathias BauerEnd Sub 1761ecadb57SMathias Bauer 1771ecadb57SMathias Bauer' Sets the value in the Topic ID dialog field when 1781ecadb57SMathias Bauer' "Suggest" button is pressed 1791ecadb57SMathias BauerSub SuggestTopicID 1801ecadb57SMathias Bauer SetTopicID("") 1811ecadb57SMathias BauerEnd Sub 1821ecadb57SMathias Bauer 1831ecadb57SMathias BauerSub ChangeStatus 1841ecadb57SMathias Bauer oCbFileStatus = oDialog.GetControl("cbFileStatus") 1851ecadb57SMathias Bauer sStatus = document.DocumentInfo.GetPropertyValue("Keywords") 1861ecadb57SMathias Bauer If (oCbFileStatus.Text = "PUBLISH") Then 1871ecadb57SMathias Bauer nNoID = 0 ' DEBUG 1881ecadb57SMathias Bauer If nNoID <> 0 Then 1891ecadb57SMathias Bauer msgbox "There are "+nNoID+" new paragraphs in the file."+chr(13)+"File status PUBLISH invalid."+chr(13)+"Setting back to "+sStatus, 48, "D'oh!" 1901ecadb57SMathias Bauer End If 1911ecadb57SMathias Bauer End If 1921ecadb57SMathias BauerEnd Sub 193*3e02b54dSAndrew Rist</script:module> 194