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="Helpers" script:language="StarBasic">' *** MODULE HELPERS *** 241ecadb57SMathias Bauer 251ecadb57SMathias Bauer'======================================================= 261ecadb57SMathias Bauer' Main 271ecadb57SMathias Bauer'------------------------------------------------------- 281ecadb57SMathias Bauer' Ensure that necessary library functions are available 291ecadb57SMathias Bauer'======================================================= 301ecadb57SMathias BauerSub Main 311ecadb57SMathias Bauer GlobalScope.BasicLibraries.loadLibrary("Tools") 321ecadb57SMathias BauerEnd Sub 331ecadb57SMathias Bauer 341ecadb57SMathias Bauer'======================================================= 351ecadb57SMathias Bauer' ShowProp 361ecadb57SMathias Bauer'------------------------------------------------------- 371ecadb57SMathias Bauer' Displays a dialog that shows the properties and 381ecadb57SMathias Bauer' the methods of an object. Used for debugging. 391ecadb57SMathias Bauer'======================================================= 401ecadb57SMathias BauerSub ShowProp(Elem As Object) 411ecadb57SMathias Bauer dim oDialog As Object 421ecadb57SMathias Bauer 431ecadb57SMathias Bauer BasicLibraries.LoadLibrary("HelpAuthoring") 441ecadb57SMathias Bauer oDialog = LoadDialog("HelpAuthoring", "dlgObjProp") 451ecadb57SMathias Bauer oDialogModel = oDialog.Model 461ecadb57SMathias Bauer 471ecadb57SMathias Bauer oTxtProp = oDialog.GetControl("txtProp") 481ecadb57SMathias Bauer oTxtProp.Text = Join(Split(Elem.dbg_properties,";"),chr(13)) 491ecadb57SMathias Bauer 501ecadb57SMathias Bauer oTxtMeth = oDialog.GetControl("txtMeth") 511ecadb57SMathias Bauer oTxtMeth.Text = Join(Split(Elem.dbg_methods,";"),chr(13)) 521ecadb57SMathias Bauer 531ecadb57SMathias Bauer oTxtInt = oDialog.GetControl("txtInt") 541ecadb57SMathias Bauer oTxtInt.Text = Join(Split(Elem.dbg_supportedInterfaces,";"),chr(13)) 551ecadb57SMathias Bauer 561ecadb57SMathias Bauer oDialog.Execute() 571ecadb57SMathias Bauer oDialog.dispose 581ecadb57SMathias BauerEnd Sub 591ecadb57SMathias Bauer 601ecadb57SMathias Bauer'======================================================= 611ecadb57SMathias Bauer' AlphaNum 621ecadb57SMathias Bauer'------------------------------------------------------- 631ecadb57SMathias Bauer' Removes all invalid characters from a string 641ecadb57SMathias Bauer'======================================================= 651ecadb57SMathias BauerFunction AlphaNum(Strg As String) 661ecadb57SMathias Bauer dim OutStrg As String 671ecadb57SMathias Bauer dim sValid As String 681ecadb57SMathias Bauer 691ecadb57SMathias Bauer sValid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789" 701ecadb57SMathias Bauer 711ecadb57SMathias Bauer For i=1 to Len(Strg) 721ecadb57SMathias Bauer If (Instr(sValid,LCase(Mid(Strg,i,1)))) Then 731ecadb57SMathias Bauer OutStrg = OutStrg + Mid(Strg,i,1) 741ecadb57SMathias Bauer End If 751ecadb57SMathias Bauer Next i 761ecadb57SMathias Bauer AlphaNum = OutStrg 771ecadb57SMathias BauerEnd Function 781ecadb57SMathias Bauer 791ecadb57SMathias Bauer'======================================================= 801ecadb57SMathias Bauer' Replace 811ecadb57SMathias Bauer'------------------------------------------------------- 821ecadb57SMathias Bauer' Replaces a character with another character in a string 831ecadb57SMathias Bauer'======================================================= 841ecadb57SMathias BauerFunction Replace(txt As String, ReplaceFrom As String, ReplaceTo As String) 851ecadb57SMathias Bauer dim OutStr As String 861ecadb57SMathias Bauer For i=1 to len(txt) 871ecadb57SMathias Bauer If LCase(mid(txt,i,1))=ReplaceFrom Then 881ecadb57SMathias Bauer OutStr = OutStr + ReplaceTo 891ecadb57SMathias Bauer Else 901ecadb57SMathias Bauer OutStr = OutStr + mid(txt,i,1) 911ecadb57SMathias Bauer End If 921ecadb57SMathias Bauer Next i 931ecadb57SMathias Bauer Replace = OutStr 941ecadb57SMathias BauerEnd Function 951ecadb57SMathias Bauer 961ecadb57SMathias Bauer 971ecadb57SMathias Bauer'======================================================= 981ecadb57SMathias Bauer' ReplaceAll 991ecadb57SMathias Bauer'------------------------------------------------------- 1001ecadb57SMathias Bauer' Replaces a character with another character in a string 1011ecadb57SMathias Bauer'======================================================= 1021ecadb57SMathias BauerFunction ReplaceAll(txt As String, ReplaceFrom As String, ReplaceTo As String) 1031ecadb57SMathias Bauer dim OutStr As String 1041ecadb57SMathias Bauer For i=1 to len(txt) 1051ecadb57SMathias Bauer bFound = 0 1061ecadb57SMathias Bauer For j=1 to len(ReplaceFrom) 1071ecadb57SMathias Bauer If LCase(mid(txt,i,1))=LCase(mid(ReplaceFrom,j,1)) Then 1081ecadb57SMathias Bauer bFound = 1 1091ecadb57SMathias Bauer OutStr = OutStr + ReplaceTo 1101ecadb57SMathias Bauer j = len(ReplaceFrom) 1111ecadb57SMathias Bauer End If 1121ecadb57SMathias Bauer Next j 1131ecadb57SMathias Bauer If bFound=0 Then 1141ecadb57SMathias Bauer OutStr = OutStr + mid(txt,i,1) 1151ecadb57SMathias Bauer End If 1161ecadb57SMathias Bauer Next i 1171ecadb57SMathias Bauer ReplaceAll = OutStr 1181ecadb57SMathias BauerEnd Function 1191ecadb57SMathias Bauer 1201ecadb57SMathias Bauer 1211ecadb57SMathias Bauer 1221ecadb57SMathias Bauer'======================================================= 1231ecadb57SMathias Bauer' CreateID 1241ecadb57SMathias Bauer'------------------------------------------------------- 1251ecadb57SMathias Bauer' Creates a numerical randomized ID 1261ecadb57SMathias Bauer'======================================================= 1271ecadb57SMathias BauerFunction CreateID 1281ecadb57SMathias Bauer sDate = ReplaceAll(Date,"/:. \","") 1291ecadb57SMathias Bauer sTime = ReplaceAll(Time,"/:. \AMP","") 1301ecadb57SMathias Bauer Randomize 1311ecadb57SMathias Bauer CreateID = sDate + sTime + Int(Rnd * 100) 1321ecadb57SMathias BauerEnd Function 1331ecadb57SMathias Bauer 1341ecadb57SMathias Bauer'======================================================= 1351ecadb57SMathias Bauer' InsertTag 1361ecadb57SMathias Bauer'------------------------------------------------------- 1371ecadb57SMathias Bauer' Inserts an inline tag (element) in the document at the 1381ecadb57SMathias Bauer' current cursor position. It also sets the character 1391ecadb57SMathias Bauer' format to hlp_aux_tag 1401ecadb57SMathias Bauer'======================================================= 1411ecadb57SMathias BauerSub InsertTag (Element As String, Content As String) 1421ecadb57SMathias Bauer dim document as object 1431ecadb57SMathias Bauer dim dispatcher as object 1441ecadb57SMathias Bauer 1451ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 1461ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 1471ecadb57SMathias Bauer 1481ecadb57SMathias Bauer dim args(5) as new com.sun.star.beans.PropertyValue 1491ecadb57SMathias Bauer args(0).Name = "Type" 1501ecadb57SMathias Bauer args(0).Value = 8 1511ecadb57SMathias Bauer args(1).Name = "SubType" 1521ecadb57SMathias Bauer args(1).Value = 1 1531ecadb57SMathias Bauer args(2).Name = "Name" 1541ecadb57SMathias Bauer args(2).Value = Element 1551ecadb57SMathias Bauer args(3).Name = "Content" 1561ecadb57SMathias Bauer args(3).Value = Content 1571ecadb57SMathias Bauer args(4).Name = "Format" 1581ecadb57SMathias Bauer args(4).Value = -1 1591ecadb57SMathias Bauer args(5).Name = "Separator" 1601ecadb57SMathias Bauer args(5).Value = " " 1611ecadb57SMathias Bauer SetCharStyle("hlp_aux_tag") 1621ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:InsertField", "", 0, args()) 1631ecadb57SMathias Bauer SetCharStyle("Default") 1641ecadb57SMathias BauerEnd Sub 1651ecadb57SMathias Bauer 1661ecadb57SMathias Bauer'======================================================= 1671ecadb57SMathias Bauer' INSERTTAGCR 1681ecadb57SMathias Bauer'------------------------------------------------------- 1691ecadb57SMathias Bauer' Inserts a tag (element) in the document at the 1701ecadb57SMathias Bauer' current cursor position in its own newly created paragraph. 1711ecadb57SMathias Bauer' It also sets the character format to hlp_aux_tag and 1721ecadb57SMathias Bauer' the paragraph to the specified value (should start with hlp_) 1731ecadb57SMathias Bauer'======================================================= 1741ecadb57SMathias BauerSub InsertTagCR (Element As String, Content As String, Style As String) 1751ecadb57SMathias Bauer dim document as object 1761ecadb57SMathias Bauer dim dispatcher as object 1771ecadb57SMathias Bauer 1781ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 1791ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 1801ecadb57SMathias Bauer 1811ecadb57SMathias Bauer dim args(5) as new com.sun.star.beans.PropertyValue 1821ecadb57SMathias Bauer args(0).Name = "Type" 1831ecadb57SMathias Bauer args(0).Value = 8 1841ecadb57SMathias Bauer args(1).Name = "SubType" 1851ecadb57SMathias Bauer args(1).Value = 1 1861ecadb57SMathias Bauer args(2).Name = "Name" 1871ecadb57SMathias Bauer args(2).Value = Element 1881ecadb57SMathias Bauer args(3).Name = "Content" 1891ecadb57SMathias Bauer args(3).Value = Content 1901ecadb57SMathias Bauer args(4).Name = "Format" 1911ecadb57SMathias Bauer args(4).Value = -1 1921ecadb57SMathias Bauer args(5).Name = "Separator" 1931ecadb57SMathias Bauer args(5).Value = " " 1941ecadb57SMathias Bauer 1951ecadb57SMathias Bauer CR 1961ecadb57SMathias Bauer goUp(1) 1971ecadb57SMathias Bauer SetParaStyle(Style) 1981ecadb57SMathias Bauer SetCharStyle("hlp_aux_tag") 1991ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:InsertField", "", 0, args()) 2001ecadb57SMathias Bauer SetCharStyle("Default") 2011ecadb57SMathias Bauer goDown(1) 2021ecadb57SMathias BauerEnd Sub 2031ecadb57SMathias Bauer 2041ecadb57SMathias Bauer'======================================================= 2051ecadb57SMathias Bauer' InsertField 2061ecadb57SMathias Bauer'------------------------------------------------------- 2071ecadb57SMathias Bauer' Inserts a field in the document at the 2081ecadb57SMathias Bauer' current cursor position. 2091ecadb57SMathias Bauer'======================================================= 2101ecadb57SMathias BauerSub InsertField(Field as String, Content as String) 2111ecadb57SMathias Bauer dim document as object 2121ecadb57SMathias Bauer dim dispatcher as object 2131ecadb57SMathias Bauer 2141ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 2151ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 2161ecadb57SMathias Bauer 2171ecadb57SMathias Bauer dim args(5) as new com.sun.star.beans.PropertyValue 2181ecadb57SMathias Bauer args(0).Name = "Type" 2191ecadb57SMathias Bauer args(0).Value = 8 2201ecadb57SMathias Bauer args(1).Name = "SubType" 2211ecadb57SMathias Bauer args(1).Value = 1 2221ecadb57SMathias Bauer args(2).Name = "Name" 2231ecadb57SMathias Bauer args(2).Value = Field 2241ecadb57SMathias Bauer args(3).Name = "Content" 2251ecadb57SMathias Bauer args(3).Value = Content 2261ecadb57SMathias Bauer args(4).Name = "Format" 2271ecadb57SMathias Bauer args(4).Value = -1 2281ecadb57SMathias Bauer args(5).Name = "Separator" 2291ecadb57SMathias Bauer args(5).Value = " " 2301ecadb57SMathias Bauer 2311ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:InsertField", "", 0, args()) 2321ecadb57SMathias BauerEnd Sub 2331ecadb57SMathias Bauer 2341ecadb57SMathias Bauer'======================================================= 2351ecadb57SMathias Bauer' GoUp 2361ecadb57SMathias Bauer'------------------------------------------------------- 2371ecadb57SMathias Bauer' Simulates the CursorUp key 2381ecadb57SMathias Bauer'======================================================= 2391ecadb57SMathias BauerSub goUp(Count As Integer, Optional bSelect As Boolean) 2401ecadb57SMathias Bauer dim document as object 2411ecadb57SMathias Bauer dim dispatcher as object 2421ecadb57SMathias Bauer 2431ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 2441ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 2451ecadb57SMathias Bauer 2461ecadb57SMathias Bauer dim args(1) as new com.sun.star.beans.PropertyValue 2471ecadb57SMathias Bauer args(0).Name = "Count" 2481ecadb57SMathias Bauer args(0).Value = Count 2491ecadb57SMathias Bauer args(1).Name = "Select" 2501ecadb57SMathias Bauer If IsMissing(bSelect) Then 2511ecadb57SMathias Bauer args(1).Value = false 2521ecadb57SMathias Bauer Else 2531ecadb57SMathias Bauer args(1).Value = bSelect 2541ecadb57SMathias Bauer End If 2551ecadb57SMathias Bauer 2561ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args()) 2571ecadb57SMathias BauerEnd Sub 2581ecadb57SMathias Bauer 2591ecadb57SMathias Bauer'======================================================= 2601ecadb57SMathias Bauer' GoDown 2611ecadb57SMathias Bauer'------------------------------------------------------- 2621ecadb57SMathias Bauer' Simulates the CursorDown key 2631ecadb57SMathias Bauer'======================================================= 2641ecadb57SMathias BauerSub goDown(Count As Integer, Optional bSelect As Boolean) 2651ecadb57SMathias Bauer dim document as object 2661ecadb57SMathias Bauer dim dispatcher as object 2671ecadb57SMathias Bauer 2681ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 2691ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 2701ecadb57SMathias Bauer 2711ecadb57SMathias Bauer dim args(1) as new com.sun.star.beans.PropertyValue 2721ecadb57SMathias Bauer args(0).Name = "Count" 2731ecadb57SMathias Bauer args(0).Value = Count 2741ecadb57SMathias Bauer args(1).Name = "Select" 2751ecadb57SMathias Bauer If IsMissing(bSelect) Then 2761ecadb57SMathias Bauer args(1).Value = false 2771ecadb57SMathias Bauer Else 2781ecadb57SMathias Bauer args(1).Value = bSelect 2791ecadb57SMathias Bauer End If 2801ecadb57SMathias Bauer 2811ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args()) 2821ecadb57SMathias BauerEnd Sub 2831ecadb57SMathias Bauer 2841ecadb57SMathias Bauer 2851ecadb57SMathias Bauer'======================================================= 2861ecadb57SMathias Bauer' GoRight 2871ecadb57SMathias Bauer'------------------------------------------------------- 2881ecadb57SMathias Bauer' Simulates the CursorRight key 2891ecadb57SMathias Bauer'======================================================= 2901ecadb57SMathias BauerSub goRight(Count As Integer, Optional bSelect As Boolean) 2911ecadb57SMathias Bauer dim document as object 2921ecadb57SMathias Bauer dim dispatcher as object 2931ecadb57SMathias Bauer 2941ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 2951ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 2961ecadb57SMathias Bauer 2971ecadb57SMathias Bauer dim args(1) as new com.sun.star.beans.PropertyValue 2981ecadb57SMathias Bauer args(0).Name = "Count" 2991ecadb57SMathias Bauer args(0).Value = Count 3001ecadb57SMathias Bauer args(1).Name = "Select" 3011ecadb57SMathias Bauer If IsMissing(bSelect) Then 3021ecadb57SMathias Bauer args(1).Value = false 3031ecadb57SMathias Bauer Else 3041ecadb57SMathias Bauer args(1).Value = bSelect 3051ecadb57SMathias Bauer End If 3061ecadb57SMathias Bauer 3071ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args()) 3081ecadb57SMathias BauerEnd Sub 3091ecadb57SMathias Bauer 3101ecadb57SMathias Bauer'======================================================= 3111ecadb57SMathias Bauer' GoLeft 3121ecadb57SMathias Bauer'------------------------------------------------------- 3131ecadb57SMathias Bauer' Simulates the CursorLeft key 3141ecadb57SMathias Bauer'======================================================= 3151ecadb57SMathias BauerSub goLeft(Count As Integer, optional bSelect As boolean) 3161ecadb57SMathias Bauer dim document as object 3171ecadb57SMathias Bauer dim dispatcher as object 3181ecadb57SMathias Bauer 3191ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 3201ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 3211ecadb57SMathias Bauer 3221ecadb57SMathias Bauer dim args(1) as new com.sun.star.beans.PropertyValue 3231ecadb57SMathias Bauer args(0).Name = "Count" 3241ecadb57SMathias Bauer args(0).Value = Count 3251ecadb57SMathias Bauer args(1).Name = "Select" 3261ecadb57SMathias Bauer If IsMissing(bSelect) Then 3271ecadb57SMathias Bauer args(1).Value = false 3281ecadb57SMathias Bauer Else 3291ecadb57SMathias Bauer args(1).Value = bSelect 3301ecadb57SMathias Bauer End If 3311ecadb57SMathias Bauer 3321ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args()) 3331ecadb57SMathias BauerEnd Sub 3341ecadb57SMathias Bauer 3351ecadb57SMathias Bauer'======================================================= 3361ecadb57SMathias Bauer' CR 3371ecadb57SMathias Bauer'------------------------------------------------------- 3381ecadb57SMathias Bauer' Inserts a Carriage Return (a new paragraph) 3391ecadb57SMathias Bauer'======================================================= 3401ecadb57SMathias BauerSub CR 3411ecadb57SMathias Bauer dim document as object 3421ecadb57SMathias Bauer dim dispatcher as object 3431ecadb57SMathias Bauer 3441ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 3451ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 3461ecadb57SMathias Bauer 3471ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 3481ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 3491ecadb57SMathias Bauer oCur.gotoEndOfParagraph(0) 3501ecadb57SMathias Bauer thiscomponent.getcurrentcontroller.select(oCur) 3511ecadb57SMathias Bauer 3521ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array()) 3531ecadb57SMathias BauerEnd Sub 3541ecadb57SMathias Bauer 3551ecadb57SMathias Bauer'======================================================= 3561ecadb57SMathias Bauer' CR_before 3571ecadb57SMathias Bauer'------------------------------------------------------- 3581ecadb57SMathias Bauer' Inserts a Carriage Return (a new paragraph) before the current para 3591ecadb57SMathias Bauer'======================================================= 3601ecadb57SMathias BauerSub CR_before 3611ecadb57SMathias Bauer dim document as object 3621ecadb57SMathias Bauer dim dispatcher as object 3631ecadb57SMathias Bauer 3641ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 3651ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 3661ecadb57SMathias Bauer 3671ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 3681ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 3691ecadb57SMathias Bauer oCur.gotoStartOfParagraph(0) 3701ecadb57SMathias Bauer thiscomponent.getcurrentcontroller.select(oCur) 3711ecadb57SMathias Bauer 3721ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array()) 3731ecadb57SMathias BauerEnd Sub 3741ecadb57SMathias Bauer 3751ecadb57SMathias Bauer'======================================================= 3761ecadb57SMathias Bauer' LF 3771ecadb57SMathias Bauer'------------------------------------------------------- 3781ecadb57SMathias Bauer' Inserts a line feed (manual line break) 3791ecadb57SMathias Bauer'======================================================= 3801ecadb57SMathias Bauersub LF 3811ecadb57SMathias Bauer dim document as object 3821ecadb57SMathias Bauer dim dispatcher as object 3831ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 3841ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 3851ecadb57SMathias Bauer 3861ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:InsertLinebreak", "", 0, Array()) 3871ecadb57SMathias Bauerend sub 3881ecadb57SMathias Bauer 3891ecadb57SMathias Bauer'======================================================= 3901ecadb57SMathias Bauer' SetParaStyle 3911ecadb57SMathias Bauer'------------------------------------------------------- 3921ecadb57SMathias Bauer' Sets the para style to the given value 3931ecadb57SMathias Bauer'======================================================= 3941ecadb57SMathias BauerSub SetParaStyle(StyleName As String) 3951ecadb57SMathias Bauer dim document as object 3961ecadb57SMathias Bauer dim dispatcher as object 3971ecadb57SMathias Bauer 3981ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 3991ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 4001ecadb57SMathias Bauer 4011ecadb57SMathias Bauer dim args(1) as new com.sun.star.beans.PropertyValue 4021ecadb57SMathias Bauer args(0).Name = "Template" 4031ecadb57SMathias Bauer args(0).Value = StyleName 4041ecadb57SMathias Bauer args(1).Name = "Family" 4051ecadb57SMathias Bauer args(1).Value = 2 4061ecadb57SMathias Bauer 4071ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:StyleApply", "", 0, args()) 4081ecadb57SMathias Bauerend Sub 4091ecadb57SMathias Bauer 4101ecadb57SMathias Bauer'======================================================= 4111ecadb57SMathias Bauer' SetCharStyle 4121ecadb57SMathias Bauer'------------------------------------------------------- 4131ecadb57SMathias Bauer' Sets the character style to the given value 4141ecadb57SMathias Bauer'======================================================= 4151ecadb57SMathias BauerSub SetCharStyle(StyleName As String) 4161ecadb57SMathias Bauer dim document as object 4171ecadb57SMathias Bauer dim dispatcher as object 4181ecadb57SMathias Bauer 4191ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 4201ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 4211ecadb57SMathias Bauer 4221ecadb57SMathias Bauer dim args(1) as new com.sun.star.beans.PropertyValue 4231ecadb57SMathias Bauer args(0).Name = "Template" 4241ecadb57SMathias Bauer args(0).Value = StyleName 4251ecadb57SMathias Bauer args(1).Name = "Family" 4261ecadb57SMathias Bauer args(1).Value = 1 4271ecadb57SMathias Bauer 4281ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:StyleApply", "", 0, args()) 4291ecadb57SMathias Bauerend Sub 4301ecadb57SMathias Bauer 4311ecadb57SMathias Bauer'======================================================= 4321ecadb57SMathias Bauer' InsertNewParaData 4331ecadb57SMathias Bauer'------------------------------------------------------- 4341ecadb57SMathias Bauer' Inserts a new ID for the paragraph 4351ecadb57SMathias Bauer'======================================================= 4361ecadb57SMathias BauerSub InsertNewParaData 4371ecadb57SMathias Bauer 4381ecadb57SMathias Bauer If not IsHelpFile Then 4391ecadb57SMathias Bauer msgbox(strErr_NoHelpFile) 4401ecadb57SMathias Bauer Exit Sub 4411ecadb57SMathias Bauer End If 4421ecadb57SMathias Bauer 4431ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 4441ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 4451ecadb57SMathias Bauer 4461ecadb57SMathias Bauer arParaData = GetParaData 4471ecadb57SMathias Bauer sID = arParaData(0) 4481ecadb57SMathias Bauer slocalize = arParaData(1) 4491ecadb57SMathias Bauer sMsg = arParaData(2) 4501ecadb57SMathias Bauer 4511ecadb57SMathias Bauer If sMsg <> "" Then 4521ecadb57SMathias Bauer msgbox "Cannot assign paragraph id:"+chr(13)+sMsg,48,"Error" 4531ecadb57SMathias Bauer Exit Sub 4541ecadb57SMathias Bauer End If 4551ecadb57SMathias Bauer 4561ecadb57SMathias Bauer If sID <> "" Then 4571ecadb57SMathias Bauer msgbox "Paragraph already has an ID."+chr(13)+"If you want to assign a new ID delete the existing one first.",48,"Error" 4581ecadb57SMathias Bauer Exit Sub 4591ecadb57SMathias Bauer End If 4601ecadb57SMathias Bauer 4611ecadb57SMathias Bauer oCur.gotoStartOfParagraph(0) 4621ecadb57SMathias Bauer 4631ecadb57SMathias Bauer If (Left(oCur.ParaStyleName,8) = "hlp_head") Then 4641ecadb57SMathias Bauer id = "hd_id" + CreateID 4651ecadb57SMathias Bauer thiscomponent.getcurrentcontroller.select(oCur) 4661ecadb57SMathias Bauer MetaData = id 4671ecadb57SMathias Bauer SetCharStyle("hlp_aux_parachanged") 4681ecadb57SMathias Bauer InsertField("ID",MetaData) 4691ecadb57SMathias Bauer SetCharStyle("Default") 4701ecadb57SMathias Bauer Else 4711ecadb57SMathias Bauer id = "par_id" + CreateID 4721ecadb57SMathias Bauer thiscomponent.getcurrentcontroller.select(oCur) 4731ecadb57SMathias Bauer MetaData = id 4741ecadb57SMathias Bauer SetCharStyle("hlp_aux_parachanged") 4751ecadb57SMathias Bauer InsertField("ID",MetaData) 4761ecadb57SMathias Bauer SetCharStyle("Default") 4771ecadb57SMathias Bauer End If 4781ecadb57SMathias Bauer 4791ecadb57SMathias Bauer 4801ecadb57SMathias BauerEnd Sub 4811ecadb57SMathias Bauer 4821ecadb57SMathias Bauer'======================================================= 4831ecadb57SMathias Bauer' LoadDialog 4841ecadb57SMathias Bauer'------------------------------------------------------- 4851ecadb57SMathias Bauer' Loads a BASIC dialog 4861ecadb57SMathias Bauer'======================================================= 4871ecadb57SMathias BauerFunction LoadDialog(Libname as String, DialogName as String, Optional oLibContainer) 4881ecadb57SMathias Bauer Dim oLib as Object 4891ecadb57SMathias Bauer Dim oLibDialog as Object 4901ecadb57SMathias Bauer Dim oRuntimeDialog as Object 4911ecadb57SMathias Bauer 4921ecadb57SMathias Bauer If IsMissing(oLibContainer ) then 4931ecadb57SMathias Bauer oLibContainer = DialogLibraries 4941ecadb57SMathias Bauer End If 4951ecadb57SMathias Bauer 4961ecadb57SMathias Bauer oLibContainer.LoadLibrary(LibName) 4971ecadb57SMathias Bauer oLib = oLibContainer.GetByName(Libname) 4981ecadb57SMathias Bauer oLibDialog = oLib.GetByName(DialogName) 4991ecadb57SMathias Bauer oRuntimeDialog = CreateUnoDialog(oLibDialog) 5001ecadb57SMathias Bauer LoadDialog() = oRuntimeDialog 5011ecadb57SMathias BauerEnd Function 5021ecadb57SMathias Bauer 5031ecadb57SMathias Bauer'======================================================= 5041ecadb57SMathias Bauer' Surprise 5051ecadb57SMathias Bauer'------------------------------------------------------- 5061ecadb57SMathias Bauer' D'oh 5071ecadb57SMathias Bauer'======================================================= 5081ecadb57SMathias BauerSub Surprise 5091ecadb57SMathias Bauer msgbox "This function is unsupported."+chr(13)+"If you know how to implement this -- go ahead!",0,"D'oh!" 5101ecadb57SMathias BauerEnd Sub 5111ecadb57SMathias Bauer 5121ecadb57SMathias Bauer'======================================================= 5131ecadb57SMathias Bauer' InsertNote 5141ecadb57SMathias Bauer'------------------------------------------------------- 5151ecadb57SMathias Bauer' Inserts a note (annotation) at the current position 5161ecadb57SMathias Bauer'======================================================= 5171ecadb57SMathias Bauersub InsertNote(Content As String) 5181ecadb57SMathias Bauer dim document as object 5191ecadb57SMathias Bauer dim dispatcher as object 5201ecadb57SMathias Bauer 5211ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 5221ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 5231ecadb57SMathias Bauer 5241ecadb57SMathias Bauer dim args(2) as new com.sun.star.beans.PropertyValue 5251ecadb57SMathias Bauer args(0).Name = "Text" 5261ecadb57SMathias Bauer args(0).Value = Content 5271ecadb57SMathias Bauer args(1).Name = "Author" 5281ecadb57SMathias Bauer args(1).Value = "Help Tooling - DO NOT EDIT" 5291ecadb57SMathias Bauer args(2).Name = "Date" 5301ecadb57SMathias Bauer args(2).Value = "02/27/2004" 5311ecadb57SMathias Bauer 5321ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:InsertAnnotation", "", 0, args()) 5331ecadb57SMathias Bauerend sub 5341ecadb57SMathias Bauer 5351ecadb57SMathias Bauer'======================================================= 5361ecadb57SMathias Bauer' InsertText 5371ecadb57SMathias Bauer'------------------------------------------------------- 5381ecadb57SMathias Bauer' Inserts a string at the current position 5391ecadb57SMathias Bauer'======================================================= 5401ecadb57SMathias BauerSub InsertText(strg As String) 5411ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 5421ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 5431ecadb57SMathias Bauer oCur.String = strg 5441ecadb57SMathias BauerEnd Sub 5451ecadb57SMathias Bauer 5461ecadb57SMathias Bauer'======================================================= 5471ecadb57SMathias Bauer' ParaIsEmpty 5481ecadb57SMathias Bauer'------------------------------------------------------- 5491ecadb57SMathias Bauer' Evaluates if a paragraph is empty. 5501ecadb57SMathias Bauer'======================================================= 5511ecadb57SMathias BauerFunction ParaIsEmpty 5521ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 5531ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 5541ecadb57SMathias Bauer oCur.gotoStartOfParagraph(0) 5551ecadb57SMathias Bauer ParaIsEmpty = oCur.IsEndOfParagraph 5561ecadb57SMathias BauerEnd Function 5571ecadb57SMathias Bauer 5581ecadb57SMathias Bauer'======================================================= 5591ecadb57SMathias Bauer' IsInBookmark 5601ecadb57SMathias Bauer'------------------------------------------------------- 5611ecadb57SMathias Bauer' Evaluates if the cursor is inside a <bookmark> </bookmark> element 5621ecadb57SMathias Bauer'======================================================= 5631ecadb57SMathias BauerFunction IsInBookmark 5641ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 5651ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 5661ecadb57SMathias Bauer 5671ecadb57SMathias Bauer If ((oCur.ParaStyleName = "hlp_aux_bookmark") AND (not(oCur.IsEndOfParagraph))) Then 5681ecadb57SMathias Bauer oCur.GotoStartOfParagraph(0) 5691ecadb57SMathias Bauer oCur.GotoEndOfParagraph(1) 5701ecadb57SMathias Bauer sText = Left(oCur.GetString,Instr(oCur.GetString,""" id=""")-1) 5711ecadb57SMathias Bauer sText = Right(sText,Len(sText)-InStr(sText,"""")) 5721ecadb57SMathias Bauer Select Case Left(sText,3) 5731ecadb57SMathias Bauer Case "ind" 5741ecadb57SMathias Bauer IsInBookmark = 1 5751ecadb57SMathias Bauer Case "hid" 5761ecadb57SMathias Bauer IsInBookmark = 2 5771ecadb57SMathias Bauer Case "con" 5781ecadb57SMathias Bauer IsInBookmark = 3 5791ecadb57SMathias Bauer Case Else 5801ecadb57SMathias Bauer IsInBookmark = 0 5811ecadb57SMathias Bauer End Select 5821ecadb57SMathias Bauer Else 5831ecadb57SMathias Bauer IsInBookmark = 0 5841ecadb57SMathias Bauer End If 5851ecadb57SMathias BauerEnd Function 5861ecadb57SMathias Bauer 5871ecadb57SMathias Bauer'======================================================= 5881ecadb57SMathias Bauer' IsInTable 5891ecadb57SMathias Bauer'------------------------------------------------------- 5901ecadb57SMathias Bauer' Evaluates if the cursor is in a table 5911ecadb57SMathias Bauer'======================================================= 5921ecadb57SMathias BauerFunction IsInTable 5931ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 5941ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 5951ecadb57SMathias Bauer 5961ecadb57SMathias Bauer IsInTable = (VarType(oCur.TextTable) <> 0) 5971ecadb57SMathias BauerEnd Function 5981ecadb57SMathias Bauer 5991ecadb57SMathias Bauer'======================================================= 6001ecadb57SMathias Bauer' InsertLink 6011ecadb57SMathias Bauer'------------------------------------------------------- 6021ecadb57SMathias Bauer' Inserts a hyperlink at the current position 6031ecadb57SMathias Bauer'======================================================= 6041ecadb57SMathias BauerSub InsertLink(sPath As String, sText As String, sName As String) 6051ecadb57SMathias Bauer dim document as object 6061ecadb57SMathias Bauer dim dispatcher as object 6071ecadb57SMathias Bauer 6081ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 6091ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 6101ecadb57SMathias Bauer 6111ecadb57SMathias Bauer dim args(4) as new com.sun.star.beans.PropertyValue 6121ecadb57SMathias Bauer args(0).Name = "Hyperlink.Text" 6131ecadb57SMathias Bauer args(0).Value = sText 6141ecadb57SMathias Bauer args(1).Name = "Hyperlink.URL" 6151ecadb57SMathias Bauer args(1).Value = sPath 6161ecadb57SMathias Bauer args(2).Name = "Hyperlink.Target" 6171ecadb57SMathias Bauer args(2).Value = "" 6181ecadb57SMathias Bauer args(3).Name = "Hyperlink.Name" 6191ecadb57SMathias Bauer args(3).Value = sName 6201ecadb57SMathias Bauer args(4).Name = "Hyperlink.Type" 6211ecadb57SMathias Bauer args(4).Value = 1 6221ecadb57SMathias Bauer 6231ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:SetHyperlink", "", 0, args()) 6241ecadb57SMathias Bauer args(0).Name = "Count" 6251ecadb57SMathias Bauer args(0).Value = 1 6261ecadb57SMathias Bauer args(1).Name = "Select" 6271ecadb57SMathias Bauer args(1).Value = false 6281ecadb57SMathias Bauer 6291ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args()) 6301ecadb57SMathias Bauer 6311ecadb57SMathias BauerEnd Sub 6321ecadb57SMathias Bauer 6331ecadb57SMathias Bauer'======================================================= 6341ecadb57SMathias Bauer' AssignMissingIDs 6351ecadb57SMathias Bauer'------------------------------------------------------- 6361ecadb57SMathias Bauer' Assigns IDs to elements that miss them 6371ecadb57SMathias Bauer'======================================================= 6381ecadb57SMathias BauerSub AssignMissingIDs 6391ecadb57SMathias Bauer' NOT IMPLEMENTED YET 6401ecadb57SMathias Bauerend sub 6411ecadb57SMathias Bauer 6421ecadb57SMathias Bauer'======================================================= 6431ecadb57SMathias Bauer' CreateTable 6441ecadb57SMathias Bauer'------------------------------------------------------- 6451ecadb57SMathias Bauer' Creates a new table 6461ecadb57SMathias Bauer'======================================================= 6471ecadb57SMathias BauerSub CreateTable(nRows as Integer, nCols as Integer, sID as String) 6481ecadb57SMathias Bauer dim document as object 6491ecadb57SMathias Bauer dim dispatcher as object 6501ecadb57SMathias Bauer 6511ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 6521ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 6531ecadb57SMathias Bauer 6541ecadb57SMathias Bauer dim args1(3) as new com.sun.star.beans.PropertyValue 6551ecadb57SMathias Bauer args1(0).Name = "TableName" 6561ecadb57SMathias Bauer args1(0).Value = sID 6571ecadb57SMathias Bauer args1(1).Name = "Columns" 6581ecadb57SMathias Bauer args1(1).Value = nCols 6591ecadb57SMathias Bauer args1(2).Name = "Rows" 6601ecadb57SMathias Bauer args1(2).Value = nRows 6611ecadb57SMathias Bauer args1(3).Name = "Flags" 6621ecadb57SMathias Bauer args1(3).Value = 9 6631ecadb57SMathias Bauer 6641ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:InsertTable", "", 0, args1()) 6651ecadb57SMathias Bauer 6661ecadb57SMathias Bauer args1(0).Name = "TopBottomMargin.TopMargin" 6671ecadb57SMathias Bauer args1(0).Value = 500 6681ecadb57SMathias Bauer args1(1).Name = "TopBottomMargin.BottomMargin" 6691ecadb57SMathias Bauer args1(1).Value = 0 6701ecadb57SMathias Bauer args1(2).Name = "TopBottomMargin.TopRelMargin" 6711ecadb57SMathias Bauer args1(2).Value = 100 6721ecadb57SMathias Bauer args1(3).Name = "TopBottomMargin.BottomRelMargin" 6731ecadb57SMathias Bauer args1(3).Value = 100 6741ecadb57SMathias Bauer 6751ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:TopBottomMargin", "", 0, args1()) 6761ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:SelectAll", "", 0, Array()) 6771ecadb57SMathias Bauer SetParaStyle("hlp_tablecontent") 6781ecadb57SMathias Bauer GoDown(1) 6791ecadb57SMathias Bauerend Sub 6801ecadb57SMathias Bauer 6811ecadb57SMathias Bauer'======================================================= 6821ecadb57SMathias Bauer' IsBlockImage 6831ecadb57SMathias Bauer'------------------------------------------------------- 6841ecadb57SMathias Bauer' Evaluates if the cursor is in a paragraph with 6851ecadb57SMathias Bauer' a block image (image in its own paragraph) 6861ecadb57SMathias Bauer'======================================================= 6871ecadb57SMathias BauerFunction IsBlockImage 6881ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 6891ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 6901ecadb57SMathias Bauer oCur.gotoStartOfParagraph(0) 6911ecadb57SMathias Bauer oCur.gotoEndOfParagraph(1) 6921ecadb57SMathias Bauer sStr = Right(oCur.String,Len(oCur.String)-InStr(oCur.String," ")) 'string must start with <IMG and end with IMG with no <IMG in between 6931ecadb57SMathias Bauer IsBlockImage = (not(Left(sStr,4)="IMG>") AND (Right(sStr,6)="</IMG>")) 6941ecadb57SMathias BauerEnd Function 6951ecadb57SMathias Bauer 6961ecadb57SMathias Bauer'======================================================= 6971ecadb57SMathias Bauer' HasCaption 6981ecadb57SMathias Bauer'------------------------------------------------------- 6991ecadb57SMathias Bauer' Evaluates if the current image has a caption element 7001ecadb57SMathias Bauer'======================================================= 7011ecadb57SMathias BauerFunction HasCaption 7021ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 7031ecadb57SMathias Bauer If oSel.ImplementationName = "SwXTextGraphicObject" Then 7041ecadb57SMathias Bauer oCur = oSel(0).getAnchor.getText.createTextCursorByRange(oSel(0).getAnchor) 7051ecadb57SMathias Bauer Else 7061ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 7071ecadb57SMathias Bauer End If 7081ecadb57SMathias Bauer oCur.gotoStartOfParagraph(0) 7091ecadb57SMathias Bauer oCur.gotoEndOfParagraph(1) 7101ecadb57SMathias Bauer HasCaption = (InStr(oCur.String,"<IMGCAPTION")>0) 7111ecadb57SMathias BauerEnd Function 7121ecadb57SMathias Bauer 7131ecadb57SMathias Bauer'======================================================= 7141ecadb57SMathias Bauer' GetImageID 7151ecadb57SMathias Bauer'------------------------------------------------------- 7161ecadb57SMathias Bauer' Returns the ID of an image at the cursor position 7171ecadb57SMathias Bauer'======================================================= 7181ecadb57SMathias BauerFunction GetImageID 7191ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 7201ecadb57SMathias Bauer If oSel.ImplementationName = "SwXTextGraphicObject" Then 7211ecadb57SMathias Bauer oCur = oSel(0).getAnchor.getText.createTextCursorByRange(oSel(0).getAnchor) 7221ecadb57SMathias Bauer Else 7231ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 7241ecadb57SMathias Bauer End If 7251ecadb57SMathias Bauer oCur.gotoStartOfParagraph(0) 7261ecadb57SMathias Bauer oCur.gotoEndOfParagraph(1) 7271ecadb57SMathias Bauer sStr = Right(oCur.String,Len(oCur.String)-(InStr(oCur.String,"IMG ID=""")+7)) 7281ecadb57SMathias Bauer GetImageID = Left(sStr,InStr(sStr,""">")+1) 'string must start with <IMG and end with IMG with no <IMG in between 7291ecadb57SMathias BauerEnd Function 7301ecadb57SMathias Bauer 7311ecadb57SMathias Bauer'======================================================= 7321ecadb57SMathias Bauer' SelAll 7331ecadb57SMathias Bauer'------------------------------------------------------- 7341ecadb57SMathias Bauer' Selects everything 7351ecadb57SMathias Bauer'======================================================= 7361ecadb57SMathias BauerSub SelAll 7371ecadb57SMathias Bauer dim document as object 7381ecadb57SMathias Bauer dim dispatcher as object 7391ecadb57SMathias Bauer 7401ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 7411ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 7421ecadb57SMathias Bauer 7431ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:SelectAll", "", 0, Array()) 7441ecadb57SMathias BauerEnd Sub 7451ecadb57SMathias Bauer 7461ecadb57SMathias Bauer'======================================================= 7471ecadb57SMathias Bauer' GetParaData 7481ecadb57SMathias Bauer'------------------------------------------------------- 7491ecadb57SMathias Bauer' Returns the Paragraph ID and localization status 7501ecadb57SMathias Bauer'======================================================= 7511ecadb57SMathias BauerFunction GetParaData 7521ecadb57SMathias Bauer arParaData = Array("","","") ' ID, localize, #message 7531ecadb57SMathias Bauer 7541ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 7551ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 7561ecadb57SMathias Bauer oCur.gotoStartOfParagraph(0) 7571ecadb57SMathias Bauer oCur.gotoEndOfParagraph(1) 7581ecadb57SMathias Bauer sID = "" 7591ecadb57SMathias Bauer Enum = oCur.createEnumeration 7601ecadb57SMathias Bauer Fd = FALSE 7611ecadb57SMathias Bauer 7621ecadb57SMathias Bauer 7631ecadb57SMathias Bauer TE = Enum.nextElement 7641ecadb57SMathias Bauer 7651ecadb57SMathias Bauer TP = TE.createEnumeration 7661ecadb57SMathias Bauer Ct = 0 7671ecadb57SMathias Bauer posID = 0 7681ecadb57SMathias Bauer 7691ecadb57SMathias Bauer Do While TP.hasmoreElements 7701ecadb57SMathias Bauer Ct = Ct+1 7711ecadb57SMathias Bauer TPE = TP.nextElement 7721ecadb57SMathias Bauer If TPE.TextPortionType="TextField" Then 7731ecadb57SMathias Bauer If TPE.TextField.TextFieldMaster.Name="ID" Then 7741ecadb57SMathias Bauer sID = TPE.TextField.Content 7751ecadb57SMathias Bauer Fd = TRUE 7761ecadb57SMathias Bauer Exit Do 7771ecadb57SMathias Bauer End If 7781ecadb57SMathias Bauer End If 7791ecadb57SMathias Bauer If TPE.String = "" Then 7801ecadb57SMathias Bauer Ct = Ct-1 7811ecadb57SMathias Bauer End If 7821ecadb57SMathias Bauer Loop 7831ecadb57SMathias Bauer 7841ecadb57SMathias Bauer If ((Left(oCur.ParaStyleName,8) = "hlp_aux_") or (Left(oCur.ParaStyleName,4) <> "hlp_")) Then 7851ecadb57SMathias Bauer arParaData(2)="Invalid Paragraph Style" 7861ecadb57SMathias Bauer GetParaData = arParaData 7871ecadb57SMathias Bauer Exit Function 7881ecadb57SMathias Bauer End If 7891ecadb57SMathias Bauer 7901ecadb57SMathias Bauer If sID = "" Then 7911ecadb57SMathias Bauer GetParaData = arParaData 7921ecadb57SMathias Bauer Exit Function 7931ecadb57SMathias Bauer End If 7941ecadb57SMathias Bauer 7951ecadb57SMathias Bauer If Right(sID,7) = "_NOL10N" Then 7961ecadb57SMathias Bauer arParaData(0) = Left(sID,Len(sID)-7) 7971ecadb57SMathias Bauer arParaData(1) = "no" 7981ecadb57SMathias Bauer Else 7991ecadb57SMathias Bauer arParaData(0) = sID 8001ecadb57SMathias Bauer arParaData(1) = "yes" 8011ecadb57SMathias Bauer End If 8021ecadb57SMathias Bauer 8031ecadb57SMathias Bauer GetParaData = arParaData 8041ecadb57SMathias BauerEnd Function 8051ecadb57SMathias Bauer 8061ecadb57SMathias Bauer'======================================================= 8071ecadb57SMathias Bauer' SetsParaData 8081ecadb57SMathias Bauer'------------------------------------------------------- 8091ecadb57SMathias Bauer' Sets the Paragraph ID and localization status 8101ecadb57SMathias Bauer'======================================================= 8111ecadb57SMathias Bauer 8121ecadb57SMathias BauerSub SetParaData(sID as String, sLocalize as String) 8131ecadb57SMathias Bauer 8141ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 8151ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 8161ecadb57SMathias Bauer oCur.gotoStartOfParagraph(0) 8171ecadb57SMathias Bauer oCur.gotoEndOfParagraph(1) 8181ecadb57SMathias Bauer Enum = oCur.createEnumeration 8191ecadb57SMathias Bauer Fd = FALSE 8201ecadb57SMathias Bauer 8211ecadb57SMathias Bauer 8221ecadb57SMathias Bauer Do While Enum.hasMoreElements 8231ecadb57SMathias Bauer TE = Enum.nextElement 8241ecadb57SMathias Bauer 8251ecadb57SMathias Bauer TP = TE.createEnumeration 8261ecadb57SMathias Bauer Ct = 0 8271ecadb57SMathias Bauer posID = 0 8281ecadb57SMathias Bauer 8291ecadb57SMathias Bauer Do While TP.hasmoreElements 8301ecadb57SMathias Bauer Ct = Ct+1 8311ecadb57SMathias Bauer TPE = TP.nextElement 8321ecadb57SMathias Bauer If TPE.TextPortionType="TextField" Then 8331ecadb57SMathias Bauer If TPE.TextField.TextFieldMaster.Name="ID" Then 8341ecadb57SMathias Bauer posID = Ct 8351ecadb57SMathias Bauer If sLocalize = "no" Then 8361ecadb57SMathias Bauer TPE.TextField.Content = sID+"_NOL10N" 8371ecadb57SMathias Bauer TPE.TextField.IsVisible = TRUE 8381ecadb57SMathias Bauer ElseIf sLocalize = "yes" Then 8391ecadb57SMathias Bauer TPE.TextField.Content = sID 8401ecadb57SMathias Bauer TPE.TextField.IsVisible = TRUE 8411ecadb57SMathias Bauer Else 8421ecadb57SMathias Bauer msgbox "Unknown localization parameter: "+sLocalize,0,"Error" 8431ecadb57SMathias Bauer End If 8441ecadb57SMathias Bauer Fd = TRUE 8451ecadb57SMathias Bauer Exit Do 8461ecadb57SMathias Bauer End If 8471ecadb57SMathias Bauer End If 8481ecadb57SMathias Bauer If TPE.String = "" Then 8491ecadb57SMathias Bauer Ct = Ct-1 8501ecadb57SMathias Bauer End If 8511ecadb57SMathias Bauer Loop 8521ecadb57SMathias Bauer If Fd Then 8531ecadb57SMathias Bauer Exit Do 8541ecadb57SMathias Bauer End If 8551ecadb57SMathias Bauer Loop 8561ecadb57SMathias Bauer 8571ecadb57SMathias Bauer oCur.TextField.update 8581ecadb57SMathias Bauer UpdateFields 8591ecadb57SMathias Bauer 8601ecadb57SMathias BauerEnd Sub 8611ecadb57SMathias Bauer 8621ecadb57SMathias Bauer 8631ecadb57SMathias Bauer'======================================================= 8641ecadb57SMathias Bauer' IsInList 8651ecadb57SMathias Bauer'------------------------------------------------------- 8661ecadb57SMathias Bauer' Evaluates if the cursor is inside a list (ordered or unordered) 8671ecadb57SMathias Bauer'======================================================= 8681ecadb57SMathias BauerFunction IsInList 8691ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 8701ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 8711ecadb57SMathias Bauer If oCur.NumberingStyleName = "" Then 8721ecadb57SMathias Bauer IsInList = false 8731ecadb57SMathias Bauer ElseIf oCur.NumberingRules.NumberingIsOutline = true Then 8741ecadb57SMathias Bauer IsInList = false 8751ecadb57SMathias Bauer Else 8761ecadb57SMathias Bauer IsInList = true 8771ecadb57SMathias Bauer End If 8781ecadb57SMathias BauerEnd Function 8791ecadb57SMathias Bauer 8801ecadb57SMathias Bauer'======================================================= 8811ecadb57SMathias Bauer' TagFormatIsCorrect 8821ecadb57SMathias Bauer'------------------------------------------------------- 8831ecadb57SMathias Bauer' Checks for correct paragraph format for tags 8841ecadb57SMathias Bauer'======================================================= 8851ecadb57SMathias BauerFunction TagFormatIsCorrect(sTN As String, sPS As String) 8861ecadb57SMathias Bauer 8871ecadb57SMathias Bauer arTag = Array("BOOKMARK","SORT","SECTION","SWITCH","CASE","DEFAULT") 8881ecadb57SMathias Bauer arTagFormat = Array("hlp_aux_bookmark","hlp_aux_sort","hlp_aux_section","hlp_aux_switch","hlp_aux_switch","hlp_aux_switch") 8891ecadb57SMathias Bauer 8901ecadb57SMathias Bauer For n=0 to ubound(arTag) 8911ecadb57SMathias Bauer If (sTN = arTag(n) AND sPS <> arTagFormat(n)) Then 8921ecadb57SMathias Bauer TagFormatIsCorrect = arTagFormat(n) 8931ecadb57SMathias Bauer Exit Function 8941ecadb57SMathias Bauer End If 8951ecadb57SMathias Bauer TagFormatIsCorrect = "" 8961ecadb57SMathias Bauer Next n 8971ecadb57SMathias Bauer 8981ecadb57SMathias BauerEnd Function 8991ecadb57SMathias Bauer 9001ecadb57SMathias Bauer'======================================================= 9011ecadb57SMathias Bauer' GetFilePath 9021ecadb57SMathias Bauer'------------------------------------------------------- 9031ecadb57SMathias Bauer' look for the "text/..." part of the file name and separate it 9041ecadb57SMathias Bauer'======================================================= 9051ecadb57SMathias BauerFunction GetFilePath(fname As String) 9061ecadb57SMathias Bauer 9071ecadb57SMathias Bauer i = 1 9081ecadb57SMathias Bauer Do 9091ecadb57SMathias Bauer If (Mid(fname,i,5) = "text/") Then 9101ecadb57SMathias Bauer Strg = Mid(fname,i,Len(fname)-i+1) 9111ecadb57SMathias Bauer Exit Do 9121ecadb57SMathias Bauer Else 9131ecadb57SMathias Bauer i = i+1 9141ecadb57SMathias Bauer Strg = fname 9151ecadb57SMathias Bauer End If 9161ecadb57SMathias Bauer Loop While (i+5 < Len(fname)) 9171ecadb57SMathias Bauer GetFilePath = Strg 9181ecadb57SMathias BauerEnd Function 9191ecadb57SMathias Bauer 9201ecadb57SMathias Bauer'======================================================= 9211ecadb57SMathias Bauer' OpenGraphics 9221ecadb57SMathias Bauer'------------------------------------------------------- 9231ecadb57SMathias Bauer' Calls the graphic open dialog for inserting an image 9241ecadb57SMathias Bauer'======================================================= 9251ecadb57SMathias BauerFunction OpenGraphics(oDoc As Object) 9261ecadb57SMathias BauerDim ListAny(0) as Long 9271ecadb57SMathias BauerDim oStoreProperties(0) as New com.sun.star.beans.PropertyValue 9281ecadb57SMathias Bauer GlobalScope.BasicLibraries.loadLibrary("Tools") 9291ecadb57SMathias Bauer ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE 9301ecadb57SMathias Bauer' ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE 9311ecadb57SMathias Bauer oFileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker") 9321ecadb57SMathias Bauer oFileDialog.Initialize(ListAny()) 9331ecadb57SMathias Bauer 9341ecadb57SMathias Bauer sLastImgDir = ReadConfig("LastImgDir") 9351ecadb57SMathias Bauer If sLastImgDir <> "" Then 9361ecadb57SMathias Bauer oFileDialog.setDisplayDirectory(sLastImgDir) 9371ecadb57SMathias Bauer End If 9381ecadb57SMathias Bauer 9391ecadb57SMathias Bauer oMasterKey = GetRegistryKeyContent("org.openoffice.TypeDetection.Types/") 9401ecadb57SMathias Bauer oTypes() = oMasterKey.Types 9411ecadb57SMathias Bauer 9421ecadb57SMathias Bauer oFileDialog.AppendFilter(oTypes.GetByName("gif_Graphics_Interchange").UIName, "*.gif") 9431ecadb57SMathias Bauer oFileDialog.AppendFilter(oTypes.GetByName("png_Portable_Network_Graphic").UIName, "*.png") 9441ecadb57SMathias Bauer 9451ecadb57SMathias Bauer oFileDialog.SetTitle("Insert Image") 9461ecadb57SMathias Bauer iAccept = oFileDialog.Execute() 9471ecadb57SMathias Bauer If iAccept = 1 Then 9481ecadb57SMathias Bauer sPath = oFileDialog.Files(0) 9491ecadb57SMathias Bauer WriteConfig("LastImgDir",oFileDialog.getDisplayDirectory) 9501ecadb57SMathias Bauer UIFilterName = oFileDialog.GetCurrentFilter() 9511ecadb57SMathias Bauer OpenGraphics = oFileDialog.Files(0) 9521ecadb57SMathias Bauer Else 9531ecadb57SMathias Bauer OpenGraphics = "" 9541ecadb57SMathias Bauer End If 9551ecadb57SMathias Bauer oFileDialog.Dispose() 9561ecadb57SMathias BauerEnd Function 9571ecadb57SMathias Bauer 9581ecadb57SMathias Bauer'======================================================= 9591ecadb57SMathias Bauer' WriteConfig 9601ecadb57SMathias Bauer'------------------------------------------------------- 9611ecadb57SMathias Bauer' Reads a parameter value from the config file 9621ecadb57SMathias Bauer'======================================================= 9631ecadb57SMathias BauerFunction ReadConfig(Parm As String) 9641ecadb57SMathias Bauer oPath = createUNOService("com.sun.star.util.PathSettings") 9651ecadb57SMathias Bauer filename = oPath.UserConfig+"/helpauthoring.cfg" 9661ecadb57SMathias Bauer iNumber = Freefile 9671ecadb57SMathias Bauer bFound = false 9681ecadb57SMathias Bauer If FileExists(filename) Then 9691ecadb57SMathias Bauer Open filename For Input As iNumber 9701ecadb57SMathias Bauer Do While (not eof(iNumber) AND not(bFound)) 9711ecadb57SMathias Bauer Line Input #iNumber, sLine 9721ecadb57SMathias Bauer If InStr(sLine, "=") > 0 Then 9731ecadb57SMathias Bauer arLine = split(sLine,"=") 9741ecadb57SMathias Bauer If arLine(0) = Parm Then 9751ecadb57SMathias Bauer sResult = arLine(1) 9761ecadb57SMathias Bauer bFound = true 9771ecadb57SMathias Bauer End If 9781ecadb57SMathias Bauer End If 9791ecadb57SMathias Bauer Loop 9801ecadb57SMathias Bauer Close #iNumber 9811ecadb57SMathias Bauer If bFound Then 9821ecadb57SMathias Bauer ReadConfig = sResult 9831ecadb57SMathias Bauer Else 9841ecadb57SMathias Bauer ReadConfig = "" 9851ecadb57SMathias Bauer End If 9861ecadb57SMathias Bauer Else 9871ecadb57SMathias Bauer ReadConfig = "" 9881ecadb57SMathias Bauer End If 9891ecadb57SMathias BauerEnd Function 9901ecadb57SMathias Bauer 9911ecadb57SMathias Bauer 9921ecadb57SMathias Bauer'======================================================= 9931ecadb57SMathias Bauer' WriteConfig 9941ecadb57SMathias Bauer'------------------------------------------------------- 9951ecadb57SMathias Bauer' Writes a parameter/value pair to the config file 9961ecadb57SMathias Bauer'======================================================= 9971ecadb57SMathias BauerFunction WriteConfig(Parm As String, Value As String) 9981ecadb57SMathias Bauer Dim arLines(0) As String 9991ecadb57SMathias Bauer bFound = false 10001ecadb57SMathias Bauer oPath = createUNOService("com.sun.star.util.PathSettings") 10011ecadb57SMathias Bauer filename = oPath.UserConfig+"/helpauthoring.cfg" 10021ecadb57SMathias Bauer iNumber = Freefile 10031ecadb57SMathias Bauer If FileExists(filename) Then 10041ecadb57SMathias Bauer 10051ecadb57SMathias Bauer Open filename For Input As iNumber 10061ecadb57SMathias Bauer Do While (not eof(iNumber)) 10071ecadb57SMathias Bauer Line Input #iNumber, sLine 10081ecadb57SMathias Bauer If InStr(sLine, "=") > 0 Then 10091ecadb57SMathias Bauer sDim = ubound(arLines())+1 10101ecadb57SMathias Bauer ReDim Preserve arLines(sDim) 10111ecadb57SMathias Bauer arLines(sDim) = sLine 10121ecadb57SMathias Bauer End If 10131ecadb57SMathias Bauer Loop 10141ecadb57SMathias Bauer Close #iNumber 10151ecadb57SMathias Bauer 10161ecadb57SMathias Bauer nLine = 1 10171ecadb57SMathias Bauer Do While (nLine <= ubound(arLines())) and (not bFound) 10181ecadb57SMathias Bauer arLine = split(arLines(nLine),"=") 10191ecadb57SMathias Bauer If arLine(0) = Parm Then 10201ecadb57SMathias Bauer arLines(nLine) = Parm+"="+Value 10211ecadb57SMathias Bauer bFound = true 10221ecadb57SMathias Bauer End If 10231ecadb57SMathias Bauer nLine = nLine +1 10241ecadb57SMathias Bauer Loop 10251ecadb57SMathias Bauer 10261ecadb57SMathias Bauer nLine = 1 10271ecadb57SMathias Bauer Open filename For Output As iNumber 10281ecadb57SMathias Bauer Do While (nLine <= ubound(arLines())) 10291ecadb57SMathias Bauer Print #iNumber, arLines(nLine) 10301ecadb57SMathias Bauer nLine = nLine + 1 10311ecadb57SMathias Bauer Loop 10321ecadb57SMathias Bauer If (not bFound) Then 10331ecadb57SMathias Bauer Print #iNumber, Parm+"="+Value 10341ecadb57SMathias Bauer End If 10351ecadb57SMathias Bauer Close #iNumber 10361ecadb57SMathias Bauer 10371ecadb57SMathias Bauer Else 10381ecadb57SMathias Bauer Open filename For Output As iNumber 10391ecadb57SMathias Bauer Print #iNumber, Parm+"="+Value 10401ecadb57SMathias Bauer Close #iNumber 10411ecadb57SMathias Bauer End If 10421ecadb57SMathias BauerEnd Function 10431ecadb57SMathias Bauer 10441ecadb57SMathias BauerFunction GetRelPath(sPath As String) 10451ecadb57SMathias Bauer sHelpPrefix = ReadConfig("HelpPrefix") 10461ecadb57SMathias Bauer If sHelpPrefix = "" Then 10471ecadb57SMathias Bauer sHelpPrefix = SetDocumentRoot 10481ecadb57SMathias Bauer End If 10491ecadb57SMathias Bauer GetRelPath = Right(sPath, Len(sPath)-(InStr(sPath,sHelpPrefix) + Len(sHelpPrefix)-1)) 10501ecadb57SMathias BauerEnd Function 10511ecadb57SMathias Bauer 10521ecadb57SMathias BauerFunction SetDocumentRoot 10531ecadb57SMathias Bauer sHelpPrefix = ReadConfig("HelpPrefix") 10541ecadb57SMathias Bauer oFolderDialog = CreateUnoService("com.sun.star.ui.dialogs.FolderPicker") 10551ecadb57SMathias Bauer oFolderDialog.SetTitle("Select Document Root Folder") 10561ecadb57SMathias Bauer If sHelpPrefix > "" Then 10571ecadb57SMathias Bauer oFolderDialog.setDisplayDirectory(sHelpPrefix) 10581ecadb57SMathias Bauer End If 10591ecadb57SMathias Bauer iAccept = oFolderDialog.Execute() 10601ecadb57SMathias Bauer 10611ecadb57SMathias Bauer If iAccept = 1 Then 10621ecadb57SMathias Bauer sHelpPrefix = oFolderDialog.getDirectory + "/" 10631ecadb57SMathias Bauer WriteConfig("HelpPrefix",sHelpPrefix) 10641ecadb57SMathias Bauer End If 10651ecadb57SMathias Bauer 10661ecadb57SMathias Bauer SetDocumentRoot = sHelpPrefix 10671ecadb57SMathias BauerEnd Function 10681ecadb57SMathias Bauer 10691ecadb57SMathias BauerFunction MakeAbsPath(sPath As String) 10701ecadb57SMathias Bauer 10711ecadb57SMathias Bauer sHelpPrefix = ReadConfig("HelpPrefix") 10721ecadb57SMathias Bauer If sHelpPrefix = "" Then 10731ecadb57SMathias Bauer sHelpPrefix = SetDocumentRoot 10741ecadb57SMathias Bauer End If 10751ecadb57SMathias Bauer 10761ecadb57SMathias Bauer If Right(sPath,4) <> ".xhp" Then 10771ecadb57SMathias Bauer sPath=sPath+".xhp" 10781ecadb57SMathias Bauer End If 10791ecadb57SMathias Bauer MakeAbsPath = sHelpPrefix+sPath 10801ecadb57SMathias BauerEnd Function 10811ecadb57SMathias Bauer 10821ecadb57SMathias Bauer 10831ecadb57SMathias BauerSub UpdateFields 10841ecadb57SMathias Bauer dim document as object 10851ecadb57SMathias Bauer dim dispatcher as object 10861ecadb57SMathias Bauer document = ThisComponent.CurrentController.Frame 10871ecadb57SMathias Bauer dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 10881ecadb57SMathias Bauer 10891ecadb57SMathias Bauer dispatcher.executeDispatch(document, ".uno:UpdateFields", "", 0, Array()) 10901ecadb57SMathias BauerEnd Sub 10911ecadb57SMathias Bauer 10921ecadb57SMathias BauerFunction IsHelpFile 10931ecadb57SMathias Bauer document = StarDesktop.CurrentComponent 10941ecadb57SMathias Bauer IsHelpFile = (Right(GetFilePath(document.URL),4)=".xhp") 10951ecadb57SMathias BauerEnd Function 10961ecadb57SMathias Bauer 10971ecadb57SMathias BauerFunction GetUserFieldNumber(fn as String) 10981ecadb57SMathias Bauer fnum = -1 10991ecadb57SMathias Bauer For a=0 to document.DocumentInfo.getUserFieldCount - 1 11001ecadb57SMathias Bauer If document.DocumentInfo.getUserFieldName(a) = fn Then 11011ecadb57SMathias Bauer fnum = a 11021ecadb57SMathias Bauer Exit for 11031ecadb57SMathias Bauer End If 11041ecadb57SMathias Bauer Next a 11051ecadb57SMathias Bauer GetUserFieldNumber = fnum 11061ecadb57SMathias BauerEnd Function 1107*3e02b54dSAndrew Rist</script:module> 1108