1*b9b79128SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b9b79128SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b9b79128SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b9b79128SAndrew Rist * distributed with this work for additional information 6*b9b79128SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b9b79128SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b9b79128SAndrew Rist * "License"); you may not use this file except in compliance 9*b9b79128SAndrew Rist * with the License. You may obtain a copy of the License at 10*b9b79128SAndrew Rist * 11*b9b79128SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*b9b79128SAndrew Rist * 13*b9b79128SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b9b79128SAndrew Rist * software distributed under the License is distributed on an 15*b9b79128SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b9b79128SAndrew Rist * KIND, either express or implied. See the License for the 17*b9b79128SAndrew Rist * specific language governing permissions and limitations 18*b9b79128SAndrew Rist * under the License. 19*b9b79128SAndrew Rist * 20*b9b79128SAndrew Rist *************************************************************/ 21*b9b79128SAndrew Rist 22*b9b79128SAndrew Rist 23cdf0e10cSrcweir package integration.forms; 24cdf0e10cSrcweir 25cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible; 26cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleEditableText; 27cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 28cdf0e10cSrcweir 29cdf0e10cSrcweir import com.sun.star.beans.XPropertySet; 30cdf0e10cSrcweir import com.sun.star.container.XIndexContainer; 31cdf0e10cSrcweir import com.sun.star.container.XIndexAccess; 32cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 33cdf0e10cSrcweir import com.sun.star.drawing.XControlShape; 34cdf0e10cSrcweir import com.sun.star.drawing.XShapes; 35cdf0e10cSrcweir import com.sun.star.awt.Size; 36cdf0e10cSrcweir import com.sun.star.awt.Point; 37cdf0e10cSrcweir import com.sun.star.awt.VisualEffect; 38cdf0e10cSrcweir import com.sun.star.awt.XControlModel; 39cdf0e10cSrcweir import com.sun.star.container.XNameAccess; 40cdf0e10cSrcweir import com.sun.star.text.TextContentAnchorType; 41cdf0e10cSrcweir import com.sun.star.drawing.XDrawPage; 42cdf0e10cSrcweir 43cdf0e10cSrcweir /** 44cdf0e10cSrcweir * 45cdf0e10cSrcweir * @author fs@openoffice.org 46cdf0e10cSrcweir */ 47cdf0e10cSrcweir public class FormLayer 48cdf0e10cSrcweir { 49cdf0e10cSrcweir private DocumentHelper m_document; 50cdf0e10cSrcweir private XDrawPage m_page; 51cdf0e10cSrcweir 52cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 53cdf0e10cSrcweir /** Creates a new instance of FormLayer */ FormLayer( DocumentHelper _document )54cdf0e10cSrcweir public FormLayer( DocumentHelper _document ) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir m_document = _document; 57cdf0e10cSrcweir } 58cdf0e10cSrcweir 59cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 60cdf0e10cSrcweir /** sets the page which is to be used for subsequent insertions of controls/shapes 61cdf0e10cSrcweir */ setInsertPage( int page )62cdf0e10cSrcweir void setInsertPage( int page ) throws com.sun.star.lang.IndexOutOfBoundsException, com.sun.star.lang.WrappedTargetException 63cdf0e10cSrcweir { 64cdf0e10cSrcweir m_page = m_document.getDrawPage( page ); 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 68cdf0e10cSrcweir /** creates a control in the document 69cdf0e10cSrcweir 70cdf0e10cSrcweir <p>Note that <em>control<em> here is an incorrect terminology. What the method really does is 71cdf0e10cSrcweir it creates a control shape, together with a control model, and inserts them into the document model. 72cdf0e10cSrcweir This will result in every view to this document creating a control described by the model-shape pair. 73cdf0e10cSrcweir </p> 74cdf0e10cSrcweir 75cdf0e10cSrcweir @param sFormComponentService 76cdf0e10cSrcweir the service name of the form component to create, e.g. "TextField" 77cdf0e10cSrcweir @param nXPos 78cdf0e10cSrcweir the abscissa of the position of the newly inserted shape 79cdf0e10cSrcweir @param nXPos 80cdf0e10cSrcweir the ordinate of the position of the newly inserted shape 81cdf0e10cSrcweir @param nWidth 82cdf0e10cSrcweir the width of the newly inserted shape 83cdf0e10cSrcweir @param nHeight 84cdf0e10cSrcweir the height of the newly inserted shape 85cdf0e10cSrcweir @param xParentForm 86cdf0e10cSrcweir the form to use as parent for the newly create form component. May be null, in this case 87cdf0e10cSrcweir a default parent is chosen by the implementation 88cdf0e10cSrcweir @return 89cdf0e10cSrcweir the property access to the control's model 90cdf0e10cSrcweir */ createControlAndShape( String sFormComponentService, int nXPos, int nYPos, int nWidth, int nHeight, Object _parentForm )91cdf0e10cSrcweir public XPropertySet createControlAndShape( String sFormComponentService, int nXPos, 92cdf0e10cSrcweir int nYPos, int nWidth, int nHeight, Object _parentForm ) throws java.lang.Exception 93cdf0e10cSrcweir { 94cdf0e10cSrcweir // let the document create a shape 95cdf0e10cSrcweir XMultiServiceFactory xDocAsFactory = UnoRuntime.queryInterface( 96cdf0e10cSrcweir XMultiServiceFactory.class, m_document.getDocument() ); 97cdf0e10cSrcweir XControlShape xShape = UnoRuntime.queryInterface( XControlShape.class, 98cdf0e10cSrcweir xDocAsFactory.createInstance( "com.sun.star.drawing.ControlShape" ) ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir // position and size of the shape 101cdf0e10cSrcweir xShape.setSize( new Size( nWidth * 100, nHeight * 100 ) ); 102cdf0e10cSrcweir xShape.setPosition( new Point( nXPos * 100, nYPos * 100 ) ); 103cdf0e10cSrcweir 104cdf0e10cSrcweir // adjust the anchor so that the control is tied to the page 105cdf0e10cSrcweir XPropertySet xShapeProps = dbfTools.queryPropertySet( xShape ); 106cdf0e10cSrcweir TextContentAnchorType eAnchorType = TextContentAnchorType.AT_PARAGRAPH; 107cdf0e10cSrcweir xShapeProps.setPropertyValue( "AnchorType", eAnchorType ); 108cdf0e10cSrcweir 109cdf0e10cSrcweir // create the form component (the model of a form control) 110cdf0e10cSrcweir String sQualifiedComponentName = "com.sun.star.form.component." + sFormComponentService; 111cdf0e10cSrcweir XControlModel xModel = UnoRuntime.queryInterface( XControlModel.class, 112cdf0e10cSrcweir m_document.getOrb().createInstance( sQualifiedComponentName ) ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir // insert the model into the form component hierarchy, if the caller gave us a location 115cdf0e10cSrcweir if ( null != _parentForm ) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir XIndexContainer parentForm = null; 118cdf0e10cSrcweir if ( _parentForm instanceof XIndexContainer ) 119cdf0e10cSrcweir parentForm = (XIndexContainer)_parentForm; 120cdf0e10cSrcweir else 121cdf0e10cSrcweir parentForm = UnoRuntime.queryInterface( XIndexContainer.class, _parentForm ); 122cdf0e10cSrcweir parentForm.insertByIndex( parentForm.getCount(), xModel ); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir // knitt them 126cdf0e10cSrcweir xShape.setControl( xModel ); 127cdf0e10cSrcweir 128cdf0e10cSrcweir // add the shape to the shapes collection of the document 129cdf0e10cSrcweir XDrawPage pageWhereToInsert = ( m_page != null ) ? m_page : m_document.getMainDrawPage(); 130cdf0e10cSrcweir 131cdf0e10cSrcweir XShapes xDocShapes = UnoRuntime.queryInterface( XShapes.class, pageWhereToInsert ); 132cdf0e10cSrcweir xDocShapes.add( xShape ); 133cdf0e10cSrcweir 134cdf0e10cSrcweir // and outta here with the XPropertySet interface of the model 135cdf0e10cSrcweir XPropertySet xModelProps = dbfTools.queryPropertySet( xModel ); 136cdf0e10cSrcweir return xModelProps; 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 140cdf0e10cSrcweir /** creates a control in the document 141cdf0e10cSrcweir 142cdf0e10cSrcweir <p>Note that <em>control<em> here is an incorrect terminology. What the method really does is 143cdf0e10cSrcweir it creates a control shape, together with a control model, and inserts them into the document model. 144cdf0e10cSrcweir This will result in every view to this document creating a control described by the model-shape pair. 145cdf0e10cSrcweir </p> 146cdf0e10cSrcweir 147cdf0e10cSrcweir @param sFormComponentService 148cdf0e10cSrcweir the service name of the form component to create, e.g. "TextField" 149cdf0e10cSrcweir @param nXPos 150cdf0e10cSrcweir the abscissa of the position of the newly inserted shape 151cdf0e10cSrcweir @param nXPos 152cdf0e10cSrcweir the ordinate of the position of the newly inserted shape 153cdf0e10cSrcweir @param nWidth 154cdf0e10cSrcweir the width of the newly inserted shape 155cdf0e10cSrcweir @param nHeight 156cdf0e10cSrcweir the height of the newly inserted shape 157cdf0e10cSrcweir @return 158cdf0e10cSrcweir the property access to the control's model 159cdf0e10cSrcweir */ createControlAndShape( String sFormComponentService, int nXPos, int nYPos, int nWidth, int nHeight )160cdf0e10cSrcweir public XPropertySet createControlAndShape( String sFormComponentService, int nXPos, 161cdf0e10cSrcweir int nYPos, int nWidth, int nHeight ) throws java.lang.Exception 162cdf0e10cSrcweir { 163cdf0e10cSrcweir return createControlAndShape( sFormComponentService, nXPos, nYPos, nWidth, nHeight, null ); 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir /** creates a pair of controls, namely a label control, and another control labeled by it 167cdf0e10cSrcweir * 168cdf0e10cSrcweir * @param _formComponentServiceName 169cdf0e10cSrcweir * the service name for the control which is not the label control 170cdf0e10cSrcweir * @param _label 171cdf0e10cSrcweir * the label to be shown in the label control 172cdf0e10cSrcweir * @param _xPos 173cdf0e10cSrcweir * the horizontal position of the control pair 174cdf0e10cSrcweir * @param _yPos 175cdf0e10cSrcweir * the vertical position of the control pair 176cdf0e10cSrcweir * @param _height 177cdf0e10cSrcweir * the height of the control which is not the label control 178cdf0e10cSrcweir * @return 179cdf0e10cSrcweir * the model of the control which is not the label control 180cdf0e10cSrcweir * @throws java.lang.Exception 181cdf0e10cSrcweir */ createLabeledControl( String _formComponentServiceName, String _label, int _xPos, int _yPos, int _height )182cdf0e10cSrcweir public XPropertySet createLabeledControl( String _formComponentServiceName, String _label, int _xPos, 183cdf0e10cSrcweir int _yPos, int _height ) 184cdf0e10cSrcweir throws java.lang.Exception 185cdf0e10cSrcweir { 186cdf0e10cSrcweir // insert the label control 187cdf0e10cSrcweir XPropertySet label = createControlAndShape( "FixedText", _xPos, _yPos, 25, 6 ); 188cdf0e10cSrcweir label.setPropertyValue( "Label", _label ); 189cdf0e10cSrcweir 190cdf0e10cSrcweir // insert the text field control 191cdf0e10cSrcweir XPropertySet field = createControlAndShape( _formComponentServiceName, 192cdf0e10cSrcweir _xPos + 25, _yPos, 40, _height ); 193cdf0e10cSrcweir // knit it to it's label component 194cdf0e10cSrcweir field.setPropertyValue( "LabelControl", label ); 195cdf0e10cSrcweir 196cdf0e10cSrcweir // names 197cdf0e10cSrcweir label.setPropertyValue( "Name", _label + "_Label" ); 198cdf0e10cSrcweir field.setPropertyValue( "Name", _label ); 199cdf0e10cSrcweir 200cdf0e10cSrcweir return field; 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 204cdf0e10cSrcweir /** creates a line of controls, consisting of a label and a field for data input. 205cdf0e10cSrcweir 206cdf0e10cSrcweir <p>In opposite to the second form of this method, here the height of the field, 207cdf0e10cSrcweir as well as the abscissa of the label, are under the control of the caller.</p> 208cdf0e10cSrcweir 209cdf0e10cSrcweir @param sControlType 210cdf0e10cSrcweir specifies the type of the data input control 211cdf0e10cSrcweir @param sFieldName 212cdf0e10cSrcweir specifies the field name the text field should be bound to 213cdf0e10cSrcweir @param sControlNamePostfix 214cdf0e10cSrcweir specifies a postfix to append to the logical control names 215cdf0e10cSrcweir @param nYPos 216cdf0e10cSrcweir specifies the Y position of the line to start at 217cdf0e10cSrcweir @param nHeight 218cdf0e10cSrcweir the height of the field 219cdf0e10cSrcweir @return 220cdf0e10cSrcweir the control model of the created data input field 221cdf0e10cSrcweir */ insertControlLine( String sControlType, String sFieldName, String _controlNamePostfix, int nXPos, int nYPos, int nHeight )222cdf0e10cSrcweir public XPropertySet insertControlLine( String sControlType, String sFieldName, String _controlNamePostfix, 223cdf0e10cSrcweir int nXPos, int nYPos, int nHeight ) 224cdf0e10cSrcweir throws java.lang.Exception 225cdf0e10cSrcweir { 226cdf0e10cSrcweir // insert the label control 227cdf0e10cSrcweir XPropertySet xLabelModel = createControlAndShape( "FixedText", nXPos, nYPos, 25, 6 ); 228cdf0e10cSrcweir xLabelModel.setPropertyValue( "Label", sFieldName ); 229cdf0e10cSrcweir 230cdf0e10cSrcweir // insert the text field control 231cdf0e10cSrcweir XPropertySet xFieldModel = createControlAndShape( sControlType, nXPos + 26, nYPos, 40, nHeight ); 232cdf0e10cSrcweir xFieldModel.setPropertyValue( "DataField", sFieldName ); 233cdf0e10cSrcweir if ( xFieldModel.getPropertySetInfo().hasPropertyByName( "Border" ) ) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir xFieldModel.setPropertyValue( "Border", new Short( VisualEffect.FLAT ) ); 236cdf0e10cSrcweir if ( xFieldModel.getPropertySetInfo().hasPropertyByName( "BorderColor" ) ) 237cdf0e10cSrcweir xFieldModel.setPropertyValue( "BorderColor", new Integer( 0x00C0C0C0 ) ); 238cdf0e10cSrcweir } 239cdf0e10cSrcweir // knit it to it's label component 240cdf0e10cSrcweir xFieldModel.setPropertyValue( "LabelControl", xLabelModel ); 241cdf0e10cSrcweir 242cdf0e10cSrcweir // some names, so later on we can find them 243cdf0e10cSrcweir if ( _controlNamePostfix == null ) 244cdf0e10cSrcweir _controlNamePostfix = ""; 245cdf0e10cSrcweir xLabelModel.setPropertyValue( "Name", sFieldName + _controlNamePostfix + "_Label" ); 246cdf0e10cSrcweir xFieldModel.setPropertyValue( "Name", sFieldName + _controlNamePostfix ); 247cdf0e10cSrcweir 248cdf0e10cSrcweir return xFieldModel; 249cdf0e10cSrcweir } 250cdf0e10cSrcweir 251cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 252cdf0e10cSrcweir /** creates a line of controls, consisting of a label and a field for data input. 253cdf0e10cSrcweir 254cdf0e10cSrcweir @param sControlType 255cdf0e10cSrcweir specifies the type of the data input control 256cdf0e10cSrcweir @param sFieldName 257cdf0e10cSrcweir specifies the field name the text field should be bound to 258cdf0e10cSrcweir @param nYPos 259cdf0e10cSrcweir specifies the Y position of the line to start at 260cdf0e10cSrcweir @return 261cdf0e10cSrcweir the control model of the created data input field 262cdf0e10cSrcweir */ insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix, int nYPos )263cdf0e10cSrcweir public XPropertySet insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix, int nYPos ) 264cdf0e10cSrcweir throws java.lang.Exception 265cdf0e10cSrcweir { 266cdf0e10cSrcweir return insertControlLine( sControlType, sFieldName, sControlNamePostfix, 10, nYPos, 6 ); 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 270cdf0e10cSrcweir /** retrieves the radio button model with the given name and the given ref value 271cdf0e10cSrcweir * @param form 272cdf0e10cSrcweir * the parent form of the radio button model to find 273cdf0e10cSrcweir * @param name 274cdf0e10cSrcweir * the name of the radio button 275cdf0e10cSrcweir * @param refValue 276cdf0e10cSrcweir * the reference value of the radio button 277cdf0e10cSrcweir */ getRadioModelByRefValue( XPropertySet form, String name, String refValue )278cdf0e10cSrcweir public XPropertySet getRadioModelByRefValue( XPropertySet form, String name, String refValue ) throws com.sun.star.uno.Exception, java.lang.Exception 279cdf0e10cSrcweir { 280cdf0e10cSrcweir XIndexAccess indexAccess = UnoRuntime.queryInterface( XIndexAccess.class, form ); 281cdf0e10cSrcweir 282cdf0e10cSrcweir for ( int i=0; i<indexAccess.getCount(); ++i ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir XPropertySet control = dbfTools.queryPropertySet( indexAccess.getByIndex( i ) ); 285cdf0e10cSrcweir 286cdf0e10cSrcweir if ( ((String)control.getPropertyValue( "Name" )).equals( name ) ) 287cdf0e10cSrcweir if ( ((String)control.getPropertyValue( "RefValue" )).equals( refValue ) ) 288cdf0e10cSrcweir return control; 289cdf0e10cSrcweir } 290cdf0e10cSrcweir return null; 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 294cdf0e10cSrcweir /** retrieves the radio button model with the given name and the given tag 295cdf0e10cSrcweir * @param form 296cdf0e10cSrcweir * the parent form of the radio button model to find 297cdf0e10cSrcweir * @param name 298cdf0e10cSrcweir * the name of the radio button 299cdf0e10cSrcweir * @param refValue 300cdf0e10cSrcweir * the tag of the radio button 301cdf0e10cSrcweir */ getRadioModelByTag( XPropertySet form, String name, String tag )302cdf0e10cSrcweir public XPropertySet getRadioModelByTag( XPropertySet form, String name, String tag ) throws com.sun.star.uno.Exception, java.lang.Exception 303cdf0e10cSrcweir { 304cdf0e10cSrcweir XIndexAccess indexAccess = UnoRuntime.queryInterface( XIndexAccess.class, form ); 305cdf0e10cSrcweir 306cdf0e10cSrcweir for ( int i=0; i<indexAccess.getCount(); ++i ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir XPropertySet control = dbfTools.queryPropertySet( indexAccess.getByIndex( i ) ); 309cdf0e10cSrcweir 310cdf0e10cSrcweir if ( ((String)control.getPropertyValue( "Name" )).equals( name ) ) 311cdf0e10cSrcweir if ( ((String)control.getPropertyValue( "Tag" )).equals( tag ) ) 312cdf0e10cSrcweir return control; 313cdf0e10cSrcweir } 314cdf0e10cSrcweir return null; 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 318cdf0e10cSrcweir /** retrieves a control model with a given (integer) access path 319cdf0e10cSrcweir */ getControlModel( int[] _accessPath )320cdf0e10cSrcweir public XPropertySet getControlModel( int[] _accessPath ) throws com.sun.star.uno.Exception 321cdf0e10cSrcweir { 322cdf0e10cSrcweir XIndexAccess indexAcc = (XIndexAccess)UnoRuntime.queryInterface( XIndexAccess.class, 323cdf0e10cSrcweir m_document.getFormComponentTreeRoot() ); 324cdf0e10cSrcweir XPropertySet controlModel = null; 325cdf0e10cSrcweir int i=0; 326cdf0e10cSrcweir while ( ( indexAcc != null ) && ( i < _accessPath.length ) ) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir controlModel = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, 329cdf0e10cSrcweir indexAcc.getByIndex( _accessPath[i] ) ); 330cdf0e10cSrcweir indexAcc = (XIndexAccess)UnoRuntime.queryInterface( XIndexAccess.class, 331cdf0e10cSrcweir controlModel ); 332cdf0e10cSrcweir ++i; 333cdf0e10cSrcweir } 334cdf0e10cSrcweir return controlModel; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 338cdf0e10cSrcweir /** retrieves a control model with a given (string) access path 339cdf0e10cSrcweir */ getControlModel( String[] _accessPath )340cdf0e10cSrcweir public XPropertySet getControlModel( String[] _accessPath ) throws com.sun.star.uno.Exception 341cdf0e10cSrcweir { 342cdf0e10cSrcweir XNameAccess nameAcc = m_document.getFormComponentTreeRoot(); 343cdf0e10cSrcweir XPropertySet controlModel = null; 344cdf0e10cSrcweir int i=0; 345cdf0e10cSrcweir while ( ( nameAcc != null ) && ( i < _accessPath.length ) ) 346cdf0e10cSrcweir { 347cdf0e10cSrcweir controlModel = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, 348cdf0e10cSrcweir nameAcc.getByName( _accessPath[i] ) ); 349cdf0e10cSrcweir nameAcc = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, 350cdf0e10cSrcweir controlModel ); 351cdf0e10cSrcweir ++i; 352cdf0e10cSrcweir } 353cdf0e10cSrcweir return controlModel; 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 356cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 357cdf0e10cSrcweir /** simulates a user's text input into a control given by control model 358cdf0e10cSrcweir */ userTextInput( XPropertySet controlModel, String text )359cdf0e10cSrcweir public void userTextInput( XPropertySet controlModel, String text ) throws com.sun.star.uno.Exception, java.lang.Exception 360cdf0e10cSrcweir { 361cdf0e10cSrcweir // we will *not* simply set the value property at the model. This is not the same as 362cdf0e10cSrcweir // doing a user input, as the latter will trigger a lot of notifications, which the forms runtime environment 363cdf0e10cSrcweir // (namely the FormController) relies on to notice that the control changed. 364cdf0e10cSrcweir // Instead, we use the Accessibility interfaces of the control to simulate text input 365cdf0e10cSrcweir XAccessible formattedAccessible = UnoRuntime.queryInterface( XAccessible.class, 366cdf0e10cSrcweir m_document.getCurrentView().getControl( controlModel ) 367cdf0e10cSrcweir ); 368cdf0e10cSrcweir XAccessibleEditableText textAccess = UnoRuntime.queryInterface( XAccessibleEditableText.class, 369cdf0e10cSrcweir formattedAccessible.getAccessibleContext() ); 370cdf0e10cSrcweir textAccess.setText( text ); 371cdf0e10cSrcweir } 372cdf0e10cSrcweir } 373