You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2020/05/05 13:36:30 UTC
svn commit: r1877398 [2/3] - in /poi: site/src/documentation/content/xdocs/
trunk/ trunk/compile-lib/ trunk/lib/ trunk/lib/main/ trunk/lib/ooxml/
trunk/ooxml-lib/ trunk/src/java/org/apache/poi/sl/draw/
trunk/src/java/org/apache/poi/sl/draw/binding/ tru...
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/geom/MoveToCommand.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/geom/MoveToCommand.java?rev=1877398&r1=1877397&r2=1877398&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/geom/MoveToCommand.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/geom/MoveToCommand.java Tue May 5 13:36:30 2020
@@ -20,26 +20,63 @@
package org.apache.poi.sl.draw.geom;
import java.awt.geom.Path2D;
+import java.util.Objects;
-import org.apache.poi.sl.draw.binding.CTAdjPoint2D;
+/**
+ * <p>Java class for CT_Path2DMoveTo complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Path2DMoveTo">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="pt" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+// @XmlAccessorType(XmlAccessType.FIELD)
+// @XmlType(name = "CT_Path2DMoveTo", propOrder = {"pt"})
+public final class MoveToCommand implements PathCommand {
-public class MoveToCommand implements PathCommand {
- private String arg1, arg2;
+ // @XmlElement(required = true)
+ private final AdjustPoint pt = new AdjustPoint();
- MoveToCommand(CTAdjPoint2D pt){
- arg1 = pt.getX();
- arg2 = pt.getY();
+ public AdjustPoint getPt() {
+ return pt;
}
- MoveToCommand(String s1, String s2){
- arg1 = s1;
- arg2 = s2;
+ public void setPt(AdjustPoint pt) {
+ if (pt != null) {
+ this.pt.setX(pt.getX());
+ this.pt.setY(pt.getY());
+ }
}
@Override
public void execute(Path2D.Double path, Context ctx){
- double x = ctx.getValue(arg1);
- double y = ctx.getValue(arg2);
+ double x = ctx.getValue(pt.getX());
+ double y = ctx.getValue(pt.getY());
path.moveTo(x, y);
}
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof MoveToCommand)) return false;
+ MoveToCommand that = (MoveToCommand) o;
+ return Objects.equals(pt, that.pt);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(pt);
+ }
}
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/geom/Path.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/geom/Path.java?rev=1877398&r1=1877397&r2=1877398&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/geom/Path.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/geom/Path.java Tue May 5 13:36:30 2020
@@ -22,84 +22,65 @@ package org.apache.poi.sl.draw.geom;
import java.awt.geom.Path2D;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
-import org.apache.poi.sl.draw.binding.CTAdjPoint2D;
-import org.apache.poi.sl.draw.binding.CTPath2D;
-import org.apache.poi.sl.draw.binding.CTPath2DArcTo;
-import org.apache.poi.sl.draw.binding.CTPath2DClose;
-import org.apache.poi.sl.draw.binding.CTPath2DCubicBezierTo;
-import org.apache.poi.sl.draw.binding.CTPath2DLineTo;
-import org.apache.poi.sl.draw.binding.CTPath2DMoveTo;
-import org.apache.poi.sl.draw.binding.CTPath2DQuadBezierTo;
import org.apache.poi.sl.usermodel.PaintStyle.PaintModifier;
/**
* Specifies a creation path consisting of a series of moves, lines and curves
* that when combined forms a geometric shape
+ *
+ * <p>Java class for CT_Path2D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Path2D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded" minOccurs="0">
+ * <element name="close" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DClose"/>
+ * <element name="moveTo" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DMoveTo"/>
+ * <element name="lnTo" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DLineTo"/>
+ * <element name="arcTo" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DArcTo"/>
+ * <element name="quadBezTo" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DQuadBezierTo"/>
+ * <element name="cubicBezTo" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DCubicBezierTo"/>
+ * </choice>
+ * <attribute name="w" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveCoordinate" default="0" />
+ * <attribute name="h" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveCoordinate" default="0" />
+ * <attribute name="fill" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PathFillMode" default="norm" />
+ * <attribute name="stroke" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
+ * <attribute name="extrusionOk" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
*/
-public class Path {
+// @XmlAccessorType(XmlAccessType.FIELD)
+// @XmlType(name = "CT_Path2D", propOrder = {"closeOrMoveToOrLnTo"})
+public final class Path {
+
+ // @XmlElements({
+ // @XmlElement(name = "close", type = CTPath2DClose.class),
+ // @XmlElement(name = "moveTo", type = CTPath2DMoveTo.class),
+ // @XmlElement(name = "lnTo", type = CTPath2DLineTo.class),
+ // @XmlElement(name = "arcTo", type = CTPath2DArcTo.class),
+ // @XmlElement(name = "quadBezTo", type = CTPath2DQuadBezierTo.class),
+ // @XmlElement(name = "cubicBezTo", type = CTPath2DCubicBezierTo.class)
+ // })
+ private final List<PathCommand> commands = new ArrayList<>();
+ // @XmlAttribute(name = "fill")
+ private PaintModifier fill = PaintModifier.NORM;
+ // @XmlAttribute(name = "stroke")
+ private boolean stroke = true;
+ // @XmlAttribute(name = "extrusionOk")
+ private boolean extrusionOk = false;
+ // @XmlAttribute(name = "w")
+ private long w = -1;
+ // @XmlAttribute(name = "h")
+ private long h = -1;
+
- private final List<PathCommand> commands;
- PaintModifier _fill;
- boolean _stroke;
- long _w, _h;
-
- public Path(){
- this(true, true);
- }
-
- public Path(boolean fill, boolean stroke){
- commands = new ArrayList<>();
- _w = -1;
- _h = -1;
- _fill = (fill) ? PaintModifier.NORM : PaintModifier.NONE;
- _stroke = stroke;
- }
-
- public Path(CTPath2D spPath){
- switch (spPath.getFill()) {
- case NONE: _fill = PaintModifier.NONE; break;
- case DARKEN: _fill = PaintModifier.DARKEN; break;
- case DARKEN_LESS: _fill = PaintModifier.DARKEN_LESS; break;
- case LIGHTEN: _fill = PaintModifier.LIGHTEN; break;
- case LIGHTEN_LESS: _fill = PaintModifier.LIGHTEN_LESS; break;
- default:
- case NORM: _fill = PaintModifier.NORM; break;
- }
- _stroke = spPath.isStroke();
- _w = spPath.isSetW() ? spPath.getW() : -1;
- _h = spPath.isSetH() ? spPath.getH() : -1;
-
- commands = new ArrayList<>();
-
- for(Object ch : spPath.getCloseOrMoveToOrLnTo()){
- if(ch instanceof CTPath2DMoveTo){
- CTAdjPoint2D pt = ((CTPath2DMoveTo)ch).getPt();
- commands.add(new MoveToCommand(pt));
- } else if (ch instanceof CTPath2DLineTo){
- CTAdjPoint2D pt = ((CTPath2DLineTo)ch).getPt();
- commands.add(new LineToCommand(pt));
- } else if (ch instanceof CTPath2DArcTo){
- CTPath2DArcTo arc = (CTPath2DArcTo)ch;
- commands.add(new ArcToCommand(arc));
- } else if (ch instanceof CTPath2DQuadBezierTo){
- CTPath2DQuadBezierTo bez = ((CTPath2DQuadBezierTo)ch);
- CTAdjPoint2D pt1 = bez.getPt().get(0);
- CTAdjPoint2D pt2 = bez.getPt().get(1);
- commands.add(new QuadToCommand(pt1, pt2));
- } else if (ch instanceof CTPath2DCubicBezierTo){
- CTPath2DCubicBezierTo bez = ((CTPath2DCubicBezierTo)ch);
- CTAdjPoint2D pt1 = bez.getPt().get(0);
- CTAdjPoint2D pt2 = bez.getPt().get(1);
- CTAdjPoint2D pt3 = bez.getPt().get(2);
- commands.add(new CurveToCommand(pt1, pt2, pt3));
- } else if (ch instanceof CTPath2DClose){
- commands.add(new ClosePathCommand());
- } else {
- throw new IllegalStateException("Unsupported path segment: " + ch);
- }
- }
- }
public void addCommand(PathCommand cmd){
commands.add(cmd);
@@ -117,22 +98,65 @@ public class Path {
}
public boolean isStroked(){
- return _stroke;
+ return stroke;
+ }
+
+ public void setStroke(boolean stroke) {
+ this.stroke = stroke;
}
public boolean isFilled(){
- return _fill != PaintModifier.NONE;
+ return fill != PaintModifier.NONE;
}
public PaintModifier getFill() {
- return _fill;
+ return fill;
+ }
+
+ public void setFill(PaintModifier fill) {
+ this.fill = fill;
}
public long getW(){
- return _w;
+ return w;
+ }
+
+ public void setW(long w) {
+ this.w = w;
}
public long getH(){
- return _h;
+ return h;
+ }
+
+ public void setH(long h) {
+ this.h = h;
+ }
+
+ public boolean isExtrusionOk() {
+ return extrusionOk;
+ }
+
+ public void setExtrusionOk(boolean extrusionOk) {
+ this.extrusionOk = extrusionOk;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof Path)) return false;
+ Path ctPath2D = (Path) o;
+ return Objects.equals(commands, ctPath2D.commands) &&
+ Objects.equals(w, ctPath2D.w) &&
+ Objects.equals(h, ctPath2D.h) &&
+ fill == ctPath2D.fill &&
+ Objects.equals(stroke, ctPath2D.stroke) &&
+ Objects.equals(extrusionOk, ctPath2D.extrusionOk);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(commands, w, h, fill.ordinal(), stroke, extrusionOk);
}
}
Added: poi/trunk/src/java/org/apache/poi/sl/draw/geom/PolarAdjustHandle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/geom/PolarAdjustHandle.java?rev=1877398&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/geom/PolarAdjustHandle.java (added)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/geom/PolarAdjustHandle.java Tue May 5 13:36:30 2020
@@ -0,0 +1,282 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.sl.draw.geom;
+
+import java.util.Objects;
+
+/**
+ * <p>Java class for CT_PolarAdjustHandle complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_PolarAdjustHandle">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="pos" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D"/>
+ * </sequence>
+ * <attribute name="gdRefR" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideName" />
+ * <attribute name="minR" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="maxR" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="gdRefAng" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideName" />
+ * <attribute name="minAng" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjAngle" />
+ * <attribute name="maxAng" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjAngle" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+// @XmlAccessorType(XmlAccessType.FIELD)
+// @XmlType(name = "CT_PolarAdjustHandle", propOrder = {"pos"})
+public final class PolarAdjustHandle implements AdjustHandle {
+
+ // @XmlElement(required = true)
+ private AdjustPoint pos;
+ // @XmlAttribute(name = "gdRefR")
+ // @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ private String gdRefR;
+ // @XmlAttribute(name = "minR")
+ private String minR;
+ // @XmlAttribute(name = "maxR")
+ private String maxR;
+ // @XmlAttribute(name = "gdRefAng")
+ // @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ private String gdRefAng;
+ // @XmlAttribute(name = "minAng")
+ private String minAng;
+ // @XmlAttribute(name = "maxAng")
+ private String maxAng;
+
+ /**
+ * Gets the value of the pos property.
+ *
+ * @return
+ * possible object is
+ * {@link AdjustPoint }
+ *
+ */
+ public AdjustPoint getPos() {
+ return pos;
+ }
+
+ /**
+ * Sets the value of the pos property.
+ *
+ * @param value
+ * allowed object is
+ * {@link AdjustPoint }
+ *
+ */
+ public void setPos(AdjustPoint value) {
+ this.pos = value;
+ }
+
+ public boolean isSetPos() {
+ return (this.pos!= null);
+ }
+
+ /**
+ * Gets the value of the gdRefR property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getGdRefR() {
+ return gdRefR;
+ }
+
+ /**
+ * Sets the value of the gdRefR property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setGdRefR(String value) {
+ this.gdRefR = value;
+ }
+
+ public boolean isSetGdRefR() {
+ return (this.gdRefR!= null);
+ }
+
+ /**
+ * Gets the value of the minR property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMinR() {
+ return minR;
+ }
+
+ /**
+ * Sets the value of the minR property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMinR(String value) {
+ this.minR = value;
+ }
+
+ public boolean isSetMinR() {
+ return (this.minR!= null);
+ }
+
+ /**
+ * Gets the value of the maxR property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMaxR() {
+ return maxR;
+ }
+
+ /**
+ * Sets the value of the maxR property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMaxR(String value) {
+ this.maxR = value;
+ }
+
+ public boolean isSetMaxR() {
+ return (this.maxR!= null);
+ }
+
+ /**
+ * Gets the value of the gdRefAng property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getGdRefAng() {
+ return gdRefAng;
+ }
+
+ /**
+ * Sets the value of the gdRefAng property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setGdRefAng(String value) {
+ this.gdRefAng = value;
+ }
+
+ public boolean isSetGdRefAng() {
+ return (this.gdRefAng!= null);
+ }
+
+ /**
+ * Gets the value of the minAng property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMinAng() {
+ return minAng;
+ }
+
+ /**
+ * Sets the value of the minAng property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMinAng(String value) {
+ this.minAng = value;
+ }
+
+ public boolean isSetMinAng() {
+ return (this.minAng!= null);
+ }
+
+ /**
+ * Gets the value of the maxAng property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMaxAng() {
+ return maxAng;
+ }
+
+ /**
+ * Sets the value of the maxAng property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMaxAng(String value) {
+ this.maxAng = value;
+ }
+
+ public boolean isSetMaxAng() {
+ return (this.maxAng!= null);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof PolarAdjustHandle)) return false;
+ PolarAdjustHandle that = (PolarAdjustHandle) o;
+ return Objects.equals(pos, that.pos) &&
+ Objects.equals(gdRefR, that.gdRefR) &&
+ Objects.equals(minR, that.minR) &&
+ Objects.equals(maxR, that.maxR) &&
+ Objects.equals(gdRefAng, that.gdRefAng) &&
+ Objects.equals(minAng, that.minAng) &&
+ Objects.equals(maxAng, that.maxAng);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(pos, gdRefR, minR, maxR, gdRefAng, minAng, maxAng);
+ }
+}
Propchange: poi/trunk/src/java/org/apache/poi/sl/draw/geom/PolarAdjustHandle.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java?rev=1877398&r1=1877397&r2=1877398&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java Tue May 5 13:36:30 2020
@@ -19,73 +19,51 @@
package org.apache.poi.sl.draw.geom;
+import java.io.IOException;
import java.io.InputStream;
-import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.TreeMap;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.stream.StreamSource;
-import org.apache.poi.sl.draw.binding.CTCustomGeometry2D;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.XMLHelper;
-/**
- *
- */
-public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
+public final class PresetGeometries {
private final static POILogger LOG = POILogFactory.getLogger(PresetGeometries.class);
- private final static String BINDING_PACKAGE = "org.apache.poi.sl.draw.binding";
- private static class SingletonHelper {
- private static JAXBContext JAXB_CONTEXT;
- static {
- try {
- JAXB_CONTEXT = JAXBContext.newInstance(BINDING_PACKAGE);
- } catch (JAXBException e) {
- throw new RuntimeException(e);
- }
- }
- }
+ private final Map<String, CustomGeometry> map = new TreeMap<>();
+ private static class SingletonHelper{
+ private static final PresetGeometries INSTANCE = new PresetGeometries();
+ }
- protected static PresetGeometries _inst;
-
- protected PresetGeometries(){}
+ public static PresetGeometries getInstance(){
+ return SingletonHelper.INSTANCE;
+ }
- @SuppressWarnings("unused")
- public void init(InputStream is) throws XMLStreamException, JAXBException {
- XMLInputFactory staxFactory = XMLHelper.newXMLInputFactory();
- XMLStreamReader streamReader = staxFactory.createXMLStreamReader(new StreamSource(is));
+ private PresetGeometries() {
+ // use a local object first to not assign a partly constructed object in case of failure
try {
- // ignore StartElement:
- streamReader.nextTag();
-
- // JAXB:
- JAXBContext jaxbContext = SingletonHelper.JAXB_CONTEXT;
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
-
- long cntElem = 0;
- while (streamReader.hasNext() && streamReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
- String name = streamReader.getLocalName();
- JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(streamReader, CTCustomGeometry2D.class);
- CTCustomGeometry2D cus = el.getValue();
- cntElem++;
-
- if (containsKey(name)) {
- LOG.log(POILogger.WARN, "Duplicate definition of " + name);
+ try (InputStream is = PresetGeometries.class.getResourceAsStream("presetShapeDefinitions.xml")) {
+ XMLInputFactory staxFactory = XMLHelper.newXMLInputFactory();
+ XMLStreamReader sr = staxFactory.createXMLStreamReader(new StreamSource(is));
+ try {
+ PresetParser p = new PresetParser(PresetParser.Mode.FILE);
+ p.parse(sr);
+ p.getGeom().forEach(map::put);
+ } finally {
+ sr.close();
}
- put(name, new CustomGeometry(cus));
}
- } finally {
- streamReader.close();
+ } catch (IOException | XMLStreamException e){
+ throw new RuntimeException(e);
}
}
@@ -94,32 +72,35 @@ public class PresetGeometries extends Li
*/
public static CustomGeometry convertCustomGeometry(XMLStreamReader staxReader) {
try {
- JAXBContext jaxbContext = SingletonHelper.JAXB_CONTEXT;
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(staxReader, CTCustomGeometry2D.class);
- return new CustomGeometry(el.getValue());
- } catch (JAXBException e) {
+ PresetParser p = new PresetParser(PresetParser.Mode.SHAPE);
+ p.parse(staxReader);
+ return p.getGeom().values().stream().findFirst().orElse(null);
+ } catch (XMLStreamException e) {
LOG.log(POILogger.ERROR, "Unable to parse single custom geometry", e);
return null;
}
}
- public static synchronized PresetGeometries getInstance(){
- if(_inst == null) {
- // use a local object first to not assign a partly constructed object
- // in case of failure
- PresetGeometries lInst = new PresetGeometries();
- try {
- try (InputStream is = PresetGeometries.class.
- getResourceAsStream("presetShapeDefinitions.xml")) {
- lInst.init(is);
- }
- } catch (Exception e){
- throw new RuntimeException(e);
- }
- _inst = lInst;
- }
+ public CustomGeometry get(String name) {
+ return name == null ? null : map.get(name);
+ }
+
+ public Set<String> keySet() {
+ return map.keySet();
+ }
+
+ public int size() {
+ return map.size();
+ }
+
+ @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
+ @Override
+ public boolean equals(Object o) {
+ return (this == o);
+ }
- return _inst;
+ @Override
+ public int hashCode() {
+ return Objects.hash(map);
}
}
Added: poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetParser.java?rev=1877398&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetParser.java (added)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetParser.java Tue May 5 13:36:30 2020
@@ -0,0 +1,573 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.poi.sl.draw.geom;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.BiConsumer;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.poi.sl.usermodel.PaintStyle.PaintModifier;
+import org.apache.poi.util.Internal;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+
+@Internal
+class PresetParser {
+ enum Mode {
+ FILE(PresetParser::updateFile),
+ SHAPE_LST(PresetParser::updateShapeList),
+ SHAPE(PresetParser::updateShape),
+ GUIDE_LST(PresetParser::updateGuideList),
+ AH_LST(PresetParser::updateAhList),
+ CXN_LST(PresetParser::updateCxnList),
+ PATH_LST(PresetParser::updatePathLst),
+ PATH(PresetParser::updatePath);
+
+ interface Handler {
+ void update(PresetParser parser, XMLStreamReader sr) throws XMLStreamException;
+ }
+
+ final Handler handler;
+
+ Mode(Handler handler) {
+ this.handler = handler;
+ }
+ }
+
+ private final static POILogger LOG = POILogFactory.getLogger(PresetParser.class);
+
+ private Mode mode;
+
+ private final Map<String, CustomGeometry> geom = new HashMap<>();
+ private CustomGeometry customGeometry;
+ private boolean useAdjustValue;
+ private Path path;
+
+
+ PresetParser(Mode mode) {
+ this.mode = mode;
+ if (mode == Mode.SHAPE) {
+ customGeometry = new CustomGeometry();
+ geom.put("custom", customGeometry);
+ }
+ }
+
+ void parse(XMLStreamReader sr) throws XMLStreamException {
+ while (sr.hasNext()) {
+ switch (sr.next()) {
+ case XMLStreamConstants.START_ELEMENT:
+ mode.handler.update(this, sr);
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ endContext();
+ break;
+ case XMLStreamConstants.END_DOCUMENT:
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+ Map<String, CustomGeometry> getGeom() {
+ return geom;
+ }
+
+ private void updateFile(XMLStreamReader sr) {
+ final String name = sr.getLocalName();
+ assert("presetShapeDefinitons".equals(name));
+ mode = Mode.SHAPE_LST;
+ }
+
+ private void updateShapeList(XMLStreamReader sr) {
+ final String name = sr.getLocalName();
+ customGeometry = new CustomGeometry();
+ if (geom.containsKey(name)) {
+ LOG.log(POILogger.WARN, "Duplicate definition of " + name);
+ }
+ geom.put(name, customGeometry);
+ mode = Mode.SHAPE;
+ }
+
+ private void updateShape(XMLStreamReader sr) throws XMLStreamException {
+ final String name = sr.getLocalName();
+ switch (name) {
+ case "avLst":
+ useAdjustValue = true;
+ mode = Mode.GUIDE_LST;
+ break;
+ case "gdLst":
+ useAdjustValue = false;
+ mode = Mode.GUIDE_LST;
+ break;
+ case "ahLst":
+ mode = Mode.AH_LST;
+ break;
+ case "cxnLst":
+ mode = Mode.CXN_LST;
+ break;
+ case "rect":
+ addRectangle(sr);
+ break;
+ case "pathLst":
+ mode = Mode.PATH_LST;
+ break;
+ }
+ }
+
+ private void updateGuideList(XMLStreamReader sr) throws XMLStreamException {
+ final String name = sr.getLocalName();
+ assert("gd".equals(name));
+ final Guide gd;
+ if (useAdjustValue) {
+ customGeometry.addAdjustGuide((AdjustValue)(gd = new AdjustValue()));
+ } else {
+ customGeometry.addGeomGuide(gd = new Guide());
+ }
+
+ parseAttributes(sr, (key,val) -> {
+ switch (key) {
+ case "name":
+ // CollapsedStringAdapter
+ gd.setName(collapseString(val));
+ break;
+ case "fmla":
+ gd.setFmla(val);
+ break;
+ }
+ });
+
+ int tag = nextTag(sr);
+ assert(tag == XMLStreamConstants.END_ELEMENT);
+ }
+
+
+ private void updateAhList(XMLStreamReader sr) throws XMLStreamException {
+ String name = sr.getLocalName();
+ switch (name) {
+ case "ahXY":
+ addXY(sr);
+ break;
+
+ case "ahPolar":
+ addPolar(sr);
+ break;
+ }
+ }
+
+ private void addXY(XMLStreamReader sr) throws XMLStreamException {
+ XYAdjustHandle ahXY = new XYAdjustHandle();
+ customGeometry.addAdjustHandle(ahXY);
+
+ parseAttributes(sr, (key, val) -> {
+ switch (key) {
+ case "gdRefX":
+ ahXY.setGdRefX(collapseString(val));
+ break;
+ case "minX":
+ ahXY.setMinX(val);
+ break;
+ case "maxX":
+ ahXY.setMaxX(val);
+ break;
+ case "gdRefY":
+ ahXY.setGdRefY(collapseString(val));
+ break;
+ case "minY":
+ ahXY.setMinY(val);
+ break;
+ case "maxY":
+ ahXY.setMaxY(val);
+ break;
+ }
+ });
+
+ ahXY.setPos(parsePosPoint(sr));
+ }
+
+ private void addPolar(XMLStreamReader sr) throws XMLStreamException {
+ PolarAdjustHandle ahPolar = new PolarAdjustHandle();
+ customGeometry.addAdjustHandle(ahPolar);
+
+ parseAttributes(sr, (key, val) -> {
+ switch (key) {
+ case "gdRefR":
+ ahPolar.setGdRefR(collapseString(val));
+ break;
+ case "minR":
+ ahPolar.setMinR(val);
+ break;
+ case "maxR":
+ ahPolar.setMaxR(val);
+ break;
+ case "gdRefAng":
+ ahPolar.setGdRefAng(collapseString(val));
+ break;
+ case "minAng":
+ ahPolar.setMinAng(val);
+ break;
+ case "maxAng":
+ ahPolar.setMaxAng(val);
+ break;
+ }
+ });
+
+ ahPolar.setPos(parsePosPoint(sr));
+ }
+
+ private void updateCxnList(XMLStreamReader sr) throws XMLStreamException {
+ String name = sr.getLocalName();
+ assert("cxn".equals(name));
+
+ ConnectionSite cxn = new ConnectionSite();
+ customGeometry.addConnectionSite(cxn);
+
+ parseAttributes(sr, (key, val) -> {
+ if ("ang".equals(key)) {
+ cxn.setAng(val);
+ }
+ });
+
+ cxn.setPos(parsePosPoint(sr));
+ }
+
+ private void updatePathLst(XMLStreamReader sr) {
+ String name = sr.getLocalName();
+ assert("path".equals(name));
+
+ path = new Path();
+ customGeometry.addPath(path);
+
+ parseAttributes(sr, (key, val) -> {
+ switch (key) {
+ case "w":
+ path.setW(Long.parseLong(val));
+ break;
+ case "h":
+ path.setH(Long.parseLong(val));
+ break;
+ case "fill":
+ path.setFill(mapFill(val));
+ break;
+ case "stroke":
+ path.setStroke(Boolean.parseBoolean(val));
+ break;
+ case "extrusionOk":
+ path.setExtrusionOk(Boolean.parseBoolean(val));
+ break;
+ }
+ });
+
+ mode = Mode.PATH;
+ }
+
+ private static PaintModifier mapFill(String fill) {
+ switch (fill) {
+ default:
+ case "none":
+ return PaintModifier.NONE;
+ case "norm":
+ return PaintModifier.NORM;
+ case "lighten":
+ return PaintModifier.LIGHTEN;
+ case "lightenLess":
+ return PaintModifier.LIGHTEN_LESS;
+ case "darken":
+ return PaintModifier.DARKEN;
+ case "darkenLess":
+ return PaintModifier.DARKEN_LESS;
+ }
+ }
+
+ private void updatePath(XMLStreamReader sr) throws XMLStreamException {
+ String name = sr.getLocalName();
+ switch (name) {
+ case "close":
+ closePath(sr);
+ break;
+ case "moveTo":
+ moveTo(sr);
+ break;
+ case "lnTo":
+ lineTo(sr);
+ break;
+ case "arcTo":
+ arcTo(sr);
+ break;
+ case "quadBezTo":
+ quadBezTo(sr);
+ break;
+ case "cubicBezTo":
+ cubicBezTo(sr);
+ break;
+ }
+ }
+
+ private void closePath(XMLStreamReader sr) throws XMLStreamException {
+ path.addCommand(new ClosePathCommand());
+ int tag = nextTag(sr);
+ assert(tag == XMLStreamConstants.END_ELEMENT);
+ }
+
+ private void moveTo(XMLStreamReader sr) throws XMLStreamException {
+ MoveToCommand cmd = new MoveToCommand();
+ path.addCommand(cmd);
+
+ AdjustPoint pt = parsePtPoint(sr, true);
+ assert(pt != null);
+ cmd.setPt(pt);
+ }
+
+ private void lineTo(XMLStreamReader sr) throws XMLStreamException {
+ LineToCommand cmd = new LineToCommand();
+ path.addCommand(cmd);
+
+ AdjustPoint pt = parsePtPoint(sr, true);
+ assert(pt != null);
+ cmd.setPt(pt);
+ }
+
+ private void arcTo(XMLStreamReader sr) throws XMLStreamException {
+ ArcToCommand cmd = new ArcToCommand();
+ path.addCommand(cmd);
+ parseAttributes(sr, (key, val) -> {
+ switch (key) {
+ case "wR":
+ cmd.setWR(val);
+ break;
+ case "hR":
+ cmd.setHR(val);
+ break;
+ case "stAng":
+ cmd.setStAng(val);
+ break;
+ case "swAng":
+ cmd.setSwAng(val);
+ break;
+ }
+ });
+ int tag = nextTag(sr);
+ assert (tag == XMLStreamConstants.END_ELEMENT);
+ }
+
+ private void quadBezTo(XMLStreamReader sr) throws XMLStreamException {
+ QuadToCommand cmd = new QuadToCommand();
+ path.addCommand(cmd);
+ AdjustPoint pt1 = parsePtPoint(sr, false);
+ AdjustPoint pt2 = parsePtPoint(sr, true);
+ assert (pt1 != null && pt2 != null);
+ cmd.setPt1(pt1);
+ cmd.setPt2(pt2);
+ }
+
+ private void cubicBezTo(XMLStreamReader sr) throws XMLStreamException {
+ CurveToCommand cmd = new CurveToCommand();
+ path.addCommand(cmd);
+ AdjustPoint pt1 = parsePtPoint(sr, false);
+ AdjustPoint pt2 = parsePtPoint(sr, false);
+ AdjustPoint pt3 = parsePtPoint(sr, true);
+ assert (pt1 != null && pt2 != null && pt3 != null);
+ cmd.setPt1(pt1);
+ cmd.setPt2(pt2);
+ cmd.setPt3(pt3);
+ }
+
+ private void addRectangle(XMLStreamReader sr) throws XMLStreamException {
+ String[] ltrb = new String[4];
+ parseAttributes(sr, (key,val) -> {
+ switch (key) {
+ case "l":
+ ltrb[0] = val;
+ break;
+ case "t":
+ ltrb[1] = val;
+ break;
+ case "r":
+ ltrb[2] = val;
+ break;
+ case "b":
+ ltrb[3] = val;
+ break;
+ }
+ });
+
+ customGeometry.setTextBounds(ltrb[0],ltrb[1],ltrb[2],ltrb[3]);
+
+ int tag = nextTag(sr);
+ assert(tag == XMLStreamConstants.END_ELEMENT);
+ }
+
+
+ private void endContext() {
+ switch (mode) {
+ case FILE:
+ case SHAPE_LST:
+ mode = Mode.FILE;
+ break;
+ case SHAPE:
+ mode = Mode.SHAPE_LST;
+ break;
+ case CXN_LST:
+ case AH_LST:
+ case GUIDE_LST:
+ case PATH_LST:
+ useAdjustValue = false;
+ path = null;
+ mode = Mode.SHAPE;
+ break;
+ case PATH:
+ path = null;
+ mode = Mode.PATH_LST;
+ break;
+ }
+ }
+
+ private AdjustPoint parsePosPoint(XMLStreamReader sr) throws XMLStreamException {
+ return parseAdjPoint(sr, true, "pos");
+ }
+
+ private AdjustPoint parsePtPoint(XMLStreamReader sr, boolean closeOuter) throws XMLStreamException {
+ return parseAdjPoint(sr, closeOuter, "pt");
+ }
+
+ private AdjustPoint parseAdjPoint(XMLStreamReader sr, boolean closeOuter, String name) throws XMLStreamException {
+ int tag = nextTag(sr);
+ if (tag == XMLStreamConstants.END_ELEMENT) {
+ return null;
+ }
+
+ assert (name.equals(sr.getLocalName()));
+
+ AdjustPoint pos = new AdjustPoint();
+ parseAttributes(sr, (key, val) -> {
+ switch (key) {
+ case "x":
+ pos.setX(val);
+ break;
+ case "y":
+ pos.setY(val);
+ break;
+ }
+ });
+ tag = nextTag(sr);
+ assert(tag == XMLStreamConstants.END_ELEMENT);
+ if (closeOuter) {
+ tag = nextTag(sr);
+ assert(tag == XMLStreamConstants.END_ELEMENT);
+ }
+ return pos;
+ }
+
+ private void parseAttributes(XMLStreamReader sr, BiConsumer<String,String> c) {
+ for (int i=0; i<sr.getAttributeCount(); i++) {
+ c.accept(sr.getAttributeLocalName(i), sr.getAttributeValue(i));
+ }
+ }
+
+ /**
+ * Reimplement {@link XMLStreamReader#nextTag()} because of differences of XmlBeans and Xerces XMLStreamReader.
+ * XmlBeans doesn't return the END_ELEMENT on nextTag()
+ *
+ * @param sr the stream reader
+ * @return the next tag type (START_ELEMENT, END_ELEMENT, END_DOCUMENT)
+ * @throws XMLStreamException if reading the next tag fails
+ */
+ private static int nextTag(XMLStreamReader sr) throws XMLStreamException {
+ int tag;
+ do {
+ tag = sr.next();
+ } while (
+ tag != XMLStreamConstants.START_ELEMENT &&
+ tag != XMLStreamConstants.END_ELEMENT &&
+ tag != XMLStreamConstants.END_DOCUMENT
+ );
+ return tag;
+ }
+
+ /**
+ * Removes leading and trailing whitespaces of the string given as the parameter, then truncate any
+ * sequence of tab, CR, LF, and SP by a single whitespace character ' '.
+ */
+ private static String collapseString(String text) {
+ if (text==null) {
+ return null;
+ }
+
+ int len = text.length();
+
+ // most of the texts are already in the collapsed form. so look for the first whitespace in the hope that we
+ // will never see it.
+ int s;
+ for (s=0; s<len; s++) {
+ if (isWhiteSpace(text.charAt(s))) {
+ break;
+ }
+ }
+
+ if (s == len) {
+ // the input happens to be already collapsed.
+ return text;
+ }
+
+ // we now know that the input contains spaces. let's sit down and do the collapsing normally.
+ // allocate enough size to avoid re-allocation
+ StringBuilder result = new StringBuilder(len);
+
+ if (s != 0) {
+ for(int i=0; i<s; i++) {
+ result.append(text.charAt(i));
+ }
+ result.append(' ');
+ }
+
+ boolean inStripMode = true;
+ for (int i = s+1; i < len; i++) {
+ char ch = text.charAt(i);
+ boolean b = isWhiteSpace(ch);
+
+ if (inStripMode && b) {
+ // skip this character
+ continue;
+ }
+
+ inStripMode = b;
+ result.append(inStripMode ? ' ' : ch);
+ }
+
+ // remove trailing whitespaces
+ len = result.length();
+ if (len > 0 && result.charAt(len - 1) == ' ') {
+ result.setLength(len - 1);
+ }
+
+ // whitespaces are already collapsed, so all we have to do is
+ // to remove the last one character if it's a whitespace.
+ return result.toString();
+ }
+
+ /** returns true if the specified char is a white space character. */
+ private static boolean isWhiteSpace(char ch) {
+ return ch == 0x9 || ch == 0xA || ch == 0xD || ch == 0x20;
+ }
+}
Propchange: poi/trunk/src/java/org/apache/poi/sl/draw/geom/PresetParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/geom/QuadToCommand.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/geom/QuadToCommand.java?rev=1877398&r1=1877397&r2=1877398&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/geom/QuadToCommand.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/geom/QuadToCommand.java Tue May 5 13:36:30 2020
@@ -20,25 +20,71 @@
package org.apache.poi.sl.draw.geom;
import java.awt.geom.Path2D;
+import java.util.Objects;
-import org.apache.poi.sl.draw.binding.CTAdjPoint2D;
+/**
+ * <p>Java class for CT_Path2DQuadBezierTo complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Path2DQuadBezierTo">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="pt" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D" maxOccurs="2" minOccurs="2"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+// @XmlAccessorType(XmlAccessType.FIELD)
+// @XmlType(name = "CT_Path2DQuadBezierTo", propOrder = {"pt"})
+public final class QuadToCommand implements PathCommand {
-public class QuadToCommand implements PathCommand {
- private String arg1, arg2, arg3, arg4;
+ // @XmlElement(required = true)
+ private final AdjustPoint pt1 = new AdjustPoint();
+ // @XmlElement(required = true)
+ private final AdjustPoint pt2 = new AdjustPoint();
- QuadToCommand(CTAdjPoint2D pt1, CTAdjPoint2D pt2){
- arg1 = pt1.getX();
- arg2 = pt1.getY();
- arg3 = pt2.getX();
- arg4 = pt2.getY();
+ public void setPt1(AdjustPoint pt1) {
+ if (pt1 != null) {
+ this.pt1.setX(pt1.getX());
+ this.pt1.setY(pt1.getY());
+ }
+ }
+
+ public void setPt2(AdjustPoint pt2) {
+ if (pt2 != null) {
+ this.pt2.setX(pt2.getX());
+ this.pt2.setY(pt2.getY());
+ }
}
@Override
public void execute(Path2D.Double path, Context ctx){
- double x1 = ctx.getValue(arg1);
- double y1 = ctx.getValue(arg2);
- double x2 = ctx.getValue(arg3);
- double y2 = ctx.getValue(arg4);
+ double x1 = ctx.getValue(pt1.getX());
+ double y1 = ctx.getValue(pt1.getY());
+ double x2 = ctx.getValue(pt2.getX());
+ double y2 = ctx.getValue(pt2.getY());
path.quadTo(x1, y1, x2, y2);
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof QuadToCommand)) return false;
+ QuadToCommand that = (QuadToCommand) o;
+ return Objects.equals(pt1, that.pt1) &&
+ Objects.equals(pt2, that.pt2);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(pt1, pt2);
+ }
+
}
Added: poi/trunk/src/java/org/apache/poi/sl/draw/geom/XYAdjustHandle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/geom/XYAdjustHandle.java?rev=1877398&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/geom/XYAdjustHandle.java (added)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/geom/XYAdjustHandle.java Tue May 5 13:36:30 2020
@@ -0,0 +1,282 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.sl.draw.geom;
+
+import java.util.Objects;
+
+/**
+ * <p>Java class for CT_XYAdjustHandle complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_XYAdjustHandle">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="pos" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D"/>
+ * </sequence>
+ * <attribute name="gdRefX" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideName" />
+ * <attribute name="minX" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="maxX" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="gdRefY" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideName" />
+ * <attribute name="minY" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="maxY" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+// @XmlAccessorType(XmlAccessType.FIELD)
+// @XmlType(name = "CT_XYAdjustHandle", propOrder = {"pos"})
+public final class XYAdjustHandle implements AdjustHandle {
+
+ // @XmlElement(required = true)
+ private AdjustPoint pos;
+ // @XmlAttribute(name = "gdRefX")
+ // @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ private String gdRefX;
+ // @XmlAttribute(name = "minX")
+ private String minX;
+ // @XmlAttribute(name = "maxX")
+ private String maxX;
+ // @XmlAttribute(name = "gdRefY")
+ // @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ private String gdRefY;
+ // @XmlAttribute(name = "minY")
+ private String minY;
+ // @XmlAttribute(name = "maxY")
+ private String maxY;
+
+ /**
+ * Gets the value of the pos property.
+ *
+ * @return
+ * possible object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public AdjustPoint getPos() {
+ return pos;
+ }
+
+ /**
+ * Sets the value of the pos property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public void setPos(AdjustPoint value) {
+ this.pos = value;
+ }
+
+ public boolean isSetPos() {
+ return (this.pos!= null);
+ }
+
+ /**
+ * Gets the value of the gdRefX property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getGdRefX() {
+ return gdRefX;
+ }
+
+ /**
+ * Sets the value of the gdRefX property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setGdRefX(String value) {
+ this.gdRefX = value;
+ }
+
+ public boolean isSetGdRefX() {
+ return (this.gdRefX!= null);
+ }
+
+ /**
+ * Gets the value of the minX property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMinX() {
+ return minX;
+ }
+
+ /**
+ * Sets the value of the minX property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMinX(String value) {
+ this.minX = value;
+ }
+
+ public boolean isSetMinX() {
+ return (this.minX!= null);
+ }
+
+ /**
+ * Gets the value of the maxX property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMaxX() {
+ return maxX;
+ }
+
+ /**
+ * Sets the value of the maxX property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMaxX(String value) {
+ this.maxX = value;
+ }
+
+ public boolean isSetMaxX() {
+ return (this.maxX!= null);
+ }
+
+ /**
+ * Gets the value of the gdRefY property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getGdRefY() {
+ return gdRefY;
+ }
+
+ /**
+ * Sets the value of the gdRefY property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setGdRefY(String value) {
+ this.gdRefY = value;
+ }
+
+ public boolean isSetGdRefY() {
+ return (this.gdRefY!= null);
+ }
+
+ /**
+ * Gets the value of the minY property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMinY() {
+ return minY;
+ }
+
+ /**
+ * Sets the value of the minY property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMinY(String value) {
+ this.minY = value;
+ }
+
+ public boolean isSetMinY() {
+ return (this.minY!= null);
+ }
+
+ /**
+ * Gets the value of the maxY property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMaxY() {
+ return maxY;
+ }
+
+ /**
+ * Sets the value of the maxY property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMaxY(String value) {
+ this.maxY = value;
+ }
+
+ public boolean isSetMaxY() {
+ return (this.maxY!= null);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof XYAdjustHandle)) return false;
+ XYAdjustHandle that = (XYAdjustHandle) o;
+ return Objects.equals(pos, that.pos) &&
+ Objects.equals(gdRefX, that.gdRefX) &&
+ Objects.equals(minX, that.minX) &&
+ Objects.equals(maxX, that.maxX) &&
+ Objects.equals(gdRefY, that.gdRefY) &&
+ Objects.equals(minY, that.minY) &&
+ Objects.equals(maxY, that.maxY);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(pos, gdRefX, minX, maxX, gdRefY, minY, maxY);
+ }
+}
Propchange: poi/trunk/src/java/org/apache/poi/sl/draw/geom/XYAdjustHandle.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/RectAlign.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/RectAlign.java?rev=1877398&r1=1877397&r2=1877398&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/RectAlign.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/RectAlign.java Tue May 5 13:36:30 2020
@@ -21,8 +21,6 @@ package org.apache.poi.sl.usermodel;
/**
* Specifies possible rectangle alignment types.
* See org.openxmlformats.schemas.drawingml.x2006.main.STRectAlignment
- *
- * @see org.apache.poi.sl.draw.binding.STRectAlignment
*/
public enum RectAlign {
/** Top-Left rectangle alignment */
Added: poi/trunk/src/multimodule/ooxml-schemas/java9/module-info.class
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/ooxml-schemas/java9/module-info.class?rev=1877398&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/src/multimodule/ooxml-schemas/java9/module-info.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: poi/trunk/src/multimodule/ooxml-schemas/java9/module-info.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/ooxml-schemas/java9/module-info.java?rev=1877398&view=auto
==============================================================================
--- poi/trunk/src/multimodule/ooxml-schemas/java9/module-info.java (added)
+++ poi/trunk/src/multimodule/ooxml-schemas/java9/module-info.java Tue May 5 13:36:30 2020
@@ -0,0 +1,50 @@
+/* ====================================================================
+ Copyright 2017 Andreas Beeker (kiwiwings@apache.org)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+
+open module org.apache.poi.ooxml.schemas {
+ requires transitive xmlbeans;
+ requires java.xml;
+ exports com.microsoft.schemas.compatibility;
+ exports com.microsoft.schemas.office.excel;
+ exports com.microsoft.schemas.office.office;
+ exports com.microsoft.schemas.office.powerpoint;
+ exports com.microsoft.schemas.office.visio.x2012.main;
+ exports com.microsoft.schemas.office.word;
+ exports com.microsoft.schemas.vml;
+ exports org.openxmlformats.schemas.drawingml.x2006.chart;
+ exports org.openxmlformats.schemas.drawingml.x2006.chartDrawing;
+ exports org.openxmlformats.schemas.drawingml.x2006.compatibility;
+ exports org.openxmlformats.schemas.drawingml.x2006.diagram;
+ exports org.openxmlformats.schemas.drawingml.x2006.lockedCanvas;
+ exports org.openxmlformats.schemas.drawingml.x2006.main;
+ exports org.openxmlformats.schemas.drawingml.x2006.picture;
+ exports org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing;
+ exports org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing;
+ exports org.openxmlformats.schemas.officeDocument.x2006.bibliography;
+ exports org.openxmlformats.schemas.officeDocument.x2006.characteristics;
+ exports org.openxmlformats.schemas.officeDocument.x2006.customProperties;
+ exports org.openxmlformats.schemas.officeDocument.x2006.customXml;
+ exports org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes;
+ exports org.openxmlformats.schemas.officeDocument.x2006.extendedProperties;
+ exports org.openxmlformats.schemas.officeDocument.x2006.math;
+ exports org.openxmlformats.schemas.officeDocument.x2006.relationships;
+ exports org.openxmlformats.schemas.presentationml.x2006.main;
+ exports org.openxmlformats.schemas.schemaLibrary.x2006.main;
+ exports org.openxmlformats.schemas.spreadsheetml.x2006.main;
+ exports org.openxmlformats.schemas.wordprocessingml.x2006.main;
+ // opens schemaorg_apache_xmlbeans.system.OoxmlSchemas to xmlbeans;
+}
\ No newline at end of file
Propchange: poi/trunk/src/multimodule/ooxml-schemas/java9/module-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: poi/trunk/src/multimodule/ooxml-security/java9/module-info.class
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/ooxml-security/java9/module-info.class?rev=1877398&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/src/multimodule/ooxml-security/java9/module-info.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: poi/trunk/src/multimodule/ooxml-security/java9/module-info.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/ooxml-security/java9/module-info.java?rev=1877398&view=auto
==============================================================================
--- poi/trunk/src/multimodule/ooxml-security/java9/module-info.java (added)
+++ poi/trunk/src/multimodule/ooxml-security/java9/module-info.java Tue May 5 13:36:30 2020
@@ -0,0 +1,31 @@
+/* ====================================================================
+ Copyright 2017 Andreas Beeker (kiwiwings@apache.org)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+
+open module org.apache.poi.ooxml.security {
+ requires transitive xmlbeans;
+ requires java.xml;
+ exports com.microsoft.schemas.office.x2006.digsig;
+ exports com.microsoft.schemas.office.x2006.encryption;
+ exports com.microsoft.schemas.office.x2006.keyEncryptor.certificate;
+ exports com.microsoft.schemas.office.x2006.keyEncryptor.password;
+ exports org.etsi.uri.x01903.v13;
+ exports org.etsi.uri.x01903.v14;
+ exports org.openxmlformats.schemas.xpackage.x2006.digitalSignature;
+ exports org.openxmlformats.schemas.xpackage.x2006.relationships;
+ exports org.w3.x2000.x09.xmldsig;
+ // opens schemaorg_apache_xmlbeans.system.OoxmlSecurity to xmlbeans;
+}
\ No newline at end of file
Propchange: poi/trunk/src/multimodule/ooxml-security/java9/module-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: poi/trunk/src/multimodule/poi/java9/module-info.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/multimodule/poi/java9/module-info.java?rev=1877398&view=auto
==============================================================================
--- poi/trunk/src/multimodule/poi/java9/module-info.java (added)
+++ poi/trunk/src/multimodule/poi/java9/module-info.java Tue May 5 13:36:30 2020
@@ -0,0 +1,86 @@
+/* ====================================================================
+ Copyright 2017 Andreas Beeker (kiwiwings@apache.org)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+module org.apache.poi.poi {
+ requires org.apache.commons.collections4;
+ requires org.apache.commons.codec;
+ requires commons.math3;
+ requires SparseBitSet;
+ requires commons.logging;
+
+
+ exports org.apache.poi.common.usermodel.fonts;
+ exports org.apache.poi.ddf;
+ exports org.apache.poi.extractor;
+ exports org.apache.poi.hpsf;
+ exports org.apache.poi.hpsf.extractor;
+ exports org.apache.poi.hpsf.wellknown;
+ exports org.apache.poi.hssf;
+ exports org.apache.poi.hssf.dev;
+ exports org.apache.poi.hssf.eventmodel;
+ exports org.apache.poi.hssf.eventusermodel;
+ exports org.apache.poi.hssf.eventusermodel.dummyrecord;
+ exports org.apache.poi.hssf.extractor;
+ exports org.apache.poi.hssf.model;
+ exports org.apache.poi.hssf.record;
+ exports org.apache.poi.hssf.record.aggregates;
+ exports org.apache.poi.hssf.record.cf;
+ exports org.apache.poi.hssf.record.chart;
+ exports org.apache.poi.hssf.record.common;
+ exports org.apache.poi.hssf.record.cont;
+ exports org.apache.poi.hssf.record.crypto;
+ exports org.apache.poi.hssf.record.pivottable;
+ exports org.apache.poi.hssf.usermodel;
+ exports org.apache.poi.hssf.usermodel.helpers;
+ exports org.apache.poi.hssf.util;
+ exports org.apache.poi.poifs.common;
+ exports org.apache.poi.poifs.crypt;
+ exports org.apache.poi.poifs.crypt.binaryrc4;
+ exports org.apache.poi.poifs.crypt.cryptoapi;
+ exports org.apache.poi.poifs.crypt.standard;
+ exports org.apache.poi.poifs.crypt.xor;
+ exports org.apache.poi.poifs.dev;
+ exports org.apache.poi.poifs.eventfilesystem;
+ exports org.apache.poi.poifs.filesystem;
+ exports org.apache.poi.poifs.macros;
+ exports org.apache.poi.poifs.nio;
+ exports org.apache.poi.poifs.property;
+ exports org.apache.poi.poifs.storage;
+ exports org.apache.poi.sl.draw;
+ exports org.apache.poi.sl.draw.geom;
+ exports org.apache.poi.sl.extractor;
+ exports org.apache.poi.sl.image;
+ exports org.apache.poi.sl.usermodel;
+ exports org.apache.poi.ss;
+ exports org.apache.poi.ss.extractor;
+ exports org.apache.poi.ss.format;
+ exports org.apache.poi.ss.formula;
+ exports org.apache.poi.ss.formula.atp;
+ exports org.apache.poi.ss.formula.constant;
+ exports org.apache.poi.ss.formula.eval;
+ exports org.apache.poi.ss.formula.eval.forked;
+ exports org.apache.poi.ss.formula.function;
+ exports org.apache.poi.ss.formula.functions;
+ exports org.apache.poi.ss.formula.ptg;
+ exports org.apache.poi.ss.formula.udf;
+ exports org.apache.poi.ss.usermodel;
+ exports org.apache.poi.ss.usermodel.charts;
+ exports org.apache.poi.ss.usermodel.helpers;
+ exports org.apache.poi.ss.util;
+ exports org.apache.poi.ss.util.cellwalk;
+ exports org.apache.poi.util;
+ exports org.apache.poi.wp.usermodel;
+}
\ No newline at end of file
Propchange: poi/trunk/src/multimodule/poi/java9/module-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java?rev=1877398&r1=1877397&r2=1877398&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java Tue May 5 13:36:30 2020
@@ -59,7 +59,7 @@ import org.openxmlformats.schemas.drawin
@Beta
public abstract class XSLFSimpleShape extends XSLFShape
implements SimpleShape<XSLFShape,XSLFTextParagraph> {
- private static CTOuterShadowEffect NO_SHADOW = CTOuterShadowEffect.Factory.newInstance();
+ private static final CTOuterShadowEffect NO_SHADOW = CTOuterShadowEffect.Factory.newInstance();
private static final POILogger LOG = POILogFactory.getLogger(XSLFSimpleShape.class);
/* package */XSLFSimpleShape(XmlObject shape, XSLFSheet sheet) {
@@ -981,7 +981,10 @@ public abstract class XSLFSimpleShape ex
//noinspection deprecation
for (CTGeomGuide g : gp.getPrstGeom().getAvLst().getGdArray()) {
if (g.getName().equals(name)) {
- return new Guide(g.getName(), g.getFmla());
+ Guide gd = new Guide();
+ gd.setName(g.getName());
+ gd.setFmla(g.getFmla());
+ return gd;
}
}
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java?rev=1877398&r1=1877397&r2=1877398&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java Tue May 5 13:36:30 2020
@@ -20,8 +20,10 @@ package org.apache.poi.xslf.geom;
import static org.junit.Assert.assertEquals;
-import org.apache.poi.sl.draw.binding.CTCustomGeometry2D;
-import org.apache.poi.sl.draw.geom.*;
+import org.apache.poi.sl.draw.geom.Context;
+import org.apache.poi.sl.draw.geom.CustomGeometry;
+import org.apache.poi.sl.draw.geom.Formula;
+import org.apache.poi.sl.draw.geom.Guide;
import org.junit.Test;
/**
@@ -34,17 +36,17 @@ public class TestFormulaParser {
public void testParse(){
Formula[] ops = {
- new Guide("adj1", "val 100"),
- new Guide("adj2", "val 200"),
- new Guide("adj3", "val -1"),
- new Guide("a1", "*/ adj1 2 adj2"), // a1 = 100*2 / 200
- new Guide("a2", "+- adj2 a1 adj1"), // a2 = 200 + a1 - 100
- new Guide("a3", "+/ adj1 adj2 adj2"), // a3 = (100 + 200) / 200
- new Guide("a4", "?: adj3 adj1 adj2"), // a4 = adj3 > 0 ? adj1 : adj2
- new Guide("a5", "abs -2"),
+ newGuide("adj1", "val 100"),
+ newGuide("adj2", "val 200"),
+ newGuide("adj3", "val -1"),
+ newGuide("a1", "*/ adj1 2 adj2"), // a1 = 100*2 / 200
+ newGuide("a2", "+- adj2 a1 adj1"), // a2 = 200 + a1 - 100
+ newGuide("a3", "+/ adj1 adj2 adj2"), // a3 = (100 + 200) / 200
+ newGuide("a4", "?: adj3 adj1 adj2"), // a4 = adj3 > 0 ? adj1 : adj2
+ newGuide("a5", "abs -2"),
};
- CustomGeometry geom = new CustomGeometry(new CTCustomGeometry2D());
+ CustomGeometry geom = new CustomGeometry();
Context ctx = new Context(geom, null, null);
for(Formula fmla : ops) {
ctx.evaluate(fmla);
@@ -58,4 +60,11 @@ public class TestFormulaParser {
assertEquals(200.0, ctx.getValue("a4"), 0.0);
assertEquals(2.0, ctx.getValue("a5"), 0.0);
}
+
+ private static Guide newGuide(String name, String fmla) {
+ Guide gd = new Guide();
+ gd.setName(name);
+ gd.setFmla(fmla);
+ return gd;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org