Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate multiple formats in single execution. #1378

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/net/sourceforge/plantuml/FileFormatOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* (C) Copyright 2009-2024, Arnaud Roques
*
* Project Info: https://plantuml.com
*
*
* If you like this project or if you find it useful, you can support us at:
*
*
* https://plantuml.com/patreon (only 1$ per month!)
* https://plantuml.com/paypal
*
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
Expand All @@ -37,6 +37,8 @@

import java.awt.geom.AffineTransform;
import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import java.util.Objects;

import net.sourceforge.plantuml.klimt.color.ColorMapper;
Expand All @@ -45,10 +47,10 @@

/**
* A FileFormat with some parameters.
*
*
*
*
* @author Arnaud Roques
*
*
*/
public final class FileFormatOption implements Serializable {
// ::remove file when __HAXE__
Expand All @@ -63,6 +65,7 @@ public final class FileFormatOption implements Serializable {
private final String preserveAspectRatio;
private final String watermark;
private final ColorMapper colorMapper;
private List<FileFormat> allFormats = new ArrayList<>();

public double getScaleCoef() {
return scale;
Expand Down Expand Up @@ -150,6 +153,11 @@ public FileFormatOption withColorMapper(ColorMapper colorMapper) {
tikzFontDistortion, scale, preserveAspectRatio, watermark, colorMapper);
}

public FileFormatOption withFileFormat(FileFormat fileFormat) {
return new FileFormatOption(fileFormat, withMetadata, useRedForError, svgLinkTarget, debugsvek, hoverColor,
tikzFontDistortion, scale, preserveAspectRatio, watermark, colorMapper);
}

@Override
public String toString() {
return fileFormat.toString();
Expand Down Expand Up @@ -198,4 +206,7 @@ public ColorMapper getColorMapper() {
return colorMapper;
}

public List<FileFormat> getAllFormats() {
return allFormats;
}
}
8 changes: 5 additions & 3 deletions src/net/sourceforge/plantuml/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* (C) Copyright 2009-2024, Arnaud Roques
*
* Project Info: https://plantuml.com
*
*
* If you like this project or if you find it useful, you can support us at:
*
*
* https://plantuml.com/patreon (only 1$ per month!)
* https://plantuml.com/paypal
*
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -119,6 +119,8 @@ final public void setFileFormat(FileFormat fileFormat) {
}

final public void setFileFormatOption(FileFormatOption newFormat) {
newFormat.getAllFormats().addAll(this.fileFormatOption.getAllFormats());
newFormat.getAllFormats().add(newFormat.getFileFormat());
this.fileFormatOption = newFormat;
}

Expand Down
18 changes: 15 additions & 3 deletions src/net/sourceforge/plantuml/SourceFileReaderAbstract.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* (C) Copyright 2009-2024, Arnaud Roques
*
* Project Info: https://plantuml.com
*
*
* If you like this project or if you find it useful, you can support us at:
*
*
* https://plantuml.com/patreon (only 1$ per month!)
* https://plantuml.com/paypal
*
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -159,6 +159,18 @@ protected void exportWarnOrErrIfWord(SFile f, Diagram system) throws FileNotFoun

final public List<GeneratedImage> getGeneratedImages() throws IOException {
Log.info("Reading file: " + file);
List<GeneratedImage> result = null;
for (FileFormat format : fileFormatOption.getAllFormats()) {
fileFormatOption = fileFormatOption.withFileFormat(format);
result = getGeneratedCurrentFormat();
}
if (result != null) {
return result;
}
return getGeneratedCurrentFormat();
}

final private List<GeneratedImage> getGeneratedCurrentFormat() throws IOException {

cpt = 0;
final List<GeneratedImage> result = new ArrayList<>();
Expand Down