From: Yegor Kozlov Date: Sun, 8 Jun 2008 12:37:39 +0000 (+0000) Subject: expose access to OEPlaceholderAtom so that users can determine whether a shape repre... X-Git-Tag: REL_3_2_FINAL~291 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0cc7221cd17319584b47e2bb690dd23a80a91435;p=poi.git expose access to OEPlaceholderAtom so that users can determine whether a shape represents ppt placeholder (date/time, footer or slide number) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@664493 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 247f991aa2..51d5b217b0 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,9 @@ + Support custom image renderers in HSLF + Correctly increment the reference count of a blip when a picture is inserted + 45110 - Fixed TextShape.resizeToFitText() to properly resize TextShape 45091 - Fixed serialization of RefN~ tokens. Simplified Ptg class hierarchy 45133 - Fixed OBJ Record (5Dh) to pad the sub-record data to a 4-byte boundary 45145 - Fixed Sheet to always enforce RowRecordsAggregate before ValueRecordsAggregate diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index ce687164d0..cd059cbdbd 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,9 @@ + Support custom image renderers in HSLF + Correctly increment the reference count of a blip when a picture is inserted + 45110 - Fixed TextShape.resizeToFitText() to properly resize TextShape 45091 - Fixed serialization of RefN~ tokens. Simplified Ptg class hierarchy 45133 - Fixed OBJ Record (5Dh) to pad the sub-record data to a 4-byte boundary 45145 - Fixed Sheet to always enforce RowRecordsAggregate before ValueRecordsAggregate diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java b/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java index d01136d87e..17c1d1c23f 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java @@ -51,21 +51,7 @@ public abstract class MasterSheet extends Sheet { if(!(shape instanceof TextShape)) return false; TextShape tx = (TextShape)shape; - TextRun run = tx.getTextRun(); - if(run == null) return false; - - Record[] records = run._records; - for (int i = 0; i < records.length; i++) { - int type = (int)records[i].getRecordType(); - if (type == RecordTypes.BaseTextPropAtom.typeID || - type == RecordTypes.DateTimeMCAtom.typeID || - type == RecordTypes.GenericDateMCAtom.typeID || - type == RecordTypes.FooterMCAtom.typeID || - type == RecordTypes.SlideNumberMCAtom.typeID - ) return true; - - } - return false; + return tx.getPlaceholderAtom() != null; } /** diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java index e15454d651..d336cb3f3f 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java @@ -20,10 +20,12 @@ package org.apache.poi.hslf.model; import org.apache.poi.ddf.*; import org.apache.poi.util.LittleEndian; import org.apache.poi.hslf.record.ColorSchemeAtom; +import org.apache.poi.hslf.record.Record; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; +import java.util.Iterator; /** * An abstract simple (non-group) shape. @@ -284,4 +286,28 @@ public class SimpleShape extends Shape { ShapePainter.paint(this, graphics); graphics.setTransform(at); } + + /** + * Find a record in the underlying EscherClientDataRecord + * + * @param recordType type of the record to search + */ + protected Record getClientDataRecord(int recordType) { + Record oep = null; + EscherContainerRecord spContainer = getSpContainer(); + for (Iterator it = spContainer.getChildRecords().iterator(); it.hasNext();) { + EscherRecord obj = (EscherRecord) it.next(); + if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) { + byte[] data = obj.serialize(); + Record[] records = Record.findChildRecords(data, 8, data.length - 8); + for (int j = 0; j < records.length; j++) { + if (records[j].getRecordType() == recordType) { + return records[j]; + } + } + } + } + return oep; + } + } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java b/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java index bb99c1bcad..ee32868eb6 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java @@ -147,6 +147,7 @@ public class Slide extends Sheet int dgId = dgg.getMaxDrawingGroupId() + 1; dg.setOptions((short)(dgId << 4)); dgg.setDrawingsSaved(dgg.getDrawingsSaved() + 1); + dgg.setMaxDrawingGroupId(dgId); for (Iterator it = dgContainer.getChildContainers().iterator(); it.hasNext(); ) { EscherContainerRecord c = (EscherContainerRecord)it.next(); diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java b/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java index 4030ddc0c2..27dbe1b2d5 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java @@ -683,4 +683,13 @@ public class TextRun String ns = s.replaceAll("\\r?\\n", "\r"); return ns; } + + /** + * Returns records that make up this text run + * + * @return text run records + */ + public Record[] getRecords(){ + return _records; + } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java index 2f3b898a7d..969e9036af 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java @@ -138,7 +138,7 @@ public class StyleTextPropAtom extends RecordAtom new TextProp(2, 0x4000, "spaceafter"), new TextProp(2, 0x8000, "para_unknown_4"), new TextProp(2, 0x10000, "para_unknown_5"), - new TextProp(2, 0xE0000, "para_unknown_6"), + new TextProp(2, 0xA0000, "para_unknown_6"), new TextProp(2, 0x200000, "para_unknown_7") }; /** All the different kinds of character properties we might handle */ @@ -167,7 +167,7 @@ public class StyleTextPropAtom extends RecordAtom /** * For the Text Style Properties (StyleTextProp) Atom */ - protected StyleTextPropAtom(byte[] source, int start, int len) { + public StyleTextPropAtom(byte[] source, int start, int len) { // Sanity Checking - we're always at least 8+10 bytes long if(len < 18) { len = 18;