/usr/lib/libreoffice/share/extensions/DmathsAddon/Dmaths/Tableau_de_variations.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 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 | <?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="Tableau_de_variations" script:language="StarBasic">'************************************************
'Copyright (C) 2008 Didier Dorange-Pattoret
'38, chemin de l'Abbaye
'74940 Annecy le Vieux
'France
'ddorange@dmaths.com
'
' Jerome Ortais
' Gisbert Friege
'
'This library is free software; you can redistribute it and/or
'modify it under the terms of the GNU General Public Licence (GPL)
'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
'General Public License for more details.
'You should have received a copy of the GNU General Public Licence (GPL)
'along with this library; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'************************************************
rem Option Explicit
Public oTava as Object
Public iCheckIndex as Integer
Public iNbreInter as Integer
rem Macros écrites par Didier Dorange-Pattoret
rem Buttons for brackets, pi, inf, cdot added by Gisbert Friege, mai 2007
rem Options for second derivative added by Gisbert Friege, june/july 2007
rem Dialogue: textfields for signs replaced by command bttons by Gisbert Friege nov 2007
Public bDerivee,bDerivee1,bDerivee2,bDerivee12,bSignesF, bSignesD as Boolean
rem cette macro lance la boite de dialogue
Sub LanceTableVar
Call VerifOperationnel
Dim I as Integer
oTava = LoadDialog("Dmaths","Tava")
' following two lines needed for the use of Module2.TextIndexSet_any and Module1.MetEntre GF
oBoite = oTava
Form1=True
' state for the start with bDerivee1
bDerivee = TRUE
bSignesF = FALSE
bSignesD = TRUE
bDerivee1 = TRUE
bDerivee2 = FALSE
iNbreInter = 1
For I=2 To 6
oTava.GetControl("CheckBox"&cstr(I)).Visible = False
Next I
For I=0 To 5
oTava.GetControl("Label"&cstr(I*3+7)).Visible = False
Next I
oTava.GetControl("Label4").Visible = False
For I=4 To 8
oTava.GetControl("TextField"&cstr(I)).Visible = False
Next I
For I=14 To 43
If (I Mod 5 <> 1) then oTava.GetControl("TextField"&cstr(I)).Visible = False
Next I
oTava.GetControl("TextField41").Visible = False 'sorry!
For I=10 To 14
oTava.GetControl("CommandButton"&cstr(I)).Visible = False
oTava.GetControl("CommandButton"&cstr(I+6)).Visible = False
Next I
oTava.Execute()
End Sub
rem ajuste au nombre d'intervalles choisis
Sub AjusteNbreIntervalles
Dim I as Integer
iNbreInter = cint(oTava.GetControl("ComboBox1").SelectedText)
If iNbreInter < 1 Then
iNbreInter = 1
Endif
If iNbreInter > 6 Then
iNbreInter = 6
Endif
For I=0 To 6
oTava.GetControl("CheckBox"&cstr(I)).State = False
If I < iNbreInter+1 Then
oTava.GetControl("CheckBox"&cstr(I)).Visible = True
Else
oTava.GetControl("CheckBox"&cstr(I)).Visible = False
End If
Next I
For I=0 To 6
oTava.GetControl("Label"&cstr(I*3+4)).Visible = False
Next I
For I=4 To 8
If I < iNbreInter+3 Then
oTava.GetControl("TextField"&cstr(I)).Visible = True
oTava.GetControl("TextField"&cstr(I+35)).Visible = True
oTava.GetControl("CommandButton"&cstr(I+6)).Visible = True
oTava.GetControl("CommandButton"&cstr(I+12)).Visible = True
Else
oTava.GetControl("TextField"&cstr(I)).Visible = False
oTava.GetControl("TextField"&cstr(I+35)).Visible = False
oTava.GetControl("CommandButton"&cstr(I+6)).Visible = False
oTava.GetControl("CommandButton"&cstr(I+12)).Visible = False
Endif
Next I
For I=10 To 38
If I mod 5 = 0 Then
If I = iNbreInter*5 + 5 Then oTava.GetControl("TextField"&cstr(I)).Visible = True Else oTava.GetControl("TextField"&cstr(I)).Visible = False
ElseIf I mod 5 = 3 Then
If I = iNbreInter*5 + 8 Then oTava.GetControl("TextField"&cstr(I)).Visible = True Else oTava.GetControl("TextField"&cstr(I)).Visible = False
Elseif (I mod 5 = 4 or (I> 12 and I mod 5 = 2)) Then oTava.GetControl("TextField"&cstr(I)).Visible = False
Elseif (I mod 5 <>1 ) and (I < iNbreInter*5 + 9) Then oTava.GetControl("TextField"&cstr(I)).Visible = True
Else
If (I mod 5 <>1 ) Then oTava.GetControl("TextField"&cstr(I)).Visible = False
Endif
Next I
MetenCreationTableauSignes
End Sub
rem Met la boite de dialogue en mode tableau de signes
Sub MetenCreationTableauSignes
Dim bEtat as Boolean
Dim I as Integer
bEtat = bDerivee
iNbreInter = cint(oTava.GetControl("ComboBox1").Peer.Text)
oTava.GetControl("Label3").Visible = bEtat
oTava.GetControl("TextField12").Visible = bEtat
oTava.GetControl("TextField2b").Visible = bEtat
oTava.GetControl("TextField3").Visible = bEtat
oTava.GetControl("TextField"&cstr(iNbreInter*5+8)).Visible = bEtat
oTava.GetControl("CommandButton15").Visible = bEtat
For I = 1 To iNbreInter-1
If oTava.GetControl("CheckBox"&cstr(I)).State Then
oTava.GetControl("TextField"&cstr(I+38)).Visible = False
Else
oTava.GetControl("TextField"&cstr(I+38)).Visible = bEtat
EndIf
oTava.GetControl("CommandButton"&cstr(I+15)).Visible = bEtat
Next I
For I = 0 To iNbreInter
oTava.GetControl("CheckBox"&cstr(I)).Visible = bEtat
Next I
End Sub
sub EchangeTF23
Dim sEchange as String
sEchange = oTava.GetControl("TextField3").Peer.Text
oTava.GetControl("TextField3").Peer.Text = oTava.GetControl("TextField2").Peer.Text
oTava.GetControl("TextField2").Peer.Text = sEchange
End Sub
Sub MetenAfficheSignes 'seulement signes de f(x)
oTava.GetControl("OptionButton1").Enable = FALSE
oTava.GetControl("OptionButton2").Enable = FALSE
oTava.GetControl("OptionButton6").Enable = FALSE
oTava.GetControl("Label2").Visible = FALSE
AjusteNbreIntervalles
EchangeTF23
bSignesF = TRUE
bDerivee = FALSE
bDerivee1 = FALSE
bDerivee2 = FALSE
Call MetenCreationTableauSignes
End Sub
Sub MetenSansSignesD 'seulement fleches/arcfleches de f(x)
oTava.GetControl("OptionButton1").Enable = TRUE
oTava.GetControl("OptionButton2").Enable = TRUE
oTava.GetControl("OptionButton6").Enable = TRUE
If bSignesF Then
EchangeTF23
oTava.GetControl("Label2").Visible = TRUE
EndIf
bSignesF = FALSE
bSignesD = FALSE
bDerivee = TRUE
Call MetenCreationTableauSignes
End Sub
Sub MetenComplete
oTava.GetControl("OptionButton1").Enable = TRUE
oTava.GetControl("OptionButton2").Enable = TRUE
oTava.GetControl("OptionButton6").Enable = TRUE
bSignesD = TRUE
If bSignesF Then
EchangeTF23
oTava.GetControl("Label2").Visible = TRUE
EndIf
bSignesF = FALSE
bDerivee = TRUE
Call MetenCreationTableauSignes
End Sub
Sub MetenDerivee1
bDerivee1 = TRUE
bDerivee2 = FALSE
Call MetenCreationTableauSignes
End Sub
Sub MetenDerivee2
bDerivee1 = FALSE
bDerivee2 = TRUE
Call MetenCreationTableauSignes
End Sub
Sub MetenDerivee12
bDerivee1 = TRUE
bDerivee2 = TRUE
Call MetenCreationTableauSignes
End Sub
rem remplace le -, pi, inf
Function Dixio5(sMot as String)
Dim I as Integer
For I = 1 To Len(sMot)
If Mid(sMot,I,1)="-" Then Mid(sMot,I,1,"–")
Next I
For I = 1 To Len(sMot)-1
If Mid(sMot,I,2)="pi" Then Mid(sMot,I,2,"")
Next I
For I = 1 To Len(sMot)-2
If Mid(sMot,I,3)="inf" Then Mid(sMot,I,3,"∞")
Next I
For I = 1 To Len(sMot)-5
If Mid(sMot,I,6)="`cdot`" Then Mid(sMot,I,6,"·")
Next I
Dixio5 = sMot
End Function
rem cree le tableau de variation ou de signes
Sub Cree_Tava
Dim oDoc as Object, oVCurs as Object, sMot as String
Dim I as Integer
Dim Signval as String
iNbreInter = cint(oTava.GetControl("ComboBox1").Peer.Text) rem releve le nbre d'intervalles
oDoc=ThisComponent
oVCurs=oDoc.CurrentController.ViewCursor
For I=4 To 43
If Not((I>10) and (I<40) and (I mod 5 =1)) then
If oTava.GetControl("TextField"&cstr(I)).Peer.Text = "" Then oTava.GetControl("TextField"&cstr(I)).Text = "?"
EndIf
Next I
sMot = oTava.GetControl("TextField1").Peer.Text &";" & oTava.GetControl("TextField9").Peer.Text ' ligne x
If oTava.GetControl("CheckBox0").State = 1 Then sMot = sMot &"*"
For I = 1 To iNbreInter-1
sMot = sMot & ";" & oTava.GetControl("TextField"&cstr(I+3)).Peer.Text
If oTava.GetControl("CheckBox"&cstr(I)).State = 1 Then sMot = sMot &"*"
Next I
sMot = sMot & ";" & oTava.GetControl("TextField"&cstr(iNbreInter*5+5)).Peer.Text
If oTava.GetControl("CheckBox"&cstr(iNbreInter)).State = 1 Then sMot = sMot &"*"
sMot = sMot & ";;"
If bDerivee then
sMot = sMot & oTava.GetControl("TextField3").Peer.Text
Else
sMot = sMot & oTava.GetControl("TextField2").Peer.Text
End If
Signval = oTava.GetControl("CommandButton9").Model.Label
sMot = sMot & ";" & oTava.GetControl("TextField12").Peer.Text & ";" & Signval 'y1 and first sign
sMot = sMot & oTava.GetControl("CommandButton15").Model.Label 'sign of f''
For I = 1 To iNbreInter-1
If oTava.GetControl("CheckBox"&cstr(I)).State = 0 Then
sMot = sMot & ";" & oTava.GetControl("TextField"&cstr(I+38)).Peer.Text 'yi
Else
sMot = sMot & ";" & oTava.GetControl("TextField"&cstr(I*5+8)).Peer.Text & ";" & oTava.GetControl("TextField"&cstr(I*5+12)).Peer.Text
End If
sMot = sMot & ";" & oTava.GetControl("CommandButton"&cstr(I+9)).Model.Label 'signs of f'
sMot = sMot & oTava.GetControl("CommandButton"&cstr(I+15)).Model.Label 'signs of f''
Next I
sMot = sMot & ";" & oTava.GetControl("TextField"&cstr(iNbreInter*5+8)).Peer.Text
rem affiche la ligne de derivee
If bDerivee Then
sMot = sMot & ";;" & oTava.GetControl("TextField2").Peer.Text
sMot = sMot & ";;" & oTava.GetControl("TextField2b").Peer.Text
Else
sMot = sMot & ";;TS"
Endif
oTava.EndExecute()
TableVar(oDoc, oVCurs, sMot)
End Sub
Sub Cancel_TaVa
oTava.EndExecute()
End Sub
'The following macro replaces all previous CheckIndexN macros (see below)
'Gisbert Friege nov 2007
Sub CheckIndex_any(event)
TF = event.source.model.name
' msgbox right(TF,1) 'last character only, must be changed if more than 9 checkboxes are needed
iCheckIndex = CINT(right(TF,1))
Call DoubleBarre
End Sub
Sub NextSign_any(event)
ESM = event.source.model
'XRay ESM
TFText = ESM.Label
If TFText = "0" then
ESM.Label = "+"
ElseIf TFText = "+" then
ESM.Label = "-"
ElseIf TFText = "-" then
ESM.Label = "0"
End If
End Sub
rem met en mode valeur interdite
Sub DoubleBarre
Dim bEtat as Boolean
bEtat = (oTava.GetControl("CheckBox"&cstr(iCheckIndex)).State = 1)
oTava.GetControl("Label"&cstr(iCheckIndex*3+4)).Visible = bEtat
If iCheckIndex <> 0 Then
If iCheckIndex<>6 and iCheckIndex <> iNbreInter Then oTava.GetControl("TextField"&cstr(iCheckIndex+38)).Visible = Not bEtat
If iCheckIndex <> iNbreInter Then oTava.GetControl("TextField"&cstr(iCheckIndex*5+8)).Visible = bEtat
If iCheckIndex <> iNbreInter Then oTava.GetControl("TextField"&cstr(iCheckIndex*5+12)).Visible = bEtat
Endif
End Sub
' Jerome Ortais
' Ces fonctions permettent la creation de tableau de variations a deux ou trois lignes ainsi que de tableaux de signes.
' Elles prennent en compte les equations starMath, les fonctions constantes, croissantes ou decroissantes
' sur un intervalle.
' Merci a tous les contributeurs du forum http://www.oooforum.org sans qui je n'y serais jamais parvenu.
' Version 3.2
' Jerome Ortais
' Selectionne la zone a traiter.
Sub Main
Dim oDoc as Object, oVCurs as Object, sMot as String
oDoc=ThisComponent
oVCurs=oDoc.CurrentController.ViewCursor
GlobalScope.BasicLibraries.loadLibrary("Dmaths")
sMot=Dmaths.Module1.Selec
TableVar(oDoc, oVCurs, sMot)
End Sub
' Jerome Ortais
' Cette fonction est la fonction principale. C'est elle qui cree et remplit le tableau.
' Gisbert Friege added the Derivee1/Derivee2-cases
Sub TableVar(oDoc as Object, oVcurs as Object, sMot as String)
Dim oText as Object, oWCurs as Object
Dim oTable as Object, oCell as Object, oCellCurs as Object, oLignes as Object, olaLigne as Object
Dim oBorderLine as Object
rem Dim oBorderLine as New com.sun.star.table.BorderLine
Dim oDispHelper as Object, oProvider as Object, iCptErreur as Integer
Dim iCpt as Integer, iNbLigne as Integer, iNbCol as Integer
Dim iDblPtVirg as Integer, iListPos1 as Integer, iListPos2 as Integer
Dim sString as String, memo_d1 as String ,memo_d2 as String
Dim bEstInterdit as Boolean, iNbInterdit as Integer
bEstInterdit=False
iNbInterdit=0
iNbCol=0
iDblPtVirg=InStr(sMot,";;")
' write iDblPtVirg 'is always 6
If InStr(iDblPtVirg+1,sMot,";;")>0 Then
iNbLigne=3
If InStr(InStr(iDblPtVirg+1,sMot,";;")+1,sMot,";;")>0 Then iNbLigne=4
Else
iNbLigne=2 'does this ever happen??? GF june 2007
EndIf
iCpt=InStr(sMot,"*;")
While iCpt<>0 And iCpt<iDblPtVirg
iNbCol=iNbCol+1
iCpt=InStr(iCpt+2,sMot,"*;")
WEnd
iCpt=InStr(sMot,";")
While iCpt<>0 And iCpt<iDblPtVirg
iNbCol=iNbCol+2
iCpt=InStr(iCpt+2,sMot,";")
WEnd
If iNbLigne<2 Or iNbCol<4 Then
Print "Format de tableau invalide"
Exit Sub
EndIf
iListPos1=1
iListPos2=InStr(iListPos1,sMot,";")
oText=oDoc.Text
oTable=oDoc.createInstance("com.sun.star.text.TextTable")
oTable.Split=False
oTable.initialize(iNbLigne,iNbCol)
If IsEmpty(oVCurs.TextTable) Then
oWCurs=oText.createTextCursorByRange(oVCurs)
oText.insertTextContent(oWCurs,oTable,false)
Else
oWCurs=oVCurs.Cell.createTextCursor
oVCurs.Cell.insertTextContent(oWCurs,oTable,false)
EndIf
' Gere les bordures
oBorderLine = createUnoStruct( "com.sun.star.table.BorderLine" )
With oBorderLine
.InnerLineWidth = 0
.OuterLineWidth = 0
End With
For iCpt=2 To iNbCol-1
oCell=oTable.getCellRangeByPosition(iCpt,0,iCpt,iNbLigne-1)
oCell.LeftBorder=oBorderLine
Next
' Fixe la hauteur de la dernière ligne à 1,6cm pour que les points de flèches soient face aux nombres.
oLignes=oTable.Rows
olaLigne=oLignes(iNbLigne-1)
With olaLigne
.Height=1600
.IsAutoHeight=False
End With
oTable.Rows(iNbLigne-1)=olaLigne
'Ecrit la premiere valeur dans le tableau
EcritCellule(oTable,0,0,Mid(sMot,iListPos1,iListPos2-iListPos1),2)
iListPos1=iListPos2+1
iListPos2=InStr(iListPos1,sMot,";")
iCpt=1
iNbInterdit=0
' Cree et remplit la premiere ligne des autres colonnes du tableau
While iListPos2<=iDblPtVirg
If Mid(sMot,iListPos2-1,1)="*" Then
EcritCellule(oTable,iCpt,0,Mid(sMot,iListPos1,iListPos2-iListPos1-1),2)
bEstInterdit=True
Else
EcritCellule(oTable,iCpt,0,Mid(sMot,iListPos1,iListPos2-iListPos1),2)
EndIf
If bEstInterdit Then
With oBorderline
.OuterLineWidth=35.28
.InnerLineWidth=35.28
.LineDistance=35.28
End With
oTable.getCellRangeByPosition(iCpt+iNbInterdit,1,iCpt+iNbInterdit,iNbLigne-1).RightBorder=oBorderLine
oCell=oTable.getCellByPosition(iCpt,0)
oCellCurs=oTable.createCursorByCellName(oCell.CellName)
oCellCurs.goRight(1,True)
oCellCurs.mergeRange
bEstInterdit=False
iNbInterdit=iNbInterdit+1
EndIf
iListPos1=iListPos2+1
iListPos2=InStr(iListPos1,sMot,";")
iCpt=iCpt+2
Wend
iDblPtVirg=InStr(iDblPtVirg+1,sMot,";;") 'Ende 1.Zeile
iListPos1=iListPos2+1
iListPos2=InStr(iListPos1,sMot,";")
'msgbox sMot & " Dbl=" & iDblPtVirg & " LP1=" & iListPos1 & " LP2=" & iListPos2
' On remplit la ligne 2 (pas de ligne 3) 'this case cannot happen! GF
If iNbLigne=2 Then
msgbox "doch Zeile 2!"
Else
' On remplit les lignes 2 et 3 et 4
If Mid(sMot,iDblPtVirg+2)="TS" Then
EcritCellule(oTable,0,1,Mid(sMot,iListPos1,iListPos2-iListPos1),2)
Else
'write f'(x)
EcritCellule(oTable,0,1,Mid(sMot,iDblPtVirg+2,Instr(iDblPtVirg+2,sMot,";;")-(iDblPtVirg+2)),2)
'write f''(x) and f(x)
If iNbLigne=4 Then
EcritCellule(oTable,0,2,Mid(sMot,Instr(iDblPtVirg+2,sMot,";;")+2),2)
EcritCellule(oTable,0,3,Mid(sMot,iListPos1,iListPos2-iListPos1),2)
Else 'iNbLigne=3
EcritCellule(oTable,0,2,Mid(sMot,iListPos1,iListPos2-iListPos1),2)
End If
EndIf
' now the data
iListPos1=iListPos2+1
iListPos2=InStr(iListPos1,sMot,";")
'msgbox sMot & " Dbl=" & iDblPtVirg & " LP1=" & iListPos1 & " LP2=" & iListPos2
'Gere le cas ou la premiere valeur est interdite
If Mid(sMot,InStr(InStr(sMot,";")+1,sMot,";")-1,1)="*" Then
iCpt=2
Else
iCpt=1
EndIf
While iListPos2<=iDblPtVirg
sString=Mid(sMot,iListPos1,iListPos2-iListPos1) 'piece of text from iListPos1 to ;
oCell=oTable.getCellByPosition(iCpt,2)
If iNbLigne=4 Then oCell=oTable.getCellByPosition(iCpt,3)
If sString="+ " or sString="+0" or sString="++" or sString="+-" or sString=" +" or sString=" -" or sString="0+" or sString="0-" Then
EcritCellule(oTable,iCpt,1,Mid(sString,1,1),2)
EcritCellule(oTable,iCpt,2,Mid(sString,2,1),2)
If (bDerivee1 and not bDerivee2) or (sString="+ ") or (sString="+0") Then
If (mid(sString,1,1)="+") Then
Fleche(oCell,40,2) 'straight arrow up
ElseIf (mid(sString,1,1)="0") or (mid(sString,1,1)=" ") Then
Fleche(oCell,0,oTable.getCellByPosition(iCpt-1,3).getPropertyValue("VertOrient")) 'gerader Pfeil horiz.
EndIf
ElseIf (bDerivee2 and not bDerivee1) Then
If (mid(sString,2,1)="+") or (mid(sString,2,1)="-") Then
ArcFleche(oCell,sString,2)
'Else empty
EndIf
Else ArcFleche(oCell,sString,2)
EndIf
oBorderLine=oTable.getCellRangeByPosition(iCpt-2,1,iCpt-2,2).RightBorder
' check for change of sign, if yes insert 0
If oBorderLine.LineDistance<35 And iCpt>2 Then
If (memo_d1<>" ") and (mid(sString,1,1)<>memo_d1) Then EcritCellule(oTable,iCpt-1,1,0,2)
If (memo_d2<>" ") and (mid(sString,2,1)<>memo_d2) Then EcritCellule(oTable,iCpt-1,2,0,2)
EndIf
memo_d1=mid(sString,1,1)
memo_d2=mid(sString,2,1)
ElseIf sString="- " or sString="-0" or sString="-+" or sString="--" Then
EcritCellule(oTable,iCpt,1,Mid(sString,1,1),2)
EcritCellule(oTable,iCpt,2,Mid(sString,2,1),2)
If (bDerivee1 and not bDerivee2) or (sString="- ") or (sString="-0") Then
If (mid(sString,1,1)="-") Then
Fleche(oCell,-40,2) 'gerader Pfeil down
EndIf
ElseIf (bDerivee2 and not bDerivee1) Then
If (mid(sString,2,1)="+") or (mid(sString,2,1)="-") Then
ArcFleche(oCell,sString,2)
'Else empty
EndIf
Else ArcFleche(oCell,sString,2)
EndIf
oBorderLine=oTable.getCellRangeByPosition(iCpt-2,1,iCpt-2,2).RightBorder
' check for change of sign, if yes write 0
If oBorderLine.LineDistance<35 And iCpt>2 Then
If (memo_d1<>" ") and (mid(sString,1,1)<>memo_d1) Then EcritCellule(oTable,iCpt-1,1,0,2)
If (memo_d2<>" ") and mid(sString,2,1)<>memo_d2 Then EcritCellule(oTable,iCpt-1,2,0,2)
EndIf
memo_d1=mid(sString,1,1)
memo_d2=mid(sString,2,1)
ElseIf (sString="0 ") or (sString="00") Then
EcritCellule(oTable,iCpt,1,Mid(sString,1,1),2)
EcritCellule(oTable,iCpt,2,Mid(sString,2,1),2)
If bDerivee1 or bDerivee2 Then Fleche(oCell,0,oTable.getCellByPosition(iCpt-1,3).getPropertyValue("VertOrient"))
oBorderLine=oTable.getCellRangeByPosition(iCpt-2,1,iCpt-2,2).RightBorder
memo_d1=mid(sString,1,1)
memo_d2=mid(sString,2,1)
Else ' yi to line 3 or 4
If iNbLigne=4 Then
EcritCellule(oTable,iCpt,3,sString,AlignementVertical(oTable,iCpt,3,sMot,iListPos1,iListPos2))
Else
EcritCellule(oTable,iCpt,2,sString,AlignementVertical(oTable,iCpt,2,sMot,iListPos1,iListPos2))
EndIf
EndIf
iListPos1=iListPos2+1
iListPos2=InStr(iListPos1,sMot,";")
iCpt=iCpt+1
Wend
EndIf
If bSignesF Then
oTable.Rows.removeByIndex(2,1)
ElseIf (not bSignesD) Then
oTable.Rows.removeByIndex(1,1)
If bDerivee1 or bDerivee2 Then oTable.Rows.removeByIndex(1,1)
ElseIf (not bDerivee2) Then
oTable.Rows.removeByIndex(2,1)
ElseIf (not bDerivee1) Then
oTable.Rows.removeByIndex(1,1)
EndIf
' Adapte la largeur des colonnes au contenu du tableau
oDoc.getCurrentController().select(oTable)
oVCurs=oDoc.getCurrentController().getViewCursor()
oVCurs.gotoEnd(True)
oVCurs.gotoEnd(True)
oProvider = oDoc.CurrentController.Frame
oDispHelper = createUnoService("com.sun.star.frame.DispatchHelper")
' Gere le probleme du executeDispatch qui se fait parfois trop rapidement
On Error GoTo TraiteErreur
DIM Array(0) as new com.sun.star.beans.PropertyValue
oDispHelper.executeDispatch(oProvider, ".uno:SetOptimalColumnWidth", "", 0, Array())
oDispHelper.executeDispatch(oProvider, ".uno:Escape", "", 0, Array())
DIM args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Count"
args1(0).Value = 1
args1(1).Name = "Select"
args1(1).Value = false
oDispHelper.executeDispatch(oProvider, ".uno:GoRight", "", 0, args1())
Exit Sub
TraiteErreur:
If err=1 Then
wait 50
iCptErreur=iCptErreur+50
If iCptErreur<2500 Then
Resume
Else
On Error GoTo 0
EndIf
Else On Error GoTo 0
EndIf
End Sub
' Jerome Ortais
' Cette fonction ecrit sMot dans une cellule de coordonnes iCol et iLig d'un tableau oTable.
Sub EcritCellule(oTable as Object, iCol as Integer, iLig as Integer, sMot as String, iVertAlign as Integer)
Dim oCell as Object, oCurseur as Object, iCptErreur as Integer
Dim oProvider as Object, oDispHelper as Object
oCell=oTable.getCellByPosition(iCol,iLig)
' Centre horizontalement et ajuste l'alignement vertical des donnees de la cellule du tableau
oCell.setPropertyValue("VertOrient",iVertAlign)
oCell.getText().createTextCursor().ParaAdjust=com.sun.star.style.ParagraphAdjust.CENTER
' If iCol>0 Then Print "Alignement précédent : " & oTable.getCellByPosition(iCol-1,iLig).getPropertyValue("VertOrient")
oCurseur=oCell.createTextCursor
rem met en fonte normale la premiere ligne
If iLig = 0 Then
oCurseur.CharWeight = com.sun.star.awt.FontWeight.NORMAL
If iCol > 0 Then oCurseur.CharPosture = com.sun.star.awt.FontSlant.NONE
Endif
If iCol = 0 Then oCurseur.CharPosture = com.sun.star.awt.FontSlant.ITALIC
If Mid(sMot,1,1)="$" Then
iCptErreur=0
oCell.String=Dmaths.Module2.Dixio(Mid(sMot,2,Len(sMot)-2))
oCurseur.gotoStart(False)
oCurseur.gotoEnd(True)
ThisComponent.getcurrentcontroller().select(oCurseur)
oProvider = ThisComponent.CurrentController.Frame
oDispHelper = createUnoService("com.sun.star.frame.DispatchHelper")
' Gere le probleme du executeDispatch qui se fait parfois trop rapidement
On Error GoTo TraiteErreur
dim Array(0) as new com.sun.star.beans.PropertyValue
oDispHelper.executeDispatch(oProvider, ".uno:InsertObjectStarMath", "", 0, Array())
Exit Sub
TraiteErreur:
If err=1 Then
wait 50
iCptErreur=iCptErreur+50
If iCptErreur<2500 Then
Resume
Else
On Error GoTo 0
EndIf
Else On Error GoTo 0
EndIf
Else
sMot = Dixio5(sMot) rem ajouté par Didier Dorange-Pattoret
oCell.String=sMot
EndIf
End Sub
' Jerome Ortais
' Cette fonction aligne verticalement la cellule de oTable de coordonnees iCol et iLigne en fonction des +, - ou 0
' trouves dans sMot
' Gisbert Friege: adaption to signs for the second derivative
Sub AlignementVertical(oTable as Object, iCol as Integer, iLigne as Integer, sMot as String,_
iListPos1 as Integer, iListPos2 as Integer) as Integer
Dim iAlignementVertical as Integer, iPosPlus as Integer, iPosMoins as Integer, iPosMoins2 as Integer, iFin as Integer
Dim signbefore as String, signafter as String
If iListPos2=0 Then
'shoul not happen ???
msgbox "why did iListPos=0 happen?"
iFin=1
Else iFin=iListPos2 'position of ";"
EndIf
signbefore=Mid(sMot,iListPos1-3,1) 'nonsense for first value
signafter=Mid(sMot,iFin+1,1) 'nonsense for last value
' msgbox signbefore & " " & signafter
' example: 123;+0;8901;-0;678 iLIstPos1=8 iLIstPos2=12 signafter=- signbefore=+
Select Case signafter
Case "+"
Select Case signbefore
Case "+"
iAlignementVertical=2
Case "0"
If iCol>3 Then iAlignementVertical=oTable.getCellByPosition(iCol-2,iLigne).getPropertyValue("VertOrient")
Case Else
' Align Bottom
iAlignementVertical=3
End Select
Case "-"
Select Case signbefore
Case "-"
iAlignementVertical=2
Case "0"
If iCol>3 Then iAlignementVertical=oTable.getCellByPosition(iCol-2,iLigne).getPropertyValue("VertOrient")
Case Else
' Align Top
iAlignementVertical=1
End Select
Case Else ' signafter is 0 or undefind for last value
Select Case signbefore
Case "+"
' Align Top
iAlignementVertical=1'2
Case "-"
' Align Bottom
iAlignementVertical=3'2
Case Else
' Meme alignement vertical
If iCol>3 Then
iAlignementVertical=oTable.getCellByPosition(iCol-2,iLigne).getPropertyValue("VertOrient")
Else
iAlignementVertical=2
End If
' following lines just for reference to the original treatment
' Case Else
' iPosPlus=InStr(iListPos2,sMot,";+;")
' iPosMoins=InStr(iListPos2,sMot,";-;")
' iPosMoins2=InStr(iListPos2,sMot,";–;")
' If iPosPlus=0 And iPosMoins=0 And iPosMoins2=0 Then
' ' La fonction est une fonction constante
' iAlignementVertical=2
' ElseIf iPosPlus<>0 And (iPosPlus<iPosMoins Or iPosMoins=0) And (iPosPlus<iPosMoins2 Or iPosMoins2=0) Then
' ' La fonction sera croissante sut le prochain interval non constant
' iAlignementVertical=3
' Else
' iAlignementVertical=1
' EndIf
End Select
End Select
AlignementVertical=iAlignementVertical
End Sub
' Jerome Ortais
' Cette fonction dessine puis insere une fleche dans une cellule oCell ayant un angle de iAngle degres.
Sub Fleche(oCell as Object, iAngle as Integer, iVertAlign as Integer)
Dim oText as Object, oCursor as Object
Dim oFleche as Object
Dim lesPoints(4) As New com.sun.star.awt.Point
' Centre horizontalement et verticalement les donnees de la cellules du tableau
oCell.setPropertyValue("VertOrient", iVertAlign)
oCell.getText().createTextCursor().ParaAdjust=com.sun.star.style.ParagraphAdjust.CENTER
oFleche=ThisComponent.CreateInstance("com.sun.star.drawing.PolyPolygonShape")
lesPoints(0).X=0
lesPoints(0).Y=0
lesPoints(1).X=750
lesPoints(1).Y=0
lesPoints(2).X=600
lesPoints(2).Y=50
lesPoints(3).X=600
lesPoints(3).Y=-50
lesPoints(4).X=750
lesPoints(4).Y=0
oText = oCell.getText()
oCursor = oText.createTextCursor()
oText.insertTextContent(oCursor,oFleche,False)
oFleche.PolyPolygon=Array(lesPoints())
oFleche.RotateAngle=iAngle*100
oFleche.FillColor=RGB(0,0,0)
oFleche.AnchorType=com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH
oFleche.AnchorType=com.sun.star.text.TextContentAnchorType.AS_CHARACTER
If iAngle=0 Then
' Decale les fleches horizontales pour qu'elles soient face aux nombres
Dim oPoint as New com.sun.star.awt.Point
oPoint.x=0
Select Case iVertAlign
Case 1
oPoint.y=150
oFleche.Position=oPoint
Case 3
oPoint.y=-300
oFleche.Position=oPoint
End Select
EndIf
End Sub
' Gisbert Friege
' Cette fonction dessine puis insere une groupe arc et fleche dans une cellule oCell.
Sub ArcFleche(oCell as Object, afType as String, iVertAlign as Integer)
Dim oText as Object, oCursor as Object
Dim oArc as Object
Dim oFleche as Object
Dim aSize As New com.sun.star.awt.Size
Dim aPoint As New com.sun.star.awt.Point
Dim oGruppe As Object
' +left, -right, ++leftup, +-leftdown, -+rightup, --rightdown
oDrawPage = ThisComponent.GetDrawPage()
oShapesToGroup = createUnoService( "com.sun.star.drawing.ShapeCollection" )
' Centre horizontalement et verticalement les donnees de la cellules du tableau
oCell.setPropertyValue("VertOrient", iVertAlign)
oCell.getText().createTextCursor().ParaAdjust=com.sun.star.style.ParagraphAdjust.CENTER
oArc=ThisComponent.CreateInstance("com.sun.star.drawing.EllipseShape")
oText = oCell.getText()
oCursor = oText.createTextCursor()
oText.insertTextContent(oCursor,oArc,False)
oArc.FillStyle = com.sun.star.drawing.FillStyle.NONE
oArc.CircleKind = com.sun.star.drawing.CircleKind.ARC
If (afType="0+") or (afType="0-") or (afType=" +") or (afType=" -")Then
aSize.width = 750
aSize.height = 750
ElseIf (afType="++") or (afType="--") Then
aSize.width = 1500
aSize.height = 1050
Else ' (afType="+-") or (afType="-+")
aSize.width = 2000
aSize.height = 1150
EndIf
oArc.Size = aSize
' oArc.LineWidth = 50
oArc.FillColor=RGB(255,255,255)
oArc.AnchorType=com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH
Select Case afType
Case "0+"," +"
oArc.CircleStartAngle = 17000 'nCircleStartAngle
oArc.CircleEndAngle = 1000 'nCircleEndAngle
aPoint.x = 0 'x
aPoint.y = 250 'y
Case "0-"," -"
oArc.CircleStartAngle = 35000
oArc.CircleEndAngle = 19000
aPoint.x = 0 'x
aPoint.y = 100 'y
Case "++"
oArc.CircleStartAngle = 27000
oArc.CircleEndAngle = 34000
aPoint.x = 0 'x
aPoint.y = 250 'y
Case "+-"
oArc.CircleStartAngle = 11500
oArc.CircleEndAngle = 17000
aPoint.x = 0 'x
aPoint.y = 250 'y
Case "--"
oArc.CircleStartAngle = 2000
oArc.CircleEndAngle = 9000
aPoint.x = 0 'x
aPoint.y = 250 'y
Case "-+"
oArc.CircleStartAngle = 19000
oArc.CircleEndAngle = 24500
aPoint.x = 0 'x
aPoint.y = 250 'y
End Select
oArc.Position = aPoint
' Arrowhead
oFleche=ThisComponent.CreateInstance("com.sun.star.drawing.PolyPolygonShape")
Dim lesPoints(2) As New com.sun.star.awt.Point
lesPoints(0).X=0
lesPoints(0).Y=0
lesPoints(1).X=50
lesPoints(1).Y=-150
lesPoints(2).X=100
lesPoints(2).Y=0
oText.insertTextContent(oCursor,oFleche,False)
oFleche.PolyPolygon=Array(lesPoints())
oFleche.FillColor=RGB(0,0,0)
oFleche.AnchorType=com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH
Select Case afType
Case "0+", " +"
oFleche.RotateAngle= 1000
aPoint.x=650
aPoint.y=0
Case "0-"," -"
oFleche.RotateAngle= 17000
aPoint.x=650
aPoint.y=500
Case "++"
oFleche.RotateAngle= 33500
aPoint.x=630 '650
aPoint.y=0
Case "+-"
oFleche.RotateAngle= 28500
aPoint.x=530
aPoint.y=160
Case "--"
oFleche.RotateAngle= 20500
aPoint.x=600
aPoint.y=500
Case "-+"
oFleche.RotateAngle= 25500
aPoint.x=530
aPoint.y=560
End Select
oFleche.Position = aPoint
' oFleche.LineWidth = 50
oShapesToGroup.Add( oFleche )
oShapesToGroup.Add( oArc )
oGroupe = oDrawPage.Group( oShapesToGroup )
oGroupe.AnchorType=com.sun.star.text.TextContentAnchorType.AS_CHARACTER
oGroupe.RotateAngle=0
End Sub
</script:module>
|