diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /qadevOOo/tests/java/mod/_xmloff/Impress | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
10 files changed, 1816 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentExporter.java new file mode 100644 index 000000000..b5a46cfff --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentExporter.java @@ -0,0 +1,187 @@ +/* + * 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.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XNamed; +import com.sun.star.document.XExporter; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.lang.XComponent; +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 + * <code>com.sun.star.comp.Impress.XMLOasisContentExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @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 { + XComponent xImpressDoc = 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 an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xImpressDoc " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLOasisContentExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The impress document is set as a source document for exporter + * created. The existing draw page is gotten a new name. This made + * for checking if this new name is successfully exported within + * the document content. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + final String expPageName = "XMLContentExporter" ; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLOasisContentExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + // assigning a draw page a new name + XDrawPagesSupplier xPagesSup = UnoRuntime.queryInterface + (XDrawPagesSupplier.class, xImpressDoc) ; + XDrawPages xPages = xPagesSup.getDrawPages() ; + XNamed xPageName = UnoRuntime.queryInterface + (XNamed.class, xPages.getByIndex(0)) ; + xPageName.setName(expPageName) ; + + // adding tags required to be in XML data exported. + filter.addTag(new XMLTools.Tag("office:document-content")) ; + filter.addTagEnclosed(new XMLTools.Tag("office:body"), + new XMLTools.Tag("office:document-content")) ; + filter.addTagEnclosed( + new XMLTools.Tag("draw:page", "draw:name", expPageName), + new XMLTools.Tag("office:body")) ; + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"simpress: StarOffice XML (Impress)"})); + tEnv.addObjRelation("SourceDocument",xImpressDoc); + 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 <code>XFilter</code> 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) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check() ; + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentImporter.java new file mode 100644 index 000000000..23ed91b47 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentImporter.java @@ -0,0 +1,201 @@ +/* + * 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.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNamed; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +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 + * <code>com.sun.star.comp.Impress.XMLContentImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @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 xImpressDoc = 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 an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Disposes document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLContentImporter</code><p> + * + * The chart document is set as a target document for importer. + * Imported XML-data contains the tag with a new page which has + * some name. + * After import page name getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam,PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impPageName = "XMLImporterPage" ; + + // 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.Impress.XMLContentImporter") ; + + 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", xImpressDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:presentation", "CDATA", "http://openoffice.org/2000/presentation", + "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg", + "xmlns:draw", "CDATA", "http://openoffice.org/2000/drawing", + "office:class", "CDATA", "presentation" + ,"office:version", "CDATA", "1.0" + }, + {"start", "office:body"}, + {"start", "draw:page", + "draw:name", "CDATA", impPageName, + "draw:master-page-name", "CDATA", "Default" + }, + {"start", "presentation:notes"}, + {"start", "draw:page-thumbnail", + "draw:style-name", "CDATA", "gr1", + "draw:layer", "CDATA", "layout", + "svg:width", "CDATA", "12.768cm", + "svg:height", "CDATA", "9.576cm", + "svg:x", "CDATA", "4.411cm", + "svg:y", "CDATA", "2.794cm", + "presentation:class", "CDATA", "page", + "draw:page-number", "CDATA", "1" + }, + {"end", "draw:page-thumbnail"}, + {"start", "draw:text-box", + "presentation:style-name", "CDATA", "Default-notes", + "draw:layer", "CDATA", "layout", + "svg:width", "CDATA", "15.021cm", + "svg:height", "CDATA", "10.63cm", + "svg:x", "CDATA", "3.292cm", + "svg:y", "CDATA", "13.299cm", + "presentation:class", "CDATA", "notes", + "presentation:placeholder", "CDATA", "true" + }, + {"end", "draw:text-box"}, + {"end", "presentation:notes"}, + {"end", "draw:page"}, + {"end", "office:body"}, + {"end", "office:document"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + XDrawPagesSupplier xPagesSup = UnoRuntime.queryInterface + (XDrawPagesSupplier.class, xImpressDoc) ; + XDrawPages xPages = xPagesSup.getDrawPages() ; + XNamed xPageName = UnoRuntime.queryInterface + (XNamed.class, xPages.getByIndex(0)) ; + String gName = xPageName.getName() ; + logF.println("Page name returned = '" + gName + "'") ; + return impPageName.equals(gName) ; + } 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/Impress/XMLExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLExporter.java new file mode 100644 index 000000000..03080f9d3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLExporter.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.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XNamed; +import com.sun.star.document.XExporter; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.lang.XComponent; +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 + * <code>com.sun.star.comp.Impress.XMLExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @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 { + XComponent xImpressDoc = null; + + /** + * New impress 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 an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xImpressDoc " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The impress document is set as a source document for exporter + * created. A new draw page with specific name created. This made + * for checking if this draw page is successfully exported within + * the document. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected 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); + + final String NAME = "XMLExporter"; + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLExporter", new Object[] {arg}); + + //get draw pages + XDrawPagesSupplier drawPagesSupplier = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xImpressDoc); + XDrawPages drawPages = drawPagesSupplier.getDrawPages(); + //insert new draw page + XDrawPage newDrawPage = drawPages.insertNewByIndex(0); + //set specific test name + XNamed newPageNamed = UnoRuntime.queryInterface(XNamed.class, newDrawPage); + newPageNamed.setName(NAME); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + // adding tags which must be contained in XML output + Filter.addTag( new XMLTools.Tag("office:document") ); + Filter.addTagEnclosed( + new XMLTools.Tag("office:body"), + new XMLTools.Tag("office:document") ); + Filter.addTagEnclosed( + new XMLTools.Tag("draw:page", "draw:name", NAME), + new XMLTools.Tag("office:body") ); + + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"simpress: StarOffice XML (Impress)"})); + tEnv.addObjRelation("SourceDocument",xImpressDoc); + tEnv.addObjRelation("XFilter.Checker", Filter) ; + + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> 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) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLImporter.java new file mode 100644 index 000000000..1331d9130 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLImporter.java @@ -0,0 +1,160 @@ +/* + * 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.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +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 + * <code>com.sun.star.comp.Impress.XMLImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @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 xImpressDoc = null; + + /** + * New impress 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 an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Impress document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLImporter</code><p> + * + * The impress document is set as a target document for importer. + * Imported tags contain page with the specific name. + * After import existence of the page with this specific + * name is checked in the target document. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @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.Impress.XMLImporter") ; + + 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", xImpressDoc) ; + + final String impName = "XMLImporter"; + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:draw", "CDATA", "http://openoffice.org/2000/drawing" + }, + {"start", "office:body"}, + {"start", "draw:page", + "draw:name", "CDATA", impName }, + {"end", "draw:page"}, + {"end", "office:body"}, + {"end", "office:document"} }; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml); + + //get draw pages + XDrawPagesSupplier drawPagesSupplier = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xImpressDoc); + XDrawPages drawPages = drawPagesSupplier.getDrawPages(); + final XNameAccess xNamePages = UnoRuntime.queryInterface(XNameAccess.class, drawPages); + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + return xNamePages.hasByName(impName); + } + } ); + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java new file mode 100644 index 000000000..360a3ac3a --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.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.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +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 + * <code>com.sun.star.comp.Impress.XMLOasisMetaExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @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 XMLMetaExporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New impress 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 an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Impress document disposed + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( "disposing xImpressDoc " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLOasisMetaExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The impress document is set as a source document for exporter + * created. A meta property 'Title' is set to specific value. This made + * for checking if this value is successfully exported within + * the document meta information. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @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); + final String NAME = "XMLMetaExporter"; + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLOasisMetaExporter", + new Object[]{arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + // change title name + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xImpressDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + xDocProps.setTitle(NAME); + + // Checking tags existence and changed property value + filter.addTag(new XMLTools.Tag ("office:document-meta")); + filter.addTagEnclosed( + new XMLTools.Tag("office:meta"), + new XMLTools.Tag("office:document-meta") ); + filter.addTagEnclosed( + new XMLTools.Tag("dc:title"), + new XMLTools.Tag("office:meta") ); + filter.addCharactersEnclosed( + NAME, + new XMLTools.Tag ("dc: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[] {"simpress: StarOffice XML (Impress)"})); + tEnv.addObjRelation("SourceDocument", xImpressDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> 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); + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java new file mode 100644 index 000000000..c50782e7e --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.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.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +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 + * <code>com.sun.star.comp.Impress.XMLMetaImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @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 XMLMetaImporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New impress 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 an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Impress document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLMetaImporter</code><p> + * + * The impress document is set as a target document for importer. + * Imported XML-data contains only meta tags including title tag + * with test title name. After import title name getting from + * target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam,PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impTitle = "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() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.XMLMetaImporter") ; + + 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", xImpressDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-meta" , + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:dc", "CDATA", "http://purl.org/dc/elements/1.1/"}, + {"start", "office:meta"} , + {"start", "dc:title"}, + {"chars", impTitle}, + {"end", "dc:title"}, + {"end", "office:meta"}, + {"end", "office:document-meta"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xImpressDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + String title = xDocProps.getTitle(); + logF.println("Title returned = '" + title + "'") ; + return impTitle.equals(title) ; + } + } ); + + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsExporter.java new file mode 100644 index 000000000..b733d67fd --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsExporter.java @@ -0,0 +1,187 @@ +/* + * 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.Impress; + +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.document.XExporter; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +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 + * <code>com.sun.star.comp.Impress.XMLOasisSettingsExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @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 XMLSettingsExporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xImpressDoc " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLOasisSettingsExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The Impress document is set as a source document for exporter + * created. Then setting 'IsLayerMode' is changed to a new value. + * After this filter checks that value has changed in the XML output. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @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); + final boolean NewDataValue; + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLOasisSettingsExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + //set some settings + XModel xImpressModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); + XController xController = xImpressModel.getCurrentController(); + XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController); + NewDataValue = ! ((Boolean) xPropSet.getPropertyValue + ("IsLayerMode")).booleanValue(); + xPropSet.setPropertyValue("IsLayerMode", + Boolean.valueOf(NewDataValue)); + + + // Adding tags for checking existence of head tag and other tags + filter.addTagEnclosed(new XMLTools.Tag("office:settings"), + new XMLTools.Tag("office:document-settings")); + filter.addTagEnclosed(new XMLTools.Tag("config:config-item-set"), + new XMLTools.Tag("office:settings")); + filter.addTagEnclosed(new XMLTools.Tag("config:config-item-map-indexed"), + new XMLTools.Tag("config:config-item-set")); + filter.addTagEnclosed(new XMLTools.Tag("config:config-item-map-entry"), + new XMLTools.Tag("config:config-item-map-indexed")); + filter.addTagEnclosed(new XMLTools.Tag("config:config-item"), + new XMLTools.Tag("config:config-item-map-entry")); + filter.addCharactersEnclosed(String.valueOf(NewDataValue), + new XMLTools.Tag("config:config-item","config:name","IsLayerMode")); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"simpress: StarOffice XML (Impress)"})); + tEnv.addObjRelation("SourceDocument",xImpressDoc); + tEnv.addObjRelation("XFilter.Checker", filter); + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> 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,false) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsImporter.java new file mode 100644 index 000000000..32860a675 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsImporter.java @@ -0,0 +1,183 @@ +/* + * 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.Impress; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +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 + * <code>com.sun.star.comp.Impress.XMLSettingsImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @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 XMLSettingsImporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New impress 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 an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Impress document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLStylesImporter</code><p> + * + * The Impress document is set as a target document for importer. + * Value of a property "IsLayerMode" has imported as 'true' to a target + * document. After import property value getting from target document + * is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @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.Impress.XMLSettingsImporter") ; + + 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", xImpressDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-settings", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:xlink", "CDATA", "http://www.w3.org/1999/xlink", + "xmlns:presentation", "CDATA", + "http://openoffice.org/2000/presentation", + "xmlns:config", "CDATA", "http://openoffice.org/2001/config", + "office:version", "CDATA", "1.0"}, + {"start", "office:settings"}, + {"start", "config:config-item-map-indexed", "config:name", + "CDATA", "Views"}, + {"start", "config:config-item-map-entry"}, + {"start","config:config-item", "config:name", "CDATA", + "IsLayerMode"}, + {"chars", "true"}, + {"end", "config:config-item"}, + {"end", "config:config-item-map-entry"}, + {"end", "config:config-item-map-indexed"}, + {"end", "office:settings"}, + {"end", "office:document-settings"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + // get property before import + XModel xImpressModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); + XController xController = xImpressModel.getCurrentController(); + final XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController); + log.println("Property \"IsLayerMode\" before import is " + + xPropSet.getPropertyValue("IsLayerMode")); + final PrintWriter logF = log; + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + Boolean propValue; + try { + propValue = (Boolean) xPropSet.getPropertyValue + ("IsLayerMode"); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(logF); + throw new StatusException + ("Can't get property value.", e); + } + logF.println("Property \"IsLayerMode\" after import is " + + propValue); + return propValue.booleanValue(); + } + }); + + return tEnv; + } // end of getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesExporter.java new file mode 100644 index 000000000..2a44f8a8e --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesExporter.java @@ -0,0 +1,185 @@ +/* + * 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.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +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 + * <code>com.sun.star.comp.Impress.XMLOasisStylesExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @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 { + XComponent xImpressDoc = null; + protected static int counter = 0; + + /** + * New spreadsheet 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 an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Spreadsheet document disposed + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xImpressDoc " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLOasisStylesExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The Impress document is set as a source document for exporter + * created. New style 'NewStyle' added to style family "Graphics". + * This made for checking if this style is successfully exported within + * the document styles information. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + String newName = "NewGraphicsStyle" + counter++; + // Adding tags for checking existence of head tag and property value + filter.addTag(new XMLTools.Tag("office:document-styles")); + filter.addTag(new XMLTools.Tag("office:styles")); + filter.addTag(new XMLTools.Tag("style:style","style:name", newName)); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLOasisStylesExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + // Obtaining and changing property values + XStyleFamiliesSupplier styleSup = UnoRuntime.queryInterface + (XStyleFamiliesSupplier.class, xImpressDoc) ; + XNameAccess styleFamilies = styleSup.getStyleFamilies(); + String[] styleFamiliesNames = styleFamilies.getElementNames(); + XNameContainer StyleFamilyName = UnoRuntime.queryInterface(XNameContainer.class, + styleFamilies.getByName(styleFamiliesNames[0])); + Object SC = SOF.createInstance + (xImpressDoc, "com.sun.star.style.Style"); + XStyle StylePage = UnoRuntime.queryInterface(XStyle.class,SC); + StyleFamilyName.insertByName(newName, StylePage); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"simpress: StarOffice XML (Impress)"})); + tEnv.addObjRelation("SourceDocument",xImpressDoc); + tEnv.addObjRelation("XFilter.Checker", filter); + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> 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, false) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesImporter.java new file mode 100644 index 000000000..4b0823b44 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesImporter.java @@ -0,0 +1,180 @@ +/* + * 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.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Impress.XMLStylesImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @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 xImpressDoc = null; + + /** + * New spreadsheet 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 an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Spreadsheet document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLStylesImporter</code><p> + * + * The Impress document is set as a target document for importer. + * Imported XML-data contains only style tags including tag + * with new style name. + * After import style names getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @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() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.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", xImpressDoc) ; + + String[][] xml = new String[][] { + {"start", "office:document-styles", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:style", "CDATA", "http://openoffice.org/2000/style", + "xmlns:fo", "CDATA", "http://www.w3.org/1999/XSL/Format", + "xmlns:table", "CDATA", "http://openoffice.org/2000/table"}, + {"start", "office:styles"}, + {"start", "style:style", + "style:name", "CDATA", impValue, + "style:family", "CDATA", "graphics", + "style:parent-style-name", "CDATA", "standard"}, + {"end", "style:style"}, + {"end", "office:styles"}, + {"end", "office:document-styles"}} ; + + // adding relation for XDocumentHandler + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + XNameAccess styles = null ; + try { + XStyleFamiliesSupplier sup = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xImpressDoc); + XNameAccess oStyleFamilies = sup.getStyleFamilies(); + Object family = oStyleFamilies.getByName("graphics") ; + styles = UnoRuntime.queryInterface + (XNameAccess.class, family) ; + log.println("Styles before:") ; + String[] names = styles.getElementNames() ; + for (int i = 0; i < names.length; i++) { + log.println(" " + names[i]) ; + } + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + } + final XNameAccess stylesF = styles ; + final PrintWriter logF = log ; + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + logF.println("Styles after:") ; + String[] names = stylesF.getElementNames() ; + for (int i = 0; i < names.length; i++) { + logF.println(" " + names[i]) ; + } + return stylesF.hasByName(impValue) ; + } + }) ; + + return tEnv; + } // end of getTestEnvironment + +} + |