General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion xmetal selection ReadonlyContainer value

  • Anonymous

    xmetal selection ReadonlyContainer value

    Participants 2
    Replies 3
    Last Activity 8 years, 11 months ago

    Hi all,
      I'm writing an addin for XMetaL(R) Author Essential 7.0. In order to implement a source control of our own from the XMetaL side, we need to set some elements Read-Only in the document, let's say, . I'm still not sure whether there is a normal way to do so.<br />  The first idea to solve this comes to my mind is that getting elements by tag name “title”, then select these elements using xmetal.selection, finally setting the selection.ReadOnlyContainer to true. But it doesn't work, for the reference to the selection will change. But I find something weird as below:</p> <p>for (int i = 0; i < elements.length; i++)<br />{<br />xmetalSelection.SelectNodeContents(elements.item(i));<br />xmetalSelection.ReadOnlyContainer = true;<br />xmetalSelection.NonRemovableContainer = true;<br />}</p> <p>I will call this for loop each time the document changes. Here is the problem, the first time I get the element title, its ReadOnlyContainer and NonRemovableContainer are false, they will be set as true; then I call this loop again, its NonRemovableContainer is true of course, but ReadOnlyContainer is false. My question is, if the selection changed, both its NonRemovableContainer and ReadOnlyContainer should change at the same time, they should be all false or all true. </p> <p>Hope someone can help solve this. It would be better if someone knows how to set a single element as Read-Only.

    Reply

    Derek Read

    Reply to: xmetal selection ReadonlyContainer value

    Having no idea what your document structures look like it is difficult to give the best answer.

    However, if there is only one in the document the following should do it. If not, then you would need to adjust appropriately. You may wish to use getNodesByXPath() if the document is complex (in which case you need to deal with DOM nodes and would need to  convert those to a Range before setting ReadOnlyContainer).</p> <p><tt>//XMetaL Script Language JScript:<br />var rng = ActiveDocument.Range;<br />rng.MoveToDocumentStart();<br />if(rng.MoveToElement("title")) {<br />  rng.ReadOnlyContainer = true;<br />  rng.NonRemovableContainer = true;<br />}</tt></p> <p>You say “the reference to the selection will change”. I'm not sure what you mean by that, but it sounds like maybe that is your issue. There is only ever one Selection object in a document, set by the user and possibly manipulated using script. Generally scripts use Range instead as you can have multiple Range objects, they are invisible, and they can go some places that a Selection cannot.

    Reply

    Derek Read

    Reply to: xmetal selection ReadonlyContainer value

    If you are building an integration with a CMS you may wish to contact our partner manager for information on the (JustSystems) officially sanctioned way to create an integration.

    Note that the SDK (which is primarily documentation because all the CMS integration APIs are built into XMetaL Author Enterprise) is usually shared with partners only (usually CMS partners).

    Reply

    rebornix

    Reply to: xmetal selection ReadonlyContainer value

    “rng.ReadOnlyContainer = true” works for me, thanks!

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support