From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../java/mod/_xmloff/Chart/XMLContentExporter.java | 182 ++++++++++++++++++++ .../java/mod/_xmloff/Chart/XMLContentImporter.java | 188 +++++++++++++++++++++ .../tests/java/mod/_xmloff/Chart/XMLExporter.java | 184 ++++++++++++++++++++ .../tests/java/mod/_xmloff/Chart/XMLImporter.java | 186 ++++++++++++++++++++ .../java/mod/_xmloff/Chart/XMLStylesExporter.java | 171 +++++++++++++++++++ .../java/mod/_xmloff/Chart/XMLStylesImporter.java | 161 ++++++++++++++++++ 6 files changed, 1072 insertions(+) create mode 100644 qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentExporter.java create mode 100644 qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentImporter.java create mode 100644 qadevOOo/tests/java/mod/_xmloff/Chart/XMLExporter.java create mode 100644 qadevOOo/tests/java/mod/_xmloff/Chart/XMLImporter.java create mode 100644 qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesExporter.java create mode 100644 qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesImporter.java (limited to 'qadevOOo/tests/java/mod/_xmloff/Chart') diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentExporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentExporter.java new file mode 100644 index 000000000..9edbe3aa3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentExporter.java @@ -0,0 +1,182 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._xmloff.Chart; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart.XChartDocument; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * com.sun.star.comp.Chart.XMLContentExporter.

+ * Object implements the following interfaces : + *

+ * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLContentExporter extends TestCase { + XChartDocument xChartDoc = null; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * com.sun.star.comp.Chart.XMLContentExporter with + * argument which is an implementation of XDocumentHandler + * and which can check if required tags and character data is + * exported.

+ * The chart document is set as a source document for exporter + * created. A new 'main title' is set for chart. This made + * for checking if this title is successfully exported within + * the document content. + * Object relations created : + *

+ */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + final String exportStr = "XMLContentExporter" ; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Chart.XMLContentExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xChartDoc); + + Object oTitle = xChartDoc.getTitle() ; + XPropertySet xTitleProp = UnoRuntime.queryInterface + (XPropertySet.class, oTitle) ; + xTitleProp.setPropertyValue("String", exportStr) ; + + filter.addTag(new XMLTools.Tag("office:document-content")) ; + filter.addTagEnclosed(new XMLTools.Tag("office:body"), + new XMLTools.Tag("office:document-content")); + filter.addCharactersEnclosed(exportStr, + new XMLTools.Tag("chart:title")) ; + + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"schart: StarOffice XML (Chart)"})); + tEnv.addObjRelation("SourceDocument",xChartDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to XFilter interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + /** + * _XFilter.FilterChecker interface method + * which returns the result of XML checking. + * @return true if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * false if some errors occurred. + */ + public boolean checkFilter() { + return check() ; + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentImporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentImporter.java new file mode 100644 index 000000000..1481e0134 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentImporter.java @@ -0,0 +1,188 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._xmloff.Chart; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart.XChartDocument; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * com.sun.star.comp.Chart.XMLContentImporter.

+ * Object implements the following interfaces : + *

+ * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLContentImporter extends TestCase { + XComponent comp ; + XChartDocument xChartDoc = null; + + /** + * New chart document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + comp = xChartDoc; + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + comp = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * com.sun.star.comp.Chart.XMLContentImporter

+ * + * The chart document is set as a target document for importer. + * Imported XML-data contains the tag which specifies the title + * of a chart. + * After import title name getting from target document is checked. + * Object relations created : + *

+ */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impValue = "XMLContentImporter_test" ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + final XPropertySet xTitleProp ; + oInt = xMSF.createInstance + ("com.sun.star.comp.Chart.XMLContentImporter") ; + + + Object oTitle = xChartDoc.getTitle() ; + xTitleProp = UnoRuntime.queryInterface + (XPropertySet.class, oTitle) ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", comp) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-content", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text", + "xmlns:chart", "CDATA", "http://openoffice.org/2000/chart", + "xmlns:table", "CDATA", "http://openoffice.org/2000/table", + "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg", + "office:class", "CDATA", "chart" + ,"office:version", "CDATA", "1.0" + }, + {"start", "office:body"}, + {"start", "chart:chart"}, + {"start", "chart:title"}, + {"start", "text:p"}, + {"chars", impValue}, + {"end", "text:p"}, + {"end", "chart:title"}, + {"end", "chart:chart"}, + {"end", "office:body"}, + {"end", "office:document-content"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + String title = (String) + xTitleProp.getPropertyValue("String") ; + logF.println("Title returned = '" + title + "'") ; + return impValue.equals(title) ; + } catch (com.sun.star.uno.Exception e) { + logF.println + ("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLExporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLExporter.java new file mode 100644 index 000000000..6a4eda292 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLExporter.java @@ -0,0 +1,184 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._xmloff.Chart; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart.XChartDocument; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * com.sun.star.comp.Chart.XMLExporter.

+ * Object implements the following interfaces : + *

+ * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLExporter extends TestCase { + XChartDocument xChartDoc = null; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * com.sun.star.comp.Chart.XMLExporter with + * argument which is an implementation of XDocumentHandler + * and which can check if required tags and character data is + * exported.

+ * The chart document is set as a source document for exporter + * created. A new 'main title' is set for chart. This made + * for checking if this title is successfully exported within + * the document content. + * Object relations created : + *

+ */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + final String exportStr = "XMLExporter test." ; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Chart.XMLExporter", new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xChartDoc); + + Object oTitle = xChartDoc.getTitle() ; + XPropertySet xTitleProp = UnoRuntime.queryInterface + (XPropertySet.class, oTitle) ; + xTitleProp.setPropertyValue("String", exportStr) ; + + filter.addTag(new XMLTools.Tag("office:document")) ; + filter.addTagEnclosed(new XMLTools.Tag("office:meta"), + new XMLTools.Tag("office:document")); + filter.addTagEnclosed(new XMLTools.Tag("office:body"), + new XMLTools.Tag("office:document")); + filter.addCharactersEnclosed(exportStr, + new XMLTools.Tag("chart:title")) ; + + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"schart: StarOffice XML (Chart)"})); + tEnv.addObjRelation("SourceDocument",xChartDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to XFilter interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + /** + * _XFilter.FilterChecker interface method + * which returns the result of XML checking. + * @return true if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * false if some errors occurred. + */ + public boolean checkFilter() { + return check() ; + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLImporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLImporter.java new file mode 100644 index 000000000..eb60684b8 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLImporter.java @@ -0,0 +1,186 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._xmloff.Chart; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart.XChartDocument; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * com.sun.star.comp.Chart.XMLImporter.

+ * Object implements the following interfaces : + *

+ * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLImporter extends TestCase { + XComponent comp ; + XChartDocument xChartDoc = null; + + /** + * New chart document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + comp = xChartDoc; + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + comp = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * com.sun.star.comp.Chart.XMLImporter

+ * + * The chart document is set as a target document for importer. + * Imported XML-data contains the tag which specifies the title + * of a chart. + * After import title name getting from target document is checked. + * Object relations created : + *

+ */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impValue = "XMLImporter_test" ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + final XPropertySet xTitleProp ; + oInt = xMSF.createInstance("com.sun.star.comp.Chart.XMLImporter") ; + + Object oTitle = xChartDoc.getTitle() ; + xTitleProp = UnoRuntime.queryInterface + (XPropertySet.class, oTitle) ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", comp) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text", + "xmlns:chart", "CDATA", "http://openoffice.org/2000/chart", + "xmlns:table", "CDATA", "http://openoffice.org/2000/table", + "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg", + "office:class", "CDATA", "chart" + ,"office:version", "CDATA", "1.0" + }, + {"start", "office:body"}, + {"start", "chart:chart"}, + {"start", "chart:title"}, + {"start", "text:p"}, + {"chars", impValue}, + {"end", "text:p"}, + {"end", "chart:title"}, + {"end", "chart:chart"}, + {"end", "office:body"}, + {"end", "office:document-content"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + String title = (String) + xTitleProp.getPropertyValue("String") ; + logF.println("Title returned = '" + title + "'") ; + return impValue.equals(title) ; + } catch (com.sun.star.uno.Exception e) { + logF.println + ("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesExporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesExporter.java new file mode 100644 index 000000000..66f46ba52 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesExporter.java @@ -0,0 +1,171 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._xmloff.Chart; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.chart.XChartDocument; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * com.sun.star.comp.Chart.XMLStylesExporter.

+ * Object implements the following interfaces : + *

+ * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLStylesExporter extends TestCase { + XChartDocument xChartDoc = null; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * com.sun.star.comp.Chart.XMLStylesExporter with + * argument which is an implementation of XDocumentHandler + * and which can check if required tags and character data is + * exported.

+ * Existing of some tags checked in XML data exported. + * Object relations created : + *

+ */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Chart.XMLStylesExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xChartDoc); + + + filter.addTag(new XMLTools.Tag("office:document-styles")) ; + filter.addTagEnclosed(new XMLTools.Tag("office:styles"), + new XMLTools.Tag("office:document-styles")); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"schart: StarOffice XML (Chart)"})); + tEnv.addObjRelation("SourceDocument",xChartDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to XFilter interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + /** + * _XFilter.FilterChecker interface method + * which returns the result of XML checking. + * @return true if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * false if some errors occurred. + */ + public boolean checkFilter() { + return check() ; + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesImporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesImporter.java new file mode 100644 index 000000000..4944e1806 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesImporter.java @@ -0,0 +1,161 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._xmloff.Chart; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.chart.XChartDocument; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * com.sun.star.comp.Chart.XMLStylesImporter.

+ * Object implements the following interfaces : + *

+ * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLStylesImporter extends TestCase { + XComponent comp ; + XChartDocument xChartDoc = null; + + /** + * New chart document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + comp = xChartDoc; + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + comp = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * com.sun.star.comp.Chart.XMLStylesImporter

+ * + * The chart document is set as a target document for importer. + * Object relations created : + *

+ */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Chart.XMLStylesImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", comp) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-styles", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text", + "xmlns:chart", "CDATA", "http://openoffice.org/2000/chart", + "xmlns:style", "CDATA", "http://openoffice.org/2000/style", + "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg", + "office:class", "CDATA", "chart", + "office:version", "CDATA", "1.0" + }, + {"start", "office:styles"}, + {"end", "office:styles"}, + {"end", "office:document-styles"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + logF.println("No ways to check styles import were not found."); + logF.println(" TRUE returned."); + return true ; + } + }) ; + + + return tEnv; + } // finish method getTestEnvironment +} -- cgit v1.2.3