diff options
Diffstat (limited to 'qadevOOo/tests/basic/ifc/frame/XDocumentTemplates/frame_XDocumentTemplates.xba')
-rw-r--r-- | qadevOOo/tests/basic/ifc/frame/XDocumentTemplates/frame_XDocumentTemplates.xba | 191 |
1 files changed, 191 insertions, 0 deletions
diff --git a/qadevOOo/tests/basic/ifc/frame/XDocumentTemplates/frame_XDocumentTemplates.xba b/qadevOOo/tests/basic/ifc/frame/XDocumentTemplates/frame_XDocumentTemplates.xba new file mode 100644 index 000000000000..639af5868d02 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/frame/XDocumentTemplates/frame_XDocumentTemplates.xba @@ -0,0 +1,191 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="frame_XDocumentTemplates" script:language="StarBasic"> + + +'************************************************************************* +' +' 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. +' +'************************************************************************* +'************************************************************************* + + + +' Be sure that all variables are dimensioned: +option explicit + +'************************************************************************* +' This Interface/Service test depends on the following GLOBAL variables, +' which must be specified in the object creation: + +' - Global oStore As Object + +'************************************************************************* + + + + + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.frame.XDocumentTemplates +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + Dim content As Object, groupContent As Object + Dim result as Object, statRes As Object + Dim res As Boolean + + Test.StartMethod("getContent()") + bOK = true + content = oObj.getContent() + Out.Log("Content list :") + Out.Log(getContentList(content)) + + bOK = bOK AND NOT isNull(content) + Test.MethodTested("getContent()", bOK) + + Test.StartMethod("addGroup()") + bOK = true + res = oObj.addGroup("XDocumentTemplatesTemp") + Out.Log("Method returned: " + res) + bOK = bOK AND res AND NOT isNull(getSubContent(content, "XDocumentTemplatesTemp")) + Test.MethodTested("addGroup()", bOK) + + Test.StartMethod("renameGroup()") + bOK = true + res = oObj.renameGroup("XDocumentTemplatesTemp", "XDocumentTemplates") + Out.Log("Method returned: " + res) + groupContent = getSubContent(content, "XDocumentTemplates") + bOK = bOK AND res AND isNull(getSubContent(content, "XDocumentTemplatesTemp")) _ + AND NOT isNull(groupContent) + Test.MethodTested("renameGroup()", bOK) + + Test.StartMethod("addTemplate()") + Dim testDoc As String + testDoc = utils.Path2URL(cTestDocsDir) + "report.stw" + Out.Log("Adding template from " + testDoc + + bOK = true + res = oObj.addTemplate("XDocumentTemplates", "ANewTemplateTemp", testDoc) + Out.Log("Method returned: " + res) + bOK = bOK AND res AND NOT isNull(getSubContent(groupContent, "ANewTemplateTemp")) + Test.MethodTested("addTemplate()", bOK) + + Test.StartMethod("renameTemplate()") + bOK = true + res = oObj.renameTemplate("XDocumentTemplates", "ANewTemplateTemp", "ANewTemplate") + Out.Log("Method returned: " + res) + bOK = bOK AND res AND isNull(getSubContent(groupContent, "ANewTemplateTemp")) _ + AND NOT isNull(getSubContent(groupContent, "ANewTemplate")) + Test.MethodTested("renameTemplate()", bOK) + + Test.StartMethod("storeTemplate()") + bOK = true + res = oObj.storeTemplate("XDocumentTemplates", "NewStoreTemplate", oStore) + Out.Log("Method returned: " + res) + bOK = bOK AND res AND NOT isNull(getSubContent(groupContent, "NewStoreTemplate")) + Test.MethodTested("storeTemplate()", bOK) + + Test.StartMethod("removeTemplate()") + bOK = true + res = oObj.removeTemplate("XDocumentTemplates", "ANewTemplate") + Out.Log("Method returned: " + res) + bOK = bOK AND res AND isNull(getSubContent(groupContent, "ANewTemplate") + Test.MethodTested("removeTemplate()", bOK) + + Test.StartMethod("removeGroup()") + bOK = true + res = oObj.removeGroup("XDocumentTemplates") + Out.Log("Method returned: " + res) + bOK = bOK AND res AND isNull(getSubContent(content, "XDocumentTemplatesTemp") + Test.MethodTested("removeGroup()", bOK) + + Test.StartMethod("update()") + bOK = true + oObj.update() + Test.MethodTested("update()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub + +Function getDynaResultSet(content As Object) As Object + Dim command as new com.sun.star.ucb.Command + Dim comArg as new com.sun.star.ucb.OpenCommandArgument2 + Dim comProps(0) as new com.sun.star.beans.Property + Dim result as Object, statRes As Object + + comArg.Mode = com.sun.star.ucb.OpenMode.ALL + comProps(0).Name = "Title" + comArg.Properties = comProps() + + command.Name = "open" + command.Handle = -1 + command.Argument = comArg + + getDynaResultSet = content.execute(command, 0, NULL_OBJECT) +End Function + +Function getStatResultSet(content As Object) As Object + getStatResultSet = getDynaResultSet(content).getStaticResultSet() +End Function + +Function getContentList(content As Object) As String + Dim statRes As Object + Dim ret As String + + statRes = getStatResultSet(content) + statRes.first() + ret = "" + while NOT statRes.isAfterLast() + ret = ret + " " + statRes.getString(1) + chr(13) + statRes.next() + wend + getContentList = ret +End Function + +Function getSubContent(content As Object, subName As String) As Object + Dim statRes As Object + Dim ret As Object + + statRes = getStatResultSet(content) + statRes.first() + while NOT statRes.isAfterLast() + if subName = statRes.getString(1) then + ret = statRes.queryContent() + endif + statRes.next() + wend + + getSubContent = ret +End Function +</script:module> |