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 : Test VBA compatibility switches
32 '\******************************************************************************
34 testcase tBasicVBACompatImportEnabled()
36 printlog( "Test VBA compatibility switch / executable Microsoft(R) Excel(R) Macros" )
37 printlog( "Test case 3: Import macros and set them executable" )
40 ' This test case is based on the use cases provided in issue #i88690
41 ' Spec: http://specs.openoffice.org/appwide/options_settings/Option_Dialog.odt
43 ' Depending on the mode of macro import we have differtent basic libraries listed
46 const DOCUMENT_POSITION_OFFSET = -7
48 const IMPORT_EXCEL_MACROS = TRUE
49 const EXEC_EXCEL_MACROS = TRUE
51 const DOCUMENT_NAME = "vba-test.xls"
54 const MATCH_PARTLY = 2
56 dim cTestFile as string
57 cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/" & DOCUMENT_NAME
59 dim cNodeCount as integer
61 dim caNodeData( 7 ) as string
62 caNodeData( 0 ) = DOCUMENT_NAME ' The document, not used
63 caNodeData( 1 ) = "Standard" ' The default library, not used
64 caNodeData( 2 ) = "DieseArbeitsmappe"
65 caNodeData( 3 ) = "Modul1"
66 caNodeData( 4 ) = "Modul2"
67 caNodeData( 5 ) = "Tabelle1"
68 caNodeData( 6 ) = "Tabelle2"
69 caNodeData( 7 ) = "Tabelle3"
71 ' These are the scripts belonging to each node above. If multiple scripts exist
72 ' they are separated by spaces. Example: "Modul1" has "ConcatFct" and "Ende" scripts.
73 dim caScripts( 7 ) as string
74 caScripts( 3 ) = "ConcatFct Ende"
75 caScripts( 4 ) = "WriteIt"
77 dim iCurrentModule as integer
78 dim iCurrentScript as integer
79 dim cCurrentModule as string
80 dim cTempString as string
83 printlog( "Set macro security to low" )
84 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW )
86 printlog( "Open Tools/Options and set the VBA macro execution mode" )
88 hSetExcelBasicImportMode( IMPORT_EXCEL_MACROS, EXEC_EXCEL_MACROS )
90 printlog( "Load the test file" )
91 hFileOpen( cTestFile )
93 printlog( "Open the Basic organizer" )
96 printlog( "Expand all nodes" )
98 cNodeCount = hExpandAllNodes( MakroAus )
100 printlog( "Verify that we have the correct node count for the current mode." )
102 if ( cNodeCount <> NODE_COUNT_OOO ) then warnlog( "The number of nodes is incorrect: " & cNodeCount )
104 if ( cNodeCount <> NODE_COUNT ) then warnlog( "The number of nodes is incorrect: " & cNodeCount )
107 printlog( "Verify position of the document node." )
108 MakroAus.select( cNodeCount + DOCUMENT_POSITION_OFFSET )
109 select case( hCompareSubStrings( MakroAus.getSelText(), DOCUMENT_NAME ) )
110 case MATCH_NONE : warnlog ( "The document is not listed at the expected position" )
111 case MATCH_EXACT : printlog( "The document is at the expected position and writable" )
112 case MATCH_PARTLY : printlog( "The document is at the expected position and write protected" )
115 for iCurrentModule = 2 to 7
117 printlog( "Look for: " & caNodeData( iCurrentModule ) )
121 MakroAus.select( cNodeCount + DOCUMENT_POSITION_OFFSET + iCurrentModule )
122 cCurrentModule = MakroAus.getSelText()
124 if ( cCurrentModule = caNodeData( iCurrentModule ) ) then
126 for iCurrentScript = 1 to MakroListe.getItemCount()
127 MakroListe.select( iCurrentScript )
128 if ( instr( caScripts( iCurrentModule ), MakroListe.getSelText() ) = 0 ) then
129 warnlog( "Script for the current module not found" )
132 printlog( "Script found at pos" & iCurrentScript )
137 if ( not bFound ) then
138 warnlog( "The node was not found: " & cCurrentModule )
143 printlog( "Close Macro Organizer" )
149 hSetExcelImportModeDefault()
150 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT )