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 tBasicVBACompatImportNothing()
36 printlog( "Test VBA compatibility switch / executable Microsoft(R) Excel(R) Macros" )
37 printlog( "Test case 1: Do not import macros at all" )
39 ' This test case is based on the use cases provided in issue #i88690
40 ' Spec: http://specs.openoffice.org/appwide/options_settings/Option_Dialog.odt
41 ' Depending on the mode of macro import we have differtent basic libraries listed
42 const NODE_COUNT = 72 ' Do not import Microsoft(R) Excel(R) macros at all
43 const MACRO_LIST = 0 ' The document library should have no scripts listed
44 const DOCUMENT_POSITION_OFFSET = -1
46 const IMPORT_EXCEL_MACROS = FALSE
47 const EXEC_EXCEL_MACROS = FALSE
49 const DOCUMENT_NAME = "vba-test.xls"
52 const MATCH_PARTLY = 2
54 dim cTestFile as string
55 cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/" & DOCUMENT_NAME
57 dim cNodeCount as integer
59 printlog( "Set macro security to low" )
60 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW )
62 printlog( "Open Tools/Options" )
64 hSetExcelBasicImportMode( IMPORT_EXCEL_MACROS, EXEC_EXCEL_MACROS )
66 printlog( "Load the test file" )
67 hFileOpen( cTestFile )
69 printlog( "Open the Basic organizer" )
72 printlog( "Expand all nodes" )
74 cNodeCount = hExpandAllNodes( MakroAus )
76 printlog( "Verify that we have the correct node count for the current mode" )
78 if ( cNodeCount <> NODE_COUNT_OOO ) then warnlog( "The number of nodes is incorrect: " & cNodeCount )
80 if ( cNodeCount <> NODE_COUNT ) then warnlog( "The number of nodes is incorrect: " & cNodeCount )
83 printlog( "Verify position of the document node" )
84 MakroAus.select( cNodeCount + DOCUMENT_POSITION_OFFSET )
85 select case( hCompareSubStrings( MakroAus.getSelText(), DOCUMENT_NAME ) )
86 case MATCH_NONE : warnlog ( "The document is not listed at the expected position" )
87 case MATCH_EXACT : printlog( "The document is at the expected position and writable" )
88 case MATCH_PARTLY : printlog( "The document is at the expected position and write protected" )
91 printlog( "Select the last node, this should be the standard Library for the document" )
92 MakroAus.select( cNodeCount )
94 printlog( "Verify that the Standard library for the document has no scripts" )
95 if ( MakroListe.getItemCount <> MACRO_LIST ) then
96 warnlog( "There should be no macros listed for the current library"
99 printlog( "Close Macro Organizer" )
105 hSetExcelImportModeDefault()
106 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT )