/* ------------------------------------------------------------------ */
@Override public String getTestObjectName()
{ return"Form Control Spreadsheet Cell Binding Test";
}
/* ------------------------------------------------------------------ */ publicvoid before() throws java.lang.Exception
{ // create the document and assign related members
XMultiServiceFactory orb = param.getMSF();
m_document = new XMLDocument( orb );
m_formLayer = new FormLayer( m_document );
// create a simple structure in the DOM tree: an element with two attributes
String[] modelNames = m_document.getXFormModelNames();
m_defaultModel = m_document.getXFormModel( modelNames[0] ); final Instance defaultInstance = m_defaultModel.getDefaultInstance(); // remove the default root node
defaultInstance.removeNode( "instanceData" ); // create test structures
XNode stringElement = defaultInstance.createElement( "stringElement" );
XNode booleanAttrib = defaultInstance.createAttribute( stringElement, "booleanAttribute", "true" );
XNode dateAttrib = defaultInstance.createAttribute( stringElement, "dateAttribute" );
assure( "booleanAttrib's parent is wrong",
UnoRuntime.areSame( stringElement, booleanAttrib.getParentNode() ) );
assure( "dateAttrib's parent is wrong",
UnoRuntime.areSame( stringElement, dateAttrib.getParentNode() ) );
// also create bindings for the element and its attributes, of the proper type
m_stringBinding = m_defaultModel.createBindingForNode( stringElement, DataTypeClass.STRING );
m_booleanBinding = m_defaultModel.createBindingForNode( booleanAttrib, DataTypeClass.BOOLEAN );
m_dateBinding = m_defaultModel.createBindingForNode( dateAttrib, DataTypeClass.DATE );
// TODO: set up the bindings so that the date bindings is relevant if and only if // the boolean value is true
// store the document
File tempFile = File.createTempFile( "xmlforms", ".odt" );
tempFile.deleteOnExit();
String fileURL = tempFile.toURI().toURL().toExternalForm();
XStorable store = UnoRuntime.queryInterface( XStorable.class,
m_document.getDocument() );
store.storeAsURL( fileURL, new PropertyValue[] {} );
assure( "document still modified after saving it", !m_document.isModified() );
}
// ensure the model is set up as containing "document-internal" data
m_defaultModel.setIsDocumentInternalData( true );
assure( "setting up the document to contain 'internal data' failed",
m_defaultModel.getIsDocumentInternalData() );
impl_storeDocument();
// okay, here we go ... // what this particular test is about is to check whether we can set up the model // so that any changes to any controls bound to any data in this model actually marks // the containing document as modified
m_formLayer.userTextInput( stringControl, "don't break this test" );
assure( "model data changed, but document is not modified",
m_document.isModified() );
// TODO: do this with the other control/binding types, too
// no the other way round: set up the model to contain "document-external" data
m_defaultModel.setIsDocumentInternalData( false );
assure( "setting up the document to contain 'internal data' failed",
!m_defaultModel.getIsDocumentInternalData() );
impl_storeDocument();
// and check that now, changes in the controls / model data are not reflected in // document's modified state
m_formLayer.userTextInput( stringControl, "(or any other test, that is)" );
assure( "model data changed, but document is modified",
!m_document.isModified() );
// finally, check whether the flag survives loading and saving
Model internalDataModel = m_document.addXFormModel( "internalData" );
internalDataModel.setIsDocumentInternalData( true );
Model externalDataModel = m_document.addXFormModel( "externalData" );
externalDataModel.setIsDocumentInternalData( false );
assure( "setting up a model to contain 'internal data' did not survive reloading",
internalDataModel.getIsDocumentInternalData() );
assure( "setting up a model to contain 'external data' did not survive reloading",
!externalDataModel.getIsDocumentInternalData() );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.