summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2008-06-25 13:26:56 +0000
committerKurt Zenker <kz@openoffice.org>2008-06-25 13:26:56 +0000
commit4acdd5689c54b9a4bcea2dd12c1b940c500c7660 (patch)
tree7e79fed54da1512d0697b3a4f89cb59a13a14ac4 /forms
parentc2de6cadb7e2eb8c661071cdf04ebbb29a6eb1e6 (diff)
INTEGRATION: CWS xformsdocmodify (1.6.24); FILE MERGED
2008/06/05 21:25:09 fs 1.6.24.2: +userTextInput (formerly in FormControlTest) 2008/06/04 20:56:35 fs 1.6.24.1: #i90363# +createLabeledControl
Diffstat (limited to 'forms')
-rw-r--r--forms/qa/integration/forms/FormLayer.java77
1 files changed, 64 insertions, 13 deletions
diff --git a/forms/qa/integration/forms/FormLayer.java b/forms/qa/integration/forms/FormLayer.java
index 10908b0d3dbd..d67e28bcf412 100644
--- a/forms/qa/integration/forms/FormLayer.java
+++ b/forms/qa/integration/forms/FormLayer.java
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: FormLayer.java,v $
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
* This file is part of OpenOffice.org.
*
@@ -29,9 +29,9 @@
************************************************************************/
package integration.forms;
-import com.sun.star.container.NoSuchElementException;
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleEditableText;
import com.sun.star.container.XNameAccess;
-import com.sun.star.lang.WrappedTargetException;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.beans.XPropertySet;
@@ -43,19 +43,15 @@ import com.sun.star.drawing.XShapes;
import com.sun.star.awt.Size;
import com.sun.star.awt.Point;
import com.sun.star.awt.XControlModel;
-import com.sun.star.awt.XControl;
-import com.sun.star.awt.XWindow;
import com.sun.star.text.TextContentAnchorType;
import com.sun.star.drawing.XDrawPage;
-import integration.forms.DocumentHelper;
-
/**
*
* @author fs@openoffice.org
*/
- public class FormLayer
- {
+public class FormLayer
+{
private DocumentHelper m_document;
private XDrawPage m_page;
@@ -98,7 +94,7 @@ import integration.forms.DocumentHelper;
@return
the property access to the control's model
*/
- protected XPropertySet createControlAndShape( String sFormComponentService, int nXPos,
+ public XPropertySet createControlAndShape( String sFormComponentService, int nXPos,
int nYPos, int nWidth, int nHeight, XIndexContainer xParentForm ) throws java.lang.Exception
{
// let the document create a shape
@@ -162,12 +158,49 @@ import integration.forms.DocumentHelper;
@return
the property access to the control's model
*/
- protected XPropertySet createControlAndShape( String sFormComponentService, int nXPos,
+ public XPropertySet createControlAndShape( String sFormComponentService, int nXPos,
int nYPos, int nWidth, int nHeight ) throws java.lang.Exception
{
return createControlAndShape( sFormComponentService, nXPos, nYPos, nWidth, nHeight, null );
}
+ /** creates a pair of controls, namely a label control, and another control labeled by it
+ *
+ * @param _formComponentServiceName
+ * the service name for the control which is not the label control
+ * @param _label
+ * the label to be shown in the label control
+ * @param _xPos
+ * the horizontal position of the control pair
+ * @param _yPos
+ * the vertical position of the control pair
+ * @param _height
+ * the height of the control which is not the label control
+ * @return
+ * the model of the control which is not the label control
+ * @throws java.lang.Exception
+ */
+ public XPropertySet createLabeledControl( String _formComponentServiceName, String _label, int _xPos,
+ int _yPos, int _height )
+ throws java.lang.Exception
+ {
+ // insert the label control
+ XPropertySet label = createControlAndShape( "FixedText", _xPos, _yPos, 25, 6 );
+ label.setPropertyValue( "Label", _label );
+
+ // insert the text field control
+ XPropertySet field = createControlAndShape( _formComponentServiceName,
+ _xPos + 25, _yPos, 40, _height );
+ // knit it to it's label component
+ field.setPropertyValue( "LabelControl", label );
+
+ // names
+ label.setPropertyValue( "Name", _label + "_Label" );
+ field.setPropertyValue( "Name", _label );
+
+ return field;
+ }
+
/* ------------------------------------------------------------------ */
/** creates a line of controls, consisting of a label and a field for data input.
@@ -187,7 +220,8 @@ import integration.forms.DocumentHelper;
@return
the control model of the created data input field
*/
- protected XPropertySet insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix, int nXPos, int nYPos, int nHeight )
+ public XPropertySet insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix,
+ int nXPos, int nYPos, int nHeight )
throws java.lang.Exception
{
// insert the label control
@@ -219,7 +253,7 @@ import integration.forms.DocumentHelper;
@return
the control model of the created data input field
*/
- protected XPropertySet insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix, int nYPos )
+ public XPropertySet insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix, int nYPos )
throws java.lang.Exception
{
return insertControlLine( sControlType, sFieldName, sControlNamePostfix, 2, nYPos, 6 );
@@ -293,4 +327,21 @@ import integration.forms.DocumentHelper;
}
return controlModel;
}
+
+ /* ------------------------------------------------------------------ */
+ /** simulates a user's text input into a control given by control model
+ */
+ public void userTextInput( XPropertySet controlModel, String text ) throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ // we will *not* simply set the value property at the model. This is not the same as
+ // doing a user input, as the latter will trigger a lot of notifications, which the forms runtime environment
+ // (namely the FormController) relies on to notice that the control changed.
+ // Instead, we use the Accessibility interfaces of the control to simulate text input
+ XAccessible formattedAccessible = (XAccessible)UnoRuntime.queryInterface( XAccessible.class,
+ m_document.getCurrentView().getControl( controlModel )
+ );
+ XAccessibleEditableText textAccess = (XAccessibleEditableText)UnoRuntime.queryInterface( XAccessibleEditableText.class,
+ formattedAccessible.getAccessibleContext() );
+ textAccess.setText( text );
+ }
}