AutoPilotRun.xba (3e02b54d) | AutoPilotRun.xba (79ff0626) |
---|---|
1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3<!--*********************************************************** | 1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3<!--*********************************************************** |
4 * | 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 | 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 * | 12 * |
13 * http://www.apache.org/licenses/LICENSE-2.0 | 13 * http://www.apache.org/licenses/LICENSE-2.0 |
14 * | 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. | 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 * | 21 * |
22 ***********************************************************--> 23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="AutoPilotRun" script:language="StarBasic">Option Explicit 24 25Public SourceDir as String 26Public TargetDir as String 27Public TargetStemDir as String 28Public SourceFile as String 29Public TargetFile as String --- 19 unchanged lines hidden (view full) --- 49 BasicLibraries.LoadLibrary("Tools") 50 BasicLibraries.LoadLibrary("ImportWizard") 51 If InitResources("Euro Converter", "eur") Then 52 oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess") 53 oLocale = GetStarOfficeLocale() 54 InitializeConverter(oLocale, 2) 55 ToggleGoOnButton() 56 oFactoryKey = GetRegistryKeyContent("org.openoffice.Setup/Office/Factories") | 22 ***********************************************************--> 23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="AutoPilotRun" script:language="StarBasic">Option Explicit 24 25Public SourceDir as String 26Public TargetDir as String 27Public TargetStemDir as String 28Public SourceFile as String 29Public TargetFile as String --- 19 unchanged lines hidden (view full) --- 49 BasicLibraries.LoadLibrary("Tools") 50 BasicLibraries.LoadLibrary("ImportWizard") 51 If InitResources("Euro Converter", "eur") Then 52 oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess") 53 oLocale = GetStarOfficeLocale() 54 InitializeConverter(oLocale, 2) 55 ToggleGoOnButton() 56 oFactoryKey = GetRegistryKeyContent("org.openoffice.Setup/Office/Factories") |
57 DialogModel.chkTextDocuments.Enabled = oFactoryKey.hasbyName("com.sun.star.text.TextDocument") | 57 DialogModel.chkTextDocuments.Enabled = oFactoryKey.hasbyName("com.sun.star.text.TextDocument") |
58 DialogModel.cmdGoOn.DefaultButton = True 59 DialogModel.lstCurrencies.TabIndex = 12 60 DialogConvert.GetControl("optWholeDir").SetFocus() 61 DialogConvert.Execute() 62 DialogConvert.Dispose() 63 End If 64End Sub 65 --- 76 unchanged lines hidden (view full) --- 142 oDocument = OpenDocument(SourceFile, OpenProperties(), bDisposable) 143 If (oDocument.IsReadOnly) AND (UCase(SourceFile) = UCase(TargetFile)) Then 144 bIsReadOnly = True 145 Msgbox(sMsgDOCISREADONLY, 16, GetProductName()) 146 Else 147 bIsReadOnly = False 148 RetrieveDocumentObjects() 149 sViewPath = CutPathView(SourceFile, 60) | 58 DialogModel.cmdGoOn.DefaultButton = True 59 DialogModel.lstCurrencies.TabIndex = 12 60 DialogConvert.GetControl("optWholeDir").SetFocus() 61 DialogConvert.Execute() 62 DialogConvert.Dispose() 63 End If 64End Sub 65 --- 76 unchanged lines hidden (view full) --- 142 oDocument = OpenDocument(SourceFile, OpenProperties(), bDisposable) 143 If (oDocument.IsReadOnly) AND (UCase(SourceFile) = UCase(TargetFile)) Then 144 bIsReadOnly = True 145 Msgbox(sMsgDOCISREADONLY, 16, GetProductName()) 146 Else 147 bIsReadOnly = False 148 RetrieveDocumentObjects() 149 sViewPath = CutPathView(SourceFile, 60) |
150 DialogModel.lblCurDocument.Label = Str(DocIndex+1) & "/" & sTotDocCount & " (" & sViewPath & ")" | 150 DialogModel.lblCurDocument.Label = Str(DocIndex+1) & "/" & sTotDocCount & " (" & sViewPath & ")" |
151 End If 152 InitializeDocument() = Not bIsReadOnly 153 Else 154 InitializeDocument() = False 155 End If 156 Else 157 InitializeDocument() = False 158 End If --- 82 unchanged lines hidden (view full) --- 241 DialogModel.lblRetrieval.Label = sPrgsRETRIEVAL 242 DialogModel.lblCurProgress.Label = sPrgsCONVERTING 243 If DialogModel.optWholeDir.State = 1 Then 244 TextBoxText = sSOURCEDIR & " " & ConvertFromUrl(Source) & chr(13) 245 If DialogModel.chkRecursive.State = 1 Then 246 TextBoxText = TextBoxText & DeleteStr(sInclusiveSubDir,"~") & chr(13) 247 End If 248 Else | 151 End If 152 InitializeDocument() = Not bIsReadOnly 153 Else 154 InitializeDocument() = False 155 End If 156 Else 157 InitializeDocument() = False 158 End If --- 82 unchanged lines hidden (view full) --- 241 DialogModel.lblRetrieval.Label = sPrgsRETRIEVAL 242 DialogModel.lblCurProgress.Label = sPrgsCONVERTING 243 If DialogModel.optWholeDir.State = 1 Then 244 TextBoxText = sSOURCEDIR & " " & ConvertFromUrl(Source) & chr(13) 245 If DialogModel.chkRecursive.State = 1 Then 246 TextBoxText = TextBoxText & DeleteStr(sInclusiveSubDir,"~") & chr(13) 247 End If 248 Else |
249 TextBoxText = sSOURCEFILE & " " & ConvertFromUrl(Source) & chr(13) | 249 TextBoxText = sSOURCEFILE & " " & ConvertFromUrl(Source) & chr(13) |
250 End If 251 TextBoxText = TextBoxText & sTARGETDIR & " " & ConvertFromUrl(TargetDir) & chr(13) 252 If DialogModel.chkProtect.State = 1 Then 253 TextBoxText = TextboxText & sPrgsUNPROTECT 254 End If 255 DialogModel.txtConfig.Text = TextBoxText 256 ToggleProgressStep() | 250 End If 251 TextBoxText = TextBoxText & sTARGETDIR & " " & ConvertFromUrl(TargetDir) & chr(13) 252 If DialogModel.chkProtect.State = 1 Then 253 TextBoxText = TextboxText & sPrgsUNPROTECT 254 End If 255 DialogModel.txtConfig.Text = TextBoxText 256 ToggleProgressStep() |
257 DialogModel.cmdGoOn.Enabled = False 258 InitializeThirdStep() = True | 257 DialogModel.cmdGoOn.Enabled = False 258 InitializeThirdStep() = True |
259 Else 260 InitializeThirdStep() = False 261 End If 262End Function 263 264 265Sub ToggleProgressStep(Optional aEvent as Object) 266Dim bMakeVisible as Boolean --- 4 unchanged lines hidden (view full) --- 271 DialogModel.Step = 3 272 Else 273 DialogModel.Step = 2 274 End If 275 DialogConvert.GetControl("lblCurrencies").Visible = Not bMakeVisible 276 DialogConvert.GetControl("lstCurrencies").Visible = Not bMakeVisible 277 DialogConvert.GetControl("cmdBack").Visible = bMakeVisible 278 DialogConvert.GetControl("cmdGoOn").Visible = bMakeVisible | 259 Else 260 InitializeThirdStep() = False 261 End If 262End Function 263 264 265Sub ToggleProgressStep(Optional aEvent as Object) 266Dim bMakeVisible as Boolean --- 4 unchanged lines hidden (view full) --- 271 DialogModel.Step = 3 272 Else 273 DialogModel.Step = 2 274 End If 275 DialogConvert.GetControl("lblCurrencies").Visible = Not bMakeVisible 276 DialogConvert.GetControl("lstCurrencies").Visible = Not bMakeVisible 277 DialogConvert.GetControl("cmdBack").Visible = bMakeVisible 278 DialogConvert.GetControl("cmdGoOn").Visible = bMakeVisible |
279 DialogModel.imgPreview.ImageUrl = BitmapDir & "euro_" & DialogModel.Step & ".bmp" | 279 DialogModel.imgPreview.ImageUrl = BitmapDir & "euro_" & DialogModel.Step & ".png" |
280End Sub 281 282 283Sub EnableStep2DialogControls(OnValue as Boolean) 284 With DialogModel 285 .hlnExtent.Enabled = OnValue 286 .optWholeDir.Enabled = OnValue 287 .optSingleFile.Enabled = OnValue --- 37 unchanged lines hidden (view full) --- 325 bIsValid = oUcb.Exists(sPath) 326 If bIsValid Then 327 If DialogModel.optSingleFile.State = 1 Then 328 If bCheckFileType Then 329 sLocMimeType = GetRealFileContent(sPath) 330 If DialogModel.chkTextDocuments.State = 1 Then 331 If (Instr(1, sLocMimeType, "text") = 0) And (Instr(1, sLocMimeType, "calc") = 0) Then 332 Msgbox(sMsgFileInvalid, 48, sMsgDLGTITLE) | 280End Sub 281 282 283Sub EnableStep2DialogControls(OnValue as Boolean) 284 With DialogModel 285 .hlnExtent.Enabled = OnValue 286 .optWholeDir.Enabled = OnValue 287 .optSingleFile.Enabled = OnValue --- 37 unchanged lines hidden (view full) --- 325 bIsValid = oUcb.Exists(sPath) 326 If bIsValid Then 327 If DialogModel.optSingleFile.State = 1 Then 328 If bCheckFileType Then 329 sLocMimeType = GetRealFileContent(sPath) 330 If DialogModel.chkTextDocuments.State = 1 Then 331 If (Instr(1, sLocMimeType, "text") = 0) And (Instr(1, sLocMimeType, "calc") = 0) Then 332 Msgbox(sMsgFileInvalid, 48, sMsgDLGTITLE) |
333 bIsValid = False 334 End If | 333 bIsValid = False 334 End If |
335 Else 336 If (Instr(1, sLocMimeType, "spreadsheet") = 0) And (Instr(1, sLocMimeType, "calc")) = 0 Then 337 Msgbox(sMsgFileInvalid, 48, sMsgDLGTITLE) 338 bIsValid = False 339 End If 340 End If 341 End If 342 Else 343 If Not oUcb.IsFolder(sPath) Then 344 sNoDirMessage = ReplaceString(sMsgNODIRECTORY,sPath,"<1>") 345 Msgbox(sNoDirMessage,48, sMsgDLGTITLE) 346 bIsValid = False 347 Else 348 sPath = RTrimStr(sPath,"/") 349 sPath = sPath & "/" 350 End If 351 End if 352 Else | 335 Else 336 If (Instr(1, sLocMimeType, "spreadsheet") = 0) And (Instr(1, sLocMimeType, "calc")) = 0 Then 337 Msgbox(sMsgFileInvalid, 48, sMsgDLGTITLE) 338 bIsValid = False 339 End If 340 End If 341 End If 342 Else 343 If Not oUcb.IsFolder(sPath) Then 344 sNoDirMessage = ReplaceString(sMsgNODIRECTORY,sPath,"<1>") 345 Msgbox(sNoDirMessage,48, sMsgDLGTITLE) 346 bIsValid = False 347 Else 348 sPath = RTrimStr(sPath,"/") 349 sPath = sPath & "/" 350 End If 351 End if 352 Else |
353 Msgbox(HeaderString & " '" & ConvertFromUrl(sPath) & "' " & sMsgNOTTHERE,48, sMsgDLGTITLE) | 353 Msgbox(HeaderString & " '" & ConvertFromUrl(sPath) & "' " & sMsgNOTTHERE,48, sMsgDLGTITLE) |
354 End If 355 If bIsValid Then 356 AssignFileName() = sPath 357 Else 358 AssignFilename() = "" 359 End If 360End Function 361 362 363Sub ToggleGoOnButton() | 354 End If 355 If bIsValid Then 356 AssignFileName() = sPath 357 Else 358 AssignFilename() = "" 359 End If 360End Function 361 362 363Sub ToggleGoOnButton() |
364Dim bDoEnable as Boolean | 364Dim bDoEnable as Boolean |
365Dim sLocMimeType as String 366Dim sPath as String 367 bDoEnable = Ubound(DialogModel.lstCurrencies.SelectedItems()) > -1 368 If bDoEnable Then 369 ' Check if Source is set correctly 370 sPath = ConvertToUrl(Trim(DialogModel.txtSource.Text)) 371 bDoEnable = oUcb.Exists(sPath) 372 End If 373 DialogModel.cmdGoOn.Enabled = bDoEnable 374End Sub 375 376 377Sub CallFolderPicker() 378 GetFolderName(DialogModel.txtTarget) | 365Dim sLocMimeType as String 366Dim sPath as String 367 bDoEnable = Ubound(DialogModel.lstCurrencies.SelectedItems()) > -1 368 If bDoEnable Then 369 ' Check if Source is set correctly 370 sPath = ConvertToUrl(Trim(DialogModel.txtSource.Text)) 371 bDoEnable = oUcb.Exists(sPath) 372 End If 373 DialogModel.cmdGoOn.Enabled = bDoEnable 374End Sub 375 376 377Sub CallFolderPicker() 378 GetFolderName(DialogModel.txtTarget) |
379 ToggleGoOnButton() | 379 ToggleGoOnButton() |
380End Sub 381 382 383Sub CallFilePicker() 384 If DialogModel.optSingleFile.State = 1 Then 385 Dim oMasterKey as Object 386 Dim oTypes() as Object 387 Dim oUIKey() as Object | 380End Sub 381 382 383Sub CallFilePicker() 384 If DialogModel.optSingleFile.State = 1 Then 385 Dim oMasterKey as Object 386 Dim oTypes() as Object 387 Dim oUIKey() as Object |
388 | 388 |
389 oMasterKey = GetRegistryKeyContent("org.openoffice.TypeDetection.Types") 390 oTypes() = oMasterKey.Types 391 oUIKey = GetRegistryKeyContent("org.openoffice.Office.UI/FilterClassification/LocalFilters") 392 If DialogModel.chkTextDocuments.State = 1 Then 393 Dim FilterNames(11,1) as String 394 FilterNames(6,0) = oTypes.GetByName("writer_StarOffice_XML_Writer").UIName 395 FilterNames(6,1) = "*.sxw" 396 FilterNames(7,0) = oTypes.GetByName("writer_StarOffice_XML_Writer_Template").UIName --- 4 unchanged lines hidden (view full) --- 401 Filternames(9,1) = "*.vor" 402 FilterNames(10,0) = oTypes.GetByName("writer8").UIName 403 FilterNames(10,1) = "*.odt" 404 FilterNames(11,0) = oTypes.GetByName("writer8_template").UIName 405 FilterNames(11,1) = "*.ott" 406 Else 407 ReDim FilterNames(5,1) as String 408 End If | 389 oMasterKey = GetRegistryKeyContent("org.openoffice.TypeDetection.Types") 390 oTypes() = oMasterKey.Types 391 oUIKey = GetRegistryKeyContent("org.openoffice.Office.UI/FilterClassification/LocalFilters") 392 If DialogModel.chkTextDocuments.State = 1 Then 393 Dim FilterNames(11,1) as String 394 FilterNames(6,0) = oTypes.GetByName("writer_StarOffice_XML_Writer").UIName 395 FilterNames(6,1) = "*.sxw" 396 FilterNames(7,0) = oTypes.GetByName("writer_StarOffice_XML_Writer_Template").UIName --- 4 unchanged lines hidden (view full) --- 401 Filternames(9,1) = "*.vor" 402 FilterNames(10,0) = oTypes.GetByName("writer8").UIName 403 FilterNames(10,1) = "*.odt" 404 FilterNames(11,0) = oTypes.GetByName("writer8_template").UIName 405 FilterNames(11,1) = "*.ott" 406 Else 407 ReDim FilterNames(5,1) as String 408 End If |
409 FilterNames(0,0) = oTypes.GetByName("calc_StarOffice_XML_Calc").UIName | 409 FilterNames(0,0) = oTypes.GetByName("calc_StarOffice_XML_Calc").UIName |
410 Filternames(0,1) = "*.sxc" 411 FilterNames(1,0) = oTypes.GetByName("calc_StarOffice_XML_Calc_Template").UIName 412 Filternames(1,1) = "*.stc" 413 FilterNames(2,0) = oUIKey.Classes.GetByName("sc345").DisplayName 414 FilterNames(2,1) = "*.sdc" 415 FilterNames(3,0) = oUIKey.Classes.GetByName("sc345templ").DisplayName 416 Filternames(3,1) = "*.vor" | 410 Filternames(0,1) = "*.sxc" 411 FilterNames(1,0) = oTypes.GetByName("calc_StarOffice_XML_Calc_Template").UIName 412 Filternames(1,1) = "*.stc" 413 FilterNames(2,0) = oUIKey.Classes.GetByName("sc345").DisplayName 414 FilterNames(2,1) = "*.sdc" 415 FilterNames(3,0) = oUIKey.Classes.GetByName("sc345templ").DisplayName 416 Filternames(3,1) = "*.vor" |
417 FilterNames(4,0) = oTypes.GetByName("calc8").UIName | 417 FilterNames(4,0) = oTypes.GetByName("calc8").UIName |
418 Filternames(4,1) = "*.ods" | 418 Filternames(4,1) = "*.ods" |
419 FilterNames(5,0) = oTypes.GetByName("calc8_template").UIName | 419 FilterNames(5,0) = oTypes.GetByName("calc8_template").UIName |
420 Filternames(5,1) = "*.ots" 421 GetFileName(DialogModel.txtSource, Filternames()) 422 Else 423 GetFolderName(DialogModel.txtSource) 424 End If 425 ToggleGoOnButton() 426End Sub 427 428 429Sub PreviousStep() 430 DialogModel.Step = 2 | 420 Filternames(5,1) = "*.ots" 421 GetFileName(DialogModel.txtSource, Filternames()) 422 Else 423 GetFolderName(DialogModel.txtSource) 424 End If 425 ToggleGoOnButton() 426End Sub 427 428 429Sub PreviousStep() 430 DialogModel.Step = 2 |
431 DialogModel.cmdGoOn.Label = sGOON | 431 DialogModel.cmdGoOn.Label = sGOON |
432 DialogModel.cmdCancel.Label = sCANCEL 433End Sub 434</script:module> | 432 DialogModel.cmdCancel.Label = sCANCEL 433End Sub 434</script:module> |