XPropertySetInfo propertyInfo = textFieldModel.getPropertySetInfo();
assure( "Per service definition, dynamic properties are expected to be forced to be removable",
( propertyInfo.getPropertyByName("SomeBoundText").Attributes & PropertyAttribute.REMOVABLE ) != 0 );
// a second addition of a property with an existent name should be rejected boolean caughtExpected = false; try { propContainer.addProperty( "SomeBoundText", PropertyAttribute.BOUND, "InitialBoundText" ); } catch( PropertyExistException e ) { caughtExpected = true; } catch( Exception e ) { }
assure( "repeated additions of a property with the same name should be rejected",
caughtExpected );
// check whether the properties are bound as expected
impl_checkPropertyValueNotification( textFieldModel );
// check property value persistence
impl_checkPropertyPersistence();
}
_controlModel.setPropertyValue( "SomeBoundText", "ChangedBoundText" );
assure( "changes in the bound property are not properly notified",
m_propertyChangeEvent.PropertyName.equals( "SomeBoundText" )
&& m_propertyChangeEvent.OldValue.equals( "InitialBoundText" )
&& m_propertyChangeEvent.NewValue.equals( "ChangedBoundText" ) );
m_propertyChangeEvent = null;
_controlModel.setPropertyValue( "SomeTransientText", "ChangedTransientText" );
assure( "changes in non-bound properties should not be notified",
m_propertyChangeEvent == null );
boolean caughtExpected = false; try { _controlModel.setPropertyValue( "SomeReadonlyText", "ChangedReadonlyText" ); } catch( PropertyVetoException e ) { caughtExpected = true; } catch( Exception e ) { }
assure( "trying to write a read-only property did not give the expected result",
caughtExpected );
_controlModel.removePropertyChangeListener( "", this );
}
/* ------------------------------------------------------------------ */ privatevoid impl_checkPropertyPersistence() throws com.sun.star.uno.Exception
{ // store the document
XStorable store = UnoRuntime.queryInterface( XStorable.class, m_document.getDocument() );
String documentURL = util.utils.getOfficeTemp( m_orb ) + "document.odt";
PropertyValue[] storeArguments = new PropertyValue[] { new PropertyValue() };
storeArguments[0].Name = "FilterName";
storeArguments[0].Value = "writer8";
store.storeAsURL( documentURL, storeArguments );
// all persistent properties should have the expected values
assure( "persistent properties did not survive reload (1)!", ((String)textFieldModel.getPropertyValue( "SomeBoundText" )).equals( "ChangedBoundText" ) );
assure( "persistent properties did not survive reload (2)!", ((String)textFieldModel.getPropertyValue( "SomeReadonlyText" )).equals( "InitialReadonlyText" ) ); // assure( "persistent properties did not survive reload (3)!", ((Integer)textFieldModel.getPropertyValue( "SomeNumericValue" )).equals( Integer.valueOf( 42 ) ) ); // cannot check this until the types really survive - at the moment, integers are converted to doubles...
// the transient property should not have survived boolean caughtExpected = false; try { textFieldModel.getPropertyValue( "SomeTransientText" ); } catch( UnknownPropertyException e ) { caughtExpected = true; }
assure( "transient property did survive reload!", caughtExpected );
// There would be more things to check. // For instance, it would be desirable of the property attributes would have survived // the reload, and the property defaults (XPropertyState). // However, the file format currently doesn't allow for this, so those information // is lost when saving the document.
}
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.