2010-06-23 06:47:42 -05:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!--**********************************************************************
|
|
|
|
*
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* This file is part of OpenOffice.org.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
|
|
|
*
|
|
|
|
**********************************************************************-->
|
|
|
|
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
|
|
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Test_Ext" script:language="StarBasic">REM ***** BASIC *****
|
|
|
|
|
|
|
|
const cMessageExtensionService = "Extension Service"
|
|
|
|
const cMessageExtensionInstall = "Install Extension"
|
|
|
|
const cMessageExtensionUninstall = "Uninstall Extension"
|
|
|
|
|
|
|
|
Sub TestExtensions (FilterType as Integer)
|
|
|
|
Dim oTestExtension as Object, obj_null as Object
|
|
|
|
Dim sCurrentMessage as String
|
|
|
|
Dim nCurrentAction as Integer
|
|
|
|
Dim bResult as Boolean
|
|
|
|
Dim sImplementationNameString as String
|
|
|
|
sImplementationNameString = cUnoSmoketestTestExtension + "$_TestExtension"
|
|
|
|
|
|
|
|
On Local Error GoTo EXTERROR
|
|
|
|
|
|
|
|
nCurrentAction = cLogfileFailed
|
|
|
|
FileChannel% = OpenLogDat (GetLogFileName(FilterType))
|
|
|
|
|
|
|
|
sCurrentMessage = cMessageExtensionService
|
|
|
|
nCurrentAction = cEXTService
|
|
|
|
|
|
|
|
'Create an implementation of com.sun.star.ucb.XCommandEnvironment which is needed for
|
|
|
|
'adding the extension. The implementation is in
|
|
|
|
'javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java and the code is in juh.jar
|
|
|
|
cmdEnv = createUnoService(cUnoSmoketestCommandEnvironment)
|
|
|
|
|
2010-07-14 08:48:12 -05:00
|
|
|
'Create the component context and then get the singleton ExtensionManager
|
2010-06-23 06:47:42 -05:00
|
|
|
'A singleton cannot be created with createUnoService
|
|
|
|
ctx = getDefaultContext
|
2010-07-14 08:48:12 -05:00
|
|
|
ext_mgr = ctx.getValueByName("/singletons/" + cExtensionManager)
|
2010-06-23 06:47:42 -05:00
|
|
|
|
|
|
|
LogState (not IsNull (ext_mgr), "Extension "+ cMessageExtensionService, FileChannel)
|
|
|
|
LogState (not IsNull (ext_mgr), "Extension "+ cMessageExtensionService, MainFileChannel)
|
|
|
|
SetStatus (FilterType, cEXTService, not IsNull (ext_mgr))
|
|
|
|
if (IsNull(ext_mgr)) then
|
|
|
|
Close #FileChannel%
|
|
|
|
Exit Sub
|
|
|
|
End If
|
|
|
|
|
|
|
|
sCurrentMessage = cMessageExtensionInstall
|
|
|
|
nCurrentAction = cEXTInstall
|
|
|
|
|
|
|
|
'Add the extension. We must provide a file URL here.
|
2010-07-14 08:48:12 -05:00
|
|
|
'By passing "user" we determine that the actions we perform on
|
|
|
|
'XExtensionManager only affect the user installation. To modify the share installation one would pass "share".
|
|
|
|
|
|
|
|
Dim props() as Object
|
|
|
|
ext_mgr.addExtension(sExtensionURL + cExtensionFileName, props, "user", obj_null, cmdEnv)
|
2010-06-23 06:47:42 -05:00
|
|
|
|
|
|
|
'Check if the extension has been added by creating a service which is contained in the extension.
|
|
|
|
oTestExtension = createUnoService(cUnoSmoketestTestExtension)
|
|
|
|
bResult = (oTestExtension.getImplementationName = sImplementationNameString)
|
|
|
|
LogState (bResult, "Extension "+ cMessageExtensionInstall, FileChannel)
|
|
|
|
LogState (bResult, "Extension "+ cMessageExtensionInstall, MainFileChannel)
|
|
|
|
SetStatus (FilterType, cEXTInstall, bResult)
|
|
|
|
if (not bResult) then
|
|
|
|
Close #FileChannel%
|
|
|
|
Exit Sub
|
|
|
|
End If
|
|
|
|
|
|
|
|
sCurrentMessage = cMessageExtensionUninstall
|
|
|
|
nCurrentAction = cEXTUninstall
|
|
|
|
|
|
|
|
'Remove the package
|
2010-07-14 08:48:12 -05:00
|
|
|
ext_mgr.removeExtension("org.openoffice.legacy." + cExtensionFileName, cExtensionFileName, "user",obj_null, cmdEnv)
|
2010-06-23 06:47:42 -05:00
|
|
|
|
|
|
|
'Try to create the service which is contained in the now removed extension.
|
|
|
|
oTestExtension = createUnoService(cUnoSmoketestTestExtension)
|
|
|
|
|
|
|
|
'The service must not be available anymore. Therefor isNull must return true.
|
|
|
|
LogState (IsNull (oTestExtension), "Extension "+ cMessageExtensionUninstall, FileChannel)
|
|
|
|
LogState (IsNull (oTestExtension), "Extension "+ cMessageExtensionUninstall, MainFileChannel)
|
|
|
|
SetStatus (FilterType, cEXTUninstall, IsNull (oTestExtension))
|
|
|
|
|
|
|
|
Print #FileChannel, "---"
|
|
|
|
Close #FileChannel%
|
|
|
|
Exit Sub ' Without error
|
|
|
|
|
|
|
|
EXTERROR:
|
|
|
|
If (nCurrentAction = cLogfileFailed) then
|
|
|
|
SetStatus (FilterType, cEXTService, False)
|
|
|
|
Exit Sub
|
|
|
|
else
|
|
|
|
LogState (False, "Extension "+ sCurrentMessage, FileChannel)
|
|
|
|
LogState (False, "Extension "+ sCurrentMessage, MainFileChannel)
|
|
|
|
SetStatus (FilterType, nCurrentAction, False)
|
|
|
|
Close #FileChannel%
|
|
|
|
End If
|
|
|
|
Exit Sub ' With error
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
</script:module>
|