Track Changes exist in the document

Oxygen general issues.
guna@ebscohost.com
Posts: 27
Joined: Tue Nov 17, 2009 10:16 pm

Track Changes exist in the document

Post by guna@ebscohost.com »

Hi,
Is there a way through api call to check, whether the existing xml document contains any tracking changes?



i checked AuthorChangeTrackingController.isTrackingChanges() method, it return true only when i check track changes is enabled in the editor.
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: Track Changes exist in the document

Post by Radu »

Hi,

The AuthorChangeTrackingController for the moment only contains API to toggle change tracking On and Off (the same action which is available on the toolbar).

There is a workaround which you can use:

Code: Select all


    AuthorElement rootElement = authorAccess.getDocumentController().getAuthorDocumentNode().getRootElement();
boolean isTrackChanges = authorAccess.getChangeTrackingController().isTrackingChanges();
if(isTrackChanges){
//Toggle change tracking off so that the created document fragment contains all changes
authorAccess.getChangeTrackingController().toggleTrackChanges();
}
//The document fragment contains all track changes if change tracking is OFF.
AuthorDocumentFragment frag = authorAccess.getDocumentController().createDocumentFragment(rootElement, true);
boolean hasChanges = frag.getChangeMarks() != null && frag.getChangeMarks().size() > 0;
if(isTrackChanges){
//Toggle change tracking on again if this is the case
authorAccess.getChangeTrackingController().toggleTrackChanges();
}
Can you give us more details? Are there any more interactions which you want to make with the change tracking system?
Maybe we can improve the API to accommodate them.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
guna@ebscohost.com
Posts: 27
Joined: Tue Nov 17, 2009 10:16 pm

Re: Track Changes exist in the document

Post by guna@ebscohost.com »

Hi Radu,
the above code dose on work in below mentioned scenario, can you help us to detect track changes in this scenario.

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//EBSCO Publishing//DTD epNLM Editing v1.0//EN" "epnlm-edit.dtd">
<?oxy_insert_start author="CCC" timestamp="20100819T165450-0400"?>
<!--Test -->
<?oxy_insert_end?>
<article article-type="DynaDiseaseSummary" dtd-version="2.3" xml:lang="en">
<front>
</front>
<body>
</body>
</article>
Thanks
Guna
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: Track Changes exist in the document

Post by Radu »

Hi Guna,

The code I gave you works only for change tracking highlights located inside the root element (the document fragment is created over the root element). As in your case the highlight is outside the root element, the code does not work.
To make the code work also outside the root element you can create the document fragment like:

Code: Select all


 boolean isTrackChanges = authorAccess.getChangeTrackingController().isTrackingChanges();
if(isTrackChanges){
//Toggle change tracking off so that the created document fragment contains all changes
authorAccess.getChangeTrackingController().toggleTrackChanges();
}
//The document fragment contains all track changes if change tracking is OFF.
AuthorDocument doc = authorAccess.getDocumentController().getAuthorDocumentNode();
AuthorDocumentFragment frag = authorAccess.getDocumentController().createDocumentFragment(doc.getStartOffset() + 1, doc.getEndOffset() - 1);
boolean hasChanges = frag.getChangeMarks() != null && frag.getChangeMarks().size() > 0;
if(isTrackChanges){
//Toggle change tracking on again if this is the case
authorAccess.getChangeTrackingController().toggleTrackChanges();
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply