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: t_tools1.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-13 10:27:11 $
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 : joerg.skottke@sun.com
36 '* short description : Tools (1)
38 '\******************************************************************************
40 private SLEEP_TIME_REQUESTED as integer
41 private SLEEP_CALLS_SUM as integer
42 private SLEEP_TIME_USED as integer
44 private const VERBOSE = FALSE
46 function GetClipboardText as string
48 '/// Returns the correct clipboard text (also if there is a 'RETURN' at it's end.
54 CBText$ = GetClipboard
61 if asc ( Right( CBText$, 1 )) = 10 then
62 Zwischen$ = Mid( CBText$, 1, len(CBText$)-1 )
63 if Zwischen$ <> "" then
64 if asc ( Right( Zwischen$, 1 )) = 13 then
65 GetClipboardText = Mid( Zwischen$, 1, len(Zwischen$)-1 )
67 GetClipboardText = Zwischen$
70 GetClipboardText = Zwischen$
73 if asc ( Right( CBText$, 1 )) = 13 then
74 Zwischen$ = Mid( CBText$, 1, len(CBText$)-1 )
75 if asc ( Right( Zwischen$, 1 )) = 10 then
76 GetClipboardText = Mid( Zwischen$, 1, len(Zwischen$)-1 )
78 GetClipboardText = Zwischen$
81 GetClipboardText = CBText$
87 '*******************************************************************************
89 function hDoubleClickInList ( window, Selektion as String, optional bFocus as boolean ) as Boolean
91 '/// hDoubleClickInList
92 '///+ Makes a double click onto an entry in a list (tested only in <i>style lists</i>)
93 '///+ window: name of list ///'
94 '///+ selektion: string to find in list ///'
95 '///+ bFocus: TRUE: activate the window with mouseclick before leaving ///'
96 '///+ ReturnValue: if found: TRUE; else FALSE ///'
99 Dim AlterWert as String
100 Dim NeuerWert as String
102 NeuerWert = "!=! !=!" ' init with dummy value
103 window.TypeKeys "<Home>"
104 if window.gettext <> Selektion then
105 for i=1 to 100 step 2
107 window.MouseDown 5, i +1
108 window.MouseUp 5, i +1
109 AlterWert = window.GetText
110 window.TypeKeys "<Down>"
111 NeuerWert = Window.GetText
112 window.TypeKeys "<Up>"
114 if AlterWert = Selektion then
116 window.MouseDown 5, i +1
117 window.MouseUp 5, i +1
119 ' catch if <down> had any effects
120 if Window.GetText = Selektion then
122 window.MouseDoubleClick 5, i +1
124 ' if optional parameter provided
125 if (isMissing (bFocus) = FALSE) then
126 window.MouseDown 5, i +1
127 window.MouseUp 5, i +1
132 i=0 ' start at top of list
136 if AlterWert = NeuerWert then
137 Warnlog "'" + Selektion + "' wasn't found in list!"
142 i=40 ' list not at end, but scrolled
151 if i < 200 OR i > 100 then
152 hDoubleClickInList = FALSE
154 hDoubleClickInList = TRUE
158 window.TypeKeys "<Return>"
159 hDoubleClickInList = TRUE
164 '*******************************************************************************
166 sub hMouseClick ( window, xPos, yPos )
168 ' Author: Thorsten Ziehm (26.09.2000)
170 '///+ Do a mouse click on a named window.
172 '///+ window : The object on which the mouse click should be make (document, listbox, window)
173 '///+ xPos : x-position (relativ to the size of the window (1:100)
174 '///+ yPos : y-position (relativ to the size of the window (1:100)
175 window.MouseDown ( xPos, yPos )
176 window.MouseUp ( xPos, yPos )
180 '*******************************************************************************
182 function wielange (StrtTime, optional iFormat as integer) as String
184 ' Author: Michael Friedrichs
186 '///+ Returns the time between a start- and an end timeframe.
187 '///+ iFormat: 0: default; 1: mysql ///'
195 if isMissing(iFormat) then
196 'dim iFormat as integer
200 Zeitspanne = Now() - StrtTime
201 Zeitspannesek = Zeitspanne / 1.15741E-05 + 1
202 Zeitspanneh = Fix(Zeitspannesek / 3600)
203 Zeitspannesek = Zeitspannesek - Zeitspanneh * 3600
204 Zeitspannemin = Fix(Zeitspannesek / 60)
205 Zeitspannesek = Zeitspannesek - Zeitspannemin * 60
206 Zeitspannesek = Fix(Zeitspannesek)
209 sTemp = "" & Zeitspanneh & "h " & Zeitspannemin & "m " & Zeitspannesek & "s"
211 ' mysql format for status.inc
212 if Zeitspanneh < 10 then
213 sTemp = "0" & Zeitspanneh & ":"
215 sTemp = "" & Zeitspanneh & ":"
218 if Zeitspannemin < 10 then
219 sTemp = "" & sTemp & "0" & Zeitspannemin & ":"
221 sTemp = "" & sTemp & Zeitspannemin & ":"
224 if Zeitspannesek < 10 then
225 sTemp = "" & sTemp & "0" & Zeitspannesek
227 sTemp = "" & sTemp & Zeitspannesek
231 qaErrorLog "t_tools1.inc::wielange: optional parameter iFormat out of range!"
239 '*******************************************************************************
241 function Sleep( optional _iSeconds as integer ) as integer
243 const CFN = "global::tools::includes::required::Sleep(...): "
245 const STATUS_NO_DELAY = 0
246 const STATUS_TIMEOUT_EXCEEDED = 1
247 const STATUS_WAITSLOT_CRASHED = 2
248 const STATUS_CLASSIC_WAIT_USED = 3
250 ' This is the "classic" behavior of the sleep function. If you did not set
251 ' GLOBAL_USE_NEW_SLEEP to TRUE in your .bas file, this will be used.
252 if ( not GLOBAL_USE_NEW_SLEEP ) then
253 if ( IsMissing( _iSeconds ) ) then
256 wait( _iSeconds * 1000 )
258 sleep() = STATUS_CLASSIC_WAIT_USED
262 ' This is an extended and accelerated version of the "classic" sleep()
263 ' subroutine which used to call Wait( n ) with a given number of
264 ' milliseconds. This function uses WaitSlot( n ) and is dynamic.
265 ' The try...catch block is necessary because WaitSlot() can - under certain
266 ' yet unknown conditions - make the office application crash.
267 ' When called with 0 seconds we return 0 (dynamic sleep statements within
268 ' test initialization can actually call the function with a Zero parameter)
269 ' A negative number forces the function to use the classic behavior.
270 ' If no time is given the function defaults to 5 seconds.
271 ' The function now provides returnvalues:
272 ' 0 = Normal WaitSlot() used, this is the preferred method.
273 ' 1 = WaitSlot() timeout reached, one extra second was added.
274 ' This is bad and the script developer should try to fix it.
275 ' 2 = Wait() was used (classic method, fallback).
276 ' 3 = Wait() was used (forced old behavior)
278 dim iMilliseconds as integer
279 dim iStatus as integer : iStatus = 0
280 dim lBegin as long : lBegin = GetSystemTicks
281 dim iSeconds as integer : iSeconds = 5
282 dim iSystemDelay as integer : iSystemDelay = 1000
283 dim iTimeDiff as long : iTimeDiff = 0
285 ' On Solaris we are a little slower, so we increase the system delay a little
286 if ( instr( lcase( gtSysName ) , "solaris" ) > 0 ) then
290 ' Override default wait time (5 seconds) if parameter is given
291 if ( not IsMissing( _iSeconds ) ) then
295 ' Do exit directly if no wait requested
296 if ( iSeconds = 0 ) then
297 Sleep() = STATUS_NO_DELAY
301 ' We need the time in ms and absolute (parameter can be negative)
302 iMilliseconds = abs( iSeconds * 1000 )
304 ' Here we actually do the delay and generate return values
305 ' If WaitSlot() times out, we give an extra second (wait(1000))
306 if ( iSeconds > 0 ) then
308 if ( WaitSlot( iMilliseconds ) <> WSFinished ) then
310 iStatus = STATUS_TIMEOUT_EXCEEDED
313 wait( iMilliseconds )
314 iStatus = STATUS_WAITSLOT_CRASHED
317 Wait( iMilliseconds )
318 iStatus = STATUS_CLASSIC_WAIT_USED
321 ' Find out how long it took, warn if time was zero (sleep most likely not required)
322 iTimeDiff = GetSystemTicks - lBegin
323 if ( iTimeDiff = 0 ) then
324 printlog( CFN & "Zero time. Please consider removing Sleep() statement" )
328 SLEEP_CALLS_SUM = SLEEP_CALLS_SUM + 1
329 SLEEP_TIME_USED = SLEEP_TIME_USED + iTimeDiff / 1000 ' good enough
330 SLEEP_TIME_REQUESTED = SLEEP_TIME_REQUESTED + iSeconds
331 printlog( CFN & "--------------------- New call ---------------------" )
332 printlog( CFN & "Total Sleep()-Time requested (seconds): " & SLEEP_TIME_REQUESTED )
333 printlog( CFN & "Total Sleep()-Time used (seconds).....: " & SLEEP_TIME_USED )
334 printlog( CFN & "Total number of Sleep()-Calls.........: " & SLEEP_CALLS_SUM )
337 ' Try to make something useful out of the status
338 if ( iStatus <> 0 ) then
339 printlog( CFN & "Sleep(" & abs( iSeconds ) & "), took " _
340 & iTimeDiff & " ms, rc=" & iStatus )
342 case STATUS_TIMEOUT_EXCEEDED :
343 printlog( CFN & "Timeout exceeded." )
344 case STATUS_WAITSLOT_CRASHED :
345 printlog( CFN & "Used Wait(n). WaitSlot() failed." )
346 case STATUS_CLASSIC_WAIT_USED :
347 printlog( CFN & "Used Wait(n). Classic behavior forced" )
354 '*******************************************************************************
356 sub DialogTest( Window, optional iNumber as integer)
359 '///+ Make <i>SnapShots</i>
360 '/// <b>Window</b> : the name of the window as declared in qa/qatesttool/global/win/*
361 '/// <i>Optional Parameter</i> <b>iNumber</b> : Number to distinguish windows which dynamical change their content but not their ID///'
362 '///+ the number has to be provided by the testscript creator ///'
363 Dim Ergebnis as Integer
364 Dim Ausgabe as String
365 Dim UndRaus as Boolean
368 ' evaluate optional parameter
369 if isMissing(iNumber) then
373 'there will be more pictures with the same ID
378 ' In Place Translation Feature: not used anymore;
379 ' The matching of the strings on the later migration step never worked.
380 ' Just kept here for historical reasons
383 while UndRaus = FALSE
385 if Ausgabe <> "" OR Ausgabe <> "1" then
386 if Left ( Ausgabe, 1 ) = "0" then
387 Ausgabe = Right ( Ausgabe, Len( Ausgabe )- 2 )
388 AnhaengenAnDatei ( gOfficePath + "trans_output.txt", Ausgabe )
391 if Ausgabe = "1" then
398 if Not window.Exists(2) then
399 Warnlog " - Window nicht existent:" + window.Name + " " + window.ID
402 'To get a history, of what windows are covered, use the following line
403 ' AnhaengenAnDatei ( ConvertPath (gOfficePath + "user\work\wieviel.txt"), window.Name + " " + sCount + " : " + window.ID )
409 if gbSnapShot = TRUE then
410 'Make Screenshot from dialog and save as HelpID.bmp
411 Dim Dummy as String, sName as String, sPicName as String
416 sName = Dummy + sCount + ".bmp"
418 'save with respect to application and language
419 sCapturePath = ConvertPath (gOfficePath + "user\work\screenshots"+iSprache+"\")
420 sPicName = sCapturePath + lCase(gApplication)
421 'create directory if it doesn't exist
422 if hDirectoryExists(sPicName) <> TRUE then
425 sPicName = sPicName + sName
428 window.SnapShot( sPicName )
430 warnlog "t_tools1.inc::DialogTest Failed to save screenshot: '" + sPicName + "'"
437 '*******************************************************************************
439 function hFindeImDokument ( Passage$ , Optional A, optional bRegEx ) as boolean
441 ' Author: Joerg Sievers (13.11.2001)
442 '/// hFindeImDokument
443 '/// Searches via 'Search&Replace'-Dlg in StarOffice Writer, -Clac,
444 '///+ -HTML, -GlobalDoc for the string <b>EXACT MATCH</b>.
445 '///+ Only ONE TIME and THE FIRST search phrase will be found!
446 '/// <i>Optional Parameter</i> <b>a</b> : If you do not want a warnlog message
447 '/// <i>Optional Parameter</i> <b>bRegEx</b> : if you look fort an regular expression
448 Dim WhatIsIn as string
449 Dim bSilent as boolean
451 bSilent = NOT isMissing(a)
452 gApplication = UCase ( gApplication )
453 hFindeImDokument = FALSE
455 select case gApplication
458 Kontext "DocumentCalc"
459 DocumentCalc.TypeKeys "<MOD1 HOME>"
462 Kontext "DocumentWriter"
463 DocumentWriter.TypeKeys "<MOD1 HOME>"
466 Kontext "DocumentWriterWeb"
467 DocumentWriterWeb.TypeKeys "<MOD1 HOME>"
470 Kontext "DocumentMasterDoc"
471 DocumentMasterDoc.TypeKeys "<MOD1 HOME>"
477 Kontext "FindAndReplace"
478 if SimilaritySearch.IsVisible = False then
482 if MatchCase.IsChecked = False then
486 if SimilaritySearch.IsChecked = TRUE then
487 SimilaritySearch.UnCheck
489 warnlog "'Similarity search' checkbox was enabled! It shouldn't be the default!"
493 if IsMissing(bRegEx) <> TRUE then
494 RegularExpressions.Check
497 SearchFor.Settext Passage$
501 if NOT Active.Exists(2) then
503 Kontext "FindAndReplace"
505 FindAndReplace.Cancel
507 WhatIsIn = GetClipboardText
509 if WhatIsIn <> Passage$ then
511 warnlog "The search-request for '" & Passage$ & "' has been fault! (Found: '"& WhatIsIn & "')"
514 hFindeImDokument = TRUE
520 if Active.Exists(1) then
525 warnlog "The search-request for '" & Passage$ & "' has been fault! (Found: '"& WhatIsIn & "')"
528 Kontext "FindAndReplace"
529 if SimilaritySearch.IsVisible = False then
533 if MatchCase.IsChecked then
537 if SimilaritySearch.IsChecked = TRUE then
539 SimilaritySearch.UnCheck
541 warnlog "'Similarity search' checkbox was enabled! It shouldn't be the default!"
545 if IsMissing(bRegEx) <> TRUE then
546 RegularExpressions.UnCheck
550 FindAndReplace.Cancel
556 if Active.Exists then
557 printlog "> "+Active.GetText
561 if Active.Exists then
566 warnlog "The search-request for '" & Passage$ & "' has been fault! (Found: '"& WhatIsIn & "')"
569 Kontext "FindAndReplace"
570 if SimilaritySearch.IsVisible = False then
574 if MatchCase.IsChecked then
578 if SimilaritySearch.IsChecked = TRUE then
580 SimilaritySearch.UnCheck
582 warnlog "'Similarity search' checkbox was enabled! It shouldn't be the default!"
586 if IsMissing(bRegEx) <> TRUE then
587 RegulaererAusdruck.UnCheck
591 FindAndReplace.Cancel
598 '*******************************************************************************
600 function hFindeMehrImDokument ( Passage as string , WieOft as integer ) as boolean
602 ' Author: Joerg Sievers (26.07.2000)
603 '/// hFindeMehrImDokument
604 '/// Searches per 'Search&Replace'-Dlg in StarOffice Writer, -Clac,
605 '///+-HTML, -GlobalDoc for the string <b>EXACT MATCH</b>.
606 '/// You have to give the function the number how often the phrase
607 '///+should be found in the document as an additional parameter (as integer).
608 '/// Only when exact the number of the phrase will be found correctly
609 '///+the function gives back TRUE.
610 '/// <i>see also</i> : hFindeImDokument (TOOLS.INC)
612 gApplication = UCase ( gApplication )
614 hFindeMehrImDokument = FALSE
616 select case gApplication
619 Kontext "DocumentCalc"
620 DocumentCalc.TypeKeys "<MOD1 HOME>"
623 Kontext "DocumentWriter"
624 DocumentWriter.TypeKeys "<MOD1 HOME>"
627 Kontext "DocumentWriter"
628 DocumentWriter.TypeKeys "<MOD1 HOME>"
631 Kontext "DocumentMasterDoc"
632 DocumentMasterDoc.TypeKeys "<MOD1 HOME>"
641 Kontext "FindAndReplace"
642 if NOT MatchCase.IsChecked then
645 SearchFor.Settext Passage
649 if NOT Active.Exists(2) then
651 FindAndReplace.Cancel
654 if GetClipboardText <> Passage then
655 warnlog "The search-request for '" & Passage & "' has been fault!"
659 hFindeImDokument = TRUE
660 printlog "Searchphrase found " & i & " time(s)."
668 if Active.Exists then
671 warnlog "The search-request for '" & Passage & "' has been fault!"
673 Kontext "FindAndReplace"
675 if MatchCase.IsChecked then
678 FindAndReplace.Cancel
683 if Active.Exists then
686 warnlog "The search-request for '" & Passage & "' has been fault!"
689 Kontext "FindAndReplace"
690 if MatchCase.IsChecked then
693 FindAndReplace.Cancel
697 Kontext "FindAndReplace"
698 if FindAndReplace.Exists(2) then
699 FindAndReplace.Cancel
704 '*******************************************************************************
706 sub ErgebnisSchreiben ( Window, Name$ )
708 '/// ErgebnisSchreiben
709 '///+ Used in context with making screenshots.
711 Dim FileNum% : Dim i%
713 Dim Text$ : Dim Text2$
715 Datei$ = sCapturePath + "Ergebis.txt"
717 Text$ = Text2$ + " => " + Name$
720 Open Datei$ for Append as #FileNum%
721 Print #FileNum%, Text$
726 '*******************************************************************************
728 sub TextInDatei ( TextText$, Datei$ )
735 Open Datei$ for Append as #FileNum%
736 Print #FileNum%, TextText$
741 '*******************************************************************************
743 function TrimTab ( sTrimmer as String ) as String
746 '/// <u>Input</u>: the original text
747 '/// Returns the string without <tab>s at the beginning and the end of a string.
749 Dim sInterim as String
752 sInterim = lTrimTab ( sInterim )
753 TrimTab = rTrimTab ( sInterim )
757 '*******************************************************************************
759 function lTrimTab ( slTrimmer as String ) as String
762 '/// <u>Input</u>: the original text
763 '/// Returns the string without <tab>s at the beginning.
764 '/// Cuts <Tab's> at the beginning of a string ( left )
766 Dim i, iLen as Integer
767 Dim sInterim as String
769 iLen = len ( slTrimmer )
773 if Asc ( left ( sInterim, 1 ) ) = 9 then
774 sInterim = Right ( sInterim, len ( sInterim ) - 1 )
782 '*******************************************************************************
784 function rTrimTab ( srTrimmer as String ) as String
787 '/// Input: the original text
788 '/// Returns the string without <tab>s at the end.
789 '/// Cuts <Tab's> at the beginning of a string ( right )
791 Dim i, iLen as Integer
792 Dim sInterim as String
794 iLen = len ( srTrimmer )
798 if Asc ( right ( sInterim, 1 ) ) = 9 then
799 sInterim = left ( sInterim, len ( sInterim ) - 1 )
808 '*******************************************************************************
810 function TrimString (Content as String, delim as integer) as String
812 ' Author: Frank Heitbrock (26.07.2002)
814 '/// <u>Input</u>: The String, the delimiter which should be cut from the string.
815 '/// Returns the String without the delimiter.
817 '///+ Content = " H a l l o ", delim = 32 (ascii for space character)
818 '///+ Return = "Hallo"
819 dim strlen as integer, i as integer, k as integer
820 dim CharBuff(1 to 100) as String
821 dim ResultStr as String
822 ' at first cut the empty strings left and right of the String
823 Content = lTrim(Content)
824 Content = rTrim(Content)
825 ' now we search for all appropriate ascii characters in the middle of the String and delete them
826 strlen = len(Content)
829 if mid(Content, i, 1) <> chr(delim) then
830 CharBuff(k) = mid(Content, i, 1)
835 ResultStr = ResultStr + CharBuff(i)
837 TrimString = ResultStr
841 '*******************************************************************************
843 function ActiveDeactivateAsianSupport ( WhatState as Boolean ) as Boolean
845 ' Author: Thorsten Ziehm
846 '/// ActiveDeactivateAsianSupport
847 '/// <u>Input</u>: TRUE or FALSE
848 '///+ TRUE: The Asian support will be enabled.
849 '///+ FALSE: The Asian support will be disabled.
851 '///+ TRUE/FALSE for the last state of the checkbox in the office UI.
853 hToolsOptions ( "LanguageSettings", "Languages" )
855 IF Aktivieren.IsEnabled then 'the checkbox is disabled in asian versions
856 ActiveDeactivateAsianSupport = Aktivieren.IsChecked ' the function gets the old state of the checkbox
858 if WhatState = TRUE then
866 gAsianSup = WhatState ' Set the global variable
868 Kontext "ExtrasOptionenDlg"
872 ActiveDeactivateAsianSupport = TRUE
873 If WhatState = FALSE then
874 warnlog "Deactivating of asian language support is not possible, because it is disabled in cjk versions"
876 Kontext "ExtrasOptionenDlg"
883 '*******************************************************************************
885 function ActiveDeactivateCTLSupport ( WhatState as Boolean ) as Boolean
887 ' Author: Hercule Li (March 2004)
888 '/// ActiveDeactivateCTLSupport
889 '/// <u>Input</u>: TRUE or FALSE
890 '/// TRUE : The CTL will be enabled.
891 '/// FALSE: The CTL will be disabled.
893 '/// TRUE/FALSE for the last state of the checkbox in the office UI.
895 hToolsOptions ( "LanguageSettings", "Languages" )
897 IF ComplexScriptEnabled.IsEnabled then 'the checkbox is disabled in CTL versions
898 ActiveDeactivateCTLSupport = ComplexScriptEnabled.IsChecked ' the function gets the old state of the checkbox
900 if WhatState = TRUE then
901 ComplexScriptEnabled.Check
903 ComplexScriptEnabled.UnCheck
905 gCTLSup = WhatState ' Set the global variable
907 Kontext "ExtrasOptionenDlg"
911 ActiveDeactivateCTLSupport = TRUE
912 If WhatState = FALSE then
913 warnlog "Deactivating of CTL language support is not possible, because it is disabled in ctl versions"
915 Kontext "ExtrasOptionenDlg"
922 '*******************************************************************************
924 function GetDecimalSeperator ( optional sDummy$ ) as String
926 '/// <u>Precondition</u>: Measuring unit has to be set to centimeter (cm) before using this function. (see: fSetMeasurementToCM())
927 '///+ <u>Input</u>: Number with fractionmark from <i>NumericField</i> as string
928 '///+ <u>Output</u>: A dot (.) or a comma (,) as string
929 Dim sCheckForSeparator as string
930 Const cWhereIsThisFunction = "qa::qatesttool::global::tools::inc::t_tools1.inc::GetDecimalSeperator: "
931 Dim bDotOrCommaIncluded as boolean
933 'Setting the determination of a dot or a comma to FALSE until it was successfull.
934 bDotOrCommaIncluded = FALSE
936 if IsMissing(sDummy$) then
937 '/// Opening a new document depending on <i>gApplication</i> value and closing it at the end.
939 '/// Tools / Options / (Modul: gApplication) / General tabpage.
941 '///+ <ol><li>Reading the string of the tabulator numeric field</li>
942 select case gApplication
944 Call hToolsOptions("WRITER","GENERAL")
945 sCheckForSeparator = Tabulatorenabstand.GetText
947 Call hToolsOptions("CALC","GENERAL")
948 sCheckForSeparator = Tabulator.GetText
950 Call hToolsOptions("IMPRESS","GENERAL")
951 sCheckForSeparator = Tabulatorenabstand.GetText
953 Call hToolsOptions("DRAW","GENERAL")
954 sCheckForSeparator = Tabulatorenabstand.GetText
955 case "MASTERDOCUMENT"
956 Call hToolsOptions("WRITER","GENERAL")
957 sCheckForSeparator = Tabulatorenabstand.GetText
959 Call hToolsOptions("WRITER","GENERAL")
960 sCheckForSeparator = Tabulatorenabstand.GetText
962 warnlog cWhereIsThisFunction & "For this module ("& gApplication &") no decimal seperator setting exists."
964 Kontext "ExtrasOptionenDlg"
966 if Instr(sCheckForSeparator, ",") > 0 then
967 GetDecimalSeperator = ","
968 bDotOrCommaIncluded = TRUE
970 if Instr(sCheckForSeparator, ".") > 0 then
971 GetDecimalSeperator = "."
972 bDotOrCommaIncluded = TRUE
976 '///+ <li>or determining the seperator depending on the OPTIONAL value (string).</li></ol>
977 'Get position of fraction mark / get IT
978 if InStr (sDummy$, ",") > 0 then
979 GetDecimalSeperator = ","
980 bDotOrCommaIncluded = TRUE
982 if InStr (sDummy$, ".") > 0 then
983 GetDecimalSeperator = "."
984 bDotOrCommaIncluded = TRUE
988 '/// If the determination failed the dot will be used (default) as decimal seperator.
989 if bDotOrCommaIncluded = FALSE then
990 warnlog cWhereIsThisFunction & "Unable to determine decimal separator. Setting dot (.) as default."
991 GetDecimalSeperator = "."
993 printlog "Info: Decimal Seperator is a '" & GetDecimalSeperator & "'."
997 '*******************************************************************************
999 sub sResetTheOffice as boolean
1004 Dim apara(1) As new com.sun.star.beans.PropertyValue
1007 Dim sString as string
1008 Dim fDeleteList(32000) as string
1009 Dim sLanguage as string
1010 Dim bError as boolean
1011 Dim sDefaultLocale as string
1012 Dim sDefaultLocaleCJK as string
1013 Dim sDefaultLocaleCTL as string
1014 Dim sfgetL10Nvalue as string
1015 Dim SetupXML as String
1016 Dim SetupXMLNet as string
1017 Dim SetupXMLDefault as string
1018 Dim sLanOutIni as string
1020 sString = "qa:qatesttool:calc:options:inc:coption1.inc:: "
1021 sResetTheOffice = TRUE
1023 ' only run on UNIX platforms; there is a problem with the quickstarter on win32
1024 if ("unx" = gPlatgroup) then
1026 SetupXML = gOfficePath & ConvertPath("user\registry\data\org\openoffice\Setup.xcu")
1027 ' function 'fgetL10Nvalue' is also in this library
1028 sLanOutIni = fgetL10Nvalue(SetupXML)
1031 ' BugID 98315 -> looking in networkpath for the language until bug will be fixed.
1032 SetupXMLNet = gNetzOfficePath & ConvertPath("share\registry\data\org\openoffice\Setup.xcu")
1033 sLanOutIni = fgetL10Nvalue(SetupXMLNet)
1036 ' It is an English FAT version 645m9s2 or higher.
1037 SetupXMLDefault = gOfficePath & ConvertPath("share\registry\data\org\openoffice\Setup.xcu")
1038 sLanOutIni = fgetL10Nvalue(SetupXMLDefault)
1040 warnlog sString & SetupXML & " not found => can't get the correct Office-Language!."
1041 sResetTheOffice = FALSE
1047 uno=hGetUnoService()
1051 ap=uno.createInstance("com.sun.star.configuration.ConfigurationProvider")
1052 apara(0).Name="nodepath"
1053 apara(0).Value="/org.openoffice.Office.Linguistic/General"
1054 apara(1).Name="lazywrite"
1055 apara(1).Value=False
1056 xViewRoot=ap.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPara())
1057 sLanguage = sfgetL10Nvalue
1058 sDefaultLocale = xViewRoot.getPropertyValue("DefaultLocale")
1059 sDefaultLocaleCJK = xViewRoot.getPropertyValue("DefaultLocale_CJK")
1060 sDefaultLocaleCTL = xViewRoot.getPropertyValue("DefaultLocale_CTL")
1061 printlog "Old UI language: '" + sLanOutIni + "'"
1062 printlog "Old default locale: '" + sDefaultLocale + "'"
1063 printlog "Old default locale CJK: '" + sDefaultLocaleCJK + "'"
1064 printlog "Old default locale CTL: '" + sDefaultLocaleCTL + "'"
1068 warnlog sString + "Failed to read UI language."
1075 ' To prevent restarting of OOo, the try/catch is around this and
1076 ' to prevent messages about communication errors
1077 printlog ResetApplication
1078 FileExit "SynchronMode", TRUE
1080 ' It is no error, if this fails - so it gets its own try/catch
1082 if active.exists(5) then
1083 active.no 'discard changes
1089 warnlog sString + "Failed to close OOo."
1092 sleep 10 'To wait until OOo is realy away
1095 'only act, if no error and if language <> ''
1096 if (NOT bError AND sLanguage <> "") then
1097 'Remove user directory
1099 if (right(gOfficePath,1)=gPathSigne) then
1100 'Dir doesn't work, is a path singe is at the end
1101 gOfficePath = left(gOfficePath,len(gOfficePath)-1)
1103 printlog "Going to delete directory: '" + gOfficePath + "'"
1104 if (dir(gOfficePath) = "") then
1105 qaErrorlog "Directory is already deleted."
1108 if (dir(gOfficePath) <> "") then
1109 warnlog "Directory wasn't deleted."
1114 warnlog sString + "Failed to delete user directory."
1119 'Start OOo and restore language
1120 'Needs only to be done, if UI language wasn't the default (!= "")
1121 if ((sLanguage & sDefaultLocale & sDefaultLocaleCJK & sDefaultLocaleCTL) <> "") then
1124 Call hDisableQuickstarter
1125 'Here we need the Exit from a running Quickstarter...
1126 Call ExitRestartTheOffice
1127 uno=hGetUnoService()
1128 ap=uno.createInstance("com.sun.star.configuration.ConfigurationProvider")
1129 apara(0).Name="nodepath"
1130 apara(0).Value="/org.openoffice.Office.Linguistic/General"
1131 apara(1).Name="lazywrite"
1132 apara(1).Value=False
1133 xViewRoot=ap.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPara())
1134 if (sLanOutIni <> "") then
1135 printlog "Old UI language: '" + sLanOutIni + "'"
1136 xViewRoot.setPropertyValue("UILocale", sLanOutIni)
1137 xViewRoot.commitChanges()
1139 if (sDefaultLocale <> "") then
1140 printlog "Old default locale: '" + sDefaultLocale + "'"
1141 xViewRoot.setPropertyValue("DefaultLocale", sDefaultLocale)
1142 xViewRoot.commitChanges()
1144 if (sDefaultLocaleCJK <> "") then
1145 printlog "Old default locale CJK: '" + sDefaultLocaleCJK + "'"
1146 xViewRoot.setPropertyValue("DefaultLocale_CJK", sDefaultLocaleCJK)
1147 xViewRoot.commitChanges()
1149 if (sDefaultLocaleCTL <> "") then
1150 printlog "Old default locale CTL: '" + sDefaultLocaleCTL + "'"
1151 xViewRoot.setPropertyValue("DefaultLocale_CTL", sDefaultLocaleCTL)
1152 xViewRoot.commitChanges()
1154 if xViewRoot.hasPendingChanges() then
1155 warnlog(sFileFunction+"Changes still pending...")
1159 warnlog sString + "Failed to set UI language."
1164 Call ExitRestartTheOffice
1168 '*******************************************************************************
1170 sub raiseApplication
1172 ' Try to solve focus problem on MacOS X; After calling this function, OOo should be most front;
1176 Dim tBundle as string
1179 ' Calling just the .app with open on MacOS X via shell command
1180 if ( lcase( gPlatform ) = "osx" ) then
1182 aPath = split(gNetzOfficePath, gPathSigne)
1184 ' make sure 'Contents' is just one time in path
1185 for i=0 to uBound(aPath)
1187 if "Contents" = aPath(i) then
1198 i=inStr(gNetzOfficePath, "Contents")
1199 tBundle=left(gNetzOfficePath, i-2)
1200 shell("open",1 ,tBundle, true)
1205 '*******************************************************************************
1207 function hUseAsyncSlot( cSlot as string ) as integer
1209 dim iWait as integer
1210 dim iTime as integer : iTime = 0
1211 const MAX_WAIT = 100
1213 const CFN = "global::tools::includes::required::hUseAsyncSlot():"
1215 if ( VERBOSE ) then printlog( CFN & "Using slot: " & cSlot )
1217 for iWait = 1 to MAX_WAIT
1219 select case ( lcase( cSlot ) )
1220 case "fileclose" : FileClose
1221 case "filesaveas" : FileSaveAs( "SynchronMode", TRUE )
1222 case "filesaveall" : FileSaveAll( "SynchronMode", TRUE )
1223 case "fileexport" : FileExport
1224 case "filereload" : FileReload( "SynchronMode", TRUE )
1225 case "fileopen" : FileOpen
1227 case "editdoc" : EditDoc
1228 case "editcopy" : EditCopy
1229 case "editchangesrecord" : EditChangesRecord
1230 case "editchangesshow" : EditChangesShow
1231 case "editchangesprotecttrace" : EditChangesProtectTrace
1232 case "editchangescomment" : EditChangesComment
1234 case "editpaste" : EditPaste
1235 case "editcopy" : EditCopy
1236 case "editcut" : EditCut
1237 case "editselectall" : EditSelectAll
1238 case "editselectallmath" : EditSelectAllMath
1239 case "editselectionmodeblock" : EditSelectionModeBlock
1240 case "editselectionmodestandard" : EditSelectionModeStandard
1241 case "editdeletecontents" : EditDeleteContents
1242 case "editundo" : EditUndo
1243 case "editredo" : EditRedo
1244 case "editrepeat" : EditRepeat
1245 case "editpastespecial" : EditPasteSpecial
1246 case "editpastespecialwriter" : EditPasteSpecialWriter
1247 case "editsearchandreplace" : EditSearchAndReplace
1248 case "editduplicate" : EditDuplicate
1249 case "editgluepoints" : EditGluePoints
1250 case "editdeleteslide" : EditDeleteSlide
1251 case "editobjectproperties" : EditObjectProperties
1252 case "editobjectedit" : EditObjectEdit
1253 case "editobjectsavecopyas" : EditObjectSaveCopyAs
1255 case "formatcharttype" : FormatChartType
1256 case "formatcontrol" : FormatControl
1257 case "formateditpoints" : FormatEditPoints
1258 case "formatsections" : FormatSections
1259 case "formatchangecaseupper" : FormatChangeCaseUpper
1260 case "formatchangecaselower" : FormatChangeCaseLower
1261 case "formatarea" : FormatArea
1262 case "formatarrangebringtofrontcalc" : FormatArrangeBringToFrontCalc
1263 case "formatflipvertically" : FormatFlipVertically
1264 case "formatfliphorizontally" : FormatFlipHorizontally
1265 case "formatline" : FormatLine
1266 case "formatpositionandsize" : FormatPositionAndSize
1267 case "formatfontwork" : FormatFontwork
1268 case "formatparagraph" : FormatParagraph
1269 case "formatstylebold" : FormatStyleBold
1270 case "formatungroupdraw" : FormatUngroupDraw
1271 case "formatexitgroupdraw" : FormatExitGroupDraw
1272 case "formatgroupgroup" : FormatGroupGroup
1273 case "formatgroupeditgroupcalc" : FormatGroupEditGroupCalc
1274 case "formatalignmentlefttext" : FormatAlignmentLeftText
1275 case "formatgraphics" : FormatGraphics
1276 case "formatanchortopage" : FormatAnchorToPage
1277 case "formatwrapcontour" : FormatWrapContour
1278 case "formatwrapeditcontour" : FormatWrapEditContour
1279 case "formatpagewriter" : FormatPageWriter
1281 case "insertindexesbibliographyentry" : InsertIndexesBibliographyEntry
1283 case "contextpositionandsize" : ContextPositionAndSize
1285 case "toolslanguagehyphenate" : ToolsLanguageHyphenate
1286 case "toolsupdateallindexes" : ToolsUpdateAllIndexes
1287 case "toolsupdatefields" : ToolsUpdateFields
1288 case "toolsupdatelinks" : ToolsUpdateLinks
1289 case "toolslanguagehangulhanjaconversion" : ToolsLanguageHangulHanjaConversion
1291 case else : warnlog( "Unknown slot called: " & cSlot )
1297 iTime = iWait * DELAY
1302 if ( iTime = MAX_WAIT * DELAY ) then
1305 if ( VERBOSE ) then printlog( CFN & "Exit with rc=" & iTime )
1306 hUseAsyncSlot() = iTime
1311 '*******************************************************************************
1313 function hClickButton( oButton as object ) as integer
1315 dim iWait as integer
1316 dim iTime as integer : iTime = 0
1318 const CFN = "global::tools::includes::required::hClickButton():"
1320 if ( VERBOSE ) then printlog( CFN & "Click button: " & oButton.name() )
1322 for iWait = 1 to MAX_WAIT
1324 if ( oButton.exists() ) then
1325 if ( VERBOSE ) then printlog( CFN & "Button exists" )
1326 if ( oButton.isEnabled() ) then
1327 if ( VERBOSE ) then printlog( "Button is enabled" )
1337 if ( iTime = 5000 ) then
1340 if ( VERBOSE ) then printlog( CFN & "Exit with rc=" & iTime )
1341 hClickButton() = iTime