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
|
'encoding UTF-8 Do not remove or change this line!
'*******************************************************************************
'* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'*
'* Copyright 2008 by Sun Microsystems, Inc.
'*
'* OpenOffice.org - a multi-platform office productivity suite
'*
'* $RCSfile: t_menu.inc,v $
'*
'* $Revision: 1.1 $
'*
'* last change: $Author: jsi $ $Date: 2008-06-13 10:27:10 $
'*
'* This file is part of OpenOffice.org.
'*
'* OpenOffice.org is free software: you can redistribute it and/or modify
'* it under the terms of the GNU Lesser General Public License version 3
'* only, as published by the Free Software Foundation.
'*
'* OpenOffice.org 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 version 3 for more details
'* (a copy is included in the LICENSE file that accompanied this code).
'*
'* You should have received a copy of the GNU Lesser General Public License
'* version 3 along with OpenOffice.org. If not, see
'* <http://www.openoffice.org/license.html>
'* for a copy of the LGPLv3 License.
'*
'/******************************************************************************
'*
'* Owner : thorsten.bosbach@sun.com
'*
'* short description : wrappers for accessing menues (context-, bar-, button- menues)
'*
'\******************************************************************************
function hMenuItemGetCount as Integer
'/// OUTPUT: number of entries in the activated menu (without seperators) ///'
'///+ menu left open ///'
dim iCurrentMenuItem as integer
dim iValidMenuItems as integer
sleep( 2 )
iValidMenuItems = 0
for iCurrentMenuItem = 1 to MenuGetItemCount
if ( NOT MenuIsSeperator ( iCurrentMenuItem ) ) then
iValidMenuItems = iValidMenuItems + 1
endif
next iCurrentMenuItem
hMenuItemGetCount = iValidMenuItems
end function
'*******************************************************************************
function hMenuSelectNr ( EintragsNr as Integer ) as String
'/// Selects the given nr. of <b>enabled</b> menu entry.
'/// <u>Note</u>: If there are disabled menu items are included the routine ignores them!
'///INPUT : number of entry from the top (>=1) OR
'///INPUT : number of entry from the bottom (<=-1)
'///INPUT : 0 to close menu
'///+ OUTPUT: text of the entry
Dim i, j, RealEnd, Ende as Integer
Dim nID as long
sleep( 2 )
Ende = EintragsNr
RealEnd = MenuGetItemCount
If (Ende > 0) then
if Ende > RealEnd then
Warnlog "hMenuSelectNr canceled: Entry number "+ Ende +" does not exists, because there are only " + RealEnd + " entries! "
hMenuClose
exit function
endif
j=0
for i=1 to Ende
if MenuIsSeperator ( i+j ) then
j = j+1
endif
next i
else
if ((RealEnd + Ende) < 0) then
Warnlog "hMenuSelectNr canceled: Entry number "+ Ende +" does not exists, because there are only " + RealEnd + " entries! "
hMenuClose
exit function
endif
j=1
for i=-1 to Ende step -1
if MenuIsSeperator (RealEnd +i+j) then
j = j -1
endif
next i
j = j + RealEnd
endif
if EintragsNr = 0 then
hMenuClose
exit function
endif
nID = MenuGetItemID ( EintragsNr+j )
hMenuSelectNr = MenuGetItemText ( nID )
MenuSelect ( nID )
end function
'*******************************************************************************
function hMenuItemCheck ( EintragsNr as Integer ) as String
'/// check the menu item (if it is checked, it stays checked) ///'
'///+ INPUT : number of entry from the top (>=1)///'
'///+ OUTPUT: text of the entry ///'
Dim i as Integer, j as Integer, RealEnd as Integer, Ende as Integer, nID as Integer
Ende = EintragsNr
RealEnd = hMenuItemGetCount
if Ende > RealEnd then
Warnlog "hMenuItemCheck canceled: Entry number "+ Ende +" does not exists, because there are only " + RealEnd + " entries! "
hMenuClose
exit function
endif
j=0
for i=1 to Ende
if MenuIsSeperator ( i+j ) then
j = j+1
endif
next i
nID = MenuGetItemID ( EintragsNr+j )
hMenuItemCheck = MenuGetItemText ( nID )
if NOT MenuIsItemChecked ( nID ) then
MenuSelect ( nID )
else
hMenuClose()
endif
end function
'*******************************************************************************
function hMenuItemUnCheck ( EintragsNr as Integer ) as String
'/// UNcheck the menu item (if it is UNchecked, it stays UNchecked) ///'
'///+ INPUT : number of entry from the top (>=1)///'
'///+ OUTPUT: text of the entry ///'
Dim i, j, RealEnd, Ende, nID as Integer
Ende = EintragsNr
RealEnd = hMenuItemGetCount
if Ende > RealEnd then
Warnlog "hMenuItemUnCheck canceled: Entry number "+ Ende +" does not exists, because there are only " + RealEnd + " entries! "
hMenuClose
exit function
endif
j=0
for i=1 to Ende
if MenuIsSeperator ( i+j ) then
j = j+1
endif
next i
nID = MenuGetItemID ( EintragsNr+j )
hMenuItemUnCheck = MenuGetItemText ( nID )
if MenuIsItemChecked ( nID ) then
MenuSelect ( nID )
else
hMenuClose()
endif
end function
'*******************************************************************************
function hMenuFindSelect(MenuID as variant, SelectSlot as Boolean, ExpectedNr as integer, optional VerboseWrongPosition as Boolean) as Boolean
'/// Find specified MenuID in Menu, check if its found on the expected place, ///'
'/// if not - report the correct slot, and if specified to do so - Select the correct slot. ///'
'///+ INPUT: MenuID: the string-name of the menu-entry we are lookin for. ///'
'///+ INPUT: TRUE, if the slot should be called, ///'
'///+ FALSE, if the slot shouldn't be called. ///'
'///+ INPUT: Optional: TRUE, if errors should be reported. ///'
'///+ FALSE, silent mode for errors. ///'
'///+ INPUT: Optional: The Expected Number of entry from the top (>=1) ///'
'///+ OUTPUT: If not found at the expected place - the correct Entry-number is reported ///'
Dim i as Integer
Dim RealId as Integer
Dim RealPosition as Integer
Dim MenuIDAsNumber as integer
Dim MenuIDAsString as string
Dim RealEnd as Integer
Dim nID as string
Dim found as string
Dim StringType as Boolean
'/// find out if we are going to search for an ID, or a string (.uno:) ///'
if IsNumeric(MenuID) then
MenuIDAsNumber = MenuID
StringType = FALSE
else
MenuIDAsString = MenuID
StringType = TRUE
endif
RealEnd = MenuGetItemCount
if ExpectedNr > RealEnd then
Warnlog "Entry number "+ ExpectedNr +" is higher than the number of entries (" + RealEnd + ") in this menu! "
endif
if StringType = FALSE then 'Search for the number.
nID = MenuGetItemID ( ExpectedNr )
if nID <> MenuID then
if VerboseWrongPosition = TRUE then
warnlog " the questioned ID (" + MenuID + ") were not found on position " + ExpectedNr
endif
Found = FALSE
for i=1 to RealEnd
nID = MenuGetItemID (i)
printlog "For the position '" + i + "', the ItemCommand was: " + MenuGetItemCommand (MenuGetItemID (i)) + " and the ID was: " + MenuGetItemID (i) + "."
if nID = MenuID then
Found = TRUE
RealID = MenuGetItemID (i)
RealPosition = i
if VerboseWrongPosition = TRUE then
warnlog "The real Position (Separators included) was: " + i
endif
i = RealEnd
endif
next i
else
Found = TRUE
RealPosition = ExpectedNr
RealId = MenuGetItemID (ExpectedNr)
endif
if Found = TRUE then
if SelectSlot then
MenuSelect (RealID)
hMenuFindSelect = TRUE
else
printlog "the slot was found, but the tester had choosen NOT to open the slot"
hMenuFindSelect = TRUE
hMenuClose
endif
else
if VerboseWrongPosition = TRUE then
warnlog "The slot was NOT found. Has either been removed, or it's a bug."
endif
hMenuFindSelect = FALSE
hMenuClose
endif
else 'StringType = TRUE : Seach for the .uno; -name.
nID = lCase(MenuGetItemCommand (MenuGetItemID (ExpectedNr)))
if nID <> lCase(MenuID) then
if VerboseWrongPosition = TRUE then
warnlog " the questioned ID (" + MenuID + ") were not found on position " + ExpectedNr
endif
Found = FALSE
for i=1 to RealEnd
nID = MenuGetItemCommand (MenuGetItemID (i))
printlog "For the position '" + i + "', the ItemCommand was: " + nID + " and the ID was: " + MenuGetItemID (i) + "."
if nID = MenuID then
Found = TRUE
RealID = MenuGetItemID (i)
RealPosition = i
if VerboseWrongPosition = TRUE then
warnlog "The real Position (Separators included) was: " + i
endif
i = RealEnd
endif
next i
else
Found = TRUE
RealPosition = ExpectedNr
RealId = MenuGetItemID (ExpectedNr)
endif
if Found = TRUE then
if SelectSlot then
MenuSelect (RealID)
hMenuFindSelect = TRUE
else
printlog "the slot was found, but the tester had choosen NOT to open the slot"
hMenuFindSelect = TRUE
hMenuClose()
endif
else
if VerboseWrongPosition = TRUE then
warnlog "The slot was NOT found. Has either been removed, or it's a bug."
endif
hMenuFindSelect = FALSE
hMenuClose()
endif
endif 'StringType = TRUE
wait 500 'Wait 0,5 seconds in case we just have called a Submenu.
end function
'*******************************************************************************
function hMenuItemIsChecked ( EintragsNr as Integer ) as Boolean
'/// is the the menu item checked ? ///'
'///+ INPUT : number of entry from the top (>=1)///'
'///+ OUTPUT: True = yes!, False = no! ///'
Dim i, j, Ende, RealEnd, nID as Integer
Ende = EintragsNr
RealEnd = hMenuItemGetCount
if Ende > RealEnd then
Warnlog "hMenuItemIsChecked canceled: Entry number "+ Ende +" does not exists, because there are only " + RealEnd + " entries! "
hMenuClose
exit function
endif
j=0
for i=1 to Ende
if MenuIsSeperator ( i+j ) then
j = j+1
endif
next i
nID = MenuGetItemID ( EintragsNr + j )
hMenuItemIsChecked = MenuIsItemChecked ( nID )
end function
'*******************************************************************************
function hMenuItemIsEnabled ( EintragsNr as Integer ) as Boolean
'/// is the the menu item enabled (not greyed out) ? ///'
'///+ INPUT : number of entry from the top (>=1)///'
'///+ OUTPUT: True = yes!, False = no! ///'
'///+ menu left open ///'
Dim i, j, Ende, RealEnd, nID as Integer
Ende = EintragsNr
RealEnd = MenuGetItemCount
if Ende > RealEnd then
Warnlog "hMenuItemIsEnabled canceled: Entry number "+ Ende +" does not exists, because there are only " + RealEnd + " entries! "
hMenuClose
exit function
endif
j=0
for i=1 to Ende
if MenuIsSeperator ( i+j ) then
j = j+1
endif
next i
nID = MenuGetItemID ( EintragsNr + j )
hMenuItemIsEnabled = MenuIsItemEnabled ( nID )
end function
'*******************************************************************************
function hMenuItemGetText ( EintragsNr as Integer ) as String
'///+ INPUT : number of entry from the top (>=1)///'
'///+ OUTPUT: text of item without tilde ///'
'///+ menu left open ///'
Dim i, j, RealEnd, Ende, nID as Integer
Ende = EintragsNr
RealEnd = MenuGetItemCount
if Ende > RealEnd then
Warnlog "hMenuItemGetText canceled: Entry number "+ Ende +" does not exists, because there are only " + RealEnd + " entries! "
hMenuClose
exit function
endif
j=0
for i=1 to Ende
if MenuIsSeperator ( i+j ) then
j = j+1
endif
next i
nID = MenuGetItemID ( EintragsNr + j )
hMenuItemGetText = hhEntferneTilde ( MenuGetItemText ( nID ) )
end function
'*******************************************************************************
sub hMenuClose
'/// close menue ///'
'///+ after a hMenuClose you have to execute Kontext.UseMenu again
'///+ if you want to open any other menu.
MenuSelect ( 0 )
end sub
'*******************************************************************************
function hhEntferneTilde ( sEintrag as String ) as String
'///+ INPUT : string with tilde ///'
'///+ OUTPUT: string without tilde ///'
Dim i
i = Instr ( 1, sEintrag, "~", 1 )
if i <> 0 then
hhEntferneTilde = Left ( sEintrag, i-1 ) + Right ( sEintrag, ( Len(sEintrag) - i ) )
else
hhEntferneTilde = sEintrag
endif
end function
'*******************************************************************************
function hMenuGetItemCommand ( EintragsNr as Integer ) as String
'/// <u>hMenuGetItemCommand(Nr)</u> ///
'///+ To read the slot/UNO slot which is behind a menu item. ///
'///+ Seperators will be ignored for the input INTEGER!
Dim i as integer
Dim j as integer
Dim RealEnd as integer
Dim DasEnde as integer
Dim nID as Integer
DasEnde = EintragsNr
RealEnd = MenuGetItemCount
if DasEnde > RealEnd then
warnlog "Parameter (" & DasEnde & ") bigger than items in menu (" & RealEnd & ") , 'hMenuGetItemCommand' canceled."
else
j=0
for i=1 to DasEnde
if MenuIsSeperator ( i+j ) then
j = j+1
endif
next i
nID = MenuGetItemID ( EintragsNr+j )
hMenuGetItemCommand = MenuGetItemCommand ( nID )
endif
end function
'*******************************************************************************
function hMenuGetItemId ( EintragsNr as Integer ) as integer
'///+ To read the Slot ID which is behind a menu item. ///
'///+ Seperators will be ignored for the input INTEGER!
Dim i as integer
Dim j as integer
Dim RealEnd as integer
Dim DasEnde as integer
DasEnde = EintragsNr
RealEnd = MenuGetItemCount
if DasEnde > RealEnd then
warnlog "Parameter (" & DasEnde & ") bigger than items in menu (" & RealEnd & ") , 'hMenuGetItemId' canceled."
else
j=0
for i=1 to DasEnde
if MenuIsSeperator ( i+j ) then
j = j+1
endif
next i
hMenuGetItemId = MenuGetItemID ( EintragsNr+j )
endif
end function
'*******************************************************************************
'/// Functions for the lower part of the 'Window' Menu ///'
'///+ philosophie: you can't do any actions on the first document -> it get's the number 0 and it doesn't count ///'
'///+ so the first window you can work with gets the number 1 and counting starts with 1 ... ///'
'///<b> function hUseMenu () </b>///'
'///+ very global function: depends on 'gApplication' just activates the menu-bar ///'
'///<b> function hWindowGetIndex () as integer </b>///'
'///+ returns the number of the active window ///'
'///<b> function hWindowGetText (optional iWindow as integer) as string </b>///'
'///+ returns the text of the menu entry without the tilde: ///'
'///+ w/ calling parameter: the active window ///'
'///+ w/o calling parameter: the window i ///'
'///<b> function hWindowSelect (iWindow as integer) </b>///'
'///+ switches to the window i ///'
'///+ calling parameter: id of the window to activate ///'
'*******************************************************************************
function hWindowGetIndex () as integer
'///<b> function hWindowGetIndex () as integer </b>///'
'///+ returns the number of the active window ///'
dim iMenues as integer ' takes the number of entries in the windows menue
dim iNotWindows as integer ' number of open windows
dim iKandidate as integer
dim i as integer
iNotWindows = GetDocumentCount()
hUseMenu()
iMenues = hMenuItemGetCount
hMenuSelectNr(iMenues-1) ' 'windows' ist usually the one before the last
waitslot() 'wait 200
iKandidate = 0
iMenues = hMenuItemGetCount
for i = ((iMenues - iNotWindows) + 1) to iMenues
if (hMenuItemIsChecked (i)) then
if (iKandidate = 0) then
iKandidate = i
else
Warnlog "unexpected error 4711 - more than one window active??!! hWindowGetIndex () "
endif
endif
next i
iMenues = (iKandidate - (iMenues - iNotWindows) - 1)
hMenuClose()
hWindowGetIndex = iMenues
end function
'*******************************************************************************
function hWindowGetText (optional iWindow as integer) as string
'///<b> function hWindowGetText (optional iWindow as integer) as string </b>///'
'///+ returns the text of the menu entry without the tilde: ///'
'///+ w/ calling parameter: the active window ///'
'///+ w/o calling parameter: the window i ///'
dim iMenues as integer ' takes the number of entries in the windows menue
dim iNotWindows as integer ' number of open windows
dim iUseWindow
if (isMissing(iWindow) = FALSE) then
iUseWindow = iWindow
else
iUseWindow = hWindowGetIndex()
endif
iNotWindows = GetDocumentCount()
hUseMenu()
iMenues = hMenuItemGetCount
hMenuSelectNr(iMenues-1) ' 'windows' ist usually the one before the last
waitslot() 'wait 200
iMenues = hMenuItemGetCount
hWindowGetText = hMenuItemGetTextMitTilde (iUseWindow + (iMenues - iNotWindows) + 1)
hWindowGetText = hhEntferneTilde(hWindowGetText)
hMenuClose()
end function
'*******************************************************************************
function hWindowSelect (iWindow as integer)
'///<b> function hWindowSelect (iWindow as integer) </b>///'
'///+ switches to the window i ///'
'///+ calling parameter: id of the window to activate ///'
dim iMenues as integer ' takes the number of entries in the windows menue
dim iNotWindows as integer ' number of open windows
iNotWindows = GetDocumentCount ()
hUseMenu()
'ActivateDocument iNumber as integer ' is a testtool command, but there is no system that stays behind iNumber :-[
iMenues = hMenuItemGetCount
hMenuSelectNr(iMenues-1) ' 'windows' ist usually the one before the last
WaitSlot() 'wait 200
iMenues = hMenuItemGetCount
hMenuSelectNr (iWindow + 1 + (iMenues - iNotWindows))
end function
'*******************************************************************************
function hUseMenu ()
'///<b> function hUseMenu () </b>///'
'///+ very global function: depends on 'gApplication' just activates the menu-bar ///'
Select Case Ucase(gApplication)
Case "WRITER"
Kontext "DocumentWriter"
DocumentWriter.UseMenu
Case "MASTERDOC"
Kontext "DocumentMasterDoc"
DocumentMasterDoc.UseMenu
Case "HTMLDOKUMENT"
Kontext "DocumentWriterWeb"
DocumentWriterWeb.UseMenu
case "CALC" ' there are 2 entries over :-( usually only one, html 0 :-((((
Kontext "DocumentCalc"
DocumentCalc.UseMenu
case "DRAW"
Kontext "DocumentDraw"
DocumentDraw.UseMenu
case "IMPRESS"
Kontext "DocumentImpress"
DocumentImpress.UseMenu
case "MATH" :
Kontext "DocumentMath"
DocumentMath.UseMenu
case "INSIGHT" :
Kontext "Insight"
Insight.UseMenu
case "BASIC" :
Kontext "BasicIde"
BasicIde.UseMenu
case "NONE" :
Kontext "DocumentBackground"
DocumentBackground.UseMenu
end select
end function
'*******************************************************************************
function hOpenContextMenu()
'/// very global function: depends on 'gApplication' just opens the Context Menu ///'
Select Case Ucase(gApplication)
Case "WRITER"
Kontext "DocumentWriter"
DocumentWriter.openContextMenu
Case "MASTERDOC"
Kontext "DocumentMasterDoc"
DocumentMasterDoc.openContextMenu
Case "HTMLDOKUMENT"
Kontext "DocumentWriterWeb"
DocumentWriterWeb.openContextMenu
case "CALC"
Kontext "DocumentCalc"
DocumentCalc.openContextMenu
case "DRAW"
Kontext "DocumentDraw"
DocumentDraw.openContextMenu
case "IMPRESS"
Kontext "DocumentImpress"
DocumentImpress.openContextMenu
case "MATH" :
Kontext "DocumentMath"
DocumentMath.openContextMenu
end select
end function
'*******************************************************************************
function hGetWindowCaption(sApplication as string, optional bAll as boolean)
'///<b> function hGetWindowCaption () </b>///'
'///+ just returns the string from the application main window ///'
'///+ If optional parameter = true, thenn go throught all applications and get caption; return array ///'
dim sTemp as string
dim aApplication() as string
dim aTemp(10) as string
dim iTimes as integer
dim i as integer
aApplication = array("SWRITER","SGLOBAL","SWEB","SCALC","SDRAW","SIMPRESS","SMATH","BASIC","BACK")
if (isMissing(bAll) OR (NOT bAll)) then
iTimes = 0
else
iTimes = uBound(aApplication())
sApplication = aApplication(0)
endif
for i=0 to iTimes
Select Case Ucase(sApplication)
Case "SWRITER"
Kontext "DocumentWriter"
try
sTemp = DocumentWriter.caption
catch
endcatch
Case "SGLOBAL"
Kontext "DocumentMasterDoc"
try
sTemp = DocumentMasterDoc.caption
catch
endcatch
Case "SWEB"
Kontext "DocumentWriterWeb"
try
sTemp = DocumentWriterWeb.caption
catch
endcatch
case "SCALC"
Kontext "DocumentCalc"
try
sTemp = DocumentCalc.caption
catch
endcatch
case "SDRAW"
Kontext "DocumentDraw"
try
sTemp = DocumentDraw.caption
catch
endcatch
case "SIMPRESS"
Kontext "DocumentImpress"
try
sTemp = DocumentImpress.caption
catch
endcatch
case "SMATH"
Kontext "DocumentMath"
try
sTemp = DocumentMath.caption
catch
endcatch
Case "BASIC"
Kontext "BasicIDE"
try
sTemp = BasicIDE.caption
catch
endcatch
Case "BACK"
Kontext "DocumentBackground"
try
sTemp = DocumentBackground.caption
catch
endcatch
case else
qaErrorLog "sApplication not defined: '" + sApplication + "'"
sTemp = ""
end select
aTemp(i) = sTemp
try
sApplication=aApplication(i+1)
catch
endcatch
next i
if (iTimes > 0) then
hGetWindowCaption = aTemp()
else
hGetWindowCaption = sTemp
endif
end function
'*******************************************************************************
function fSplitWindowTitle(sInString as string)
dim a, b, x, i as integer
dim sTemp() as string
dim sTempReturn(2) as string
dim sTempReturn2(3) as string
dim bTestToolCommunication as boolean
dim bDebugVersion as boolean ' aka 'nonpro'
dim bError as boolean
' a) 'Untitled2 - OpenOffice.org Draw' (2)
' b) 'Untitled1 - OpenOffice.org Writer TTD :localhost[1034]' (4)
' c) 'Untitled1 - StarOffice Writer [680m72(Build:8863)]' (3)
' d) 'Untitled2 - StarOffice Draw [680m72(Build:8863)] TTD :localhost[1034]' (5)
bTestToolCommunication = FALSE
bDebugVersion = FALSE
bError = FALSE
if (sInString <> "") then
' ' - ' separates Filename from Vendor
a = instr(sInString, " - ") ' get Document file name or Untitledi
if (a > 1) then
if (instr(a+1,sInString, " - ") > a) then
qaErrorLog "Argh!"
bError = TRUE
endif
sTempReturn(0) = left(sInString, a-1) ' (0) Filename
else
sTempReturn(0) = ""
bError = TRUE
endif
' seperate second string by spaces
sTemp() = split(right(sInString, len(sInString)-(a+2)), " ") ' Parts are now separated by spaces
x = uBound(sTemp())
sTempReturn(1) = sTemp(1) ' (1) Application
sTempReturn(2) = sTemp(0) ' (2) Vendor
' if ']' at end... (b,c,d)
if (right(sInString,1) = "]") then
' if ')' at second last position it is a nonpro!
if (right(sInString,2) = ")]") then
' normal detection works with spaces... (c)
bDebugVersion = TRUE
else
' remove TestTool communication string (b,d)
' it is the last 2 space seperated parts!
bTestToolCommunication = TRUE
if (left(sTemp(2),1)="[") then
bDebugVersion = TRUE
endif
endif
else
' normal detection with spaces works... (a)
endif
' sanity checks, to warn if assumptions are not met!
select case x
case 1:
if ((bTestToolCommunication) OR (bDebugVersion)) then
qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 1"
bError = TRUE
endif
case 2:
if ((bTestToolCommunication) OR (NOT bDebugVersion)) then
qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 2"
bError = TRUE
endif
case 3:
if ((NOT bTestToolCommunication) OR (bDebugVersion)) then
qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 3"
bError = TRUE
endif
'***** Warning: Indention error *****
case 4:
if ((NOT bTestToolCommunication) OR (NOT bDebugVersion)) then
'***** Warning: Indention error *****
qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 4"
bError = TRUE
endif
case else:
qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 0"
bError = TRUE
end select
if bError then
printlog sInString
endif
if (x > 1) then ' there is more to evaluate
' save the current computed values
for i=0 to 2
'***** Warning: Indention error *****
sTempReturn2(i) = sTempReturn(i)
next i
' make return array bigger
redim sTempReturn(4) as string
' copy data back
for i=0 to 2
'***** Warning: Indention error *****
sTempReturn(i) = sTempReturn2(i)
next i
' set remaining values, if exist
' debug version string
if bDebugVersion then
'***** Warning: Indention error *****
sTempReturn(3) = mid(sTemp(2),2,len(sTemp(2))-2) ' optional (3) Debug Version
else
'***** Warning: Indention error *****
sTempReturn(3) = ""
endif
' TestTool Communication string
if bTestToolCommunication then
'***** Warning: Indention error *****
' if true, then always the two last strings
sTempReturn(4) = sTemp(x-1) + " " + sTemp(x) ' optional (4) TestTool Communication
else
'***** Warning: Indention error *****
sTempReturn(4) = ""
endif
endif
else
redim sTempReturn(0) as string
sTempReturn(0) = ""
endif
fSplitWindowTitle = sTempReturn()
end function
|