You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/12/31 23:10:18 UTC
svn commit: r1722476 [1/2] - in /poi: site/src/documentation/content/xdocs/
trunk/src/examples/src/org/apache/poi/hslf/examples/
trunk/src/examples/src/org/apache/poi/xslf/usermodel/
trunk/src/java/org/apache/poi/ddf/ trunk/src/java/org/apache/poi/sl/d...
Author: kiwiwings
Date: Thu Dec 31 22:10:17 2015
New Revision: 1722476
URL: http://svn.apache.org/viewvc?rev=1722476&view=rev
Log:
#56570 - RecordType has repeat by code type 3009
#58159 - getHeaderText() and getFooterText() duplicate text in sheet.getTextRuns()
Added:
poi/trunk/src/java/org/apache/poi/sl/usermodel/Placeholder.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExObjRefAtom.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java
Removed:
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/OEShapeAtom.java
Modified:
poi/site/src/documentation/content/xdocs/status.xml
poi/trunk/src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java
poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java
poi/trunk/src/java/org/apache/poi/ddf/EscherClientDataRecord.java
poi/trunk/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java
poi/trunk/src/java/org/apache/poi/sl/usermodel/SimpleShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFNotes.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextBox.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowDumper.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherRecordFactory.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/OEPlaceholderAtom.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RoundTripHFPlaceholder12.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFHyperlink.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPlaceholder.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordTypes.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java
Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Thu Dec 31 22:10:17 2015
@@ -40,6 +40,8 @@
</devs>
<release version="3.14-beta2" date="2016-??-??">
+ <action dev="PD" type="fix" fixes-bug="56570">RecordType has repeat by code type 3009</action>
+ <action dev="PD" type="add" fixes-bug="58159">getHeaderText() and getFooterText() duplicate text in sheet.getTextRuns()</action>
<action dev="PD" type="fix" fixes-bug="58775">Set maximum number of data formats to avoid corrupted workbook</action>
<action dev="PD" type="add" fixes-bug="58778">Override built-in number formats in XSSFWorkbooks</action>
<action dev="PD" type="fix" fixes-bug="58733">New AIOOBE in getCell while iterating through a table in PPT</action>
Modified: poi/trunk/src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java Thu Dec 31 22:10:17 2015
@@ -16,13 +16,10 @@
==================================================================== */
package org.apache.poi.hslf.examples;
import java.io.FileInputStream;
+import java.io.IOException;
-import org.apache.poi.ddf.EscherClientDataRecord;
-import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherRecord;
-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.hslf.record.RecordTypes;
import org.apache.poi.hslf.usermodel.HSLFShape;
import org.apache.poi.hslf.usermodel.HSLFSlide;
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
@@ -30,12 +27,11 @@ import org.apache.poi.hslf.usermodel.HSL
/**
* For each slide iterate over shapes and found associated sound data.
- *
- * @author Yegor Kozlov
*/
public class SoundFinder {
- public static void main(String[] args) throws Exception {
- HSLFSlideShow ppt = new HSLFSlideShow(new FileInputStream(args[0]));
+ public static void main(String[] args) throws IOException {
+ FileInputStream fis = new FileInputStream(args[0]);
+ HSLFSlideShow ppt = new HSLFSlideShow(fis);
HSLFSoundData[] sounds = ppt.getSoundData();
for (HSLFSlide slide : ppt.getSlides()) {
@@ -49,6 +45,8 @@ public class SoundFinder {
System.out.println(" " + sounds[soundRef].getSoundType());
}
}
+ ppt.close();
+ fis.close();
}
/**
@@ -59,19 +57,9 @@ public class SoundFinder {
protected static int getSoundReference(HSLFShape shape){
int soundRef = -1;
//dive into the shape container and search for InteractiveInfoAtom
- EscherContainerRecord spContainer = shape.getSpContainer();
- for (EscherRecord obj : spContainer.getChildRecords()) {
- if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
- byte[] data = obj.serialize();
- for (Record record : Record.findChildRecords(data, 8, data.length - 8)) {
- if (record instanceof InteractiveInfo) {
- InteractiveInfoAtom info = ((InteractiveInfo)record).getInteractiveInfoAtom();
- if (info.getAction() == InteractiveInfoAtom.ACTION_MEDIA) {
- soundRef = info.getSoundRef();
- }
- }
- }
- }
+ InteractiveInfoAtom info = shape.getClientDataRecord(RecordTypes.InteractiveInfo.typeID);
+ if (info != null && info.getAction() == InteractiveInfoAtom.ACTION_MEDIA) {
+ soundRef = info.getSoundRef();
}
return soundRef;
}
Modified: poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java Thu Dec 31 22:10:17 2015
@@ -23,7 +23,7 @@ import java.awt.Rectangle;
import java.io.FileOutputStream;
import java.io.IOException;
-import org.apache.poi.sl.usermodel.SimpleShape.Placeholder;
+import org.apache.poi.sl.usermodel.Placeholder;
/**
* How to set slide title
Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherClientDataRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherClientDataRecord.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherClientDataRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherClientDataRecord.java Thu Dec 31 22:10:17 2015
@@ -76,7 +76,7 @@ public class EscherClientDataRecord
public String toString()
{
String nl = System.getProperty("line.separator");
- String extraData = HexDump.dump(this.remainingData, 0, 0);
+ String extraData = HexDump.dump(getRemainingData(), 0, 0);
return getClass().getName() + ":" + nl +
" RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl +
" Version: 0x" + HexDump.toHex(getVersion()) + nl +
@@ -88,7 +88,7 @@ public class EscherClientDataRecord
@Override
public String toXml(String tab) {
- String extraData = HexDump.dump(this.remainingData, 0, 0).trim();
+ String extraData = HexDump.dump(getRemainingData(), 0, 0).trim();
StringBuilder builder = new StringBuilder();
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()),
HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java Thu Dec 31 22:10:17 2015
@@ -33,7 +33,12 @@ public class DrawMasterSheet extends Dra
* for instance, slide masters and layouts don't display placeholders
*/
@Override
- protected boolean canDraw(Shape<?,?> shape){
- return !(shape instanceof SimpleShape) || !((SimpleShape<?,?>)shape).isPlaceholder();
+ protected boolean canDraw(Shape<?,?> shape) {
+ if (shape instanceof SimpleShape) {
+ Placeholder ph = ((SimpleShape<?,?>)shape).getPlaceholder();
+ return ph == null;
+ } else {
+ return true;
+ }
}
}
Added: poi/trunk/src/java/org/apache/poi/sl/usermodel/Placeholder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Placeholder.java?rev=1722476&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Placeholder.java (added)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Placeholder.java Thu Dec 31 22:10:17 2015
@@ -0,0 +1,138 @@
+/* ====================================================================
+ 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.usermodel;
+
+public enum Placeholder {
+ /**
+ * No placeholder shape.
+ */
+ NONE(0,0,0,0,0),
+ /**
+ * Title text placeholder shape.
+ */
+ TITLE(13,1,1,1,1),
+ /**
+ * Body text placeholder shape.
+ */
+ BODY(14,2,12,6,2),
+ /**
+ * Center title text placeholder shape.
+ */
+ CENTERED_TITLE(15,3,3,3,3),
+ /**
+ * Sub-title text placeholder shape.
+ */
+ SUBTITLE(16,4,4,4,4),
+ /**
+ * Date placeholder shape.
+ */
+ DATETIME(7,7,7,7,5),
+ /**
+ * Slide number placeholder shape.
+ */
+ SLIDE_NUMBER(8,8,8,8,6),
+ /**
+ * Footer placeholder shape.
+ */
+ FOOTER(9,9,9,9,7),
+ /**
+ * Header placeholder shape.
+ */
+ HEADER(10,10,10,10,8),
+ /**
+ * Object placeholder shape.
+ */
+ CONTENT(19,19,19,19,9),
+ /**
+ * Graph object placeholder shape.
+ */
+ CHART(20,20,20,20,10),
+ /**
+ * Table object placeholder shape.
+ */
+ TABLE(21,21,21,21,11),
+ /**
+ * Clipart object placeholder shape.
+ */
+ CLIP_ART(22,22,22,22,12),
+ /**
+ * Organization chart object placeholder shape.
+ */
+ DGM(23,23,23,23,13),
+ /**
+ * Media object placeholder shape.
+ */
+ MEDIA(24,24,24,24,14),
+ /**
+ * Slide image placeholder shape.
+ */
+ SLIDE_IMAGE(11,11,11,5,15),
+ /**
+ * Picture object placeholder shape.
+ */
+ PICTURE(26,26,26,26,16),
+ /**
+ * Vertical object placeholder shape.
+ */
+ VERTICAL_OBJECT(25,25,25,25,-2),
+ /**
+ * Vertical title text placeholder shape.
+ */
+ VERTICAL_TEXT_TITLE(17,17,17,17,-2),
+ /**
+ * Vertical body text placeholder shape.
+ */
+ VERTICAL_TEXT_BODY(18,18,18,18,-2)
+ ;
+
+ public final int nativeSlideId;
+ public final int nativeSlideMasterId;
+ public final int nativeNotesId;
+ public final int nativeNotesMasterId;
+ public final int ooxmlId;
+
+ Placeholder(int nativeSlideId, int nativeSlideMasterId, int nativeNotesId, int nativeNotesMasterId, int ooxmlId) {
+ this.nativeSlideId = nativeSlideId;
+ this.nativeSlideMasterId = nativeSlideMasterId;
+ this.nativeNotesId = nativeNotesId;
+ this.nativeNotesMasterId = nativeNotesMasterId;
+ this.ooxmlId = ooxmlId;
+ }
+
+ public static Placeholder lookupNative(int nativeId) {
+ for (Placeholder ph : values()) {
+ if (ph.nativeSlideId == nativeId ||
+ ph.nativeSlideMasterId == nativeId ||
+ ph.nativeNotesId == nativeId ||
+ ph.nativeNotesMasterId == nativeId
+ ) {
+ return ph;
+ }
+ }
+ return null;
+ }
+
+ public static Placeholder lookupOoxml(int ooxmlId) {
+ for (Placeholder ph : values()) {
+ if (ph.ooxmlId == ooxmlId) {
+ return ph;
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/SimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/SimpleShape.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/SimpleShape.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/SimpleShape.java Thu Dec 31 22:10:17 2015
@@ -28,25 +28,6 @@ public interface SimpleShape<
P extends TextParagraph<S,P,?>
> extends Shape<S,P>, IAdjustableShape, PlaceableShape<S,P> {
- enum Placeholder {
- TITLE,
- BODY,
- CENTERED_TITLE,
- SUBTITLE,
- DATETIME,
- SLIDE_NUMBER,
- FOOTER,
- HEADER,
- CONTENT,
- CHART,
- TABLE,
- CLIP_ART,
- DGM,
- MEDIA,
- SLIDE_IMAGE,
- PICTURE
- }
-
FillStyle getFillStyle();
LineDecoration getLineDecoration();
@@ -69,7 +50,20 @@ public interface SimpleShape<
ShapeType getShapeType();
void setShapeType(ShapeType type);
- boolean isPlaceholder();
+ /**
+ * @return the placeholder or null if none is assigned
+ * @see #setPlaceholder(Placeholder)
+ */
+ Placeholder getPlaceholder();
+
+ /**
+ * Specifies that the corresponding shape should be represented by the generating application
+ * as a placeholder. When a shape is considered a placeholder by the generating application
+ * it can have special properties to alert the user that they may enter content into the shape.
+ *
+ * @param placeholder the placeholder or null to remove the reference to the placeholder
+ */
+ void setPlaceholder(Placeholder placeholder);
Shadow<S,P> getShadow();
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java Thu Dec 31 22:10:17 2015
@@ -21,11 +21,13 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.geom.Rectangle2D;
+import org.apache.poi.POIXMLException;
import org.apache.poi.sl.draw.DrawPaint;
import org.apache.poi.sl.usermodel.Background;
import org.apache.poi.sl.usermodel.ColorStyle;
import org.apache.poi.sl.usermodel.FillStyle;
import org.apache.poi.sl.usermodel.PaintStyle;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;
@@ -70,4 +72,10 @@ public class XSLFBackground extends XSLF
protected CTTransform2D getXfrm() {
return CTTransform2D.Factory.newInstance();
}
+
+ @Override
+ public void setPlaceholder(Placeholder placeholder) {
+ // extending XSLFSimpleShape is a bit unlucky ...
+ throw new POIXMLException("Can't set a placeholder for a background");
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java Thu Dec 31 22:10:17 2015
@@ -19,7 +19,9 @@
package org.apache.poi.xslf.usermodel;
+import org.apache.poi.POIXMLException;
import org.apache.poi.sl.usermodel.ConnectorShape;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.util.Beta;
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
@@ -69,4 +71,8 @@ public class XSLFConnectorShape extends
return null;
}
+ @Override
+ public void setPlaceholder(Placeholder placeholder) {
+ throw new POIXMLException("A connector shape can't be a placeholder.");
+ }
}
\ No newline at end of file
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java Thu Dec 31 22:10:17 2015
@@ -28,6 +28,7 @@ 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.PictureShape;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
@@ -118,6 +119,12 @@ public class XSLFPictureShape extends XS
}
return _data;
}
+
+ @Override
+ public void setPlaceholder(Placeholder placeholder) {
+ super.setPlaceholder(placeholder);
+ }
+
/**
* For an external linked picture, return the last-seen
@@ -168,7 +175,6 @@ public class XSLFPictureShape extends XS
return (r == null) ? null : new Insets(r.getT(), r.getL(), r.getB(), r.getR());
}
- @SuppressWarnings("deprecation")
@Override
void copy(XSLFShape sh){
super.copy(sh);
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java Thu Dec 31 22:10:17 2015
@@ -33,7 +33,7 @@ import org.apache.poi.sl.usermodel.Paint
import org.apache.poi.sl.usermodel.PaintStyle.GradientPaint;
import org.apache.poi.sl.usermodel.PaintStyle.TexturePaint;
import org.apache.poi.sl.usermodel.PlaceableShape;
-import org.apache.poi.sl.usermodel.SimpleShape.Placeholder;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.sl.usermodel.Shape;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
@@ -255,6 +255,14 @@ public abstract class XSLFShape implemen
return _ph;
}
+ public Placeholder getPlaceholder() {
+ CTPlaceholder ph = getCTPlaceholder();
+ if (ph == null || !ph.isSetType()) {
+ return null;
+ }
+ return Placeholder.lookupOoxml(ph.getType().intValue());
+ }
+
/**
* Specifies that the corresponding shape should be represented by the generating application
* as a placeholder. When a shape is considered a placeholder by the generating application
@@ -272,7 +280,7 @@ public abstract class XSLFShape implemen
if (nv.isSetPh()) nv.unsetPh();
_ph = null;
} else {
- nv.addNewPh().setType(STPlaceholderType.Enum.forInt(placeholder.ordinal() + 1));
+ nv.addNewPh().setType(STPlaceholderType.Enum.forInt(placeholder.ooxmlId));
}
}
@@ -442,7 +450,6 @@ public abstract class XSLFShape implemen
protected PaintStyle selectPaint(final CTGradientFillProperties gradFill, CTSchemeColor phClr) {
- @SuppressWarnings("deprecation")
final CTGradientStop[] gs = gradFill.getGsLst().getGsArray();
Arrays.sort(gs, new Comparator<CTGradientStop>() {
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java Thu Dec 31 22:10:17 2015
@@ -42,8 +42,8 @@ import org.apache.poi.sl.draw.DrawFactor
import org.apache.poi.sl.draw.DrawPictureShape;
import org.apache.poi.sl.draw.Drawable;
import org.apache.poi.sl.usermodel.PictureData;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.sl.usermodel.Sheet;
-import org.apache.poi.sl.usermodel.SimpleShape.Placeholder;
import org.apache.poi.util.Beta;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java Thu Dec 31 22:10:17 2015
@@ -34,6 +34,7 @@ import org.apache.poi.sl.usermodel.LineD
import org.apache.poi.sl.usermodel.LineDecoration.DecorationShape;
import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;
import org.apache.poi.sl.usermodel.PaintStyle;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.sl.usermodel.SimpleShape;
@@ -815,7 +816,6 @@ public abstract class XSLFSimpleShape ex
return ph != null;
}
- @SuppressWarnings("deprecation")
public Guide getAdjustValue(String name) {
CTPresetGeometry2D prst = getSpPr().getPrstGeom();
if (prst.isSetAvLst()) {
@@ -918,4 +918,9 @@ public abstract class XSLFSimpleShape ex
}
}
}
+
+ @Override
+ public void setPlaceholder(Placeholder placeholder) {
+ super.setPlaceholder(placeholder);
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java Thu Dec 31 22:10:17 2015
@@ -27,7 +27,7 @@ import org.apache.poi.openxml4j.opc.Pack
import org.apache.poi.sl.draw.DrawFactory;
import org.apache.poi.sl.draw.Drawable;
import org.apache.poi.sl.usermodel.Notes;
-import org.apache.poi.sl.usermodel.SimpleShape.Placeholder;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.sl.usermodel.Slide;
import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlException;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java Thu Dec 31 22:10:17 2015
@@ -24,7 +24,7 @@ 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.sl.usermodel.SimpleShape.Placeholder;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.xmlbeans.XmlException;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java Thu Dec 31 22:10:17 2015
@@ -27,7 +27,7 @@ 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.sl.usermodel.SimpleShape.Placeholder;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.drawingml.x2006.main.CTColorMapping;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java Thu Dec 31 22:10:17 2015
@@ -28,6 +28,7 @@ import org.apache.poi.POIXMLException;
import org.apache.poi.sl.draw.DrawFactory;
import org.apache.poi.sl.draw.DrawTextShape;
import org.apache.poi.sl.usermodel.Insets2D;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.sl.usermodel.TextShape;
import org.apache.poi.sl.usermodel.VerticalAlignment;
import org.apache.poi.util.Beta;
@@ -54,7 +55,6 @@ public abstract class XSLFTextShape exte
implements TextShape<XSLFShape,XSLFTextParagraph> {
private final List<XSLFTextParagraph> _paragraphs;
- @SuppressWarnings("deprecation")
/*package*/ XSLFTextShape(XmlObject shape, XSLFSheet sheet) {
super(shape, sheet);
@@ -497,13 +497,13 @@ public abstract class XSLFTextShape exte
public void setPlaceholder(Placeholder placeholder) {
super.setPlaceholder(placeholder);
}
-
+
public Placeholder getTextType(){
CTPlaceholder ph = getCTPlaceholder();
if (ph == null) return null;
int val = ph.getType().intValue();
- return Placeholder.values()[val - 1];
+ return Placeholder.lookupOoxml(val);
}
@Override
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFNotes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFNotes.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFNotes.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFNotes.java Thu Dec 31 22:10:17 2015
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertNul
import java.io.IOException;
-import org.apache.poi.sl.usermodel.SimpleShape.Placeholder;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.xslf.XSLFTestDataSamples;
import org.junit.Test;
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java Thu Dec 31 22:10:17 2015
@@ -28,7 +28,7 @@ import java.io.IOException;
import java.util.List;
import org.apache.poi.sl.draw.geom.TestPresetGeometries;
-import org.apache.poi.sl.usermodel.SimpleShape.Placeholder;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
import org.apache.poi.util.Units;
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextBox.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextBox.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextBox.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextBox.java Thu Dec 31 22:10:17 2015
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertNul
import java.io.IOException;
-import org.apache.poi.sl.usermodel.SimpleShape.Placeholder;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.junit.Test;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java Thu Dec 31 22:10:17 2015
@@ -31,7 +31,7 @@ import java.util.List;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hslf.usermodel.HSLFTextShape;
-import org.apache.poi.sl.usermodel.SimpleShape.Placeholder;
+import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.sl.usermodel.SlideShow;
import org.apache.poi.sl.usermodel.SlideShowFactory;
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java Thu Dec 31 22:10:17 2015
@@ -122,7 +122,7 @@ public final class PPTXMLDump {
pos += LittleEndian.INT_SIZE;
//get name of the record by type
- String recname = RecordTypes.recordName(type);
+ String recname = RecordTypes.forTypeID(type).name();
write(out, "<"+recname + " info=\""+info+"\" type=\""+type+"\" size=\""+size+"\" offset=\""+(pos-8)+"\"", padding);
if (hexHeader){
out.write(" header=\"");
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java Thu Dec 31 22:10:17 2015
@@ -79,7 +79,7 @@ public final class SLWTListing {
for(int k=0; k<upTo; k++) {
Record r = children[k];
int typeID = (int)r.getRecordType();
- String typeName = RecordTypes.recordName(typeID);
+ String typeName = RecordTypes.forTypeID(typeID).name();
System.out.println(" - " + typeID + " (" + typeName + ")");
}
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowDumper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowDumper.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowDumper.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowDumper.java Thu Dec 31 22:10:17 2015
@@ -167,7 +167,7 @@ public void walkTree(int depth, int star
out.println(String.format(Locale.ROOT, fmt, "", pos, type, len));
// See if we know about the type of it
- String recordName = RecordTypes.recordName((int)type);
+ String recordName = RecordTypes.forTypeID((short)type).name();
// Jump over header, and think about going on more
pos += 8;
@@ -293,7 +293,7 @@ public void walkTree(int depth, int star
String fmt = ind+"At position %2$d ($2$04x): type is %3$d (%3$04x), len is %4$d (%4$04x)";
out.println(String.format(Locale.ROOT, fmt, "", pos, type, atomlen));
- String typeName = RecordTypes.recordName((int)type);
+ String typeName = RecordTypes.forTypeID((short)type).name();
out.println(String.format(Locale.ROOT, ind+"%2$s", "That's an Escher Record: ", typeName));
// Record specific dumps
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java Thu Dec 31 22:10:17 2015
@@ -17,21 +17,17 @@
package org.apache.poi.hslf.model;
-import java.io.ByteArrayOutputStream;
-import java.util.Iterator;
-
import org.apache.poi.ddf.AbstractEscherOptRecord;
-import org.apache.poi.ddf.EscherClientDataRecord;
import org.apache.poi.ddf.EscherComplexProperty;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherProperties;
-import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.record.Document;
import org.apache.poi.hslf.record.ExControl;
import org.apache.poi.hslf.record.ExObjList;
-import org.apache.poi.hslf.record.OEShapeAtom;
+import org.apache.poi.hslf.record.ExObjRefAtom;
+import org.apache.poi.hslf.record.HSLFEscherClientDataRecord;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.hslf.usermodel.HSLFPictureData;
@@ -41,7 +37,6 @@ import org.apache.poi.hslf.usermodel.HSL
import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
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;
/**
@@ -92,20 +87,8 @@ public final class ActiveXShape extends
setEscherProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, -1);
- EscherClientDataRecord cldata = new EscherClientDataRecord();
- cldata.setOptions((short)0xF);
- _escherContainer.addChildRecord(cldata); // TODO unit test to prove getChildRecords().add is wrong
-
- OEShapeAtom oe = new OEShapeAtom();
-
- //convert hslf into ddf
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- try {
- oe.writeOut(out);
- } catch(Exception e){
- throw new HSLFException(e);
- }
- cldata.setRemainingData(out.toByteArray());
+ HSLFEscherClientDataRecord cldata = getClientData(true);
+ cldata.addChild(new ExObjRefAtom());
return _escherContainer;
}
@@ -116,22 +99,18 @@ public final class ActiveXShape extends
* @see org.apache.poi.hslf.usermodel.HSLFSlideShow#addMovie(String, int)
* @param idx the index of the movie
*/
- public void setActiveXIndex(int idx){
- EscherContainerRecord spContainer = getSpContainer();
- for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext();) {
- EscherRecord obj = it.next();
- if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
- EscherClientDataRecord clientRecord = (EscherClientDataRecord)obj;
- byte[] recdata = clientRecord.getRemainingData();
- LittleEndian.putInt(recdata, 8, idx);
- }
+ public void setActiveXIndex(int idx) {
+ ExObjRefAtom oe = getClientDataRecord(RecordTypes.ExObjRefAtom.typeID);
+ if (oe == null) {
+ throw new HSLFException("OEShapeAtom for ActiveX doesn't exist");
}
+ oe.setExObjIdRef(idx);
}
public int getControlIndex(){
int idx = -1;
- OEShapeAtom oe = getClientDataRecord(RecordTypes.OEShapeAtom.typeID);
- if(oe != null) idx = oe.getOptions();
+ ExObjRefAtom oe = getClientDataRecord(RecordTypes.ExObjRefAtom.typeID);
+ if(oe != null) idx = oe.getExObjIdRef();
return idx;
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java Thu Dec 31 22:10:17 2015
@@ -17,14 +17,24 @@
package org.apache.poi.hslf.model;
-import java.io.ByteArrayOutputStream;
-
-import org.apache.poi.ddf.EscherClientDataRecord;
import org.apache.poi.ddf.EscherContainerRecord;
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.*;
+import org.apache.poi.hslf.record.AnimationInfo;
+import org.apache.poi.hslf.record.AnimationInfoAtom;
+import org.apache.poi.hslf.record.ExMCIMovie;
+import org.apache.poi.hslf.record.ExObjList;
+import org.apache.poi.hslf.record.ExObjRefAtom;
+import org.apache.poi.hslf.record.ExVideoContainer;
+import org.apache.poi.hslf.record.HSLFEscherClientDataRecord;
+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.hslf.record.RecordTypes;
+import org.apache.poi.hslf.usermodel.HSLFPictureData;
+import org.apache.poi.hslf.usermodel.HSLFPictureShape;
+import org.apache.poi.hslf.usermodel.HSLFShape;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
import org.apache.poi.sl.usermodel.ShapeContainer;
/**
@@ -82,11 +92,7 @@ public final class MovieShape extends HS
setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x1000100);
setEscherProperty(EscherProperties.FILL__NOFILLHITTEST, 0x10001);
- EscherClientDataRecord cldata = new EscherClientDataRecord();
- cldata.setOptions((short)0xF);
- _escherContainer.addChildRecord(cldata);
-
- OEShapeAtom oe = new OEShapeAtom();
+ ExObjRefAtom oe = new ExObjRefAtom();
InteractiveInfo info = new InteractiveInfo();
InteractiveInfoAtom infoAtom = info.getInteractiveInfoAtom();
infoAtom.setAction(InteractiveInfoAtom.ACTION_MEDIA);
@@ -96,16 +102,10 @@ public final class MovieShape extends HS
AnimationInfoAtom anAtom = an.getAnimationInfoAtom();
anAtom.setFlag(AnimationInfoAtom.Automatic, true);
- //convert hslf into ddf
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- try {
- oe.writeOut(out);
- an.writeOut(out);
- info.writeOut(out);
- } catch(Exception e){
- throw new HSLFException(e);
- }
- cldata.setRemainingData(out.toByteArray());
+ HSLFEscherClientDataRecord cldata = getClientData(true);
+ cldata.addChild(oe);
+ cldata.addChild(an);
+ cldata.addChild(info);
return _escherContainer;
}
@@ -117,8 +117,8 @@ public final class MovieShape extends HS
* @param idx the index of the movie
*/
public void setMovieIndex(int idx){
- OEShapeAtom oe = getClientDataRecord(RecordTypes.OEShapeAtom.typeID);
- oe.setOptions(idx);
+ ExObjRefAtom oe = getClientDataRecord(RecordTypes.ExObjRefAtom.typeID);
+ oe.setExObjIdRef(idx);
AnimationInfo an = getClientDataRecord(RecordTypes.AnimationInfo.typeID);
if(an != null) {
@@ -135,7 +135,6 @@ public final class MovieShape extends HS
AnimationInfo an = getClientDataRecord(RecordTypes.AnimationInfo.typeID);
if(an != null){
an.getAnimationInfoAtom().setFlag(AnimationInfoAtom.Automatic, flag);
- updateClientData();
}
}
@@ -150,13 +149,16 @@ public final class MovieShape extends HS
/**
* @return UNC or local path to a video file
*/
+ @SuppressWarnings("resource")
public String getPath(){
- OEShapeAtom oe = getClientDataRecord(RecordTypes.OEShapeAtom.typeID);
- int idx = oe.getOptions();
+ ExObjRefAtom oe = getClientDataRecord(RecordTypes.ExObjRefAtom.typeID);
+ int idx = oe.getExObjIdRef();
HSLFSlideShow ppt = getSheet().getSlideShow();
ExObjList lst = (ExObjList)ppt.getDocumentRecord().findFirstOfType(RecordTypes.ExObjList.typeID);
- if(lst == null) return null;
+ if(lst == null) {
+ return null;
+ }
Record[] r = lst.getChildRecords();
for (int i = 0; i < r.length; i++) {
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java Thu Dec 31 22:10:17 2015
@@ -17,14 +17,22 @@
package org.apache.poi.hslf.model;
-import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherProperties;
+import org.apache.poi.ddf.EscherSpRecord;
+import org.apache.poi.hslf.record.ExEmbed;
import org.apache.poi.hslf.record.ExObjList;
+import org.apache.poi.hslf.record.ExObjRefAtom;
+import org.apache.poi.hslf.record.HSLFEscherClientDataRecord;
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.hslf.usermodel.HSLFObjectData;
+import org.apache.poi.hslf.usermodel.HSLFPictureData;
+import org.apache.poi.hslf.usermodel.HSLFPictureShape;
+import org.apache.poi.hslf.usermodel.HSLFShape;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
import org.apache.poi.sl.usermodel.ShapeContainer;
-import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
@@ -88,26 +96,19 @@ public final class OLEShape extends HSLF
EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
spRecord.setFlags(spRecord.getFlags()|EscherSpRecord.FLAG_OLESHAPE);
- EscherContainerRecord uerCont = ecr.getChildById((short)RecordTypes.EscherClientData);
- if (uerCont == null) {
- uerCont = new EscherContainerRecord();
- ecr.addChildRecord(uerCont);
+ HSLFEscherClientDataRecord cldata = getClientData(true);
+ ExObjRefAtom uer = null;
+ for (Record r : cldata.getHSLFChildRecords()) {
+ if (r.getRecordType() == RecordTypes.ExObjRefAtom.typeID) {
+ uer = (ExObjRefAtom)r;
+ break;
+ }
}
- uerCont.setRecordId((short)RecordTypes.EscherClientData);
- uerCont.setVersion((short)0x000F); // yes, we are still a container ...
-
- UnknownEscherRecord uer = uerCont.getChildById((short)RecordTypes.ExObjRefAtom.typeID);
if (uer == null) {
- uer = new UnknownEscherRecord();
- uerCont.addChildRecord(uer);
+ uer = new ExObjRefAtom();
+ cldata.addChild(uer);
}
-
- byte uerData[] = new byte[12];
- LittleEndian.putShort( uerData, 0, (short)0 ); // options = 0
- LittleEndian.putShort( uerData, 2, (short)RecordTypes.ExObjRefAtom.typeID); // recordId
- LittleEndian.putInt( uerData, 4, 4 ); // remaining bytes
- LittleEndian.putInt( uerData, 8, objectId ); // the data
- uer.fillFields(uerData, 0, null);
+ uer.setExObjIdRef(objectId);
}
@@ -116,6 +117,7 @@ public final class OLEShape extends HSLF
*
* @return the unique identifier for the OLE object
*/
+ @SuppressWarnings("resource")
public HSLFObjectData getObjectData(){
HSLFSlideShow ppt = getSheet().getSlideShow();
HSLFObjectData[] ole = ppt.getEmbeddedObjects();
@@ -153,6 +155,7 @@ public final class OLEShape extends HSLF
* 6. MetaFile( 4033), optional
* </p>
*/
+ @SuppressWarnings("resource")
public ExEmbed getExEmbed(){
if(_exEmbed == null){
HSLFSlideShow ppt = getSheet().getSlideShow();
Added: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExObjRefAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExObjRefAtom.java?rev=1722476&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExObjRefAtom.java (added)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExObjRefAtom.java Thu Dec 31 22:10:17 2015
@@ -0,0 +1,94 @@
+/* ====================================================================
+ 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.record;
+
+import org.apache.poi.util.LittleEndian;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * ExObjRefAtom (3009).
+ * <p>
+ * An atom record that specifies a reference to an external object.
+ * </p>
+ */
+
+public final class ExObjRefAtom extends RecordAtom {
+ private byte[] _header;
+
+ /**
+ * A 4-byte unsigned integer that specifies a reference to an external object.
+ * It MUST be equal to the value of the exObjId field of an ExMediaAtom record
+ * or the value of the exObjId field of an ExOleObjAtom record.
+ */
+ private int exObjIdRef;
+
+ /**
+ * Create a new instance of <code>ExObjRefAtom</code>
+ */
+ public ExObjRefAtom() {
+ _header = new byte[8];
+ LittleEndian.putUShort(_header, 0, 0);
+ LittleEndian.putUShort(_header, 2, (int)getRecordType());
+ LittleEndian.putInt(_header, 4, 4);
+ exObjIdRef = 0;
+ }
+
+ /**
+ * Build an instance of <code>ExObjRefAtom</code> from on-disk data
+ *
+ * @param source the source data as a byte array.
+ * @param start the start offset into the byte array.
+ * @param len the length of the slice in the byte array.
+ */
+ protected ExObjRefAtom(byte[] source, int start, int len) {
+ _header = new byte[8];
+ int offset = start;
+ System.arraycopy(source,start,_header,0,8);
+ offset += _header.length;
+ exObjIdRef = (int)LittleEndian.getUInt(source, offset);
+ }
+
+ /**
+ * @return type of this record {@link RecordTypes#ExObjRefAtom}.
+ */
+ public long getRecordType() {
+ return RecordTypes.ExObjRefAtom.typeID;
+ }
+
+ public int getExObjIdRef(){
+ return exObjIdRef;
+ }
+
+ public void setExObjIdRef(int id){
+ exObjIdRef = id;
+ }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ out.write(_header);
+
+ byte[] recdata = new byte[4];
+ LittleEndian.putUInt(recdata, 0, exObjIdRef);
+
+ out.write(recdata);
+ }
+}
Added: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java?rev=1722476&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java (added)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java Thu Dec 31 22:10:17 2015
@@ -0,0 +1,120 @@
+/* ====================================================================
+ 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.record;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.poi.ddf.EscherClientDataRecord;
+import org.apache.poi.ddf.EscherRecordFactory;
+import org.apache.poi.ddf.EscherSerializationListener;
+import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.util.LittleEndian;
+
+/**
+ * An atom record that specifies whether a shape is a placeholder shape.
+ * The number, position, and type of placeholder shapes are determined by
+ * the slide layout as specified in the SlideAtom record.
+ *
+ * @since POI 3.14-Beta2
+ */
+public class HSLFEscherClientDataRecord extends EscherClientDataRecord {
+
+ private final List<Record> _childRecords = new ArrayList<Record>();
+
+ public List<? extends Record> getHSLFChildRecords() {
+ return _childRecords;
+ }
+
+ public void removeChild(Class<? extends Record> childClass) {
+ Iterator<Record> iter = _childRecords.iterator();
+ while (iter.hasNext()) {
+ if (childClass.isInstance(iter.next())) {
+ iter.remove();
+ }
+ }
+ }
+
+ public void addChild(Record childRecord) {
+ _childRecords.add(childRecord);
+ }
+
+ @Override
+ public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
+ int bytesRemaining = readHeader( data, offset );
+ byte remainingData[] = new byte[bytesRemaining];
+ System.arraycopy(data, offset+8, remainingData, 0, bytesRemaining);
+ setRemainingData(remainingData);
+ return bytesRemaining + 8;
+ }
+
+ @Override
+ public int serialize(int offset, byte[] data, EscherSerializationListener listener) {
+ listener.beforeRecordSerialize( offset, getRecordId(), this );
+
+ LittleEndian.putShort(data, offset, getOptions());
+ LittleEndian.putShort(data, offset+2, getRecordId());
+
+ byte childBytes[] = getRemainingData();
+
+ LittleEndian.putInt(data, offset+4, childBytes.length);
+ System.arraycopy(childBytes, 0, data, offset+8, childBytes.length);
+ int recordSize = 8+childBytes.length;
+ listener.afterRecordSerialize( offset+recordSize, getRecordId(), recordSize, this );
+ return recordSize;
+ }
+
+ @Override
+ public int getRecordSize() {
+ return 8 + getRemainingData().length;
+ }
+
+ @Override
+ public byte[] getRemainingData() {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ try {
+ for (Record r : _childRecords) {
+ r.writeOut(bos);
+ }
+ } catch (IOException e) {
+ throw new HSLFException(e);
+ }
+ return bos.toByteArray();
+ }
+
+ @Override
+ public void setRemainingData( byte[] remainingData ) {
+ _childRecords.clear();
+ int offset = 0;
+ while (offset < remainingData.length) {
+ Record r = Record.buildRecordAtOffset(remainingData, offset);
+ _childRecords.add(r);
+ long rlen = LittleEndian.getUInt(remainingData,offset+4);
+ offset += 8 + rlen;
+ }
+ }
+
+ public String getRecordName() {
+ return "HSLFClientData";
+ }
+
+
+}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherRecordFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherRecordFactory.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherRecordFactory.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherRecordFactory.java Thu Dec 31 22:10:17 2015
@@ -29,7 +29,7 @@ import org.apache.poi.util.LittleEndian;
* @see EscherRecordFactory
*/
public class HSLFEscherRecordFactory extends DefaultEscherRecordFactory {
- private static Class<?>[] escherRecordClasses = { EscherPlaceholder.class };
+ private static Class<?>[] escherRecordClasses = { EscherPlaceholder.class, HSLFEscherClientDataRecord.class };
private static Map<Short, Constructor<? extends EscherRecord>> recordsMap = recordsToMap( escherRecordClasses );
@@ -65,6 +65,10 @@ public class HSLFEscherRecordFactory ext
}
escherRecord.setRecordId(recordId);
escherRecord.setOptions(options);
+ if (escherRecord instanceof EscherContainerRecord) {
+ ((EscherContainerRecord)escherRecord).fillFields(data, offset, this);
+ }
+
return escherRecord;
}
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/OEPlaceholderAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/OEPlaceholderAtom.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/OEPlaceholderAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/OEPlaceholderAtom.java Thu Dec 31 22:10:17 2015
@@ -201,6 +201,7 @@ public final class OEPlaceholderAtom ext
private int placementId;
private int placeholderId;
private int placeholderSize;
+ private short unusedShort = 0;
/**
@@ -227,8 +228,9 @@ public final class OEPlaceholderAtom ext
offset += _header.length;
placementId = LittleEndian.getInt(source, offset); offset += 4;
- placeholderId = LittleEndian.getUnsignedByte(source, offset); offset++;
- placeholderSize = LittleEndian.getUnsignedByte(source, offset); offset++;
+ placeholderId = LittleEndian.getUByte(source, offset); offset++;
+ placeholderSize = LittleEndian.getUByte(source, offset); offset++;
+ unusedShort = LittleEndian.getShort(source, offset);
}
/**
@@ -322,6 +324,7 @@ public final class OEPlaceholderAtom ext
LittleEndian.putInt(recdata, 0, placementId);
recdata[4] = (byte)placeholderId;
recdata[5] = (byte)placeholderSize;
+ LittleEndian.putShort(recdata, 6, unusedShort);
out.write(recdata);
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java Thu Dec 31 22:10:17 2015
@@ -20,7 +20,6 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -36,7 +35,6 @@ import org.apache.poi.ddf.EscherSimplePr
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.sl.usermodel.ShapeType;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
@@ -57,7 +55,7 @@ public final class PPDrawing extends Rec
private byte[] _header;
private long _type;
- private EscherRecord[] childRecords;
+ private final List<EscherRecord> childRecords = new ArrayList<EscherRecord>();
private EscherTextboxWrapper[] textboxWrappers;
//cached EscherDgRecord
@@ -66,7 +64,7 @@ public final class PPDrawing extends Rec
/**
* Get access to the underlying Escher Records
*/
- public EscherRecord[] getEscherRecords() { return childRecords; }
+ public List<EscherRecord> getEscherRecords() { return childRecords; }
/**
* Get access to the atoms inside Textboxes
@@ -76,6 +74,20 @@ public final class PPDrawing extends Rec
/* ******************** record stuff follows ********************** */
+ /**
+ * Creates a new, empty, PPDrawing (typically for use with a new Slide
+ * or Notes)
+ */
+ public PPDrawing() {
+ _header = new byte[8];
+ LittleEndian.putUShort(_header, 0, 15);
+ LittleEndian.putUShort(_header, 2, RecordTypes.PPDrawing.typeID);
+ LittleEndian.putInt(_header, 4, 0);
+
+ textboxWrappers = new EscherTextboxWrapper[]{};
+ create();
+ }
+
/**
* Sets everything up, groks the escher etc
*/
@@ -93,12 +105,11 @@ public final class PPDrawing extends Rec
// Build up a tree of Escher records contained within
final DefaultEscherRecordFactory erf = new HSLFEscherRecordFactory();
- final List<EscherRecord> escherChildren = new ArrayList<EscherRecord>();
- findEscherChildren(erf, contents, 8, len-8, escherChildren);
- this.childRecords = escherChildren.toArray(new EscherRecord[escherChildren.size()]);
+ findEscherChildren(erf, contents, 8, len-8, childRecords);
+ EscherContainerRecord dgContainer = getDgContainer();
- if (1 == this.childRecords.length && (short)RecordTypes.EscherDgContainer == this.childRecords[0].getRecordId() && this.childRecords[0] instanceof EscherContainerRecord) {
- this.textboxWrappers = findInDgContainer((EscherContainerRecord) this.childRecords[0]);
+ if (dgContainer != null) {
+ textboxWrappers = findInDgContainer(dgContainer);
} else {
// Find and EscherTextboxRecord's, and wrap them up
final List<EscherTextboxWrapper> textboxes = new ArrayList<EscherTextboxWrapper>();
@@ -108,15 +119,15 @@ public final class PPDrawing extends Rec
}
private EscherTextboxWrapper[] findInDgContainer(final EscherContainerRecord dgContainer) {
final List<EscherTextboxWrapper> found = new LinkedList<EscherTextboxWrapper>();
- final EscherContainerRecord spgrContainer = findFirstEscherContainerRecordOfType((short)RecordTypes.EscherSpgrContainer, dgContainer);
- final EscherContainerRecord[] spContainers = findAllEscherContainerRecordOfType((short)RecordTypes.EscherSpContainer, spgrContainer);
+ final EscherContainerRecord spgrContainer = findFirstEscherContainerRecordOfType(RecordTypes.EscherSpgrContainer, dgContainer);
+ final EscherContainerRecord[] spContainers = findAllEscherContainerRecordOfType(RecordTypes.EscherSpContainer, spgrContainer);
for (EscherContainerRecord spContainer : spContainers) {
- StyleTextProp9Atom nineAtom = findInSpContainer(spContainer);
- EscherSpRecord sp = (EscherSpRecord)findFirstEscherRecordOfType((short)RecordTypes.EscherSp, spContainer);
- EscherTextboxRecord clientTextbox = (EscherTextboxRecord)findFirstEscherRecordOfType((short)RecordTypes.EscherClientTextbox, spContainer);
+ EscherSpRecord sp = (EscherSpRecord)findFirstEscherRecordOfType(RecordTypes.EscherSp, spContainer);
+ EscherTextboxRecord clientTextbox = (EscherTextboxRecord)findFirstEscherRecordOfType(RecordTypes.EscherClientTextbox, spContainer);
if (null == clientTextbox) { continue; }
EscherTextboxWrapper w = new EscherTextboxWrapper(clientTextbox);
+ StyleTextProp9Atom nineAtom = findInSpContainer(spContainer);
w.setStyleTextProp9Atom(nineAtom);
if (null != sp) {
w.setShapeId(sp.getShapeId());
@@ -127,16 +138,26 @@ public final class PPDrawing extends Rec
}
private StyleTextProp9Atom findInSpContainer(final EscherContainerRecord spContainer) {
- EscherContainerRecord clientData = findFirstEscherContainerRecordOfType((short)RecordTypes.EscherClientData, spContainer);
- if (null == clientData) { return null; }
- final EscherContainerRecord progTagsContainer = findFirstEscherContainerRecordOfType((short)0x1388, clientData);
- if (null == progTagsContainer) { return null; }
- final EscherContainerRecord progBinaryTag = findFirstEscherContainerRecordOfType((short)0x138A, progTagsContainer);
- if (null == progBinaryTag) { return null; }
- int size = progBinaryTag.getChildRecords().size();
+ HSLFEscherClientDataRecord cldata = spContainer.getChildById(RecordTypes.EscherClientData.typeID);
+ if (cldata == null) {
+ return null;
+ }
+ DummyPositionSensitiveRecordWithChildren progTags =
+ getChildRecord(cldata.getHSLFChildRecords(), RecordTypes.ProgTags);
+ if (progTags == null) {
+ return null;
+ }
+ DummyPositionSensitiveRecordWithChildren progBinaryTag =
+ (DummyPositionSensitiveRecordWithChildren)progTags.findFirstOfType(RecordTypes.ProgBinaryTag.typeID);
+ if (progBinaryTag == null) {
+ return null;
+ }
+ int size = progBinaryTag.getChildRecords().length;
if (2 != size) { return null; }
- final Record r0 = buildFromUnknownEscherRecord((UnknownEscherRecord) progBinaryTag.getChild(0));
- final Record r1 = buildFromUnknownEscherRecord((UnknownEscherRecord) progBinaryTag.getChild(1));
+
+ final Record r0 = progBinaryTag.getChildRecords()[0];
+ final Record r1 = progBinaryTag.getChildRecords()[1];
+
if (!(r0 instanceof CString)) { return null; }
if (!("___PPT9".equals(((CString) r0).getText()))) { return null; };
if (!(r1 instanceof BinaryTagDataBlob )) { return null; }
@@ -144,19 +165,6 @@ public final class PPDrawing extends Rec
if (1 != blob.getChildRecords().length) { return null; }
return (StyleTextProp9Atom) blob.findFirstOfType(RecordTypes.StyleTextProp9Atom.typeID);
}
- /**
- * Creates a new, empty, PPDrawing (typically for use with a new Slide
- * or Notes)
- */
- public PPDrawing(){
- _header = new byte[8];
- LittleEndian.putUShort(_header, 0, 15);
- LittleEndian.putUShort(_header, 2, RecordTypes.PPDrawing.typeID);
- LittleEndian.putInt(_header, 4, 0);
-
- textboxWrappers = new EscherTextboxWrapper[]{};
- create();
- }
/**
* Tree walking way of finding Escher Child Records
@@ -198,27 +206,22 @@ public final class PPDrawing extends Rec
/**
* Look for EscherTextboxRecords
*/
- private void findEscherTextboxRecord(EscherRecord[] toSearch, List<EscherTextboxWrapper> found) {
- for(int i=0; i<toSearch.length; i++) {
- if(toSearch[i] instanceof EscherTextboxRecord) {
- EscherTextboxRecord tbr = (EscherTextboxRecord)toSearch[i];
+ private void findEscherTextboxRecord(List<EscherRecord> toSearch, List<EscherTextboxWrapper> found) {
+ EscherSpRecord sp = null;
+ for (EscherRecord r : toSearch) {
+ if (r instanceof EscherSpRecord) {
+ sp = (EscherSpRecord)r;
+ } else if (r instanceof EscherTextboxRecord) {
+ EscherTextboxRecord tbr = (EscherTextboxRecord)r;
EscherTextboxWrapper w = new EscherTextboxWrapper(tbr);
- found.add(w);
- for (int j = i; j >= 0; j--) {
- if(toSearch[j] instanceof EscherSpRecord){
- EscherSpRecord sp = (EscherSpRecord)toSearch[j];
- w.setShapeId(sp.getShapeId());
- break;
- }
+ if (sp != null) {
+ w.setShapeId(sp.getShapeId());
}
- } else {
+ found.add(w);
+ } else if (r.isContainerRecord()) {
// If it has children, walk them
- if(toSearch[i].isContainerRecord()) {
- List<EscherRecord> childrenL = toSearch[i].getChildRecords();
- EscherRecord[] children = new EscherRecord[childrenL.size()];
- childrenL.toArray(children);
- findEscherTextboxRecord(children,found);
- }
+ List<EscherRecord> children = r.getChildRecords();
+ findEscherTextboxRecord(children,found);
}
}
}
@@ -259,9 +262,8 @@ public final class PPDrawing extends Rec
// Now grab the children's data
byte[] b = new byte[newSize];
int done = 0;
- for(int i=0; i<childRecords.length; i++) {
- int written = childRecords[i].serialize( done, b );
- done += written;
+ for(EscherRecord r : childRecords) {
+ done += r.serialize( done, b );
}
// Finally, write out the children
@@ -276,7 +278,7 @@ public final class PPDrawing extends Rec
dgContainer.setRecordId( EscherContainerRecord.DG_CONTAINER );
dgContainer.setOptions((short)15);
- EscherDgRecord dg = new EscherDgRecord();
+ dg = new EscherDgRecord();
dg.setOptions((short)16);
dg.setNumShapes(1);
dgContainer.addChildRecord(dg);
@@ -321,10 +323,8 @@ public final class PPDrawing extends Rec
spContainer.addChildRecord(opt);
dgContainer.addChildRecord(spContainer);
-
- childRecords = new EscherRecord[]{
- dgContainer
- };
+
+ childRecords.add(dgContainer);
}
/**
@@ -339,15 +339,29 @@ public final class PPDrawing extends Rec
}
/**
+ * @return the container record for drawings
+ * @since POI 3.14-Beta2
+ */
+ public EscherContainerRecord getDgContainer() {
+ if (childRecords.isEmpty()) {
+ return null;
+ }
+ EscherRecord r = childRecords.get(0);
+ if (r instanceof EscherContainerRecord && r.getRecordId() == RecordTypes.EscherDgContainer.typeID) {
+ return (EscherContainerRecord)r;
+ } else {
+ return null;
+ }
+ }
+
+ /**
* Return EscherDgRecord which keeps track of the number of shapes and shapeId in this drawing group
*
* @return EscherDgRecord
*/
public EscherDgRecord getEscherDgRecord(){
if(dg == null){
- EscherContainerRecord dgContainer = (EscherContainerRecord)childRecords[0];
- for(Iterator<EscherRecord> it = dgContainer.getChildIterator(); it.hasNext();){
- EscherRecord r = it.next();
+ for(EscherRecord r : getDgContainer().getChildRecords()){
if(r instanceof EscherDgRecord){
dg = (EscherDgRecord)r;
break;
@@ -357,59 +371,59 @@ public final class PPDrawing extends Rec
return dg;
}
- protected EscherContainerRecord findFirstEscherContainerRecordOfType(short type, EscherContainerRecord parent) {
+ protected EscherContainerRecord findFirstEscherContainerRecordOfType(RecordTypes type, EscherContainerRecord parent) {
if (null == parent) { return null; }
final List<EscherContainerRecord> children = parent.getChildContainers();
for (EscherContainerRecord child : children) {
- if (type == child.getRecordId()) {
+ if (type.typeID == child.getRecordId()) {
return child;
}
}
return null;
}
- protected EscherRecord findFirstEscherRecordOfType(short type, EscherContainerRecord parent) {
+ protected EscherRecord findFirstEscherRecordOfType(RecordTypes type, EscherContainerRecord parent) {
if (null == parent) { return null; }
final List<EscherRecord> children = parent.getChildRecords();
for (EscherRecord child : children) {
- if (type == child.getRecordId()) {
+ if (type.typeID == child.getRecordId()) {
return child;
}
}
return null;
}
- protected EscherContainerRecord[] findAllEscherContainerRecordOfType(short type, EscherContainerRecord parent) {
+ protected EscherContainerRecord[] findAllEscherContainerRecordOfType(RecordTypes type, EscherContainerRecord parent) {
if (null == parent) { return new EscherContainerRecord[0]; }
final List<EscherContainerRecord> children = parent.getChildContainers();
final List<EscherContainerRecord> result = new LinkedList<EscherContainerRecord>();
for (EscherContainerRecord child : children) {
- if (type == child.getRecordId()) {
+ if (type.typeID == child.getRecordId()) {
result.add(child);
}
}
return result.toArray(new EscherContainerRecord[result.size()]);
}
- protected Record buildFromUnknownEscherRecord(UnknownEscherRecord unknown) {
- byte[] bingo = unknown.getData();
- byte[] restoredRecord = new byte[8 + bingo.length];
- System.arraycopy(bingo, 0, restoredRecord, 8, bingo.length);
- short recordVersion = unknown.getVersion();
- short recordId = unknown.getRecordId();
- int recordLength = unknown.getRecordSize();
- LittleEndian.putShort(restoredRecord, 0, recordVersion);
- LittleEndian.putShort(restoredRecord, 2, recordId);
- LittleEndian.putInt(restoredRecord, 4, recordLength);
- return Record.createRecordForType(recordId, restoredRecord, 0, restoredRecord.length);
- }
public StyleTextProp9Atom[] getNumberedListInfo() {
final List<StyleTextProp9Atom> result = new LinkedList<StyleTextProp9Atom>();
- EscherContainerRecord dgContainer = (EscherContainerRecord)childRecords[0];
- final EscherContainerRecord spgrContainer = findFirstEscherContainerRecordOfType((short)RecordTypes.EscherSpgrContainer, dgContainer);
- final EscherContainerRecord[] spContainers = findAllEscherContainerRecordOfType((short)RecordTypes.EscherSpContainer, spgrContainer);
+ EscherContainerRecord dgContainer = getDgContainer();
+ final EscherContainerRecord spgrContainer = findFirstEscherContainerRecordOfType(RecordTypes.EscherSpgrContainer, dgContainer);
+ final EscherContainerRecord[] spContainers = findAllEscherContainerRecordOfType(RecordTypes.EscherSpContainer, spgrContainer);
for (EscherContainerRecord spContainer : spContainers) {
StyleTextProp9Atom prop9 = findInSpContainer(spContainer);
- if (prop9 != null) result.add(prop9);
+ if (prop9 != null) {
+ result.add(prop9);
+ }
}
return result.toArray(new StyleTextProp9Atom[result.size()]);
}
+
+ @SuppressWarnings("unchecked")
+ private static <T extends Record> T getChildRecord(List<? extends Record> children, RecordTypes type) {
+ for (Record r : children) {
+ if (r.getRecordType() == type.typeID) {
+ return (T)r;
+ }
+ }
+ return null;
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java?rev=1722476&r1=1722475&r2=1722476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java Thu Dec 31 22:10:17 2015
@@ -166,19 +166,19 @@ public abstract class Record
// Any special record handling occurs once we have the class
Class<? extends Record> c = null;
try {
- c = RecordTypes.recordHandlingClass((int)type);
+ c = RecordTypes.forTypeID((short)type).handlingClass;
if(c == null) {
// How odd. RecordTypes normally subsitutes in
// a default handler class if it has heard of the record
// type but there's no support for it. Explicitly request
// that now
- c = RecordTypes.recordHandlingClass( RecordTypes.Unknown.typeID );
+ c = RecordTypes.UnknownRecordPlaceholder.handlingClass;
}
// Grab the right constructor
java.lang.reflect.Constructor<? extends Record> con = c.getDeclaredConstructor(new Class[] { byte[].class, Integer.TYPE, Integer.TYPE });
// Instantiate
- toReturn = con.newInstance(new Object[] { b, Integer.valueOf(start), Integer.valueOf(len) });
+ toReturn = con.newInstance(new Object[] { b, start, len });
} catch(InstantiationException ie) {
throw new RuntimeException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ie, ie);
} catch(java.lang.reflect.InvocationTargetException ite) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org