Pages: 1
Print
Author Topic: On_Document_Open_View not fired for DITA maps?  (Read 3541 times)
jperkins
Member

Posts: 11


« on: December 09, 2008, 10:20:31 AM »

First off, THANK YOU to JustSystems for setting up these forums!

I am trying to fire a script whenever any document is opened. The On_Document_Open_View event fires when I create a new DITA topic, but not when I create a new map. Is there another event, or any other method, that I can use to detect the creation of a new DITA map?

FYI, we're doing to to force new documents to be saved before any content is written. This ensures that any links to external content will be stored as relative URIs, which helps some of our downstream systems. If there is another way to achieve this without catching an event, that would be great too.

Thanks!

Jason Perkins
Jacquette Consulting
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1553



WWW
« Reply #1 on: December 09, 2008, 03:13:05 PM »

The map editor currently has no APIs (no events, no methods or properties) that you can tie into. It is a closed system and not open for customization at this time.

It sounds like your real issue is that links are not being made relative because users might not save a document before adding links to it (which you are trying to work around by forcing a save). We hope to correct this in the future so that saving a file (map or topic) before inserting a link should not be necessary.

I'm thinking some sort of url adjustment at save time would be the least intrusive but the solution hasn't been decided on yet so I cannot say exactly how it would function. One alternative would be to prompt the user to save before inserting anything containing an href or conref into an unsaved document, or do you think that would be too intrusive? Yet another option would be to force a save right after creating any new document (which is what you are proposing).

Note that whatever is decided on will likely have to take CMS integrations into account, and that might throw a wrench into solutions that might otherwise work when documents are stored only on a local file system.
« Last Edit: December 09, 2008, 03:14:58 PM by Derek Read » Logged
mag3737
XMetaL Evangelist
Administrator
Member

Posts: 100


I even use XMetaL to write my business letters.


« Reply #2 on: December 09, 2008, 03:54:07 PM »

As Derek mentions, the problem here really is that the map editor is kind of a closed system embedded within XMetaL, and so doesn't trigger any of the ordinary XMetaL events.

A workaround:  If you don't mind opening maps initially in "XML view", all the usual events will fire normally.

Even there, though, On_Document_Open_View, doesn't seem to fire for maps.  I'll ask about that.

Meanwhile, there are two other (undocumented) event macros that may be useful:

On_Application_Document_Open_View
On_Application_Document_Open_Complete

Both of these events fire in the XML view both for maps and topics.
Logged

Tom Magliery
JustSystems Canada, Inc.
ghkrause
Member

Posts: 62


« Reply #3 on: December 09, 2008, 07:26:32 PM »

Qimonda developed its own XMetaL Author to Sharepoint integration prior to Justsystems. We prefer drag'n'drop to link images and topicrefs. (conref is in pilot use only as of today). Our macro waits for "On_Application_Document_Before_DropText" and checks if the URL is part of our repository. We drag from our CMS tab in resource manager or directly from IE window with Sharepoint file list.
In case the drop text is a filepath of concern it is made relative and inserted as @href together with image or topicref. Other attributes are set as well. We can drop topics and maps in maps. So this code might fit perfect for your maps while you do topics as you already started ?!
I enclose the code but it is without warranty as usual. Some CRCL functions might no longer be supported officially by Justsystems ...
PS: TOM is the nickname for our repository = TechDoc On MOSS.

* On_Application_Document_Before_DropText.zip (1.33 KB - downloaded 117 times.)
Logged

Gunnar H. Krause, TechDoc Manager, Nuremberg Area, Germany
mag3737
XMetaL Evangelist
Administrator
Member

Posts: 100


I even use XMetaL to write my business letters.


« Reply #4 on: December 09, 2008, 07:52:35 PM »

PS: TOM is the nickname for our repository = TechDoc On MOSS.

:-)

Thanks for the posting Gunnar!
Logged

Tom Magliery
JustSystems Canada, Inc.
jperkins
Member

Posts: 11


« Reply #5 on: December 10, 2008, 06:54:34 AM »

Thanks for the responses, everyone! It sounds like there is no simple answer, at least not currently. The drag-and-drop approach sounds interesting, I will take a look at that. And I'll poke around the scripts and see if I can find a place to throw a hook. Thanks again!
Logged
jperkins
Member

Posts: 11


« Reply #6 on: December 16, 2008, 09:43:33 AM »

I managed to display the Save As... dialog automatically for new maps by editing DITA\MAPMANAGER\js\DitaMapHandler.js:

DITAMapHandler.prototype.initFromString = function (filePath, mapAsString, resourceLocator) {
  // ...body of function is unchanged
  this.SaveMap();
}

Not ideal, but it works. If anyone has any advice on a cleaner way to implement this, especially if it can be put in a customization macro, it would be much appreciated.

Thanks!
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1553



WWW
« Reply #7 on: December 18, 2008, 12:24:59 PM »

I managed to display the Save As... dialog automatically for new maps by editing DITA\MAPMANAGER\js\DitaMapHandler.js

Hacking the code like this is likely the only way to do this until we implement a supported method for clients to officially change the DITA functionality.
Logged
Pages: 1
Print
Jump to:  

email us