1 'encoding UTF-8 Do not remove or change this line!
2 '*******************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: w_tool6.inc,v $
13 '* last change: $Author: vg $ $Date: 2008-08-18 12:44:06 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/******************************************************************************
34 '* owner : helge.delfs@sun.com
36 '* short description : Tools for writer tests.
38 '\******************************************************************************
43 ' Close the backing windows
44 FileExit "SynchronMode", TRUE
49 '--------------------------------------------------------------
50 ' end of temporaly functions
51 '--------------------------------------------------------------
53 function LiberalMeasurement ( sShould$, sActual$) as Boolean
54 '/// Input : (1. Should, 2. Actual) as Number with or without MeasurementUnit 'NumericField' as String ///'
55 '///+ if input has no MeasurementUnit i take it as 'cm' (was the default in old tests) ///'
56 '///+ Output: Boolean are they likely the same?
57 '/// NEEDED: mathematical proofment of iTolerance, by now just some guesses :-| ///'
58 '/// reason for this function:///'
59 '///+ because SO counts internaly in 'twip┤s' 'twentieth of a point' there are some rounding errors ///'
60 '///+ there are also some rounding errors because of the internal representatio of floating point numbers in computers ///'
61 '///+ now lets try to get rid of them and have a nicer output in tests... ///'
62 dim iTolerance as Double
64 LiberalMeasurement = False ' worst case
66 if (sShould$ = sActual$) then
67 LiberalMeasurement = True
69 ' check if measunit is the same !!
70 if (GetMeasUnit(sShould$) <> GetMeasUnit(sActual$) ) then
71 warnlog "in function LiberalMeasurement the measUnit is different, compare not possible yet :-("
73 ' set factor for liberality ;-)
75 if ( (StrToDouble(sShould$) + iTolerance) >= StrToDouble(sActual$) ) AND ((StrToDouble ( sShould$ ) - iTolerance) <= StrToDouble ( sActual$ )) then
76 LiberalMeasurement = True
78 LiberalMeasurement = False
84 '--------------------------------------------------------------
86 function GetMeasUnit ( sWert$ ) as String
87 '/// Input : Number with or without MeasurementUnit 'NumericField' as String ///'
88 '///+ Output: Initials of MeasurementUnit as String or "" when only a number ///'
90 '/// first lets check, if there is a number -> no unit there ///
91 if isNumeric (right (sWert$, 1)) then
94 '/// the only single character is '"' all others are two chars ///
95 if ( StrComp (right (sWert$, 1), chr$(34) ) = 0 ) then
96 GetMeasUnit = right (sWert$, 1)
98 GetMeasUnit = right (sWert$, 2)
103 '--------------------------------------------------------------
105 function StrToDouble ( sWert$ ) as Double
107 dim i, i1, i2 as integer
113 '/// Input : {'a[. ,]b[mm cm " pi pt]' with a, b as integer} as String ///'
114 '///+ Output: a[. , ]b as double ///'
116 ' get rid of measure unit, the only single character is '"' all others are two chars
117 ' there was a problem, if there is NO meas.unit!!!
118 if Len(sWert$) > Len(mUnit) then
119 test = Left$(sWert$, (len(sWert$) - Len(mUnit)))
120 StrToDouble = cDbl(rtrim(test))
122 if (isNumeric (sWert$) = FALSE) then
123 if ( StrComp (right (sWert$, 1), chr$(34) ) = 0 ) then
124 sDummy$ = Left$ ( sWert$, Len(sWert$)-1 )
126 sDummy$ = Left$ ( sWert$, Len(sWert$)-2 )
131 ' get position of fraction mark
132 i1 = instr (sDummy$, ",") ' wrong output
133 i2 = instr (sDummy$, ".")
134 if i1 > i2 then i = i1 else i = i2
137 a = val (left$ (sDummy$,i-1))
140 n = (len (sDummy$)-i)
141 b = val (right$ (sDummy$, n) )
149 '--------------------------------------------------------------
151 function wKillUpcomingActives(optional sDocument as string)
152 ' primary used in import/export tests
153 '/// to get any aktive killed & print the content of the aktive ///'
154 ' to catch errors during loading document
156 if Active.Exists then
157 if Strcomp(Left(Active.GetText,42),"Saving in external formats may have caused") = 0 then
158 printlog "info loss, messg!! OK??"
163 printLog Active.GetText
167 if Active.Exists then
168 if IsMissing(sDocument) then
169 Warnlog "(1/2): " + Active.GetText ' Changed from Warn to print.
171 Select case sDocument
172 Case "sw31.sdw", "sw31.vor"
173 warnlog "Saving sdw-file as sxw fails"
175 Warnlog Active.Gettext
179 Active.Ok ' Read Error
181 Active.No ' Style is different ...
185 ' catching style after read error :-)
188 if Active.Exists then
189 WarnLog "(2/2): "+Active.GetText
191 Active.No ' Style is different ...
198 '--------------------------------------------------------------
200 function wGetCharacterFont as String
201 Dim wasAsianLan as boolean
202 '/// Input : nothing ///'
203 '///+ Output: Fontname at cursor position as String ///'
207 Active.SetPage TabFont
211 if gAsianSup = True then
212 wGetCharacterFont = FontWest.GetSelText
214 wGetCharacterFont = Font.GetSelText
220 wasAsianLan = ActiveDeactivateAsianSupport (True)
224 Active.SetPage TabFont
227 wGetCharacterFont = FontWest.GetSelText
230 wasAsianLan = ActiveDeactivateAsianSupport (True)
234 '--------------------------------------------------------------
236 function wGetCharacterFontSize as String
237 Dim wasAsianLan as boolean
238 '/// Input : nothing ///'
239 '///+ Output: FontSize at cursor position as String ///'
243 Active.SetPage TabFont
247 if gAsianSup = True then
248 wGetCharacterFontSize = SizeWest.GetSelText
250 wGetCharacterFontSize = Size.GetSelText
256 wasAsianLan = ActiveDeactivateAsianSupport (True)
260 Active.SetPage TabFont
263 wGetCharacterFontSize = SizeWest.GetSelText
266 wasAsianLan = ActiveDeactivateAsianSupport (True)
270 '--------------------------------------------------------------
272 function ZeilenHoeheHolen as Double
273 '/// input: nothing///'
274 '///+ output: FormatRowHeight as double///'
275 Dim zWert as Double : Dim Ausgabe$
278 Kontext "ZellenHoehe"
279 Ausgabe$ = Hoehe.GetText
280 zWert = ZahlAusSpinnfield ( Ausgabe$ )
282 ZeilenHoeheHolen = 0.00
284 ZeilenHoeheHolen = zWert
289 '--------------------------------------------------------------
291 sub ZeilenHoeheTesten ( Wert as Double )
292 '/// input: FormatRowHeight as double///'
293 '///+ output: warnlog, if not eaqual ///'
294 '/// LiberalMeasurement enabled///'
297 Kontext "ZellenHoehe"
298 zWert = ZahlAusSpinnfield ( Hoehe.GetText )
299 if (LiberalMeasurement (Wert, zWert) <> TRUE) then QAErrorlog "#i94556# - Die Zeilenhöhe ist nicht "+ Wert + " sondern "+ zWert + "."
303 '--------------------------------------------------------------
305 function SpaltenBreiteHolen as Double
306 FormatColumnWidthWriter
307 Kontext "SpaltenBreite"
308 SpaltenBreiteHolen = ZahlAusSpinnfield (Breite.GetText )
312 '--------------------------------------------------------------
314 sub SpaltenBreiteTesten ( Wert as Double )
316 FormatColumnWidthWriter
317 Kontext "SpaltenBreite"
318 zWert = ZahlAusSpinnfield ( Breite.GetText )
319 if Not Wert = zWert then
320 Warnlog "Die Spaltenbreite ist nicht "+ Wert +" sondern "+ zWert
325 '--------------------------------------------------------------
327 sub SeitenAbstaendeHolen ( ZweiWerte() as Double )
330 Active.SetPage TabTabelle
332 ZweiWerte(1) = ZahlAusSpinnfield ( NachLinks.GetText )
333 ZweiWerte(2) = ZahlAusSpinnfield ( NachRechts.GetText )
337 '--------------------------------------------------------------
339 sub SeitenAbstaendeTesten ( WertLi as Double, WertRe as Double )
340 '/// liberalMeasurement implemented ///'
341 Dim zWert1 as Double : Dim zWert2 as Double
344 Active.SetPage TabTabelle
346 zWert1 = ZahlAusSpinnfield ( NachLinks.GetText )
347 zWert2 = ZahlAusSpinnfield ( NachRechts.GetText )
349 if (LiberalMeasurement (zWert1, WertLi) <> TRUE) then Warnlog "Left distance not " + WertLi + " but " + zWert1
350 if (LiberalMeasurement (zWert2, WertRe) <> TRUE) then Warnlog "Right distance not " + WertRe + " but " + zWert2
355 '--------------------------------------------------------------
357 function ZahlAusSpinnfield ( sWert$ ) as Double
358 ZahlAusSpinnfield = StrToDouble ( sWert$)
359 printlog ZahlAusSpinnfield
362 '--------------------------------------------------------------
364 sub ZeilenTesten ( Anzahl% )
365 dim temp(10) as string
368 Kontext "DocumentWriter"
369 DocumentWriter.TypeKeys "<Up>", 5 ' Move out of table ????!!!!
370 for i=2 to Anzahl% +4 ' might work, but if there are some more tables, it doesn't!!
372 Call wTypeKeys "<Down>"
373 FormatRowHeight 'This is OK; but different evaluation is necessary
374 Kontext "ZellenHoehe"
381 if dummy <> Anzahl% then Warnlog "Die Tabelle hat wohl mehr Zeilen als erwartet: soll => "+ Anzahl% +" sind "+ dummy
382 Kontext "DocumentWriter"
383 DocumentWriter.TypeKeys "<Up><Left>", 10
386 '--------------------------------------------------------------
388 sub SpaltenTesten ( Anzahl% )
389 FormatColumnWidthWriter
390 Kontext "SpaltenBreite"
392 if Anzahl% <> Spalte.GetText then Warnlog "Table has mohl column then expected: should => "+ Anzahl% +" is "+ Spalte.GetText
396 '--------------------------------------------------------------
398 sub TBOhTabelleEinfuegen (optional tName as string, optional tHeader as boolean, optional tRepeat as boolean, optional tSeperate as boolean, optional tBorder as boolean, optional tWidth as string, optional tHeight as string )
399 '/// TBOhTabelleEinfuegen ("Garfield",0,1,0,1,"10",tHeight:="7") ///'
400 ' maybe TODO: return of an array, that tells you the state of an existing / name table/ cause, you create a table in a tabl÷e :-)
401 ' try with switching tabpage
404 Kontext "TabelleEinfuegenWriter"
407 ' Default had been changed. Not to rewrite the whole test I decided to changed the row-number
411 if (IsMissing (tName) <> True) then TabellenName.SetText tName
412 if (IsMissing (tHeader) <> True) then
415 if (IsMissing (tRepeat) <> True) then if tRepeat then UeberschriftWiederholen.Check else UeberschriftWiederholen.UnCheck
421 if IsMissing (tSeperate) <> True then
423 TabelleNichtTrennen.Check
425 TabelleNichtTrennen.UnCheck
429 if IsMissing(tBorder) <> True then
437 if IsMissing(tWidth) <> True then
438 Spalten.SetText tWidth
442 if IsMissing(tHeight) <> True then Zeilen.SetText tHeight
444 TabelleEinfuegenWriter.OK
447 Kontext "TableObjectbar"
449 if TableObjectbar.NotExists then
450 Kontext "TextObjectbar"
451 TextObjectbar.SetNextToolBox
454 Select Case gApplication
456 Kontext "DocumentWriter"
458 Case "MASTERDOCUMENT"
459 Kontext "DocumentMasterDoc"
462 Kontext "DocumentWriterWeb"
468 '--------------------------------------------------------------
470 function hGetTableName () as string
471 hGetTableName = "" ' Worst Case
472 TableTableProperties ' get into existing table
476 Active.SetPage TabTabelle
480 hGetTableName = TabellenName.GetText
483 Kontext "TabelleEinfuegenWriter"
484 if TabelleEinfuegenWriter.Exists then
485 hGetTableName = TabellenName.Gettext
486 TabelleEinfuegenWriter.Ok
494 '--------------------------------------------------------------
496 function dec(Ref as integer)
497 ' ----------------------------------------
498 ' to give this func a var as ref: call without ANNY brackets => 'dec Variable'
499 ' opposite of this to call it via value ! WE DON'T WANT THIS !
500 ' (would be 'dec (Variable)' or in declaration 'function dec (ByVal x)')
504 '--------------------------------------------------------------
506 function inc(Ref as integer)
511 '--------------------------------------------------------------
513 function hGetColumn() as integer
515 FormatColumnWidthWriter
517 printlog "func1.inc->hGetColumn asks for table."
520 FormatColumnWidthWriter
522 print "giving up to find a table: func1 hgetcolumn 2"
525 Kontext "SpaltenBreite"
526 if SpaltenBreite.exists then
527 hGetColumn = Spalte.GetText
534 '--------------------------------------------------------------
536 function hNavigatorOpenWindows() as Integer
537 hNavigatorOpenWindows = 0
540 '/// Input: (); Output: 0: for the usual started SO first window / +1 for each other open Window ///'
541 '///+ -2 if no window is open :-) (i think then there is another problem ...)///'
542 '///+ this fuunction depends on navigator-fuunction: ///'
543 '///+ NO nav avail in: Formular; NOT CATCHED UPTONOW ///'
544 '///+ count classes - only windows in this class are visible in their nav ///'
545 '///+ Spreadsheet ///'
546 '///+ Presentation, Drawing///'
547 '///+ Text Doc, HTML Doc, Labels, Business cards, AND ///'
548 '///+ !Master Doc! in his nav are no windows countable!; NOT CATCHED UPTONOW ///'
550 '/// usually it counts 2 windows; 1. the window, that results in starting office ///'
551 '///+ 2. The entry 'Active Window', is always there (entries in navigator changes automatical ///'
552 '///+ to the visible window -> 2 this is the minima! ///'
553 '///+ so i give back a count of x-2 everything below 0 is an error !///'
555 dim j as integer, WelcherEintrag as integer
556 ' Navigator zur├�?cksetzen
557 Kontext "NavigatorWriter"
558 if NavigatorWriter.NotExists then ViewNavigator
561 do while (Active.Exists)
562 printlog Active.GetText
566 active.ok ' ...new since 638a5 7001 :-(
570 Kontext "NavigatorWriter"
572 hNavigatorOpenWindows = DokumentListe.GetItemCount - 2 ' couldn' see dokumentliste :-( reason:: active that prevents it :-(
574 ' printlog " hnow: "+DokumentListe.GetItemCount +" "+DokumentListe.GetSelText
575 if (DokumentListe.GetItemCount = 0) then print "waassss o ??!!?!??!?!"
578 Kontext "DocumentWriter"
582 '--------------------------------------------------------------
584 function hIsNamedDocLoaded (ShouldFile as String) as Boolean
585 '/// Input: name of loaded file; Output: True/False///'
586 '///+ Several checks may be combined: ///'
587 '///+ disabled: Plan A: requires clippboard: check, if not untitled 1 window... ///'
588 '///+ Plan B: SaveAs Dialog ///'
589 '///+ not used now: Plan C: check if hNavigatorOpenWindows() > 0 ///'
592 ''///+ to be able to check, that document was loaded, print something before opening new doc ///'
593 ''///+ during test, check if it is readable ... ///'
594 ' Kontext "DocumentWriter"
595 ' DocumentWriter.TypeKeys "<Mod1 home>"
596 ' DocumentWriter.TypeKeys "TBOlastWindow"
597 ' DocumentWriter.TypeKeys "<Return>"
599 ' Kontext "DocumentWriter"
600 ' DocumentWriter.TypeKeys "<Mod1 Home>"
601 ' DocumentWriter.TypeKeys "<Shift End>"
603 ' DocumentWriter.TypeKeys "<Home>"
604 ' if GetClipboardText <> "TBOlastWindow" Then ///'
606 '/// ' Plan B :-) ///
607 '///+' if a doc got loaded, the filename in a 'SaveAs' Dlg is different from "" ///
608 '///+' usually the file name of the loaded document with an changed extension chosen from SO ///
610 hIsNamedDocLoaded = False ' Let's start WorstCase :-(
611 FileSaveAs ' (Plan B)
612 Kontext "SpeichernDlg"
613 If DateiOhneExt(DateiExtract(Dateiname.GetSelText)) = DateiOhneExt(DateiExtract(ShouldFile)) Then
614 hIsNamedDocLoaded = True
615 ' Printlog "Filename: " + Dateiname.GetSelText+"; "+ShouldFile
616 ' Printlog "--------------------------------------------------Loaded as: " + Dateityp.GetSelText
618 'exception! for templates
619 if lcase(right(ShouldFile,3)) = "vor" or lcase(right(ShouldFile,3)) = "dot" then hIsNamedDocLoaded = True
623 '/ remove text of last window test text ///'
624 ' Kontext "DocumentWriter"
625 ' DocumentWriter.TypeKeys "<Mod1 home>"
626 ' DocumentWriter.TypeKeys "TBOlastWindow"
627 ' DocumentWriter.TypeKeys "<delete>"
630 '--------------------------------------------------------------
632 sub hSetSpellHypLanguage
635 Printlog " to get it to work, ihave to change the default languge in the options! FOR CURRENT DOCUMENT ONLY!!!!!"
637 Call hToolsOptions ("LANGUAGESETTINGS","LANGUAGES")
638 AktuellesDokument.Check
639 if glLocale (4) = "" then
640 warnlog "choose a spellbokk from the list below and insert it into the file <\testtool\input\impress\locale_1.txt> on position (4) (only enabled for asiann languages!) - '"+glLocale(4)+"'"
641 Kontext "ExtrasOptionenDlg"
642 ExtrasOptionenDlg.Cancel
643 sTrieit = hFindSpellHypLanguage
645 Call hToolsOptions ("LANGUAGESETTINGS","LANGUAGES")
646 AktuellesDokument.Check
647 if sTrieit <> "" then
648 Westlich.Select sTrieit
650 warnlog "SOrry no spellbook found :-("
653 Westlich.Select glLocale (4)
655 printlog "selected: "+Westlich.GetSelText
656 Kontext "ExtrasOptionenDlg"
661 '--------------------------------------------------------------
663 sub hFindSpellHypLanguage as string
664 dim iListLength as integer
668 ToolsOptions ' take length of list
669 Call hToolsOptions ("LANGUAGESETTINGS","WRITINGAIDS")
670 SprachmoduleBearbeiten.click
671 Kontext "ModuleBearbeiten"
672 for i = 1 to Sprache.GetItemCount
675 Printlog " "+i+": '"+Sprache.GetSelText +"'"
676 if i = 1 then hFindSpellHypLanguage = Sprache.GetSelText
678 ModuleBearbeiten.Close
679 Kontext "ExtrasOptionenDlg"
685 '--------------------------------------------------------------
687 function wCheckRowHeight ( ShouldValue as string ) as boolean
689 Kontext "ZellenHoehe"
690 if Hoehe.Gettext <> ShouldValue then
691 Warnlog "Height is not " + ShouldValue + " but " + Hoehe.Gettext
692 wCheckRowHeight = False
694 wCheckRowHeight = True
699 '--------------------------------------------------------------
701 sub wSearchWriteableArea ()
702 Dim PageDownNow as boolean, NowWriteable as boolean
704 ' This sup has not been properly worked
705 ' Looks complicated but isn't
706 ' Searches for messagebox, if found makes a PageDown in document 5 times
707 ' if writeable then, the moves curors up 1000 times. Hope it helps
708 ' Document is completely writeprotected the sup would loop endless
711 Do until NowWriteable = True
714 if Active.Exists then
715 if Active.GetRT = 304 then
717 if PageDownNow = True then
719 Call wTypeKeys "<Down>", 5
722 if Active.Exists then
723 if Active.GetRT = 304 then
733 Call wTypeKeys "<Up>", 1
736 if Active.Exists then
737 if Active.GetRT = 304 then
757 '---------------------------------------------------
759 function fInsertFrame (x1 as Integer , y1 as Integer , x2 as Integer , y2 as Integer)
760 'This function will insert a frame with the coordinate
764 Call hToolbarSelect("INSERT", true )
770 Call gMouseDown ( x1,y1 )
771 Call gMouseMove ( x1,y1,x2,y2 )
772 Call gMouseUp( x2,y2 )