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 tBasicVBACompatApplicationUnion()
36 printlog( "Functionality of Application.Union" )
37 ' Based on issue #i110724
39 const IMPORT_EXCEL_MACROS = TRUE
40 const EXEC_EXCEL_MACROS = TRUE
41 const DOCUMENT_NAME = "vba-application-union.xls"
42 const LIBRARY_NAME = "Standard"
43 const MODULE_NAME = "Module1"
44 const EXPECTED_MACRO_COUNT = 6
48 dim macro_identifier( EXPECTED_MACRO_COUNT )
50 ' Find out whether we can write to the program directory or not.
51 ' If we can we get different values returned from the test functions
52 ' This is required for userland installations.
53 if( hCheckForAdministratorPermissions() ) then
54 macro_identifier( 1 ) = "1: False"
55 macro_identifier( 2 ) = "2: False"
56 macro_identifier( 3 ) = "3: False"
57 macro_identifier( 4 ) = "4: True"
58 macro_identifier( 5 ) = "5: False"
59 macro_identifier( 6 ) = "6: True"
61 macro_identifier( 1 ) = "1: False"
62 macro_identifier( 2 ) = "2: False"
63 macro_identifier( 3 ) = "3: True"
64 macro_identifier( 1 ) = "4: False"
65 macro_identifier( 2 ) = "5: False"
66 macro_identifier( 6 ) = "6: True"
69 dim cTestFile as string
70 cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/" & DOCUMENT_NAME
72 dim iMacroPosition as integer
73 dim iCurrentMacro as integer
74 dim iRepeat as integer
76 printlog( "Set macro security to low" )
77 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW )
79 printlog( "Open Tools/Options" )
80 hSetExcelBasicImportMode( IMPORT_EXCEL_MACROS, EXEC_EXCEL_MACROS )
82 printlog( "Load the test file" )
83 hFileOpen( cTestFile )
88 if ( Makro.exists( MAX_WAIT ) ) then
90 iMacroPosition = hSelectNodeByName( MakroAus, DOCUMENT_NAME )
91 hExpandNode( MakroAus, iMacroPosition )
93 printlog( "Move to node <" & LIBRARY_NAME & ">" )
94 iMacroPosition = hSelectNextNode( MakroAus )
95 if ( not hVerifyNodeName( MakroAus, LIBRARY_NAME ) ) then
96 warnlog( "This is not the expected library" )
99 printlog( "Move to node <" & MODULE_NAME & ">" )
100 hSelectNextNode( MakroAus )
101 if ( not hVerifyNodeName( MakroAus, MODULE_NAME ) ) then
102 warnlog( "This is not the expected module" )
105 printlog( "Click <Ausfuehren> to execute the macro" )
106 if ( hClickButton( Ausfuehren ) <> RC_FAILURE ) then
108 printlog( "Check for the " & EXPECTED_MACRO_COUNT & " expected messageboxes" )
109 for iCurrentMacro = 1 to EXPECTED_MACRO_COUNT
113 printlog( iCurrentMacro & ": Check for messagebox: " & macro_identifier( iCurrentMacro ) )
114 if ( Active.exists( MAX_WAIT ) ) then
116 if ( Active.getText() = macro_identifier( iCurrentMacro ) ) then
117 printlog( "The expected macro was executed" )
119 warnlog( "Unexpected macro executed: " & Active.getText() )
124 warnlog( "Expected messagebox not displayed within reasonable timeframe" )
130 warnlog( "Unable to execute macro, the <Run Macro> button is disabled" )
135 warnlog( "Failed to open BASIC organizer" )
138 printlog( "Cleanup" )
140 hSetExcelImportModeDefault()
141 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT )