To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=84491





------- Additional comments from [EMAIL PROTECTED] Mon Apr  7 15:33:39 +0000 
2008 -------
@sb:
As I understand the description of this issue, our Java code that calls
UnoRuntime.generateOid() will no longer compile, as will all other code written
to use that function.

If that is true, then it becomes impossible to put UNO components into hashable
containers (aside from the fact that breaks already deployed code), because as
the documention to UnoRuntime states

---
The methods generateOid, queryInterface and areSame delegate calls to the
implementing objects and are used instead of hashCode, casts, instanceof, ==,
and equals
---

generateOid() needs to be used instead of hashCode(). At least that's how I
understand the documentation. I don't remember ever seeing something that said
that the default hashCode() of 2 different proxies is guaranteed to be the same.
That's why so far we've used the following class:

public class HashableComponent
{
  private XInterface compo;
  public HashableComponent(Object compo)
  {
    this.compo = UNO.XInterface(compo);
    if (this.compo == null) throw new ClassCastException();
  }

  public int hashCode()
  {
    if (compo != null) return UnoRuntime.generateOid(compo).hashCode();
    return 0;
  }

  public boolean equals(Object b)
  {
    if (b != null && b instanceof HashableComponent)
    {
      HashableComponent other = (HashableComponent) b;
      return UnoRuntime.areSame(this.compo, other.compo);
    }
    return false;
  }
}

which is used like this

hashset.add(new HashableComponent(unoComponent))


If you're telling me that this is unnecessary and that every proxy of the same
UNO object will return the same hashcode, I'm happy. If you're telling me that
this is not the case, then we have a problem. We need to be able to tell if a
given proxy, no matter where it comes from refers to an object already processed
earlier or not. The only efficient way to do this is using hashes. The
alternative of using a list and going through the list sequentially with
areSame() checks is unacceptable. In one instance we're dealing with 100s, even
1000s of components (all the shapes in a 100+ page document constructed
incrementally).


---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

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


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

Reply via email to