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="TOC" script:language="StarBasic">REM ***** BASIC ***** 241ecadb57SMathias Bauer 251ecadb57SMathias BauerDim oDialog AS Object 261ecadb57SMathias BauerDim document AS Object 271ecadb57SMathias Bauer 281ecadb57SMathias BauerSub Main 291ecadb57SMathias Bauer document = StarDesktop.CurrentComponent 301ecadb57SMathias Bauer 311ecadb57SMathias Bauer BasicLibraries.LoadLibrary("HelpAuthoring") 321ecadb57SMathias Bauer oDialog = LoadDialog("HelpAuthoring", "dlgTOC") 331ecadb57SMathias Bauer oDialogModel = oDialog.Model 341ecadb57SMathias Bauer 351ecadb57SMathias Bauer ocbAddTag = oDialog.GetControl("cbAddTag") 361ecadb57SMathias Bauer 371ecadb57SMathias Bauer ' Check if bookmarks are allowed here 381ecadb57SMathias Bauer If IsInList Then 391ecadb57SMathias Bauer msgbox "No Bookmarks allowed inside a list.", 48, "D'oh!" 401ecadb57SMathias Bauer Exit Sub 411ecadb57SMathias Bauer End If 421ecadb57SMathias Bauer 431ecadb57SMathias Bauer nBookmarkType = IsInBookmark 441ecadb57SMathias Bauer If nBookmarkType = 3 Then ' inside TOC bookmark 451ecadb57SMathias Bauer ocbAddTag.State = 0 461ecadb57SMathias Bauer End If 471ecadb57SMathias Bauer 481ecadb57SMathias Bauer If oDialog.Execute() = 1 Then 491ecadb57SMathias Bauer ' Insert the bookmark construction 501ecadb57SMathias Bauer olbTOC = oDialog.GetControl("lbTOC") 511ecadb57SMathias Bauer 521ecadb57SMathias Bauer If nBookmarkType = 0 Then' not in a bookmark, always add parent tags 531ecadb57SMathias Bauer bmid = CreateID 541ecadb57SMathias Bauer ' now check if we are in a para with text (this wouldn't be valid) 551ecadb57SMathias Bauer If Not(ParaIsEmpty) Then 561ecadb57SMathias Bauer CR 571ecadb57SMathias Bauer End If 581ecadb57SMathias Bauer InsertTag("BOOKMARK_","<BOOKMARK branch=""contents"" id=""bm_id" + bmid + """>","hlp_aux_bookmark") 591ecadb57SMathias Bauer For i=0 to ubound(olbTOC.Items) 601ecadb57SMathias Bauer LF 611ecadb57SMathias Bauer InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>") 621ecadb57SMathias Bauer InsertField("BOOKMARKVALUE",olbTOC.Items(i)) 631ecadb57SMathias Bauer InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>") 641ecadb57SMathias Bauer Next i 651ecadb57SMathias Bauer LF 661ecadb57SMathias Bauer InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark") 671ecadb57SMathias Bauer 681ecadb57SMathias Bauer ElseIf nBookmarkType = 3 Then ' correct bookmark type 691ecadb57SMathias Bauer If ocbAddTag.State = 1 Then 701ecadb57SMathias Bauer bmid = CreateID 711ecadb57SMathias Bauer ' now check if we are in a para with text (this wouldn't be valid) 721ecadb57SMathias Bauer If Not(ParaIsEmpty) Then 731ecadb57SMathias Bauer CR 741ecadb57SMathias Bauer End If 751ecadb57SMathias Bauer InsertTag("BOOKMARK_","<BOOKMARK branch=""contents"" id=""bm_id" + bmid + """>","hlp_aux_bookmark") 761ecadb57SMathias Bauer End If 771ecadb57SMathias Bauer For i=0 to ubound(olbTOC.Items) 781ecadb57SMathias Bauer LF 791ecadb57SMathias Bauer InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>") 801ecadb57SMathias Bauer InsertField("BOOKMARKVALUE",olbTOC.Items(i)) 811ecadb57SMathias Bauer InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>") 821ecadb57SMathias Bauer Next i 831ecadb57SMathias Bauer If ocbAddTag.State = 1 Then 841ecadb57SMathias Bauer LF 851ecadb57SMathias Bauer InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark") 861ecadb57SMathias Bauer End If 871ecadb57SMathias Bauer Else ' wrong bookmark type 881ecadb57SMathias Bauer bmid = CreateID 891ecadb57SMathias Bauer ' now check if we are in a para with text (this wouldn't be valid) 901ecadb57SMathias Bauer If Not(ParaIsEmpty) Then 911ecadb57SMathias Bauer CR 921ecadb57SMathias Bauer End If 931ecadb57SMathias Bauer InsertTag("BOOKMARK_","<BOOKMARK branch=""contents"" id=""bm_id" + bmid + """>","hlp_aux_bookmark") 941ecadb57SMathias Bauer For i=0 to ubound(olbTOC.Items) 951ecadb57SMathias Bauer LF 961ecadb57SMathias Bauer InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>") 971ecadb57SMathias Bauer InsertField("BOOKMARKVALUE",olbTOC.Items(i)) 981ecadb57SMathias Bauer InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>") 991ecadb57SMathias Bauer Next i 1001ecadb57SMathias Bauer LF 1011ecadb57SMathias Bauer InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark") 1021ecadb57SMathias Bauer End If 1031ecadb57SMathias Bauer 1041ecadb57SMathias Bauer End If 1051ecadb57SMathias Bauer oDialog.dispose 1061ecadb57SMathias Bauer 1071ecadb57SMathias BauerEnd Sub 1081ecadb57SMathias Bauer 1091ecadb57SMathias BauerSub RemoveKeyStroke(Event As Object) 1101ecadb57SMathias Bauer Select Case Event.KeyCode 1111ecadb57SMathias Bauer Case com.sun.star.awt.Key.RETURN 1121ecadb57SMathias Bauer RemoveIndexEntry 1131ecadb57SMathias Bauer Case com.sun.star.awt.Key.SPACE 1141ecadb57SMathias Bauer RemoveIndexEntry 1151ecadb57SMathias Bauer End Select 1161ecadb57SMathias BauerEnd Sub 1171ecadb57SMathias Bauer 1181ecadb57SMathias Bauer 1191ecadb57SMathias BauerSub RemoveTOCEntry 1201ecadb57SMathias Bauer olbTOC = oDialog.GetControl("lbTOC") 1211ecadb57SMathias Bauer ItemsPos = olbTOC.getSelectedItemsPos 1221ecadb57SMathias Bauer For i=0 to ubound(ItemsPos) 1231ecadb57SMathias Bauer olbTOC.removeItems(ItemsPos(i)-i,1) 1241ecadb57SMathias Bauer Next i 1251ecadb57SMathias BauerEnd Sub 1261ecadb57SMathias Bauer 1271ecadb57SMathias BauerSub KeyPressedRemove(Event As Object) 1281ecadb57SMathias Bauer Select Case Event.KeyCode 1291ecadb57SMathias Bauer Case com.sun.star.awt.Key.DELETE 1301ecadb57SMathias Bauer RemoveTOCEntry 1311ecadb57SMathias Bauer End Select 1321ecadb57SMathias BauerEnd Sub 1331ecadb57SMathias Bauer 1341ecadb57SMathias BauerSub AddKeyStroke(Event As Object) 1351ecadb57SMathias Bauer Select Case Event.KeyCode 1361ecadb57SMathias Bauer Case com.sun.star.awt.Key.RETURN 1371ecadb57SMathias Bauer AddTOCEntry 1381ecadb57SMathias Bauer Case com.sun.star.awt.Key.SPACE 1391ecadb57SMathias Bauer AddTOCEntry 1401ecadb57SMathias Bauer End Select 1411ecadb57SMathias BauerEnd Sub 1421ecadb57SMathias Bauer 1431ecadb57SMathias BauerSub AddTOCEntry 1441ecadb57SMathias Bauer oTxtTOC = oDialog.GetControl("txtTOC") 1451ecadb57SMathias Bauer If (oTxtTOC.Text = "") Then 1461ecadb57SMathias Bauer msgbox "Enter a TOC entry first." 1471ecadb57SMathias Bauer Else 1481ecadb57SMathias Bauer ' Insert the index entry into the list 1491ecadb57SMathias Bauer olbTOC = oDialog.GetControl("lbTOC") 1501ecadb57SMathias Bauer olbTOC.addItem(oTxtTOC.Text,0) 1511ecadb57SMathias Bauer End If 1521ecadb57SMathias Bauer 1531ecadb57SMathias BauerEnd Sub 1541ecadb57SMathias Bauer 1551ecadb57SMathias Bauer 156*3e02b54dSAndrew Rist</script:module> 157