You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ba...@apache.org on 2006/12/22 21:56:06 UTC
svn commit: r489760 [2/8] - in /jakarta/poi/trunk/src:
java/org/apache/poi/hssf/record/ java/org/apache/poi/hssf/record/formula/
java/org/apache/poi/hssf/util/ scratchpad/src/org/apache/poi/hslf/blip/
scratchpad/src/org/apache/poi/hslf/extractor/ scrat...
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java?view=diff&rev=489760&r1=489759&r2=489760
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java Fri Dec 22 12:56:04 2006
@@ -1,187 +1,187 @@
-/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.blip;
-
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.hslf.model.Picture;
-import org.apache.poi.hslf.model.Shape;
-
-import java.io.*;
-import java.util.zip.InflaterInputStream;
-import java.util.zip.DeflaterOutputStream;
-
-/**
- * Represents a WMF (Windows Metafile) picture data.
- *
- * @author Yegor Kozlov
- */
-public class WMF extends Metafile {
-
- /**
- * Extract compressed WMF data from a ppt
- */
- public byte[] getData(){
- try {
- byte[] rawdata = getRawData();
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- InputStream is = new ByteArrayInputStream( rawdata );
- Header header = new Header();
- header.read(rawdata, CHECKSUM_SIZE);
- is.skip(header.getSize() + CHECKSUM_SIZE);
-
- AldusHeader aldus = new AldusHeader();
- aldus.left = header.bounds.x;
- aldus.top = header.bounds.y;
- aldus.right = header.bounds.x + header.bounds.width;
- aldus.bottom = header.bounds.y + header.bounds.height;
- aldus.write(out);
-
- InflaterInputStream inflater = new InflaterInputStream( is );
- byte[] chunk = new byte[4096];
- int count;
- while ((count = inflater.read(chunk)) >=0 ) {
- out.write(chunk,0,count);
- }
- inflater.close();
- return out.toByteArray();
- } catch (IOException e){
- throw new RuntimeException(e);
- }
- }
-
- public void setData(byte[] data) throws IOException {
- int pos = 0;
- AldusHeader aldus = new AldusHeader();
- aldus.read(data, pos);
- pos += aldus.getSize();
-
- byte[] compressed = compress(data, pos, data.length-pos);
-
- Header header = new Header();
- header.wmfsize = data.length - aldus.getSize();
- header.bounds = new java.awt.Rectangle((short)aldus.left, (short)aldus.top, (short)aldus.right-(short)aldus.left, (short)aldus.bottom-(short)aldus.top);
- //coefficiaent to translate from WMF dpi to 96pdi
- int coeff = 96*Shape.EMU_PER_POINT/aldus.inch;
- header.size = new java.awt.Dimension(header.bounds.width*coeff, header.bounds.height*coeff);
- header.zipsize = compressed.length;
-
- byte[] checksum = getChecksum(data);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- out.write(checksum);
- header.write(out);
- out.write(compressed);
-
- setRawData(out.toByteArray());
- }
-
- /**
- * We are of type <code>Picture.WMF</code>
- */
- public int getType(){
- return Picture.WMF;
- }
-
- /**
- * WMF signature is <code>0x2160</code>
- */
- public int getSignature(){
- return 0x2160;
- }
-
-
- /**
- * Aldus Placeable Metafile header - 22 byte structure before WMF data.
- * <ul>
- * <li>int Key; Magic number (always 9AC6CDD7h)
- * <li>short Handle; Metafile HANDLE number (always 0)
- * <li>short Left; Left coordinate in metafile units
- * <li>short Top; Top coordinate in metafile units
- * <li>short Right; Right coordinate in metafile units
- * <li>short Bottom; Bottom coordinate in metafile units
- * <li>short Inch; Number of metafile units per inch
- * <li>int Reserved; Reserved (always 0)
- * <li>short Checksum; Checksum value for previous 10 shorts
- * </ul>
- */
- public static class AldusHeader{
- public static final int APMHEADER_KEY = 0x9AC6CDD7;
-
- public int handle;
- public int left, top, right, bottom;
- public int inch = 72; //default resolution is 72 dpi
- public int reserved;
- public int checksum;
-
- public void read(byte[] data, int offset){
- int pos = offset;
- int key = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE; //header key
- if (key != APMHEADER_KEY) throw new RuntimeException("Not a valid WMF file");
-
- handle = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
- left = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
- top = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
- right = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
- bottom = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
-
- inch = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
- reserved = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
-
- checksum = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE;
- if (checksum != getChecksum())
- throw new RuntimeException("WMF checksum does not match the header data");
- }
-
- /**
- * Returns a checksum value for the previous 10 shorts in the header.
- * The checksum is calculated by XORing each short value to an initial value of 0:
- */
- public int getChecksum(){
- int checksum = 0;
- checksum ^= (APMHEADER_KEY & 0x0000FFFF);
- checksum ^= ((APMHEADER_KEY & 0xFFFF0000) >> 16);
- checksum ^= left;
- checksum ^= top;
- checksum ^= right;
- checksum ^= bottom;
- checksum ^= inch;
- return checksum;
- }
-
- public void write(OutputStream out) throws IOException {
- byte[] header = new byte[22];
- int pos = 0;
- LittleEndian.putInt(header, pos, APMHEADER_KEY); pos += LittleEndian.INT_SIZE; //header key
- LittleEndian.putUShort(header, pos, 0); pos += LittleEndian.SHORT_SIZE; //hmf
- LittleEndian.putUShort(header, pos, left); pos += LittleEndian.SHORT_SIZE; //left
- LittleEndian.putUShort(header, pos, top); pos += LittleEndian.SHORT_SIZE; //top
- LittleEndian.putUShort(header, pos, right); pos += LittleEndian.SHORT_SIZE; //right
- LittleEndian.putUShort(header, pos, bottom); pos += LittleEndian.SHORT_SIZE; //bottom
- LittleEndian.putUShort(header, pos, inch); pos += LittleEndian.SHORT_SIZE; //inch
- LittleEndian.putInt(header, pos, 0); pos += LittleEndian.INT_SIZE; //reserved
-
- checksum = getChecksum();
- LittleEndian.putUShort(header, pos, checksum);
-
- out.write(header);
- }
-
- public int getSize(){
- return 22;
- }
- }
-
-}
+/* ====================================================================
+ Copyright 2002-2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.hslf.blip;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.hslf.model.Picture;
+import org.apache.poi.hslf.model.Shape;
+
+import java.io.*;
+import java.util.zip.InflaterInputStream;
+import java.util.zip.DeflaterOutputStream;
+
+/**
+ * Represents a WMF (Windows Metafile) picture data.
+ *
+ * @author Yegor Kozlov
+ */
+public class WMF extends Metafile {
+
+ /**
+ * Extract compressed WMF data from a ppt
+ */
+ public byte[] getData(){
+ try {
+ byte[] rawdata = getRawData();
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ InputStream is = new ByteArrayInputStream( rawdata );
+ Header header = new Header();
+ header.read(rawdata, CHECKSUM_SIZE);
+ is.skip(header.getSize() + CHECKSUM_SIZE);
+
+ AldusHeader aldus = new AldusHeader();
+ aldus.left = header.bounds.x;
+ aldus.top = header.bounds.y;
+ aldus.right = header.bounds.x + header.bounds.width;
+ aldus.bottom = header.bounds.y + header.bounds.height;
+ aldus.write(out);
+
+ InflaterInputStream inflater = new InflaterInputStream( is );
+ byte[] chunk = new byte[4096];
+ int count;
+ while ((count = inflater.read(chunk)) >=0 ) {
+ out.write(chunk,0,count);
+ }
+ inflater.close();
+ return out.toByteArray();
+ } catch (IOException e){
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setData(byte[] data) throws IOException {
+ int pos = 0;
+ AldusHeader aldus = new AldusHeader();
+ aldus.read(data, pos);
+ pos += aldus.getSize();
+
+ byte[] compressed = compress(data, pos, data.length-pos);
+
+ Header header = new Header();
+ header.wmfsize = data.length - aldus.getSize();
+ header.bounds = new java.awt.Rectangle((short)aldus.left, (short)aldus.top, (short)aldus.right-(short)aldus.left, (short)aldus.bottom-(short)aldus.top);
+ //coefficiaent to translate from WMF dpi to 96pdi
+ int coeff = 96*Shape.EMU_PER_POINT/aldus.inch;
+ header.size = new java.awt.Dimension(header.bounds.width*coeff, header.bounds.height*coeff);
+ header.zipsize = compressed.length;
+
+ byte[] checksum = getChecksum(data);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ out.write(checksum);
+ header.write(out);
+ out.write(compressed);
+
+ setRawData(out.toByteArray());
+ }
+
+ /**
+ * We are of type <code>Picture.WMF</code>
+ */
+ public int getType(){
+ return Picture.WMF;
+ }
+
+ /**
+ * WMF signature is <code>0x2160</code>
+ */
+ public int getSignature(){
+ return 0x2160;
+ }
+
+
+ /**
+ * Aldus Placeable Metafile header - 22 byte structure before WMF data.
+ * <ul>
+ * <li>int Key; Magic number (always 9AC6CDD7h)
+ * <li>short Handle; Metafile HANDLE number (always 0)
+ * <li>short Left; Left coordinate in metafile units
+ * <li>short Top; Top coordinate in metafile units
+ * <li>short Right; Right coordinate in metafile units
+ * <li>short Bottom; Bottom coordinate in metafile units
+ * <li>short Inch; Number of metafile units per inch
+ * <li>int Reserved; Reserved (always 0)
+ * <li>short Checksum; Checksum value for previous 10 shorts
+ * </ul>
+ */
+ public static class AldusHeader{
+ public static final int APMHEADER_KEY = 0x9AC6CDD7;
+
+ public int handle;
+ public int left, top, right, bottom;
+ public int inch = 72; //default resolution is 72 dpi
+ public int reserved;
+ public int checksum;
+
+ public void read(byte[] data, int offset){
+ int pos = offset;
+ int key = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE; //header key
+ if (key != APMHEADER_KEY) throw new RuntimeException("Not a valid WMF file");
+
+ handle = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
+ left = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
+ top = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
+ right = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
+ bottom = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
+
+ inch = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
+ reserved = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
+
+ checksum = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE;
+ if (checksum != getChecksum())
+ throw new RuntimeException("WMF checksum does not match the header data");
+ }
+
+ /**
+ * Returns a checksum value for the previous 10 shorts in the header.
+ * The checksum is calculated by XORing each short value to an initial value of 0:
+ */
+ public int getChecksum(){
+ int checksum = 0;
+ checksum ^= (APMHEADER_KEY & 0x0000FFFF);
+ checksum ^= ((APMHEADER_KEY & 0xFFFF0000) >> 16);
+ checksum ^= left;
+ checksum ^= top;
+ checksum ^= right;
+ checksum ^= bottom;
+ checksum ^= inch;
+ return checksum;
+ }
+
+ public void write(OutputStream out) throws IOException {
+ byte[] header = new byte[22];
+ int pos = 0;
+ LittleEndian.putInt(header, pos, APMHEADER_KEY); pos += LittleEndian.INT_SIZE; //header key
+ LittleEndian.putUShort(header, pos, 0); pos += LittleEndian.SHORT_SIZE; //hmf
+ LittleEndian.putUShort(header, pos, left); pos += LittleEndian.SHORT_SIZE; //left
+ LittleEndian.putUShort(header, pos, top); pos += LittleEndian.SHORT_SIZE; //top
+ LittleEndian.putUShort(header, pos, right); pos += LittleEndian.SHORT_SIZE; //right
+ LittleEndian.putUShort(header, pos, bottom); pos += LittleEndian.SHORT_SIZE; //bottom
+ LittleEndian.putUShort(header, pos, inch); pos += LittleEndian.SHORT_SIZE; //inch
+ LittleEndian.putInt(header, pos, 0); pos += LittleEndian.INT_SIZE; //reserved
+
+ checksum = getChecksum();
+ LittleEndian.putUShort(header, pos, checksum);
+
+ out.write(header);
+ }
+
+ public int getSize(){
+ return 22;
+ }
+ }
+
+}
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/ImageExtractor.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/ImageExtractor.java?view=diff&rev=489760&r1=489759&r2=489760
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/ImageExtractor.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/ImageExtractor.java Fri Dec 22 12:56:04 2006
@@ -1,78 +1,78 @@
-
-/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.extractor;
-
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.PictureData;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.model.Picture;
-
-import java.io.IOException;
-import java.io.FileOutputStream;
-
-/**
- * Utility to extract pictures from a PowerPoint file.
- *
- * @author Yegor Kozlov
- */
-public class ImageExtractor {
- public static void main(String args[]) throws IOException {
- if (args.length < 1) {
- System.err.println("Usage:");
- System.err.println("\tImageExtractor <file>");
- return;
- }
- SlideShow ppt = new SlideShow(new HSLFSlideShow(args[0]));
-
- //extract all pictures contained in the presentation
- PictureData[] pdata = ppt.getPictureData();
- for (int i = 0; i < pdata.length; i++) {
- PictureData pict = pdata[i];
-
- // picture data
- byte[] data = pict.getData();
-
- int type = pict.getType();
- String ext;
- switch (type) {
- case Picture.JPEG:
- ext = ".jpg";
- break;
- case Picture.PNG:
- ext = ".png";
- break;
- case Picture.WMF:
- ext = ".wmf";
- break;
- case Picture.EMF:
- ext = ".emf";
- break;
- case Picture.PICT:
- ext = ".pict";
- break;
- case Picture.DIB:
- ext = ".dib";
- break;
- default:
- continue;
- }
- FileOutputStream out = new FileOutputStream("pict_" + i + ext);
- out.write(data);
- out.close();
- }
- }
-}
+
+/* ====================================================================
+ Copyright 2002-2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.hslf.extractor;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.model.Picture;
+
+import java.io.IOException;
+import java.io.FileOutputStream;
+
+/**
+ * Utility to extract pictures from a PowerPoint file.
+ *
+ * @author Yegor Kozlov
+ */
+public class ImageExtractor {
+ public static void main(String args[]) throws IOException {
+ if (args.length < 1) {
+ System.err.println("Usage:");
+ System.err.println("\tImageExtractor <file>");
+ return;
+ }
+ SlideShow ppt = new SlideShow(new HSLFSlideShow(args[0]));
+
+ //extract all pictures contained in the presentation
+ PictureData[] pdata = ppt.getPictureData();
+ for (int i = 0; i < pdata.length; i++) {
+ PictureData pict = pdata[i];
+
+ // picture data
+ byte[] data = pict.getData();
+
+ int type = pict.getType();
+ String ext;
+ switch (type) {
+ case Picture.JPEG:
+ ext = ".jpg";
+ break;
+ case Picture.PNG:
+ ext = ".png";
+ break;
+ case Picture.WMF:
+ ext = ".wmf";
+ break;
+ case Picture.EMF:
+ ext = ".emf";
+ break;
+ case Picture.PICT:
+ ext = ".pict";
+ break;
+ case Picture.DIB:
+ ext = ".dib";
+ break;
+ default:
+ continue;
+ }
+ FileOutputStream out = new FileOutputStream("pict_" + i + ext);
+ out.write(data);
+ out.close();
+ }
+ }
+}
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java?view=diff&rev=489760&r1=489759&r2=489760
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java Fri Dec 22 12:56:04 2006
@@ -1,61 +1,61 @@
-/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.model;
-
-import org.apache.poi.ddf.*;
-
-/**
- * Represents a autoshape in a PowerPoint drawing
- *
- * @author Yegor Kozlov
- */
-public class AutoShape extends SimpleShape {
-
- protected AutoShape(EscherContainerRecord escherRecord, Shape parent){
- super(escherRecord, parent);
- }
-
- public AutoShape(int type, Shape parent){
- super(null, parent);
- _escherContainer = createSpContainer(type, parent instanceof ShapeGroup);
- }
-
- public AutoShape(int type){
- this(type, null);
- }
-
- protected EscherContainerRecord createSpContainer(int shapeType, boolean isChild){
- EscherContainerRecord spcont = super.createSpContainer(isChild);
-
- EscherSpRecord spRecord = spcont.getChildById(EscherSpRecord.RECORD_ID);
- short type = (short)((shapeType << 4) | 0x2);
- spRecord.setOptions(type);
-
- //set default properties for an autoshape
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(spcont, EscherOptRecord.RECORD_ID);
-
- opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.FILL__FILLCOLOR, 0x8000004));
- opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.FILL__FILLBACKCOLOR, 0x8000000));
- opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.FILL__NOFILLHITTEST, 0x100010));
- opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__COLOR, 0x8000001));
- opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80008));
- opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x8000002));
-
- return spcont;
- }
-
-}
+/* ====================================================================
+ Copyright 2002-2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import org.apache.poi.ddf.*;
+
+/**
+ * Represents a autoshape in a PowerPoint drawing
+ *
+ * @author Yegor Kozlov
+ */
+public class AutoShape extends SimpleShape {
+
+ protected AutoShape(EscherContainerRecord escherRecord, Shape parent){
+ super(escherRecord, parent);
+ }
+
+ public AutoShape(int type, Shape parent){
+ super(null, parent);
+ _escherContainer = createSpContainer(type, parent instanceof ShapeGroup);
+ }
+
+ public AutoShape(int type){
+ this(type, null);
+ }
+
+ protected EscherContainerRecord createSpContainer(int shapeType, boolean isChild){
+ EscherContainerRecord spcont = super.createSpContainer(isChild);
+
+ EscherSpRecord spRecord = spcont.getChildById(EscherSpRecord.RECORD_ID);
+ short type = (short)((shapeType << 4) | 0x2);
+ spRecord.setOptions(type);
+
+ //set default properties for an autoshape
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(spcont, EscherOptRecord.RECORD_ID);
+
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.FILL__FILLCOLOR, 0x8000004));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.FILL__FILLBACKCOLOR, 0x8000000));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.FILL__NOFILLHITTEST, 0x100010));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__COLOR, 0x8000001));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80008));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x8000002));
+
+ return spcont;
+ }
+
+}
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Background.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Background.java?view=diff&rev=489760&r1=489759&r2=489760
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Background.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Background.java Fri Dec 22 12:56:04 2006
@@ -1,37 +1,37 @@
-
-/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.model;
-
-import org.apache.poi.ddf.EscherContainerRecord;
-
-/**
- * Background shape
- *
- * @author Yegor Kozlov
- */
-public class Background extends Shape {
-
- protected Background(EscherContainerRecord escherRecord, Shape parent){
- super(escherRecord, parent);
- }
-
- protected EscherContainerRecord createSpContainer(boolean isChild){
- return null;
- }
-
-}
+
+/* ====================================================================
+ Copyright 2002-2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import org.apache.poi.ddf.EscherContainerRecord;
+
+/**
+ * Background shape
+ *
+ * @author Yegor Kozlov
+ */
+public class Background extends Shape {
+
+ protected Background(EscherContainerRecord escherRecord, Shape parent){
+ super(escherRecord, parent);
+ }
+
+ protected EscherContainerRecord createSpContainer(boolean isChild){
+ return null;
+ }
+
+}
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java?view=diff&rev=489760&r1=489759&r2=489760
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java Fri Dec 22 12:56:04 2006
@@ -1,228 +1,228 @@
-
-/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.record.*;
-import org.apache.poi.hslf.usermodel.PictureData;
-import org.apache.poi.hslf.usermodel.SlideShow;
-
-import java.awt.*;
-import java.util.*;
-
-/**
- * Represents functionality provided by the 'Fill Effects' dialog in PowerPoint.
- *
- * @author Yegor Kozlov
- */
-public class Fill {
- /**
- * Fill with a solid color
- */
- public static final int FILL_SOLID = 0;
-
- /**
- * Fill with a pattern (bitmap)
- */
- public static final int FILL_PATTERN = 1;
-
- /**
- * A texture (pattern with its own color map)
- */
- public static final int FILL_TEXTURE = 2;
-
- /**
- * Center a picture in the shape
- */
- public static final int FILL_PICTURE = 3;
-
- /**
- * Shade from start to end points
- */
- public static final int FILL_SHADE = 4;
-
- /**
- * Shade from bounding rectangle to end point
- */
- public static final int FILL_SHADE_CENTER = 5;
-
- /**
- * Shade from shape outline to end point
- */
- public static final int FILL_SHADE_SHAPE = 6;
-
- /**
- * Similar to FILL_SHADE, but the fill angle
- * is additionally scaled by the aspect ratio of
- * the shape. If shape is square, it is the same as FILL_SHADE
- */
- public static final int FILL_SHADE_SCALE = 7;
-
- /**
- * shade to title
- */
- public static final int FILL_SHADE_TITLE = 8;
-
- /**
- * Use the background fill color/pattern
- */
- public static final int FILL_BACKGROUND = 9;
-
-
-
- /**
- * The shape this background applies to
- */
- protected Shape shape;
-
- /**
- * Construct a <code>Fill</code> object for a shape.
- * Fill information will be read from shape's escher properties.
- *
- * @param shape the shape this background applies to
- */
- public Fill(Shape shape){
- this.shape = shape;
- }
-
- /**
- * Returns fill type.
- * Must be one of the <code>FILL_*</code> constants defined in this class.
- *
- * @return type of fill
- */
- public int getFillType(){
- EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
- EscherSimpleProperty prop = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLTYPE);
- return prop == null ? FILL_SOLID : prop.getPropertyValue();
- }
-
- /**
- * Sets fill type.
- * Must be one of the <code>FILL_*</code> constants defined in this class.
- *
- * @param type type of the fill
- */
- public void setFillType(int type){
- EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
- Shape.setEscherProperty(opt, EscherProperties.FILL__FILLTYPE, type);
- }
-
- /**
- * Foreground color
- */
- public Color getForegroundColor(){
- EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
- EscherSimpleProperty p1 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLCOLOR);
- EscherSimpleProperty p2 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
-
- int p2val = p2 == null ? 0 : p2.getPropertyValue();
-
- Color clr = null;
- if (p1 != null && (p2val & 0x10) != 0){
- int rgb = p1.getPropertyValue();
- clr = shape.getColor(rgb);
- }
- return clr;
- }
-
- /**
- * Foreground color
- */
- public void setForegroundColor(Color color){
- EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
- if (color == null) {
- Shape.setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, -1);
- }
- else {
- int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
- Shape.setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, rgb);
- }
- }
-
- /**
- * Background color
- */
- public Color getBackgroundColor(){
- EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
- EscherSimpleProperty p1 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR);
- EscherSimpleProperty p2 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
-
- int p2val = p2 == null ? 0 : p2.getPropertyValue();
-
- Color clr = null;
- if (p1 != null && (p2val & 0x10) != 0){
- int rgb = p1.getPropertyValue();
- clr = shape.getColor(rgb);
- }
- return clr;
- }
-
- /**
- * Background color
- */
- public void setBackgroundColor(Color color){
- EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
- if (color == null) {
- Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, -1);
- }
- else {
- int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
- Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, rgb);
- }
- }
-
- /**
- * <code>PictureData</code> object used in a texture, pattern of picture fill.
- */
- public PictureData getPictureData(){
- EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
- EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
- if (p == null) return null;
-
- SlideShow ppt = shape.getSheet().getSlideShow();
- PictureData[] pict = ppt.getPictureData();
- Document doc = ppt.getDocumentRecord();
-
- EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
- EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
-
- java.util.List lst = bstore.getChildRecords();
- int idx = p.getPropertyValue();
- EscherBSERecord bse = (EscherBSERecord)lst.get(idx);
- for ( int i = 0; i < pict.length; i++ ) {
- if (pict[i].getOffset() == bse.getOffset()){
- return pict[i];
- }
- }
- throw new RuntimeException("Picture data not found: \n" +
- " bse: " + bse + " at " + bse.getOffset() );
-
- }
-
- /**
- * Assign picture used to fill the underlying shape.
- *
- * @param idx 0-based index of the picture added to this ppt by <code>SlideShow.addPicture</code> method.
- */
- public void setPictureData(int idx){
- EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
- Shape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), idx);
- }
-
-}
+
+/* ====================================================================
+ Copyright 2002-2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import org.apache.poi.ddf.*;
+import org.apache.poi.hslf.record.*;
+import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.usermodel.SlideShow;
+
+import java.awt.*;
+import java.util.*;
+
+/**
+ * Represents functionality provided by the 'Fill Effects' dialog in PowerPoint.
+ *
+ * @author Yegor Kozlov
+ */
+public class Fill {
+ /**
+ * Fill with a solid color
+ */
+ public static final int FILL_SOLID = 0;
+
+ /**
+ * Fill with a pattern (bitmap)
+ */
+ public static final int FILL_PATTERN = 1;
+
+ /**
+ * A texture (pattern with its own color map)
+ */
+ public static final int FILL_TEXTURE = 2;
+
+ /**
+ * Center a picture in the shape
+ */
+ public static final int FILL_PICTURE = 3;
+
+ /**
+ * Shade from start to end points
+ */
+ public static final int FILL_SHADE = 4;
+
+ /**
+ * Shade from bounding rectangle to end point
+ */
+ public static final int FILL_SHADE_CENTER = 5;
+
+ /**
+ * Shade from shape outline to end point
+ */
+ public static final int FILL_SHADE_SHAPE = 6;
+
+ /**
+ * Similar to FILL_SHADE, but the fill angle
+ * is additionally scaled by the aspect ratio of
+ * the shape. If shape is square, it is the same as FILL_SHADE
+ */
+ public static final int FILL_SHADE_SCALE = 7;
+
+ /**
+ * shade to title
+ */
+ public static final int FILL_SHADE_TITLE = 8;
+
+ /**
+ * Use the background fill color/pattern
+ */
+ public static final int FILL_BACKGROUND = 9;
+
+
+
+ /**
+ * The shape this background applies to
+ */
+ protected Shape shape;
+
+ /**
+ * Construct a <code>Fill</code> object for a shape.
+ * Fill information will be read from shape's escher properties.
+ *
+ * @param shape the shape this background applies to
+ */
+ public Fill(Shape shape){
+ this.shape = shape;
+ }
+
+ /**
+ * Returns fill type.
+ * Must be one of the <code>FILL_*</code> constants defined in this class.
+ *
+ * @return type of fill
+ */
+ public int getFillType(){
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
+ EscherSimpleProperty prop = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLTYPE);
+ return prop == null ? FILL_SOLID : prop.getPropertyValue();
+ }
+
+ /**
+ * Sets fill type.
+ * Must be one of the <code>FILL_*</code> constants defined in this class.
+ *
+ * @param type type of the fill
+ */
+ public void setFillType(int type){
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
+ Shape.setEscherProperty(opt, EscherProperties.FILL__FILLTYPE, type);
+ }
+
+ /**
+ * Foreground color
+ */
+ public Color getForegroundColor(){
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
+ EscherSimpleProperty p1 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLCOLOR);
+ EscherSimpleProperty p2 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
+
+ int p2val = p2 == null ? 0 : p2.getPropertyValue();
+
+ Color clr = null;
+ if (p1 != null && (p2val & 0x10) != 0){
+ int rgb = p1.getPropertyValue();
+ clr = shape.getColor(rgb);
+ }
+ return clr;
+ }
+
+ /**
+ * Foreground color
+ */
+ public void setForegroundColor(Color color){
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
+ if (color == null) {
+ Shape.setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, -1);
+ }
+ else {
+ int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
+ Shape.setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, rgb);
+ }
+ }
+
+ /**
+ * Background color
+ */
+ public Color getBackgroundColor(){
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
+ EscherSimpleProperty p1 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR);
+ EscherSimpleProperty p2 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
+
+ int p2val = p2 == null ? 0 : p2.getPropertyValue();
+
+ Color clr = null;
+ if (p1 != null && (p2val & 0x10) != 0){
+ int rgb = p1.getPropertyValue();
+ clr = shape.getColor(rgb);
+ }
+ return clr;
+ }
+
+ /**
+ * Background color
+ */
+ public void setBackgroundColor(Color color){
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
+ if (color == null) {
+ Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, -1);
+ }
+ else {
+ int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
+ Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, rgb);
+ }
+ }
+
+ /**
+ * <code>PictureData</code> object used in a texture, pattern of picture fill.
+ */
+ public PictureData getPictureData(){
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
+ EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
+ if (p == null) return null;
+
+ SlideShow ppt = shape.getSheet().getSlideShow();
+ PictureData[] pict = ppt.getPictureData();
+ Document doc = ppt.getDocumentRecord();
+
+ EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
+ EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
+
+ java.util.List lst = bstore.getChildRecords();
+ int idx = p.getPropertyValue();
+ EscherBSERecord bse = (EscherBSERecord)lst.get(idx);
+ for ( int i = 0; i < pict.length; i++ ) {
+ if (pict[i].getOffset() == bse.getOffset()){
+ return pict[i];
+ }
+ }
+ throw new RuntimeException("Picture data not found: \n" +
+ " bse: " + bse + " at " + bse.getOffset() );
+
+ }
+
+ /**
+ * Assign picture used to fill the underlying shape.
+ *
+ * @param idx 0-based index of the picture added to this ppt by <code>SlideShow.addPicture</code> method.
+ */
+ public void setPictureData(int idx){
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
+ Shape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), idx);
+ }
+
+}
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Line.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Line.java?view=diff&rev=489760&r1=489759&r2=489760
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Line.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Line.java Fri Dec 22 12:56:04 2006
@@ -1,128 +1,128 @@
-/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.model;
-
-import org.apache.poi.ddf.*;
-
-/**
- * Represents a line in a PowerPoint drawing
- *
- * @author Yegor Kozlov
- */
-public class Line extends SimpleShape {
- /**
- * Solid (continuous) pen
- */
- public static final int PEN_SOLID = 1;
- /**
- * PS_DASH system dash style
- */
- public static final int PEN_PS_DASH = 2;
- /**
- * PS_DOT system dash style
- */
- public static final int PEN_DOT = 3;
- /**
- * PS_DASHDOT system dash style
- */
- public static final int PEN_DASHDOT = 4;
- /**
- * PS_DASHDOTDOT system dash style
- */
- public static final int PEN_DASHDOTDOT = 5;
- /**
- * square dot style
- */
- public static final int PEN_DOTGEL = 6;
- /**
- * dash style
- */
- public static final int PEN_DASH = 7;
- /**
- * long dash style
- */
- public static final int PEN_LONGDASHGEL = 8;
- /**
- * dash short dash
- */
- public static final int PEN_DASHDOTGEL = 9;
- /**
- * long dash short dash
- */
- public static final int PEN_LONGDASHDOTGEL = 10;
- /**
- * long dash short dash short dash
- */
- public static final int PEN_LONGDASHDOTDOTGEL = 11;
-
- /**
- * Single line (of width lineWidth)
- */
- public static final int LINE_SIMPLE = 0;
- /**
- * Double lines of equal width
- */
- public static final int LINE_DOUBLE = 1;
- /**
- * Double lines, one thick, one thin
- */
- public static final int LINE_THICKTHIN = 2;
- /**
- * Double lines, reverse order
- */
- public static final int LINE_THINTHICK = 3;
- /**
- * Three lines, thin, thick, thin
- */
- public static final int LINE_TRIPLE = 4;
-
-
- protected Line(EscherContainerRecord escherRecord, Shape parent){
- super(escherRecord, parent);
- }
-
- public Line(Shape parent){
- super(null, parent);
- _escherContainer = createSpContainer(parent instanceof ShapeGroup);
- }
-
- public Line(){
- this(null);
- }
-
- protected EscherContainerRecord createSpContainer(boolean isChild){
- EscherContainerRecord spcont = super.createSpContainer(isChild);
-
- EscherSpRecord spRecord = spcont.getChildById(EscherSpRecord.RECORD_ID);
- short type = (ShapeTypes.Line << 4) | 0x2;
- spRecord.setOptions(type);
-
- //set default properties for a line
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(spcont, EscherOptRecord.RECORD_ID);
-
- //default line properties
- setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, 4);
- setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, 0x10000);
- setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x100000);
- setEscherProperty(opt, EscherProperties.LINESTYLE__COLOR, 0x8000001);
- setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0xA0008);
- setEscherProperty(opt, EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
-
- return spcont;
- }
-
-}
+/* ====================================================================
+ Copyright 2002-2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import org.apache.poi.ddf.*;
+
+/**
+ * Represents a line in a PowerPoint drawing
+ *
+ * @author Yegor Kozlov
+ */
+public class Line extends SimpleShape {
+ /**
+ * Solid (continuous) pen
+ */
+ public static final int PEN_SOLID = 1;
+ /**
+ * PS_DASH system dash style
+ */
+ public static final int PEN_PS_DASH = 2;
+ /**
+ * PS_DOT system dash style
+ */
+ public static final int PEN_DOT = 3;
+ /**
+ * PS_DASHDOT system dash style
+ */
+ public static final int PEN_DASHDOT = 4;
+ /**
+ * PS_DASHDOTDOT system dash style
+ */
+ public static final int PEN_DASHDOTDOT = 5;
+ /**
+ * square dot style
+ */
+ public static final int PEN_DOTGEL = 6;
+ /**
+ * dash style
+ */
+ public static final int PEN_DASH = 7;
+ /**
+ * long dash style
+ */
+ public static final int PEN_LONGDASHGEL = 8;
+ /**
+ * dash short dash
+ */
+ public static final int PEN_DASHDOTGEL = 9;
+ /**
+ * long dash short dash
+ */
+ public static final int PEN_LONGDASHDOTGEL = 10;
+ /**
+ * long dash short dash short dash
+ */
+ public static final int PEN_LONGDASHDOTDOTGEL = 11;
+
+ /**
+ * Single line (of width lineWidth)
+ */
+ public static final int LINE_SIMPLE = 0;
+ /**
+ * Double lines of equal width
+ */
+ public static final int LINE_DOUBLE = 1;
+ /**
+ * Double lines, one thick, one thin
+ */
+ public static final int LINE_THICKTHIN = 2;
+ /**
+ * Double lines, reverse order
+ */
+ public static final int LINE_THINTHICK = 3;
+ /**
+ * Three lines, thin, thick, thin
+ */
+ public static final int LINE_TRIPLE = 4;
+
+
+ protected Line(EscherContainerRecord escherRecord, Shape parent){
+ super(escherRecord, parent);
+ }
+
+ public Line(Shape parent){
+ super(null, parent);
+ _escherContainer = createSpContainer(parent instanceof ShapeGroup);
+ }
+
+ public Line(){
+ this(null);
+ }
+
+ protected EscherContainerRecord createSpContainer(boolean isChild){
+ EscherContainerRecord spcont = super.createSpContainer(isChild);
+
+ EscherSpRecord spRecord = spcont.getChildById(EscherSpRecord.RECORD_ID);
+ short type = (ShapeTypes.Line << 4) | 0x2;
+ spRecord.setOptions(type);
+
+ //set default properties for a line
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(spcont, EscherOptRecord.RECORD_ID);
+
+ //default line properties
+ setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, 4);
+ setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, 0x10000);
+ setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x100000);
+ setEscherProperty(opt, EscherProperties.LINESTYLE__COLOR, 0x8000001);
+ setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0xA0008);
+ setEscherProperty(opt, EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
+
+ return spcont;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/