mirror of https://github.com/apache/poi.git
Pass font details + character styling up to the model
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353787 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2a1bc426a6
commit
5a52664cf7
|
@ -29,6 +29,7 @@ import org.apache.poi.poifs.filesystem.DocumentInputStream;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
import org.apache.poi.hslf.record.Record;
|
import org.apache.poi.hslf.record.Record;
|
||||||
|
import org.apache.poi.hslf.record.StyleTextPropAtom;
|
||||||
import org.apache.poi.hslf.record.TextHeaderAtom;
|
import org.apache.poi.hslf.record.TextHeaderAtom;
|
||||||
import org.apache.poi.hslf.record.TextBytesAtom;
|
import org.apache.poi.hslf.record.TextBytesAtom;
|
||||||
import org.apache.poi.hslf.record.TextCharsAtom;
|
import org.apache.poi.hslf.record.TextCharsAtom;
|
||||||
|
@ -182,12 +183,12 @@ public class QuickButCruddyTextExtractor
|
||||||
// TextBytesAtom
|
// TextBytesAtom
|
||||||
if(type == 4008l) {
|
if(type == 4008l) {
|
||||||
TextBytesAtom tba = (TextBytesAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
|
TextBytesAtom tba = (TextBytesAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
|
||||||
trun = new TextRun((TextHeaderAtom)null,tba);
|
trun = new TextRun((TextHeaderAtom)null,tba,(StyleTextPropAtom)null);
|
||||||
}
|
}
|
||||||
// TextCharsAtom
|
// TextCharsAtom
|
||||||
if(type == 4000l) {
|
if(type == 4000l) {
|
||||||
TextCharsAtom tca = (TextCharsAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
|
TextCharsAtom tca = (TextCharsAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
|
||||||
trun = new TextRun((TextHeaderAtom)null,tca);
|
trun = new TextRun((TextHeaderAtom)null,tca,(StyleTextPropAtom)null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we found text, save it in the vector
|
// If we found text, save it in the vector
|
||||||
|
|
|
@ -71,12 +71,22 @@ public abstract class Sheet
|
||||||
if(records[i] instanceof TextHeaderAtom) {
|
if(records[i] instanceof TextHeaderAtom) {
|
||||||
TextRun trun = null;
|
TextRun trun = null;
|
||||||
TextHeaderAtom tha = (TextHeaderAtom)records[i];
|
TextHeaderAtom tha = (TextHeaderAtom)records[i];
|
||||||
|
StyleTextPropAtom stpa = null;
|
||||||
|
|
||||||
|
// Look for a subsequent StyleTextPropAtom
|
||||||
|
if(i < (records.length-2)) {
|
||||||
|
if(records[i+2] instanceof StyleTextPropAtom) {
|
||||||
|
stpa = (StyleTextPropAtom)records[i+2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// See what follows the TextHeaderAtom
|
||||||
if(records[i+1] instanceof TextCharsAtom) {
|
if(records[i+1] instanceof TextCharsAtom) {
|
||||||
TextCharsAtom tca = (TextCharsAtom)records[i+1];
|
TextCharsAtom tca = (TextCharsAtom)records[i+1];
|
||||||
trun = new TextRun(tha,tca);
|
trun = new TextRun(tha,tca,stpa);
|
||||||
} else if(records[i+1] instanceof TextBytesAtom) {
|
} else if(records[i+1] instanceof TextBytesAtom) {
|
||||||
TextBytesAtom tba = (TextBytesAtom)records[i+1];
|
TextBytesAtom tba = (TextBytesAtom)records[i+1];
|
||||||
trun = new TextRun(tha,tba);
|
trun = new TextRun(tha,tba,stpa);
|
||||||
} else if(records[i+1].getRecordType() == 4001l) {
|
} else if(records[i+1].getRecordType() == 4001l) {
|
||||||
// StyleTextPropAtom - Safe to ignore
|
// StyleTextPropAtom - Safe to ignore
|
||||||
} else if(records[i+1].getRecordType() == 4010l) {
|
} else if(records[i+1].getRecordType() == 4010l) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class TextRun
|
||||||
private TextHeaderAtom _headerAtom;
|
private TextHeaderAtom _headerAtom;
|
||||||
private TextBytesAtom _byteAtom;
|
private TextBytesAtom _byteAtom;
|
||||||
private TextCharsAtom _charAtom;
|
private TextCharsAtom _charAtom;
|
||||||
|
private StyleTextPropAtom _styleAtom;
|
||||||
private boolean _isUnicode;
|
private boolean _isUnicode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,9 +44,10 @@ public class TextRun
|
||||||
* @param tha the TextHeaderAtom that defines what's what
|
* @param tha the TextHeaderAtom that defines what's what
|
||||||
* @param tca the TextCharsAtom containing the text
|
* @param tca the TextCharsAtom containing the text
|
||||||
*/
|
*/
|
||||||
public TextRun(TextHeaderAtom tha, TextCharsAtom tca) {
|
public TextRun(TextHeaderAtom tha, TextCharsAtom tca, StyleTextPropAtom sta) {
|
||||||
_headerAtom = tha;
|
_headerAtom = tha;
|
||||||
_charAtom = tca;
|
_charAtom = tca;
|
||||||
|
_styleAtom = sta;
|
||||||
_isUnicode = true;
|
_isUnicode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,9 +57,10 @@ public class TextRun
|
||||||
* @param tha the TextHeaderAtom that defines what's what
|
* @param tha the TextHeaderAtom that defines what's what
|
||||||
* @param tba the TextBytesAtom containing the text
|
* @param tba the TextBytesAtom containing the text
|
||||||
*/
|
*/
|
||||||
public TextRun(TextHeaderAtom tha, TextBytesAtom tba) {
|
public TextRun(TextHeaderAtom tha, TextBytesAtom tba, StyleTextPropAtom sta) {
|
||||||
_headerAtom = tha;
|
_headerAtom = tha;
|
||||||
_byteAtom = tba;
|
_byteAtom = tba;
|
||||||
|
_styleAtom = sta;
|
||||||
_isUnicode = false;
|
_isUnicode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class RecordTypes {
|
||||||
public static final Type SlideAtom = new Type(1007,SlideAtom.class);
|
public static final Type SlideAtom = new Type(1007,SlideAtom.class);
|
||||||
public static final Type Notes = new Type(1008,Notes.class);
|
public static final Type Notes = new Type(1008,Notes.class);
|
||||||
public static final Type NotesAtom = new Type(1009,NotesAtom.class);
|
public static final Type NotesAtom = new Type(1009,NotesAtom.class);
|
||||||
public static final Type Environment = new Type(1010,null);
|
public static final Type Environment = new Type(1010,DummyRecordWithChildren.class);
|
||||||
public static final Type SlidePersistAtom = new Type(1011,SlidePersistAtom.class);
|
public static final Type SlidePersistAtom = new Type(1011,SlidePersistAtom.class);
|
||||||
public static final Type SSlideLayoutAtom = new Type(1015,null);
|
public static final Type SSlideLayoutAtom = new Type(1015,null);
|
||||||
public static final Type MainMaster = new Type(1016,DummyPositionSensitiveRecordWithChildren.class);
|
public static final Type MainMaster = new Type(1016,DummyPositionSensitiveRecordWithChildren.class);
|
||||||
|
|
|
@ -26,7 +26,9 @@ import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
import org.apache.poi.hslf.*;
|
import org.apache.poi.hslf.*;
|
||||||
import org.apache.poi.hslf.model.*;
|
import org.apache.poi.hslf.model.*;
|
||||||
|
import org.apache.poi.hslf.record.FontCollection;
|
||||||
import org.apache.poi.hslf.record.Record;
|
import org.apache.poi.hslf.record.Record;
|
||||||
|
import org.apache.poi.hslf.record.RecordTypes;
|
||||||
import org.apache.poi.hslf.record.SlideAtom;
|
import org.apache.poi.hslf.record.SlideAtom;
|
||||||
import org.apache.poi.hslf.record.SlideListWithText;
|
import org.apache.poi.hslf.record.SlideListWithText;
|
||||||
import org.apache.poi.hslf.record.SlideListWithText.*;
|
import org.apache.poi.hslf.record.SlideListWithText.*;
|
||||||
|
@ -59,6 +61,7 @@ public class SlideShow
|
||||||
// Friendly objects for people to deal with
|
// Friendly objects for people to deal with
|
||||||
private Slide[] _slides;
|
private Slide[] _slides;
|
||||||
private Notes[] _notes;
|
private Notes[] _notes;
|
||||||
|
private FontCollection _fonts;
|
||||||
// MetaSheets (eg masters) not yet supported
|
// MetaSheets (eg masters) not yet supported
|
||||||
// private MetaSheets[] _msheets;
|
// private MetaSheets[] _msheets;
|
||||||
|
|
||||||
|
@ -183,7 +186,7 @@ public class SlideShow
|
||||||
if(_mostRecentCoreRecords[i] instanceof org.apache.poi.hslf.record.Slide) {
|
if(_mostRecentCoreRecords[i] instanceof org.apache.poi.hslf.record.Slide) {
|
||||||
slidesV.add(_mostRecentCoreRecords[i]);
|
slidesV.add(_mostRecentCoreRecords[i]);
|
||||||
}
|
}
|
||||||
if(_records[i].getRecordType() == 1000l) {
|
if(_records[i].getRecordType() == RecordTypes.Document.typeID) {
|
||||||
documentRecord = _mostRecentCoreRecords[i];
|
documentRecord = _mostRecentCoreRecords[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,9 +213,19 @@ public class SlideShow
|
||||||
|
|
||||||
Record[] docChildren = documentRecord.getChildRecords();
|
Record[] docChildren = documentRecord.getChildRecords();
|
||||||
for(int i=0; i<docChildren.length; i++) {
|
for(int i=0; i<docChildren.length; i++) {
|
||||||
|
// Look for SlideListWithText
|
||||||
if(docChildren[i] instanceof SlideListWithText) {
|
if(docChildren[i] instanceof SlideListWithText) {
|
||||||
slwtV.add(docChildren[i]);
|
slwtV.add(docChildren[i]);
|
||||||
}
|
}
|
||||||
|
// Look for FontCollection under Environment
|
||||||
|
if(docChildren[i].getRecordType() == RecordTypes.Environment.typeID) {
|
||||||
|
Record[] envChildren = docChildren[i].getChildRecords();
|
||||||
|
for(int j=0; j<envChildren.length; j++) {
|
||||||
|
if(envChildren[j] instanceof FontCollection) {
|
||||||
|
_fonts = (FontCollection)envChildren[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now, grab out all the sets of Atoms in the SlideListWithText's
|
// For now, grab out all the sets of Atoms in the SlideListWithText's
|
||||||
|
|
Loading…
Reference in New Issue