See inline please:

Frank Schönheit - Sun Microsystems Germany wrote:
Hi,

in my opinion, one of the major drawbacks of the "new" interface
attributes over the long-existing service properties is the missing
possibility to listen for attribute changes.

That is, the XPropertySet interface has methods
add-/removePropertyChangeListener, which take the name of a property and
an XPropertyChangeListener interface. This is a very generic and
flexible way to listen for changes in certain facets of a component.

For interface attributes, there's the syntactic element to declare an
attribute as bound, but no common mechanism to make use of it. You
either need to re-use XPropertySet.add/removePropertyChangeListener (and
thus the whole XPropertySet) in your implementation, or introduce
dedicated, non-generic methods/listeners.

Just to clarify: "[attribute, bound]" is observable reflectively via com.sun.star.reflection, and used by the C++/Java PropertySetMixin helpers. I would strongly recommend to add "bound" to any attributes for which a change-notification mechanism shall be supported, be it XPropertySet, the proposed XAttributeChangeBroadcaster, or whatever.

My recent experience while designing new APIs is that the only reason
why I usually also include an XPropertySet is that it's the
only/fastest/generic way to allow for (property/attribute value) observers.

My suggestion now is to add something like the following:

namespace com { namespace sun { namespace star {
namespace beans {

  struct AttributeChangeEvent : com::sun::star::lang::EventObject
  {
    string  AttributeName;
    any     OldValue;
    any     NewValue;
  };

...don't want to restart the discussion that Old/NewValue are of no use here (<http://www.openoffice.org/servlets/ReadMsg?list=dev&msgId=360257>)...

  interface XAttributeChangeListener
  {
    [oneway] void attributeChanged( [in] AttributeChangeEvent _Event );

"_Event" etc. are not valid UNOIDL identifiers (even though idlc unfortunately does not complain in default mode); no leading underscores, please.

  };

  exception UnknownAttributeException: com::sun::star::uno::Exception
  {
    string AttributeName;
  };

  interface XAttributeChangeBroadcaster
  {
    void addAttributeChangeListener(
      [in] string _AttributeName,
      [in] XAttributeChangeListener _Listener
    )
      raises ( UnknownAttributeException );

    void removeAttributeChangeListener(
      [in] string _AttributeName,
      [in] XAttributeChangeListener _Listener
    )
      raises ( UnknownAttributeException );
  };

}
} } }

The semantics of all those would be similar to the semantics of the
respective *PropertyChange* structs/interfaces, so I omitted the
documentation here for the moment.

Every interface which declares bound attributes could then additionally
inherit from XAttributeChangeBroadcaster, and thus offer its clients a
standardized way to be notified of attribute changes.

(Note that as a generalization, one could also imagine introducing
vetoable attributes, but for the moment, I think the above would be a
very useful first step.)

Opinions?

Ciao
Frank

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to