summaryrefslogtreecommitdiff
path: root/forms/qa/org/openoffice
diff options
context:
space:
mode:
Diffstat (limited to 'forms/qa/org/openoffice')
-rw-r--r--forms/qa/org/openoffice/complex/forms/tools/ResultSet.java264
-rw-r--r--forms/qa/org/openoffice/xforms/Instance.java198
-rw-r--r--forms/qa/org/openoffice/xforms/Model.java100
-rw-r--r--forms/qa/org/openoffice/xforms/XMLDocument.java96
4 files changed, 658 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 000000000000..7763afe6b262
--- /dev/null
+++ b/forms/qa/org/openoffice/complex/forms/tools/ResultSet.java
@@ -0,0 +1,264 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+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;
+
+/**
+ *
+ * @author frank.schoenheit@sun.com
+ */
+public class ResultSet implements XResultSet, XRow
+{
+ private final XResultSet m_resultSet;
+ private final XRow m_row;
+
+ public ResultSet( final Object _resultSet )
+ {
+ m_resultSet = (XResultSet)UnoRuntime.queryInterface( XResultSet.class, _resultSet );
+ m_row = (XRow)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 000000000000..5e4e04741995
--- /dev/null
+++ b/forms/qa/org/openoffice/xforms/Instance.java
@@ -0,0 +1,198 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+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;
+
+/**
+ *
+ * @author fs93730
+ */
+public class Instance
+{
+ private Model m_model;
+ private 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
+ * @throws com.sun.star.xml.dom.DOMException
+ */
+ 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 the root node of the instance.
+ *
+ * @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
+ * @throws com.sun.star.xml.dom.DOMException
+ */
+ public XNode createElement( String _elementName, String _initialNodeValue ) throws DOMException
+ {
+ return createElement( m_domInstance, _elementName, _initialNodeValue );
+ }
+
+ /** 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
+ * @return
+ * the node of the newly created element
+ * @throws com.sun.star.xml.dom.DOMException
+ */
+ public XNode createElement( XNode _parentElement, String _elementName ) throws DOMException
+ {
+ return createElement( _parentElement, _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
+ * @throws com.sun.star.xml.dom.DOMException
+ */
+ public 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
+ */
+ public XNode removeNode( XNode _parentElement, String _elementName ) throws DOMException
+ {
+ XNodeList nodes = _parentElement.getChildNodes();
+ for ( int i=0; i<nodes.getLength(); ++i )
+ {
+ XNode node = nodes.item(i);
+ if ( node.getLocalName().equals( _elementName ) )
+ {
+ _parentElement.removeChild( node );
+ return node;
+ }
+ }
+ throw new NoSuchElementException();
+ }
+
+ /** creates an attribute for the root node of the instance
+ *
+ * @param _attribName
+ * the name of the to-be-created attribute
+ * @return
+ * the DOM node, which has already been inserted into the DOM tree
+ * @throws com.sun.star.xml.dom.DOMException
+ */
+ public XNode createAttribute( String _attribName ) throws DOMException
+ {
+ return createAttribute( m_domInstance, _attribName, null );
+ }
+
+ /** creates an attribute for the root node of the instance
+ *
+ * @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
+ * @throws com.sun.star.xml.dom.DOMException
+ */
+ public XNode createAttribute( String _attribName, String _initialNodeValue ) throws DOMException
+ {
+ return createAttribute( m_domInstance, _attribName, _initialNodeValue );
+ }
+
+ /** 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
+ * @throws com.sun.star.xml.dom.DOMException
+ */
+ 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
+ * @throws com.sun.star.xml.dom.DOMException
+ */
+ 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 000000000000..ee4ed6caa7e8
--- /dev/null
+++ b/forms/qa/org/openoffice/xforms/Model.java
@@ -0,0 +1,100 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.openoffice.xforms;
+
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.WrappedTargetException;
+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;
+
+/** encapsulates an XForms model
+ *
+ * @author fs93730
+ */
+public class Model
+{
+ private XModel m_model;
+ private XPropertySet m_modelProps;
+ private XFormsUIHelper1 m_helper;
+
+ protected Model( Object _model )
+ {
+ m_model = (XModel)UnoRuntime.queryInterface( XModel.class, _model );
+ m_modelProps = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, _model );
+ m_helper = (XFormsUIHelper1)UnoRuntime.queryInterface( XFormsUIHelper1.class,
+ m_model );
+ }
+
+ protected XModel getXModel()
+ {
+ return 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 _dataType
+ * the data type to be used for the binding
+ * @return
+ */
+ 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", new Boolean(!_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 000000000000..9ca35b3801da
--- /dev/null
+++ b/forms/qa/org/openoffice/xforms/XMLDocument.java
@@ -0,0 +1,96 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+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;
+
+/**
+ *
+ * @author fs93730
+ */
+public class XMLDocument extends integration.forms.DocumentHelper
+{
+ private XFormsSupplier m_formsSupplier;
+ private XNameContainer m_forms;
+
+ /* ------------------------------------------------------------------ */
+ public XMLDocument( XMultiServiceFactory _orb ) throws Exception
+ {
+ super( _orb, implLoadAsComponent( _orb, getDocumentFactoryURL( DocumentType.XMLFORM ) ) );
+ impl_initialize( getDocument() );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public XMLDocument( XMultiServiceFactory _orb, XComponent _document )
+ {
+ super( _orb, _document );
+ impl_initialize( _document );
+ }
+
+ /* ------------------------------------------------------------------ */
+ private void impl_initialize( XComponent _document )
+ {
+ m_formsSupplier = (XFormsSupplier)UnoRuntime.queryInterface( XFormsSupplier.class,
+ _document );
+
+ if ( m_formsSupplier == null )
+ throw new IllegalArgumentException();
+
+ m_forms = m_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();
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ public Model addXFormModel( String _modelName )
+ {
+ XModel newModel = null;
+ try
+ {
+ newModel = (XModel) UnoRuntime.queryInterface( XModel.class,
+ getOrb().createInstance( "com.sun.star.xforms.Model" ) );
+ newModel.setID(_modelName);
+ XFormsUIHelper1 modelHelper = (XFormsUIHelper1) UnoRuntime.queryInterface(
+ XFormsUIHelper1.class, newModel );
+ modelHelper.newInstance( "Instance 1", new String(), true );
+ newModel.initialize();
+
+ m_forms.insertByName(_modelName, newModel);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return new Model( newModel );
+ }
+}