/usr/lib/libreoffice/share/extensions/DmathsAddon/BatchConv/Module1.xba is in libreoffice-dmaths 3.4+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">'************************************************
'Copyright (C) 2003 Laurent Godard
'oooconv@free.fr
'This library is free software; you can redistribute it and/or
'modify it under the terms of the GNU Lesser General Public
'License as published by the Free Software Foundation; either
'version 2.1 of the License, or (at your option) any later version.
'This library is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
'Lesser General Public License for more details.
'You should have received a copy of the GNU Lesser General Public
'License along with this library; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'************************************************
' --------------------------
' modifié le 20/04/2004 par Cédric Durmont (durmont@yahoo.fr)
' --------------------------
' Ajout de la fonctionnalité : "ajout d'un dossier"
' Procédures et fonctions ajoutées :
' - ajouteDossier : equivalent de AjouteFichier, mais qui appelle GetFileNamesFromDir plutôt que GetFileNames
' - GetFileNamesFromDir : Equivalent de GetFileNames mais affichant un dialogue "choix de dossier"
' - GetFilesFromDir : obtient à partir d'un nom de dossier un tableau des fichiers bureautiques
' contenus (dans le dossier ou un sous dossier quelconque)
' - FormatSupporte : teste si un nom de fichier désigne un fichier bureautique. Le test porte sur l'extension (.xxx)
' La liste des extensions est "en dur" pour le moment. Renvoie true dans le cas d'un fichier bureautique, false sinon
' --------------------------
Option Explicit
dim Feuille as object, oDlg as object
dim CodeExten(1 to 16) as string
dim traduction(0 to 20) as string
Sub Main
dim button as object, file2 as object
dim pgb as object, ListeExt as object, Liste as object
Call VerifOperationnel
DialogLibraries.loadLibrary("BatchConv")
BasicLibraries.loadLibrary("Dmaths")
Feuille=DialogLibraries.BatchConv.Convert
oDlg=CreateUnoDialog(Feuille )
'Initialisation
button=odlg.GetControl("CommandButton6")
file2=odlg.GetControl("File2")
pgb=odlg.GetControl("pgb")
button.visible=false
file2.visible=false
pgb.visible=false
Rem SelectedLangNumber est le numéro de la langue chargée
Liste=odlg.GetControl("LstLangue")
If SelectLangNumber <=2 Then Liste.selectitempos(SelectLangNumber,true) Else Liste.selectitempos(1,true)
call TraduireFeuille()
ListeExt=oDlg.GetControl("LstExp")
Call RempliListeExport(ListeExt)
oDlg.execute
End Sub
Sub Fin()
'Ferme la fenêtre
odlg.endExecute
end sub
Sub MontreFichier()
on error resume next
dim args()
dim oDesktop as object, oDocument as object
dim surl as string
dim Liste as object
oDesktop=createUnoService("com.sun.star.frame.Desktop")
Liste=odlg.GetControl("Liste1")
sUrl=ConvertToURL(Liste.GetSelectedItem)
oDocument=oDesktop.loadComponentFromURL(surl,"_blank",0,args())
end sub
sub AjouteFichier()
dim File1 as object, nomFichier as string
dim Liste as object
dim lesFichiers()
dim i as long
dim RepBase as string
dim nb as Long
Liste=odlg.GetControl("Liste1")
GetFileNames(lesFichiers)
if lbound(lesfichiers)<=ubound(lesfichiers) then ' ce test est faux si l'utilisateur n'a pas choisi de fichier
if lbound(lesfichiers)=ubound(lesfichiers) then
'only one file - path included
Liste.additem(ConvertFromUrl(LesFichiers(lbound(lesfichiers))), liste.GetItemCount)
nb=(ubound(lesfichiers)-lbound(lesfichiers))+1
else
RepBase=lesfichiers(lbound(lesfichiers))
for i=lbound(lesfichiers)+1 to ubound(lesfichiers)
Liste.additem(ConvertFromUrl(repBase+"/"+LesFichiers(i)), liste.GetItemCount)
next i
nb=(ubound(lesfichiers)-lbound(lesfichiers)) ' un de moins pour ne pas compter la ligne qui contenait le nom du dossier
endif
MsgBox nb & traduction(15),64,traduction(16)
endif
end sub
' --------------------------------
' -- AjouteDossier --
' --------------------------------
sub AjouteDossier()
dim File1 as object, nomFichier as string
dim Liste as object
dim lesFichiers()
dim i as long
dim RepBase as string
dim nb as long
Liste=odlg.GetControl("Liste1")
GetFileNamesFromDir(lesFichiers)
if lbound(lesfichiers)<=ubound(lesfichiers) then ' ce test est faux si l'utilisateur n'a pas choisi de fichier
RepBase=lesfichiers(lbound(lesfichiers))
for i=lbound(lesfichiers) to ubound(lesfichiers)
Liste.additem(LesFichiers(i), liste.GetItemCount)
next i
nb=(ubound(lesfichiers)-lbound(lesfichiers)+1)
MsgBox nb & traduction(15),64,traduction(16)
endif
end sub
' --------------------------------
sub EnleveFichier()
dim position as long
dim Liste as object
Liste=odlg.GetControl("Liste1")
position=Liste.GetSelectedItemPos()
Liste.removeitems(position,1)
end sub
Sub AfficheChoixRep()
dim status as boolean
dim bouton as object, file2 as object, radio as object
radio=odlg.GetControl("Radio1")
bouton=odlg.GetControl("CommandButton6")
file2=odlg.GetControl("File2")
status=(radio.state=0)
bouton.visible=status
file2.visible=status
end sub
sub ChoisirRep()
odlg.getControl("File2").text=GetFolderName()
end sub
sub Exporter
on error resume Next
dim Liste as object, LstExp as object, File2 as object
dim radio as object, pgb as object
dim Titre as string, ListeFichiers() as string, export as string
dim NomRep as string, NbFichiers as long
dim Erreur as boolean, nouveauRep as boolean
dim NomFichier as string
dim i as long, j as long
dim IsGraphic as boolean
'Declaration paor l'export proprement dit
dim args()
dim oDesktop as object, oDocument as object
dim surl as string, ExtDest as string
dim args2(0) as new com.sun.star.beans.PropertyValue
dim args3(1) as new com.sun.star.beans.PropertyValue
dim oPages as object, oGraphic as object
Titre=traduction(0)
'Contrôle de la saisie des paramètres
Liste=odlg.GetControl("Liste1")
if Liste.getitemcount=0 then
msgbox traduction(10),16,Titre
erreur=true
endif
LstExp=odlg.GetControl("LstExp")
export=ucase(trim(LstExp.getSelectedItem))
if export="" then
msgbox traduction(11),16,Titre
erreur=true
endif
NouveauRep=false
radio=odlg.GetControl("Radio2")
if radio.state<>0 then
NouveauRep=true
file2=odlg.GetControl("File2")
NomRep=file2.text
if NomRep="" then
msgbox traduction(12),16,Titre
erreur=true
endif
endif
if erreur then exit sub
'récupere la liste des fichiers
ListeFichiers=Liste.getItems()
NbFichiers=ubound(ListeFichiers)
'progress bar
pgb=odlg.GetControl("pgb")
call pgb.setrange(0,NbFichiers+1)
pgb.visible=true
'Position Export
export=CodeExten(LstExp.getSelectedItemPos()+1)
'Boucle sur l'export
for i=0 to NbFichiers
call pgb.setvalue(i+1)
if NouveauRep then
NomRep=iif(right(Nomrep,1)="/",NomRep,NomRep+"/")
NomFichier=NomRep+dir(ListeFichiers(i))
else
NomFichier=ListeFichiers(i)
endif
oDesktop=createUnoService("com.sun.star.frame.Desktop")
sURL=ConvertToURL(ListeFichiers(i))
oDocument=oDesktop.loadComponentFromURL(surl,"_blank",0,args())
args2(0).Name = "FilterName"
args2(0).Value = TrouveFilterName(oDocument,export,ExtDest,IsGraphic)
if args2(0).Value<>"" then
if not IsGraphic then
NomFichier=ConvertToURL(NomFichier+ExtDest)
odocument.storeToURL(NomFichier,args2())
else
oGraphic=CreateUnoService("com.sun.star.drawing.GraphicExportFilter")
for j=0 to odocument.drawpages.getcount()-1
opage=odocument.drawPages(j)
ographic.setSourceDocument(opage)
args3(0).Name = "URL"
args3(0).Value =ConvertToURL(NomFichier+"-"+opage.name+ ExtDest)
args3(1).Name = "MediaType"
args3(1).Value = args2(0).Value
oGraphic.filter(args3())
next j
endif
endif
oDocument.dispose()
next i
call pgb.setvalue(NbFichiers+1)
pgb.visible=false
end sub
Function TrouveFilterName(oDoc as object, typedoc as string,ExtDest as string, IsGraphic as boolean) as string
Dim FilterName as string
FilterName=""
IsGraphic=false
if oDoc.SupportsService("com.sun.star.text.TextDocument") then
'Writer
select case typedoc
case "PDF":
FilterName="writer_pdf_Export"
ExtDESt=".pdf"
case "OOO":
FilterName="StarOffice XML (Writer)"
ExtDESt=".odt"
case "MSXP":
FilterName="MS Word 97"
ExtDESt=".doc"
case "MS95":
FilterName="MS Word 95"
ExtDESt=".doc"
case "MS60":
FilterName="MS WinWord 6.0"
ExtDESt=".doc"
case "RTF":
FilterName="Rich Text Format"
ExtDESt=".rtf"
case "HTML":
FilterName="HTML (StarWriter)"
ExtDESt=".html"
case "XHTML":
FilterName="XHTML plus MathML File"
ExtDESt=".xhtml"
case "TEX":
FilterName="Latex File"
ExtDESt=".tex"
case "TXT":
FilterName="Text"
ExtDESt=".txt"
end select
TrouveFilterName=FilterName
Exit Function
endif
if oDoc.SupportsService("com.sun.star.sheet.SpreadsheetDocument") then
'Calc
select case typedoc
case "PDF":
FilterName="calc_pdf_Export"
ExtDESt=".pdf"
case "OOO":
FilterName="StarOffice XML (Calc)"
ExtDESt=".ods"
case "MSXP":
FilterName="MS Excel 97"
ExtDESt=".xls"
case "MS95":
FilterName="MS Excel 95"
ExtDESt=".xls"
case "MS50":
FilterName="MS Excel 5.0/95"
ExtDESt=".xls"
case "HTML":
FilterName="HTML (StarCalc)"
ExtDESt=".html"
case "TXT":
FilterName="Text"
ExtDESt=".txt"
end select
TrouveFilterName=FilterName
Exit Function
endif
'if oDoc.SupportsService("com.sun.star.text.WebDocument") then
'Web
'Exit Function
'endif
if oDoc.SupportsService("com.sun.star.presentation.PresentationDocument") then
'Impress
select case typedoc
case "PDF":
FilterName="impress_pdf_Export"
ExtDESt=".pdf"
case "OOO":
FilterName="StarOffice XML (Impress)"
ExtDESt=".odp"
case "MSXP":
FilterName="MS Powerpoint 97"
ExtDESt=".ppt"
case "JPG":
FilterName="image/jpeg"
ExtDESt=".jpg"
IsGraphic=true
case "PNG":
FilterName="image/png"
ExtDESt=".png"
IsGraphic=true
case "TIFF":
FilterName="image/tiff"
ExtDESt=".tif"
IsGraphic=true
case "SVG":
FilterName="image/svg+xml"
ExtDESt=".svg"
IsGraphic=true
case "EPS":
FilterName="application/postscript"
ExtDESt=".eps"
IsGraphic=true
case "SWF":
FilterName="impress_flash_Export"
ExtDESt=".swf"
case "HTML":
FilterName="impress_html_Export"
ExtDESt=".html"
end select
TrouveFilterName=FilterName
Exit Function
endif
if oDoc.SupportsService("com.sun.star.drawing.DrawingDocument") then
'Draw
select case typedoc
case "PDF":
FilterName="draw_pdf_Export"
ExtDESt=".pdf"
case "OOO":
FilterName="StarOffice XML (Draw)"
ExtDESt=".odg"
case "JPG":
FilterName="image/jpeg"
ExtDESt=".jpg"
IsGraphic=true
case "PNG":
FilterName="image/png"
ExtDESt=".png"
IsGraphic=true
case "TIFF":
FilterName="image/tiff"
ExtDESt=".tif"
IsGraphic=true
case "SVG":
FilterName="image/svg+xml"
ExtDESt=".svg"
IsGraphic=true
case "EPS":
FilterName="application/postscript"
ExtDESt=".eps"
IsGraphic=true
case "SWF":
FilterName="draw_flash_Export"
ExtDESt=".swf"
case "HTML":
FilterName="draw_html_Export"
ExtDESt=".swf"
end select
TrouveFilterName=FilterName
Exit Function
endif
end function
sub RempliListeExport(oListe as object)
Dim i as long, j as long
'Nettoyage de la liste
while oListe.getItemCount > 0
oListe.removeitems(oListe.getItemCount-1,1)
wend
'Definition Tableau
Dim Libelle(16) as string
i=0
if clng(getSolarVersion) >= 644 then
i=i+1:Libelle(i)="PDF":CodeExten(i)="PDF"
endif
i=i+1:Libelle(i)="OpenOffice":CodeExten(i)="OOO"
i=i+1:Libelle(i)="Microsoft Office 97/2000/XP":CodeExten(i)="MSXP"
if clng(getSolarVersion) >= 644 then
i=i+1:Libelle(i)="Flash":CodeExten(i)="SWF"
endif
i=i+1:Libelle(i)="HTML":CodeExten(i)="HTML"
i=i+1:Libelle(i)="Fichier Texte":CodeExten(i)="TXT"
i=i+1:Libelle(i)="RTF":CodeExten(i)="RTF"
i=i+1:Libelle(i)="Image JPG":CodeExten(i)="JPG"
i=i+1:Libelle(i)="Image PNG":CodeExten(i)="PNG"
i=i+1:Libelle(i)="Image TIFF":CodeExten(i)="TIF"
i=i+1:Libelle(i)="Image SVG":CodeExten(i)="SVG"
i=i+1:Libelle(i)="Image EPS":CodeExten(i)="EPS"
i=i+1:Libelle(i)="Microsoft Word 95":CodeExten(i)="MS95"
i=i+1:Libelle(i)="Microsoft Winword 6.0":CodeExten(i)="MS60"
i=i+1:Libelle(i)="Microsoft Excel 95":CodeExten(i)="MS95"
i=i+1:Libelle(i)="Microsoft Excel 5.0":CodeExten(i)="MS50"
'Necessite AddOn
'i=i+1:Libelle(i)="XHTML"
'i=i+1:Libelle(i)="LaTex 2e"
'Remplissage
for j=1 to i
oListe.additem(Libelle(j),j-1)
next j
end Sub
Sub TraduireFeuille()
dim NumLangue as long
dim objet as object
'Récupère la langue
objet=odlg.GetControl("LstLangue")
NumLangue=objet.GetSelectedItemPos()
'Construit le tableau suivant la langue
select Case NumLangue
case 0: 'Français
traduction(0)="Dmaths : BatchConv"
traduction(1)="Choisir un fichier"
traduction(2)="Prévisualiser"
traduction(3)="Ajouter des fichiers"
traduction(4)="Exporter vers"
traduction(5)="Chaque Fichier dans son répertoire d'origine"
traduction(6)="Tous les fichiers dans le même répertoire"
traduction(7)="Sélectionner un fichier dans le répertoire désiré"
traduction(8)="Annuler"
traduction(9)="Transformer"
traduction(10)="Liste Vide"
traduction(11)="Choisir un format d'export"
traduction(12)="Saisir un répertoire de destination"
traduction(13)="Langue"
traduction(14)="Ajouter un dossier"
traduction(15)=" Documents ont été ajoutés pour conversion."
traduction(16)="Recherche des fichiers terminée"
traduction(17)="Ne pas inclure les sous-dossiers du dossier sélectionné"
case 2: 'Deutsch
traduction(0)="Dmaths : BatchConv"
traduction(1)="Wahl der Datei"
traduction(2)="Vorschau"
traduction(3)="Datei hinzufügen"
traduction(4)="Export-Format"
traduction(5)="Jede Datei in ihrem Original-Verzeichnis"
traduction(6)="Alle Dateien im selben Verzeichnis"
traduction(7)="Wählen Sie eine Datei im gewünschten Verzeichnis aus"
traduction(8)="Abbruch"
traduction(9)="Start der Umwandlung"
traduction(10)="Die Liste ist leer!"
traduction(11)="Wählen Sie ein Export-Format !"
traduction(12)="Bestimmen Sie ein Zielverzeichnis"
traduction(13)="Sprache"
traduction(14)="Verzeichnis hinzufügen"
traduction(15)=" Dokument(e) für die Umwandlung hinzugefügt."
traduction(16)="Dateiuntersuchung beendet"
traduction(17)="Unterverzeichnisse des gewählten Verzeichnisses nicht einchließen"
traduction(18)="Textdatei" 'fichier texte
traduction(19)="Bild" '... image
case 3:
'Thanks to Arturo Garro - Costa Rica
traduction(0)="Dmaths : BatchConv"
traduction(1)="Escoger un archivo"
traduction(2)="Vista previa"
traduction(3)="Agragar archivo a la lista"
traduction(4)="Exportar a"
traduction(5)="Cada archivo convertido en el directorio fuente"
traduction(6)="Todos los archivos convertidos en el mismo directorio"
traduction(7)="Seleccione un archivo en el directorio destino"
traduction(8)="Cancelar"
traduction(9)="Lista de exportación"
traduction(10)="Lista vacía"
traduction(11)="Escoja un formato de exportación"
traduction(12)="Escoja un directorio destino"
traduction(13)="Lenguaje"
traduction(14)="Agragar directorio"
case 4:
traduction(0)="Dmaths : BatchConv"
traduction(1)="Pasirink bylą"
traduction(2)="Peržiūra"
traduction(3)="Pridėti šią bylą į sąrašą"
traduction(4)="Konvertuoti į"
traduction(5)="Each converted file in the source directory"
traduction(6)="All converted files in the same directory"
traduction(7)="Pasirinkite bylą paskirties kataloge"
traduction(8)="Atsisakyti"
traduction(9)="Konvertuoti dokumentus"
traduction(10)="Tuščias sąrašas"
traduction(11)="Pasirinkite į kokį formatą konvertuosite"
traduction(12)="Nurodykite paskirties katalogą"
traduction(13)="Kalba"
traduction(14)="Add a directory"
case else: 'Anglais
traduction(0)="Dmaths : BatchConv"
traduction(1)="Choose a file"
traduction(2)="Preview"
traduction(3)="Add files to the list"
traduction(4)="Export to"
traduction(5)="Each converted file in the source directory"
traduction(6)="All converted files in the same directory"
traduction(7)="Select a file in the target directory"
traduction(8)="Cancel"
traduction(9)="Export List"
traduction(10)="Empty List"
traduction(11)="Choose an export format"
traduction(12)="Choose a target directory"
traduction(13)="Language"
traduction(14)="Add a directory"
traduction(15)=" Files were added to the list."
traduction(16)="File search complete"
traduction(17)="Do not include the subfolders of the selected folder"
end select
'Rafraichi la boite de dialogue
odlg.title=traduction(0)
objet=odlg.GetControl("Label4"):objet.text=traduction(13)
'objet=odlg.GetControl("Label1"):objet.text=traduction(1)
objet=odlg.GetControl("CommandButton5"):objet.label=traduction(2)
objet=odlg.GetControl("CommandButton4"):objet.label=traduction(3)
objet=odlg.GetControl("Label2"):objet.text=traduction(4)
objet=odlg.GetControl("Radio1"):objet.label=traduction(5)
objet=odlg.GetControl("Radio2"):objet.label=traduction(6)
objet=odlg.GetControl("CommandButton6"):objet.label=traduction(12)
objet=odlg.GetControl("CommandButton3"):objet.label=traduction(8)
objet=odlg.GetControl("CommandButton1"):objet.label=traduction(9)
' ajouté par Cédric Durmont
objet=odlg.GetControl("CommandButton7"):objet.label=traduction(14)
' ajouté par Didier Dorange-Pattoret
objet=odlg.GetControl("CheckBox1"):objet.label=traduction(17)
end sub
' --------------------------------
Function GetFileNames(lesFichiers()) as variant
' --------------------------------
Dim oFileDialog as Object
Dim iAccept as Integer
Dim sPath as String
Dim InitPath as String
Dim RefControlName as String
Dim oUcb as object
on error resume next
'Dim ListAny(0)
'Note: The following services have to be called in the following order
' because otherwise Basic does not remove the FileDialog Service
oFileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
'ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE
'oFileDialog.initialize(ListAny())
'AddFiltersToDialog(FilterNames(), oFileDialog)
'InitPath = ConvertToUrl(oRefModel.Text)
'If InitPath = "" Then
InitPath = GetPathSettings("Work")
'End If
If oUcb.Exists(InitPath) Then
oFileDialog.SetDisplayDirectory(InitPath)
End If
oFileDialog.setMultiSelectionMode(true)
iAccept = oFileDialog.Execute()
If iAccept = 1 Then
LesFichiers=oFileDialog.files()
End If
oFileDialog.Dispose()
End function
' --------------------------------
' Affiche le dialogue de sélection de dossier et récupère la liste des fichiers bureautique
' --------------------------------
Function GetFileNamesFromDir(lesFichiers()) as variant
Dim oFolderDialog as Object
Dim iAccept as Integer
Dim sPath as String
Dim InitPath as String
Dim RefControlName as String
Dim oUcb as object
on error resume next
'Note: The following services have to be called in the following order
' because otherwise Basic does not remove the FileDialog Service
oFolderDialog = CreateUnoService("com.sun.star.ui.dialogs.FolderPicker")
oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
InitPath = GetPathSettings("Work")
If oUcb.Exists(InitPath) Then
oFolderDialog.SetDisplayDirectory(InitPath)
End If
iAccept = oFolderDialog.Execute()
If iAccept = 1 Then
sPath = oFolderDialog.GetDirectory()
LesFichiers = getFilesFromDir(sPath)
'If oUcb.Exists(sPath) Then
' GetFolderName = ConvertFromUrl(sPath)
'End If
End If
End function
' --------------------------------
' Retourne une liste des fichiers bureautique contenus dans myDir (fonction pseudo-récursive)
' --------------------------------
function getFilesFromDir(myDir as String) as variant
dim fileList(0) as String ' ma liste des fichiers
dim dirList(0) as String ' liste des dossiers à explorer
dim fileNb as Long ' nombre de fichiers
dim dirNb as Long ' nombre de dossiers
dim currentDir as String ' dossier courant
dim currentDir1 as String ' masque de recherche courant (=dossier courant + "\*")
dim myDir1 as String
dim fic as String
dim fini as Boolean
fileNb=0
dirNb=0
myDir1= ConvertFromUrl(myDir)
currentDir=myDir1
fini=False
do
currentDir1=currentDir+getPathSeparator()+"*"
' liste tous les éléments de currentDir (fichiers)
fic = Dir$(currentDir1,0+2+4)
while fic > ""
' met les fichiers dans le tableau fileList()
if (formatSupporte(fic)) then ' ce fichier est-il un fichier bureautique ?
fileList(fileNb)=currentDir + getPathSeparator() + fic
fileNb=fileNb+1
ReDim Preserve fileList(fileNb) as String ' augmente la taille du tableau pour l'élément suivant
end if
fic = Dir$
wend
' liste tous les éléments de currentDir (dossiers)
If odlg.GetControl("CheckBox1").State = 0 Then ' si on inclut les sous-dossiers du dossier sélectionné.
fic = Dir$(currentDir1,16)
while fic > ""
if (fic <> "." and fic <> "..") then
' met les dossiers (sauf . et ..) dans le tableau dirList()
dirList(dirNb)=currentDir + getPathSeparator() + fic
dirNb=dirNb+1
ReDim Preserve dirList(dirNb) as String ' augmente la taille du tableau pour l'élément suivant
end if
fic = Dir$
wend
' si dirList() est non vide, retire un élément de dirList() et le met dans currentDir
Endif
if dirNb>0 then
dirNb=dirNb-1
currentDir=dirList(dirNb)
else
fini = True
end if
' sinon sort du do...loop
loop until fini
ReDim Preserve fileList(fileNb-1) as String ' j'ajuste la taille du tableau
getFilesFromDir = fileList()
end function
'----------------------------------------
'-- teste si nomFic est un fichier bureautique
'----------------------------------------
function formatSupporte(nomFic) as Boolean
dim i as Integer
dim ext(8) as String
dim retour as Boolean
ext(0)=".doc"
ext(1)=".xls"
ext(2)=".ppt"
ext(3)=".sxw"
ext(4)=".sxc"
ext(5)=".sxi"
ext(6)=".sxg"
ext(7)=".rtf"
ext(8)=".csv"
' etc, etc...
retour=false
for i=0 to 8
if (Right(Lcase(nomFic),4)= ext(i)) then
retour=true
end if
next
formatSupporte=retour
end function
function GetFolderName() as string
Dim oFolderDialog as Object
Dim iAccept as Integer
Dim sPath as String
Dim InitPath as String
Dim RefControlName as String
Dim oUcb as object
on error resume next
'Note: The following services have to be called in the following order
' because otherwise Basic does not remove the FileDialog Service
oFolderDialog = CreateUnoService("com.sun.star.ui.dialogs.FolderPicker")
oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
InitPath = GetPathSettings("Work")
If oUcb.Exists(InitPath) Then
oFolderDialog.SetDisplayDirectory(InitPath)
End If
iAccept = oFolderDialog.Execute()
If iAccept = 1 Then
sPath = oFolderDialog.GetDirectory()
If oUcb.Exists(sPath) Then
GetFolderName = ConvertFromUrl(sPath)
End If
End If
End function
Function GetPathSettings(sPathType as String, Optional bshowall as Boolean, Optional ListIndex as integer) as String
Dim oSettings, oPathSettings as Object
Dim sPath as String
Dim PathList() as String
Dim MaxIndex as Integer
Dim oUcb as Object
oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
oSettings = createUnoService("com.sun.star.frame.Settings")
oPathSettings = oSettings.getByName("PathSettings")
If Not IsMissing(bShowall) Then
If bShowAll Then
ShowPropertyValues(oPathSettings)
Exit Function
End If
End If
sPath = oPathSettings.GetPropertyValue(sPathType)
If Not IsMissing(ListIndex) Then
' Share and User-Directory
If Instr(1,sPath,";") <> 0 Then
PathList = ArrayoutofString(sPath,";", MaxIndex)
If ListIndex <= MaxIndex Then
sPath = PathList(ListIndex)
Else
Msgbox("String Cannot be analyzed!" & sPath , 16, GetProductName())
End If
End If
End If
If Instr(1, sPath, ";") = 0 Then
GetPathSettings = ConvertToUrl(sPath)
Else
GetPathSettings = sPath
End If
End Function
Function SelectLangNumber as Integer
Dim iLangNumber as integer
Dim oPathSubstSrv as Object
Dim sLangPath as String
If Globalscope.BasicLibraries.HasByName("Dmaths") Then
Globalscope.BasicLibraries.loadLibrary("Dmaths")
If iLang <=2 Then iLangNumber=iLang Else iLangNumber = 1
Else
oPathSubstSrv = createUnoService("com.sun.star.comp.framework.PathSubstitution")
sLangPath = ConvertFromUrl(oPathSubstSrv.getSubstituteVariableValue("$(vlang)"))
Select Case sLangPath
Case "french"
iLangNumber = 0
Case "german"
iLangNumber = 2
Case Else
iLangNumber = 1
End Select
Endif
SelectLangNumber = iLangNumber
End Function
</script:module>
|