2019-08-26 17:07:21 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2022-03-07 19:33:46 +00:00
|
|
|
* (C) Copyright 2009-2023, Arnaud Roques
|
2019-08-26 17:07:21 +00:00
|
|
|
*
|
|
|
|
* Project Info: http://plantuml.com
|
2022-08-17 17:34:24 +00:00
|
|
|
*
|
2019-08-26 17:07:21 +00:00
|
|
|
* If you like this project or if you find it useful, you can support us at:
|
2022-08-17 17:34:24 +00:00
|
|
|
*
|
2019-08-26 17:07:21 +00:00
|
|
|
* http://plantuml.com/patreon (only 1$ per month!)
|
|
|
|
* http://plantuml.com/paypal
|
2022-08-17 17:34:24 +00:00
|
|
|
*
|
2019-08-26 17:07:21 +00:00
|
|
|
* This file is part of PlantUML.
|
|
|
|
*
|
|
|
|
* PlantUML is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PlantUML distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
|
|
* License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Original Author: Arnaud Roques
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package net.sourceforge.plantuml.style;
|
|
|
|
|
2021-11-18 17:12:17 +00:00
|
|
|
import net.sourceforge.plantuml.SkinParam;
|
2020-08-25 17:24:17 +00:00
|
|
|
import net.sourceforge.plantuml.TitledDiagram;
|
2019-08-26 17:07:21 +00:00
|
|
|
import net.sourceforge.plantuml.command.BlocLines;
|
|
|
|
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
|
|
|
import net.sourceforge.plantuml.command.CommandMultilines2;
|
|
|
|
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
2022-09-23 16:53:33 +00:00
|
|
|
import net.sourceforge.plantuml.command.Trim;
|
2019-08-26 17:07:21 +00:00
|
|
|
import net.sourceforge.plantuml.command.regex.IRegex;
|
|
|
|
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
|
|
|
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
|
|
|
|
2020-08-25 17:24:17 +00:00
|
|
|
public class CommandStyleMultilinesCSS extends CommandMultilines2<TitledDiagram> {
|
2019-08-26 17:07:21 +00:00
|
|
|
|
2022-12-16 16:20:14 +00:00
|
|
|
public static final CommandStyleMultilinesCSS ME = new CommandStyleMultilinesCSS();
|
|
|
|
|
|
|
|
private CommandStyleMultilinesCSS() {
|
2022-09-23 16:53:33 +00:00
|
|
|
super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE, Trim.BOTH);
|
2019-08-26 17:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getPatternEnd() {
|
2021-05-23 15:35:13 +00:00
|
|
|
return "^[%s]*\\</style\\>[%s]*$";
|
2019-08-26 17:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static IRegex getRegexConcat() {
|
|
|
|
return RegexConcat.build(CommandStyleMultilinesCSS.class.getName(), RegexLeaf.start(), //
|
|
|
|
new RegexLeaf("\\<style\\>"), //
|
|
|
|
RegexLeaf.end() //
|
2020-08-25 17:24:17 +00:00
|
|
|
);
|
2019-08-26 17:07:21 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 17:24:17 +00:00
|
|
|
protected CommandExecutionResult executeNow(TitledDiagram diagram, BlocLines lines) {
|
2020-12-01 21:39:27 +00:00
|
|
|
try {
|
|
|
|
final StyleBuilder styleBuilder = diagram.getSkinParam().getCurrentStyleBuilder();
|
2022-04-10 19:24:55 +00:00
|
|
|
for (Style modifiedStyle : StyleLoader.getDeclaredStyles(lines.subExtract(1, 1), styleBuilder))
|
2020-12-01 21:39:27 +00:00
|
|
|
diagram.getSkinParam().muteStyle(modifiedStyle);
|
2022-04-10 19:24:55 +00:00
|
|
|
|
2021-11-18 17:12:17 +00:00
|
|
|
((SkinParam) diagram.getSkinParam()).applyPendingStyleMigration();
|
2020-12-01 21:39:27 +00:00
|
|
|
return CommandExecutionResult.ok();
|
|
|
|
} catch (NoStyleAvailableException e) {
|
2022-08-17 17:34:24 +00:00
|
|
|
// Logme.error(e);
|
2020-12-01 21:39:27 +00:00
|
|
|
return CommandExecutionResult.error("General failure: no style available.");
|
2019-08-26 17:07:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|