summaryrefslogtreecommitdiffstats
path: root/forms/qa/org
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /forms/qa/org
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'forms/qa/org')
-rw-r--r--forms/qa/org/openoffice/complex/forms/tools/ResultSet.java273
-rw-r--r--forms/qa/org/openoffice/xforms/Instance.java145
-rw-r--r--forms/qa/org/openoffice/xforms/Model.java99
-rw-r--r--forms/qa/org/openoffice/xforms/XMLDocument.java97
4 files changed, 614 insertions, 0 deletions
diff --git a/forms/qa/org/openoffice/complex/forms/tools/ResultSet.java b/forms/qa/org/openoffice/complex/forms/tools/ResultSet.java
new file mode 100644
index 000000000..7f87db745
--- /dev/null
+++ b/forms/qa/org/openoffice/complex/forms/tools/ResultSet.java
@@ -0,0 +1,273 @@
+/*
+ * 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 org.openoffice.complex.forms.tools;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.io.XInputStream;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XArray;
+import com.sun.star.sdbc.XBlob;
+import com.sun.star.sdbc.XClob;
+import com.sun.star.sdbc.XRef;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.Date;
+import com.sun.star.util.DateTime;
+import com.sun.star.util.Time;
+
+public class ResultSet implements XResultSet, XRow
+{
+ private final XResultSet m_resultSet;
+ private final XRow m_row;
+
+ public ResultSet( final Object _resultSet )
+ {
+ m_resultSet = UnoRuntime.queryInterface( XResultSet.class, _resultSet );
+ m_row = UnoRuntime.queryInterface( XRow.class, _resultSet );
+ }
+
+ public
+ boolean next() throws SQLException
+ {
+ return m_resultSet.next();
+ }
+
+ public
+ boolean isBeforeFirst() throws SQLException
+ {
+ return m_resultSet.isBeforeFirst();
+ }
+
+ public
+ boolean isAfterLast() throws SQLException
+ {
+ return m_resultSet.isAfterLast();
+ }
+
+ public
+ boolean isFirst() throws SQLException
+ {
+ return m_resultSet.isFirst();
+ }
+
+ public
+ boolean isLast() throws SQLException
+ {
+ return m_resultSet.isLast();
+ }
+
+ public
+ void beforeFirst() throws SQLException
+ {
+ m_resultSet.beforeFirst();
+ }
+
+ public
+ void afterLast() throws SQLException
+ {
+ m_resultSet.afterLast();
+ }
+
+ public
+ boolean first() throws SQLException
+ {
+ return m_resultSet.first();
+ }
+
+ public
+ boolean last() throws SQLException
+ {
+ return m_resultSet.last();
+ }
+
+ public
+ int getRow() throws SQLException
+ {
+ return m_resultSet.getRow();
+ }
+
+ public
+ boolean absolute( int _row ) throws SQLException
+ {
+ return m_resultSet.absolute( _row );
+ }
+
+ public
+ boolean relative( int _offset ) throws SQLException
+ {
+ return m_resultSet.relative( _offset );
+ }
+
+ public
+ boolean previous() throws SQLException
+ {
+ return m_resultSet.previous();
+ }
+
+ public
+ void refreshRow() throws SQLException
+ {
+ m_resultSet.refreshRow();
+ }
+
+ public
+ boolean rowUpdated() throws SQLException
+ {
+ return m_resultSet.rowUpdated();
+ }
+
+ public
+ boolean rowInserted() throws SQLException
+ {
+ return m_resultSet.rowInserted();
+ }
+
+ public
+ boolean rowDeleted() throws SQLException
+ {
+ return m_resultSet.rowDeleted();
+ }
+
+ public
+ Object getStatement() throws SQLException
+ {
+ return m_resultSet.getStatement();
+ }
+
+ public
+ boolean wasNull() throws SQLException
+ {
+ return m_row.wasNull();
+ }
+
+ public
+ String getString( int _colIndex ) throws SQLException
+ {
+ return m_row.getString( _colIndex );
+ }
+
+ public
+ boolean getBoolean( int _colIndex ) throws SQLException
+ {
+ return m_row.getBoolean( _colIndex );
+ }
+
+ public
+ byte getByte( int _colIndex ) throws SQLException
+ {
+ return m_row.getByte( _colIndex );
+ }
+
+ public
+ short getShort( int _colIndex ) throws SQLException
+ {
+ return m_row.getShort( _colIndex );
+ }
+
+ public
+ int getInt( int _colIndex ) throws SQLException
+ {
+ return m_row.getInt( _colIndex );
+ }
+
+ public
+ long getLong( int _colIndex ) throws SQLException
+ {
+ return m_row.getLong( _colIndex );
+ }
+
+ public
+ float getFloat( int _colIndex ) throws SQLException
+ {
+ return m_row.getFloat( _colIndex );
+ }
+
+ public
+ double getDouble( int _colIndex ) throws SQLException
+ {
+ return m_row.getDouble( _colIndex );
+ }
+
+ public
+ byte[] getBytes( int _colIndex ) throws SQLException
+ {
+ return m_row.getBytes( _colIndex );
+ }
+
+ public
+ Date getDate( int _colIndex ) throws SQLException
+ {
+ return m_row.getDate( _colIndex );
+ }
+
+ public
+ Time getTime( int _colIndex ) throws SQLException
+ {
+ return m_row.getTime( _colIndex );
+ }
+
+ public
+ DateTime getTimestamp( int _colIndex ) throws SQLException
+ {
+ return m_row.getTimestamp( _colIndex );
+ }
+
+ public
+ XInputStream getBinaryStream( int _colIndex ) throws SQLException
+ {
+ return m_row.getBinaryStream( _colIndex );
+ }
+
+ public
+ XInputStream getCharacterStream( int _colIndex ) throws SQLException
+ {
+ return m_row.getCharacterStream( _colIndex );
+ }
+
+ public
+ Object getObject( int _colIndex, XNameAccess _typeMap ) throws SQLException
+ {
+ return m_row.getObject( _colIndex, _typeMap );
+ }
+
+ public
+ XRef getRef( int _colIndex ) throws SQLException
+ {
+ return m_row.getRef( _colIndex );
+ }
+
+ public
+ XBlob getBlob( int _colIndex ) throws SQLException
+ {
+ return m_row.getBlob( _colIndex );
+ }
+
+ public
+ XClob getClob( int _colIndex ) throws SQLException
+ {
+ return m_row.getClob( _colIndex );
+ }
+
+ public
+ XArray getArray( int _colIndex ) throws SQLException
+ {
+ return m_row.getArray( _colIndex );
+ }
+}
diff --git a/forms/qa/org/openoffice/xforms/Instance.java b/forms/qa/org/openoffice/xforms/Instance.java
new file mode 100644
index 000000000..53e9452df
--- /dev/null
+++ b/forms/qa/org/openoffice/xforms/Instance.java
@@ -0,0 +1,145 @@
+/*
+ * 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 org.openoffice.xforms;
+
+import com.sun.star.xml.dom.DOMException;
+import com.sun.star.xml.dom.XDocument;
+import com.sun.star.xml.dom.XNode;
+import com.sun.star.xml.dom.XNodeList;
+import java.util.NoSuchElementException;
+
+public class Instance
+{
+ private final Model m_model;
+ private final XDocument m_domInstance;
+
+ protected Instance( Model _model, XDocument _domInstance )
+ {
+ m_model = _model;
+ m_domInstance = _domInstance;
+ }
+
+ /** creates a new element in the instance
+ *
+ * The element will be inserted immediately below the root node of the instance.
+ *
+ * @param _elementName the name of the to-be-created element
+ * @return the node of the newly created element
+ */
+ public XNode createElement( String _elementName ) throws DOMException
+ {
+ return createElement( m_domInstance, _elementName, null );
+ }
+
+
+
+ /** creates a new element in the instance
+ *
+ * The element will be inserted immediately below a given XNode.
+ *
+ * @param _parentElement
+ * the node whose child shall be created
+ * @param _elementName
+ * the name of the to-be-created element
+ * @param _initialNodeValue
+ * the initial value to set at the node. Might be null, in this case no value is set.
+ * @return
+ * the node of the newly created element
+ */
+ private XNode createElement( XNode _parentElement, String _elementName, String _initialNodeValue ) throws DOMException
+ {
+ XNode node = _parentElement.appendChild(
+ m_model.getUIHelper().createElement( _parentElement, _elementName )
+ );
+ if ( _initialNodeValue != null )
+ node.setNodeValue( _initialNodeValue );
+ return node;
+ }
+
+ /** removes a child of the root-level node from the instance
+ *
+ * @param _elementName
+ * the name of the to-be-removed child
+ */
+ public XNode removeNode( String _elementName ) throws DOMException
+ {
+ return removeNode( m_domInstance, _elementName );
+ }
+
+ /** removes a node from the instance
+ *
+ * @param _parentElement
+ * the node whose child is to be removed
+ * @param _elementName
+ * the name of the to-be-removed child
+ */
+ private XNode removeNode( XNode _parentElement, String _elementName ) throws DOMException
+ {
+ XNodeList nodes = _parentElement.getChildNodes();
+ for ( int i=0; i<nodes.(); ++i )
+ {
+ XNode node = nodes.item(i);
+ if ( node.getLocalName().equals( _elementName ) )
+ {
+ _parentElement.removeChild( node );
+ return node;
+ }
+ }
+ throw new NoSuchElementException();
+ }
+
+
+
+
+
+ /** creates an attribute for the given node
+ *
+ * @param _parentElement
+ * the element at which the attribute should be created
+ * @param _attribName
+ * the name of the to-be-created attribute
+ * @return
+ * the DOM node, which has already been inserted into the DOM tree
+ */
+ public XNode createAttribute( XNode _parentElement, String _attribName ) throws DOMException
+ {
+ return createAttribute( _parentElement, _attribName, null );
+ }
+
+ /** creates an attribute for the given node
+ *
+ * @param _parentElement
+ * the element at which the attribute should be created
+ * @param _attribName
+ * the name of the to-be-created attribute
+ * @param _initialNodeValue
+ * the initial value to set at the node. Might be null, in this case no value is set.
+ * @return
+ * the DOM node, which has already been inserted into the DOM tree
+ */
+ public XNode createAttribute( XNode _parentElement, String _attribName, String _initialNodeValue ) throws DOMException
+ {
+ XNode node = _parentElement.appendChild(
+ m_model.getUIHelper().createAttribute( _parentElement, _attribName )
+ );
+ if ( _initialNodeValue != null )
+ node.setNodeValue( _initialNodeValue );
+ return node;
+ }
+}
diff --git a/forms/qa/org/openoffice/xforms/Model.java b/forms/qa/org/openoffice/xforms/Model.java
new file mode 100644
index 000000000..37c3915b2
--- /dev/null
+++ b/forms/qa/org/openoffice/xforms/Model.java
@@ -0,0 +1,99 @@
+/*
+ * 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 org.openoffice.xforms;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.xforms.XFormsUIHelper1;
+import com.sun.star.xforms.XModel;
+import com.sun.star.xml.dom.XNode;
+
+public class Model
+{
+ private final XModel m_model;
+ private final XPropertySet m_modelProps;
+ private final XFormsUIHelper1 m_helper;
+
+ protected Model( Object _model )
+ {
+ m_model = UnoRuntime.queryInterface( XModel.class, _model );
+ m_modelProps = UnoRuntime.queryInterface( XPropertySet.class, _model );
+ m_helper = UnoRuntime.queryInterface( XFormsUIHelper1.class,
+ m_model );
+ }
+
+
+
+ protected XFormsUIHelper1 getUIHelper()
+ {
+ return m_helper;
+ }
+
+ public Instance getDefaultInstance()
+ {
+ return new Instance( this, m_model.getDefaultInstance() );
+ }
+
+ /** creates a binding for the given DOM node
+ *
+ * @param _node the DOM node to create a binding for
+ * @param _dataTypeClass the data type to be used for the binding
+ */
+ public XPropertySet createBindingForNode( XNode _node, short _dataTypeClass )
+ {
+ XPropertySet binding = m_helper.getBindingForNode(_node, true);
+ try
+ {
+ String basicTypeName = (String)m_model.getDataTypeRepository().getBasicDataType( _dataTypeClass ).
+ getPropertyValue( "Name" );
+ binding.setPropertyValue( "Type", basicTypeName );
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return binding;
+ }
+
+ public void setIsDocumentInternalData( boolean _internalData )
+ {
+ try
+ {
+ m_modelProps.setPropertyValue("ExternalData", Boolean.valueOf(!_internalData));
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public boolean getIsDocumentInternalData()
+ {
+ boolean isInternalData = false;
+ try
+ {
+ isInternalData = !((Boolean)m_modelProps.getPropertyValue( "ExternalData" )).booleanValue();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return isInternalData;
+ }
+}
diff --git a/forms/qa/org/openoffice/xforms/XMLDocument.java b/forms/qa/org/openoffice/xforms/XMLDocument.java
new file mode 100644
index 000000000..d4dfcbc21
--- /dev/null
+++ b/forms/qa/org/openoffice/xforms/XMLDocument.java
@@ -0,0 +1,97 @@
+/*
+ * 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 org.openoffice.xforms;
+
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.xforms.XFormsSupplier;
+import com.sun.star.xforms.XFormsUIHelper1;
+import com.sun.star.xforms.XModel;
+import integration.forms.DocumentType;
+
+public class XMLDocument extends integration.forms.DocumentHelper
+{
+ private XNameContainer m_forms;
+
+ /* ------------------------------------------------------------------ */
+ public XMLDocument( XMultiServiceFactory _orb ) throws Exception
+ {
+ super( _orb, implLoadAsComponent( _orb, getDocumentFactoryURL( DocumentType.XMLFORM ) ) );
+ impl_initialize( getDocument() );
+ }
+
+ /* ------------------------------------------------------------------ */
+ private void impl_initialize( XComponent _document )
+ {
+ XFormsSupplier formsSupplier = UnoRuntime.queryInterface( XFormsSupplier.class,
+ _document );
+
+ if ( formsSupplier == null )
+ throw new IllegalArgumentException();
+
+ m_forms = formsSupplier.getXForms();
+ }
+
+ /* ------------------------------------------------------------------ */
+ public String[] getXFormModelNames()
+ {
+ return m_forms.getElementNames();
+ }
+
+ /* ------------------------------------------------------------------ */
+ public Model getXFormModel( String _modelName ) throws NoSuchElementException
+ {
+ try
+ {
+ return new Model(m_forms.getByName(_modelName));
+ }
+ catch (WrappedTargetException ex)
+ {
+ throw new NoSuchElementException(ex);
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ public Model addXFormModel( String _modelName )
+ {
+ XModel newModel = null;
+ try
+ {
+ newModel = UnoRuntime.queryInterface( XModel.class,
+ getOrb().createInstance( "com.sun.star.xforms.Model" ) );
+ newModel.setID(_modelName);
+ XFormsUIHelper1 modelHelper = UnoRuntime.queryInterface(
+ XFormsUIHelper1.class, newModel );
+ modelHelper.newInstance( "Instance 1", "", true );
+ newModel.initialize();
+
+ m_forms.insertByName(_modelName, newModel);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return new Model( newModel );
+ }
+}