Page 1 of 1
ExtensionsBundle Implementation
Posted: Wed Nov 20, 2013 11:11 am
by sebastienlavandier
Hi,
I need to implement a StyleFilter which must used an AuthorAccess. So, for do that I implemented an CustomExtensionsBundle which extend ExtensionsBundle.
Code: Select all
public class CustomExtensionBundle extends ExtensionsBundle {
private CustomAuthorExtensionStateListener extensionStateListener = new CustomAuthorExtensionStateListener ();
@Override
public String getDocumentTypeID() {
return "Document type ID";
}
@Override
public String getDescription() {
return "Description";
}
@Override
public ro.sync.exml.editor.xmleditor.pageauthor.AuthorDnDListener createAuthorAWTDndListener() {
return new DragNDropListener();
}
@Override
public StylesFilter createAuthorStylesFilter() {
return new CustomStylesFilter(extensionStateListener);
}
@Override
public AuthorExtensionStateListener createAuthorExtensionStateListener() {
return extensionStateListener;
}
}
This CustomExtensionsBundle instantiate a CustomStylesFilter (which implements StylesFilter) and an AuthorExtensionStateListener (which implements AuthorExtensionStateListener, AuthorAccessProvider).
The Only one reference about this CustomExtensionsBundle is in my .framework file.
Code: Select all
<field name="extensionsBundleClassName">
<String>com.miyCompany.extensionBundle.CustomExtensionBundle</String></field>
But the CustomExtensionBundle is instanciate twice, and I don't understand why.
Do you have an idea about it ?
Thanks in advance for your answer.
Sébastien
Re: ExtensionsBundle Implementation
Posted: Wed Nov 20, 2013 11:41 am
by alex_jitianu
Hi Sebastien,
We are aware that the ExtensionsBundle gets instantiated twice on document load and we already have added an issue to fix it. We also have an issue registered to provide the StylesFilter with an AuthorAccess instance. Meanwhile, if you want an AuthorAccess instance in the StylesFilter you can get one like this:
Code: Select all
WSEditor editorAccess =
PluginWorkspaceProvider.getPluginWorkspace().getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA);
if (editorAccess != null) {
WSEditorPage currentPage = editorAccess.getCurrentPage();
if (currentPage instanceof WSAuthorEditorPage) {
AuthorAccess authorAccess = ((WSAuthorEditorPage) currentPage).getAuthorAccess();
}
}
Best regards,
Alex
Re: ExtensionsBundle Implementation
Posted: Thu Nov 21, 2013 11:06 am
by alex_jitianu
Hi Sebastien,
I'm just curious, why you need an AuthorAccess object in a StylesFilter? What's the use case?
Best regards,
Alex
Re: ExtensionsBundle Implementation
Posted: Thu Nov 21, 2013 1:28 pm
by sebastienlavandier
Hi,
We work with CGM/TIFF illustrations format files in our xml documents, so we need to convert this to SVG format.
When our CustomStyleFilter found an illustration element node Ex:<GRAPHIC>, it must access to the DOCTYPE to find the illustration's filename. And for read the Doctype, we must used : authorAccess.getDocumentController().getDoctype();
With the fileName, we can convert the CGM, or TIF file to SVG.
Do you have a solution without AuhtorAcces ?
Thanks in advance.
Sébastien
Re: ExtensionsBundle Implementation
Posted: Thu Nov 21, 2013 2:34 pm
by Radu
Hi Sébastien,
How exactly does the graphic refer the image? If you are using unparsed entity references you could use the API
Code: Select all
ro.sync.ecss.extensions.api.AuthorDocumentController.getUnparsedEntityUri(AuthorNode, String)
Regards,
Radu
Re: ExtensionsBundle Implementation
Posted: Thu Nov 21, 2013 5:09 pm
by sebastienlavandier
Hi,
Unfortunately in the Style Filter, we have only Styles and AuthorNode
Code: Select all
public Styles filter(Styles styles, AuthorNode authorNode)
.
To use the AuthorDocumentController, we need the AuthorAccess too.
Sébastien
Re: ExtensionsBundle Implementation
Posted: Mon Nov 25, 2013 11:10 am
by Radu
Hi Sébastien,
I understand, we'll see how we can improve the StylesFilter API in a future version. In the meantime you can use Alex's workaround code.
Regards,
Radu
Re: ExtensionsBundle Implementation
Posted: Mon Nov 25, 2013 11:18 am
by Radu
By the way, if you just want to show an image referenced via an unparsed entity you can also do this via the CSS:
http://www.oxygenxml.com/doc/ug-oxygen/ ... ction.html
Regards,
Radu
Re: ExtensionsBundle Implementation
Posted: Mon Nov 25, 2013 12:33 pm
by sebastienlavandier
Hi,
We already use oxy_unparsed-entity-uri for all supported image file extension by Oxygen. But for the CGM files we don't have solution if we can't use the styleFilter with AuthorAcces.
We are waiting the next version ...
have a nice day.
Sébastien.
Re: ExtensionsBundle Implementation
Posted: Mon Nov 25, 2013 1:32 pm
by Radu
Hi Sébastien,
It's important when asking advice to give more details about the use case, maybe your specific problem can be solved not necessarily using a certain API but by taking a different approach.
I thing you have several other choices, haven't tested them thoroughly but they might work.
Let's say that the CSS is something like:
Code: Select all
imagedata[entityref]{
content: oxy_url(oxy_unparsed-entity-uri(attr(entityref)));
}
First approach:
In the StylesFilter implementation you received a pre-computed Styles object which on the method
Styles.getMixedContent() will return an array containing an
ro.sync.ecss.css.URIContent pointing to the CGM image. The
URIContent.getCatalogExpandedURL() already has the reference to the CGM properly computed going through the unparsed URI mappings. So you could take this URL and create another URIContent object by changing the extension to point to an SVG image instead.
Second approach:
Without any StylesFilter, Oxygen uses the usual Swing libraries to load images, and you can implement a Swing "ImageIO" plugin for CGM images. This plugin would be packed in a JAR which would need to be in the component's class path.
Third approach:
In the CSS you could have something like:
Code: Select all
imagedata[entityref]{
content: oxy_url(oxy_replace(oxy_unparsed-entity-uri(attr(entityref)), '.cgm', '.svg'));
}
By the way, do you use an open source converter for CGM to SVG? We are interested in having better CGM support in Oxygen. Do you know any details about how the XML referencing CGM gets published? If it gets published to HTML does the CGM support need to have an ActiveX control installed in IE in order to show the CGM properly?
Regards,
Radu
Re: ExtensionsBundle Implementation
Posted: Thu Dec 05, 2013 4:51 pm
by Radu
Hi Sébastien,
Have you tried any of the workarounds I gave you?
Regards,
Radu