diff --git a/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/M2DocSiriusUtils.java b/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/M2DocSiriusUtils.java index 65090875f..ef195dc57 100644 --- a/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/M2DocSiriusUtils.java +++ b/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/M2DocSiriusUtils.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2017, 2024 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ package org.obeonetwork.m2doc.sirius; /** @@ -22,6 +32,16 @@ public final class M2DocSiriusUtils { */ public static final String SIRIUS_FORCE_REFRESH = "SiriusForceRefresh"; + /** + * The Sirius scale policy option. + */ + public static final String SIRIUS_SCALING_POLICY = "SiriusScalingPolicy"; + + /** + * The Sirius scale level option. + */ + public static final String SIRIUS_SCALE_LEVEL = "SiriusScaleLevel"; + /** * Constructor. */ diff --git a/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/services/M2DocSiriusServices.java b/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/services/M2DocSiriusServices.java index f487bc728..e1fc313fc 100644 --- a/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/services/M2DocSiriusServices.java +++ b/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/services/M2DocSiriusServices.java @@ -45,6 +45,7 @@ import org.eclipse.sirius.table.metamodel.table.description.TableDescription; import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager; import org.eclipse.sirius.ui.business.api.dialect.ExportFormat; +import org.eclipse.sirius.ui.business.api.dialect.ExportFormat.ScalingPolicy; import org.eclipse.sirius.ui.tools.api.actions.export.SizeTooLargeException; import org.eclipse.sirius.viewpoint.DRepresentation; import org.eclipse.sirius.viewpoint.DRepresentationDescriptor; @@ -73,6 +74,9 @@ public class M2DocSiriusServices { */ private static final String JPG = "JPG"; + /** + * The {@link Set} of valid {@link ImageFileFormat} {@link ImageFileFormat#getName() names}. + */ private static final Set VALID_IMAGE_FORMATS = initializeValidImageFormats(); /** @@ -131,6 +135,16 @@ public void clean(Object key) { */ private final boolean forceRefresh; + /** + * The {@link ScalingPolicy} for diagram image export. + */ + private final ScalingPolicy scalingPolicy; + + /** + * The scale level for the diagram image export. + */ + private final Integer scaleLevel; + /** * The {@link CleaningJobRegistry}. */ @@ -168,8 +182,26 @@ public void clean(Object key) { * * @param session * the Sirius {@link Session} + * @param forceRefresh + * for the refresh of diagarms before image export */ public M2DocSiriusServices(Session session, boolean forceRefresh) { + this(session, forceRefresh, ScalingPolicy.WORKSPACE_DEFAULT, null); + } + + /** + * Constructor. + * + * @param session + * the Sirius {@link Session} + * @param forceRefresh + * for the refresh of diagarms before image export + * @param scalingPolicy + * the {@link ScalingPolicy} for diagram image export + * @param scaleLevel + * the scale level for diagram image export + */ + public M2DocSiriusServices(Session session, boolean forceRefresh, ScalingPolicy scalingPolicy, Integer scaleLevel) { this.session = session; this.uriConverter = session.getTransactionalEditingDomain().getResourceSet().getURIConverter(); this.forceRefresh = forceRefresh; @@ -179,6 +211,8 @@ public M2DocSiriusServices(Session session, boolean forceRefresh) { } else { shouldCloseSession = false; } + this.scalingPolicy = scalingPolicy; + this.scaleLevel = scaleLevel; } private static Set initializeValidImageFormats() { @@ -492,7 +526,7 @@ protected MImage internalAsImage(final DRepresentation representation, String fo throw new IllegalArgumentException(format + " is not a valide format: " + validFormatString); } final ExportFormat exportFormat = new ExportFormat(ExportFormat.ExportDocumentFormat.NONE, - ImageFileFormat.resolveImageFormat(format)); + ImageFileFormat.resolveImageFormat(format), scalingPolicy, scaleLevel); final File tmpFile = File.createTempFile(sanitize(representation.getName()) + "-m2doc", "." + format.toLowerCase()); tmpFiles.add(tmpFile); diff --git a/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/services/configurator/SiriusServiceConfigurator.java b/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/services/configurator/SiriusServiceConfigurator.java index a88a54591..9a609bb53 100644 --- a/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/services/configurator/SiriusServiceConfigurator.java +++ b/plugins/org.obeonetwork.m2doc.sirius/src/org/obeonetwork/m2doc/sirius/services/configurator/SiriusServiceConfigurator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2023 Obeo. + * Copyright (c) 2017, 2024 Obeo. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -11,6 +11,7 @@ package org.obeonetwork.m2doc.sirius.services.configurator; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -43,6 +44,7 @@ import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.business.api.session.SessionManager; import org.eclipse.sirius.business.internal.session.SessionTransientAttachment; +import org.eclipse.sirius.ui.business.api.dialect.ExportFormat.ScalingPolicy; import org.eclipse.ui.PlatformUI; import org.obeonetwork.m2doc.genconf.GenconfUtils; import org.obeonetwork.m2doc.services.configurator.IServicesConfigurator; @@ -92,6 +94,8 @@ private static List initOptions() { res.add(M2DocSiriusUtils.SIRIUS_SESSION_OPTION); res.add(M2DocSiriusUtils.SIRIUS_FORCE_REFRESH); + res.add(M2DocSiriusUtils.SIRIUS_SCALING_POLICY); + res.add(M2DocSiriusUtils.SIRIUS_SCALE_LEVEL); return res; } @@ -239,7 +243,20 @@ public Set getServices(IReadOnlyQueryEnvironment queryEnvironment, Res if (URIConverter.INSTANCE.exists(sessionURI, Collections.emptyMap())) { final Session session = SessionManager.INSTANCE.getSession(sessionURI, new NullProgressMonitor()); final boolean forceRefresh = Boolean.valueOf(options.get(M2DocSiriusUtils.SIRIUS_FORCE_REFRESH)); - final M2DocSiriusServices serviceInstance = new M2DocSiriusServices(session, forceRefresh); + final ScalingPolicy scalingPolicy; + if (options.containsKey(M2DocSiriusUtils.SIRIUS_SCALING_POLICY)) { + scalingPolicy = ScalingPolicy.valueOf(options.get(M2DocSiriusUtils.SIRIUS_SCALING_POLICY)); + } else { + scalingPolicy = ScalingPolicy.WORKSPACE_DEFAULT; + } + final Integer scaleLevel; + if (options.containsKey(M2DocSiriusUtils.SIRIUS_SCALE_LEVEL)) { + scaleLevel = Integer.valueOf(options.get(M2DocSiriusUtils.SIRIUS_SCALE_LEVEL)); + } else { + scaleLevel = null; + } + final M2DocSiriusServices serviceInstance = new M2DocSiriusServices(session, forceRefresh, + scalingPolicy, scaleLevel); res.addAll(ServiceUtils.getServices(queryEnvironment, serviceInstance)); services.put(queryEnvironment, serviceInstance); } @@ -285,7 +302,7 @@ public Map> validate(IReadOnlyQueryEnvironment queryEnv "The Sirius session doesn't exist: " + sessionURI.toString(), new Object[] {sessionURI})); } } - final String forceRefreshStr = options.get(M2DocSiriusUtils.SIRIUS_SESSION_OPTION); + final String forceRefreshStr = options.get(M2DocSiriusUtils.SIRIUS_FORCE_REFRESH); if (forceRefreshStr != null) { final List diagnostics = new ArrayList<>(); res.put(M2DocSiriusUtils.SIRIUS_FORCE_REFRESH, diagnostics); @@ -296,6 +313,44 @@ public Map> validate(IReadOnlyQueryEnvironment queryEnv new Object[] {forceRefreshStr})); } } + final String scalePolicyStr = options.get(M2DocSiriusUtils.SIRIUS_SCALING_POLICY); + if (!isValidScalePolicy(scalePolicyStr)) { + final List diagnostics = new ArrayList<>(); + res.put(M2DocSiriusUtils.SIRIUS_SCALING_POLICY, diagnostics); + diagnostics.add(new BasicDiagnostic( + Diagnostic.ERROR, M2DocSiriusUtils.PLUGIN_ID, 0, "The Sirius scale policy must be one of " + + Arrays.toString(ScalingPolicy.values()) + ": " + scalePolicyStr, + new Object[] {scalePolicyStr})); + } + final String scaleLevelStr = options.get(M2DocSiriusUtils.SIRIUS_SCALE_LEVEL); + try { + Integer.valueOf(scaleLevelStr); + } catch (NumberFormatException e) { + final List diagnostics = new ArrayList<>(); + res.put(M2DocSiriusUtils.SIRIUS_SCALE_LEVEL, diagnostics); + diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR, M2DocSiriusUtils.PLUGIN_ID, 0, + "The Sirius scale level must be an integer: " + scalePolicyStr, new Object[] {scaleLevelStr})); + } + + return res; + } + + /** + * Tells if the given scale policy {@link String} is a valid {@link ScalingPolicy}. + * + * @param scalePolicyStr + * the scale policy {@link String} + * @return true if the given scale policy {@link String} is a valid {@link ScalingPolicy}, false otherwise + */ + private boolean isValidScalePolicy(String scalePolicyStr) { + boolean res = false; + + for (ScalingPolicy policy : ScalingPolicy.values()) { + if (policy.name().equals(scalePolicyStr)) { + res = true; + break; + } + } return res; } diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/META-INF/MANIFEST.MF b/tests/org.obeonetwork.m2doc.sirius.tests/META-INF/MANIFEST.MF index 8d8b1526a..077f36126 100644 --- a/tests/org.obeonetwork.m2doc.sirius.tests/META-INF/MANIFEST.MF +++ b/tests/org.obeonetwork.m2doc.sirius.tests/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.junit, org.obeonetwork.m2doc.sirius;bundle-version="[3.0.0,4.0.0)", + org.eclipse.sirius.ui;bundle-version="[6.5.1,7.5.0)", org.obeonetwork.m2doc;bundle-version="[3.0.0,4.0.0)", org.eclipse.core.runtime, org.obeonetwork.m2doc.genconf;bundle-version="[3.0.0,4.0.0)", diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/anydsl.ecore b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/anydsl.ecore new file mode 100644 index 000000000..ad603845a --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/anydsl.ecore @@ -0,0 +1,167 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-expected-ast.txt b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-expected-ast.txt new file mode 100644 index 000000000..3569824ca --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-expected-ast.txt @@ -0,0 +1,13 @@ + +=== HEADER === + + +=== BODY === + + This demonstrate the simple usage of representationByName serviceĀ : + [query: .fit(.asImage(.representationByName('anydsl class diagram'), 'JPG'), 400, 400)] + End of demonstration. +=== FOOTER === + + +=== TEMPLATES === \ No newline at end of file diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-expected-generation-messages.txt b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-expected-generation-messages.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-expected-generation.docx b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-expected-generation.docx new file mode 100644 index 000000000..8e890d4ae Binary files /dev/null and b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-expected-generation.docx differ diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-expected-validation.docx b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-expected-validation.docx new file mode 100644 index 000000000..e69de29bb diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-template.docx b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-template.docx new file mode 100644 index 000000000..345e25c53 Binary files /dev/null and b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG-template.docx differ diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG.aird b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG.aird new file mode 100644 index 000000000..94370dbd5 --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG.aird @@ -0,0 +1,1386 @@ + + + + anydsl.ecore + http://www.eclipse.org/emf/2002/Ecore + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG.genconf b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG.genconf new file mode 100644 index 000000000..83489df0e --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/asImageJPG.genconf @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/description/ecore.odesign b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/description/ecore.odesign new file mode 100644 index 000000000..48b964402 --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel1/asImageJPG/description/ecore.odesign @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/anydsl.ecore b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/anydsl.ecore new file mode 100644 index 000000000..ad603845a --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/anydsl.ecore @@ -0,0 +1,167 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-expected-ast.txt b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-expected-ast.txt new file mode 100644 index 000000000..3569824ca --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-expected-ast.txt @@ -0,0 +1,13 @@ + +=== HEADER === + + +=== BODY === + + This demonstrate the simple usage of representationByName serviceĀ : + [query: .fit(.asImage(.representationByName('anydsl class diagram'), 'JPG'), 400, 400)] + End of demonstration. +=== FOOTER === + + +=== TEMPLATES === \ No newline at end of file diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-expected-generation-messages.txt b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-expected-generation-messages.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-expected-generation.docx b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-expected-generation.docx new file mode 100644 index 000000000..95de9de40 Binary files /dev/null and b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-expected-generation.docx differ diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-expected-validation.docx b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-expected-validation.docx new file mode 100644 index 000000000..e69de29bb diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-template.docx b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-template.docx new file mode 100644 index 000000000..345e25c53 Binary files /dev/null and b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG-template.docx differ diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG.aird b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG.aird new file mode 100644 index 000000000..94370dbd5 --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG.aird @@ -0,0 +1,1386 @@ + + + + anydsl.ecore + http://www.eclipse.org/emf/2002/Ecore + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG.genconf b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG.genconf new file mode 100644 index 000000000..c7a3de1ca --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/asImageJPG.genconf @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/description/ecore.odesign b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/description/ecore.odesign new file mode 100644 index 000000000..48b964402 --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/resources/asImageWithSiriusScaleLevel50/asImageJPG/description/ecore.odesign @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/AbstractTemplatesTestSuite.java b/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/AbstractTemplatesTestSuite.java index cc5d6e274..baa7e1484 100644 --- a/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/AbstractTemplatesTestSuite.java +++ b/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/AbstractTemplatesTestSuite.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2017 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Obeo - initial API and implementation + * + *******************************************************************************/ package org.obeonetwork.m2doc.sirius.tests; import java.io.File; diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/AllTests.java b/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/AllTests.java index b6d89c133..5b12e34b7 100644 --- a/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/AllTests.java +++ b/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 Obeo. + * Copyright (c) 2017, 2024 Obeo. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -24,7 +24,9 @@ */ @RunWith(Suite.class) @SuiteClasses(value = {M2DocSiriusServicesTests.class, M2DocSiriusServicesWithForceRefreshTests.class, - DMStyleTest.class, DMTableTest.class, }) + M2DocSiriusServicesWithScaleLevel1Tests.class, M2DocSiriusServicesWithScaleLevel50Tests.class, DMStyleTest.class, + DMTableTest.class, }) + public class AllTests { } diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/M2DocSiriusServicesWithForceRefreshTests.java b/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/M2DocSiriusServicesWithForceRefreshTests.java index acd7bb04a..38e41ebdc 100644 --- a/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/M2DocSiriusServicesWithForceRefreshTests.java +++ b/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/M2DocSiriusServicesWithForceRefreshTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 Obeo. + * Copyright (c) 2016, 2024 Obeo. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -14,17 +14,17 @@ import java.io.IOException; import java.util.Collection; +import org.eclipse.sirius.ui.business.api.dialect.ExportFormat.ScalingPolicy; import org.junit.runners.Parameterized.Parameters; import org.obeonetwork.m2doc.genconf.GenconfUtils; import org.obeonetwork.m2doc.genconf.Generation; import org.obeonetwork.m2doc.genconf.Option; import org.obeonetwork.m2doc.parser.DocumentParserException; import org.obeonetwork.m2doc.sirius.M2DocSiriusUtils; -import org.obeonetwork.m2doc.template.Bookmark; -import org.obeonetwork.m2doc.template.Link; +import org.obeonetwork.m2doc.sirius.services.M2DocSiriusServices; /** - * Tests {@link Bookmark} and {@link Link}. + * Tests {@link M2DocSiriusServices}. * * @author Yvan Lussaud */ @@ -47,6 +47,8 @@ public M2DocSiriusServicesWithForceRefreshTests(String testFolder) throws IOExce @Override protected void setTemplateFileName(Generation gen, String templateFileName) { super.setTemplateFileName(gen, templateFileName); + final Option scalingPolicyOption = GenconfUtils.getOrCreateOption(gen, M2DocSiriusUtils.SIRIUS_SCALING_POLICY); + scalingPolicyOption.setValue(ScalingPolicy.AUTO_SCALING.name()); final Option option = GenconfUtils.getOrCreateOption(gen, M2DocSiriusUtils.SIRIUS_FORCE_REFRESH); option.setValue(Boolean.TRUE.toString()); } diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/M2DocSiriusServicesWithScaleLevel1Tests.java b/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/M2DocSiriusServicesWithScaleLevel1Tests.java new file mode 100644 index 000000000..0fb4e2cab --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/M2DocSiriusServicesWithScaleLevel1Tests.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2024 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Obeo - initial API and implementation + * + *******************************************************************************/ +package org.obeonetwork.m2doc.sirius.tests; + +import java.io.IOException; +import java.util.Collection; + +import org.junit.runners.Parameterized.Parameters; +import org.obeonetwork.m2doc.genconf.GenconfUtils; +import org.obeonetwork.m2doc.genconf.Generation; +import org.obeonetwork.m2doc.genconf.Option; +import org.obeonetwork.m2doc.parser.DocumentParserException; +import org.obeonetwork.m2doc.sirius.M2DocSiriusUtils; +import org.obeonetwork.m2doc.sirius.services.M2DocSiriusServices; + +/** + * Tests {@link M2DocSiriusServices}. + * + * @author Yvan Lussaud + */ +public class M2DocSiriusServicesWithScaleLevel1Tests extends AbstractTemplatesTestSuite { + + /** + * Constructor. + * + * @param testFolder + * the test folder path + * @throws IOException + * if the tested template can't be read + * @throws DocumentParserException + * if the tested template can't be parsed + */ + public M2DocSiriusServicesWithScaleLevel1Tests(String testFolder) throws IOException, DocumentParserException { + super(testFolder); + } + + @Override + protected void setTemplateFileName(Generation gen, String templateFileName) { + super.setTemplateFileName(gen, templateFileName); + final Option option = GenconfUtils.getOrCreateOption(gen, M2DocSiriusUtils.SIRIUS_SCALE_LEVEL); + option.setValue("1"); + } + + /** + * Gets the {@link Collection} of test folders. + * + * @return the {@link Collection} of test folders + */ + @Parameters(name = "{0}") + public static Collection retrieveTestFolders() { + return retrieveTestFolders("resources/asImageWithSiriusScaleLevel1"); + } + +} diff --git a/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/M2DocSiriusServicesWithScaleLevel50Tests.java b/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/M2DocSiriusServicesWithScaleLevel50Tests.java new file mode 100644 index 000000000..7e17b7671 --- /dev/null +++ b/tests/org.obeonetwork.m2doc.sirius.tests/src/org/obeonetwork/m2doc/sirius/tests/M2DocSiriusServicesWithScaleLevel50Tests.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2024 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Obeo - initial API and implementation + * + *******************************************************************************/ +package org.obeonetwork.m2doc.sirius.tests; + +import java.io.IOException; +import java.util.Collection; + +import org.eclipse.sirius.ui.business.api.dialect.ExportFormat.ScalingPolicy; +import org.junit.runners.Parameterized.Parameters; +import org.obeonetwork.m2doc.genconf.GenconfUtils; +import org.obeonetwork.m2doc.genconf.Generation; +import org.obeonetwork.m2doc.genconf.Option; +import org.obeonetwork.m2doc.parser.DocumentParserException; +import org.obeonetwork.m2doc.sirius.M2DocSiriusUtils; +import org.obeonetwork.m2doc.sirius.services.M2DocSiriusServices; + +/** + * Tests {@link M2DocSiriusServices}. + * + * @author Yvan Lussaud + */ +public class M2DocSiriusServicesWithScaleLevel50Tests extends AbstractTemplatesTestSuite { + + /** + * Constructor. + * + * @param testFolder + * the test folder path + * @throws IOException + * if the tested template can't be read + * @throws DocumentParserException + * if the tested template can't be parsed + */ + public M2DocSiriusServicesWithScaleLevel50Tests(String testFolder) throws IOException, DocumentParserException { + super(testFolder); + } + + @Override + protected void setTemplateFileName(Generation gen, String templateFileName) { + super.setTemplateFileName(gen, templateFileName); + final Option scalingPolicyOption = GenconfUtils.getOrCreateOption(gen, M2DocSiriusUtils.SIRIUS_SCALING_POLICY); + scalingPolicyOption.setValue(ScalingPolicy.AUTO_SCALING.name()); + final Option scaleLevelOption = GenconfUtils.getOrCreateOption(gen, M2DocSiriusUtils.SIRIUS_SCALE_LEVEL); + scaleLevelOption.setValue("50"); + } + + /** + * Gets the {@link Collection} of test folders. + * + * @return the {@link Collection} of test folders + */ + @Parameters(name = "{0}") + public static Collection retrieveTestFolders() { + return retrieveTestFolders("resources/asImageWithSiriusScaleLevel50"); + } + +}