1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3<!--*********************************************************** 4 * 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file 9 * to you under the Apache License, Version 2.0 (the 10 * "License"); you may not use this file except in compliance 11 * with the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 * 22 ***********************************************************--> 23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="OtherElements" script:language="StarBasic">REM ***** BASIC ***** 24 25Sub Main 26 27End Sub 28 29Sub InsertVariable 30 31 If not IsHelpFile Then 32 msgbox(strErr_NoHelpFile) 33 Exit Sub 34 End If 35 36 oSel = thiscomponent.getcurrentcontroller.getselection 37 oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 38 oStart = oCur.getStart 39 oCurStart = oStart.getText.createTextCursorByRange(oStart) 40 oEnd = oCur.getEnd 41 oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) 42 43 ID = inputbox("Enter an identifier for the variable element:","Enter Variable ID") 44 45 If ID="" Then 46 Exit Sub 47 End If 48 49 thiscomponent.getcurrentcontroller.select(oCurStart) 50 InsertTag("VAR_","<VAR ID="""+ID+""">") 51 thiscomponent.getcurrentcontroller.select(oCurEnd) 52 InsertTag("_VAR","</VAR>") 53End Sub 54 55Sub InsertInlineGraphic 56 If not IsHelpFile Then 57 msgbox(strErr_NoHelpFile) 58 Exit Sub 59 End If 60 sFName = OpenGraphics 61 If sFName <> "" Then 62 sAlt = InputBox("Enter an alternative Text for the graphical element."+chr(13)+"This can be changed later in the image properties.","ALT description","<ALT DESCRIPTION>") 63 sID = "img_id"+CreateID 64 InsertTag("IMG_","<IMG ID="""+sID+""">") 65 InsertGraphicFile(sFName,sID,sAlt) 66 InsertTag("_IMG","</IMG>") 67 End If 68End Sub 69 70Sub InsertGraphic 71 72 If not IsHelpFile Then 73 msgbox(strErr_NoHelpFile) 74 Exit Sub 75 End If 76 77 GlobalScope.BasicLibraries.loadLibrary("Tools") 78 sFName = OpenGraphics 79 If sFName <> "" Then 80 DocRoot = ReadConfig("HelpPrefix") 81' msgbox("DocRoot "+DocRoot+chr(13)+"FName "+sFName) 82 83 If not(IsSubDir(sFName,DocRoot)) Then 84 msgbox("Image is located outside of your Document Root"+chr(13)+DocRoot,48,"Warning") 85 End If 86 87 sAlt = InputBox("Enter an alternative Text for the graphical element."+chr(13)+"This can be changed later in the image properties.","ALT description","<ALT DESCRIPTION>") 88' sCap = InputBox("Enter a caption for the image (optional)","Caption","") 89 sID = CreateID 90 CR 91 InsertTag("IMG_","<IMG ID="""+"img_id"+sID+""">") 92 InsertGraphicFile(sFName,"img_id"+sID,sAlt) 93' If sCap <> "" Then 94' InsertCaption(sCap,"cap_id"+sID) 95' End If 96 InsertTag("_IMG","</IMG>") 97 End If 98End Sub 99 100 101Sub InsertGraphicFile(sURL As String, sName As String, sAlt As String) 102 oSel = thiscomponent.getcurrentcontroller.getselection 103 oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 104 oDoc = StarDesktop.CurrentComponent 105 oGrp = oDoc.createInstance("com.sun.star.text.GraphicObject") 106 oGrp.GraphicURL = sURL 107 oGrp.AnchorType = 1 108 oGrp.Name = sName 109 oGrp.Title = sAlt 110 oCur.Text.InsertTextContent(oCur,oGrp,true) 111End Sub 112 113Sub SpecifyCaption 114 'check if the image allows captions 115 If thiscomponent.getcurrentcontroller.getselection.ImplementationName = "SwXTextGraphicObject" Then 116 msgbox "Please press ESCAPE to deselect the image and recall the menu item" 117 Exit Sub 118 End If 119 If IsBlockImage Then 120 If not(HasCaption) Then 121 sCap = InputBox("Enter a caption for the image (optional)","Caption","") 122 If sCap <> "" Then 123 sID = GetImageID 124 sID = "cap"+right(sID, Len(sID)-3) 125 GoLeft(1) 126 InsertCaption(sCap, sID) 127 End If 128 Else 129 msgbox "Image has a caption already.",0,"D'oh!" 130 End If 131 Else 132 msgbox "Only block images may have captions.",0,"D'oh!" 133 End If 134End Sub 135 136Sub InsertCaption(sCap As String, sID as String) 137 InsertTag("IMGCAPTION_","<IMGCAPTION id="""+sID+""">") 138 InsertText(sCap) 139 InsertTag("_IMGCAPTION","</IMGCAPTION>") 140End Sub 141 142Sub InsertExtendedTip 143 144 If not IsHelpFile Then 145 msgbox(strErr_NoHelpFile) 146 Exit Sub 147 End If 148 149 oSel = thiscomponent.getcurrentcontroller.getselection 150 oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 151 oStart = oCur.getStart 152 oCurStart = oStart.getText.createTextCursorByRange(oStart) 153 oEnd = oCur.getEnd 154 oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) 155 156 Ret = msgbox ("Create a hidden tip?",3+32,"Extended Tip") 157 158 If Ret=2 or Ret=3 Then 159 Exit Sub 160 End If 161 162 thiscomponent.getcurrentcontroller.select(oCurStart) 163 If Ret=6 Then 164 InsertTag("AHID_","<AHID hid="""+ID+""">") 165 ElseIf Ret=7 Then 166 InsertTag("AVIS_","<AVIS hid="""+ID+""">") 167 End If 168 thiscomponent.getcurrentcontroller.select(oCurEnd) 169 If Ret=6 Then 170 InsertTag("_AHID","</AHID>") 171 ElseIf Ret=7 Then 172 InsertTag("_AVIS","</AVIS>") 173 End If 174End Sub 175 176Sub InsertSort 177 CR 178 SetParaStyle("hlp_aux_sort") 179 InsertTag("SORT_","<SORT order=""asc"">","hlp_aux_sort") 180 GoLeft(1) 181 GoDown(1) 182 msgbox "Remember to also specify the closing SORT tag!",48,"Don't forget to close the tag" 183End Sub 184 185Sub CloseSort 186 CR 187 SetParaStyle("hlp_aux_sort") 188 InsertTag("_SORT","</SORT>","hlp_aux_sort") 189 GoLeft(1) 190 GoDown(1) 191End Sub 192 193sub InsertSection 194 195 196 If not IsHelpFile Then 197 msgbox(strErr_NoHelpFile) 198 Exit Sub 199 End If 200 201 dim document as object 202 dim dispatcher as object 203 204 oSel = thiscomponent.getcurrentcontroller.getselection 205 oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 206 oStart = oCur.getStart 207 oCurStart = oStart.getText.createTextCursorByRange(oStart) 208 oEnd = oCur.getEnd 209 oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) 210 211 sSectionName = AlphaNum(inputbox("Please specify a section name/identifier:")) 212 213 If sSectionName = "" Then 214 Exit Sub 215 End If 216 217 If sSectionName = "" Then 218 msgbox "No (valid) identifier -- no section."+chr(13)+"Hint: Use only A-Z,a-z,0-9 and _",48,"D'oh!" 219 Exit Sub 220 End If 221 222 document = ThisComponent.CurrentController.Frame 223 dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 224 225 dim args(6) as new com.sun.star.beans.PropertyValue 226 args(0).Name = "RegionName" 227 args(0).Value = sSectionName 228 args(1).Name = "RegionCondition" 229 args(1).Value = "" 230 args(2).Name = "RegionHidden" 231 args(2).Value = false 232 args(3).Name = "RegionProtect" 233 args(3).Value = false 234 args(4).Name = "LinkName" 235 args(4).Value = "" 236 args(5).Name = "FilterName" 237 args(5).Value = "" 238 args(6).Name = "SubRegion" 239 args(6).Value = "" 240 241 dispatcher.executeDispatch(document, ".uno:InsertSection", "", 0, args()) 242 243 If oCur.GetString <> "" Then 244 thiscomponent.getcurrentcontroller.select(oCurStart) 245 CR_before 246 GoUp(1) 247 InsertTag("SECTION_","<SECTION id="""+sSectionName+""">") 248 SetParaStyle("hlp_aux_section") 249 250 thiscomponent.getcurrentcontroller.select(oCurEnd) 251 CR 252 SetParaStyle("hlp_aux_section") 253 InsertTag("_SECTION","</SECTION>") 254 Else 255 GoUp(1) 256 InsertTagCR("SECTION_","<SECTION id="""+sSectionName+""">","hlp_aux_section") 257 CR 258 SetParaStyle("hlp_aux_section") 259 InsertTag("_SECTION","</SECTION>") 260 GoUp(1) 261 SetParaStyle("hlp_default") 262 End If 263 264end sub 265 266Sub ToggleParaL10NStatus 267 268 If not IsHelpFile Then 269 msgbox(strErr_NoHelpFile) 270 Exit Sub 271 End If 272 273 oSel = thiscomponent.getcurrentcontroller.getselection 274 oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 275 276 oCur.gotoStartOfParagraph(0) 277 CharStyle = oCur.charStyleName 278 279 arParaData = GetParaData 280 sID = arParaData(0) 281 slocalize = arParaData(1) 282 sMsg = arParaData(2) 283 284 If sMsg <> "" Then 285 msgbox "Error in paragraph status:"+chr(13)+sMsg,48,"Error" 286 Exit Sub 287 End If 288 289 290 If (sID = "") Then 291 msgbox "Paragraph has no ID. Assigning ID.",48,"Info" 292 InsertNewParaData 293 thiscomponent.getcurrentcontroller.select(oSel(0)) 294 arParaData = GetParaData 295 sID = arParaData(0) 296 slocalize = arParaData(1) 297 sMsg = arParaData(2) 298 End If 299 300 If slocalize = "no" Then 301 SetParaData(sID,"yes") 302 Else 303 SetParaData(sID,"no") 304 End If 305 306 thiscomponent.getcurrentcontroller.select(oSel(0)) 307 308End Sub 309 310 311Sub LocalizeImage 312 oSel = thiscomponent.getcurrentcontroller.getselection 313 If oSel(0).ImplementationName <> "SwXTextGraphicObject" Then 314 msgbox "Please select an image" 315 Else 316 If Instr(oSel(0).Name," ")>0 Then 317 oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name," ")-1) 318 End If 319 oSel(0).Name = oSel(0).Name + " localize=""true""" 320 End If 321 SetBorder 322End Sub 323 324 325Sub UnLocalizeImage 326 oSel = thiscomponent.getcurrentcontroller.getselection 327 If oSel(0).ImplementationName <> "SwXTextGraphicObject" Then 328 msgbox "Please select an image" 329 Else 330 331 If Instr(oSel(0).Name," ")>0 Then 332 oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name," ")-1) 333 End If 334 UnsetBorder 335 End If 336 337End Sub 338 339 340Sub ResetAllParaStatusValues 341 REM ... to be done 342End Sub 343 344Sub InsertHowToGet 345 346 If not IsHelpFile Then 347 msgbox(strErr_NoHelpFile) 348 Exit Sub 349 End If 350 351 document = ThisComponent.CurrentController.Frame 352 dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 353 354 dim args(6) as new com.sun.star.beans.PropertyValue 355 args(0).Name = "RegionName" 356 args(0).Value = "howtoget" 357 args(1).Name = "RegionCondition" 358 args(1).Value = "" 359 args(2).Name = "RegionHidden" 360 args(2).Value = false 361 args(3).Name = "RegionProtect" 362 args(3).Value = false 363 args(4).Name = "LinkName" 364 args(4).Value = "" 365 args(5).Name = "FilterName" 366 args(5).Value = "" 367 args(6).Name = "SubRegion" 368 args(6).Value = "" 369 370 dispatcher.executeDispatch(document, ".uno:InsertSection", "", 0, args()) 371 GoUp(1) 372 InsertTagCR("SECTION_","<SECTION id=""howtoget"">","hlp_aux_section") 373 CR 374 SetParaStyle("hlp_aux_section") 375 InsertTag("_SECTION","</SECTION>") 376 GoUp(1) 377 SetParaStyle("hlp_default") 378' Embed.Main(false) 379End Sub 380 381Sub InsertRelatedTopics 382 383 If not IsHelpFile Then 384 msgbox(strErr_NoHelpFile) 385 Exit Sub 386 End If 387 388 document = ThisComponent.CurrentController.Frame 389 dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 390 391 dim args(6) as new com.sun.star.beans.PropertyValue 392 args(0).Name = "RegionName" 393 args(0).Value = "relatedtopics" 394 args(1).Name = "RegionCondition" 395 args(1).Value = "" 396 args(2).Name = "RegionHidden" 397 args(2).Value = false 398 args(3).Name = "RegionProtect" 399 args(3).Value = false 400 args(4).Name = "LinkName" 401 args(4).Value = "" 402 args(5).Name = "FilterName" 403 args(5).Value = "" 404 args(6).Name = "SubRegion" 405 args(6).Value = "" 406 407 dispatcher.executeDispatch(document, ".uno:InsertSection", "", 0, args()) 408 GoUp(1) 409 InsertTagCR("SECTION_","<SECTION id=""relatedtopics"">","hlp_aux_section") 410 CR 411 SetParaStyle("hlp_aux_section") 412 InsertTag("_SECTION","</SECTION>") 413 GoUp(1) 414 SetParaStyle("hlp_default") 415End Sub 416 417 418sub UnsetBorder 419rem ---------------------------------------------------------------------- 420rem define variables 421dim document as object 422dim dispatcher as object 423rem ---------------------------------------------------------------------- 424rem get access to the document 425document = ThisComponent.CurrentController.Frame 426dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 427 428rem ---------------------------------------------------------------------- 429dim args1(7) as new com.sun.star.beans.PropertyValue 430args1(0).Name = "BorderOuter.LeftBorder" 431args1(0).Value = Array(0,0,0,0) 432args1(1).Name = "BorderOuter.LeftDistance" 433args1(1).Value = 10 434args1(2).Name = "BorderOuter.RightBorder" 435args1(2).Value = Array(0,0,0,0) 436args1(3).Name = "BorderOuter.RightDistance" 437args1(3).Value = 0 438args1(4).Name = "BorderOuter.TopBorder" 439args1(4).Value = Array(0,0,0,0) 440args1(5).Name = "BorderOuter.TopDistance" 441args1(5).Value = 0 442args1(6).Name = "BorderOuter.BottomBorder" 443args1(6).Value = Array(0,0,0,0) 444args1(7).Name = "BorderOuter.BottomDistance" 445args1(7).Value = 0 446 447dispatcher.executeDispatch(document, ".uno:BorderOuter", "", 0, args1()) 448 449rem ---------------------------------------------------------------------- 450dim args2(4) as new com.sun.star.beans.PropertyValue 451args2(0).Name = "BorderInner.Horizontal" 452args2(0).Value = Array(0,0,0,0) 453args2(1).Name = "BorderInner.Vertical" 454args2(1).Value = Array(0,0,0,0) 455args2(2).Name = "BorderInner.Flags" 456args2(2).Value = 2 457args2(3).Name = "BorderInner.ValidFlags" 458args2(3).Value = 63 459args2(4).Name = "BorderInner.DefaultDistance" 460args2(4).Value = 0 461 462dispatcher.executeDispatch(document, ".uno:BorderInner", "", 0, args2()) 463 464 465end sub 466 467 468 469sub SetBorder 470rem ---------------------------------------------------------------------- 471rem define variables 472dim document as object 473dim dispatcher as object 474rem ---------------------------------------------------------------------- 475rem get access to the document 476document = ThisComponent.CurrentController.Frame 477dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 478 479rem ---------------------------------------------------------------------- 480dim args1(7) as new com.sun.star.beans.PropertyValue 481args1(0).Name = "BorderOuter.LeftBorder" 482args1(0).Value = Array(15167232,0,88,0) 483args1(1).Name = "BorderOuter.LeftDistance" 484args1(1).Value = 101 485args1(2).Name = "BorderOuter.RightBorder" 486args1(2).Value = Array(15167232,0,88,0) 487args1(3).Name = "BorderOuter.RightDistance" 488args1(3).Value = 101 489args1(4).Name = "BorderOuter.TopBorder" 490args1(4).Value = Array(15167232,0,88,0) 491args1(5).Name = "BorderOuter.TopDistance" 492args1(5).Value = 101 493args1(6).Name = "BorderOuter.BottomBorder" 494args1(6).Value = Array(15167232,0,88,0) 495args1(7).Name = "BorderOuter.BottomDistance" 496args1(7).Value = 101 497 498dispatcher.executeDispatch(document, ".uno:BorderOuter", "", 0, args1()) 499 500rem ---------------------------------------------------------------------- 501dim args2(4) as new com.sun.star.beans.PropertyValue 502args2(0).Name = "BorderInner.Horizontal" 503args2(0).Value = Array(0,0,0,0) 504args2(1).Name = "BorderInner.Vertical" 505args2(1).Value = Array(0,0,0,0) 506args2(2).Name = "BorderInner.Flags" 507args2(2).Value = 2 508args2(3).Name = "BorderInner.ValidFlags" 509args2(3).Value = 127 510args2(4).Name = "BorderInner.DefaultDistance" 511args2(4).Value = 0 512 513dispatcher.executeDispatch(document, ".uno:BorderInner", "", 0, args2()) 514 515 516end sub 517</script:module> 518