insertFragment in AuthorMode is pretty

Post here questions and problems related to oXygen frameworks/document types.
andygraham
Posts: 3
Joined: Wed Aug 31, 2016 1:48 pm

insertFragment in AuthorMode is pretty

Post by andygraham »

Hi

I have a plugin which constructs a string containing XML with everything on one line. I insert it into a document using the following method:

AuthorDocumentFragment fragment = documentController.createNewDocumentFragmentInContext( xmlString, selection);
documentController.insertFragment(selection, fragment);

In Author mode everything looks fine but when I switch to text mode the inserted fragment is pretty printed while the rest of the document is not. I would like the fragment to appear in the document the way I created it in the string - all on the same line.

Any ideas?

Thanks
Andy
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: insertFragment in AuthorMode is pretty

Post by alex_jitianu »

Hi Andy,

When the Author page serializes its content, it automatically applies some pretty print rules. These rules can be controlled from the Author Preferences page. Once you arrive on this page, focus on the Compatibility with other tools section. if you select Do not break lines, do not indent, the entire document will be on one line. If this is more than you desire, then you can try going on the Format Preferences page and add a few elements in the Preserve space list. The contents of these elements are not formatted and will be serialized on one line.

Best regards,
Alex
andygraham
Posts: 3
Joined: Wed Aug 31, 2016 1:48 pm

Re: insertFragment in AuthorMode is pretty

Post by andygraham »

Hi Alex

Thanks a lot for your reply, that was really helpful.

Apologies for the delay in responding, initially we found another workaround with our own content but we have now been forced to adopt the solution you suggested. We are now programatically setting the compatibility option in our plugin, as follows:

Code: Select all

standalonePluginWorkspace.setGlobalObjectProperty("author.format.compatibility", 1);
My concern with this is that if the number of options for this property change, or the order of the properties in the drop down change, then setting this property to 1 will fail silently. Are there any plans to extend programmatic property setting to make it statically typed?

-Andy
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: insertFragment in AuthorMode is pretty

Post by alex_jitianu »

Hi Andy,

We have published this option in the API so, now, there is a constant that you can use: ro.sync.exml.options.APIAccessibleOptionTags.AUTHOR_FORMAT_COMPATIBILITY. Set the value to ro.sync.ecss.dom.builder.AuthorFormatCompatibilityModeConstants.FORMAT_COMPATIBILITY_DO_NOT_BREAK_LINES_DO_NO_INDENT.

Best regards,
Alex
Post Reply