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="Switch" script:language="StarBasic">REM ***** BASIC ***** 4 5Dim oDialog AS Object 6Dim document AS Object 7 8Sub Main 9End Sub 10 11Sub InsertSwitch 12 InsertSwitchTag(FALSE) 13End Sub 14 15Sub InsertSwitchInline 16 InsertSwitchTag(TRUE) 17End Sub 18 19Sub InsertSwitchTag(bInline As Boolean) 20 document = StarDesktop.CurrentComponent 21 Dim oCur as Object 22 23 BasicLibraries.LoadLibrary("HelpAuthoring") 24 25 oDialog = LoadDialog("HelpAuthoring", "dlgSwitch") 26 oDialogModel = oDialog.Model 27 28 oOptSys = oDialog.GetControl("opSwitchSystem") 29 oOptAppl = oDialog.GetControl("opSwitchAppl") 30 oOptDistrib = oDialog.GetControl("opSwitchDistrib") 31 32 If oDialog.Execute() = 1 Then 33 If oOptSys.State Then 34 sType = "sys" 35 ElseIf oOptAppl.State Then 36 sType = "appl" 37 ElseIf oOptDistrib.State Then 38 sType = "distrib" 39 End If 40 Else 41 End If 42 oDialog.Dispose 43 44 If bInline Then 45 oSel = thiscomponent.getcurrentcontroller.getselection 46 oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 47 48 oStart = oCur.getStart 49 oCurStart = oStart.getText.createTextCursorByRange(oStart) 50 51 oEnd = oCur.getEnd 52 oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) 53 54 thiscomponent.getcurrentcontroller.select(oCurStart) 55 InsertTag("SWITCHINLINE_","<SWITCHINLINE select=""" + sType + """>","hlp_aux_switch") 56 InsertCase(sType,TRUE,oCur) 57 thiscomponent.getcurrentcontroller.select(oCurEnd) 58 CloseSwitchInline 59 GoLeft(1) 60 Else 61 CR_before 62 GoUp(1) 63 SetParaStyle("hlp_aux_switch") 64 InsertTag("SWITCH_","<SWITCH select=""" + sType + """>","hlp_aux_switch") 65 GoLeft(1) 66 GoDown(1) 67 SetCharStyle("Default") 68 CloseSwitch 69 GoUp(1) 70 InsertCase(sType,FALSE,oCur) 71 End If 72End Sub 73 74Sub InsertCaseElement 75 document = StarDesktop.CurrentComponent 76 Dim oCur as Object 77 BasicLibraries.LoadLibrary("HelpAuthoring") 78 79 oDialog = LoadDialog("HelpAuthoring", "dlgSwitch") 80 oDialogModel = oDialog.Model 81 82 oOptSys = oDialog.GetControl("opSwitchSystem") 83 oOptAppl = oDialog.GetControl("opSwitchAppl") 84 oOptDistrib = oDialog.GetControl("opSwitchDistrib") 85 86 If oDialog.Execute() = 1 Then 87 If oOptSys.State Then 88 sType = "sys" 89 ElseIf oOptAppl.State Then 90 sType = "appl" 91 ElseIf oOptDistrib.State Then 92 sType = "distrib" 93 End If 94 Else 95 End If 96 oDialog.Dispose 97 98 InsertCase(sType,FALSE,oCur) 99 100End Sub 101 102Sub InsertDefaultElement 103 document = StarDesktop.CurrentComponent 104 BasicLibraries.LoadLibrary("HelpAuthoring") 105 106 InsertDefault 107End Sub 108 109Sub InsertCaseInlineElement 110 document = StarDesktop.CurrentComponent 111 Dim oCur as Object 112 BasicLibraries.LoadLibrary("HelpAuthoring") 113 114 oDialog = LoadDialog("HelpAuthoring", "dlgSwitch") 115 oDialogModel = oDialog.Model 116 117 oOptSys = oDialog.GetControl("opSwitchSystem") 118 oOptAppl = oDialog.GetControl("opSwitchAppl") 119 oOptDistrib = oDialog.GetControl("opSwitchDistrib") 120 121 If oDialog.Execute() = 1 Then 122 If oOptSys.State Then 123 sType = "sys" 124 ElseIf oOptAppl.State Then 125 sType = "appl" 126 ElseIf oOptDistrib.State Then 127 sType = "distrib" 128 End If 129 Else 130 End If 131 oDialog.Dispose 132 133 oSel = thiscomponent.getcurrentcontroller.getselection 134 oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 135 136 oStart = oCur.getStart 137 oCurStart = oStart.getText.createTextCursorByRange(oStart) 138 139 oEnd = oCur.getEnd 140 oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) 141 142 InsertCase(sType,TRUE,oCur) 143 GoLeft(1) 144End Sub 145 146Sub InsertDefaultInlineElement 147 document = StarDesktop.CurrentComponent 148 BasicLibraries.LoadLibrary("HelpAuthoring") 149 150 oSel = thiscomponent.getcurrentcontroller.getselection 151 oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 152 153 oStart = oCur.getStart 154 oCurStart = oStart.getText.createTextCursorByRange(oStart) 155 156 oEnd = oCur.getEnd 157 oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) 158 159 InsertDefaultInline(oCur) 160 GoLeft(1) 161End Sub 162 163 164Sub InsertCaseSys 165 InsertCase("sys",FALSE) 166End Sub 167 168Sub InsertCaseAppl 169 InsertCase("appl",FALSE) 170End Sub 171 172Sub InsertCaseDistrib 173 InsertCase("distrib",FALSE) 174End Sub 175 176Sub InsertCaseInlineSys 177 InsertCase("sys",TRUE) 178End Sub 179 180Sub InsertCaseInlineAppl 181 InsertCase("appl",TRUE) 182End Sub 183 184Sub InsertCaseInlineDistrib 185 InsertCase("distrib",TRUE) 186End Sub 187 188Sub InsertDefaultInline(oCur as Object) 189 oSel = thiscomponent.getcurrentcontroller.getselection 190 'oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 191 192 oStart = oCur.getStart 193 oCurStart = oStart.getText.createTextCursorByRange(oStart) 194 195 oEnd = oCur.getEnd 196 oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) 197 198 thiscomponent.getcurrentcontroller.select(oCurStart) 199 InsertTag("DEFAULTINLINE_","<DEFAULTINLINE>") 200 201 thiscomponent.getcurrentcontroller.select(oCurEnd) 202 InsertTag("_DEFAULTINLINE","</DEFAULTINLINE>") 203End Sub 204 205Sub InsertCase(sType As String, bInline As Boolean,oCur As Object) 206 document = StarDesktop.CurrentComponent 207 208 BasicLibraries.LoadLibrary("HelpAuthoring") 209 oDialog = LoadDialog("HelpAuthoring", "dlgCase") 210 oDialogModel = oDialog.Model 211 212 oOptPredefined = oDialog.GetControl("opPredefined") 213 oCbPredefined = oDialog.GetControl("cbPredefined") 214 oOptSpecify = oDialog.GetControl("opSpecify") 215 oTxtSpecify = oDialog.GetControl("txtSpecify") 216 oTxtSpecify.setVisible(FALSE) 217 218 If sType = "sys" Then 219 arItems = Array("WIN","UNIX","MAC") 220 ElseIf sType = "appl" Then 221 arItems = Array("CALC","CHART","DRAW","IMPRESS","MATH","WRITER","BASIC") 222 ElseIf sType = "distrib" Then 223 arItems = Array("OPENSOURCE","COMMERCIAL") 224 Else 225 msgbox "Unknown Case. Go tell Frank about this",0,"D'oh!" 226 Exit Sub 227 End If 228 229 oCbPredefined.AddItems(arItems,ubound(arItems)) 230 oCbPredefined.SetText(arItems(0)) 231 232 If oDialog.Execute() = 1 Then 233 234 If oOptPredefined.State Then 235 sSelect = oCbPredefined.GetText 236 Else 237 sSelect = oTxtSpecify.Text 238 End If 239 240 If bInline Then 241 oSel = thiscomponent.getcurrentcontroller.getselection 242 'oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 243 244 oStart = oCur.getStart 245 oCurStart = oStart.getText.createTextCursorByRange(oStart) 246 247 oEnd = oCur.getEnd 248 oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) 249 250 thiscomponent.getcurrentcontroller.select(oCurStart) 251 InsertTag("CASEINLINE_","<CASEINLINE select="""+sSelect+""">") 252 253 thiscomponent.getcurrentcontroller.select(oCurEnd) 254 InsertTag("_CASEINLINE","</CASEINLINE>") 255 Else 256 CR_before 257 GoUp(1) 258 SetParaStyle("hlp_aux_switch") 259 InsertTag("CASE_","<CASE select=""" + sSelect+""">","hlp_aux_switch") 260 GoLeft(1) 261 GoDown(1) 262 SetCharStyle("Default") 263 CloseCase 264 GoUp(1) 265 End If 266 End If 267 oDialog.dispose 268End Sub 269 270Sub StatusChange 271 oOptPredefined = oDialog.GetControl("opPredefined") 272 oCbPredefined = oDialog.GetControl("cbPredefined") 273 oOptSpecify = oDialog.GetControl("opSpecify") 274 oTxtSpecify = oDialog.GetControl("txtSpecify") 275 276 If oOptPredefined.State Then 277 oCbPredefined.setVisible(TRUE) 278 oTxtSpecify.setVisible(FALSE) 279 ElseIf oOptSpecify.State Then 280 oCbPredefined.setVisible(FALSE) 281 oTxtSpecify.setVisible(TRUE) 282 End If 283End Sub 284 285Sub CloseCase 286 CR 287 SetParaStyle("hlp_aux_switch") 288 InsertTag("_CASE","</CASE>","hlp_aux_switch") 289End Sub 290 291Sub InsertDefault 292 CR_before 293 GoUp(1) 294 SetParaStyle("hlp_aux_switch") 295 InsertTag("DEFAULT_","<DEFAULT>","hlp_aux_switch") 296 GoLeft(1) 297 GoDown(1) 298 SetCharStyle("Default") 299 CloseDefault 300 GoUp(1) 301End Sub 302 303Sub CloseDefault 304 CR 305 SetParaStyle("hlp_aux_switch") 306 InsertTag("_DEFAULT","</DEFAULT>","hlp_aux_switch") 307End Sub 308 309Sub CloseSwitch 310 CR 311 SetParaStyle("hlp_aux_switch") 312 InsertTag("_SWITCH","</SWITCH>","hlp_aux_switch") 313End Sub 314 315Sub CloseSwitchInline 316 InsertTag("_SWITCHINLINE","</SWITCHINLINE>") 317End Sub 318</script:module>