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