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