Rename EscherRecordHolder to OfficeArtContent

While the class does indeed hold EscherRecords, due to recent refactoring it is much more structured now than it was before. The contents of the class now closely resemble the OfficeArtContent structure referenced in the MS-DOC spec. Naming the class after the specification structure makes it easier to find and understand.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1887009 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Marius Volkhart 2021-02-28 19:18:13 +00:00
parent 9c88bb2201
commit e7b9a5af13
6 changed files with 29 additions and 28 deletions

View File

@ -31,7 +31,6 @@ import org.apache.poi.hwpf.model.BookmarksTables;
import org.apache.poi.hwpf.model.CHPBinTable;
import org.apache.poi.hwpf.model.ComplexFileTable;
import org.apache.poi.hwpf.model.DocumentProperties;
import org.apache.poi.hwpf.model.EscherRecordHolder;
import org.apache.poi.hwpf.model.FSPADocumentPart;
import org.apache.poi.hwpf.model.FSPATable;
import org.apache.poi.hwpf.model.FieldsTables;
@ -39,6 +38,7 @@ import org.apache.poi.hwpf.model.FontTable;
import org.apache.poi.hwpf.model.ListTables;
import org.apache.poi.hwpf.model.NoteType;
import org.apache.poi.hwpf.model.NotesTables;
import org.apache.poi.hwpf.model.OfficeArtContent;
import org.apache.poi.hwpf.model.PAPBinTable;
import org.apache.poi.hwpf.model.PicturesTable;
import org.apache.poi.hwpf.model.RevisionMarkAuthorTable;
@ -134,9 +134,9 @@ public final class HWPFDocument extends HWPFDocumentCore {
private FSPATable _fspaMain;
/**
* Escher Drawing Group information
* Office Art (Escher records) information
*/
private EscherRecordHolder _escherRecordHolder;
private final OfficeArtContent officeArtContent;
/**
* Holds pictures table
@ -309,14 +309,14 @@ public final class HWPFDocument extends HWPFDocumentCore {
FSPADocumentPart.HEADER);
_fspaMain = new FSPATable(_tableStream, _fib, FSPADocumentPart.MAIN);
_escherRecordHolder = new EscherRecordHolder(_tableStream, _fib.getFcDggInfo(), _fib.getLcbDggInfo());
officeArtContent = new OfficeArtContent(_tableStream, _fib.getFcDggInfo(), _fib.getLcbDggInfo());
// read in the pictures stream
_pictures = new PicturesTable(this, _dataStream, _mainStream, _fspaMain, _escherRecordHolder);
_pictures = new PicturesTable(this, _dataStream, _mainStream, _fspaMain, officeArtContent);
// And escher pictures
_officeDrawingsHeaders = new OfficeDrawingsImpl(_fspaHeaders, _escherRecordHolder, _mainStream);
_officeDrawingsMain = new OfficeDrawingsImpl(_fspaMain, _escherRecordHolder, _mainStream);
_officeDrawingsHeaders = new OfficeDrawingsImpl(_fspaHeaders, officeArtContent, _mainStream);
_officeDrawingsMain = new OfficeDrawingsImpl(_fspaMain, officeArtContent, _mainStream);
_st = new SectionTable(_mainStream, _tableStream, _fib.getFcPlcfsed(), _fib.getLcbPlcfsed(), fcMin, _tpt, _fib.getSubdocumentTextStreamLength(SubdocumentType.MAIN));
_ss = new StyleSheet(_tableStream, _fib.getFcStshf());
@ -513,8 +513,8 @@ public final class HWPFDocument extends HWPFDocumentCore {
}
@Internal
public EscherRecordHolder getEscherRecordHolder() {
return _escherRecordHolder;
public OfficeArtContent getOfficeArtContent() {
return officeArtContent;
}
public OfficeDrawings getOfficeDrawingsHeaders() {

View File

@ -64,7 +64,6 @@ import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.Entry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.Beta;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
/**
@ -367,7 +366,7 @@ public final class HWPFLister {
return;
}
System.out.println( ( (HWPFDocument) _doc ).getEscherRecordHolder() );
System.out.println( ( (HWPFDocument) _doc ).getOfficeArtContent() );
}
public void dumpFIB() {

View File

@ -1005,7 +1005,7 @@ public final class FileInformationBlock {
}
/**
* @return Offset in the Table Stream at which the {@link EscherRecordHolder} exists.
* @return Offset in the Table Stream at which the {@link OfficeArtContent} exists.
*/
public int getFcDggInfo()
{
@ -1013,11 +1013,11 @@ public final class FileInformationBlock {
}
/**
* Returns the size, in bytes, of the {@link EscherRecordHolder} at the offset {@link #getFcDggInfo()}.
* Returns the size, in bytes, of the {@link OfficeArtContent} at the offset {@link #getFcDggInfo()}.
* <p>
* If {@code 0}, there MUST NOT be any drawings in the document.
*
* @return Size, in bytes, of the {@link EscherRecordHolder} at the offset {@link #getFcDggInfo()}.
* @return Size, in bytes, of the {@link OfficeArtContent} at the offset {@link #getFcDggInfo()}.
*/
public int getLcbDggInfo()
{

View File

@ -31,12 +31,14 @@ import org.apache.poi.util.Internal;
import static org.apache.logging.log4j.util.Unbox.box;
/**
* Based on AbstractEscherRecordHolder from HSSF.
* Information about drawings in the document.
* <p>
* The {@code delay stream} referenced in {@code [MS-ODRAW]} is the {@code WordDocument} stream.
*
* @author Squeeself
*/
@Internal
public final class EscherRecordHolder {
public final class OfficeArtContent {
/**
* {@link EscherRecordTypes#DGG_CONTAINER} containing drawing group information for the document.
@ -59,7 +61,7 @@ public final class EscherRecordHolder {
*/
private EscherContainerRecord headerDocumentDgContainer;
public EscherRecordHolder(byte[] data, int offset, int size) {
public OfficeArtContent(byte[] data, int offset, int size) {
fillEscherRecords(data, offset, size);
}
@ -107,7 +109,7 @@ public final class EscherRecordHolder {
headerDocumentDgContainer = dgContainer;
break;
default:
LogManager.getLogger(EscherRecordHolder.class).atWarn()
LogManager.getLogger(OfficeArtContent.class).atWarn()
.log("dgglbl {} for OfficeArtWordDrawing is out of bounds [0, 1]", box(dgglbl));
}
}
@ -180,7 +182,7 @@ public final class EscherRecordHolder {
@Override
public String toString() {
return "EscherRecordHolder{" +
return "OfficeArtContent{" +
"drawingGroupData=" + drawingGroupData +
", mainDocumentDgContainer=" + mainDocumentDgContainer +
", headerDocumentDgContainer=" + headerDocumentDgContainer +

View File

@ -72,7 +72,7 @@ public final class PicturesTable {
@Deprecated
private FSPATable _fspa;
@Deprecated
private EscherRecordHolder _dgg;
private OfficeArtContent _dgg;
/** @link dependency
* @stereotype instantiate*/
@ -84,7 +84,7 @@ public final class PicturesTable {
* @param _dataStream
*/
@Deprecated
public PicturesTable(HWPFDocument _document, byte[] _dataStream, byte[] _mainStream, FSPATable fspa, EscherRecordHolder dgg)
public PicturesTable(HWPFDocument _document, byte[] _dataStream, byte[] _mainStream, FSPATable fspa, OfficeArtContent dgg)
{
this._document = _document;
this._dataStream = _dataStream;

View File

@ -32,27 +32,27 @@ import org.apache.poi.ddf.EscherRecordFactory;
import org.apache.poi.ddf.EscherSimpleProperty;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.ddf.EscherTertiaryOptRecord;
import org.apache.poi.hwpf.model.EscherRecordHolder;
import org.apache.poi.hwpf.model.FSPA;
import org.apache.poi.hwpf.model.FSPATable;
import org.apache.poi.hwpf.model.OfficeArtContent;
public class OfficeDrawingsImpl implements OfficeDrawings
{
private final EscherRecordHolder _escherRecordHolder;
private final OfficeArtContent officeArtContent;
private final FSPATable _fspaTable;
private final byte[] _mainStream;
public OfficeDrawingsImpl( FSPATable fspaTable,
EscherRecordHolder escherRecordHolder, byte[] mainStream )
public OfficeDrawingsImpl(FSPATable fspaTable,
OfficeArtContent officeArtContent, byte[] mainStream )
{
this._fspaTable = fspaTable;
this._escherRecordHolder = escherRecordHolder;
this.officeArtContent = officeArtContent;
this._mainStream = mainStream;
}
private EscherBlipRecord getBitmapRecord( int bitmapIndex )
{
List<? extends EscherContainerRecord> bContainers = _escherRecordHolder
List<? extends EscherContainerRecord> bContainers = officeArtContent
.getBStoreContainers();
if ( bContainers == null || bContainers.size() != 1 )
return null;
@ -105,7 +105,7 @@ public class OfficeDrawingsImpl implements OfficeDrawings
private EscherContainerRecord getEscherShapeRecordContainer(
final int shapeId )
{
for ( EscherContainerRecord spContainer : _escherRecordHolder
for ( EscherContainerRecord spContainer : officeArtContent
.getSpContainers() )
{
EscherSpRecord escherSpRecord = spContainer