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