Hi Jacob,

as far as I know, you can only get the filter (or URL) after the document is saved, using the "OnSaveAsDone" event. What may be possible is reacting to that event, change the document and save again. This will lead to a recursion, because the 2nd save will trigger the listener again.

Don't know if there is a simpler solution.

Here's some sample code anyway (without handling the recursion!):


public void notifyEvent(EventObject event) {
  if (event.EventName.equals("OnSaveAsDone")) {
      XModel xModel = (XModel)
        UnoRuntime.queryInterface(XModel.class, event.Source);

      PropertyValue[] props = xModel.getArgs();
      for (int i = 0; i < props.length; i++) {

        // still have to check the props[i].Value for the right filter
        if ("FilterName".equals(props[i].Name)) {

          // get the document for changing...
          XTextDocument xTextDocument = (XTextDocument)
            UnoRuntime.queryInterface(XTextDocument.class, xModel);

          // store again and enter this method again
          // -> never ending recursion!
          XStorable xStorable = (XStorable)UnoRuntime.queryInterface(
            XStorable.class, xTextDocument);
          xStorable.storeAsURL(xModel.getURL(),
            new PropertyValue[0]);
        }
      }
    }
  }



Jakob Lechner wrote:
Hello,

I want my UNO component to modify a text document just before it's
saved. Therefore I've used an EventListener in order to get notified
about the "OnSaveAs" event. Does anybody know how I can retrieve the new
filename of the document? I want to modify the document if and only if
it is saved as html document.

Thanks in advance!
Best regards

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

Reply via email to