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 2000, 2010 Oracle and/or its affiliates.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' This file is part of OpenOffice.org.
11 ' OpenOffice.org is free software: you can redistribute it and/or modify
12 ' it under the terms of the GNU Lesser General Public License version 3
13 ' only, as published by the Free Software Foundation.
15 ' OpenOffice.org is distributed in the hope that it will be useful,
16 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ' GNU Lesser General Public License version 3 for more details
19 ' (a copy is included in the LICENSE file that accompanied this code).
21 ' You should have received a copy of the GNU Lesser General Public License
22 ' version 3 along with OpenOffice.org. If not, see
23 ' <http://www.openoffice.org/license.html>
24 ' for a copy of the LGPLv3 License.
26 '/******************************************************************************
28 '* owner : gregor.hartmann@oracle.com
30 '* short description : Verify names of macros and scripts
32 '\******************************************************************************
36 printlog( "Resource test for macros and scripts / related dialogs" )
38 if ( gIsoLang <> "en-US" ) then
39 printlog( "No testing for languages other than en_US" )
43 const SCRIPTING_DIALOGS = 5
45 const DLG_JAVASCRIPT = "JavaScript"
46 const DLG_BEANSHELL = "BeanShell"
47 const DLG_PYTHON = "Python"
48 const DLG_BASIC_ORG = "BasicOrganizer"
49 const DLG_RUN_MACRO = "RunMacro"
51 ' This is the build specific part of the filename including substrings for
52 ' the productname and language.
53 dim sProductString as string : sProductString = gProductName & "_" & gISOLang & "_"
55 ' define platforms that have different scriptcount
56 if ( lcase( gPlatGroup ) = "w95" ) then sProductString = sProductString & "win_"
57 if ( lcase( gPlatform ) = "osx" ) then sProductString = sProductString & "osx_"
60 sProductString = hStringReplaceChar( sProductString, " ", "-" )
62 ' This is where reference file is located, the filename is yet incomplete
63 dim sInputPath as string
64 sInputPath = gTesttoolPath & "framework/required/input/scripts/" & sProductString
66 ' This is where we store the reference file if differences are found.
67 dim sOutputPath as string
68 sOutputPath = gOfficePath & "user/work/" & sProductString
70 ' These contain the input and output paths (fully qualified)
72 dim sFileOut as string
74 ' Array that contains the scriptnames for all organizers
75 dim cScriptNamesList( 1000 ) as string
78 dim iCurrentDialog as integer
80 dim iDiffCount as integer
81 dim max_diffcount as integer
85 for iCurrentDialog = 1 to SCRIPTING_DIALOGS
87 ListAllDelete( cScriptNamesList() )
89 ' Build complete filename and identify dialog for logging and case selection
90 select case ( iCurrentDialog )
91 case 1 : sDialog = DLG_JAVASCRIPT
92 case 2 : sDialog = DLG_BEANSHELL
93 case 3 : sDialog = DLG_PYTHON
94 case 4 : sDialog = DLG_BASIC_ORG
95 case 5 : sDialog = DLG_RUN_MACRO
99 sFileIn = convertpath( sInputPath & sDialog & ".txt" )
100 sFileOut = convertpath( sOutputPath & sDialog & ".txt" )
102 printlog( "Open <" & sDialog & "> and access the treelist object" )
104 ' Note: hGetAllNodeNames() is a *global* function defined in t_treelist_tools.inc
105 ' DLG_BASIC_ORG and DLG_RUN_MACRO have - in addition to the treelist -
106 ' a separate script list. To get those scripts a little more effort is
107 ' required which is done in the *local* function hGetScriptNames()
109 select case ( sDialog )
110 case DLG_JAVASCRIPT: ToolsMacrosOrganizeMacrosJavaScript
111 kontext "ScriptOrganizer"
112 hGetAllNodeNames( ScriptTreeList, cScriptNamesList() )
114 case DLG_BEANSHELL: ToolsMacrosOrganizeMacrosBeanShell
115 kontext "ScriptOrganizer"
116 hGetAllNodeNames( ScriptTreeList, cScriptNamesList() )
118 case DLG_PYTHON: ToolsMacrosOrganizeMacrosPython
119 kontext "ScriptOrganizer"
120 hGetAllNodeNames( ScriptTreeList, cScriptNamesList() )
122 case DLG_BASIC_ORG: ToolsMacro_uno
124 hGetScriptNames( MakroAus, MakroListe, cScriptNamesList() )
126 case DLG_RUN_MACRO: ToolsMacrosRunMacro
127 kontext "ScriptSelector"
128 hGetScriptNames( LibraryTreeList, ScriptList, cScriptNamesList() )
132 printlog( "Compare to reference list, create new one if differences were found" )
133 iDiffCount = abs( hManageComparisionList( sFileIn, sFileOut, cScriptNamesList() ) )
135 ' Usually we should have 0 differences in the list. However, as we do not have
136 ' a unique way of installing the office (Root-Installation, archives and
137 ' others) we need a little tolerance here. If a number of bundled extensions
138 ' are installed, we have more scripts.
139 if ( iDiffCount > max_diffcount ) then warnlog( "The number of scripts has changed, please review." )
141 printlog( "Close <" & sDialog & ">" )
142 select case ( sDialog )
143 case DLG_JAVASCRIPT :
144 ScriptOrganizer.cancel()
146 ScriptOrganizer.cancel()
148 ScriptOrganizer.cancel()
152 ScriptSelector.cancel()
161 '*******************************************************************************
163 sub hGetScriptNames( oTreeList as object, oScriptList as object, cItemList() as string )
165 ' oTreeList is the treelist object (left pane)
166 ' oScriptList is the script list (right pane)
167 ' cScriptList() is filled with the scriptnames of the form
168 ' <module>:<script name> like "CommonLang:LoadLanguages"
170 dim iCurrentTreeListItem as integer
171 dim iObjectsInTreelist as integer
173 dim cModuleName as string
174 dim cReferenceString as string
176 dim iScriptCount as integer
177 dim iCurrentScript as integer
178 dim cScriptList( 1000 ) as string
180 ' Get the number of nodes from the modules treelist
181 iObjectsInTreeList = hExpandAllNodes( oTreeList )
183 ' For each item in the modules treelist get the number of scripts (right pane)
184 for iCurrentTreeListItem = 1 to iObjectsInTreeList
186 ' Get the name of the current treelist node, append it to the list
187 ' (otherwise it does not appear if it has no scripts)
188 cModuleName = hGetNodeName( oTreeList, iCurrentTreeListItem )
189 hListAppend( cModuleName, cItemList() )
191 ' Get the number of scripts from the right pane, reset the array in advance
192 ListAllDelete( cScriptList() )
193 iScriptCount = hGetListItems( oScriptList, cScriptList() )
195 ' Build the string for the reference list and append it to cScriptList()
196 for iCurrentScript = 1 to iScriptCount
197 cReferenceString = cModuleName & ":" & cScriptList( iCurrentScript )
198 hListAppend( cReferenceString, cItemList() )
201 next iCurrentTreeListItem