Page 1 of 1

Implementing Smart Paste for my own document type

Posted: Wed Sep 11, 2013 8:25 am
by yann1806
Hi guys,

I have my own document type (based on an XSD schema); the schema includes html-style formatting tags for lists, bold, italics, paragraphs and such.

I'd like to implement smart paste so that docs from Word can retain this kind of formatting, but I'm not clear on whether I need to implement AuthorSchemaAwareEditingHandlerAdapter, or if there is a non-Java way of doing that? Maybe tweaks in the schema to allow the existing smart paste implementation to work?

Any lead / example / code sample welcome.

Thanks a lot,

Yannick

Re: Implementing Smart Paste for my own document type

Posted: Wed Sep 11, 2013 8:27 am
by yann1806
I forgot to mention that my schema aware preferences do have smart paste enabled, but it's not pasting smartly into my doc :-)

Re: Implementing Smart Paste for my own document type

Posted: Wed Sep 11, 2013 9:58 am
by Radu
Hi Yannick,

You would need to also write some Java code to handle this.

First of all, smart paste is based on the fact than when you copy content in an application like MS Word it also sets in the clipboard an HTML translation of the copied content. So Oxygen actually interprets this HTML content from the clipboard using XSLT stylesheets to convert it to its target XML vocabulary.

Let's discuss for example how smart pasting works in XHTML document type for example (as it is probably closer to what you need).
If in the Oxygen Preferences->Document Type Association page you edit the XHTML document type, in the Classpath list there are references to the xhtml.jar containing Java extensions and to a resources folder containing the XSLT stylesheets which are used for conversion. In the same dialog in the XHTMLExtensionsBundle tab there is an extension configured called XHTMLExtensionsBundle which is implemented in the xhtml.jar.

If you download our Author SDK:

http://www.oxygenxml.com/oxygen_sdk.htm ... horing_SDK

you will have in it the Java code for the XHTMLExtensionsBundle implementation.
That code instantiates a class called XHTMLExternalObjectInsertionHandler for which Java sources are also present. On the method XHTMLExternalObjectInsertionHandler.getImporterStylesheetFileName(AuthorAccess) the code returns xhtml2xhtml.xsl which means that this XSLT:

OXYGEN_INSTALL_DIR\frameworks\xhtml\resources\xhtml2xhtml.xsl

will be called to process the HTML content set in the clipboard by MS Word and return the translated XML content to be inserted at the caret position in the Author mode.

Regards,
Radu