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 : My Macros/standard execution with user defined template
32 '\******************************************************************************
34 testcase tMacroUsertemplate
37 ' requires: Default template path, default security level (medium)
40 ' This test checks for some really weird behavior. A macro is created
41 ' for the standard lib in My Macros - this means the macro is stored with
42 ' the application, not the document.
43 ' When creating a document based on a user-created template the macro
44 ' will not execute, instead a com.sun.star... errormessage is displayed
46 dim irc as integer ' returncode
48 dim cMacroName as string ' Temp variable to store the name of current macro
50 const DOC_IDENTIFIER = "A test document for tMacroUserTemplate"
52 dim sPathOut as string ' output path for workfile
53 const FILEOUT = "tMacroUserTemplate"
54 const FILTER = "writer8_template"
56 dim iCurrentNode as integer
58 sPathOut = convertpath( gOfficePath & "user\template\" )
59 hDeleteFile( sPathOut & FILEOUT & ".ott" )
62 kontext "DocumentWriter"
63 DocumentWriter.typeKeys( DOC_IDENTIFIER )
65 printlog( "Create a new document" )
68 printlog( "Open the macro organizer" )
71 printlog( "Search for the module" )
73 iCurrentNode = hSelectNodeByName( MakroAus, "Module1" )
74 if ( iCurrentNode = 0 ) then
75 warnlog( "#i73521# - The expected node could not be found. Aborting test" )
77 hCloseDialog( Makro, "close" )
82 printlog( "Find the macro we are going to replace" )
83 if ( MakroListe.getItemCount() > 0 ) then
84 cMacroName = MakroListe.getSelText()
85 if ( lcase( cMacroName ) <> "main" ) then
86 warnlog( "Test abort: Incorrect macro is selected: " & cMacroName )
87 printlog( "This should have been the <Main> Macro" )
89 hCloseDialog( Makro, "cancel" )
94 warnlog( "There is no macro listed for the current module, the test cannot continue" )
96 hCloseDialog( Makro, "close" )
104 printlog( "Insert test macro" )
107 printlog( "Close BASIC IDE" )
110 printlog( "Close Document" )
113 printlog( "Open new document" )
116 printlog( "Open Macro Organizer" )
119 printlog( "Find the Macro again" )
120 cMacroName = hExecScript_tMacroUserTemplate() ' local function, see below
121 if ( lcase( cMacroName ) <> "main" ) then
122 warnlog( "Test abort: Incorrect macro is selected: " & cMacroName )
123 printlog( "This should have been the <Main> Macro" )
124 ScriptSelector.cancel()
129 printlog( "Run the macro" )
132 printlog( "Check for macro" )
134 if ( active.exists( 3 ) ) then
135 printlog( "Messagebox: " & active.getText() )
138 warnlog( "The Macro has not been executed" )
141 printlog( "Close the document" )
144 printlog( "Open a new document" )
148 printlog( "Save as template" )
149 hFileSaveAsWithFilterKill( sPathOut & FILEOUT, FILTER )
151 printlog( "Close the document" )
155 printlog( "File New from Template" )
158 printlog( "Find the template" )
159 irc = hFindTemplate( FILEOUT )
160 hSelectDocumentObject( irc, 1 )
163 printlog( "Open the <Run Macro> dialog" )
166 printlog( "Try to find the macro" )
167 cMacroName = hExecScript_tMacroUserTemplate() ' local function, see below
168 if ( lcase( cMacroName ) <> "main" ) then
169 warnlog( "Test abort: Incorrect macro is selected: " & cMacroName )
170 printlog( "This should have been the <Main> Macro" )
171 ScriptSelector.cancel()
179 printlog( "Verify macro execution" )
181 if ( active.exists( 3 ) ) then
183 if ( instr( active.getText() , "com.sun" ) <> 0 ) then
184 warnlog( "#i58527# - unable to run macro with user-template loaded" )
187 if ( active.getText() = "TTMacro3" ) then
188 printlog( "The macro was executed" )
190 printlog( "Unknown dialog: " & hRemoveLineBreaks( active.getText() ) )
195 warnlog( "Macro not executed / no warning" )
198 printlog( "Close all open documents" )
201 printlog( "Delete test template" )
202 hDeleteFile( sPathOut & FILEOUT & ".ott" )
207 '*******************************************************************************
209 function hExecScript_tMacroUserTemplate() as string
211 Kontext "ScriptSelector"
212 hSelectTopNode( LibraryTreeList )
213 hExpandNode( LibraryTreeList , 1 )
214 hSelectNode( LibraryTreeList , 2 )
215 hExpandNode( LibraryTreeList , 2 )
216 hSelectNode( LibraryTreeList , 3 )
218 hExecScript_tMacroUserTemplate() = ScriptList.getSelText()