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 tBasicVBACompatSecurityCheck()
36 printlog( "Test VBA Security feature" )
37 printlog( "VBA macros may not ignore global macro security setting" )
39 ' This test case is based on the use cases provided in issue #i109699
41 const IMPORT_EXCEL_MACROS = TRUE
42 const EXEC_EXCEL_MACROS = TRUE
44 const MACRO_IDENTIFICATION_MESSAGE = "Clicked"
45 const MACRO_NAME = "CommandButton1_Click"
47 const WORK_FILE = "framework/optional/input/vba-compat/Book1.xls"
49 dim cTestFile as string : cTestFile = gTesttoolPath & WORK_FILE
50 dim iSecurityLevel as integer
53 printlog( "Set VBA macro handling to import and execute" )
54 hSetExcelBasicImportMode( IMPORT_EXCEL_MACROS, EXEC_EXCEL_MACROS )
56 for iSecurityLevel = GC_MACRO_SECURITY_LEVEL_MEDIUM to GC_MACRO_SECURITY_LEVEL_VERYHIGH
58 printlog( "Adjust security level" )
59 hSetMacroSecurityAPI( iSecurityLevel )
61 printlog( "Load the test file" )
62 hFileOpen( cTestFile )
64 printlog( "Deny macro execution or close macros blocked message" )
65 if ( iSecurityLevel = GC_MACRO_SECURITY_LEVEL_MEDIUM ) then
72 printlog( "Try to execute macro via macro organizer" )
73 hMacroOrganizerRunMacro( MACRO_NAME )
75 printlog( "Probe for warning message (or macro)" )
77 if ( Active.exists( 2 ) ) then
78 if ( Active.getText() = MACRO_IDENTIFICATION_MESSAGE ) then
79 warnlog( "Macro was executed though macro execution has been denied" )
82 printlog( "Macro execution blocked - warning is displayed." )
86 warnlog( "No warning message for blocked macro execution" )
89 ' recover silently, the warnings above should say it all.
91 if ( Makro.exists() ) then Makro.cancel()
93 printlog( "Close file" )
98 printlog( "Reset VBA import options to default" )
99 hSetExcelImportModeDefault()
101 printlog( "Reset macro security level to default" )
102 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT )