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: basic_vba-compat_import_enabled.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:18:13 $
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 : Test VBA compatibility switches
38 '\******************************************************************************
40 testcase tBasicVBACompatImportEnabled()
42 warnlog( "#i92666# loading sample document crashes the office" )
45 printlog( "Test VBA compatibility switch / executable Microsoft(R) Excel(R) Macros" )
46 printlog( "Test case 3: Import macros and set them executable" )
49 ' This test case is based on the use cases provided in issue #i88690
50 ' Spec: http://specs.openoffice.org/appwide/options_settings/Option_Dialog.odt
52 dim cTestFile as string
53 cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/vba-test.xls"
55 dim cNodeCount as integer
57 ' note that index 0 and 1 are ommitted intentionally
58 dim caNodeData( 3 ) as string
59 caNodeData( 2 ) = "Modul1"
60 caNodeData( 3 ) = "Modul2"
62 dim caScripts( 3 ) as string
63 caScripts( 2 ) = "ConcatFct Ende"
64 caScripts( 3 ) = "WriteIt"
66 dim iCurrentModule as integer
67 dim iCurrentScript as integer
68 dim cCurrentModule as string
71 ' Depending on the mode of macro import we have differtent basic libraries listed
74 const DOCUMENT_POSITION_OFFSET = -3
76 const IMPORT_EXCEL_MACROS = TRUE
77 const EXEC_EXCEL_MACROS = TRUE
79 printlog( "Set macro security to low" )
80 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW )
82 printlog( "Open Tools/Options" )
84 hSetExcelBasicImportMode( IMPORT_EXCEL_MACROS, EXEC_EXCEL_MACROS )
86 printlog( "Load the test file" )
87 hFileOpen( cTestFile )
89 printlog( "Open the Basic organizer" )
90 hOpenBasicOrganizerFromDoc()
92 printlog( "Expand all nodes" )
93 cNodeCount = hExpandAllNodes( MakroAus )
95 printlog( "Verify that we have the correct node count for the current mode" )
96 if ( cNodeCount <> NODE_COUNT ) then
97 warnlog( "The number of nodes is incorrect: " & cNodeCount )
100 printlog( "Verify position of the document node" )
101 MakroAus.select( cNodeCount + DOCUMENT_POSITION_OFFSET )
102 if ( MakroAus.getSelText() <> "vba-test" ) then
103 qaerrorlog( "The document node is not at the expected position" )
106 for iCurrentModule = 2 to 3
108 printlog( "Look for: " & caNodeData( iCurrentModule ) )
112 MakroAus.select( cNodeCount + DOCUMENT_POSITION_OFFSET + iCurrentModule )
113 cCurrentModule = MakroAus.getSelText()
115 if ( cCurrentModule = caNodeData( iCurrentModule ) ) then
117 for iCurrentScript = 1 to MakroListe.getItemCount()
118 MakroListe.select( iCurrentScript )
119 if ( instr( caScripts( iCurrentModule ), MakroListe.getSelText() ) = 0 ) then
120 warnlog( "Script for the current module not found" )
123 printlog( "Script(s) found." )
128 if ( not bFound ) then
129 warnlog( "The node was not found: " & cCurrentModule )
134 printlog( "Close Macro Organizer" )
140 hSetExcelImportModeDefault()
141 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT )