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="Init" script:language="StarBasic">Option Explicit 24REM ***** BASIC ***** 25 26Public Const SBRANGEUBOUND = 20 27Public StyleRangeAssignmentList(SBRANGEUBOUND)as String 28Public SelRangeList(SBRANGEUBOUND) as String 29Public RangeList(SBRANGEUBOUND) as String 30Public UnprotectList() as String 31Public FilterNames(2,1) as String 32Public bDoUnProtect as Boolean 33Public bCancelTask as Boolean 34 35Public sREADY as String 36Public sPROTECT as String 37Public sCONTINUE as String 38 39Public sSELTEMPL as String 40Public sSELCELL as String 41Public sCURRRANGES as String 42Public sTEMPLATES as String 43 44Public sSOURCEFILE as String 45Public sSOURCEDIR as String 46Public sTARGETDIR as String 47 48Public sStsPROGRESS as String 49Public sStsCELLPROGRSS as String 50Public sStsRELRANGES as String 51Public sStsRELSHEETRANGES as String 52Public sStsREPROTECT as String 53 54Public sMsgSELDIR as String 55Public sMsgSELFILE as String 56Public sMsgTARGETDIR as String 57Public sMsgNOTTHERE as String 58Public sMsgDLGTITLE as String 59Public sMsgUNPROTECT as String 60Public sMsgPWPROTECT as String 61Public sMsgWRONGPW as String 62Public sMsgSHEETPROTECTED as String 63Public sMsgWARNING as String 64Public sMsgSHEETSNOPROTECT as String 65Public sMsgSHEETNOPROTECT as String 66Public sMsgCHOOSECURRENCY as String 67Public sMsgPASSWORD as String 68Public sMsgOK as String 69Public sMsgCANCEL as String 70Public sMsgFileInvalid as String 71Public sMsgNODIRECTORY as String 72Public sMsgDOCISREADONLY as String 73Public sMsgFileExists as String 74Public sMsgCancelConversion as String 75Public sMsgCancelTitle as String 76Public sCurrPORTUGUESE as String 77Public sCurrDUTCH as String 78Public sCurrFRENCH as String 79Public sCurrSPANISH as String 80Public sCurrITALIAN as String 81Public sCurrGERMAN as String 82Public sCurrBELGIAN as String 83Public sCurrIRISH as String 84Public sCurrLUXEMBOURG as String 85Public sCurrAUSTRIAN as String 86Public sCurrFINNISH as String 87Public sCurrGREEK as String 88Public sCurrSLOVENIAN as String 89Public sCurrCYPRIOT as String 90Public sCurrMALTESE as String 91Public sCurrSLOVAK as String 92Public sCurrUNKNOWN as String 93Public sCurrSYSUNKNOWN as String 94 95Public sPrgsRETRIEVAL as String 96Public sPrgsCONVERTING as String 97Public sPrgsUNPROTECT as String 98Public sInclusiveSubDir as String 99 100Public Const SBCOUNTRYCOUNT = 15 101Public CurMimeType as String 102Public CurCellCount as Long 103Public oSheets as Object 104Public oStyles as Object 105Public oStyle as Object 106Public oFormats as Object 107Public aSimpleStr as String 108Public nSimpleKey as Long 109Public aFormat() as Variant 110Public oRanges as Object 111Public oRange as Object 112Public nLanguage as integer 113Public nFormatLanguage as integer 114Public aCellFormat as Variant 115Public oDocument as Object 116Public StartCol, StartRow, EndCol, EndRow as String 117Public oSheet as Object 118Public IntStartCol, IntStartRow, IntEndCol, IntEndRow as integer 119Public oSelRanges as Object 120Public nFormatType as Integer 121Public sFormatCurrency as String 122Public sFormatLanguage as String 123Public CurSheetName as String 124Public oStatusLine as Object 125Public Const SBRELGET = 50 126Public StatusValue as Single 127Public TotCellCount as Long 128Public StyleIndex as Integer 129Public RangeIndex as Integer 130Public CurrIndex as Integer 131Public ActLangNumber(1) as Integer 132Public CurExtension(2) as String 133Public Currfactor as Double 134Public CurrSymbolList(2) as String 135Public CurrLanguage as String 136Public CurrValue(15,5) 137Public LangIDValue(15,2,2) as String 138Public PreName as String 139Public Separator as String 140Public BitmapDir as String 141Public TypeIndex as Integer, CSIndex as Integer, LangIndex as Integer, FSIndex as Integer 142Public oLocale as New com.sun.star.lang.Locale 143Public sEuroSign as String 144Public oPointer as Object 145Public sDocType as String 146Public bPreSelected as Boolean 147Public bRecursive as Boolean 148Public bCancelProtection as Boolean 149Public CurrRoundMode as Boolean 150Public bRangeListDefined as Boolean 151Public bDocHasProtectedSheets as Boolean 152Public sGOON as String 153Public sHELP as String 154Public sCANCEL as String 155Dim sEnd as String 156 157Sub InitializeResources() 158Dim LocWorkPath as String 159 With DialogModel 160 ' Strings that are also needed by the Password Dialog 161 sGoOn = GetResText(1003) 162 sHelp = GetResText(1001) 163 sCANCEL = GetResText(1418) 164 sEnd = GetResText(1000) 165 sPROTECT = GetResText(1005) 166 sCONTINUE = GetResText(1007) 167 sSELTEMPL = GetResText(1106) 168 sSELCELL = GetResText(1107) 169 sCURRRANGES = GetResText(1108) 170 sTEMPLATES = GetResText(1109) 171 sStsPROGRESS = GetResText(1300) 172 sStsCELLPROGRSS = GetResText(1301) 173 sStsRELSHEETRANGES = GetResText(1302) 174 sStsRELRANGES = GetResText(1303) 175 sStsREPROTECT = GetResText(1304) 176 sREADY = GetResText(1400) 177 sMsgSELDIR = GetResText(1401) 178 sMsgSELFILE = GetResText(1402) 179 sMsgTARGETDIR = GetResText(1403) 180 sMsgNOTTHERE = GetResText(1404) 181 sMsgDLGTITLE = GetResText(1405) 182 sMsgUNPROTECT = GetResText(1406) 183 sMsgPWPROTECT = GetResText(1407) 184 sMsgWRONGPW = GetResText(1408) 185 sMsgSHEETPROTECTED = GetResText(1409) 186 sMsgWARNING = GetResText(1410) 187 sMsgSHEETSNOPROTECT = GetResText(1411) 188 sMsgSHEETNOPROTECT = GetResText(1412) 189 sMsgCHOOSECURRENCY = GetResText(1415) 190 sMsgPASSWORD = GetResText(1416) 191 sMsgOK = GetResText(1417) 192 sMsgCANCEL = GetResText(1418) 193 sMsgFILEINVALID = GetResText(1419) 194 sMsgFILEINVALID = ReplaceString(sMsgFILEINVALID,"%PRODUCTNAME", GetProductname()) 195 SMsgNODIRECTORY = GetResText(1420) 196 sMsgDOCISREADONLY = GetResText(1421) 197 sMsgFileExists = GetResText(1422) 198 sMsgCancelConversion = GetResText(1423) 199 sMsgCancelTitle = GetResText(1424) 200 sCurrPORTUGUESE = GetResText(1500) 201 sCurrDUTCH = GetResText(1501) 202 sCurrFRENCH = GetResText(1502) 203 sCurrSPANISH = GetResText(1503) 204 sCurrITALIAN = GetResText(1504) 205 sCurrGERMAN = GetResText(1505) 206 sCurrBELGIAN = GetResText(1506) 207 sCurrIRISH = GetResText(1507) 208 sCurrLUXEMBOURG = GetResText(1508) 209 sCurrAUSTRIAN = GetResText(1509) 210 sCurrFINNISH = GetResText(1510) 211 sCurrGREEK = GetResText(1511) 212 sCurrSLOVENIAN = GetResText(1512) 213 sCurrCYPRIOT = GetResText(1513) 214 sCurrMALTESE = GetResText(1514) 215 sCurrSLOVAK = GetResText(1515) 216 sCurrUNKNOWN = GetResText(1516) 217 sCurrSYSUNKNOWN = GetResText(1517) 218 .cmdCancel.Label = sCANCEL 219 .cmdHelp.Label = sHELP 220 .cmdBack.Label = GetResText(1002) 221 .cmdGoOn.Label = sGOON 222 .lblHint.Label = GetResText(1004) 223 .lblCurrencies.Label = GetResText(1006) 224 .cmdBack.Enabled = False 225 If .Step = 1 Then 226 .chkComplete.Label = GetResText(1100) 227 .hlnSelection.Label = GetResText(1101) 228 .optCellTemplates.Label = GetResText(1102) 229 .optSheetRanges.Label = GetResText(1103) 230 .optDocRanges.Label = GetResText(1104) 231 .optSelRange.Label = GetResText(1105) 232 sCURRRANGES = GetResText(1108) 233 .lblSelection.Label = sCURRRANGES 234 Else 235 .lblProgress.Label = sStsPROGRESS 236 .hlnExtent.Label = GetResText(1200) 237 .optSingleFile.Label = GetResText(1201) 238 .optWholeDir.Label = GetResText(1202) 239 .chkProtect.Label = GetResText(1207) 240 .chkTextDocuments.Label = GetResText(1210) 241 242 sSOURCEFILE = GetResText(1203) 243 sSOURCEDIR = GetResText(1204) 244 .lblSource.Label = sSOURCEDIR 245 sInclusiveSubDir = GetResText(1205) 246 .chkRecursive.Label = sInclusiveSubDir 247 sTARGETDIR = GetResText(1206) 248 .lblTarget.Label = STARGETDIR 249 250 LocWorkPath = GetPathSettings("Work") 251 If Not oUcb.Exists(LocWorkPath) Then 252 ShowNoOfficePathError() 253 Stop 254 End If 255 256 .txtSource.Text = ConvertfromUrl(LocWorkPath) 257 258 SubstDir = .txtSource.Text 259 .txtTarget.Text = .txtSource.Text 260 .hlnProgress.Label = GetResText(1600) 261 .lblConfig.Label = GetResText(1603) 262 sPrgsRETRIEVAL = GetResText(1601) 263 sPrgsCONVERTING = GetResText(1602) 264 sPrgsUNPROTECT = GetResText(1604) 265 End If 266 End With 267End Sub 268 269Sub InitializeLanguages() 270 sEuroSign = chr(8364) 271 272' CURRENCIES_PORTUGUESE 273 LangIDValue(0,0,0) = "pt" 274 LangIDValue(0,0,1) = "" 275 LangIDValue(0,0,2) = "-816" 276 277' CURRENCIES_DUTCH 278 LangIDValue(1,0,0) = "nl" 279 LangIDValue(1,0,1) = "" 280 LangIDValue(1,0,2) = "-413" 281 282' CURRENCIES_FRENCH 283 LangIDValue(2,0,0) = "fr" 284 LangIDValue(2,0,1) = "" 285 LangIDValue(2,0,2) = "-40C" 286 287' CURRENCIES_SPANISH 288 LangIDValue(3,0,0) = "es" 289 LangIDValue(3,0,1) = "" 290 LangIDValue(3,0,2) = "-40A" 291 292 'Spanish modern 293 LangIDValue(3,1,0) = "es" 294 LangIDValue(3,1,1) = "" 295 LangIDValue(3,1,2) = "-C0A" 296 297 'Spanish katalanic 298 LangIDValue(3,2,0) = "es" 299 LangIDValue(3,2,1) = "" 300 LangIDValue(3,2,2) = "-403" 301 302' CURRENCIES_ITALIAN 303 LangIDValue(4,0,0) = "it" 304 LangIDValue(4,0,1) = "" 305 LangIDValue(4,0,2) = "-410" 306 307' CURRENCIES_GERMAN 308 LangIDValue(5,0,0) = "de" 309 LangIDValue(5,0,1) = "DE" 310 LangIDValue(5,0,2) = "-407" 311 312' CURRENCIES_BELGIAN 313 LangIDValue(6,0,0) = "fr" 314 LangIDValue(6,0,1) = "BE" 315 LangIDValue(6,0,2) = "-80C" 316 317 LangIDValue(6,1,0) = "nl" 318 LangIDValue(6,1,1) = "BE" 319 LangIDValue(6,1,2) = "-813" 320 321' CURRENCIES_IRISH 322 LangIDValue(7,0,0) = "en" 323 LangIDValue(7,0,1) = "IE" 324 LangIDValue(7,0,2) = "-1809" 325 326 LangIDValue(7,1,0) = "ga" 327 LangIDValue(7,1,1) = "IE" 328 LangIDValue(7,1,2) = "-83C" 329 330' CURRENCIES_LUXEMBOURG 331 LangIDValue(8,0,0) = "fr" 332 LangIDValue(8,0,1) = "LU" 333 LangIDValue(8,0,2) = "-140C" 334 335 LangIDValue(8,1,0) = "de" 336 LangIDValue(8,1,1) = "LU" 337 LangIDValue(8,1,2) = "-1007" 338 339' CURRENCIES_AUSTRIAN 340 LangIDValue(9,0,0) = "de" 341 LangIDValue(9,0,1) = "AT" 342 LangIDValue(9,0,2) = "-C07" 343 344' CURRENCIES_FINNISH 345 LangIDValue(10,0,0) = "fi" 346 LangIDValue(10,0,1) = "FI" 347 LangIDValue(10,0,2) = "-40B" 348 349 LangIDValue(10,1,0) = "sv" 350 LangIDValue(10,1,1) = "FI" 351 LangIDValue(10,1,2) = "-81D" 352 353' CURRENCIES_GREEK 354 LangIDValue(11,0,0) = "el" 355 LangIDValue(11,0,1) = "GR" 356 LangIDValue(11,0,2) = "-408" 357 358' CURRENCIES_SLOVENIAN 359 LangIDValue(12,0,0) = "sl" 360 LangIDValue(12,0,1) = "SI" 361 LangIDValue(12,0,2) = "-424" 362 363' CURRENCIES_CYPRIOT 364 LangIDValue(13,0,0) = "el" 365 LangIDValue(13,0,1) = "CY" 366 LangIDValue(13,0,2) = "-408" 367 368' CURRENCIES_MALTESE 369 LangIDValue(14,0,0) = "mt" 370 LangIDValue(14,0,1) = "MT" 371 LangIDValue(14,0,2) = "-43A" 372 373' CURRENCIES_SLOVAK 374 LangIDValue(15,0,0) = "sk" 375 LangIDValue(15,0,1) = "SK" 376 LangIDValue(15,0,2) = "-41B" 377 378End Sub 379 380 381 382Sub InitializeCurrencies() 383Dim i as Integer 384 GoOn = True 385 386 CurrValue(0,0) = sCurrPORTUGUESE 387 ' real conversion rate 388 CurrValue(0,1) = 200.482 389 ' rounded conversion rate 390 CurrValue(0,2) = 200 391 CurrValue(0,3) = "Esc." 392 CurrValue(0,4) = "Esc." 393 CurrValue(0,5) = "PTE" 394 395 CurrValue(1,0) = sCurrDUTCH 396 ' real conversion rate 397 CurrValue(1,1) = 2.20371 398 ' rounded conversion rate 399 CurrValue(1,2) = 2 400 CurrValue(1,3) = "F" 401 CurrValue(1,4) = "fl" 402 CurrValue(1,5) = "NLG" 403 404 CurrValue(2,0) = sCurrFRENCH 405 ' real conversion rate 406 CurrValue(2,1) = 6.55957 407 ' rounded conversion rate 408 CurrValue(2,2) = 7 409 CurrValue(2,3) = "F" 410 CurrValue(2,4) = "F" 411 CurrValue(2,5) = "FRF" 412 413 CurrValue(3,0) = sCurrSPANISH 414 ' real conversion rate 415 CurrValue(3,1) = 166.386 416 ' rounded conversion rate 417 CurrValue(3,2) = 170 418 CurrValue(3,3) = "Pts" 419 CurrValue(3,4) = "Pts" 420 CurrValue(3,5) = "ESP" 421 422 CurrValue(4,0) = sCurrITALIAN 423 ' real conversion rate 424 CurrValue(4,1) = 1936.27 425 ' rounded conversion rate 426 CurrValue(4,2) = 2000 427 CurrValue(4,3) = "L." 428 CurrValue(4,4) = "L." 429 CurrValue(4,5) = "ITL" 430 431 CurrValue(5,0) = sCurrGERMAN 432 ' real conversion rate 433 CurrValue(5,1) = 1.95583 434 ' rounded conversion rate 435 CurrValue(5,2) = 2 436 CurrValue(5,3) = "DM" 437 CurrValue(5,4) = "DM" 438 CurrValue(5,5) = "DEM" 439 440 CurrValue(6,0) = sCurrBELGIAN 441 ' real conversion rate 442 CurrValue(6,1) = 40.3399 443 ' rounded conversion rate 444 CurrValue(6,2) = 40 445 CurrValue(6,3) = "FB" 446 CurrValue(6,4) = "BF" 447 CurrValue(6,5) = "BEF" 448 449 CurrValue(7,0) = sCurrIRISH 450 ' real conversion rate 451 CurrValue(7,1) = 0.787564 452 ' rounded conversion rate 453 CurrValue(7,2) = 0.8 454 CurrValue(7,3) = "IR£" 455 CurrValue(7,4) = "£" 456 CurrValue(7,5) = "IEP" 457 458 CurrValue(8,0) = sCurrLUXEMBOURG 459 ' real conversion rate 460 CurrValue(8,1) = 40.3399 461 ' rounded conversion rate 462 CurrValue(8,2) = 40 463 CurrValue(8,3) = "F" 464 CurrValue(8,4) = "F" 465 CurrValue(8,5) = "LUF" 466 467 CurrValue(9,0) = sCurrAUSTRIAN 468 ' real conversion rate 469 CurrValue(9,1) = 13.7603 470 ' rounded conversion rate 471 CurrValue(9,2) = 15 472 CurrValue(9,3) = "öS" 473 CurrValue(9,4) = "S" 474 CurrValue(9,5) = "ATS" 475 476 CurrValue(10,0) = sCurrFINNISH 477 ' real conversion rate 478 CurrValue(10,1) = 5.94573 479 ' rounded conversion rate 480 CurrValue(10,2) = 6 481 CurrValue(10,3) = "mk" 482 CurrValue(10,4) = "mk" 483 CurrValue(10,5) = "FIM" 484 485 CurrValue(11,0) = sCurrGREEK 486 ' real conversion rate 487 CurrValue(11,1) = 340.750 488 ' rounded conversion rate 489 CurrValue(11,2) = 400 490 CurrValue(11,3) = chr(916) & chr(961) & chr(967) 491 CurrValue(11,4) = chr(916) & chr(961) & chr(967) 492 CurrValue(11,5) = "GRD" 493 494 CurrValue(12,0) = sCurrSLOVENIAN 495 ' real conversion rate 496 CurrValue(12,1) = 239.64 497 ' rounded conversion rate 498 CurrValue(12,2) = 240 499 CurrValue(12,3) = "SIT" 500 CurrValue(12,4) = "SIT" 501 CurrValue(12,5) = "SIT" 502 503 CurrValue(13,0) = sCurrCYPRIOT 504 ' real conversion rate 505 CurrValue(13,1) = 0.585274 506 ' rounded conversion rate 507 CurrValue(13,2) = 0.6 508 CurrValue(13,3) = "£C" 509 CurrValue(13,4) = "£" 510 CurrValue(13,5) = "CYP" 511 512 CurrValue(14,0) = sCurrMALTESE 513 ' real conversion rate 514 CurrValue(14,1) = 0.429300 515 ' rounded conversion rate 516 CurrValue(14,2) = 0.4 517 CurrValue(14,3) = chr(8356) 518 CurrValue(14,4) = "Lm" 519 CurrValue(14,5) = "MTL" 520 521 CurrValue(15,0) = sCurrSLOVAK 522 ' real conversion rate 523 CurrValue(15,1) = 30.1260 524 ' rounded conversion rate 525 CurrValue(15,2) = 30 526 CurrValue(15,3) = "Sk" 527 CurrValue(15,4) = "Sk" 528 CurrValue(15,5) = "SKK" 529 530 i = -1 531 CurrSymbolList(0) = "" 532 CurrSymbolList(1) = "" 533 InitializeCurrencyValues(CurrIndex) 534End Sub 535 536 537Sub InitializeControls() 538 If CurrIndex = -1 Then 539 If DialogModel.Step = 1 Then 540 EnableStep1DialogControls(True, False, False) 541 ElseIf DialogModel.Step = 2 Then 542 EnableStep2DialogControls(True) 543 End If 544 End If 545End Sub 546 547 548Sub InitializeConverter(oLocale, iDialogPage as Integer) 549Dim Isthere as Boolean 550 bCancelProtection = False 551 bRangeListDefined = False 552 PWIndex = -1 553 If iDialogPage = 1 Then 554 ToggleWindow(False) 555 sDocType = Tools.GetDocumentType(ThisComponent) 556 If sDocType = "sCalc" Then 557 bDocHasProtectedSheets = CheckSheetProtection(oSheets) 558 End If 559 oStatusline = ThisComponent.GetCurrentController.GetFrame.CreateStatusIndicator() 560 End If 561 DialogConvert = LoadDialog("Euro", "DlgConvert") 562 DialogModel = DialogConvert.Model 563 DialogPassword = LoadDialog("Euro", "DlgPassword") 564 PasswordModel = DialogPassword.Model 565 DialogModel.Step = iDialogPage 566 InitializeResources() 567 InitializeLanguages() 568 InitializeLocales(oLocale) 569 InitializeCurrencies() 570 InitializeControls() 571 BitmapDir = GetOfficeSubPath("Template", "../wizard/bitmap") 572 If BitmapDir = "" Then 573 Stop 574 End If 575 FillUpCurrencyListbox() 576 DialogModel.imgPreview.ImageUrl = BitmapDir & "euro_" & DialogModel.Step & ".png" 577 DialogConvert.Title = sMsgDLGTITLE 578 DialogModel.cmdGoOn.DefaultButton = True 579 If iDialogPage = 1 Then 580 ToggleWindow(True) 581 End If 582End Sub 583 584 585Sub InitializeCurrencyValues(CurrIndex) 586 If CurrIndex <> -1 Then 587 CurrLanguage = CurrValue(CurrIndex,0) 588 CurrFactor = CurrValue(CurrIndex,1) 589 CurrSymbolList(0) = CurrValue(CurrIndex,3) 590 CurrSymbolList(1) = CurrValue(CurrIndex,4) 591 CurrSymbolList(2) = CurrValue(CurrIndex,5) 592 End If 593End Sub 594 595 596Function InitializeLocales(oLocale) as Boolean 597Dim i as Integer, n as Integer, m as Integer 598Dim sLanguage as String, sCountry as String 599Dim bTakeThisLocale as Boolean 600 sLanguage = oLocale.Language 601 sCountry = oLocale.Country 602 For n = 0 To SBCOUNTRYCOUNT - 1 603 For m = 0 TO 1 604 If DialogModel.Step = 2 Then 605 bTakeThisLocale = LangIDValue(n,m,0) = sLanguage 606 Else 607 bTakeThisLocale = LangIDValue(n,m,0) = sLanguage 608 End If 609 If bTakeThisLocale Then 610 CurrIndex = n 611 For i = 0 To 2 612 CurExtension(i) = LangIDValue(CurrIndex,i,2) 613 Next i 614 InitializeLocales = True 615 Exit Function 616 End If 617 Next m 618 Next n 619 CurrIndex = -1 620 InitializeLocales = False 621End Function 622</script:module> 623