Implementing Smart Paste for my own document type

Post here questions and problems related to oXygen frameworks/document types.
yann1806
Posts: 22
Joined: Fri Aug 09, 2013 11:03 am

Implementing Smart Paste for my own document type

Post 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
yann1806
Posts: 22
Joined: Fri Aug 09, 2013 11:03 am

Re: Implementing Smart Paste for my own document type

Post 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 :-)
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Implementing Smart Paste for my own document type

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply