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 : Macros with all security-levels
32 '\******************************************************************************
34 sub tMacroSecurityLevelsControlModule
36 dim iApplication as integer
38 for iApplication = 1 to 6
41 printlog( hNumericDocType( iApplication ) )
42 call tMacroSecurityLevels( "current" )
43 call tMacroSecurityLevels( "645" )
49 '*******************************************************************************
51 testcase tMacroSecurityLevels( cFileFormat )
53 printlog( "Check macro execution behavior for all macro security levels" )
55 dim cWorkFile as string
56 cWorkFile = gTesttoolPath & "framework\optional\input\BasicDocs\"
57 cWorkFile = cWorkFile & "basic" & hGetSuffix( cFileFormat )
59 dim iSecLevel as integer
61 const EXPECTED_MESSAGECOUNT = 0
62 const ALLOW_ONE_EXTRA_MESSAGEBOX = 1
63 const ALLOW_NO_EXTRA_MESSAGEBOXES = 0
65 ' We have quite a bunch of possible combinations here. Some trigger a security warning
66 ' others do not. Depending on the security level we either get no warning at all, the
67 ' "classic" Security Warning or a message that the macros will not be executed (Blocked)
69 ' |---------------------------------------------------------|
70 ' | Trusted | Security Level / Warning displayed |
71 ' | Path | Low | Medium | High | Very High |
72 ' |---------------------------------------------------------|
73 ' | Yes*) | No | No | No | No |
74 ' |---------------------------------------------------------|
75 ' | No | No | Yes | Blocked | Blocked |
76 ' |---------------------------------------------------------|
77 ' *) Covered by test "f_sec_trusted_path.bas"
79 printlog( "Load a document with macro for each of the four security levels" )
80 for iSecLevel = GC_MACRO_SECURITY_LEVEL_LOW to GC_MACRO_SECURITY_LEVEL_VERYHIGH
82 printlog( "Set macro security level to " & iSecLevel )
83 hSetMacroSecurityAPI( iSecLevel )
85 printlog( "Load document..." )
86 hFileOpen( cWorkFile )
88 printlog( "Check security level dependent behavior" )
90 case GC_MACRO_SECURITY_LEVEL_LOW :
92 if ( not hIdentifyExecutedMacro() ) then
93 if ( gApplication = "MATH" ) then
94 qaerrorlog( "#i110184# - Macro was not executed" )
96 warnlog( "Macro was not excuted" )
100 case GC_MACRO_SECURITY_LEVEL_MEDIUM :
102 if ( not hAllowMacroExecution() ) then
103 warnlog( "#i110184# - Macro execution warning missing, check the file/security settings" )
106 if ( not hIdentifyExecutedMacro() ) then
107 if ( gApplication = "MATH" ) then
108 qaerrorlog( "#i110184# - Macro was not executed" )
110 warnlog( "Macro was not excuted" )
114 case GC_MACRO_SECURITY_LEVEL_HIGH :
117 hCloseDialog( Active, "ok" )
119 if ( not hHandleActivesOnLoad( EXPECTED_MESSAGECOUNT , ALLOW_NO_EXTRA_MESSAGEBOXES ) ) then
120 warnlog( "#i53710# unexpected second messagebox" )
123 if ( hIdentifyExecutedMacro() ) then
124 warnlog( "Macro was executed" )
127 case GC_MACRO_SECURITY_LEVEL_VERYHIGH :
130 hCloseDialog( Active, "ok" )
132 if ( not hHandleActivesOnLoad( EXPECTED_MESSAGECOUNT , ALLOW_NO_EXTRA_MESSAGEBOXES ) ) then
133 warnlog( "#i53710# unexpected second messagebox" )
136 if ( hIdentifyExecutedMacro() ) then
137 warnlog( "Macro was executed" )
142 printlog( "Close document" )
147 printlog( "Reset security level to default" )
148 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT )
152 '*******************************************************************************
154 function hIdentifyExecutedMacro() as boolean
157 dim cMessage as string
158 const CFN = "hIdentifyExecutedMacro::"
163 if ( active.exists( 3 ) ) then
165 cMessage = active.getText()
167 if ( cMessage = "TTMacro3" ) then
168 printlog( CFN & "The Macro has been executed" )
169 hIdentifyExecutedMacro() = true
172 warnlog( CFN & "The WRONG macro/dialog is open" )
173 hIdentifyExecutedMacro() = false
174 hHandleActivesOnLoad( 0 , 2 )
179 printlog( CFN & "No macro/dialog is open" )
180 hIdentifyExecutedMacro() = false