General XMetaL Discussion
Anonymous October 12, 2013 at 1:58 am
xmetal selection ReadonlyContainer valueOctober 12, 2013 at 1:58 amParticipants 2Replies 3Last Activity 9 years, 3 months ago
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.
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:
for (int i = 0; i < elements.length; i++)
xmetalSelection.ReadOnlyContainer = true;
xmetalSelection.NonRemovableContainer = true;
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.
Hope someone can help solve this. It would be better if someone knows how to set a single element as Read-Only.Derek Read October 15, 2013 at 8:24 pm
Reply to: xmetal selection ReadonlyContainer valueOctober 15, 2013 at 8:24 pm
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).
//XMetaL Script Language JScript:
var rng = ActiveDocument.Range;
rng.ReadOnlyContainer = true;
rng.NonRemovableContainer = true;
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.Derek Read October 15, 2013 at 8:28 pm
Reply to: xmetal selection ReadonlyContainer valueOctober 15, 2013 at 8:28 pm
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).rebornix October 17, 2013 at 1:34 am
Reply to: xmetal selection ReadonlyContainer valueOctober 17, 2013 at 1:34 am
“rng.ReadOnlyContainer = true” works for me, thanks!
- You must be logged in to reply to this topic.