initial commit - still lots of errors, but I need to switch to a clean trunk for releasing and testing

git-svn-id: https://svn.apache.org/repos/asf/poi/branches/common_sl@1661322 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2015-02-21 10:56:03 +00:00
parent 8e701d0c4d
commit 996c9dd93c
207 changed files with 38606 additions and 2271 deletions

View File

@ -103,6 +103,12 @@ under the License.
<property name="scratchpad.output.test.dir" location="build/scratchpad-test-classes"/>
<property name="scratchpad.testokfile" location="build/scratchpad-testokfile.txt"/>
<!-- Scratchpad/Geometry -->
<property name="geometry.schema" value="src/resources/ooxml/org/apache/poi/xslf/usermodel/presetShapeDefinitions.xml"/>
<property name="geometry.pkg" value="org.apache.poi.sl.draw.binding"/>
<property name="geometry.output.tmpdir" value="build/geometry-java"/>
<!-- Examples: -->
<property name="examples.src" location="src/examples/src"/>
<property name="examples.output.dir" location="build/examples-classes"/>
@ -371,6 +377,7 @@ under the License.
<mkdir dir="${scratchpad.output.dir}"/>
<mkdir dir="${scratchpad.output.test.dir}"/>
<mkdir dir="${scratchpad.reports.test}"/>
<mkdir dir="${geometry.output.tmpdir}"/>
<mkdir dir="${ooxml.output.dir}"/>
<mkdir dir="${ooxml.output.test.dir}"/>
<mkdir dir="${ooxml.reports.test}"/>
@ -690,7 +697,38 @@ under the License.
</copy>
</target>
<target name="compile-scratchpad" depends="compile-main">
<target name="generate-geometry" depends="fetch-ooxml-xsds">
<delete dir="${geometry.output.tmpdir}"/>
<!-- taskdef xjc -->
<!-- "D:\Program Files\Java\jdk1.6.0_45\bin\xjc" -p org.apache.poi.sl.model.geom.binding -readOnly -Xlocator -mark-generated ooxml-schemas\dml-shapeGeometry.xsd -->
<unzip src="${ooxml.lib}/${ooxml.xsds.izip.1}" dest="${geometry.output.tmpdir}"/>
<exec executable="${env.JAVA_HOME}/bin/xjc">
<arg value="-p"/>
<arg value="${geometry.pkg}"/>
<arg value="-b"/>
<arg file="src/types/definitions/dml-shapeGeometry.xjb"/>
<arg value="-readOnly"/>
<arg value="-npa"/>
<arg value="-no-header"/>
<arg value="-Xlocator"/>
<arg file="${geometry.output.tmpdir}/dml-shapeGeometry.xsd"/>
<arg value="-d"/>
<arg file="${geometry.output.tmpdir}"/>
</exec>
<copy file="src/java/org/apache/poi/POIDocument.java" tofile="${geometry.output.tmpdir}/apache-license.txt">
<filterchain>
<headfilter lines="16"/>
</filterchain>
</copy>
<copy todir="${scratchpad.src}">
<fileset dir="${geometry.output.tmpdir}" includes="**/*.java"/>
<filterchain>
<concatfilter prepend="${geometry.output.tmpdir}/apache-license.txt"/>
</filterchain>
</copy>
</target>
<target name="compile-scratchpad" depends="compile-main,generate-geometry">
<javac target="${jdk.version.class}"
source="${jdk.version.source}"
destdir="${scratchpad.output.dir}"

View File

@ -20,6 +20,7 @@ package org.apache.poi.hslf.examples;
import org.apache.poi.hslf.usermodel.*;
import org.apache.poi.hslf.model.*;
import org.apache.poi.hslf.record.TextHeaderAtom;
import org.apache.poi.sl.usermodel.ShapeType;
import java.io.IOException;
import java.io.FileOutputStream;
@ -312,7 +313,7 @@ public final class ApacheconEU08 {
box3.setAnchor(new Rectangle(473, 243, 170, 170));
slide.addShape(box3);
AutoShape box4 = new AutoShape(ShapeTypes.Arrow);
AutoShape box4 = new AutoShape(ShapeType.RIGHT_ARROW);
box4.getFill().setForegroundColor(new Color(187, 224, 227));
box4.setLineWidth(0.75);
box4.setLineColor(Color.black);

View File

@ -24,6 +24,8 @@ import java.awt.geom.Rectangle2D;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.sl.usermodel.TextAlign;
/**
* PPTX Tables
*

View File

@ -519,7 +519,7 @@ public final class HSSFPatriarch implements HSSFShapeContainer, Drawing {
}
public Chart createChart(ClientAnchor anchor) {
throw new RuntimeException("NotImplemented");
throw new UnsupportedOperationException("NotImplemented");
}

View File

@ -42,17 +42,32 @@ public class Units {
}
/**
* Converts a value of type FixedPoint to a decimal number
* Converts a value of type FixedPoint to a floating point
*
* @param fixedPoint
* @return decimal number
* @return floating point (double)
*
* @see <a href="http://msdn.microsoft.com/en-us/library/dd910765(v=office.12).aspx">[MS-OSHARED] - 2.2.1.6 FixedPoint</a>
*/
public static double fixedPointToDecimal(int fixedPoint) {
public static double fixedPointToDouble(int fixedPoint) {
int i = (fixedPoint >> 16);
int f = (fixedPoint >> 0) & 0xFFFF;
double decimal = (i + f/65536.0);
return decimal;
double floatPoint = (i + f/65536d);
return floatPoint;
}
/**
* Converts a value of type floating point to a FixedPoint
*
* @param floatPoint
* @return fixedPoint
*
* @see <a href="http://msdn.microsoft.com/en-us/library/dd910765(v=office.12).aspx">[MS-OSHARED] - 2.2.1.6 FixedPoint</a>
*/
public static int doubleToFixedPoint(double floatPoint) {
int i = (int)Math.floor(floatPoint);
int f = (int)((floatPoint % 1d)*65536d);
int fixedPoint = (i << 16) | (f & 0xFFFF);
return fixedPoint;
}
}

View File

@ -19,8 +19,8 @@
package org.apache.poi.xslf.model;
import org.apache.poi.xslf.usermodel.XSLFSimpleShape;
import org.apache.poi.util.Internal;
import org.apache.poi.xslf.usermodel.XSLFShape;
/**
* Used internally to navigate the PresentationML text style hierarchy and fetch properties
@ -36,7 +36,7 @@ public abstract class PropertyFetcher<T> {
* @param shape the shape being examined
* @return true if the desired property was fetched
*/
public abstract boolean fetch(XSLFSimpleShape shape) ;
public abstract boolean fetch(XSLFShape shape) ;
public T getValue(){
return _value;

View File

@ -1,67 +0,0 @@
/*
* ====================================================================
* 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.xslf.model.geom;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.CTCustomGeometry2D;
import java.io.InputStream;
import java.util.LinkedHashMap;
/**
* Date: 10/25/11
*
* @author Yegor Kozlov
*/
public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
private static PresetGeometries _inst;
private PresetGeometries(){
try {
InputStream is =
XMLSlideShow.class.getResourceAsStream("presetShapeDefinitions.xml");
read(is);
} catch (Exception e){
throw new RuntimeException(e);
}
}
private void read(InputStream is) throws Exception {
XmlObject obj = XmlObject.Factory.parse(is);
for (XmlObject def : obj.selectPath("*/*")) {
String name = def.getDomNode().getLocalName();
CTCustomGeometry2D geom = CTCustomGeometry2D.Factory.parse(def.toString());
if(containsKey(name)) {
System.out.println("Duplicate definoition of " + name) ;
}
put(name, new CustomGeometry(geom));
}
}
public static PresetGeometries getInstance(){
if(_inst == null) _inst = new PresetGeometries();
return _inst;
}
}

View File

@ -1,34 +0,0 @@
/* ====================================================================
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.xslf.usermodel;
/**
* @author Yegor Kozlov
*/
public enum LineDash {
SOLID,
DOT,
DASH,
LG_DASH,
DASH_DOT,
LG_DASH_DOT,
LG_DASH_DOT_DOT,
SYS_DASH,
SYS_DOT,
SYS_DASH_DOT,
SYS_DASH_DOT_DOT;
}

View File

@ -40,6 +40,8 @@ import java.util.Comparator;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.sl.usermodel.LineCap;
import org.apache.poi.sl.usermodel.LineDash;
import org.apache.poi.util.Internal;
import org.apache.poi.util.Units;
import org.apache.poi.xslf.model.PropertyFetcher;

View File

@ -1,50 +0,0 @@
/*
* ====================================================================
* 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.xslf.usermodel;
/**
* Specified a list of text alignment types
*
* @author Yegor Kozlov
*/
public enum TextAlign {
/**
* Align text to the left margin.
*/
LEFT,
/**
* Align text in the center.
*/
CENTER,
/**
* Align text to the right margin.
*/
RIGHT,
/**
* Align text so that it is justified across the whole line. It
* is smart in the sense that it will not justify sentences
* which are short
*/
JUSTIFY,
JUSTIFY_LOW,
DIST,
THAI_DIST
}

View File

@ -1,59 +0,0 @@
/*
* ====================================================================
* 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.xslf.usermodel;
/**
* Specifies alist of auto-fit types.
* <p>
* Autofit specofies that a shape should be auto-fit to fully contain the text described within it.
* Auto-fitting is when text within a shape is scaled in order to contain all the text inside
* </p>
*
* @author Yegor Kozlov
*/
public enum TextAutofit {
/**
* Specifies that text within the text body should not be auto-fit to the bounding box.
* Auto-fitting is when text within a text box is scaled in order to remain inside
* the text box.
*/
NONE,
/**
* Specifies that text within the text body should be normally auto-fit to the bounding box.
* Autofitting is when text within a text box is scaled in order to remain inside the text box.
*
* <p>
* <em>Example:</em> Consider the situation where a user is building a diagram and needs
* to have the text for each shape that they are using stay within the bounds of the shape.
* An easy way this might be done is by using NORMAL autofit
* </p>
*/
NORMAL,
/**
* Specifies that a shape should be auto-fit to fully contain the text described within it.
* Auto-fitting is when text within a shape is scaled in order to contain all the text inside.
*
* <p>
* <em>Example:</em> Consider the situation where a user is building a diagram and needs to have
* the text for each shape that they are using stay within the bounds of the shape.
* An easy way this might be done is by using SHAPE autofit
* </p>
*/
SHAPE
}

View File

@ -1,48 +0,0 @@
/*
* ====================================================================
* 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.xslf.usermodel;
/**
* Vertical Text Types
*/
public enum TextDirection {
/**
* Horizontal text. This should be default.
*/
HORIZONTAL,
/**
* Vertical orientation.
* (each line is 90 degrees rotated clockwise, so it goes
* from top to bottom; each next line is to the left from
* the previous one).
*/
VERTICAL,
/**
* Vertical orientation.
* (each line is 270 degrees rotated clockwise, so it goes
* from bottom to top; each next line is to the right from
* the previous one).
*/
VERTICAL_270,
/**
* Determines if all of the text is vertical
* ("one letter on top of another").
*/
STACKED;
}

View File

@ -1,90 +0,0 @@
/*
* ====================================================================
* 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.xslf.usermodel;
import java.awt.*;
import java.awt.font.TextLayout;
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
import java.text.CharacterIterator;
/**
* a renderable text fragment
*/
class TextFragment {
final TextLayout _layout;
final AttributedString _str;
TextFragment(TextLayout layout, AttributedString str){
_layout = layout;
_str = str;
}
void draw(Graphics2D graphics, double x, double y){
if(_str == null) {
return;
}
double yBaseline = y + _layout.getAscent();
Integer textMode = (Integer)graphics.getRenderingHint(XSLFRenderingHint.TEXT_RENDERING_MODE);
if(textMode != null && textMode == XSLFRenderingHint.TEXT_AS_SHAPES){
_layout.draw(graphics, (float)x, (float)yBaseline);
} else {
graphics.drawString(_str.getIterator(), (float)x, (float)yBaseline );
}
}
/**
* @return full height of this text run which is sum of ascent, descent and leading
*/
public float getHeight(){
double h = Math.ceil(_layout.getAscent()) + Math.ceil(_layout.getDescent()) + _layout.getLeading();
return (float)h;
}
/**
*
* @return width if this text run
*/
public float getWidth(){
return _layout.getAdvance();
}
/**
*
* @return the string to be painted
*/
public String getString(){
if(_str == null) return "";
AttributedCharacterIterator it = _str.getIterator();
StringBuffer buf = new StringBuffer();
for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
buf.append(c);
}
return buf.toString();
}
@Override
public String toString(){
return "[" + getClass().getSimpleName() + "] " + getString();
}
}

View File

@ -20,7 +20,11 @@ import java.awt.Dimension;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.poi.POIXMLDocument;
@ -32,6 +36,9 @@ import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.TargetMode;
import org.apache.poi.sl.usermodel.MasterSheet;
import org.apache.poi.sl.usermodel.Resources;
import org.apache.poi.sl.usermodel.SlideShow;
import org.apache.poi.util.Beta;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
@ -53,6 +60,10 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideSize;
import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import com.sun.org.apache.xml.internal.utils.UnImplNode;
/**
* High level representation of a ooxml slideshow.
* This is the first object most users will construct whether
@ -60,7 +71,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument
* top level object for creating new slides/etc.
*/
@Beta
public class XMLSlideShow extends POIXMLDocument {
public class XMLSlideShow extends POIXMLDocument implements SlideShow {
private static POILogger _logger = POILogFactory.getLogger(XMLSlideShow.class);
private CTPresentation _presentation;
@ -437,7 +448,7 @@ public class XMLSlideShow extends POIXMLDocument {
*/
public int addPicture(byte[] pictureData, int format) {
XSLFPictureData img = findPictureData(pictureData);
POIXMLRelation relDesc = XSLFPictureData.RELATIONS[format];
// POIXMLRelation relDesc = XSLFPictureData.RELATIONS[format];
if(img == null) {
int imageNumber = _pictures.size();
@ -485,4 +496,17 @@ public class XMLSlideShow extends POIXMLDocument {
return null;
}
public MasterSheet<XSLFShape>[] getMasterSheet() {
return getSlideMasters();
}
public MasterSheet<XSLFShape> createMasterSheet() throws IOException {
// TODO: implement!
throw new UnsupportedOperationException();
}
public Resources getResources() {
// TODO: implement!
throw new UnsupportedOperationException();
}
}

View File

@ -19,6 +19,7 @@
package org.apache.poi.xslf.usermodel;
import org.apache.poi.sl.usermodel.AutoShape;
import org.apache.poi.util.Beta;
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
@ -35,7 +36,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual;
* @author Yegor Kozlov
*/
@Beta
public class XSLFAutoShape extends XSLFTextShape {
public class XSLFAutoShape extends XSLFTextShape implements AutoShape {
/*package*/ XSLFAutoShape(CTShape shape, XSLFSheet sheet) {
super(shape, sheet);

View File

@ -17,25 +17,20 @@
package org.apache.poi.xslf.usermodel;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.CTBackgroundFillStyleList;
import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import org.apache.poi.sl.usermodel.Background;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;
/**
* Background shape
*
* @author Yegor Kozlov
*/
public class XSLFBackground extends XSLFSimpleShape {
public class XSLFBackground extends XSLFSimpleShape implements Background {
/* package */XSLFBackground(CTBackground shape, XSLFSheet sheet) {
super(shape, sheet);

View File

@ -18,22 +18,18 @@
*/
package org.apache.poi.xslf.usermodel;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTHslColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTScRgbColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTSystemColor;
import org.w3c.dom.Node;
import java.awt.Color;
import java.util.HashMap;
import java.util.Map;
import org.apache.poi.sl.draw.DrawPaint;
import org.apache.poi.sl.usermodel.ColorStyle;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.w3c.dom.Node;
/**
* Encapsulates logic to read color definitions from DrawingML and convert them to java.awt.Color
*
@ -63,38 +59,35 @@ public class XSLFColor {
* If not color information was found in the supplied xml object then a null is returned.
*/
public Color getColor() {
return _color == null ? null : applyColorTransform(_color);
return DrawPaint.applyColorTransform(getColorStyle());
}
private Color applyColorTransform(Color color){
Color result = color;
int alpha = getAlpha();
if(alpha != -1){
result = new Color(
result.getRed(), result.getGreen(), result.getBlue(),
Math.round(255 * alpha * 0.01f));
public ColorStyle getColorStyle() {
return new ColorStyle() {
public Color getColor() {
return _color;
}
int lumOff = getLumOff();
int lumMod = getLumMod();
if(lumMod != -1 || lumOff != -1){
result = modulateLuminanace(result,
lumMod == -1 ? 100 : lumMod,
lumOff == -1 ? 0 : lumOff);
public int getAlpha() {
return getRawValue("alpha");
}
int shade = getShade();
if(shade != -1){
result = shade(result, shade);
public int getLumOff() {
return getRawValue("lumOff");
}
int tint = getTint();
if(tint != -1){
result = tint(result, tint);
public int getLumMod() {
return getRawValue("lumMod");
}
return result;
public int getShade() {
return getRawValue("shade");
}
public int getTint() {
return getRawValue("tint");
}
};
}
Color toColor(XmlObject obj, XSLFTheme theme) {
@ -140,6 +133,7 @@ public class XSLFColor {
color = new Color(0xFF & val[0], 0xFF & val[1], 0xFF & val[2]);
} else {
// YK: color is a string like "menuText" or "windowText", we return black for such cases
@SuppressWarnings("unused")
String colorName = sys.getVal().toString();
color = Color.black;
}
@ -150,6 +144,33 @@ public class XSLFColor {
return color;
}
private int getRawValue(String elem) {
String query = "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' $this//a:" + elem;
XmlObject[] obj;
// first ask the context color and if not found, ask the actual color bean
if (_phClr != null){
obj = _phClr.selectPath(query);
if (obj.length == 1){
Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
if(attr != null) {
return Integer.parseInt(attr.getNodeValue());
}
}
}
obj = _xmlObject.selectPath(query);
if (obj.length == 1){
Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
if(attr != null) {
return Integer.parseInt(attr.getNodeValue());
}
}
return -1;
}
/**
* Read a perecentage value from the supplied xml bean.
* Example:
@ -160,56 +181,13 @@ public class XSLFColor {
* @return the percentage value in the range [0 .. 100]
*/
private int getPercentageValue(String elem){
String query = "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' $this//a:" + elem;
XmlObject[] obj;
// first ask the context color and if not found, ask the actual color bean
if(_phClr != null){
obj = _phClr.selectPath(query);
if(obj.length == 1){
Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
if(attr != null) {
return Integer.parseInt(attr.getNodeValue()) / 1000;
}
}
}
obj = _xmlObject.selectPath(query);
if(obj.length == 1){
Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
if(attr != null) {
return Integer.parseInt(attr.getNodeValue()) / 1000;
}
}
return -1;
int val = getRawValue(elem);
return (val == -1) ? val : (val / 1000);
}
private int getAngleValue(String elem){
String color = "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' $this//a:" + elem;
XmlObject[] obj;
// first ask the context color and if not found, ask the actual color bean
if(_phClr != null){
obj = _xmlObject.selectPath( color );
if(obj.length == 1){
Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
if(attr != null) {
return Integer.parseInt(attr.getNodeValue()) / 60000;
}
}
}
obj = _xmlObject.selectPath( color );
if(obj.length == 1){
Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
if(attr != null) {
return Integer.parseInt(attr.getNodeValue()) / 60000;
}
}
return -1;
int val = getRawValue(elem);
return (val == -1) ? val : (val / 60000);
}
/**
@ -387,7 +365,7 @@ public class XSLFColor {
* percentage with 0% indicating minimal shade and 100% indicating maximum
* or -1 if the value is not set
*/
int getShade(){
public int getShade(){
return getPercentageValue("shade");
}
@ -399,69 +377,11 @@ public class XSLFColor {
* percentage with 0% indicating minimal tint and 100% indicating maximum
* or -1 if the value is not set
*/
int getTint(){
public int getTint(){
return getPercentageValue("tint");
}
/**
* Apply lumMod / lumOff adjustments
*
* @param c the color to modify
* @param lumMod luminance modulation in the range [0..100]
* @param lumOff luminance offset in the range [0..100]
* @return modified color
*/
private static Color modulateLuminanace(Color c, int lumMod, int lumOff) {
Color color;
if (lumOff > 0) {
color = new Color(
(int) (Math.round((255 - c.getRed()) * (100.0 - lumMod) / 100.0 + c.getRed())),
(int) (Math.round((255 - c.getGreen()) * lumOff / 100.0 + c.getGreen())),
(int) (Math.round((255 - c.getBlue()) * lumOff / 100.0 + c.getBlue())),
c.getAlpha()
);
} else {
color = new Color(
(int) (Math.round(c.getRed() * lumMod / 100.0)),
(int) (Math.round(c.getGreen() * lumMod / 100.0)),
(int) (Math.round(c.getBlue() * lumMod / 100.0)),
c.getAlpha()
);
}
return color;
}
/**
* This algorithm returns result different from PowerPoint.
* TODO: revisit and improve
*/
private static Color shade(Color c, int shade) {
return new Color(
(int)(c.getRed() * shade * 0.01),
(int)(c.getGreen() * shade * 0.01),
(int)(c.getBlue() * shade * 0.01),
c.getAlpha());
}
/**
* This algorithm returns result different from PowerPoint.
* TODO: revisit and improve
*/
private static Color tint(Color c, int tint) {
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();
float ftint = tint / 100.0f;
int red = Math.round(ftint * r + (1 - ftint) * 255);
int green = Math.round(ftint * g + (1 - ftint) * 255);
int blue = Math.round(ftint * b + (1 - ftint) * 255);
return new Color(red, green, blue);
}
/**
* Preset colors defined in DrawingML
*/

View File

@ -23,6 +23,7 @@ import org.apache.poi.POIXMLException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Units;
import org.apache.xmlbeans.XmlCursor;
@ -34,6 +35,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
import javax.xml.namespace.QName;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
@ -58,8 +60,8 @@ public class XSLFGraphicFrame extends XSLFShape {
return _sheet;
}
public int getShapeType(){
throw new RuntimeException("NotImplemented");
public ShapeType getShapeType(){
throw new UnsupportedOperationException();
}
public int getShapeId(){

View File

@ -19,9 +19,17 @@
package org.apache.poi.xslf.usermodel;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.TargetMode;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Units;
import org.apache.xmlbeans.XmlObject;
@ -35,13 +43,6 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
/**
* Represents a group shape that consists of many shapes grouped together.
*
@ -207,30 +208,35 @@ public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer {
public XSLFAutoShape createAutoShape(){
XSLFAutoShape sh = getDrawing().createAutoShape();
_shapes.add(sh);
sh.setParent(this);
return sh;
}
public XSLFFreeformShape createFreeform(){
XSLFFreeformShape sh = getDrawing().createFreeform();
_shapes.add(sh);
sh.setParent(this);
return sh;
}
public XSLFTextBox createTextBox(){
XSLFTextBox sh = getDrawing().createTextBox();
_shapes.add(sh);
sh.setParent(this);
return sh;
}
public XSLFConnectorShape createConnector(){
XSLFConnectorShape sh = getDrawing().createConnector();
_shapes.add(sh);
sh.setParent(this);
return sh;
}
public XSLFGroupShape createGroup(){
XSLFGroupShape sh = getDrawing().createGroup();
_shapes.add(sh);
sh.setParent(this);
return sh;
}
@ -251,6 +257,7 @@ public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer {
XSLFPictureShape sh = getDrawing().createPicture(rel.getId());
sh.resize();
_shapes.add(sh);
sh.setParent(this);
return sh;
}
@ -343,4 +350,13 @@ public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer {
}
}
public ShapeType getShapeType(){
return null;
}
public void addShape(XSLFShape shape) {
throw new UnsupportedOperationException(
"Adding a shape from a different container is not supported -"
+ " create it from scratch witht XSLFGroupShape.create* methods");
}
}

View File

@ -21,6 +21,8 @@ import java.io.IOException;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.sl.usermodel.Notes;
import org.apache.poi.sl.usermodel.TextRun;
import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
@ -28,7 +30,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument;
@Beta
public final class XSLFNotes extends XSLFSheet {
public final class XSLFNotes extends XSLFSheet implements Notes<XSLFShape> {
private CTNotesSlide _notes;
/**
@ -80,7 +82,6 @@ public final class XSLFNotes extends XSLFSheet {
return getMasterSheet().getTheme();
}
@Override
public XSLFNotesMaster getMasterSheet() {
for (POIXMLDocumentPart p : getRelations()) {
if (p instanceof XSLFNotesMaster){
@ -89,4 +90,20 @@ public final class XSLFNotes extends XSLFSheet {
}
return null;
}
public TextRun getTextRun() {
for (XSLFShape sh : super.getShapes()) {
if (sh instanceof XSLFTextShape) {
XSLFTextShape txt = (XSLFTextShape)sh;
for (XSLFTextParagraph p : txt.getTextParagraphs()) {
for (XSLFTextRun r : p.getTextRuns()) {
return r;
}
}
}
}
return null;
}
}

View File

@ -23,6 +23,7 @@ import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.POIXMLException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.sl.usermodel.MasterSheet;
import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.drawingml.x2006.main.CTColorMapping;
@ -46,7 +47,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
* @author Yegor Kozlov
*/
@Beta
public class XSLFNotesMaster extends XSLFSheet {
public class XSLFNotesMaster extends XSLFSheet implements MasterSheet<XSLFShape> {
private CTNotesMaster _slide;
private XSLFTheme _theme;
@ -93,7 +94,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
}
@Override
public XSLFSheet getMasterSheet() {
public MasterSheet getMasterSheet() {
return null;
}

View File

@ -17,6 +17,7 @@
package org.apache.poi.xslf.usermodel;
import org.apache.poi.sl.usermodel.Shadow;
import org.apache.poi.util.Units;
import org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect;
import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
@ -31,7 +32,7 @@ import java.awt.geom.Rectangle2D;
*
* @author Yegor Kozlov
*/
public class XSLFShadow extends XSLFSimpleShape {
public class XSLFShadow extends XSLFSimpleShape implements Shadow {
private XSLFSimpleShape _parent;

View File

@ -19,13 +19,25 @@
package org.apache.poi.xslf.usermodel;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.Color;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Comparator;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.sl.draw.DrawPaint;
import org.apache.poi.sl.draw.geom.CustomGeometry;
import org.apache.poi.sl.usermodel.*;
import org.apache.poi.util.*;
import org.apache.poi.xslf.model.PropertyFetcher;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
/**
* Base super-class class for all shapes in PresentationML
@ -33,24 +45,42 @@ import org.apache.xmlbeans.XmlObject;
* @author Yegor Kozlov
*/
@Beta
public abstract class XSLFShape {
public abstract class XSLFShape implements Shape {
protected final XmlObject _shape;
protected final XSLFSheet _sheet;
protected XSLFShapeContainer _parent;
/**
* @return the position of this shape within the drawing canvas.
* The coordinates are expressed in points
*/
public abstract Rectangle2D getAnchor();
private CTShapeProperties _spPr;
private CTShapeStyle _spStyle;
private CTNonVisualDrawingProps _nvPr;
private CTPlaceholder _ph;
private static final PaintStyle TRANSPARENT_PAINT = new SolidPaint() {
public ColorStyle getSolidColor() {
return new ColorStyle(){
public Color getColor() { return DrawPaint.NO_PAINT; }
public int getAlpha() { return -1; }
public int getLumOff() { return -1; }
public int getLumMod() { return -1; }
public int getShade() { return -1; }
public int getTint() { return -1; }
};
}
};
protected XSLFShape(XmlObject shape, XSLFSheet sheet) {
_shape = shape;
_sheet = sheet;
}
/**
* @param anchor the position of this shape within the drawing canvas.
* The coordinates are expressed in points
*/
public abstract void setAnchor(Rectangle2D anchor);
/**
* @return the xml bean holding this shape's data
*/
public abstract XmlObject getXmlObject();
public XmlObject getXmlObject() {
return _shape;
}
/**
* @return human-readable name of this shape, e.g. "Rectange 3"
@ -118,84 +148,6 @@ public abstract class XSLFShape {
*/
public abstract boolean getFlipVertical();
/**
* Draw this shape into the supplied canvas
*
* @param graphics the graphics to draw into
*/
public abstract void draw(Graphics2D graphics);
/**
* Apply 2-D transforms before drawing this shape. This includes rotation and flipping.
*
* @param graphics the graphics whos transform matrix will be modified
*/
protected void applyTransform(Graphics2D graphics) {
Rectangle2D anchor = getAnchor();
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(XSLFRenderingHint.GROUP_TRANSFORM);
if(tx != null) {
anchor = tx.createTransformedShape(anchor).getBounds2D();
}
// rotation
double rotation = getRotation();
if (rotation != 0.) {
// PowerPoint rotates shapes relative to the geometric center
double centerX = anchor.getCenterX();
double centerY = anchor.getCenterY();
// normalize rotation
rotation = (360.+(rotation%360.))%360.;
int quadrant = (((int)rotation+45)/90)%4;
double scaleX = 1.0, scaleY = 1.0;
// scale to bounding box (bug #53176)
if (quadrant == 1 || quadrant == 3) {
// In quadrant 1 and 3, which is basically a shape in a more or less portrait orientation
// (45-135 degrees and 225-315 degrees), we need to first rotate the shape by a multiple
// of 90 degrees and then resize the bounding box to its original bbox. After that we can
// rotate the shape to the exact rotation amount.
// It's strange that you'll need to rotate the shape back and forth again, but you can
// think of it, as if you paint the shape on a canvas. First you rotate the canvas, which might
// be already (differently) scaled, so you can paint the shape in its default orientation
// and later on, turn it around again to compare it with its original size ...
AffineTransform txg = new AffineTransform(); // graphics coordinate space
AffineTransform txs = new AffineTransform(tx); // shape coordinate space
txg.translate(centerX, centerY);
txg.rotate(Math.toRadians(quadrant*90));
txg.translate(-centerX, -centerY);
txs.translate(centerX, centerY);
txs.rotate(Math.toRadians(-quadrant*90));
txs.translate(-centerX, -centerY);
txg.concatenate(txs);
Rectangle2D anchor2 = txg.createTransformedShape(getAnchor()).getBounds2D();
scaleX = anchor.getWidth() == 0. ? 1.0 : anchor.getWidth() / anchor2.getWidth();
scaleY = anchor.getHeight() == 0. ? 1.0 : anchor.getHeight() / anchor2.getHeight();
}
// transformation is applied reversed ...
graphics.translate(centerX, centerY);
graphics.rotate(Math.toRadians(rotation-(double)(quadrant*90)));
graphics.scale(scaleX, scaleY);
graphics.rotate(Math.toRadians(quadrant*90));
graphics.translate(-centerX, -centerY);
}
//flip horizontal
if (getFlipHorizontal()) {
graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
graphics.scale(-1, 1);
graphics.translate(-anchor.getX(), -anchor.getY());
}
//flip vertical
if (getFlipVertical()) {
graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
graphics.scale(1, -1);
graphics.translate(-anchor.getX(), -anchor.getY());
}
}
/**
* Set the contents of this shape to be a copy of the source shape.
* This method is called recursively for each shape when merging slides
@ -212,4 +164,402 @@ public abstract class XSLFShape {
setAnchor(sh.getAnchor());
}
public void setParent(XSLFShapeContainer parent) {
this._parent = parent;
}
public XSLFShapeContainer getParent() {
return this._parent;
}
public boolean isPlaceholder() {
return false;
}
public StrokeStyle getStrokeStyle() {
// TODO Auto-generated method stub
return null;
}
public CustomGeometry getGeometry() {
// TODO Auto-generated method stub
return null;
}
public ShapeType getShapeType() {
// TODO Auto-generated method stub
return null;
}
public XSLFSheet getSheet() {
// TODO Auto-generated method stub
return null;
}
/**
* fetch shape fill as a java.awt.Paint
*
* @return either Color or GradientPaint or TexturePaint or null
*/
@Override
public FillStyle getFillStyle() {
return new FillStyle() {
public PaintStyle getPaint() {
PropertyFetcher<PaintStyle> fetcher = new PropertyFetcher<PaintStyle>() {
public boolean fetch(XSLFShape shape) {
CTShapeProperties spPr = shape.getSpPr();
if (spPr.isSetNoFill()) {
setValue(TRANSPARENT_PAINT);
return true;
}
PaintStyle paint = null;
for (XmlObject obj : spPr.selectPath("*")) {
paint = selectPaint(obj, null, getSheet().getPackagePart());
if (paint != null) break;
}
if (paint == null) return false;
setValue(paint);
return true;
}
};
fetchShapeProperty(fetcher);
PaintStyle paint = fetcher.getValue();
if (paint != null) return paint;
// fill color was not found, check if it is defined in the theme
CTShapeStyle style = getSpStyle();
if (style != null) {
// get a reference to a fill style within the style matrix.
CTStyleMatrixReference fillRef = style.getFillRef();
// The idx attribute refers to the index of a fill style or
// background fill style within the presentation's style matrix, defined by the fmtScheme element.
// value of 0 or 1000 indicates no background,
// values 1-999 refer to the index of a fill style within the fillStyleLst element
// values 1001 and above refer to the index of a background fill style within the bgFillStyleLst element.
int idx = (int)fillRef.getIdx();
CTSchemeColor phClr = fillRef.getSchemeClr();
XSLFSheet sheet = _sheet;
XSLFTheme theme = sheet.getTheme();
XmlObject fillProps = null;
CTStyleMatrix matrix = theme.getXmlObject().getThemeElements().getFmtScheme();
if(idx >= 1 && idx <= 999){
fillProps = matrix.getFillStyleLst().selectPath("*")[idx - 1];
} else if (idx >= 1001 ){
fillProps = matrix.getBgFillStyleLst().selectPath("*")[idx - 1001];
}
if(fillProps != null) {
paint = selectPaint(fillProps, phClr, sheet.getPackagePart());
}
}
return paint == RenderableShape.NO_PAINT ? null : paint;
}
};
}
/**
* Walk up the inheritance tree and fetch shape properties.
*
* The following order of inheritance is assumed:
* <p>
* slide <-- slideLayout <-- slideMaster
* </p>
*
* @param visitor the object that collects the desired property
* @return true if the property was fetched
*/
protected boolean fetchShapeProperty(PropertyFetcher<?> visitor) {
boolean ok = visitor.fetch(this);
XSLFSimpleShape masterShape;
XSLFSheet masterSheet = (XSLFSheet)getSheet().getMasterSheet();
CTPlaceholder ph = getCTPlaceholder();
if (masterSheet != null && ph != null) {
if (!ok) {
masterShape = masterSheet.getPlaceholder(ph);
if (masterShape != null) {
ok = visitor.fetch(masterShape);
}
}
// try slide master
if (!ok ) {
int textType;
if ( !ph.isSetType()) textType = STPlaceholderType.INT_BODY;
else {
switch (ph.getType().intValue()) {
case STPlaceholderType.INT_TITLE:
case STPlaceholderType.INT_CTR_TITLE:
textType = STPlaceholderType.INT_TITLE;
break;
case STPlaceholderType.INT_FTR:
case STPlaceholderType.INT_SLD_NUM:
case STPlaceholderType.INT_DT:
textType = ph.getType().intValue();
break;
default:
textType = STPlaceholderType.INT_BODY;
break;
}
}
XSLFSheet master = (XSLFSheet)masterSheet.getMasterSheet();
if (master != null) {
masterShape = master.getPlaceholderByType(textType);
if (masterShape != null) {
ok = visitor.fetch(masterShape);
}
}
}
}
return ok;
}
protected CTPlaceholder getCTPlaceholder() {
if (_ph == null) {
XmlObject[] obj = _shape.selectPath(
"declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:nvPr/p:ph");
if (obj.length == 1) {
_ph = (CTPlaceholder) obj[0];
}
}
return _ph;
}
protected CTShapeStyle getSpStyle() {
if (_spStyle == null) {
for (XmlObject obj : _shape.selectPath("*")) {
if (obj instanceof CTShapeStyle) {
_spStyle = (CTShapeStyle) obj;
}
}
}
return _spStyle;
}
protected CTNonVisualDrawingProps getNvPr() {
if (_nvPr == null) {
XmlObject[] rs = _shape
.selectPath("declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:cNvPr");
if (rs.length != 0) {
_nvPr = (CTNonVisualDrawingProps) rs[0];
}
}
return _nvPr;
}
protected CTShapeProperties getSpPr() {
if (_spPr == null) {
for (XmlObject obj : _shape.selectPath("*")) {
if (obj instanceof CTShapeProperties) {
_spPr = (CTShapeProperties) obj;
}
}
}
if (_spPr == null) {
throw new IllegalStateException("CTShapeProperties was not found.");
}
return _spPr;
}
CTTransform2D getXfrm() {
PropertyFetcher<CTTransform2D> fetcher = new PropertyFetcher<CTTransform2D>() {
public boolean fetch(XSLFShape shape) {
CTShapeProperties pr = shape.getSpPr();
if (pr.isSetXfrm()) {
setValue(pr.getXfrm());
return true;
}
return false;
}
};
fetchShapeProperty(fetcher);
return fetcher.getValue();
}
/**
* @return the position of this shape within the drawing canvas.
* The coordinates are expressed in points
*/
public Rectangle2D getAnchor() {
CTTransform2D xfrm = getXfrm();
if (xfrm == null) return null;
CTPoint2D off = xfrm.getOff();
long x = off.getX();
long y = off.getY();
CTPositiveSize2D ext = xfrm.getExt();
long cx = ext.getCx();
long cy = ext.getCy();
return new Rectangle2D.Double(
Units.toPoints(x), Units.toPoints(y),
Units.toPoints(cx), Units.toPoints(cy));
}
/**
* @param anchor the position of this shape within the drawing canvas.
* The coordinates are expressed in points
*/
public void setAnchor(Rectangle2D anchor) {
CTShapeProperties spPr = getSpPr();
if (spPr == null) return;
CTTransform2D xfrm = spPr.isSetXfrm() ? spPr.getXfrm() : spPr.addNewXfrm();
CTPoint2D off = xfrm.isSetOff() ? xfrm.getOff() : xfrm.addNewOff();
long x = Units.toEMU(anchor.getX());
long y = Units.toEMU(anchor.getY());
off.setX(x);
off.setY(y);
CTPositiveSize2D ext = xfrm.isSetExt() ? xfrm.getExt() : xfrm
.addNewExt();
long cx = Units.toEMU(anchor.getWidth());
long cy = Units.toEMU(anchor.getHeight());
ext.setCx(cx);
ext.setCy(cy);
}
/**
* Convert shape fill into java.awt.Paint. The result is either Color or
* TexturePaint or GradientPaint or null
*
* @param graphics the target graphics
* @param obj the xml to read. Must contain elements from the EG_ColorChoice group:
* <code>
* a:scrgbClr RGB Color Model - Percentage Variant
* a:srgbClr RGB Color Model - Hex Variant
* a:hslClr Hue, Saturation, Luminance Color Model
* a:sysClr System Color
* a:schemeClr Scheme Color
* a:prstClr Preset Color
* </code>
*
* @param phClr context color
* @param parentPart the parent package part. Any external references (images, etc.) are resolved relative to it.
*
* @return the applied Paint or null if none was applied
*/
protected PaintStyle selectPaint(XmlObject obj, final CTSchemeColor phClr, final PackagePart parentPart) {
final XSLFTheme theme = getSheet().getTheme();
if (obj instanceof CTNoFillProperties) {
return TRANSPARENT_PAINT;
}
if (obj instanceof CTSolidColorFillProperties) {
CTSolidColorFillProperties solidFill = (CTSolidColorFillProperties) obj;
final XSLFColor c = new XSLFColor(solidFill, theme, phClr);
return new SolidPaint() {
public ColorStyle getSolidColor() {
return c.getColorStyle();
}
};
}
if (obj instanceof CTBlipFillProperties) {
CTBlipFillProperties blipFill = (CTBlipFillProperties)obj;
final CTBlip blip = blipFill.getBlip();
return new TexturePaint() {
private PackagePart getPart() {
try {
String blipId = blip.getEmbed();
PackageRelationship rel = parentPart.getRelationship(blipId);
return parentPart.getRelatedPart(rel);
} catch (InvalidFormatException e) {
throw new RuntimeException(e);
}
}
public InputStream getImageData() {
try {
return getPart().getInputStream();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public String getContentType() {
/* TOOD: map content-type */
return getPart().getContentType();
}
public int getAlpha() {
return (blip.sizeOfAlphaModFixArray() > 0)
? blip.getAlphaModFixArray(0).getAmt()
: 0;
}
};
}
if (obj instanceof CTGradientFillProperties) {
final CTGradientFillProperties gradFill = (CTGradientFillProperties) obj;
@SuppressWarnings("deprecation")
final CTGradientStop[] gs = gradFill.getGsLst().getGsArray();
Arrays.sort(gs, new Comparator<CTGradientStop>() {
public int compare(CTGradientStop o1, CTGradientStop o2) {
Integer pos1 = o1.getPos();
Integer pos2 = o2.getPos();
return pos1.compareTo(pos2);
}
});
final ColorStyle cs[] = new ColorStyle[gs.length];
final float fractions[] = new float[gs.length];
int i=0;
for (CTGradientStop cgs : gs) {
cs[i] = new XSLFColor(cgs, theme, phClr).getColorStyle();
fractions[i] = cgs.getPos() / 100000.f;
}
return new GradientPaint() {
public double getGradientAngle() {
return (gradFill.isSetLin())
? gradFill.getLin().getAng() / 60000.d
: 0;
}
public ColorStyle[] getGradientColors() {
return cs;
}
public float[] getGradientFractions() {
return fractions;
}
public boolean isRotatedWithShape() {
// TODO: is this correct???
return (gradFill.isSetRotWithShape() || !gradFill.getRotWithShape());
}
public GradientType getGradientType() {
if (gradFill.isSetLin()) {
return GradientType.linear;
}
if (gradFill.isSetPath()) {
/* TODO: handle rect path */
STPathShadeType.Enum ps = gradFill.getPath().getPath();
if (ps == STPathShadeType.CIRCLE) {
return GradientType.circular;
} else if (ps == STPathShadeType.SHAPE) {
return GradientType.shape;
}
}
return GradientType.linear;
}
};
}
return TRANSPARENT_PAINT;
}
}

View File

@ -19,10 +19,12 @@
package org.apache.poi.xslf.usermodel;
import org.apache.poi.sl.usermodel.ShapeContainer;
/**
* Common interface for shape containers, e.g. sheets or groups of shapes
*/
public interface XSLFShapeContainer extends Iterable<XSLFShape> {
public interface XSLFShapeContainer extends ShapeContainer {
/**
* create a new shape with a predefined geometry and add it to this shape container
@ -55,27 +57,6 @@ public interface XSLFShapeContainer extends Iterable<XSLFShape> {
*/
XSLFPictureShape createPicture(int pictureIndex);
/**
* Returns an array containing all of the elements in this container in proper
* sequence (from first to last element).
*
* @return an array containing all of the elements in this container in proper
* sequence
*/
XSLFShape[] getShapes();
/**
* Removes the specified shape from this sheet, if it is present
* (optional operation). If this sheet does not contain the element,
* it is unchanged.
*
* @param xShape shape to be removed from this sheet, if present
* @return <tt>true</tt> if this sheet contained the specified element
* @throws IllegalArgumentException if the type of the specified shape
* is incompatible with this sheet (optional)
*/
boolean removeShape(XSLFShape xShape) ;
/**
* Removes all of the elements from this container (optional operation).
* The container will be empty after this call returns.

View File

@ -1,236 +0,0 @@
/*
* ====================================================================
* 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.xslf.usermodel;
/**
* known preset shape geometries in PresentationML
*
* @author Yegor Kozlov
*/
public enum XSLFShapeType {
LINE(1),
LINE_INV(2),
TRIANGLE(3),
RT_TRIANGLE(4),
RECT(5),
DIAMOND(6),
PARALLELOGRAM(7),
TRAPEZOID(8),
NON_ISOSCELES_TRAPEZOID(9),
PENTAGON(10),
HEXAGON(11),
HEPTAGON(12),
OCTAGON(13),
DECAGON(14),
DODECAGON(15),
STAR_4(16),
STAR_5(17),
STAR_6(18),
STAR_7(19),
STAR_8(20),
STAR_10(21),
STAR_12(22),
STAR_16(23),
STAR_24(24),
STAR_32(25),
ROUND_RECT(26),
ROUND_1_RECT(27),
ROUND_2_SAME_RECT(28),
ROUND_2_DIAG_RECT(29),
SNIP_ROUND_RECT(30),
SNIP_1_RECT(31),
SNIP_2_SAME_RECT(32),
SNIP_2_DIAG_RECT(33),
PLAQUE(34),
ELLIPSE(35),
TEARDROP(36),
HOME_PLATE(37),
CHEVRON(38),
PIE_WEDGE(39),
PIE(40),
BLOCK_ARC(41),
DONUT(42),
NO_SMOKING(43),
RIGHT_ARROW(44),
LEFT_ARROW(45),
UP_ARROW(46),
DOWN_ARROW(47),
STRIPED_RIGHT_ARROW(48),
NOTCHED_RIGHT_ARROW(49),
BENT_UP_ARROW(50),
LEFT_RIGHT_ARROW(51),
UP_DOWN_ARROW(52),
LEFT_UP_ARROW(53),
LEFT_RIGHT_UP_ARROW(54),
QUAD_ARROW(55),
LEFT_ARROW_CALLOUT(56),
RIGHT_ARROW_CALLOUT(57),
UP_ARROW_CALLOUT(58),
DOWN_ARROW_CALLOUT(59),
LEFT_RIGHT_ARROW_CALLOUT(60),
UP_DOWN_ARROW_CALLOUT(61),
QUAD_ARROW_CALLOUT(62),
BENT_ARROW(63),
UTURN_ARROW(64),
CIRCULAR_ARROW(65),
LEFT_CIRCULAR_ARROW(66),
LEFT_RIGHT_CIRCULAR_ARROW(67),
CURVED_RIGHT_ARROW(68),
CURVED_LEFT_ARROW(69),
CURVED_UP_ARROW(70),
CURVED_DOWN_ARROW(71),
SWOOSH_ARROW(72),
CUBE(73),
CAN(74),
LIGHTNING_BOLT(75),
HEART(76),
SUN(77),
MOON(78),
SMILEY_FACE(79),
IRREGULAR_SEAL_1(80),
IRREGULAR_SEAL_2(81),
FOLDED_CORNER(82),
BEVEL(83),
FRAME(84),
HALF_FRAME(85),
CORNER(86),
DIAG_STRIPE(87),
CHORD(88),
ARC(89),
LEFT_BRACKET(90),
RIGHT_BRACKET(91),
LEFT_BRACE(92),
RIGHT_BRACE(93),
BRACKET_PAIR(94),
BRACE_PAIR(95),
STRAIGHT_CONNECTOR_1(96),
BENT_CONNECTOR_2(97),
BENT_CONNECTOR_3(98),
BENT_CONNECTOR_4(99),
BENT_CONNECTOR_5(100),
CURVED_CONNECTOR_2(101),
CURVED_CONNECTOR_3(102),
CURVED_CONNECTOR_4(103),
CURVED_CONNECTOR_5(104),
CALLOUT_1(105),
CALLOUT_2(106),
CALLOUT_3(107),
ACCENT_CALLOUT_1(108),
ACCENT_CALLOUT_2(109),
ACCENT_CALLOUT_3(110),
BORDER_CALLOUT_1(111),
BORDER_CALLOUT_2(112),
BORDER_CALLOUT_3(113),
ACCENT_BORDER_CALLOUT_1(114),
ACCENT_BORDER_CALLOUT_2(115),
ACCENT_BORDER_CALLOUT_3(116),
WEDGE_RECT_CALLOUT(117),
WEDGE_ROUND_RECT_CALLOUT(118),
WEDGE_ELLIPSE_CALLOUT(119),
CLOUD_CALLOUT(120),
CLOUD(121),
RIBBON(122),
RIBBON_2(123),
ELLIPSE_RIBBON(124),
ELLIPSE_RIBBON_2(125),
LEFT_RIGHT_RIBBON(126),
VERTICAL_SCROLL(127),
HORIZONTAL_SCROLL(128),
WAVE(129),
DOUBLE_WAVE(130),
PLUS(131),
FLOW_CHART_PROCESS(132),
FLOW_CHART_DECISION(133),
FLOW_CHART_INPUT_OUTPUT(134),
FLOW_CHART_PREDEFINED_PROCESS(135),
FLOW_CHART_INTERNAL_STORAGE(136),
FLOW_CHART_DOCUMENT(137),
FLOW_CHART_MULTIDOCUMENT(138),
FLOW_CHART_TERMINATOR(139),
FLOW_CHART_PREPARATION(140),
FLOW_CHART_MANUAL_INPUT(141),
FLOW_CHART_MANUAL_OPERATION(142),
FLOW_CHART_CONNECTOR(143),
FLOW_CHART_PUNCHED_CARD(144),
FLOW_CHART_PUNCHED_TAPE(145),
FLOW_CHART_SUMMING_JUNCTION(146),
FLOW_CHART_OR(147),
FLOW_CHART_COLLATE(148),
FLOW_CHART_SORT(149),
FLOW_CHART_EXTRACT(150),
FLOW_CHART_MERGE(151),
FLOW_CHART_OFFLINE_STORAGE(152),
FLOW_CHART_ONLINE_STORAGE(153),
FLOW_CHART_MAGNETIC_TAPE(154),
FLOW_CHART_MAGNETIC_DISK(155),
FLOW_CHART_MAGNETIC_DRUM(156),
FLOW_CHART_DISPLAY(157),
FLOW_CHART_DELAY(158),
FLOW_CHART_ALTERNATE_PROCESS(159),
FLOW_CHART_OFFPAGE_CONNECTOR(160),
ACTION_BUTTON_BLANK(161),
ACTION_BUTTON_HOME(162),
ACTION_BUTTON_HELP(163),
ACTION_BUTTON_INFORMATION(164),
ACTION_BUTTON_FORWARD_NEXT(165),
ACTION_BUTTON_BACK_PREVIOUS(166),
ACTION_BUTTON_END(167),
ACTION_BUTTON_BEGINNING(168),
ACTION_BUTTON_RETURN(169),
ACTION_BUTTON_DOCUMENT(170),
ACTION_BUTTON_SOUND(171),
ACTION_BUTTON_MOVIE(172),
GEAR_6(173),
GEAR_9(174),
FUNNEL(175),
MATH_PLUS(176),
MATH_MINUS(177),
MATH_MULTIPLY(178),
MATH_DIVIDE(179),
MATH_EQUAL(180),
MATH_NOT_EQUAL(181),
CORNER_TABS(182),
SQUARE_TABS(183),
PLAQUE_TABS(184),
CHART_X(185),
CHART_STAR(186),
CHART_PLUS(187);
private int _idx;
XSLFShapeType(int idx){
_idx = idx;
}
/**
*
* @return index in the STShapeType enum
*/
int getIndex(){
return _idx;
}
static XSLFShapeType forInt(int idx){
for(XSLFShapeType t : values()){
if(t._idx == idx) return t;
}
throw new IllegalArgumentException("Unknown shape type: " + idx);
}
}

View File

@ -23,6 +23,8 @@ import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.TargetMode;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.sl.usermodel.MasterSheet;
import org.apache.poi.sl.usermodel.Sheet;
import org.apache.poi.util.Beta;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
@ -37,7 +39,10 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
import com.sun.org.apache.xml.internal.utils.UnImplNode;
import javax.xml.namespace.QName;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.io.IOException;
@ -51,7 +56,7 @@ import java.util.Map;
import java.util.regex.Pattern;
@Beta
public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeContainer {
public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeContainer, Sheet {
private XSLFCommonSlideData _commonSlideData;
private XSLFDrawing _drawing;
private List<XSLFShape> _shapes;
@ -142,6 +147,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
List<XSLFShape> shapes = getShapeList();
XSLFAutoShape sh = getDrawing().createAutoShape();
shapes.add(sh);
sh.setParent(this);
return sh;
}
@ -149,6 +155,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
List<XSLFShape> shapes = getShapeList();
XSLFFreeformShape sh = getDrawing().createFreeform();
shapes.add(sh);
sh.setParent(this);
return sh;
}
@ -156,6 +163,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
List<XSLFShape> shapes = getShapeList();
XSLFTextBox sh = getDrawing().createTextBox();
shapes.add(sh);
sh.setParent(this);
return sh;
}
@ -163,6 +171,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
List<XSLFShape> shapes = getShapeList();
XSLFConnectorShape sh = getDrawing().createConnector();
shapes.add(sh);
sh.setParent(this);
return sh;
}
@ -170,6 +179,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
List<XSLFShape> shapes = getShapeList();
XSLFGroupShape sh = getDrawing().createGroup();
shapes.add(sh);
sh.setParent(this);
return sh;
}
@ -191,6 +201,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
sh.resize();
getShapeList().add(sh);
sh.setParent(this);
return sh;
}
@ -198,6 +209,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
List<XSLFShape> shapes = getShapeList();
XSLFTable sh = getDrawing().createTable();
shapes.add(sh);
sh.setParent(this);
return sh;
}
@ -219,6 +231,12 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
return getShapeList().iterator();
}
public void addShape(XSLFShape shape) {
throw new UnsupportedOperationException(
"Adding a shape from a different container is not supported -"
+ " create it from scratch witht XSLFSheet.create* methods");
}
/**
* Removes the specified shape from this sheet, if it is present
* (optional operation). If this sheet does not contain the element,
@ -370,12 +388,6 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
return null;
}
/**
*
* @return master of this sheet.
*/
public abstract XSLFSheet getMasterSheet();
protected XSLFTextShape getTextShapeByType(Placeholder type){
for(XSLFShape shape : this.getShapes()){
if(shape instanceof XSLFTextShape) {
@ -486,7 +498,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
* @param graphics
*/
public void draw(Graphics2D graphics){
XSLFSheet master = getMasterSheet();
XSLFSheet master = (XSLFSheet)getMasterSheet();
if(getFollowMasterGraphics() && master != null) master.draw(graphics);
graphics.setRenderingHint(XSLFRenderingHint.GROUP_TRANSFORM, new AffineTransform());

View File

@ -19,26 +19,25 @@
package org.apache.poi.xslf.usermodel;
import java.awt.*;
import java.awt.Shape;
import java.awt.geom.*;
import java.util.ArrayList;
import java.util.List;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.poi.sl.draw.geom.*;
import org.apache.poi.sl.usermodel.*;
import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Units;
import org.apache.poi.xslf.model.PropertyFetcher;
import org.apache.poi.xslf.model.geom.CustomGeometry;
import org.apache.poi.xslf.model.geom.Outline;
import org.apache.poi.xslf.model.geom.Path;
import org.apache.poi.xslf.model.geom.PresetGeometries;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.List;
import org.openxmlformats.schemas.presentationml.x2006.main.*;
/**
* Represents a single (non-group) shape in a .pptx slide show
@ -46,24 +45,11 @@ import java.util.List;
* @author Yegor Kozlov
*/
@Beta
public abstract class XSLFSimpleShape extends XSLFShape {
public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {
private static CTOuterShadowEffect NO_SHADOW = CTOuterShadowEffect.Factory.newInstance();
private final XmlObject _shape;
private final XSLFSheet _sheet;
private CTShapeProperties _spPr;
private CTShapeStyle _spStyle;
private CTNonVisualDrawingProps _nvPr;
private CTPlaceholder _ph;
/* package */XSLFSimpleShape(XmlObject shape, XSLFSheet sheet) {
_shape = shape;
_sheet = sheet;
}
@Override
public XmlObject getXmlObject() {
return _shape;
super(shape,sheet);
}
/**
@ -78,16 +64,16 @@ public abstract class XSLFSimpleShape extends XSLFShape {
*
* @param type
*/
public void setShapeType(XSLFShapeType type){
public void setShapeType(ShapeType type){
CTShape shape = (CTShape) getXmlObject();
STShapeType.Enum geom = STShapeType.Enum.forInt(type.getIndex());
STShapeType.Enum geom = STShapeType.Enum.forInt(type.ooxmlId);
shape.getSpPr().getPrstGeom().setPrst(geom);
}
public XSLFShapeType getShapeType(){
public ShapeType getShapeType(){
CTShape shape = (CTShape) getXmlObject();
STShapeType.Enum geom = shape.getSpPr().getPrstGeom().getPrst();
return XSLFShapeType.forInt(geom.intValue());
return ShapeType.forId(geom.intValue(), true);
}
@Override
@ -100,101 +86,6 @@ public abstract class XSLFSimpleShape extends XSLFShape {
return (int) getNvPr().getId();
}
protected CTNonVisualDrawingProps getNvPr() {
if (_nvPr == null) {
XmlObject[] rs = _shape
.selectPath("declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:cNvPr");
if (rs.length != 0) {
_nvPr = (CTNonVisualDrawingProps) rs[0];
}
}
return _nvPr;
}
protected CTShapeProperties getSpPr() {
if (_spPr == null) {
for (XmlObject obj : _shape.selectPath("*")) {
if (obj instanceof CTShapeProperties) {
_spPr = (CTShapeProperties) obj;
}
}
}
if (_spPr == null) {
throw new IllegalStateException("CTShapeProperties was not found.");
}
return _spPr;
}
protected CTShapeStyle getSpStyle() {
if (_spStyle == null) {
for (XmlObject obj : _shape.selectPath("*")) {
if (obj instanceof CTShapeStyle) {
_spStyle = (CTShapeStyle) obj;
}
}
}
return _spStyle;
}
protected CTPlaceholder getCTPlaceholder() {
if (_ph == null) {
XmlObject[] obj = _shape.selectPath(
"declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:nvPr/p:ph");
if (obj.length == 1) {
_ph = (CTPlaceholder) obj[0];
}
}
return _ph;
}
CTTransform2D getXfrm() {
PropertyFetcher<CTTransform2D> fetcher = new PropertyFetcher<CTTransform2D>() {
public boolean fetch(XSLFSimpleShape shape) {
CTShapeProperties pr = shape.getSpPr();
if (pr.isSetXfrm()) {
setValue(pr.getXfrm());
return true;
}
return false;
}
};
fetchShapeProperty(fetcher);
return fetcher.getValue();
}
@Override
public Rectangle2D getAnchor() {
CTTransform2D xfrm = getXfrm();
CTPoint2D off = xfrm.getOff();
long x = off.getX();
long y = off.getY();
CTPositiveSize2D ext = xfrm.getExt();
long cx = ext.getCx();
long cy = ext.getCy();
return new Rectangle2D.Double(
Units.toPoints(x), Units.toPoints(y),
Units.toPoints(cx), Units.toPoints(cy));
}
@Override
public void setAnchor(Rectangle2D anchor) {
CTShapeProperties spPr = getSpPr();
CTTransform2D xfrm = spPr.isSetXfrm() ? spPr.getXfrm() : spPr.addNewXfrm();
CTPoint2D off = xfrm.isSetOff() ? xfrm.getOff() : xfrm.addNewOff();
long x = Units.toEMU(anchor.getX());
long y = Units.toEMU(anchor.getY());
off.setX(x);
off.setY(y);
CTPositiveSize2D ext = xfrm.isSetExt() ? xfrm.getExt() : xfrm
.addNewExt();
long cx = Units.toEMU(anchor.getWidth());
long cy = Units.toEMU(anchor.getHeight());
ext.setCx(cx);
ext.setCy(cy);
}
@Override
public void setRotation(double theta) {
CTShapeProperties spPr = getSpPr();
@ -314,7 +205,7 @@ public abstract class XSLFSimpleShape extends XSLFShape {
*/
public double getLineWidth() {
PropertyFetcher<Double> fetcher = new PropertyFetcher<Double>() {
public boolean fetch(XSLFSimpleShape shape) {
public boolean fetch(XSLFShape shape) {
CTShapeProperties spPr = shape.getSpPr();
CTLineProperties ln = spPr.getLn();
if (ln != null) {
@ -371,7 +262,7 @@ public abstract class XSLFSimpleShape extends XSLFShape {
public LineDash getLineDash() {
PropertyFetcher<LineDash> fetcher = new PropertyFetcher<LineDash>() {
public boolean fetch(XSLFSimpleShape shape) {
public boolean fetch(XSLFShape shape) {
CTShapeProperties spPr = shape.getSpPr();
CTLineProperties ln = spPr.getLn();
if (ln != null) {
@ -421,7 +312,7 @@ public abstract class XSLFSimpleShape extends XSLFShape {
*/
public LineCap getLineCap() {
PropertyFetcher<LineCap> fetcher = new PropertyFetcher<LineCap>() {
public boolean fetch(XSLFSimpleShape shape) {
public boolean fetch(XSLFShape shape) {
CTShapeProperties spPr = shape.getSpPr();
CTLineProperties ln = spPr.getLn();
if (ln != null) {
@ -499,7 +390,7 @@ public abstract class XSLFSimpleShape extends XSLFShape {
*/
public XSLFShadow getShadow() {
PropertyFetcher<CTOuterShadowEffect> fetcher = new PropertyFetcher<CTOuterShadowEffect>() {
public boolean fetch(XSLFSimpleShape shape) {
public boolean fetch(XSLFShape shape) {
CTShapeProperties spPr = shape.getSpPr();
if (spPr.isSetEffectLst()) {
CTOuterShadowEffect obj = spPr.getEffectLst().getOuterShdw();
@ -528,90 +419,11 @@ public abstract class XSLFSimpleShape extends XSLFShape {
return (obj == null || obj == NO_SHADOW) ? null : new XSLFShadow(obj, this);
}
@Override
public void draw(Graphics2D graphics) {
RenderableShape rShape = new RenderableShape(this);
rShape.render(graphics);
// draw line decorations
Color lineColor = getLineColor();
if(lineColor != null) {
graphics.setPaint(lineColor);
for(Outline o : getDecorationOutlines(graphics)){
if(o.getPath().isFilled()){
graphics.fill(o.getOutline());
}
if(o.getPath().isStroked()){
graphics.draw(o.getOutline());
}
}
}
}
/**
* Walk up the inheritance tree and fetch shape properties.
*
* The following order of inheritance is assumed:
* <p>
* slide <-- slideLayout <-- slideMaster
* </p>
*
* @param visitor the object that collects the desired property
* @return true if the property was fetched
*/
boolean fetchShapeProperty(PropertyFetcher visitor) {
boolean ok = visitor.fetch(this);
XSLFSimpleShape masterShape;
XSLFSheet masterSheet = getSheet().getMasterSheet();
CTPlaceholder ph = getCTPlaceholder();
if (masterSheet != null && ph != null) {
if (!ok) {
masterShape = masterSheet.getPlaceholder(ph);
if (masterShape != null) {
ok = visitor.fetch(masterShape);
}
}
// try slide master
if (!ok ) {
int textType;
if ( !ph.isSetType()) textType = STPlaceholderType.INT_BODY;
else {
switch (ph.getType().intValue()) {
case STPlaceholderType.INT_TITLE:
case STPlaceholderType.INT_CTR_TITLE:
textType = STPlaceholderType.INT_TITLE;
break;
case STPlaceholderType.INT_FTR:
case STPlaceholderType.INT_SLD_NUM:
case STPlaceholderType.INT_DT:
textType = ph.getType().intValue();
break;
default:
textType = STPlaceholderType.INT_BODY;
break;
}
}
XSLFSheet master = masterSheet.getMasterSheet();
if (master != null) {
masterShape = master.getPlaceholderByType(textType);
if (masterShape != null) {
ok = visitor.fetch(masterShape);
}
}
}
}
return ok;
}
/**
*
* @return definition of the shape geometry
*/
CustomGeometry getGeometry(){
public CustomGeometry getGeometry(){
CTShapeProperties spPr = getSpPr();
CustomGeometry geom;
PresetGeometries dict = PresetGeometries.getInstance();
@ -622,23 +434,16 @@ public abstract class XSLFSimpleShape extends XSLFShape {
throw new IllegalStateException("Unknown shape geometry: " + name);
}
} else if (spPr.isSetCustGeom()){
geom = new CustomGeometry(spPr.getCustGeom());
XMLStreamReader staxReader = spPr.getCustGeom().newXMLStreamReader();
geom = PresetGeometries.convertCustomGeometry(staxReader);
try { staxReader.close(); }
catch (XMLStreamException e) {}
} else {
geom = dict.get("rect");
}
return geom;
}
/**
* draw any content within this shape (image, text, etc.).
*
* @param graphics the graphics to draw into
*/
public void drawContent(Graphics2D graphics){
}
@Override
void copy(XSLFShape sh){
super.copy(sh);
@ -943,4 +748,30 @@ public abstract class XSLFSimpleShape extends XSLFShape {
return lst;
}
public boolean isPlaceholder() {
CTPlaceholder ph = getCTPlaceholder();
return ph != null;
}
public Hyperlink getHyperlink() {
// TODO Auto-generated method stub
return null;
}
public void setHyperlink(Hyperlink hyperlink) {
// TODO Auto-generated method stub
}
public Guide getAdjustValue(String name) {
// TODO Auto-generated method stub
return null;
}
public org.apache.poi.sl.usermodel.LineDecoration getLineDecoration() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -16,29 +16,31 @@
==================================================================== */
package org.apache.poi.xslf.usermodel;
import java.awt.Graphics2D;
import java.io.IOException;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.sl.usermodel.Notes;
import org.apache.poi.sl.usermodel.Slide;
import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D;
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;
import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument;
import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;
import java.awt.Graphics2D;
import java.io.IOException;
@Beta
public final class XSLFSlide extends XSLFSheet {
public final class XSLFSlide extends XSLFSheet implements Slide {
private final CTSlide _slide;
private XSLFSlideLayout _layout;
private XSLFComments _comments;
@ -111,7 +113,6 @@ public final class XSLFSlide extends XSLFSheet {
return "sld";
}
@Override
public XSLFSlideLayout getMasterSheet(){
return getSlideLayout();
}
@ -211,6 +212,15 @@ public final class XSLFSlide extends XSLFSheet {
}
public boolean getFollowMasterObjects() {
return getFollowMasterGraphics();
}
public void setFollowMasterObjects(boolean follow) {
setFollowMasterGraphics(follow);
}
@Override
public void draw(Graphics2D graphics){
@ -239,4 +249,26 @@ public final class XSLFSlide extends XSLFSheet {
return this;
}
public boolean getFollowMasterBackground() {
return false;
}
public void setFollowMasterBackground(boolean follow) {
// not implemented ... also not in the specs
throw new UnsupportedOperationException();
}
public boolean getFollowMasterColourScheme() {
return false;
}
public void setFollowMasterColourScheme(boolean follow) {
// not implemented ... only for OLE objects in the specs
throw new UnsupportedOperationException();
}
public void setNotes(Notes<XSLFShape> notes) {
// TODO Auto-generated method stub
}
}

View File

@ -19,6 +19,7 @@ package org.apache.poi.xslf.usermodel;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.sl.usermodel.MasterSheet;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.xmlbeans.XmlException;
@ -30,7 +31,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldLayoutDocument;
import java.io.IOException;
@Beta
public class XSLFSlideLayout extends XSLFSheet {
public class XSLFSlideLayout extends XSLFSheet implements MasterSheet {
private CTSlideLayout _layout;
private XSLFSlideMaster _master;

View File

@ -19,6 +19,7 @@ package org.apache.poi.xslf.usermodel;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.sl.usermodel.MasterSheet;
import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.drawingml.x2006.main.CTColorMapping;
@ -53,7 +54,7 @@ import java.util.Map;
* @author Yegor Kozlov
*/
@Beta
public class XSLFSlideMaster extends XSLFSheet {
public class XSLFSlideMaster extends XSLFSheet implements MasterSheet {
private CTSlideMaster _slide;
private Map<String, XSLFSlideLayout> _layouts;
private XSLFTheme _theme;
@ -82,7 +83,7 @@ import java.util.Map;
}
@Override
public XSLFSheet getMasterSheet() {
public MasterSheet getMasterSheet() {
return null;
}
@ -177,5 +178,4 @@ import java.util.Map;
return null;
}
}
}

View File

@ -21,6 +21,7 @@ package org.apache.poi.xslf.usermodel;
import java.awt.Color;
import org.apache.poi.sl.usermodel.VerticalAlignment;
import org.apache.poi.util.Units;
import org.openxmlformats.schemas.drawingml.x2006.main.CTLineEndProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties;

View File

@ -18,42 +18,14 @@ package org.apache.poi.xslf.usermodel;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.font.LineBreakMeasurer;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.geom.Rectangle2D;
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import org.apache.poi.hslf.model.TextPainter;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.util.Units;
import org.apache.poi.sl.usermodel.TextParagraph;
import org.apache.poi.util.*;
import org.apache.poi.xslf.model.ParagraphPropertyFetcher;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;
import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextAutonumberBullet;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizePercent;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizePoint;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharBullet;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextField;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextLineBreak;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStop;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStopList;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextAlignType;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextAutonumberScheme;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
@ -65,16 +37,10 @@ import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
* @since POI-3.8
*/
@Beta
public class XSLFTextParagraph implements Iterable<XSLFTextRun>{
public class XSLFTextParagraph implements TextParagraph {
private final CTTextParagraph _p;
private final List<XSLFTextRun> _runs;
private final XSLFTextShape _shape;
private List<TextFragment> _lines;
private TextFragment _bullet;
/**
* the highest line in this paragraph. Used for line spacing.
*/
private double _maxLineHeight;
XSLFTextParagraph(CTTextParagraph p, XSLFTextShape shape){
_p = p;
@ -122,7 +88,7 @@ public class XSLFTextParagraph implements Iterable<XSLFTextRun>{
return _p;
}
XSLFTextShape getParentShape() {
public XSLFTextShape getParentShape() {
return _shape;
}
@ -194,7 +160,7 @@ public class XSLFTextParagraph implements Iterable<XSLFTextRun>{
/**
* Specifies the alignment that is to be applied to the paragraph.
* Possible values for this include left, right, centered, justified and distributed,
* see {@link org.apache.poi.xslf.usermodel.TextAlign}.
* see {@link org.apache.poi.sl.usermodel.TextAlign}.
*
* @param align text align
*/
@ -408,6 +374,26 @@ public class XSLFTextParagraph implements Iterable<XSLFTextRun>{
return fetcher.getValue() == null ? 0 : fetcher.getValue();
}
/**
*
* @return the right margin of the paragraph
*/
public double getRightMargin(){
ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){
public boolean fetch(CTTextParagraphProperties props){
if(props.isSetMarR()){
double val = Units.toPoints(props.getMarR());
setValue(val);
return true;
}
return false;
}
};
fetchParagraphProperty(fetcher);
// if the marL attribute is omitted, then a value of 347663 is implied
return fetcher.getValue() == null ? 0 : fetcher.getValue();
}
/**
*
* @return the default size for a tab character within this paragraph in points
@ -711,10 +697,6 @@ public class XSLFTextParagraph implements Iterable<XSLFTextRun>{
return "[" + getClass() + "]" + getText();
}
List<TextFragment> getTextLines(){
return _lines;
}
/**
* Returns wrapping width to break lines in this paragraph
*
@ -754,244 +736,6 @@ public class XSLFTextParagraph implements Iterable<XSLFTextRun>{
return width;
}
public double draw(Graphics2D graphics, double x, double y){
double leftInset = _shape.getLeftInset();
double rightInset = _shape.getRightInset();
RenderableShape rShape = new RenderableShape(_shape);
Rectangle2D anchor = rShape.getAnchor(graphics);
double penY = y;
double leftMargin = getLeftMargin();
boolean firstLine = true;
double indent = getIndent();
//The vertical line spacing
double spacing = getLineSpacing();
for(TextFragment line : _lines){
double penX = x + leftMargin;
if(firstLine) {
if(_bullet != null){
if(indent < 0) {
// a negative value means "Hanging" indentation and
// indicates the position of the actual bullet character.
// (the bullet is shifted to right relative to the text)
_bullet.draw(graphics, penX + indent, penY);
} else if(indent > 0){
// a positive value means the "First Line" indentation:
// the first line is indented and other lines start at the bullet ofset
_bullet.draw(graphics, penX, penY);
penX += indent;
} else {
// a zero indent means that the bullet and text have the same offset
_bullet.draw(graphics, penX, penY);
// don't let text overlay the bullet and advance by the bullet width
penX += _bullet._layout.getAdvance() + 1;
}
} else {
penX += indent;
}
}
switch (getTextAlign()) {
case CENTER:
penX += (anchor.getWidth() - leftMargin - line.getWidth() - leftInset - rightInset) / 2;
break;
case RIGHT:
penX += (anchor.getWidth() - line.getWidth() - leftInset - rightInset);
break;
default:
break;
}
line.draw(graphics, penX, penY);
if(spacing > 0) {
// If linespacing >= 0, then linespacing is a percentage of normal line height.
penY += spacing*0.01* line.getHeight();
} else {
// positive value means absolute spacing in points
penY += -spacing;
}
firstLine = false;
}
return penY - y;
}
AttributedString getAttributedString(Graphics2D graphics){
String text = getRenderableText();
AttributedString string = new AttributedString(text);
XSLFFontManager fontHandler = (XSLFFontManager)graphics.getRenderingHint(XSLFRenderingHint.FONT_HANDLER);
int startIndex = 0;
for (XSLFTextRun run : _runs){
int length = run.getRenderableText().length();
if(length == 0) {
// skip empty runs
continue;
}
int endIndex = startIndex + length;
string.addAttribute(TextAttribute.FOREGROUND, run.getFontColor(), startIndex, endIndex);
// user can pass an custom object to convert fonts
String fontFamily = run.getFontFamily();
@SuppressWarnings("unchecked")
Map<String,String> fontMap = (Map<String,String>)graphics.getRenderingHint(TextPainter.KEY_FONTMAP);
if (fontMap != null && fontMap.containsKey(fontFamily)) {
fontFamily = fontMap.get(fontFamily);
}
if(fontHandler != null) {
fontFamily = fontHandler.getRendererableFont(fontFamily, run.getPitchAndFamily());
}
string.addAttribute(TextAttribute.FAMILY, fontFamily, startIndex, endIndex);
float fontSz = (float)run.getFontSize();
string.addAttribute(TextAttribute.SIZE, fontSz , startIndex, endIndex);
if(run.isBold()) {
string.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, startIndex, endIndex);
}
if(run.isItalic()) {
string.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, startIndex, endIndex);
}
if(run.isUnderline()) {
string.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, startIndex, endIndex);
string.addAttribute(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_TWO_PIXEL, startIndex, endIndex);
}
if(run.isStrikethrough()) {
string.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, startIndex, endIndex);
}
if(run.isSubscript()) {
string.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB, startIndex, endIndex);
}
if(run.isSuperscript()) {
string.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, startIndex, endIndex);
}
startIndex = endIndex;
}
return string;
}
/**
* ensure that the paragraph contains at least one character.
* We need this trick to correctly measure text
*/
private void ensureNotEmpty(){
XSLFTextRun r = addNewTextRun();
r.setText(" ");
CTTextCharacterProperties endPr = _p.getEndParaRPr();
if(endPr != null) {
if(endPr.isSetSz()) r.setFontSize(endPr.getSz() / 100);
}
}
/**
* break text into lines
*
* @param graphics
* @return array of text fragments,
* each representing a line of text that fits in the wrapping width
*/
List<TextFragment> breakText(Graphics2D graphics){
_lines = new ArrayList<TextFragment>();
// does this paragraph contain text?
boolean emptyParagraph = _runs.size() == 0;
// ensure that the paragraph contains at least one character
if(_runs.size() == 0) ensureNotEmpty();
String text = getRenderableText();
if(text.length() == 0) return _lines;
AttributedString at = getAttributedString(graphics);
AttributedCharacterIterator it = at.getIterator();
LineBreakMeasurer measurer = new LineBreakMeasurer(it, graphics.getFontRenderContext()) ;
for (;;) {
int startIndex = measurer.getPosition();
double wrappingWidth = getWrappingWidth(_lines.size() == 0, graphics) + 1; // add a pixel to compensate rounding errors
// shape width can be smaller that the sum of insets (this was proved by a test file)
if(wrappingWidth < 0) wrappingWidth = 1;
int nextBreak = text.indexOf('\n', startIndex + 1);
if(nextBreak == -1) nextBreak = it.getEndIndex();
TextLayout layout = measurer.nextLayout((float)wrappingWidth, nextBreak, true);
if (layout == null) {
// layout can be null if the entire word at the current position
// does not fit within the wrapping width. Try with requireNextWord=false.
layout = measurer.nextLayout((float)wrappingWidth, nextBreak, false);
}
if(layout == null) {
// exit if can't break any more
break;
}
int endIndex = measurer.getPosition();
// skip over new line breaks (we paint 'clear' text runs not starting or ending with \n)
if(endIndex < it.getEndIndex() && text.charAt(endIndex) == '\n'){
measurer.setPosition(endIndex + 1);
}
TextAlign hAlign = getTextAlign();
if(hAlign == TextAlign.JUSTIFY || hAlign == TextAlign.JUSTIFY_LOW) {
layout = layout.getJustifiedLayout((float)wrappingWidth);
}
AttributedString str = new AttributedString(it, startIndex, endIndex);
TextFragment line = new TextFragment(
layout, // we will not paint empty paragraphs
emptyParagraph ? null : str);
_lines.add(line);
_maxLineHeight = Math.max(_maxLineHeight, line.getHeight());
if(endIndex == it.getEndIndex()) break;
}
if(isBullet() && !emptyParagraph) {
String buCharacter = getBulletCharacter();
String buFont = getBulletFont();
if(buFont == null) buFont = getTextRuns().get(0).getFontFamily();
if(buCharacter != null && buFont != null && _lines.size() > 0) {
AttributedString str = new AttributedString(buCharacter);
TextFragment firstLine = _lines.get(0);
AttributedCharacterIterator bit = firstLine._str.getIterator();
Color buColor = getBulletFontColor();
str.addAttribute(TextAttribute.FOREGROUND, buColor == null ?
bit.getAttribute(TextAttribute.FOREGROUND) : buColor);
str.addAttribute(TextAttribute.FAMILY, buFont);
float fontSize = (Float)bit.getAttribute(TextAttribute.SIZE);
float buSz = (float)getBulletFontSize();
if(buSz > 0) fontSize *= buSz* 0.01;
else fontSize = -buSz;
str.addAttribute(TextAttribute.SIZE, fontSize);
TextLayout layout = new TextLayout(str.getIterator(), graphics.getFontRenderContext());
_bullet = new TextFragment(layout, str);
}
}
return _lines;
}
CTTextParagraphProperties getDefaultMasterStyle(){
CTPlaceholder ph = _shape.getCTPlaceholder();
String defaultStyleSelector;
@ -1017,7 +761,7 @@ public class XSLFTextParagraph implements Iterable<XSLFTextRun>{
// wind up and find the root master sheet which must be slide master
XSLFSheet masterSheet = _shape.getSheet();
while (masterSheet.getMasterSheet() != null){
masterSheet = masterSheet.getMasterSheet();
masterSheet = (XSLFSheet)masterSheet.getMasterSheet();
}
XmlObject[] o = masterSheet.getXmlObject().selectPath(
@ -1130,4 +874,32 @@ public class XSLFTextParagraph implements Iterable<XSLFTextRun>{
}
}
public double getDefaultFontSize() {
CTTextCharacterProperties endPr = _p.getEndParaRPr();
return (endPr == null || !endPr.isSetSz()) ? 12 : (endPr.getSz() / 100);
}
public String getDefaultFontFamily() {
return (_runs.isEmpty() ? "Arial" : _runs.get(0).getFontFamily());
}
public BulletStyle getBulletStyle() {
return new BulletStyle(){
public String getBulletCharacter() {
return XSLFTextParagraph.this.getBulletCharacter();
}
public String getBulletFont() {
return XSLFTextParagraph.this.getBulletFont();
}
public double getBulletFontSize() {
return XSLFTextParagraph.this.getBulletFontSize();
}
public Color getBulletFontColor() {
return XSLFTextParagraph.this.getBulletFontColor();
}
};
}
}

View File

@ -22,6 +22,7 @@ import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.text.AttributedString;
import org.apache.poi.sl.usermodel.TextRun;
import org.apache.poi.util.Beta;
import org.apache.poi.xslf.model.CharacterPropertyFetcher;
import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;
@ -45,7 +46,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
* @author Yegor Kozlov
*/
@Beta
public class XSLFTextRun {
public class XSLFTextRun implements TextRun {
private final CTRegularTextRun _r;
private final XSLFTextParagraph _p;

View File

@ -23,26 +23,20 @@ import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.*;
import org.apache.poi.POIXMLException;
import org.apache.poi.sl.draw.DrawFactory;
import org.apache.poi.sl.draw.geom.Guide;
import org.apache.poi.sl.usermodel.*;
import org.apache.poi.sl.usermodel.LineDecoration;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Units;
import org.apache.poi.xslf.model.PropertyFetcher;
import org.apache.poi.xslf.model.TextBodyPropertyFetcher;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextAnchoringType;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextVerticalType;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextWrappingType;
import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.*;
/**
* Represents a shape that can hold text.
@ -50,7 +44,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
* @author Yegor Kozlov
*/
@Beta
public abstract class XSLFTextShape extends XSLFSimpleShape implements Iterable<XSLFTextParagraph>{
public abstract class XSLFTextShape extends XSLFSimpleShape implements TextShape {
private final List<XSLFTextParagraph> _paragraphs;
/**
@ -338,6 +332,12 @@ public abstract class XSLFTextShape extends XSLFSimpleShape implements Iterable<
}
}
@Override
public Insets2D getInsets() {
Insets2D insets = new Insets2D(getTopInset(), getLeftInset(), getBottomInset(), getRightInset());
return insets;
}
/**
* @return whether to wrap words within the bounding rectangle
@ -453,6 +453,9 @@ public abstract class XSLFTextShape extends XSLFSimpleShape implements Iterable<
// dry-run in a 1x1 image and return the vertical advance
BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
DrawFactory fact = DrawFactory.getInstance(graphics);
fact.getDrawable(this);
breakText(graphics);
return drawParagraphs(graphics, 0, 0);
}
@ -475,121 +478,6 @@ public abstract class XSLFTextShape extends XSLFSimpleShape implements Iterable<
return anchor;
}
/**
* break the contained text into lines
*/
private void breakText(Graphics2D graphics){
if(!_isTextBroken) {
for(XSLFTextParagraph p : _paragraphs) p.breakText(graphics);
_isTextBroken = true;
}
}
@Override
public void drawContent(Graphics2D graphics) {
breakText(graphics);
RenderableShape rShape = new RenderableShape(this);
Rectangle2D anchor = rShape.getAnchor(graphics);
double x = anchor.getX() + getLeftInset();
double y = anchor.getY();
// remember the initial transform
AffineTransform tx = graphics.getTransform();
// Transform of text in flipped shapes is special.
// At this point the flip and rotation transform is already applied
// (see XSLFShape#applyTransform ), but we need to restore it to avoid painting "upside down".
// See Bugzilla 54210.
if(getFlipVertical()){
graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
graphics.scale(1, -1);
graphics.translate(-anchor.getX(), -anchor.getY());
// text in vertically flipped shapes is rotated by 180 degrees
double centerX = anchor.getX() + anchor.getWidth()/2;
double centerY = anchor.getY() + anchor.getHeight()/2;
graphics.translate(centerX, centerY);
graphics.rotate(Math.toRadians(180));
graphics.translate(-centerX, -centerY);
}
// Horizontal flipping applies only to shape outline and not to the text in the shape.
// Applying flip second time restores the original not-flipped transform
if(getFlipHorizontal()){
graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
graphics.scale(-1, 1);
graphics.translate(-anchor.getX() , -anchor.getY());
}
// first dry-run to calculate the total height of the text
double textHeight = getTextHeight();
switch (getVerticalAlignment()){
case TOP:
y += getTopInset();
break;
case BOTTOM:
y += anchor.getHeight() - textHeight - getBottomInset();
break;
default:
case MIDDLE:
double delta = anchor.getHeight() - textHeight -
getTopInset() - getBottomInset();
y += getTopInset() + delta/2;
break;
}
drawParagraphs(graphics, x, y);
// restore the transform
graphics.setTransform(tx);
}
/**
* paint the paragraphs starting from top left (x,y)
*
* @return the vertical advance, i.e. the cumulative space occupied by the text
*/
private double drawParagraphs(Graphics2D graphics, double x, double y) {
double y0 = y;
for(int i = 0; i < _paragraphs.size(); i++){
XSLFTextParagraph p = _paragraphs.get(i);
List<TextFragment> lines = p.getTextLines();
if(i > 0 && lines.size() > 0) {
// the amount of vertical white space before the paragraph
double spaceBefore = p.getSpaceBefore();
if(spaceBefore > 0) {
// positive value means percentage spacing of the height of the first line, e.g.
// the higher the first line, the bigger the space before the paragraph
y += spaceBefore*0.01*lines.get(0).getHeight();
} else {
// negative value means the absolute spacing in points
y += -spaceBefore;
}
}
y += p.draw(graphics, x, y);
if(i < _paragraphs.size() - 1) {
double spaceAfter = p.getSpaceAfter();
if(spaceAfter > 0) {
// positive value means percentage spacing of the height of the last line, e.g.
// the higher the last line, the bigger the space after the paragraph
y += spaceAfter*0.01*lines.get(lines.size() - 1).getHeight();
} else {
// negative value means the absolute spacing in points
y += -spaceAfter;
}
}
}
return y - y0;
}
@Override
void copy(XSLFShape sh){
@ -633,4 +521,19 @@ public abstract class XSLFTextShape extends XSLFSimpleShape implements Iterable<
}
}
public LineDecoration getLineDecoration() {
// TODO Auto-generated method stub
return null;
}
public FillStyle getFillStyle() {
// TODO Auto-generated method stub
return null;
}
public Guide getAdjustValue(String name) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -17,6 +17,10 @@
package org.apache.poi.xslf.usermodel;
import junit.framework.TestCase;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.sl.usermodel.TextAlign;
import org.apache.poi.sl.usermodel.VerticalAlignment;
import org.apache.poi.util.Units;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextStrikeType;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
@ -270,12 +274,12 @@ public class TestXSLFAutoShape extends TestCase {
XSLFSlide slide = ppt.createSlide();
XSLFAutoShape shape = slide.createAutoShape();
assertEquals(XSLFShapeType.RECT, shape.getShapeType());
assertEquals(ShapeType.RECT, shape.getShapeType());
shape.setShapeType(XSLFShapeType.TRIANGLE);
assertEquals(XSLFShapeType.TRIANGLE, shape.getShapeType());
shape.setShapeType(ShapeType.TRIANGLE);
assertEquals(ShapeType.TRIANGLE, shape.getShapeType());
for(XSLFShapeType tp : XSLFShapeType.values()) {
for(ShapeType tp : ShapeType.values()) {
shape.setShapeType(tp);
assertEquals(tp, shape.getShapeType());
}

View File

@ -17,6 +17,8 @@
package org.apache.poi.xslf.usermodel;
import junit.framework.TestCase;
import org.apache.poi.sl.usermodel.ShapeType;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
@ -112,12 +114,12 @@ public class TestXSLFConnectorShape extends TestCase {
XSLFSlide slide = pptx.createSlide();
XSLFAutoShape rect1 = slide.createAutoShape();
rect1.setShapeType(XSLFShapeType.RECT);
rect1.setShapeType(ShapeType.RECT);
rect1.setAnchor(new Rectangle(100, 100, 100, 100));
rect1.setFillColor(Color.blue);
XSLFAutoShape rect2 = slide.createAutoShape();
rect2.setShapeType(XSLFShapeType.RECT);
rect2.setShapeType(ShapeType.RECT);
rect2.setAnchor(new Rectangle(300, 300, 100, 100));
rect2.setFillColor(Color.red);

View File

@ -20,6 +20,8 @@ import java.awt.Color;
import junit.framework.TestCase;
import org.apache.poi.sl.usermodel.LineCap;
import org.apache.poi.sl.usermodel.LineDash;
import org.apache.poi.util.Units;
import org.apache.poi.xslf.XSLFTestDataSamples;
import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem;

View File

@ -17,6 +17,8 @@
package org.apache.poi.xslf.usermodel;
import junit.framework.TestCase;
import org.apache.poi.sl.usermodel.VerticalAlignment;
import org.apache.poi.xslf.XSLFTestDataSamples;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;

View File

@ -17,6 +17,9 @@
package org.apache.poi.xslf.usermodel;
import junit.framework.TestCase;
import org.apache.poi.sl.draw.TextFragment;
import org.apache.poi.sl.usermodel.TextAlign;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.xslf.XSLFTestDataSamples;

View File

@ -17,6 +17,9 @@
package org.apache.poi.xslf.usermodel;
import junit.framework.TestCase;
import org.apache.poi.sl.usermodel.TextAlign;
import org.apache.poi.sl.usermodel.VerticalAlignment;
import org.apache.poi.xslf.XSLFTestDataSamples;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,8 @@ import org.apache.poi.hslf.record.ExObjList;
import org.apache.poi.hslf.record.OEShapeAtom;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil;
@ -63,7 +65,7 @@ public final class ActiveXShape extends Picture {
* this picture in the <code>Slide</code>
* @param parent the parent shape of this picture
*/
protected ActiveXShape(EscherContainerRecord escherRecord, Shape parent){
protected ActiveXShape(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
@ -78,7 +80,7 @@ public final class ActiveXShape extends Picture {
EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
spRecord.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE | EscherSpRecord.FLAG_OLESHAPE);
setShapeType(ShapeTypes.HostControl);
setShapeType(ShapeType.HOST_CONTROL);
setEscherProperty(EscherProperties.BLIP__PICTUREID, idx);
setEscherProperty(EscherProperties.LINESTYLE__COLOR, 0x8000001);
setEscherProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80008);

View File

@ -18,6 +18,8 @@
package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.POILogger;
import java.awt.geom.Rectangle2D;
@ -33,20 +35,20 @@ import java.awt.geom.Rectangle2D;
*/
public class AutoShape extends TextShape {
protected AutoShape(EscherContainerRecord escherRecord, Shape parent){
protected AutoShape(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
public AutoShape(int type, Shape parent){
public AutoShape(ShapeType type, ShapeContainer<Shape> parent){
super(null, parent);
_escherContainer = createSpContainer(type, parent instanceof ShapeGroup);
}
public AutoShape(int type){
public AutoShape(ShapeType type){
this(type, null);
}
protected EscherContainerRecord createSpContainer(int shapeType, boolean isChild){
protected EscherContainerRecord createSpContainer(ShapeType shapeType, boolean isChild){
_escherContainer = super.createSpContainer(isChild);
setShapeType(shapeType);
@ -110,7 +112,7 @@ public class AutoShape extends TextShape {
ShapeOutline outline = AutoShapes.getShapeOutline(getShapeType());
Rectangle2D anchor = getLogicalAnchor2D();
if(outline == null){
logger.log(POILogger.WARN, "Outline not found for " + ShapeTypes.typeName(getShapeType()));
logger.log(POILogger.WARN, "Outline not found for " + getShapeType().nativeName);
return anchor;
}
java.awt.Shape shape = outline.getOutline(this);

View File

@ -26,6 +26,7 @@ import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.sl.usermodel.ShapeType;
/**
* Stores definition of auto-shapes.
@ -45,8 +46,8 @@ public final class AutoShapes {
*
* @return the shape outline
*/
public static ShapeOutline getShapeOutline(int type){
ShapeOutline outline = shapes[type];
public static ShapeOutline getShapeOutline(ShapeType type){
ShapeOutline outline = shapes[type.nativeId];
return outline;
}
@ -68,14 +69,14 @@ public final class AutoShapes {
static {
shapes = new ShapeOutline[255];
shapes[ShapeTypes.Rectangle] = new ShapeOutline(){
shapes[ShapeType.RECT.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
Rectangle2D path = new Rectangle2D.Float(0, 0, 21600, 21600);
return path;
}
};
shapes[ShapeTypes.RoundRectangle] = new ShapeOutline(){
shapes[ShapeType.ROUND_RECT.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
RoundRectangle2D path = new RoundRectangle2D.Float(0, 0, 21600, 21600, adjval, adjval);
@ -83,14 +84,14 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.Ellipse] = new ShapeOutline(){
shapes[ShapeType.ELLIPSE.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
Ellipse2D path = new Ellipse2D.Float(0, 0, 21600, 21600);
return path;
}
};
shapes[ShapeTypes.Diamond] = new ShapeOutline(){
shapes[ShapeType.DIAMOND.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
GeneralPath path = new GeneralPath();
path.moveTo(10800, 0);
@ -103,7 +104,7 @@ public final class AutoShapes {
};
//m@0,l,21600r21600
shapes[ShapeTypes.IsocelesTriangle] = new ShapeOutline(){
shapes[ShapeType.TRIANGLE.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 10800);
GeneralPath path = new GeneralPath();
@ -115,7 +116,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.RightTriangle] = new ShapeOutline(){
shapes[ShapeType.RT_TRIANGLE.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
GeneralPath path = new GeneralPath();
path.moveTo(0, 0);
@ -126,7 +127,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.Parallelogram] = new ShapeOutline(){
shapes[ShapeType.PARALLELOGRAM.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
@ -140,7 +141,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.Trapezoid] = new ShapeOutline(){
shapes[ShapeType.TRAPEZOID.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
@ -154,7 +155,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.Hexagon] = new ShapeOutline(){
shapes[ShapeType.HEXAGON.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
@ -170,7 +171,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.Octagon] = new ShapeOutline(){
shapes[ShapeType.OCTAGON.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 6326);
@ -188,7 +189,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.Plus] = new ShapeOutline(){
shapes[ShapeType.PLUS.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
@ -210,7 +211,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.Pentagon] = new ShapeOutline(){
shapes[ShapeType.PENTAGON.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
GeneralPath path = new GeneralPath();
@ -224,7 +225,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.DownArrow] = new ShapeOutline(){
shapes[ShapeType.DOWN_ARROW.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
//m0@0 l@1@0 @1,0 @2,0 @2@0,21600@0,10800,21600xe
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 16200);
@ -242,7 +243,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.UpArrow] = new ShapeOutline(){
shapes[ShapeType.UP_ARROW.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
//m0@0 l@1@0 @1,21600@2,21600@2@0,21600@0,10800,xe
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
@ -260,7 +261,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.Arrow] = new ShapeOutline(){
shapes[ShapeType.RIGHT_ARROW.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
//m@0, l@0@1 ,0@1,0@2@0@2@0,21600,21600,10800xe
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 16200);
@ -278,7 +279,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.LeftArrow] = new ShapeOutline(){
shapes[ShapeType.LEFT_ARROW.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
//m@0, l@0@1,21600@1,21600@2@0@2@0,21600,,10800xe
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
@ -296,7 +297,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.Can] = new ShapeOutline(){
shapes[ShapeType.CAN.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
//m10800,qx0@1l0@2qy10800,21600,21600@2l21600@1qy10800,xem0@1qy10800@0,21600@1nfe
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
@ -320,7 +321,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.LeftBrace] = new ShapeOutline(){
shapes[ShapeType.LEFT_BRACE.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
//m21600,qx10800@0l10800@2qy0@11,10800@3l10800@1qy21600,21600e
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 1800);
@ -348,7 +349,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.RightBrace] = new ShapeOutline(){
shapes[ShapeType.RIGHT_BRACE.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
//m,qx10800@0 l10800@2qy21600@11,10800@3l10800@1qy,21600e
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 1800);
@ -376,7 +377,7 @@ public final class AutoShapes {
}
};
shapes[ShapeTypes.StraightConnector1] = new ShapeOutline(){
shapes[ShapeType.STRAIGHT_CONNECTOR_1.nativeId] = new ShapeOutline(){
public java.awt.Shape getOutline(Shape shape){
return new Line2D.Float(0, 0, 21600, 21600);
}

View File

@ -17,16 +17,22 @@
package org.apache.poi.hslf.model;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.hslf.usermodel.PictureData;
import org.apache.poi.hslf.blip.Bitmap;
import org.apache.poi.util.POILogger;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import javax.imageio.ImageIO;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.hslf.blip.Bitmap;
import org.apache.poi.hslf.usermodel.PictureData;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.util.POILogger;
/**
* Background shape
*
@ -34,7 +40,7 @@ import java.io.ByteArrayInputStream;
*/
public final class Background extends Shape {
protected Background(EscherContainerRecord escherRecord, Shape parent) {
protected Background(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent) {
super(escherRecord, parent);
}

View File

@ -31,6 +31,8 @@ import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.ddf.EscherSimpleProperty;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
@ -60,7 +62,7 @@ public final class Freeform extends AutoShape {
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of the shape
*/
protected Freeform(EscherContainerRecord escherRecord, Shape parent){
protected Freeform(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
@ -71,9 +73,9 @@ public final class Freeform extends AutoShape {
* @param parent the parent of this Shape. For example, if this text box is a cell
* in a table then the parent is Table.
*/
public Freeform(Shape parent){
super(null, parent);
_escherContainer = createSpContainer(ShapeTypes.NotPrimitive, parent instanceof ShapeGroup);
public Freeform(ShapeContainer<Shape> parent){
super((EscherContainerRecord)null, parent);
_escherContainer = createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof ShapeGroup);
}
/**

View File

@ -152,7 +152,7 @@ public final class Hyperlink {
* @return found hyperlinks or <code>null</code> if not found
*/
protected static Hyperlink[] find(TextRun run){
ArrayList lst = new ArrayList();
List<Hyperlink> lst = new ArrayList<Hyperlink>();
SlideShow ppt = run.getSheet().getSlideShow();
//document-level container which stores info about all links in a presentation
ExObjList exobj = ppt.getDocumentRecord().getExObjList();
@ -177,7 +177,7 @@ public final class Hyperlink {
* @return found hyperlink or <code>null</code>
*/
protected static Hyperlink find(Shape shape){
ArrayList lst = new ArrayList();
List<Hyperlink> lst = new ArrayList<Hyperlink>();
SlideShow ppt = shape.getSheet().getSlideShow();
//document-level container which stores info about all links in a presentation
ExObjList exobj = ppt.getDocumentRecord().getExObjList();
@ -198,7 +198,7 @@ public final class Hyperlink {
return lst.size() == 1 ? (Hyperlink)lst.get(0) : null;
}
private static void find(Record[] records, ExObjList exobj, List out){
private static void find(Record[] records, ExObjList exobj, List<Hyperlink> out){
for (int i = 0; i < records.length; i++) {
//see if we have InteractiveInfo in the textrun's records
if( records[i] instanceof InteractiveInfo){

View File

@ -18,6 +18,8 @@
package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Line2D;
@ -95,11 +97,11 @@ public final class Line extends SimpleShape {
public static final int LINE_TRIPLE = 4;
protected Line(EscherContainerRecord escherRecord, Shape parent){
protected Line(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
public Line(Shape parent){
public Line(ShapeContainer<Shape> parent){
super(null, parent);
_escherContainer = createSpContainer(parent instanceof ShapeGroup);
}
@ -112,7 +114,7 @@ public final class Line extends SimpleShape {
_escherContainer = super.createSpContainer(isChild);
EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
short type = (ShapeTypes.Line << 4) | 0x2;
short type = (short)((ShapeType.LINE.nativeId << 4) | 0x2);
spRecord.setOptions(type);
//set default properties for a line

View File

@ -25,6 +25,7 @@ import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.record.*;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.sl.usermodel.ShapeContainer;
/**
* Represents a movie in a PowerPoint document.
@ -54,7 +55,7 @@ public final class MovieShape extends Picture {
* @param idx the index of the picture
* @param parent the parent shape
*/
public MovieShape(int movieIdx, int idx, Shape parent) {
public MovieShape(int movieIdx, int idx, ShapeContainer<Shape> parent) {
super(idx, parent);
setMovieIndex(movieIdx);
}
@ -66,7 +67,7 @@ public final class MovieShape extends Picture {
* this picture in the <code>Slide</code>
* @param parent the parent shape of this picture
*/
protected MovieShape(EscherContainerRecord escherRecord, Shape parent){
protected MovieShape(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}

View File

@ -24,6 +24,7 @@ import org.apache.poi.hslf.record.ExObjList;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.ExEmbed;
import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
@ -51,7 +52,7 @@ public final class OLEShape extends Picture {
* @param idx the index of the picture
* @param parent the parent shape
*/
public OLEShape(int idx, Shape parent) {
public OLEShape(int idx, ShapeContainer<Shape> parent) {
super(idx, parent);
}
@ -62,7 +63,7 @@ public final class OLEShape extends Picture {
* this picture in the <code>Slide</code>
* @param parent the parent shape of this picture
*/
protected OLEShape(EscherContainerRecord escherRecord, Shape parent){
protected OLEShape(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}

View File

@ -1456,7 +1456,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param hints the rendering hints to be set
* @see RenderingHints
*/
public void addRenderingHints(Map hints){
public void addRenderingHints(Map<?,?> hints){
this._hints.putAll(hints);
}
@ -1581,8 +1581,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param hints the rendering hints to be set
* @see RenderingHints
*/
public void setRenderingHints(Map hints){
this._hints = new RenderingHints(hints);
public void setRenderingHints(Map<?,?> hints){
this._hints = new RenderingHints(null);
this._hints.putAll(hints);
}
/**

View File

@ -39,6 +39,8 @@ import org.apache.poi.hslf.blip.Bitmap;
import org.apache.poi.hslf.record.Document;
import org.apache.poi.hslf.usermodel.PictureData;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.StringUtil;
import org.apache.poi.util.Units;
@ -96,7 +98,7 @@ public class Picture extends SimpleShape {
* @param idx the index of the picture
* @param parent the parent shape
*/
public Picture(int idx, Shape parent) {
public Picture(int idx, ShapeContainer<Shape> parent) {
super(null, parent);
_escherContainer = createSpContainer(idx, parent instanceof ShapeGroup);
}
@ -108,7 +110,7 @@ public class Picture extends SimpleShape {
* this picture in the <code>Slide</code>
* @param parent the parent shape of this picture
*/
protected Picture(EscherContainerRecord escherRecord, Shape parent){
protected Picture(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
@ -136,7 +138,7 @@ public class Picture extends SimpleShape {
_escherContainer.setOptions((short)15);
EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
spRecord.setOptions((short)((ShapeTypes.PictureFrame << 4) | 0x2));
spRecord.setOptions((short)((ShapeType.FRAME.nativeId << 4) | 0x2));
//set default properties for a picture
EscherOptRecord opt = getEscherOptRecord();
@ -295,6 +297,6 @@ public class Picture extends SimpleShape {
EscherSimpleProperty prop = getEscherProperty(opt, propertyId);
if (prop == null) return 0;
int fixedPoint = prop.getPropertyValue();
return Units.fixedPointToDecimal(fixedPoint);
return Units.fixedPointToDouble(fixedPoint);
}
}

View File

@ -20,6 +20,7 @@ package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.hslf.record.OEPlaceholderAtom;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.sl.usermodel.ShapeContainer;
import java.io.ByteArrayOutputStream;
@ -30,11 +31,11 @@ import java.io.ByteArrayOutputStream;
*/
public final class Placeholder extends TextBox {
protected Placeholder(EscherContainerRecord escherRecord, Shape parent){
protected Placeholder(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
public Placeholder(Shape parent){
public Placeholder(ShapeContainer<Shape> parent){
super(parent);
}

View File

@ -18,6 +18,8 @@
package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.LittleEndian;
import java.awt.geom.Point2D;
@ -34,7 +36,7 @@ public final class Polygon extends AutoShape {
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of the shape
*/
protected Polygon(EscherContainerRecord escherRecord, Shape parent){
protected Polygon(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
@ -45,9 +47,9 @@ public final class Polygon extends AutoShape {
* @param parent the parent of this Shape. For example, if this text box is a cell
* in a table then the parent is Table.
*/
public Polygon(Shape parent){
super(null, parent);
_escherContainer = createSpContainer(ShapeTypes.NotPrimitive, parent instanceof ShapeGroup);
public Polygon(ShapeContainer<Shape> parent){
super((EscherContainerRecord)null, parent);
_escherContainer = createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof ShapeGroup);
}
/**

View File

@ -19,6 +19,8 @@ package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.hslf.record.ColorSchemeAtom;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.Units;
@ -43,7 +45,7 @@ import java.awt.geom.Rectangle2D;
*
* @author Yegor Kozlov
*/
public abstract class Shape {
public abstract class Shape implements org.apache.poi.sl.usermodel.Shape<Shape> {
// For logging
protected POILogger logger = POILogFactory.getLogger(this.getClass());
@ -83,7 +85,7 @@ public abstract class Shape {
* Parent of this shape.
* <code>null</code> for the topmost shapes.
*/
protected Shape _parent;
protected ShapeContainer<Shape> _parent;
/**
* The <code>Sheet</code> this shape belongs to
@ -101,7 +103,7 @@ public abstract class Shape {
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of this Shape
*/
protected Shape(EscherContainerRecord escherRecord, Shape parent){
protected Shape(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
_escherContainer = escherRecord;
_parent = parent;
}
@ -114,7 +116,7 @@ public abstract class Shape {
/**
* @return the parent of this shape
*/
public Shape getParent(){
public ShapeContainer<Shape> getParent(){
return _parent;
}
@ -122,25 +124,25 @@ public abstract class Shape {
* @return name of the shape.
*/
public String getShapeName(){
return ShapeTypes.typeName(getShapeType());
return getShapeType().nativeName;
}
/**
* @return type of the shape.
* @see org.apache.poi.hslf.record.RecordTypes
*/
public int getShapeType(){
public ShapeType getShapeType(){
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
return spRecord.getShapeType();
return ShapeType.forId(spRecord.getShapeType(), false);
}
/**
* @param type type of the shape.
* @see org.apache.poi.hslf.record.RecordTypes
*/
public void setShapeType(int type){
public void setShapeType(ShapeType type){
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
spRecord.setShapeType( (short) type );
spRecord.setShapeType( (short) type.nativeId );
spRecord.setVersion( (short) 0x2 );
}
@ -395,7 +397,7 @@ public abstract class Shape {
EscherSimpleProperty op = getEscherProperty(opt, opacityProperty);
int defaultOpacity = 0x00010000;
int opacity = (op == null) ? defaultOpacity : op.getPropertyValue();
double alpha = Units.fixedPointToDecimal(opacity)*255.0;
double alpha = Units.fixedPointToDouble(opacity)*255.0;
return new Color(rgb[0], rgb[1], rgb[2], (int)alpha);
}
@ -477,44 +479,47 @@ public abstract class Shape {
return getEscherChild(EscherOptRecord.RECORD_ID);
}
/**
* Whether the shape is horizontally flipped
*
* @return whether the shape is horizontally flipped
*/
@Override
public boolean getFlipHorizontal(){
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
return (spRecord.getFlags()& EscherSpRecord.FLAG_FLIPHORIZ) != 0;
}
/**
* Whether the shape is vertically flipped
*
* @return whether the shape is vertically flipped
*/
@Override
public void setFlipHorizontal(boolean flip) {
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
int flag = spRecord.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ;
spRecord.setFlags(flag);
}
@Override
public boolean getFlipVertical(){
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
return (spRecord.getFlags()& EscherSpRecord.FLAG_FLIPVERT) != 0;
}
/**
* Rotation angle in degrees
*
* @return rotation angle in degrees
*/
public int getRotation(){
int rot = getEscherProperty(EscherProperties.TRANSFORM__ROTATION);
int angle = (rot >> 16) % 360;
@Override
public void setFlipVertical(boolean flip) {
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
int flag = spRecord.getFlags() | EscherSpRecord.FLAG_FLIPVERT;
spRecord.setFlags(flag);
}
@Override
public double getRotation(){
int rot = getEscherProperty(EscherProperties.TRANSFORM__ROTATION);
double angle = Units.fixedPointToDouble(rot) % 360.0;
return angle;
}
/**
* Rotate this shape
*
* @param theta the rotation angle in degrees
*/
public void setRotation(int theta){
setEscherProperty(EscherProperties.TRANSFORM__ROTATION, (theta << 16));
@Override
public void setRotation(double theta){
int rot = Units.doubleToFixedPoint(theta % 360.0);
setEscherProperty(EscherProperties.TRANSFORM__ROTATION, rot);
}
@Override
public boolean isPlaceholder() {
return false;
}
}

View File

@ -34,6 +34,8 @@ import org.apache.poi.hslf.record.InteractiveInfoAtom;
import org.apache.poi.hslf.record.OEShapeAtom;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@ -49,14 +51,14 @@ public final class ShapeFactory {
/**
* Create a new shape from the data provided.
*/
public static Shape createShape(EscherContainerRecord spContainer, Shape parent){
public static Shape createShape(EscherContainerRecord spContainer, ShapeContainer<Shape> parent){
if (spContainer.getRecordId() == EscherContainerRecord.SPGR_CONTAINER){
return createShapeGroup(spContainer, parent);
}
return createSimpeShape(spContainer, parent);
}
public static ShapeGroup createShapeGroup(EscherContainerRecord spContainer, Shape parent){
public static ShapeGroup createShapeGroup(EscherContainerRecord spContainer, ShapeContainer<Shape> parent){
ShapeGroup group = null;
EscherRecord opt = Shape.getEscherChild((EscherContainerRecord)spContainer.getChild(0), (short)0xF122);
if(opt != null){
@ -80,17 +82,17 @@ public final class ShapeFactory {
return group;
}
public static Shape createSimpeShape(EscherContainerRecord spContainer, Shape parent){
public static Shape createSimpeShape(EscherContainerRecord spContainer, ShapeContainer<Shape> parent){
Shape shape = null;
EscherSpRecord spRecord = spContainer.getChildById(EscherSpRecord.RECORD_ID);
int type = spRecord.getShapeType();
ShapeType type = ShapeType.forId(spRecord.getShapeType(), false);
switch (type){
case ShapeTypes.TextBox:
case TEXT_BOX:
shape = new TextBox(spContainer, parent);
break;
case ShapeTypes.HostControl:
case ShapeTypes.PictureFrame: {
case HOST_CONTROL:
case FRAME: {
InteractiveInfo info = getClientDataRecord(spContainer, RecordTypes.InteractiveInfo.typeID);
OEShapeAtom oes = getClientDataRecord(spContainer, RecordTypes.OEShapeAtom.typeID);
if(info != null && info.getInteractiveInfoAtom() != null){
@ -111,10 +113,10 @@ public final class ShapeFactory {
if(shape == null) shape = new Picture(spContainer, parent);
break;
}
case ShapeTypes.Line:
case LINE:
shape = new Line(spContainer, parent);
break;
case ShapeTypes.NotPrimitive: {
case NOT_PRIMITIVE: {
EscherOptRecord opt = Shape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID);
EscherProperty prop = Shape.getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES);
if(prop != null)

View File

@ -30,6 +30,8 @@ import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.ddf.EscherSpgrRecord;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
@ -38,7 +40,7 @@ import org.apache.poi.util.POILogger;
*
* @author Yegor Kozlov
*/
public class ShapeGroup extends Shape{
public class ShapeGroup extends Shape implements ShapeContainer<Shape> {
/**
* Create a new ShapeGroup. This constructor is used when a new shape is created.
@ -55,7 +57,7 @@ public class ShapeGroup extends Shape{
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of the shape
*/
protected ShapeGroup(EscherContainerRecord escherRecord, Shape parent){
protected ShapeGroup(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
@ -63,31 +65,7 @@ public class ShapeGroup extends Shape{
* @return the shapes contained in this group container
*/
public Shape[] getShapes() {
// Out escher container record should contain several
// SpContainers, the first of which is the group shape itself
Iterator<EscherRecord> iter = _escherContainer.getChildIterator();
// Don't include the first SpContainer, it is always NotPrimitive
if (iter.hasNext()) {
iter.next();
}
List<Shape> shapeList = new ArrayList<Shape>();
while (iter.hasNext()) {
EscherRecord r = iter.next();
if(r instanceof EscherContainerRecord) {
// Create the Shape for it
EscherContainerRecord container = (EscherContainerRecord)r;
Shape shape = ShapeFactory.createShape(container, this);
shape.setSheet(getSheet());
shapeList.add( shape );
} else {
// Should we do anything special with these non
// Container records?
logger.log(POILogger.ERROR, "Shape contained non container escher record, was " + r.getClass().getName());
}
}
// Put the shapes into an array, and return
List<Shape> shapeList = getShapeList();
Shape[] shapes = shapeList.toArray(new Shape[shapeList.size()]);
return shapes;
}
@ -179,7 +157,7 @@ public class ShapeGroup extends Shape{
spcont.addChildRecord(spg);
EscherSpRecord sp = new EscherSpRecord();
short type = (ShapeTypes.NotPrimitive << 4) + 2;
short type = (short)((ShapeType.NOT_PRIMITIVE.nativeId << 4) + 2);
sp.setOptions(type);
sp.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_GROUP);
spcont.addChildRecord(sp);
@ -260,9 +238,10 @@ public class ShapeGroup extends Shape{
*
* @return type of the shape.
*/
public int getShapeType(){
public ShapeType getShapeType(){
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
return spRecord.getOptions() >> 4;
int nativeId = spRecord.getOptions() >> 4;
return ShapeType.forId(nativeId, false);
}
/**
@ -291,4 +270,45 @@ public class ShapeGroup extends Shape{
EscherContainerRecord groupInfoContainer = (EscherContainerRecord)_escherContainer.getChild(0);
return groupInfoContainer.getChildById((short)recordId);
}
public Iterator<Shape> iterator() {
return getShapeList().iterator();
}
public boolean removeShape(Shape shape) {
// TODO: implement!
throw new UnsupportedOperationException();
}
/**
* @return the shapes contained in this group container
*/
protected List<Shape> getShapeList() {
// Out escher container record should contain several
// SpContainers, the first of which is the group shape itself
Iterator<EscherRecord> iter = _escherContainer.getChildIterator();
// Don't include the first SpContainer, it is always NotPrimitive
if (iter.hasNext()) {
iter.next();
}
List<Shape> shapeList = new ArrayList<Shape>();
while (iter.hasNext()) {
EscherRecord r = iter.next();
if(r instanceof EscherContainerRecord) {
// Create the Shape for it
EscherContainerRecord container = (EscherContainerRecord)r;
Shape shape = ShapeFactory.createShape(container, this);
shape.setSheet(getSheet());
shapeList.add( shape );
} else {
// Should we do anything special with these non
// Container records?
logger.log(POILogger.ERROR, "Shape contained non container escher record, was " + r.getClass().getName());
}
}
return shapeList;
}
}

View File

@ -1,57 +0,0 @@
/* ====================================================================
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.hslf.model;
import java.lang.reflect.Field;
import java.util.HashMap;
import org.apache.poi.hslf.exceptions.HSLFException;
/**
* Contains all known shape types in PowerPoint
*
* @author Yegor Kozlov
*/
public final class ShapeTypes implements org.apache.poi.sl.usermodel.ShapeTypes {
/**
* Return name of the shape by id
* @param type - the id of the shape, one of the static constants defined in this class
* @return the name of the shape
*/
public static String typeName(int type) {
String name = (String)types.get(Integer.valueOf(type));
return name;
}
public static final HashMap types;
static {
types = new HashMap();
try {
Field[] f = org.apache.poi.sl.usermodel.ShapeTypes.class.getFields();
for (int i = 0; i < f.length; i++){
Object val = f[i].get(null);
if (val instanceof Integer) {
types.put(val, f[i].getName());
}
}
} catch (IllegalAccessException e){
throw new HSLFException("Failed to initialize shape types");
}
}
}

View File

@ -45,6 +45,7 @@ import org.apache.poi.hslf.record.TextHeaderAtom;
import org.apache.poi.hslf.record.TextRulerAtom;
import org.apache.poi.hslf.record.TextSpecInfoAtom;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@ -56,7 +57,7 @@ import org.apache.poi.util.POILogger;
* @author Yegor Kozlov
*/
public abstract class Sheet {
public abstract class Sheet implements ShapeContainer<Shape> {
private static POILogger logger = POILogFactory.getLogger(Sheet.class);
/**
@ -272,36 +273,8 @@ public abstract class Sheet {
* @return all shapes contained in this Sheet (Slide or Notes)
*/
public Shape[] getShapes() {
PPDrawing ppdrawing = getPPDrawing();
EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
EscherContainerRecord spgr = null;
for (Iterator<EscherRecord> it = dg.getChildIterator(); it.hasNext();) {
EscherRecord rec = it.next();
if (rec.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
spgr = (EscherContainerRecord) rec;
break;
}
}
if (spgr == null) {
throw new IllegalStateException("spgr not found");
}
List<Shape> shapes = new ArrayList<Shape>();
Iterator<EscherRecord> it = spgr.getChildIterator();
if (it.hasNext()) {
// skip first item
it.next();
}
for (; it.hasNext();) {
EscherContainerRecord sp = (EscherContainerRecord) it.next();
Shape sh = ShapeFactory.createShape(sp, null);
sh.setSheet(this);
shapes.add(sh);
}
return shapes.toArray(new Shape[shapes.size()]);
List<Shape> shapeList = getShapeList();
return shapeList.toArray(new Shape[shapeList.size()]);
}
/**
@ -524,4 +497,47 @@ public abstract class Sheet {
}
public Iterator<Shape> iterator() {
return getShapeList().iterator();
}
/**
* Returns all shapes contained in this Sheet
*
* @return all shapes contained in this Sheet (Slide or Notes)
*/
protected List<Shape> getShapeList() {
PPDrawing ppdrawing = getPPDrawing();
EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
EscherContainerRecord spgr = null;
for (Iterator<EscherRecord> it = dg.getChildIterator(); it.hasNext();) {
EscherRecord rec = it.next();
if (rec.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
spgr = (EscherContainerRecord) rec;
break;
}
}
if (spgr == null) {
throw new IllegalStateException("spgr not found");
}
List<Shape> shapeList = new ArrayList<Shape>();
Iterator<EscherRecord> it = spgr.getChildIterator();
if (it.hasNext()) {
// skip first item
it.next();
}
for (; it.hasNext();) {
EscherContainerRecord sp = (EscherContainerRecord) it.next();
Shape sh = ShapeFactory.createShape(sp, null);
sh.setSheet(this);
shapeList.add(sh);
}
return shapeList;
}
}

View File

@ -38,6 +38,7 @@ import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.record.InteractiveInfo;
import org.apache.poi.hslf.record.InteractiveInfoAtom;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.util.LittleEndian;
/**
@ -62,7 +63,7 @@ public abstract class SimpleShape extends Shape {
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of the shape
*/
protected SimpleShape(EscherContainerRecord escherRecord, Shape parent){
protected SimpleShape(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
@ -191,7 +192,7 @@ public abstract class SimpleShape extends Shape {
*
* @return style of the line.
*/
public int getLineStyle(){
public int getStrokeStyle(){
EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE);
return prop == null ? Line.LINE_SIMPLE : prop.getPropertyValue();
@ -221,10 +222,12 @@ public abstract class SimpleShape extends Shape {
Rectangle2D anchor = getAnchor2D();
//if it is a groupped shape see if we need to transform the coordinates
if (_parent != null){
if (getParent() != null){
ArrayList<ShapeGroup> lst = new ArrayList<ShapeGroup>();
for (Shape top=this; (top = top.getParent()) != null; ) {
lst.add(0, (ShapeGroup)top);
for (ShapeContainer<Shape> parent=this.getParent();
parent instanceof ShapeGroup;
parent = ((ShapeGroup)parent).getParent()) {
lst.add(0, (ShapeGroup)parent);
}
AffineTransform tx = new AffineTransform();
@ -243,8 +246,8 @@ public abstract class SimpleShape extends Shape {
anchor = tx.createTransformedShape(anchor).getBounds2D();
}
int angle = getRotation();
if(angle != 0){
double angle = getRotation();
if(angle != 0.){
double centerX = anchor.getX() + anchor.getWidth()/2;
double centerY = anchor.getY() + anchor.getHeight()/2;

View File

@ -34,9 +34,10 @@ import org.apache.poi.hslf.record.RecordContainer;
import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.hslf.record.SSSlideInfoAtom;
import org.apache.poi.hslf.record.SlideAtom;
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
import org.apache.poi.hslf.record.StyleTextProp9Atom;
import org.apache.poi.hslf.record.TextHeaderAtom;
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
import org.apache.poi.sl.usermodel.ShapeType;
/**
* This class represents a slide in a PowerPoint Document. It allows
@ -47,8 +48,7 @@ import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
* @author Yegor Kozlov
*/
public final class Slide extends Sheet
{
public final class Slide extends Sheet {
private int _slideNo;
private SlideAtomsSet _atomSet;
private TextRun[] _runs;
@ -180,7 +180,7 @@ public final class Slide extends Sheet
*/
public TextBox addTitle() {
Placeholder pl = new Placeholder();
pl.setShapeType(ShapeTypes.Rectangle);
pl.setShapeType(ShapeType.RECT);
pl.getTextRun().setRunType(TextHeaderAtom.TITLE_TYPE);
pl.setText("Click to edit title");
pl.setAnchor(new java.awt.Rectangle(54, 48, 612, 90));

View File

@ -18,6 +18,7 @@
package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.util.LittleEndian;
import java.util.*;
@ -92,7 +93,7 @@ public final class Table extends ShapeGroup {
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of the shape
*/
public Table(EscherContainerRecord escherRecord, Shape parent) {
public Table(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent) {
super(escherRecord, parent);
}
@ -125,7 +126,7 @@ public final class Table extends ShapeGroup {
TableCell cell = cells[i][0];
int rowHeight = cell.getAnchor().height*MASTER_DPI/POINT_DPI;
byte[] val = new byte[4];
LittleEndian.putInt(val, rowHeight);
LittleEndian.putInt(val, 0, rowHeight);
p.setElement(i, val);
for (int j = 0; j < cells[i].length; j++) {
TableCell c = cells[i][j];
@ -149,11 +150,11 @@ public final class Table extends ShapeGroup {
}
protected void initTable(){
Shape[] sh = getShapes();
Arrays.sort(sh, new Comparator(){
public int compare( Object o1, Object o2 ) {
Rectangle anchor1 = ((Shape)o1).getAnchor();
Rectangle anchor2 = ((Shape)o2).getAnchor();
List<Shape> shapeList = getShapeList();
Collections.sort(shapeList, new Comparator<Shape>(){
public int compare( Shape o1, Shape o2 ) {
Rectangle anchor1 = o1.getAnchor();
Rectangle anchor2 = o2.getAnchor();
int delta = anchor1.y - anchor2.y;
if(delta == 0) delta = anchor1.x - anchor2.x;
return delta;
@ -161,23 +162,23 @@ public final class Table extends ShapeGroup {
});
int y0 = -1;
int maxrowlen = 0;
ArrayList lst = new ArrayList();
ArrayList row = null;
for (int i = 0; i < sh.length; i++) {
if(sh[i] instanceof TextShape){
Rectangle anchor = sh[i].getAnchor();
List<List<Shape>> lst = new ArrayList<List<Shape>>();
List<Shape> row = null;
for (Shape sh : shapeList) {
if(sh instanceof TextShape){
Rectangle anchor = sh.getAnchor();
if(anchor.y != y0){
y0 = anchor.y;
row = new ArrayList();
row = new ArrayList<Shape>();
lst.add(row);
}
row.add(sh[i]);
row.add(sh);
maxrowlen = Math.max(maxrowlen, row.size());
}
}
cells = new TableCell[lst.size()][maxrowlen];
for (int i = 0; i < lst.size(); i++) {
row = (ArrayList)lst.get(i);
row = lst.get(i);
for (int j = 0; j < row.size(); j++) {
TextShape tx = (TextShape)row.get(j);
cells[i][j] = new TableCell(tx.getSpContainer(), getParent());
@ -318,7 +319,7 @@ public final class Table extends ShapeGroup {
private Line cloneBorder(Line line){
Line border = createBorder();
border.setLineWidth(line.getLineWidth());
border.setLineStyle(line.getLineStyle());
border.setLineStyle(line.getStrokeStyle());
border.setLineDashing(line.getLineDashing());
border.setLineColor(line.getLineColor());
return border;

View File

@ -17,9 +17,13 @@
package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import java.awt.Rectangle;
import java.awt.*;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
/**
* Represents a cell in a ppt table
@ -38,10 +42,10 @@ public final class TableCell extends TextBox {
/**
* Create a TableCell object and initialize it from the supplied Record container.
*
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param escherRecord {@link EscherSpContainer} container which holds information about this shape
* @param parent the parent of the shape
*/
protected TableCell(EscherContainerRecord escherRecord, Shape parent){
protected TableCell(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
@ -51,10 +55,10 @@ public final class TableCell extends TextBox {
* @param parent the parent of this Shape. For example, if this text box is a cell
* in a table then the parent is Table.
*/
public TableCell(Shape parent){
public TableCell(ShapeContainer<Shape> parent){
super(parent);
setShapeType(ShapeTypes.Rectangle);
setShapeType(ShapeType.RECT);
//_txtrun.setRunType(TextHeaderAtom.HALF_BODY_TYPE);
//_txtrun.getRichTextRuns()[0].setFlag(false, 0, false);
}

View File

@ -18,6 +18,8 @@
package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
/**
* Represents a TextFrame shape in PowerPoint.
@ -36,7 +38,7 @@ public class TextBox extends TextShape {
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of the shape
*/
protected TextBox(EscherContainerRecord escherRecord, Shape parent){
protected TextBox(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
@ -47,7 +49,7 @@ public class TextBox extends TextShape {
* @param parent the parent of this Shape. For example, if this text box is a cell
* in a table then the parent is Table.
*/
public TextBox(Shape parent){
public TextBox(ShapeContainer<Shape> parent){
super(parent);
}
@ -67,7 +69,7 @@ public class TextBox extends TextShape {
protected EscherContainerRecord createSpContainer(boolean isChild){
_escherContainer = super.createSpContainer(isChild);
setShapeType(ShapeTypes.TextBox);
setShapeType(ShapeType.TEXT_BOX);
//set default properties for a TextBox
setEscherProperty(EscherProperties.FILL__FILLCOLOR, 0x8000004);

View File

@ -41,12 +41,14 @@ import org.apache.poi.hslf.record.OutlineTextRefAtom;
import org.apache.poi.hslf.record.PPDrawing;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.hslf.record.RoundTripHFPlaceholder12;
import org.apache.poi.hslf.record.StyleTextPropAtom;
import org.apache.poi.hslf.record.TextBytesAtom;
import org.apache.poi.hslf.record.TextCharsAtom;
import org.apache.poi.hslf.record.TextHeaderAtom;
import org.apache.poi.hslf.record.TxInteractiveInfoAtom;
import org.apache.poi.hslf.usermodel.RichTextRun;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.util.POILogger;
/**
@ -109,7 +111,7 @@ public abstract class TextShape extends SimpleShape {
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of the shape
*/
protected TextShape(EscherContainerRecord escherRecord, Shape parent){
protected TextShape(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
super(escherRecord, parent);
}
@ -120,7 +122,7 @@ public abstract class TextShape extends SimpleShape {
* @param parent the parent of this Shape. For example, if this text box is a cell
* in a table then the parent is Table.
*/
public TextShape(Shape parent){
public TextShape(ShapeContainer<Shape> parent){
super(null, parent);
_escherContainer = createSpContainer(parent instanceof ShapeGroup);
}
@ -623,4 +625,17 @@ public abstract class TextShape extends SimpleShape {
}
@Override
public boolean isPlaceholder() {
OEPlaceholderAtom oep = getPlaceholderAtom();
if (oep != null) return true;
//special case for files saved in Office 2007
RoundTripHFPlaceholder12 hldr = getClientDataRecord(RecordTypes.RoundTripHFPlaceholder12.typeID);
if (hldr != null) return true;
return false;
}
}

View File

@ -37,7 +37,7 @@ import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.ddf.EscherSpgrRecord;
import org.apache.poi.ddf.EscherTextboxRecord;
import org.apache.poi.ddf.UnknownEscherRecord;
import org.apache.poi.hslf.model.ShapeTypes;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
@ -95,7 +95,7 @@ public final class PPDrawing extends RecordAtom {
final DefaultEscherRecordFactory erf = new DefaultEscherRecordFactory();
final List<EscherRecord> escherChildren = new ArrayList<EscherRecord>();
findEscherChildren(erf, contents, 8, len-8, escherChildren);
this.childRecords = (EscherRecord[]) escherChildren.toArray(new EscherRecord[escherChildren.size()]);
this.childRecords = escherChildren.toArray(new EscherRecord[escherChildren.size()]);
if (1 == this.childRecords.length && (short)0xf002 == this.childRecords[0].getRecordId() && this.childRecords[0] instanceof EscherContainerRecord) {
this.textboxWrappers = findInDgContainer((EscherContainerRecord) this.childRecords[0]);
@ -103,7 +103,7 @@ public final class PPDrawing extends RecordAtom {
// Find and EscherTextboxRecord's, and wrap them up
final List<EscherTextboxWrapper> textboxes = new ArrayList<EscherTextboxWrapper>();
findEscherTextboxRecord(childRecords, textboxes);
this.textboxWrappers = (EscherTextboxWrapper[]) textboxes.toArray(new EscherTextboxWrapper[textboxes.size()]);
this.textboxWrappers = textboxes.toArray(new EscherTextboxWrapper[textboxes.size()]);
}
}
private EscherTextboxWrapper[] findInDgContainer(final EscherContainerRecord escherContainerF002) {
@ -131,7 +131,7 @@ public final class PPDrawing extends RecordAtom {
found.add(w);
}
}
return (EscherTextboxWrapper[]) found.toArray(new EscherTextboxWrapper[found.size()]);
return found.toArray(new EscherTextboxWrapper[found.size()]);
}
private StyleTextProp9Atom findInSpContainer(final EscherContainerRecord spContainer) {
final EscherContainerRecord escherContainerF011 = findFirstEscherContainerRecordOfType((short)0xf011, spContainer);
@ -301,7 +301,7 @@ public final class PPDrawing extends RecordAtom {
spContainer.addChildRecord(spgr);
EscherSpRecord sp = new EscherSpRecord();
sp.setOptions((short)((ShapeTypes.NotPrimitive << 4) + 2));
sp.setOptions((short)((ShapeType.NOT_PRIMITIVE.nativeId << 4) + 2));
sp.setFlags(EscherSpRecord.FLAG_PATRIARCH | EscherSpRecord.FLAG_GROUP);
spContainer.addChildRecord(sp);
spgrContainer.addChildRecord(spContainer);
@ -311,7 +311,7 @@ public final class PPDrawing extends RecordAtom {
spContainer.setOptions((short)15);
spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
sp = new EscherSpRecord();
sp.setOptions((short)((ShapeTypes.Rectangle << 4) + 2));
sp.setOptions((short)((ShapeType.RECT.nativeId << 4) + 2));
sp.setFlags(EscherSpRecord.FLAG_BACKGROUND | EscherSpRecord.FLAG_HASSHAPETYPE);
spContainer.addChildRecord(sp);
@ -393,7 +393,7 @@ public final class PPDrawing extends RecordAtom {
result.add(child);
}
}
return (EscherContainerRecord[]) result.toArray(new EscherContainerRecord[result.size()]);
return result.toArray(new EscherContainerRecord[result.size()]);
}
protected Record buildFromUnknownEscherRecord(UnknownEscherRecord unknown) {
byte[] bingo = unknown.getData();
@ -436,6 +436,6 @@ public final class PPDrawing extends RecordAtom {
}
}
}
return (StyleTextProp9Atom[]) result.toArray(new StyleTextProp9Atom[result.size()]);
return result.toArray(new StyleTextProp9Atom[result.size()]);
}
}

View File

@ -0,0 +1,10 @@
package org.apache.poi.sl.draw;
import org.apache.poi.sl.usermodel.*;
public class DrawAutoShape<T extends AutoShape> extends DrawTextShape<T> {
public DrawAutoShape(T shape) {
super(shape);
}
}

View File

@ -0,0 +1,96 @@
/* ====================================================================
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;
import static org.apache.poi.sl.draw.Drawable.DRAW_FACTORY;
import java.awt.Graphics2D;
import java.awt.font.TextLayout;
import java.text.AttributedString;
import org.apache.poi.sl.usermodel.*;
public class DrawFactory {
protected static ThreadLocal<DrawFactory> defaultFactory = new ThreadLocal<DrawFactory>();
/**
* Set a custom draw factory for the current thread.
* This is a fallback, for operations where usercode can't set a graphics context.
* Preferably use the rendering hint {@link Drawable#DRAW_FACTORY} to set the factory.
*
* @param factory
*/
public static void setDefaultFactory(DrawFactory factory) {
defaultFactory.set(factory);
}
public static DrawFactory getInstance(Graphics2D graphics) {
// first try to find the factory over the rendering hing
DrawFactory factory = (DrawFactory)graphics.getRenderingHint(DRAW_FACTORY);
// secondly try the thread local default
if (factory == null) {
factory = defaultFactory.get();
}
// and at last, use the default factory
if (factory == null) {
factory = new DrawFactory();
graphics.setRenderingHint(DRAW_FACTORY, factory);
}
return factory;
}
public Drawable getDrawable(Sheet sheet) {
return new DrawSheet(sheet);
}
public Drawable getDrawable(MasterSheet sheet) {
return new DrawMasterSheet(sheet);
}
@SuppressWarnings("unchecked")
public Drawable getDrawable(Shape shape) {
if (shape instanceof TextBox) {
return getDrawable((TextBox)shape);
} else if (shape instanceof FreeformShape) {
return getDrawable((FreeformShape)shape);
}
throw new IllegalArgumentException("Unsupported shape type: "+shape.getClass());
}
public <T extends TextBox> DrawTextBox<T> getDrawable(T shape) {
return new DrawTextBox<T>(shape);
}
public <T extends FreeformShape> DrawFreeformShape<T> getDrawable(T shape) {
return new DrawFreeformShape<T>(shape);
}
public DrawTextParagraph getDrawable(TextParagraph paragraph) {
return new DrawTextParagraph(paragraph);
}
public DrawTextFragment getTextFragment(TextLayout layout, AttributedString str) {
return new DrawTextFragment(layout, str);
}
public DrawPaint getPaint(PlaceableShape shape) {
return new DrawPaint(shape);
}
}

View File

@ -17,13 +17,22 @@
* ====================================================================
*/
package org.apache.poi.xslf.usermodel;
package org.apache.poi.sl.draw;
/**
* @author Yegor Kozlov
* Manages fonts when rendering slides.
*
* Use this class to handle unknown / missing fonts or to substitute fonts
*/
public enum TextCap {
NONE,
SMALL,
ALL
public interface DrawFontManager {
/**
* select a font to be used to paint text
*
* @param typeface the font family as defined in the .pptx file.
* This can be unknown or missing in the graphic environment.
*
* @return the font to be used to paint text
*/
String getRendererableFont(String typeface, int pitchFamily);
}

View File

@ -0,0 +1,9 @@
package org.apache.poi.sl.draw;
import org.apache.poi.sl.usermodel.*;
public class DrawFreeformShape<T extends FreeformShape> extends DrawAutoShape<T> {
public DrawFreeformShape(T shape) {
super(shape);
}
}

View File

@ -0,0 +1,22 @@
package org.apache.poi.sl.draw;
import org.apache.poi.sl.usermodel.MasterSheet;
import org.apache.poi.sl.usermodel.Shape;
public class DrawMasterSheet extends DrawSheet {
public DrawMasterSheet(MasterSheet sheet) {
super(sheet);
}
/**
* Checks if this <code>sheet</code> displays the specified shape.
*
* Subclasses can override it and skip certain shapes from drawings,
* for instance, slide masters and layouts don't display placeholders
*/
protected boolean canDraw(Shape shape){
return !shape.isPlaceholder();
}
}

View File

@ -0,0 +1,448 @@
/* ====================================================================
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;
import java.awt.*;
import java.awt.MultipleGradientPaint.ColorSpaceType;
import java.awt.MultipleGradientPaint.CycleMethod;
import java.awt.Shape;
import java.awt.geom.*;
import java.awt.image.*;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.sl.usermodel.*;
import org.apache.poi.sl.usermodel.GradientPaint;
import org.apache.poi.sl.usermodel.TexturePaint;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
public class DrawPaint {
public final static Color NO_PAINT = new Color(0xFF, 0xFF, 0xFF, 0);
private final static POILogger LOG = POILogFactory.getLogger(DrawPaint.class);
protected PlaceableShape shape;
public DrawPaint(PlaceableShape shape) {
this.shape = shape;
}
public Paint getPaint(Graphics2D graphics, PaintStyle paint) {
if (paint instanceof SolidPaint) {
return getSolidPaint((SolidPaint)paint, graphics);
} else if (paint instanceof GradientPaint) {
return getGradientPaint((GradientPaint)paint, graphics);
} else if (paint instanceof TexturePaint) {
return getTexturePaint((TexturePaint)paint, graphics);
}
return null;
}
protected Paint getSolidPaint(SolidPaint fill, Graphics2D graphics) {
return applyColorTransform(fill.getSolidColor());
}
protected Paint getGradientPaint(GradientPaint fill, Graphics2D graphics) {
switch (fill.getGradientType()) {
case linear:
return createLinearGradientPaint(fill, graphics);
case circular:
return createRadialGradientPaint(fill, graphics);
case shape:
return createPathGradientPaint(fill, graphics);
default:
throw new UnsupportedOperationException("gradient fill of type "+fill+" not supported.");
}
}
protected Paint getTexturePaint(TexturePaint fill, Graphics2D graphics) {
InputStream is = fill.getImageData();
if (is == null) return NO_PAINT;
assert(graphics != null);
ImageRenderer renderer = (ImageRenderer)graphics.getRenderingHint(Drawable.IMAGE_RENDERER);
if (renderer == null) renderer = new ImageRenderer();
try {
renderer.loadImage(fill.getImageData(), fill.getContentType());
} catch (IOException e) {
LOG.log(POILogger.ERROR, "Can't load image data - using transparent color", e);
return NO_PAINT;
}
int alpha = fill.getAlpha();
if (alpha != -1) {
renderer.setAlpha(fill.getAlpha()/100000.f);
}
Dimension dim = renderer.getDimension();
Rectangle2D textAnchor = new Rectangle2D.Double(0, 0, dim.getWidth(), dim.getHeight());
Paint paint = new java.awt.TexturePaint(renderer.getImage(), textAnchor);
return paint;
}
/**
* Convert color transformations in {@link ColorStyle} to a {@link Color} instance
*/
public static Color applyColorTransform(ColorStyle color){
Color result = color.getColor();
if (result == null || color.getAlpha() == 100) return NO_PAINT;
result = applyAlpha(result, color);
result = applyLuminanace(result, color);
result = applyShade(result, color);
result = applyTint(result, color);
return result;
}
protected static Color applyAlpha(Color c, ColorStyle fc) {
int alpha = c.getAlpha();
return (alpha == 0 || alpha == -1) ? c : new Color(c.getRed(), c.getGreen(), c.getBlue(), alpha);
}
/**
* Apply lumMod / lumOff adjustments
*
* @param c the color to modify
* @param lumMod luminance modulation in the range [0..100000]
* @param lumOff luminance offset in the range [0..100000]
* @return modified color
*/
protected static Color applyLuminanace(Color c, ColorStyle fc) {
int lumMod = fc.getLumMod();
if (lumMod == -1) lumMod = 100000;
int lumOff = fc.getLumOff();
if (lumOff == -1) lumOff = 0;
if (lumMod == 100000 && lumOff == 0) return c;
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();
float red,green,blue;
Color color;
if (lumOff > 0) {
float flumOff = lumOff / 100000.f;
red = (255.f - r) * (1.f - flumOff) + r;
green = (255.f - g) * flumOff + g;
blue = (255.f - b) * flumOff + b;
} else {
float flumMod = lumMod / 100000.f;
red = r * lumMod;
green = g * lumMod;
blue = b * lumMod;
}
return new Color(Math.round(red), Math.round(green), Math.round(blue), c.getAlpha());
}
/**
* This algorithm returns result different from PowerPoint.
* TODO: revisit and improve
*/
protected static Color applyShade(Color c, ColorStyle fc) {
int shade = fc.getShade();
if (shade == -1) return c;
float fshade = shade / 100000.f;
float red = c.getRed() * fshade;
float green = c.getGreen() * fshade;
float blue = c.getGreen() * fshade;
return new Color(Math.round(red), Math.round(green), Math.round(blue), c.getAlpha());
}
/**
* This algorithm returns result different from PowerPoint.
* TODO: revisit and improve
*/
protected static Color applyTint(Color c, ColorStyle fc) {
int tint = fc.getTint();
if (tint == -1) return c;
float ftint = tint / 100000.f;
float red = ftint * c.getRed() + (1.f - ftint) * 255.f;
float green = ftint * c.getGreen() + (1.f - ftint) * 255.f;
float blue = ftint * c.getBlue() + (1.f - ftint) * 255.f;
return new Color(Math.round(red), Math.round(green), Math.round(blue), c.getAlpha());
}
protected Paint createLinearGradientPaint(GradientPaint fill, Graphics2D graphics) {
double angle = fill.getGradientAngle();
Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);
AffineTransform at = AffineTransform.getRotateInstance(
Math.toRadians(angle),
anchor.getX() + anchor.getWidth() / 2,
anchor.getY() + anchor.getHeight() / 2);
double diagonal = Math.sqrt(anchor.getHeight() * anchor.getHeight() + anchor.getWidth() * anchor.getWidth());
Point2D p1 = new Point2D.Double(anchor.getX() + anchor.getWidth() / 2 - diagonal / 2,
anchor.getY() + anchor.getHeight() / 2);
p1 = at.transform(p1, null);
Point2D p2 = new Point2D.Double(anchor.getX() + anchor.getWidth(), anchor.getY() + anchor.getHeight() / 2);
p2 = at.transform(p2, null);
snapToAnchor(p1, anchor);
snapToAnchor(p2, anchor);
float[] fractions = fill.getGradientFractions();
Color[] colors = new Color[fractions.length];
int i = 0;
for (ColorStyle fc : fill.getGradientColors()) {
colors[i++] = applyColorTransform(fc);
}
AffineTransform grAt = new AffineTransform();
if(fill.isRotatedWithShape()) {
double rotation = shape.getRotation();
if (rotation != 0.) {
double centerX = anchor.getX() + anchor.getWidth() / 2;
double centerY = anchor.getY() + anchor.getHeight() / 2;
grAt.translate(centerX, centerY);
grAt.rotate(Math.toRadians(-rotation));
grAt.translate(-centerX, -centerY);
}
}
return new LinearGradientPaint
(p1, p2, fractions, colors, CycleMethod.NO_CYCLE, ColorSpaceType.SRGB, grAt);
}
protected Paint createRadialGradientPaint(GradientPaint fill, Graphics2D graphics) {
Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);
Point2D pCenter = new Point2D.Double(anchor.getX() + anchor.getWidth()/2,
anchor.getY() + anchor.getHeight()/2);
float radius = (float)Math.max(anchor.getWidth(), anchor.getHeight());
float[] fractions = fill.getGradientFractions();
Color[] colors = new Color[fractions.length];
int i=0;
for (ColorStyle fc : fill.getGradientColors()) {
colors[i++] = applyColorTransform(fc);
}
return new RadialGradientPaint(pCenter, radius, fractions, colors);
}
protected Paint createPathGradientPaint(GradientPaint fill, Graphics2D graphics) {
// currently we ignore an eventually center setting
float[] fractions = fill.getGradientFractions();
Color[] colors = new Color[fractions.length];
int i=0;
for (ColorStyle fc : fill.getGradientColors()) {
colors[i++] = applyColorTransform(fc);
}
return new PathGradientPaint(colors, fractions);
}
protected void snapToAnchor(Point2D p, Rectangle2D anchor) {
if (p.getX() < anchor.getX()) {
p.setLocation(anchor.getX(), p.getY());
} else if (p.getX() > (anchor.getX() + anchor.getWidth())) {
p.setLocation(anchor.getX() + anchor.getWidth(), p.getY());
}
if (p.getY() < anchor.getY()) {
p.setLocation(p.getX(), anchor.getY());
} else if (p.getY() > (anchor.getY() + anchor.getHeight())) {
p.setLocation(p.getX(), anchor.getY() + anchor.getHeight());
}
}
public static class PathGradientPaint implements Paint {
// http://asserttrue.blogspot.de/2010/01/how-to-iimplement-custom-paint-in-50.html
protected final Color colors[];
protected final float fractions[];
protected final int capStyle;
protected final int joinStyle;
protected final int transparency;
public PathGradientPaint(Color colors[], float fractions[]) {
this(colors,fractions,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
}
public PathGradientPaint(Color colors[], float fractions[], int capStyle, int joinStyle) {
this.colors = colors;
this.fractions = fractions;
this.capStyle = capStyle;
this.joinStyle = joinStyle;
// determine transparency
boolean opaque = true;
for (int i = 0; i < colors.length; i++){
opaque = opaque && (colors[i].getAlpha() == 0xff);
}
this.transparency = opaque ? OPAQUE : TRANSLUCENT;
}
public PaintContext createContext(ColorModel cm,
Rectangle deviceBounds,
Rectangle2D userBounds,
AffineTransform transform,
RenderingHints hints) {
return new PathGradientContext(cm, deviceBounds, userBounds, transform, hints);
}
public int getTransparency() {
return transparency;
}
class PathGradientContext implements PaintContext {
protected final Rectangle deviceBounds;
protected final Rectangle2D userBounds;
protected final AffineTransform xform;
protected final RenderingHints hints;
/**
* for POI: the shape will be only known when the subclasses determines the concrete implementation
* in the draw/-content method, so we need to postpone the setting/creation as long as possible
**/
protected final Shape shape;
protected final PaintContext pCtx;
protected final int gradientSteps;
WritableRaster raster;
public PathGradientContext(
ColorModel cm
, Rectangle deviceBounds
, Rectangle2D userBounds
, AffineTransform xform
, RenderingHints hints
) {
shape = (Shape)hints.get(Drawable.GRADIENT_SHAPE);
if (shape == null) {
throw new IllegalPathStateException("PathGradientPaint needs a shape to be set via the rendering hint PathGradientPaint.GRADIANT_SHAPE.");
}
this.deviceBounds = deviceBounds;
this.userBounds = userBounds;
this.xform = xform;
this.hints = hints;
gradientSteps = getGradientSteps(shape);
Point2D start = new Point2D.Double(0, 0);
Point2D end = new Point2D.Double(gradientSteps, 0);
LinearGradientPaint gradientPaint = new LinearGradientPaint(start, end, fractions, colors, CycleMethod.NO_CYCLE, ColorSpaceType.SRGB, new AffineTransform());
Rectangle bounds = new Rectangle(0, 0, gradientSteps, 1);
pCtx = gradientPaint.createContext(cm, bounds, bounds, new AffineTransform(), hints);
}
public void dispose() {}
public ColorModel getColorModel() {
return pCtx.getColorModel();
}
public Raster getRaster(int xOffset, int yOffset, int w, int h) {
ColorModel cm = getColorModel();
if (raster == null) createRaster();
// TODO: eventually use caching here
WritableRaster childRaster = cm.createCompatibleWritableRaster(w, h);
Rectangle2D childRect = new Rectangle2D.Double(xOffset, yOffset, w, h);
if (!childRect.intersects(deviceBounds)) {
// usually doesn't happen ...
return childRaster;
}
Rectangle2D destRect = new Rectangle2D.Double();
Rectangle2D.intersect(childRect, deviceBounds, destRect);
int dx = (int)(destRect.getX()-deviceBounds.getX());
int dy = (int)(destRect.getY()-deviceBounds.getY());
int dw = (int)destRect.getWidth();
int dh = (int)destRect.getHeight();
Object data = raster.getDataElements(dx, dy, dw, dh, null);
dx = (int)(destRect.getX()-childRect.getX());
dy = (int)(destRect.getY()-childRect.getY());
childRaster.setDataElements(dx, dy, dw, dh, data);
return childRaster;
}
protected int getGradientSteps(Shape shape) {
Rectangle rect = shape.getBounds();
int lower = 1;
int upper = (int)(Math.max(rect.getWidth(),rect.getHeight())/2.0);
while (lower < upper-1) {
int mid = lower + (upper - lower) / 2;
BasicStroke bs = new BasicStroke(mid, capStyle, joinStyle);
Area area = new Area(bs.createStrokedShape(shape));
if (area.isSingular()) {
upper = mid;
} else {
lower = mid;
}
}
return upper;
}
protected void createRaster() {
ColorModel cm = getColorModel();
raster = cm.createCompatibleWritableRaster((int)deviceBounds.getWidth(), (int)deviceBounds.getHeight());
BufferedImage img = new BufferedImage(cm, raster, false, null);
Graphics2D graphics = img.createGraphics();
graphics.setRenderingHints(hints);
graphics.translate(-deviceBounds.getX(), -deviceBounds.getY());
graphics.transform(xform);
Raster img2 = pCtx.getRaster(0, 0, gradientSteps, 1);
int rgb[] = new int[cm.getNumComponents()];
for (int i = gradientSteps-1; i>=0; i--) {
img2.getPixel(i, 0, rgb);
Color c = new Color(rgb[0],rgb[1],rgb[2]);
if (rgb.length == 4) {
// it doesn't work to use just a color with transparency ...
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, rgb[3]/255.0f));
}
graphics.setStroke(new BasicStroke(i+1, capStyle, joinStyle));
graphics.setColor(c);
graphics.draw(shape);
}
graphics.dispose();
}
}
}
}

View File

@ -0,0 +1,109 @@
package org.apache.poi.sl.draw;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import org.apache.poi.sl.usermodel.PlaceableShape;
import org.apache.poi.sl.usermodel.Shape;
public class DrawShape<T extends Shape> implements Drawable {
protected final T shape;
public DrawShape(T shape) {
this.shape = shape;
}
/**
* Apply 2-D transforms before drawing this shape. This includes rotation and flipping.
*
* @param graphics the graphics whos transform matrix will be modified
*/
public void applyTransform(Graphics2D graphics) {
Rectangle2D anchor = shape.getAnchor();
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
if(tx != null) {
anchor = tx.createTransformedShape(anchor).getBounds2D();
}
// rotation
double rotation = shape.getRotation();
if (rotation != 0.) {
// PowerPoint rotates shapes relative to the geometric center
double centerX = anchor.getCenterX();
double centerY = anchor.getCenterY();
// normalize rotation
rotation = (360.+(rotation%360.))%360.;
int quadrant = (((int)rotation+45)/90)%4;
double scaleX = 1.0, scaleY = 1.0;
// scale to bounding box (bug #53176)
if (quadrant == 1 || quadrant == 3) {
// In quadrant 1 and 3, which is basically a shape in a more or less portrait orientation
// (45-135 degrees and 225-315 degrees), we need to first rotate the shape by a multiple
// of 90 degrees and then resize the bounding box to its original bbox. After that we can
// rotate the shape to the exact rotation amount.
// It's strange that you'll need to rotate the shape back and forth again, but you can
// think of it, as if you paint the shape on a canvas. First you rotate the canvas, which might
// be already (differently) scaled, so you can paint the shape in its default orientation
// and later on, turn it around again to compare it with its original size ...
AffineTransform txg = new AffineTransform(); // graphics coordinate space
AffineTransform txs = new AffineTransform(tx); // shape coordinate space
txg.translate(centerX, centerY);
txg.rotate(Math.toRadians(quadrant*90));
txg.translate(-centerX, -centerY);
txs.translate(centerX, centerY);
txs.rotate(Math.toRadians(-quadrant*90));
txs.translate(-centerX, -centerY);
txg.concatenate(txs);
Rectangle2D anchor2 = txg.createTransformedShape(shape.getAnchor()).getBounds2D();
scaleX = anchor.getWidth() == 0. ? 1.0 : anchor.getWidth() / anchor2.getWidth();
scaleY = anchor.getHeight() == 0. ? 1.0 : anchor.getHeight() / anchor2.getHeight();
}
// transformation is applied reversed ...
graphics.translate(centerX, centerY);
graphics.rotate(Math.toRadians(rotation-quadrant*90.));
graphics.scale(scaleX, scaleY);
graphics.rotate(Math.toRadians(quadrant*90));
graphics.translate(-centerX, -centerY);
}
//flip horizontal
if (shape.getFlipHorizontal()) {
graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
graphics.scale(-1, 1);
graphics.translate(-anchor.getX(), -anchor.getY());
}
//flip vertical
if (shape.getFlipVertical()) {
graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
graphics.scale(1, -1);
graphics.translate(-anchor.getX(), -anchor.getY());
}
}
public void draw(Graphics2D graphics) {
}
public void drawContent(Graphics2D context) {
}
public static Rectangle2D getAnchor(Graphics2D graphics, PlaceableShape shape) {
Rectangle2D anchor = shape.getAnchor();
if(graphics == null) {
return anchor;
}
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
if(tx != null) {
anchor = tx.createTransformedShape(anchor).getBounds2D();
}
return anchor;
}
}

View File

@ -0,0 +1,72 @@
package org.apache.poi.sl.draw;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import org.apache.poi.sl.usermodel.MasterSheet;
import org.apache.poi.sl.usermodel.Shape;
import org.apache.poi.sl.usermodel.Sheet;
public class DrawSheet implements Drawable {
protected final Sheet sheet;
public DrawSheet(Sheet sheet) {
this.sheet = sheet;
}
public void applyTransform(Graphics2D context) {
// TODO Auto-generated method stub
}
public void draw(Graphics2D graphics) {
DrawFactory drawFact = DrawFactory.getInstance(graphics);
MasterSheet master = sheet.getMasterSheet();
if(sheet.getFollowMasterGraphics() && master != null) {
Drawable drawer = drawFact.getDrawable(master);
drawer.draw(graphics);
}
graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, new AffineTransform());
for (Shape shape : sheet.getShapes()) {
if(!canDraw(shape)) continue;
// remember the initial transform and restore it after we are done with drawing
AffineTransform at = graphics.getTransform();
// concrete implementations can make sense of this hint,
// for example PSGraphics2D or PDFGraphics2D would call gsave() / grestore
graphics.setRenderingHint(Drawable.GSAVE, true);
// apply rotation and flipping
Drawable drawer = drawFact.getDrawable(shape);
drawer.applyTransform(graphics);
// draw stuff
drawer.draw(graphics);
// restore the coordinate system
graphics.setTransform(at);
graphics.setRenderingHint(Drawable.GRESTORE, true);
}
}
public void drawContent(Graphics2D context) {
// TODO Auto-generated method stub
}
/**
* Checks if this <code>sheet</code> displays the specified shape.
*
* Subclasses can override it and skip certain shapes from drawings,
* for instance, slide masters and layouts don't display placeholders
*/
protected boolean canDraw(Shape shape){
return true;
}
}

View File

@ -0,0 +1,391 @@
package org.apache.poi.sl.draw;
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.nio.charset.Charset;
import java.util.*;
import java.util.List;
import javax.xml.bind.*;
import javax.xml.stream.*;
import javax.xml.stream.EventFilter;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import org.apache.poi.sl.draw.binding.CTCustomGeometry2D;
import org.apache.poi.sl.draw.geom.*;
import org.apache.poi.sl.usermodel.*;
import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
import org.apache.poi.util.Units;
public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
public DrawSimpleShape(T shape) {
super(shape);
}
@Override
public void draw(Graphics2D graphics) {
// RenderableShape rShape = new RenderableShape(this);
// rShape.render(graphics);
DrawPaint drawPaint = DrawFactory.getInstance(graphics).getPaint(shape);
Paint fill = drawPaint.getPaint(graphics, shape.getFillStyle().getPaint());
Paint line = drawPaint.getPaint(graphics, shape.getStrokeStyle().getPaint());
BasicStroke stroke = getStroke(); // the stroke applies both to the shadow and the shape
graphics.setStroke(stroke);
Collection<Outline> elems = computeOutlines(graphics);
// first paint the shadow
drawShadow(graphics, elems, fill, line);
// then fill the shape interior
if (fill != null) {
graphics.setPaint(fill);
for (Outline o : elems) {
if (o.getPath().isFilled()){
java.awt.Shape s = o.getOutline();
graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
graphics.fill(s);
}
}
}
// then draw any content within this shape (text, image, etc.)
drawContent(graphics);
// then stroke the shape outline
if(line != null) {
graphics.setPaint(line);
for(Outline o : elems){
if(o.getPath().isStroked()){
java.awt.Shape s = o.getOutline();
graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
graphics.draw(s);
}
}
}
// draw line decorations
drawDecoration(graphics, line, stroke);
}
protected void drawDecoration(Graphics2D graphics, Paint line, BasicStroke stroke) {
if(line == null) return;
graphics.setPaint(line);
List<Outline> lst = new ArrayList<Outline>();
LineDecoration deco = shape.getLineDecoration();
Outline head = getHeadDecoration(graphics, deco, stroke);
if (head != null) lst.add(head);
Outline tail = getTailDecoration(graphics, deco, stroke);
if (tail != null) lst.add(tail);
for(Outline o : lst){
java.awt.Shape s = o.getOutline();
Path p = o.getPath();
graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
if(p.isFilled()) graphics.fill(s);
if(p.isStroked()) graphics.draw(s);
}
}
protected Outline getTailDecoration(Graphics2D graphics, LineDecoration deco, BasicStroke stroke) {
DecorationSize tailLength = deco.getTailLength();
DecorationSize tailWidth = deco.getTailWidth();
double lineWidth = Math.max(2.5, stroke.getLineWidth());
Rectangle2D anchor = getAnchor(graphics, shape);
double x2 = anchor.getX() + anchor.getWidth(),
y2 = anchor.getY() + anchor.getHeight();
double alpha = Math.atan(anchor.getHeight() / anchor.getWidth());
AffineTransform at = new AffineTransform();
java.awt.Shape shape = null;
Path p = null;
Rectangle2D bounds;
double scaleY = Math.pow(2, tailWidth.ordinal());
double scaleX = Math.pow(2, tailLength.ordinal());
switch (deco.getTailShape()) {
case OVAL:
p = new Path();
shape = new Ellipse2D.Double(0, 0, lineWidth * scaleX, lineWidth * scaleY);
bounds = shape.getBounds2D();
at.translate(x2 - bounds.getWidth() / 2, y2 - bounds.getHeight() / 2);
at.rotate(alpha, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2);
break;
case ARROW:
p = new Path();
GeneralPath arrow = new GeneralPath();
arrow.moveTo((float) (-lineWidth * 3), (float) (-lineWidth * 2));
arrow.lineTo(0, 0);
arrow.lineTo((float) (-lineWidth * 3), (float) (lineWidth * 2));
shape = arrow;
at.translate(x2, y2);
at.rotate(alpha);
break;
case TRIANGLE:
p = new Path();
scaleY = tailWidth.ordinal() + 1;
scaleX = tailLength.ordinal() + 1;
GeneralPath triangle = new GeneralPath();
triangle.moveTo((float) (-lineWidth * scaleX), (float) (-lineWidth * scaleY / 2));
triangle.lineTo(0, 0);
triangle.lineTo((float) (-lineWidth * scaleX), (float) (lineWidth * scaleY / 2));
triangle.closePath();
shape = triangle;
at.translate(x2, y2);
at.rotate(alpha);
break;
default:
break;
}
if (shape != null) {
shape = at.createTransformedShape(shape);
}
return shape == null ? null : new Outline(shape, p);
}
Outline getHeadDecoration(Graphics2D graphics, LineDecoration deco, BasicStroke stroke) {
DecorationSize headLength = deco.getHeadLength();
DecorationSize headWidth = deco.getHeadWidth();
double lineWidth = Math.max(2.5, stroke.getLineWidth());
Rectangle2D anchor = getAnchor(graphics, shape);
double x1 = anchor.getX(),
y1 = anchor.getY();
double alpha = Math.atan(anchor.getHeight() / anchor.getWidth());
AffineTransform at = new AffineTransform();
java.awt.Shape shape = null;
Path p = null;
Rectangle2D bounds;
double scaleY = 1;
double scaleX = 1;
switch (deco.getHeadShape()) {
case OVAL:
p = new Path();
shape = new Ellipse2D.Double(0, 0, lineWidth * scaleX, lineWidth * scaleY);
bounds = shape.getBounds2D();
at.translate(x1 - bounds.getWidth() / 2, y1 - bounds.getHeight() / 2);
at.rotate(alpha, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2);
break;
case STEALTH:
case ARROW:
p = new Path(false, true);
GeneralPath arrow = new GeneralPath();
arrow.moveTo((float) (lineWidth * 3 * scaleX), (float) (-lineWidth * scaleY * 2));
arrow.lineTo(0, 0);
arrow.lineTo((float) (lineWidth * 3 * scaleX), (float) (lineWidth * scaleY * 2));
shape = arrow;
at.translate(x1, y1);
at.rotate(alpha);
break;
case TRIANGLE:
p = new Path();
scaleY = headWidth.ordinal() + 1;
scaleX = headLength.ordinal() + 1;
GeneralPath triangle = new GeneralPath();
triangle.moveTo((float) (lineWidth * scaleX), (float) (-lineWidth * scaleY / 2));
triangle.lineTo(0, 0);
triangle.lineTo((float) (lineWidth * scaleX), (float) (lineWidth * scaleY / 2));
triangle.closePath();
shape = triangle;
at.translate(x1, y1);
at.rotate(alpha);
break;
default:
break;
}
if (shape != null) {
shape = at.createTransformedShape(shape);
}
return shape == null ? null : new Outline(shape, p);
}
public BasicStroke getStroke() {
StrokeStyle strokeStyle = shape.getStrokeStyle();
float lineWidth = (float) strokeStyle.getLineWidth();
if (lineWidth == 0.0f) lineWidth = 0.25f; // Both PowerPoint and OOo draw zero-length lines as 0.25pt
LineDash lineDash = strokeStyle.getLineDash();
int dashPatI[] = lineDash.pattern;
float[] dashPatF = new float[dashPatI.length];
final float dash_phase = 0;
for (int i=0; i<dashPatI.length; i++) {
dashPatF[i] = dashPatI[i]*lineWidth;
}
int lineCap;
switch (strokeStyle.getLineCap()) {
case ROUND:
lineCap = BasicStroke.CAP_ROUND;
break;
case SQUARE:
lineCap = BasicStroke.CAP_SQUARE;
break;
default:
case FLAT:
lineCap = BasicStroke.CAP_BUTT;
break;
}
int lineJoin = BasicStroke.JOIN_ROUND;
return new BasicStroke(lineWidth, lineCap, lineJoin, Math.max(1, lineWidth), dashPatF, dash_phase);
}
protected void drawShadow(
Graphics2D graphics
, Collection<Outline> outlines
, Paint fill
, Paint line
) {
Shadow shadow = shape.getShadow();
if (shadow == null || (fill == null && line == null)) return;
double shapeRotation = shape.getRotation();
if(shape.getFlipVertical()) {
shapeRotation += 180;
}
double angle = shadow.getAngle() - shapeRotation;
double dist = shadow.getDistance();
double dx = dist * Math.cos(Math.toRadians(angle));
double dy = dist * Math.sin(Math.toRadians(angle));
graphics.translate(dx, dy);
for(Outline o : outlines){
java.awt.Shape s = o.getOutline();
Path p = o.getPath();
graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
if(fill != null && p.isFilled()){
graphics.setPaint(fill);
graphics.fill(s);
} else if (line != null && p.isStroked()) {
graphics.setPaint(line);
graphics.draw(s);
}
}
graphics.translate(-dx, -dy);
}
protected static CustomGeometry getCustomGeometry(String name) {
return getCustomGeometry(name, null);
}
protected static CustomGeometry getCustomGeometry(String name, Graphics2D graphics) {
@SuppressWarnings("unchecked")
Map<String, CustomGeometry> presets = (graphics == null)
? null
: (Map<String, CustomGeometry>)graphics.getRenderingHint(Drawable.PRESET_GEOMETRY_CACHE);
if (presets == null) {
presets = new HashMap<String,CustomGeometry>();
if (graphics != null) {
graphics.setRenderingHint(Drawable.PRESET_GEOMETRY_CACHE, presets);
}
String packageName = "org.apache.poi.sl.draw.binding";
InputStream presetIS = Drawable.class.getResourceAsStream("presetShapeDefinitions.xml");
Reader xml = new InputStreamReader( presetIS, Charset.forName("UTF-8") );
// StAX:
EventFilter startElementFilter = new EventFilter() {
@Override
public boolean accept(XMLEvent event) {
return event.isStartElement();
}
};
try {
XMLInputFactory staxFactory = XMLInputFactory.newInstance();
XMLEventReader staxReader = staxFactory.createXMLEventReader(xml);
XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
// Ignore StartElement:
staxFiltRd.nextEvent();
// JAXB:
JAXBContext jaxbContext = JAXBContext.newInstance(packageName);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
while (staxFiltRd.peek() != null) {
StartElement evRoot = (StartElement)staxFiltRd.peek();
String cusName = evRoot.getName().getLocalPart();
// XMLEvent ev = staxReader.nextEvent();
JAXBElement<org.apache.poi.sl.draw.binding.CTCustomGeometry2D> el = unmarshaller.unmarshal(staxReader, CTCustomGeometry2D.class);
CTCustomGeometry2D cusGeom = el.getValue();
presets.put(cusName, new CustomGeometry(cusGeom));
}
} catch (Exception e) {
throw new RuntimeException("Unable to load preset geometries.", e);
}
}
return presets.get(name);
}
protected Collection<Outline> computeOutlines(Graphics2D graphics) {
List<Outline> lst = new ArrayList<Outline>();
CustomGeometry geom = shape.getGeometry();
if(geom == null) {
return lst;
}
Rectangle2D anchor = getAnchor(graphics, shape);
for (Path p : geom) {
double w = p.getW() == -1 ? anchor.getWidth() * Units.EMU_PER_POINT : p.getW();
double h = p.getH() == -1 ? anchor.getHeight() * Units.EMU_PER_POINT : p.getH();
// the guides in the shape definitions are all defined relative to each other,
// so we build the path starting from (0,0).
final Rectangle2D pathAnchor = new Rectangle2D.Double(0,0,w,h);
Context ctx = new Context(geom, pathAnchor, shape);
java.awt.Shape gp = p.getPath(ctx);
// translate the result to the canvas coordinates in points
AffineTransform at = new AffineTransform();
at.translate(anchor.getX(), anchor.getY());
double scaleX, scaleY;
if (p.getW() != -1) {
scaleX = anchor.getWidth() / p.getW();
} else {
scaleX = 1.0 / Units.EMU_PER_POINT;
}
if (p.getH() != -1) {
scaleY = anchor.getHeight() / p.getH();
} else {
scaleY = 1.0 / Units.EMU_PER_POINT;
}
at.scale(scaleX, scaleY);
java.awt.Shape canvasShape = at.createTransformedShape(gp);
lst.add(new Outline(canvasShape, p));
}
return lst;
}
}

View File

@ -0,0 +1,9 @@
package org.apache.poi.sl.draw;
import org.apache.poi.sl.usermodel.*;
public class DrawTextBox<T extends TextBox> extends DrawAutoShape<T> {
public DrawTextBox(T shape) {
super(shape);
}
}

View File

@ -0,0 +1,94 @@
package org.apache.poi.sl.draw;
import java.awt.Graphics2D;
import java.awt.font.TextLayout;
import java.text.*;
import org.apache.poi.xslf.usermodel.XSLFRenderingHint;
public class DrawTextFragment implements Drawable {
final TextLayout layout;
final AttributedString str;
double x, y;
public DrawTextFragment(TextLayout layout, AttributedString str) {
this.layout = layout;
this.str = str;
}
public void setPosition(double x, double y) {
// TODO: replace it, by applyTransform????
this.x = x;
this.y = y;
}
public void draw(Graphics2D graphics){
if(str == null) {
return;
}
double yBaseline = y + layout.getAscent();
Integer textMode = (Integer)graphics.getRenderingHint(XSLFRenderingHint.TEXT_RENDERING_MODE);
if(textMode != null && textMode == XSLFRenderingHint.TEXT_AS_SHAPES){
layout.draw(graphics, (float)x, (float)yBaseline);
} else {
graphics.drawString(str.getIterator(), (float)x, (float)yBaseline );
}
}
public void applyTransform(Graphics2D graphics) {
// TODO Auto-generated method stub
}
public void drawContent(Graphics2D graphics) {
// TODO Auto-generated method stub
}
public TextLayout getLayout() {
return layout;
}
public AttributedString getAttributedString() {
return str;
}
/**
* @return full height of this text run which is sum of ascent, descent and leading
*/
public float getHeight(){
double h = Math.ceil(layout.getAscent()) + Math.ceil(layout.getDescent()) + layout.getLeading();
return (float)h;
}
/**
*
* @return width if this text run
*/
public float getWidth(){
return layout.getAdvance();
}
/**
*
* @return the string to be painted
*/
public String getString(){
if (str == null) return "";
AttributedCharacterIterator it = str.getIterator();
StringBuilder buf = new StringBuilder();
for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
buf.append(c);
}
return buf.toString();
}
@Override
public String toString(){
return "[" + getClass().getSimpleName() + "] " + getString();
}
}

View File

@ -0,0 +1,381 @@
package org.apache.poi.sl.draw;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.font.*;
import java.awt.geom.Rectangle2D;
import java.text.*;
import java.text.AttributedCharacterIterator.Attribute;
import java.util.*;
import org.apache.poi.sl.usermodel.*;
import org.apache.poi.sl.usermodel.TextParagraph.BulletStyle;
import org.apache.poi.sl.usermodel.TextRun.TextCap;
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
public class DrawTextParagraph implements Drawable {
protected TextParagraph paragraph;
double x, y;
protected Insets2D insets = new Insets2D(0,0,0,0);
protected List<DrawTextFragment> lines = new ArrayList<DrawTextFragment>();
protected String rawText;
protected DrawTextFragment bullet;
/**
* the highest line in this paragraph. Used for line spacing.
*/
protected double maxLineHeight;
public DrawTextParagraph(TextParagraph paragraph) {
this.paragraph = paragraph;
}
public Insets2D getInsets() {
return insets;
}
public void setInsets(Insets2D insets) {
this.insets.set(insets.top, insets.left, insets.bottom, insets.right);
}
public void setPosition(double x, double y) {
// TODO: replace it, by applyTransform????
this.x = x;
this.y = y;
}
public double getY() {
return y;
}
public void draw(Graphics2D graphics){
if (lines.isEmpty()) return;
double leftInset = insets.left;
double rightInset = insets.right;
double penY = y;
double leftMargin = paragraph.getLeftMargin();
boolean firstLine = true;
double indent = paragraph.getIndent();
//The vertical line spacing
double spacing = paragraph.getLineSpacing();
for(DrawTextFragment line : lines){
double penX = x + leftMargin;
if(firstLine) {
if (!isEmptyParagraph()) {
bullet = getBullet(graphics, line.getAttributedString().getIterator());
}
if(bullet != null){
if (indent < 0) {
// a negative value means "Hanging" indentation and
// indicates the position of the actual bullet character.
// (the bullet is shifted to right relative to the text)
bullet.setPosition(penX + indent, penY);
} else if(indent > 0){
// a positive value means the "First Line" indentation:
// the first line is indented and other lines start at the bullet ofset
bullet.setPosition(penX, penY);
penX += indent;
} else {
// a zero indent means that the bullet and text have the same offset
bullet.setPosition(penX, penY);
// don't let text overlay the bullet and advance by the bullet width
penX += bullet.getLayout().getAdvance() + 1;
}
bullet.draw(graphics);
} else {
penX += indent;
}
}
Rectangle2D anchor = DrawShape.getAnchor(graphics, paragraph.getParentShape());
switch (paragraph.getTextAlign()) {
case CENTER:
penX += (anchor.getWidth() - leftMargin - line.getWidth() - leftInset - rightInset) / 2;
break;
case RIGHT:
penX += (anchor.getWidth() - line.getWidth() - leftInset - rightInset);
break;
default:
break;
}
line.setPosition(penX, penY);
line.draw(graphics);
if(spacing > 0) {
// If linespacing >= 0, then linespacing is a percentage of normal line height.
penY += spacing*0.01* line.getHeight();
} else {
// positive value means absolute spacing in points
penY += -spacing;
}
firstLine = false;
}
y = penY - y;
}
public float getFirstLineHeight() {
return (lines.isEmpty()) ? 0 : lines.get(0).getHeight();
}
public float getLastLineHeight() {
return (lines.isEmpty()) ? 0 : lines.get(lines.size()-1).getHeight();
}
public boolean isEmptyParagraph() {
return (lines.isEmpty() || rawText.trim().isEmpty());
}
public void applyTransform(Graphics2D graphics) {
}
public void drawContent(Graphics2D graphics) {
}
/**
* break text into lines, each representing a line of text that fits in the wrapping width
*
* @param graphics
*/
protected void breakText(Graphics2D graphics){
lines.clear();
DrawFactory fact = DrawFactory.getInstance(graphics);
StringBuilder text = new StringBuilder();
AttributedString at = getAttributedString(graphics, text);
boolean emptyParagraph = ("".equals(text.toString().trim()));
AttributedCharacterIterator it = at.getIterator();
LineBreakMeasurer measurer = new LineBreakMeasurer(it, graphics.getFontRenderContext());
for (;;) {
int startIndex = measurer.getPosition();
double wrappingWidth = getWrappingWidth(lines.size() == 0, graphics) + 1; // add a pixel to compensate rounding errors
// shape width can be smaller that the sum of insets (this was proved by a test file)
if(wrappingWidth < 0) wrappingWidth = 1;
int nextBreak = text.indexOf("\n", startIndex + 1);
if(nextBreak == -1) nextBreak = it.getEndIndex();
TextLayout layout = measurer.nextLayout((float)wrappingWidth, nextBreak, true);
if (layout == null) {
// layout can be null if the entire word at the current position
// does not fit within the wrapping width. Try with requireNextWord=false.
layout = measurer.nextLayout((float)wrappingWidth, nextBreak, false);
}
if(layout == null) {
// exit if can't break any more
break;
}
int endIndex = measurer.getPosition();
// skip over new line breaks (we paint 'clear' text runs not starting or ending with \n)
if(endIndex < it.getEndIndex() && text.charAt(endIndex) == '\n'){
measurer.setPosition(endIndex + 1);
}
TextAlign hAlign = paragraph.getTextAlign();
if(hAlign == TextAlign.JUSTIFY || hAlign == TextAlign.JUSTIFY_LOW) {
layout = layout.getJustifiedLayout((float)wrappingWidth);
}
AttributedString str = (emptyParagraph)
? null // we will not paint empty paragraphs
: new AttributedString(it, startIndex, endIndex);
DrawTextFragment line = fact.getTextFragment(layout, str);
lines.add(line);
maxLineHeight = Math.max(maxLineHeight, line.getHeight());
if(endIndex == it.getEndIndex()) break;
}
rawText = text.toString();
}
protected DrawTextFragment getBullet(Graphics2D graphics, AttributedCharacterIterator firstLineAttr) {
BulletStyle bulletStyle = paragraph.getBulletStyle();
if (bulletStyle == null) return null;
String buCharacter = bulletStyle.getBulletCharacter();
if (buCharacter == null) return null;
String buFont = bulletStyle.getBulletFont();
if (buFont == null) buFont = paragraph.getDefaultFontFamily();
assert(buFont != null);
Color buColor = bulletStyle.getBulletFontColor();
if (buColor == null) buColor = (Color)firstLineAttr.getAttribute(TextAttribute.FOREGROUND);
float fontSize = (Float)firstLineAttr.getAttribute(TextAttribute.SIZE);
float buSz = (float)bulletStyle.getBulletFontSize();
if(buSz > 0) fontSize *= buSz* 0.01;
else fontSize = -buSz;
AttributedString str = new AttributedString(buCharacter);
str.addAttribute(TextAttribute.FOREGROUND, buColor);
str.addAttribute(TextAttribute.FAMILY, buFont);
str.addAttribute(TextAttribute.SIZE, fontSize);
TextLayout layout = new TextLayout(str.getIterator(), graphics.getFontRenderContext());
DrawFactory fact = DrawFactory.getInstance(graphics);
return fact.getTextFragment(layout, str);
}
protected String getRenderableText(TextRun tr) {
StringBuilder buf = new StringBuilder();
TextCap cap = tr.getTextCap();
for (char c : tr.getText().toCharArray()) {
if(c == '\t') {
// TODO: finish support for tabs
buf.append(" ");
continue;
}
switch (cap) {
case ALL: c = Character.toUpperCase(c); break;
case SMALL: c = Character.toLowerCase(c); break;
case NONE: break;
}
buf.append(c);
}
return buf.toString();
}
/**
* Returns wrapping width to break lines in this paragraph
*
* @param firstLine whether the first line is breaking
*
* @return wrapping width in points
*/
protected double getWrappingWidth(boolean firstLine, Graphics2D graphics){
// internal margins for the text box
double leftInset = insets.left;
double rightInset = insets.right;
Rectangle2D anchor = DrawShape.getAnchor(graphics, paragraph.getParentShape());
double leftMargin = paragraph.getLeftMargin();
double indent = paragraph.getIndent();
double width;
TextShape ts = paragraph.getParentShape();
if (!ts.getWordWrap()) {
// if wordWrap == false then we return the advance to the right border of the sheet
width = ts.getSheet().getSlideShow().getPageSize().getWidth() - anchor.getX();
} else {
width = anchor.getWidth() - leftInset - rightInset - leftMargin;
if (firstLine) {
if (bullet != null){
if (indent > 0) width -= indent;
} else {
if (indent > 0) width -= indent; // first line indentation
else if (indent < 0) { // hanging indentation: the first line start at the left margin
width += leftMargin;
}
}
}
}
return width;
}
private static class AttributedStringData {
Attribute attribute;
Object value;
int beginIndex, endIndex;
AttributedStringData(Attribute attribute, Object value, int beginIndex, int endIndex) {
this.attribute = attribute;
this.value = value;
this.beginIndex = beginIndex;
this.endIndex = endIndex;
}
}
protected AttributedString getAttributedString(Graphics2D graphics, StringBuilder text){
List<AttributedStringData> attList = new ArrayList<AttributedStringData>();
if (text == null) text = new StringBuilder();
DrawFontManager fontHandler = (DrawFontManager)graphics.getRenderingHint(Drawable.FONT_HANDLER);
for (TextRun run : paragraph){
String runText = getRenderableText(run);
// skip empty runs
if (runText.isEmpty()) continue;
int beginIndex = text.length();
text.append(runText);
int endIndex = text.length();
attList.add(new AttributedStringData(TextAttribute.FOREGROUND, run.getFontColor(), beginIndex, endIndex));
// user can pass an custom object to convert fonts
String fontFamily = run.getFontFamily();
@SuppressWarnings("unchecked")
Map<String,String> fontMap = (Map<String,String>)graphics.getRenderingHint(Drawable.FONT_MAP);
if (fontMap != null && fontMap.containsKey(fontFamily)) {
fontFamily = fontMap.get(fontFamily);
}
if(fontHandler != null) {
fontFamily = fontHandler.getRendererableFont(fontFamily, run.getPitchAndFamily());
}
attList.add(new AttributedStringData(TextAttribute.FAMILY, fontFamily, beginIndex, endIndex));
float fontSz = (float)run.getFontSize();
attList.add(new AttributedStringData(TextAttribute.SIZE, fontSz, beginIndex, endIndex));
if(run.isBold()) {
attList.add(new AttributedStringData(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, beginIndex, endIndex));
}
if(run.isItalic()) {
attList.add(new AttributedStringData(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, beginIndex, endIndex));
}
if(run.isUnderline()) {
attList.add(new AttributedStringData(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, beginIndex, endIndex));
attList.add(new AttributedStringData(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_TWO_PIXEL, beginIndex, endIndex));
}
if(run.isStrikethrough()) {
attList.add(new AttributedStringData(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, beginIndex, endIndex));
}
if(run.isSubscript()) {
attList.add(new AttributedStringData(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB, beginIndex, endIndex));
}
if(run.isSuperscript()) {
attList.add(new AttributedStringData(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, beginIndex, endIndex));
}
}
// ensure that the paragraph contains at least one character
// We need this trick to correctly measure text
if (text.length() == 0) {
float fontSz = (float)paragraph.getDefaultFontSize();
text.append(" ");
attList.add(new AttributedStringData(TextAttribute.SIZE, fontSz, 0, 1));
}
AttributedString string = new AttributedString(text.toString());
for (AttributedStringData asd : attList) {
string.addAttribute(asd.attribute, asd.value, asd.beginIndex, asd.endIndex);
}
return string;
}
}

View File

@ -0,0 +1,140 @@
package org.apache.poi.sl.draw;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.Iterator;
import org.apache.poi.sl.usermodel.*;
public class DrawTextShape<T extends TextShape> extends DrawSimpleShape<T> {
public DrawTextShape(T shape) {
super(shape);
}
@Override
public void drawContent(Graphics2D graphics) {
Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);
Insets2D insets = shape.getInsets();
double x = anchor.getX() + insets.left;
double y = anchor.getY();
// remember the initial transform
AffineTransform tx = graphics.getTransform();
// Transform of text in flipped shapes is special.
// At this point the flip and rotation transform is already applied
// (see XSLFShape#applyTransform ), but we need to restore it to avoid painting "upside down".
// See Bugzilla 54210.
if(shape.getFlipVertical()){
graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
graphics.scale(1, -1);
graphics.translate(-anchor.getX(), -anchor.getY());
// text in vertically flipped shapes is rotated by 180 degrees
double centerX = anchor.getX() + anchor.getWidth()/2;
double centerY = anchor.getY() + anchor.getHeight()/2;
graphics.translate(centerX, centerY);
graphics.rotate(Math.toRadians(180));
graphics.translate(-centerX, -centerY);
}
// Horizontal flipping applies only to shape outline and not to the text in the shape.
// Applying flip second time restores the original not-flipped transform
if(shape.getFlipHorizontal()){
graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
graphics.scale(-1, 1);
graphics.translate(-anchor.getX() , -anchor.getY());
}
// first dry-run to calculate the total height of the text
double textHeight = shape.getTextHeight();
switch (shape.getVerticalAlignment()){
case TOP:
y += insets.top;
break;
case BOTTOM:
y += anchor.getHeight() - textHeight - insets.bottom;
break;
default:
case MIDDLE:
double delta = anchor.getHeight() - textHeight - insets.top - insets.bottom;
y += insets.top + delta/2;
break;
}
drawParagraphs(graphics, x, y);
// restore the transform
graphics.setTransform(tx);
}
/**
* paint the paragraphs starting from top left (x,y)
*
* @return the vertical advance, i.e. the cumulative space occupied by the text
*/
public double drawParagraphs(Graphics2D graphics, double x, double y) {
DrawFactory fact = DrawFactory.getInstance(graphics);
Insets2D shapePadding = shape.getInsets();
double y0 = y;
Iterator<TextParagraph> paragraphs = shape.iterator();
boolean isFirstLine = true;
while (paragraphs.hasNext()){
TextParagraph p = paragraphs.next();
DrawTextParagraph dp = fact.getDrawable(p);
dp.setInsets(shapePadding);
dp.breakText(graphics);
if (!isFirstLine) {
// the amount of vertical white space before the paragraph
double spaceBefore = p.getSpaceBefore();
if(spaceBefore > 0) {
// positive value means percentage spacing of the height of the first line, e.g.
// the higher the first line, the bigger the space before the paragraph
y += spaceBefore*0.01*dp.getFirstLineHeight();
} else {
// negative value means the absolute spacing in points
y += -spaceBefore;
}
isFirstLine = false;
}
dp.setPosition(x, y);
dp.draw(graphics);
y += dp.getY();
if (paragraphs.hasNext()) {
double spaceAfter = p.getSpaceAfter();
if(spaceAfter > 0) {
// positive value means percentage spacing of the height of the last line, e.g.
// the higher the last line, the bigger the space after the paragraph
y += spaceAfter*0.01*dp.getLastLineHeight();
} else {
// negative value means the absolute spacing in points
y += -spaceAfter;
}
}
}
return y - y0;
}
/**
* Compute the cumulative height occupied by the text
*/
protected double getTextHeight(){
// dry-run in a 1x1 image and return the vertical advance
BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
return drawParagraphs(graphics, 0, 0);
}
}

View File

@ -0,0 +1,123 @@
/* ====================================================================
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;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import org.apache.poi.util.Internal;
public interface Drawable {
class DrawableHint extends RenderingHints.Key {
protected DrawableHint(int id) {
super(id);
}
public boolean isCompatibleValue(Object val) {
return true;
}
}
/**
* {@link DrawFactory} which will be used to draw objects into this graphics context
*/
DrawableHint DRAW_FACTORY = new DrawableHint(1);
/**
* Key will be internally used to store affine transformation temporarily within group shapes
*/
@Internal
DrawableHint GROUP_TRANSFORM = new DrawableHint(2);
/**
* Use a custom image renderer of an instance of {@link ImageRenderer}
*/
DrawableHint IMAGE_RENDERER = new DrawableHint(3);
/**
* how to render text:
*
* {@link #TEXT_AS_CHARACTERS} (default) means to draw via
* {@link java.awt.Graphics2D#drawString(java.text.AttributedCharacterIterator, float, float)}.
* This mode draws text as characters. Use it if the target graphics writes the actual
* character codes instead of glyph outlines (PDFGraphics2D, SVGGraphics2D, etc.)
*
* {@link #TEXT_AS_SHAPES} means to render via
* {@link java.awt.font.TextLayout#draw(java.awt.Graphics2D, float, float)}.
* This mode draws glyphs as shapes and provides some advanced capabilities such as
* justification and font substitution. Use it if the target graphics is an image.
*
*/
DrawableHint TEXT_RENDERING_MODE = new DrawableHint(4);
/**
* PathGradientPaint needs the shape to be set.
* It will be achieved through setting it in the rendering hints
*/
DrawableHint GRADIENT_SHAPE = new DrawableHint(5);
/**
* Internal key for caching the preset geometries
*/
DrawableHint PRESET_GEOMETRY_CACHE = new DrawableHint(6);
/**
* draw text via {@link java.awt.Graphics2D#drawString(java.text.AttributedCharacterIterator, float, float)}
*/
int TEXT_AS_CHARACTERS = 1;
/**
* draw text via {@link java.awt.font.TextLayout#draw(java.awt.Graphics2D, float, float)}
*/
int TEXT_AS_SHAPES = 2;
/**
* Use this object to resolve unknown / missing fonts when rendering slides
*/
DrawableHint FONT_HANDLER = new DrawableHint(7);
DrawableHint FONT_FALLBACK = new DrawableHint(8);
DrawableHint FONT_MAP = new DrawableHint(9);
DrawableHint GSAVE = new DrawableHint(10);
DrawableHint GRESTORE = new DrawableHint(11);
/**
* Apply 2-D transforms before drawing this shape. This includes rotation and flipping.
*
* @param graphics the graphics whos transform matrix will be modified
*/
void applyTransform(Graphics2D graphics);
/**
* Draw this shape into the supplied canvas
*
* @param graphics the graphics to draw into
*/
void draw(Graphics2D graphics);
/**
* draw any content within this shape (image, text, etc.).
*
* @param graphics the graphics to draw into
*/
void drawContent(Graphics2D graphics);
}

View File

@ -0,0 +1,155 @@
/*
* ====================================================================
* 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;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.RescaleOp;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
/**
* For now this class renders only images supported by the javax.imageio.ImageIO
* framework. Subclasses can override this class to support other formats, for
* example, Use Apache batik to render WMF:
*
* <pre>
* <code>
* public class MyImageRendener extends ImageRendener {
*
* public boolean drawImage(Graphics2D graphics,Rectangle2D anchor,Insets clip) {
* // draw image
* }
*
* public void loadImage(InputStream data, String contentType) throws IOException {
* if ("image/wmf".equals(contentType)) {
* // use Apache Batik to handle WMF
* } else {
* super.loadImage(data,contentType);
* }
* }
* }
* </code>
* </pre>
*
* and then pass this class to your instance of java.awt.Graphics2D:
*
* <pre>
* <code>
* graphics.setRenderingHint(Drawable.IMAGE_RENDERER, new MyImageRendener());
* </code>
* </pre>
*/
public class ImageRenderer {
protected BufferedImage img;
/**
* Load and buffer the image
*
* @param data the raw image stream
* @param contentType the content type
*/
public void loadImage(InputStream data, String contentType) throws IOException {
img = ImageIO.read(data);
}
/**
* @return the buffered image
*/
public BufferedImage getImage() {
return img;
}
/**
* @return the dimension of the buffered image
*/
public Dimension getDimension() {
return (img == null)
? new Dimension(0,0)
: new Dimension(img.getWidth(),img.getHeight());
}
/**
* @param alpha the alpha [0..1] to be added to the image (possibly already containing an alpha channel)
*/
public void setAlpha(double alpha) {
if (img == null) return;
Dimension dim = getDimension();
BufferedImage newImg = new BufferedImage((int)dim.getWidth(), (int)dim.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g = newImg.createGraphics();
RescaleOp op = new RescaleOp(new float[]{1.0f, 1.0f, 1.0f, (float)alpha}, new float[]{0,0,0,0}, null);
g.drawImage(img, op, 0, 0);
g.dispose();
img = newImg;
}
/**
* Render picture data into the supplied graphics
*
* @return true if the picture data was successfully rendered
*/
public boolean drawImage(
Graphics2D graphics,
Rectangle2D anchor) {
return drawImage(graphics, anchor, null);
}
/**
* Render picture data into the supplied graphics
*
* @return true if the picture data was successfully rendered
*/
public boolean drawImage(
Graphics2D graphics,
Rectangle2D anchor,
Insets clip) {
if (img == null) return false;
boolean isClipped = true;
if (clip == null) {
isClipped = false;
clip = new Insets(0,0,0,0);
}
int iw = img.getWidth();
int ih = img.getHeight();
double cw = (100000-clip.left-clip.right) / 100000.0;
double ch = (100000-clip.top-clip.bottom) / 100000.0;
double sx = anchor.getWidth()/(iw*cw);
double sy = anchor.getHeight()/(ih*ch);
double tx = anchor.getX()-(iw*sx*clip.left/100000.0);
double ty = anchor.getY()-(ih*sy*clip.top/100000.0);
AffineTransform at = new AffineTransform(sx, 0, 0, sy, tx, ty) ;
Shape clipOld = graphics.getClip();
if (isClipped) graphics.clip(anchor.getBounds2D());
graphics.drawRenderedImage(img, at);
graphics.setClip(clipOld);
return true;
}
}

View File

@ -0,0 +1,126 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_AdjPoint2D complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_AdjPoint2D">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;attribute name="x" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
* &lt;attribute name="y" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_AdjPoint2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
public class CTAdjPoint2D
implements Locatable
{
@XmlAttribute(name = "x", required = true)
protected String x;
@XmlAttribute(name = "y", required = true)
protected String y;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the x property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getX() {
return x;
}
/**
* Sets the value of the x property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setX(String value) {
this.x = value;
}
public boolean isSetX() {
return (this.x!= null);
}
/**
* Gets the value of the y property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getY() {
return y;
}
/**
* Sets the value of the y property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setY(String value) {
this.y = value;
}
public boolean isSetY() {
return (this.y!= null);
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,116 @@
/* ====================================================================
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.binding;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_AdjustHandleList complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_AdjustHandleList">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;choice maxOccurs="unbounded" minOccurs="0">
* &lt;element name="ahXY" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_XYAdjustHandle"/>
* &lt;element name="ahPolar" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_PolarAdjustHandle"/>
* &lt;/choice>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_AdjustHandleList", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
"ahXYOrAhPolar"
})
public class CTAdjustHandleList
implements Locatable
{
@XmlElements({
@XmlElement(name = "ahXY", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTXYAdjustHandle.class),
@XmlElement(name = "ahPolar", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTPolarAdjustHandle.class)
})
protected List<Object> ahXYOrAhPolar;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the ahXYOrAhPolar property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the ahXYOrAhPolar property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getAhXYOrAhPolar().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link CTXYAdjustHandle }
* {@link CTPolarAdjustHandle }
*
*
*/
public List<Object> getAhXYOrAhPolar() {
if (ahXYOrAhPolar == null) {
ahXYOrAhPolar = new ArrayList<Object>();
}
return this.ahXYOrAhPolar;
}
public boolean isSetAhXYOrAhPolar() {
return ((this.ahXYOrAhPolar!= null)&&(!this.ahXYOrAhPolar.isEmpty()));
}
public void unsetAhXYOrAhPolar() {
this.ahXYOrAhPolar = null;
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,86 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_Angle complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_Angle">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;attribute name="val" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Angle" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_Angle", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
public class CTAngle implements Locatable
{
@XmlAttribute(name = "val", required = true)
protected int val;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the val property.
*
*/
public int getVal() {
return val;
}
/**
* Sets the value of the val property.
*
*/
public void setVal(int value) {
this.val = value;
}
public boolean isSetVal() {
return true;
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,254 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_Color complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_Color">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_ColorChoice"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_Color", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
"scrgbClr",
"srgbClr",
"hslClr",
"sysClr",
"schemeClr",
"prstClr"
})
public class CTColor
implements Locatable
{
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTScRgbColor scrgbClr;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTSRgbColor srgbClr;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTHslColor hslClr;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTSystemColor sysClr;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTSchemeColor schemeClr;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTPresetColor prstClr;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the scrgbClr property.
*
* @return
* possible object is
* {@link CTScRgbColor }
*
*/
public CTScRgbColor getScrgbClr() {
return scrgbClr;
}
/**
* Sets the value of the scrgbClr property.
*
* @param value
* allowed object is
* {@link CTScRgbColor }
*
*/
public void setScrgbClr(CTScRgbColor value) {
this.scrgbClr = value;
}
public boolean isSetScrgbClr() {
return (this.scrgbClr!= null);
}
/**
* Gets the value of the srgbClr property.
*
* @return
* possible object is
* {@link CTSRgbColor }
*
*/
public CTSRgbColor getSrgbClr() {
return srgbClr;
}
/**
* Sets the value of the srgbClr property.
*
* @param value
* allowed object is
* {@link CTSRgbColor }
*
*/
public void setSrgbClr(CTSRgbColor value) {
this.srgbClr = value;
}
public boolean isSetSrgbClr() {
return (this.srgbClr!= null);
}
/**
* Gets the value of the hslClr property.
*
* @return
* possible object is
* {@link CTHslColor }
*
*/
public CTHslColor getHslClr() {
return hslClr;
}
/**
* Sets the value of the hslClr property.
*
* @param value
* allowed object is
* {@link CTHslColor }
*
*/
public void setHslClr(CTHslColor value) {
this.hslClr = value;
}
public boolean isSetHslClr() {
return (this.hslClr!= null);
}
/**
* Gets the value of the sysClr property.
*
* @return
* possible object is
* {@link CTSystemColor }
*
*/
public CTSystemColor getSysClr() {
return sysClr;
}
/**
* Sets the value of the sysClr property.
*
* @param value
* allowed object is
* {@link CTSystemColor }
*
*/
public void setSysClr(CTSystemColor value) {
this.sysClr = value;
}
public boolean isSetSysClr() {
return (this.sysClr!= null);
}
/**
* Gets the value of the schemeClr property.
*
* @return
* possible object is
* {@link CTSchemeColor }
*
*/
public CTSchemeColor getSchemeClr() {
return schemeClr;
}
/**
* Sets the value of the schemeClr property.
*
* @param value
* allowed object is
* {@link CTSchemeColor }
*
*/
public void setSchemeClr(CTSchemeColor value) {
this.schemeClr = value;
}
public boolean isSetSchemeClr() {
return (this.schemeClr!= null);
}
/**
* Gets the value of the prstClr property.
*
* @return
* possible object is
* {@link CTPresetColor }
*
*/
public CTPresetColor getPrstClr() {
return prstClr;
}
/**
* Sets the value of the prstClr property.
*
* @param value
* allowed object is
* {@link CTPresetColor }
*
*/
public void setPrstClr(CTPresetColor value) {
this.prstClr = value;
}
public boolean isSetPrstClr() {
return (this.prstClr!= null);
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,123 @@
/* ====================================================================
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.binding;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_ColorMRU complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_ColorMRU">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_ColorChoice" maxOccurs="10" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_ColorMRU", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
"egColorChoice"
})
public class CTColorMRU
implements Locatable
{
@XmlElements({
@XmlElement(name = "scrgbClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTScRgbColor.class),
@XmlElement(name = "srgbClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTSRgbColor.class),
@XmlElement(name = "hslClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTHslColor.class),
@XmlElement(name = "sysClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTSystemColor.class),
@XmlElement(name = "schemeClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTSchemeColor.class),
@XmlElement(name = "prstClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTPresetColor.class)
})
protected List<Object> egColorChoice;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the egColorChoice property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the egColorChoice property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getEGColorChoice().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link CTScRgbColor }
* {@link CTSRgbColor }
* {@link CTHslColor }
* {@link CTSystemColor }
* {@link CTSchemeColor }
* {@link CTPresetColor }
*
*
*/
public List<Object> getEGColorChoice() {
if (egColorChoice == null) {
egColorChoice = new ArrayList<Object>();
}
return this.egColorChoice;
}
public boolean isSetEGColorChoice() {
return ((this.egColorChoice!= null)&&(!this.egColorChoice.isEmpty()));
}
public void unsetEGColorChoice() {
this.egColorChoice = null;
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,62 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_ComplementTransform complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_ComplementTransform">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_ComplementTransform", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
public class CTComplementTransform implements Locatable
{
@XmlLocation
@XmlTransient
protected Locator locator;
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,112 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_Connection complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_Connection">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;attribute name="id" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_DrawingElementId" />
* &lt;attribute name="idx" use="required" type="{http://www.w3.org/2001/XMLSchema}unsignedInt" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_Connection", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
public class CTConnection
implements Locatable
{
@XmlAttribute(name = "id", required = true)
protected long id;
@XmlAttribute(name = "idx", required = true)
@XmlSchemaType(name = "unsignedInt")
protected long idx;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the id property.
*
*/
public long getId() {
return id;
}
/**
* Sets the value of the id property.
*
*/
public void setId(long value) {
this.id = value;
}
public boolean isSetId() {
return true;
}
/**
* Gets the value of the idx property.
*
*/
public long getIdx() {
return idx;
}
/**
* Sets the value of the idx property.
*
*/
public void setIdx(long value) {
this.idx = value;
}
public boolean isSetIdx() {
return true;
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,131 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_ConnectionSite complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_ConnectionSite">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="pos" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D"/>
* &lt;/sequence>
* &lt;attribute name="ang" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjAngle" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_ConnectionSite", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
"pos"
})
public class CTConnectionSite
implements Locatable
{
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
protected CTAdjPoint2D pos;
@XmlAttribute(name = "ang", required = true)
protected String ang;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the pos property.
*
* @return
* possible object is
* {@link CTAdjPoint2D }
*
*/
public CTAdjPoint2D getPos() {
return pos;
}
/**
* Sets the value of the pos property.
*
* @param value
* allowed object is
* {@link CTAdjPoint2D }
*
*/
public void setPos(CTAdjPoint2D value) {
this.pos = value;
}
public boolean isSetPos() {
return (this.pos!= null);
}
/**
* Gets the value of the ang property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getAng() {
return ang;
}
/**
* Sets the value of the ang property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setAng(String value) {
this.ang = value;
}
public boolean isSetAng() {
return (this.ang!= null);
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,110 @@
/* ====================================================================
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.binding;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_ConnectionSiteList complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_ConnectionSiteList">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="cxn" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_ConnectionSite" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_ConnectionSiteList", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
"cxn"
})
public class CTConnectionSiteList
implements Locatable
{
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected List<CTConnectionSite> cxn;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the cxn property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the cxn property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getCxn().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link CTConnectionSite }
*
*
*/
public List<CTConnectionSite> getCxn() {
if (cxn == null) {
cxn = new ArrayList<CTConnectionSite>();
}
return this.cxn;
}
public boolean isSetCxn() {
return ((this.cxn!= null)&&(!this.cxn.isEmpty()));
}
public void unsetCxn() {
this.cxn = null;
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,259 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_CustomGeometry2D complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_CustomGeometry2D">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="avLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_GeomGuideList" minOccurs="0"/>
* &lt;element name="gdLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_GeomGuideList" minOccurs="0"/>
* &lt;element name="ahLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjustHandleList" minOccurs="0"/>
* &lt;element name="cxnLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_ConnectionSiteList" minOccurs="0"/>
* &lt;element name="rect" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_GeomRect" minOccurs="0"/>
* &lt;element name="pathLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DList"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_CustomGeometry2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
"avLst",
"gdLst",
"ahLst",
"cxnLst",
"rect",
"pathLst"
})
public class CTCustomGeometry2D
implements Locatable
{
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTGeomGuideList avLst;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTGeomGuideList gdLst;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTAdjustHandleList ahLst;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTConnectionSiteList cxnLst;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTGeomRect rect;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
protected CTPath2DList pathLst;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the avLst property.
*
* @return
* possible object is
* {@link CTGeomGuideList }
*
*/
public CTGeomGuideList getAvLst() {
return avLst;
}
/**
* Sets the value of the avLst property.
*
* @param value
* allowed object is
* {@link CTGeomGuideList }
*
*/
public void setAvLst(CTGeomGuideList value) {
this.avLst = value;
}
public boolean isSetAvLst() {
return (this.avLst!= null);
}
/**
* Gets the value of the gdLst property.
*
* @return
* possible object is
* {@link CTGeomGuideList }
*
*/
public CTGeomGuideList getGdLst() {
return gdLst;
}
/**
* Sets the value of the gdLst property.
*
* @param value
* allowed object is
* {@link CTGeomGuideList }
*
*/
public void setGdLst(CTGeomGuideList value) {
this.gdLst = value;
}
public boolean isSetGdLst() {
return (this.gdLst!= null);
}
/**
* Gets the value of the ahLst property.
*
* @return
* possible object is
* {@link CTAdjustHandleList }
*
*/
public CTAdjustHandleList getAhLst() {
return ahLst;
}
/**
* Sets the value of the ahLst property.
*
* @param value
* allowed object is
* {@link CTAdjustHandleList }
*
*/
public void setAhLst(CTAdjustHandleList value) {
this.ahLst = value;
}
public boolean isSetAhLst() {
return (this.ahLst!= null);
}
/**
* Gets the value of the cxnLst property.
*
* @return
* possible object is
* {@link CTConnectionSiteList }
*
*/
public CTConnectionSiteList getCxnLst() {
return cxnLst;
}
/**
* Sets the value of the cxnLst property.
*
* @param value
* allowed object is
* {@link CTConnectionSiteList }
*
*/
public void setCxnLst(CTConnectionSiteList value) {
this.cxnLst = value;
}
public boolean isSetCxnLst() {
return (this.cxnLst!= null);
}
/**
* Gets the value of the rect property.
*
* @return
* possible object is
* {@link CTGeomRect }
*
*/
public CTGeomRect getRect() {
return rect;
}
/**
* Sets the value of the rect property.
*
* @param value
* allowed object is
* {@link CTGeomRect }
*
*/
public void setRect(CTGeomRect value) {
this.rect = value;
}
public boolean isSetRect() {
return (this.rect!= null);
}
/**
* Gets the value of the pathLst property.
*
* @return
* possible object is
* {@link CTPath2DList }
*
*/
public CTPath2DList getPathLst() {
return pathLst;
}
/**
* Sets the value of the pathLst property.
*
* @param value
* allowed object is
* {@link CTPath2DList }
*
*/
public void setPathLst(CTPath2DList value) {
this.pathLst = value;
}
public boolean isSetPathLst() {
return (this.pathLst!= null);
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,169 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_EmbeddedWAVAudioFile complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_EmbeddedWAVAudioFile">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;attribute ref="{http://schemas.openxmlformats.org/officeDocument/2006/relationships}embed use="required""/>
* &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" default="" />
* &lt;attribute name="builtIn" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_EmbeddedWAVAudioFile", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
public class CTEmbeddedWAVAudioFile
implements Locatable
{
@XmlAttribute(name = "embed", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", required = true)
protected String embed;
@XmlAttribute(name = "name")
protected String name;
@XmlAttribute(name = "builtIn")
protected Boolean builtIn;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Embedded Audio File Relationship ID
*
* @return
* possible object is
* {@link String }
*
*/
public String getEmbed() {
return embed;
}
/**
* Sets the value of the embed property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setEmbed(String value) {
this.embed = value;
}
public boolean isSetEmbed() {
return (this.embed!= null);
}
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
if (name == null) {
return "";
} else {
return name;
}
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
public boolean isSetName() {
return (this.name!= null);
}
/**
* Gets the value of the builtIn property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public boolean isBuiltIn() {
if (builtIn == null) {
return false;
} else {
return builtIn;
}
}
/**
* Sets the value of the builtIn property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setBuiltIn(boolean value) {
this.builtIn = value;
}
public boolean isSetBuiltIn() {
return (this.builtIn!= null);
}
public void unsetBuiltIn() {
this.builtIn = null;
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,86 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_FixedPercentage complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_FixedPercentage">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;attribute name="val" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_FixedPercentage" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_FixedPercentage", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
public class CTFixedPercentage implements Locatable
{
@XmlAttribute(name = "val", required = true)
protected int val;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the val property.
*
*/
public int getVal() {
return val;
}
/**
* Sets the value of the val property.
*
*/
public void setVal(int value) {
this.val = value;
}
public boolean isSetVal() {
return true;
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,62 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_GammaTransform complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_GammaTransform">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_GammaTransform", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
public class CTGammaTransform implements Locatable
{
@XmlLocation
@XmlTransient
protected Locator locator;
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,129 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_GeomGuide complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_GeomGuide">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;attribute name="name" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideName" />
* &lt;attribute name="fmla" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideFormula" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_GeomGuide", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
public class CTGeomGuide
implements Locatable
{
@XmlAttribute(name = "name", required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String name;
@XmlAttribute(name = "fmla", required = true)
protected String fmla;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
public boolean isSetName() {
return (this.name!= null);
}
/**
* Gets the value of the fmla property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getFmla() {
return fmla;
}
/**
* Sets the value of the fmla property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setFmla(String value) {
this.fmla = value;
}
public boolean isSetFmla() {
return (this.fmla!= null);
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,110 @@
/* ====================================================================
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.binding;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_GeomGuideList complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_GeomGuideList">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="gd" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_GeomGuide" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_GeomGuideList", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
"gd"
})
public class CTGeomGuideList
implements Locatable
{
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected List<CTGeomGuide> gd;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the gd property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the gd property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getGd().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link CTGeomGuide }
*
*
*/
public List<CTGeomGuide> getGd() {
if (gd == null) {
gd = new ArrayList<CTGeomGuide>();
}
return this.gd;
}
public boolean isSetGd() {
return ((this.gd!= null)&&(!this.gd.isEmpty()));
}
public void unsetGd() {
this.gd = null;
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,188 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_GeomRect complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_GeomRect">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;attribute name="l" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
* &lt;attribute name="t" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
* &lt;attribute name="r" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
* &lt;attribute name="b" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_GeomRect", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
public class CTGeomRect
implements Locatable
{
@XmlAttribute(name = "l", required = true)
protected String l;
@XmlAttribute(name = "t", required = true)
protected String t;
@XmlAttribute(name = "r", required = true)
protected String r;
@XmlAttribute(name = "b", required = true)
protected String b;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the l property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getL() {
return l;
}
/**
* Sets the value of the l property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setL(String value) {
this.l = value;
}
public boolean isSetL() {
return (this.l!= null);
}
/**
* Gets the value of the t property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getT() {
return t;
}
/**
* Sets the value of the t property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setT(String value) {
this.t = value;
}
public boolean isSetT() {
return (this.t!= null);
}
/**
* Gets the value of the r property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getR() {
return r;
}
/**
* Sets the value of the r property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setR(String value) {
this.r = value;
}
public boolean isSetR() {
return (this.r!= null);
}
/**
* Gets the value of the b property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getB() {
return b;
}
/**
* Sets the value of the b property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setB(String value) {
this.b = value;
}
public boolean isSetB() {
return (this.b!= null);
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,62 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_GrayscaleTransform complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_GrayscaleTransform">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_GrayscaleTransform", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
public class CTGrayscaleTransform implements Locatable
{
@XmlLocation
@XmlTransient
protected Locator locator;
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,313 @@
/* ====================================================================
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.binding;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_GroupTransform2D complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_GroupTransform2D">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="off" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Point2D" minOccurs="0"/>
* &lt;element name="ext" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_PositiveSize2D" minOccurs="0"/>
* &lt;element name="chOff" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Point2D" minOccurs="0"/>
* &lt;element name="chExt" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_PositiveSize2D" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="rot" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Angle" default="0" />
* &lt;attribute name="flipH" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
* &lt;attribute name="flipV" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_GroupTransform2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
"off",
"ext",
"chOff",
"chExt"
})
public class CTGroupTransform2D
implements Locatable
{
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTPoint2D off;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTPositiveSize2D ext;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTPoint2D chOff;
@XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
protected CTPositiveSize2D chExt;
@XmlAttribute(name = "rot")
protected Integer rot;
@XmlAttribute(name = "flipH")
protected Boolean flipH;
@XmlAttribute(name = "flipV")
protected Boolean flipV;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the off property.
*
* @return
* possible object is
* {@link CTPoint2D }
*
*/
public CTPoint2D getOff() {
return off;
}
/**
* Sets the value of the off property.
*
* @param value
* allowed object is
* {@link CTPoint2D }
*
*/
public void setOff(CTPoint2D value) {
this.off = value;
}
public boolean isSetOff() {
return (this.off!= null);
}
/**
* Gets the value of the ext property.
*
* @return
* possible object is
* {@link CTPositiveSize2D }
*
*/
public CTPositiveSize2D getExt() {
return ext;
}
/**
* Sets the value of the ext property.
*
* @param value
* allowed object is
* {@link CTPositiveSize2D }
*
*/
public void setExt(CTPositiveSize2D value) {
this.ext = value;
}
public boolean isSetExt() {
return (this.ext!= null);
}
/**
* Gets the value of the chOff property.
*
* @return
* possible object is
* {@link CTPoint2D }
*
*/
public CTPoint2D getChOff() {
return chOff;
}
/**
* Sets the value of the chOff property.
*
* @param value
* allowed object is
* {@link CTPoint2D }
*
*/
public void setChOff(CTPoint2D value) {
this.chOff = value;
}
public boolean isSetChOff() {
return (this.chOff!= null);
}
/**
* Gets the value of the chExt property.
*
* @return
* possible object is
* {@link CTPositiveSize2D }
*
*/
public CTPositiveSize2D getChExt() {
return chExt;
}
/**
* Sets the value of the chExt property.
*
* @param value
* allowed object is
* {@link CTPositiveSize2D }
*
*/
public void setChExt(CTPositiveSize2D value) {
this.chExt = value;
}
public boolean isSetChExt() {
return (this.chExt!= null);
}
/**
* Gets the value of the rot property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public int getRot() {
if (rot == null) {
return 0;
} else {
return rot;
}
}
/**
* Sets the value of the rot property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setRot(int value) {
this.rot = value;
}
public boolean isSetRot() {
return (this.rot!= null);
}
public void unsetRot() {
this.rot = null;
}
/**
* Gets the value of the flipH property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public boolean isFlipH() {
if (flipH == null) {
return false;
} else {
return flipH;
}
}
/**
* Sets the value of the flipH property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setFlipH(boolean value) {
this.flipH = value;
}
public boolean isSetFlipH() {
return (this.flipH!= null);
}
public void unsetFlipH() {
this.flipH = null;
}
/**
* Gets the value of the flipV property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public boolean isFlipV() {
if (flipV == null) {
return false;
} else {
return flipV;
}
}
/**
* Sets the value of the flipV property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setFlipV(boolean value) {
this.flipV = value;
}
public boolean isSetFlipV() {
return (this.flipV!= null);
}
public void unsetFlipV() {
this.flipV = null;
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

View File

@ -0,0 +1,237 @@
/* ====================================================================
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.binding;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.internal.bind.Locatable;
import com.sun.xml.internal.bind.annotation.XmlLocation;
import org.xml.sax.Locator;
/**
* <p>Java class for CT_HslColor complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="CT_HslColor">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_ColorTransform" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="hue" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveFixedAngle" />
* &lt;attribute name="sat" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" />
* &lt;attribute name="lum" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CT_HslColor", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
"egColorTransform"
})
public class CTHslColor implements Locatable
{
@XmlElementRefs({
@XmlElementRef(name = "hueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "blueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "gamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "green", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "lumOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "red", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "redMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "gray", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "shade", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "alphaOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "satOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "greenMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "inv", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "satMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "redOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "sat", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "lum", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "invGamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "hueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "greenOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "alpha", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "alphaMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "comp", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "hue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "lumMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "tint", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "blueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
@XmlElementRef(name = "blue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false)
})
protected List<JAXBElement<?>> egColorTransform;
@XmlAttribute(name = "hue", required = true)
protected int hue;
@XmlAttribute(name = "sat", required = true)
protected int sat;
@XmlAttribute(name = "lum", required = true)
protected int lum;
@XmlLocation
@XmlTransient
protected Locator locator;
/**
* Gets the value of the egColorTransform property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the egColorTransform property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getEGColorTransform().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link CTAngle }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}
* {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}
* {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}
* {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
* {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
*
*
*/
public List<JAXBElement<?>> getEGColorTransform() {
if (egColorTransform == null) {
egColorTransform = new ArrayList<JAXBElement<?>>();
}
return this.egColorTransform;
}
public boolean isSetEGColorTransform() {
return ((this.egColorTransform!= null)&&(!this.egColorTransform.isEmpty()));
}
public void unsetEGColorTransform() {
this.egColorTransform = null;
}
/**
* Gets the value of the hue property.
*
*/
public int getHue() {
return hue;
}
/**
* Sets the value of the hue property.
*
*/
public void setHue(int value) {
this.hue = value;
}
public boolean isSetHue() {
return true;
}
/**
* Gets the value of the sat property.
*
*/
public int getSat() {
return sat;
}
/**
* Sets the value of the sat property.
*
*/
public void setSat(int value) {
this.sat = value;
}
public boolean isSetSat() {
return true;
}
/**
* Gets the value of the lum property.
*
*/
public int getLum() {
return lum;
}
/**
* Sets the value of the lum property.
*
*/
public void setLum(int value) {
this.lum = value;
}
public boolean isSetLum() {
return true;
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
}

Some files were not shown because too many files have changed in this diff Show More