ObeoNetwork / M2Doc

The M2Doc technology enables the generation of Office Open XML documents from models.
http://obeonetwork.github.io/M2Doc/
Eclipse Public License 2.0
38 stars 22 forks source link

Size of image for an empty representation is way too big #501

Closed vrichard12 closed 11 months ago

vrichard12 commented 11 months ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please have a look to the support pages of our website : http://m2doc.org/support/

Current behavior

When generating a document for a template inserting representation images with the service EObject.asImageByRepresentationDescriptionName(String), the generated images are way too big. M2Doc generates a 829x4974 image when the"Size of exported images" preference is set to maximum and a 20x120 image when the preference is set to minimum. Changing this preference doesn't constitute a workaround as usually the call to asImageByRepresentationDescriptionName is followed by something like .setConserveRatio(true).setWidth(450). The formatting of the resulting document is then very odd because a place bigger than a page is taken by this empty image. The vertical shape of the image doesn't help either using the setWidth service. This service makes sense when the image is not empty, but if it is then applying a .setConserveRatio(true).setWidth(450) makes a vertical image of 2700 pixels!

Expected behavior

Empty representations should be exported as very small and horizontal images, or if that is possible exported as nothing.

Minimal reproduction of the problem with instructions

Please see the attached M2DocEmptyDiagram M2Doc modeling project.

What is the motivation / use case for changing the behavior?

Testing that a representation is empty is possible with this query : representation.oclAsType(diagram::DSemanticDiagram).ownedDiagramElements->notEmpty() but it complexifies the writing of the templates. (By the way, for this query to work the following nsuris have to be added to the template properties: http://www.eclipse.org/sirius/1.1.0 and http://www.eclipse.org/sirius/diagram/1.1.0). The need is to make the writing of templates as simple as possible.

Environment


M2Doc version: 3.3.0
Eclipse version: OD Community 11.8
Platform version:  Linux and Windows            
vrichard12 commented 11 months ago

Here is a download link for the M2DocEmptyDiagram project.

ylussaud commented 11 months ago

I think you could do this if we implement the fit() service from this issue #473.

vrichard12 commented 11 months ago

Thank you Yvan, I think this is the best you can do from the M2Doc point of view. Generating a small image for empty diagrams should be seen with the Sirius team.

vrichard12 commented 11 months ago

I close this issue as the #473 is fixed.