fixing the build
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353163 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0ff1e673ab
commit
a849b6aaa6
@ -53,9 +53,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hdf.model.hdftypes;
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,15 +73,7 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
*/
|
*/
|
||||||
public class CHPFormattedDiskPage extends FormattedDiskPage
|
public class CHPFormattedDiskPage extends FormattedDiskPage
|
||||||
{
|
{
|
||||||
private static final int FC_SIZE = 4;
|
|
||||||
|
|
||||||
private ArrayList _chpxList = new ArrayList();
|
|
||||||
private ArrayList _overFlow;
|
|
||||||
|
|
||||||
|
|
||||||
public CHPFormattedDiskPage()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
|
* This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
|
||||||
@ -92,29 +81,9 @@ public class CHPFormattedDiskPage extends FormattedDiskPage
|
|||||||
*
|
*
|
||||||
* @param fkp The 512 byte array to read data from
|
* @param fkp The 512 byte array to read data from
|
||||||
*/
|
*/
|
||||||
public CHPFormattedDiskPage(byte[] documentStream, int offset, int fcMin)
|
public CHPFormattedDiskPage(byte[] fkp)
|
||||||
{
|
{
|
||||||
super(documentStream, offset);
|
super(fkp);
|
||||||
|
|
||||||
for (int x = 0; x < _crun; x++)
|
|
||||||
{
|
|
||||||
_chpxList.add(new CHPX(getStart(x) - fcMin, getEnd(x) - fcMin, getGrpprl(x)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CHPX getCHPX(int index)
|
|
||||||
{
|
|
||||||
return (CHPX)_chpxList.get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fill(List filler)
|
|
||||||
{
|
|
||||||
_chpxList.addAll(filler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList getOverflow()
|
|
||||||
{
|
|
||||||
return _overFlow;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,87 +92,22 @@ public class CHPFormattedDiskPage extends FormattedDiskPage
|
|||||||
* @param index The index of the chpx to get.
|
* @param index The index of the chpx to get.
|
||||||
* @return a chpx grpprl.
|
* @return a chpx grpprl.
|
||||||
*/
|
*/
|
||||||
protected byte[] getGrpprl(int index)
|
public byte[] getGrpprl(int index)
|
||||||
{
|
{
|
||||||
int chpxOffset = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + (((_crun + 1) * 4) + index));
|
int chpxOffset = 2 * LittleEndian.getUnsignedByte(_fkp, ((_crun + 1) * 4) + index);
|
||||||
|
|
||||||
//optimization if offset == 0 use "Normal" style
|
//optimization if offset == 0 use "Normal" style
|
||||||
if(chpxOffset == 0)
|
if(chpxOffset == 0)
|
||||||
{
|
{
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = LittleEndian.getUnsignedByte(_fkp, _offset + chpxOffset);
|
int size = LittleEndian.getUnsignedByte(_fkp, chpxOffset);
|
||||||
|
|
||||||
byte[] chpx = new byte[size];
|
byte[] chpx = new byte[size];
|
||||||
|
|
||||||
System.arraycopy(_fkp, _offset + ++chpxOffset, chpx, 0, size);
|
System.arraycopy(_fkp, ++chpxOffset, chpx, 0, size);
|
||||||
return chpx;
|
return chpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte[] toByteArray(int fcMin)
|
|
||||||
{
|
|
||||||
byte[] buf = new byte[512];
|
|
||||||
int size = _chpxList.size();
|
|
||||||
int grpprlOffset = 0;
|
|
||||||
int offsetOffset = 0;
|
|
||||||
int fcOffset = 0;
|
|
||||||
|
|
||||||
// total size is currently the size of one FC
|
|
||||||
int totalSize = FC_SIZE;
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
for (; index < size; index++)
|
|
||||||
{
|
|
||||||
int grpprlLength = ((CHPX)_chpxList.get(index)).getGrpprl().length;
|
|
||||||
|
|
||||||
// check to see if we have enough room for an FC, a byte, and the grpprl.
|
|
||||||
totalSize += (FC_SIZE + 1 + grpprlLength);
|
|
||||||
// if size is uneven we will have to add one so the first grpprl falls
|
|
||||||
// on a word boundary
|
|
||||||
if (totalSize > 511 + (index % 2))
|
|
||||||
{
|
|
||||||
totalSize -= (FC_SIZE + 1 + grpprlLength);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// grpprls must fall on word boundaries
|
|
||||||
if (grpprlLength % 2 > 0)
|
|
||||||
{
|
|
||||||
totalSize += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// see if we couldn't fit some
|
|
||||||
if (index != size)
|
|
||||||
{
|
|
||||||
_overFlow = new ArrayList();
|
|
||||||
_overFlow.addAll(index, _chpxList);
|
|
||||||
}
|
|
||||||
|
|
||||||
// index should equal number of CHPXs that will be in this fkp now.
|
|
||||||
buf[511] = (byte)index;
|
|
||||||
|
|
||||||
offsetOffset = (FC_SIZE * index) + FC_SIZE;
|
|
||||||
grpprlOffset = offsetOffset + index + (grpprlOffset % 2);
|
|
||||||
|
|
||||||
CHPX chpx = null;
|
|
||||||
for (int x = 0; x < index; x++)
|
|
||||||
{
|
|
||||||
chpx = (CHPX)_chpxList.get(x);
|
|
||||||
byte[] grpprl = chpx.getGrpprl();
|
|
||||||
|
|
||||||
LittleEndian.putInt(buf, fcOffset, chpx.getStart() + fcMin);
|
|
||||||
buf[offsetOffset] = (byte)(grpprlOffset/2);
|
|
||||||
System.arraycopy(grpprl, 0, buf, grpprlOffset, grpprl.length);
|
|
||||||
|
|
||||||
grpprlOffset += grpprl.length + (grpprl.length % 2);
|
|
||||||
offsetOffset += 1;
|
|
||||||
fcOffset += FC_SIZE;
|
|
||||||
}
|
|
||||||
// put the last chpx's end in
|
|
||||||
LittleEndian.putInt(buf, fcOffset, chpx.getEnd() + fcMin);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
*
|
*
|
||||||
@ -58,20 +56,35 @@
|
|||||||
package org.apache.poi.hdf.model.hdftypes;
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.hwpf.model.hdftypes.definitions.DOPAbstractType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment me
|
* Comment me
|
||||||
*
|
*
|
||||||
* @author Ryan Ackley
|
* @author Ryan Ackley
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DocumentProperties extends DOPAbstractType
|
public class DocumentProperties implements HDFType
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public boolean _fFacingPages;
|
||||||
|
public int _fpc;
|
||||||
|
public int _epc;
|
||||||
|
public int _rncFtn;
|
||||||
|
public int _nFtn;
|
||||||
|
public int _rncEdn;
|
||||||
|
public int _nEdn;
|
||||||
|
|
||||||
public DocumentProperties(byte[] tableStream, int offset)
|
public DocumentProperties(byte[] dopArray)
|
||||||
{
|
{
|
||||||
super.fillFields(tableStream, (short)0, offset);
|
_fFacingPages = (dopArray[0] & 0x1) > 0;
|
||||||
|
_fpc = (dopArray[0] & 0x60) >> 5;
|
||||||
|
|
||||||
|
short num = LittleEndian.getShort(dopArray, 2);
|
||||||
|
_rncFtn = (num & 0x3);
|
||||||
|
_nFtn = (short)(num & 0xfffc) >> 2;
|
||||||
|
num = LittleEndian.getShort(dopArray, 52);
|
||||||
|
_rncEdn = num & 0x3;
|
||||||
|
_nEdn = (short)(num & 0xfffc) >> 2;
|
||||||
|
num = LittleEndian.getShort(dopArray, 54);
|
||||||
|
_epc = num & 0x3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,65 +1,10 @@
|
|||||||
/*
|
|
||||||
* ====================================================================
|
|
||||||
* The Apache Software License, Version 1.1
|
|
||||||
*
|
|
||||||
* Copyright (c) 2003 The Apache Software Foundation. All rights
|
|
||||||
* reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
*
|
|
||||||
* 3. The end-user documentation included with the redistribution,
|
|
||||||
* if any, must include the following acknowledgment:
|
|
||||||
* "This product includes software developed by the
|
|
||||||
* Apache Software Foundation (http://www.apache.org/)."
|
|
||||||
* Alternately, this acknowledgment may appear in the software itself,
|
|
||||||
* if and wherever such third-party acknowledgments normally appear.
|
|
||||||
*
|
|
||||||
* 4. The names "Apache" and "Apache Software Foundation" and
|
|
||||||
* "Apache POI" must not be used to endorse or promote products
|
|
||||||
* derived from this software without prior written permission. For
|
|
||||||
* written permission, please contact apache@apache.org.
|
|
||||||
*
|
|
||||||
* 5. Products derived from this software may not be called "Apache",
|
|
||||||
* "Apache POI", nor may "Apache" appear in their name, without
|
|
||||||
* prior written permission of the Apache Software Foundation.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
|
||||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
||||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
||||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
* ====================================================================
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many
|
|
||||||
* individuals on behalf of the Apache Software Foundation. For more
|
|
||||||
* information on the Apache Software Foundation, please see
|
|
||||||
* <http://www.apache.org/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.poi.hdf.model.hdftypes;
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
import org.apache.poi.util.BitField;
|
import org.apache.poi.util.BitField;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
|
|
||||||
import org.apache.poi.hwpf.model.hdftypes.definitions.FIBAbstractType;
|
import org.apache.poi.hdf.model.hdftypes.definitions.FIBAbstractType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -359,3 +304,4 @@ public class FileInformationBlock extends FIBAbstractType
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,40 +80,32 @@ public abstract class FormattedDiskPage
|
|||||||
{
|
{
|
||||||
protected byte[] _fkp;
|
protected byte[] _fkp;
|
||||||
protected int _crun;
|
protected int _crun;
|
||||||
protected int _offset;
|
|
||||||
|
|
||||||
|
|
||||||
public FormattedDiskPage()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses a 512-byte array to create a FKP
|
* Uses a 512-byte array to create a FKP
|
||||||
*/
|
*/
|
||||||
public FormattedDiskPage(byte[] documentStream, int offset)
|
public FormattedDiskPage(byte[] fkp)
|
||||||
{
|
{
|
||||||
_crun = LittleEndian.getUnsignedByte(documentStream, offset + 511);
|
_crun = LittleEndian.getUnsignedByte(fkp, 511);
|
||||||
_fkp = documentStream;
|
_fkp = fkp;
|
||||||
_offset = offset;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Used to get a text offset corresponding to a grpprl in this fkp.
|
* Used to get a text offset corresponding to a grpprl in this fkp.
|
||||||
* @param index The index of the property in this FKP
|
* @param index The index of the property in this FKP
|
||||||
* @return an int representing an offset in the "WordDocument" stream
|
* @return an int representing an offset in the "WordDocument" stream
|
||||||
*/
|
*/
|
||||||
protected int getStart(int index)
|
public int getStart(int index)
|
||||||
{
|
{
|
||||||
return LittleEndian.getInt(_fkp, _offset + (index * 4));
|
return LittleEndian.getInt(_fkp, (index * 4));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Used to get the end of the text corresponding to a grpprl in this fkp.
|
* Used to get the end of the text corresponding to a grpprl in this fkp.
|
||||||
* @param index The index of the property in this fkp.
|
* @param index The index of the property in this fkp.
|
||||||
* @return an int representing an offset in the "WordDocument" stream
|
* @return an int representing an offset in the "WordDocument" stream
|
||||||
*/
|
*/
|
||||||
protected int getEnd(int index)
|
public int getEnd(int index)
|
||||||
{
|
{
|
||||||
return LittleEndian.getInt(_fkp, _offset + ((index + 1) * 4));
|
return LittleEndian.getInt(_fkp, ((index + 1) * 4));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Used to get the total number of grrprl's stored int this FKP
|
* Used to get the total number of grrprl's stored int this FKP
|
||||||
@ -124,5 +116,5 @@ public abstract class FormattedDiskPage
|
|||||||
return _crun;
|
return _crun;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract byte[] getGrpprl(int index);
|
public abstract byte[] getGrpprl(int index);
|
||||||
}
|
}
|
||||||
|
@ -53,12 +53,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hdf.model.hdftypes;
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
import org.apache.poi.poifs.common.POIFSConstants;
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a PAP FKP. The style properties for paragraph and character runs
|
* Represents a PAP FKP. The style properties for paragraph and character runs
|
||||||
* are stored in fkps. There are PAP fkps for paragraph properties and CHP fkps
|
* are stored in fkps. There are PAP fkps for paragraph properties and CHP fkps
|
||||||
@ -78,62 +74,29 @@ import java.util.List;
|
|||||||
public class PAPFormattedDiskPage extends FormattedDiskPage
|
public class PAPFormattedDiskPage extends FormattedDiskPage
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final int BX_SIZE = 13;
|
|
||||||
private static final int FC_SIZE = 4;
|
|
||||||
|
|
||||||
private ArrayList _papxList = new ArrayList();
|
|
||||||
private ArrayList _overFlow;
|
|
||||||
|
|
||||||
|
|
||||||
public PAPFormattedDiskPage()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a PAPFormattedDiskPage from a 512 byte array
|
* Creates a PAPFormattedDiskPage from a 512 byte array
|
||||||
*
|
*
|
||||||
* @param fkp a 512 byte array.
|
* @param fkp a 512 byte array.
|
||||||
*/
|
*/
|
||||||
public PAPFormattedDiskPage(byte[] documentStream, int offset, int fcMin)
|
public PAPFormattedDiskPage(byte[] fkp)
|
||||||
{
|
{
|
||||||
super(documentStream, offset);
|
super(fkp);
|
||||||
|
|
||||||
for (int x = 0; x < _crun; x++)
|
|
||||||
{
|
|
||||||
_papxList.add(new PAPX(getStart(x) - fcMin, getEnd(x) - fcMin, getGrpprl(x), getParagraphHeight(x)));
|
|
||||||
}
|
|
||||||
_fkp = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fill(List filler)
|
|
||||||
{
|
|
||||||
_papxList.addAll(filler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList getOverflow()
|
|
||||||
{
|
|
||||||
return _overFlow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PAPX getPAPX(int index)
|
|
||||||
{
|
|
||||||
return (PAPX)_papxList.get(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the papx for the paragraph at index in this fkp.
|
* Gets the papx for the pagraph at index in this fkp.
|
||||||
*
|
*
|
||||||
* @param index The index of the papx to get.
|
* @param index The index of the papx to get.
|
||||||
* @return a papx grpprl.
|
* @return a papx grpprl.
|
||||||
*/
|
*/
|
||||||
protected byte[] getGrpprl(int index)
|
public byte[] getGrpprl(int index)
|
||||||
{
|
{
|
||||||
int papxOffset = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + (((_crun + 1) * FC_SIZE) + (index * BX_SIZE)));
|
int papxOffset = 2 * LittleEndian.getUnsignedByte(_fkp, ((_crun + 1) * 4) + (index * 13));
|
||||||
int size = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + papxOffset);
|
int size = 2 * LittleEndian.getUnsignedByte(_fkp, papxOffset);
|
||||||
if(size == 0)
|
if(size == 0)
|
||||||
{
|
{
|
||||||
size = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + ++papxOffset);
|
size = 2 * LittleEndian.getUnsignedByte(_fkp, ++papxOffset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -141,100 +104,7 @@ public class PAPFormattedDiskPage extends FormattedDiskPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] papx = new byte[size];
|
byte[] papx = new byte[size];
|
||||||
System.arraycopy(_fkp, _offset + ++papxOffset, papx, 0, size);
|
System.arraycopy(_fkp, ++papxOffset, papx, 0, size);
|
||||||
return papx;
|
return papx;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte[] toByteArray(int fcMin)
|
|
||||||
{
|
|
||||||
byte[] buf = new byte[512];
|
|
||||||
int size = _papxList.size();
|
|
||||||
int grpprlOffset = 0;
|
|
||||||
int bxOffset = 0;
|
|
||||||
int fcOffset = 0;
|
|
||||||
|
|
||||||
// total size is currently the size of one FC
|
|
||||||
int totalSize = FC_SIZE;
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
for (; index < size; index++)
|
|
||||||
{
|
|
||||||
int grpprlLength = ((PAPX)_papxList.get(index)).getGrpprl().length;
|
|
||||||
|
|
||||||
// check to see if we have enough room for an FC, a BX, and the grpprl
|
|
||||||
// and the 1 byte size of the grpprl.
|
|
||||||
totalSize += (FC_SIZE + BX_SIZE + grpprlLength + 1);
|
|
||||||
// if size is uneven we will have to add one so the first grpprl falls
|
|
||||||
// on a word boundary
|
|
||||||
if (totalSize > 511 + (index % 2))
|
|
||||||
{
|
|
||||||
totalSize -= (FC_SIZE + BX_SIZE + grpprlLength);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// grpprls must fall on word boundaries
|
|
||||||
if (grpprlLength % 2 > 0)
|
|
||||||
{
|
|
||||||
totalSize += 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
totalSize += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// see if we couldn't fit some
|
|
||||||
if (index != size)
|
|
||||||
{
|
|
||||||
_overFlow = new ArrayList();
|
|
||||||
_overFlow.addAll(index, _papxList);
|
|
||||||
}
|
|
||||||
|
|
||||||
// index should equal number of papxs that will be in this fkp now.
|
|
||||||
buf[511] = (byte)index;
|
|
||||||
|
|
||||||
bxOffset = (FC_SIZE * index) + FC_SIZE;
|
|
||||||
grpprlOffset = bxOffset + (BX_SIZE * index) + (grpprlOffset % 2);
|
|
||||||
|
|
||||||
PAPX papx = null;
|
|
||||||
for (int x = 0; x < index; x++)
|
|
||||||
{
|
|
||||||
papx = (PAPX)_papxList.get(x);
|
|
||||||
byte[] phe = papx.getParagraphHeight().toByteArray();
|
|
||||||
byte[] grpprl = papx.getGrpprl();
|
|
||||||
|
|
||||||
LittleEndian.putInt(buf, fcOffset, papx.getStart() + fcMin);
|
|
||||||
buf[bxOffset] = (byte)(grpprlOffset/2);
|
|
||||||
System.arraycopy(phe, 0, buf, bxOffset + 1, phe.length);
|
|
||||||
|
|
||||||
// refer to the section on PAPX in the spec. Places a size on the front
|
|
||||||
// of the PAPX. Has to do with how the grpprl stays on word
|
|
||||||
// boundaries.
|
|
||||||
if ((grpprl.length % 2) > 0)
|
|
||||||
{
|
|
||||||
buf[grpprlOffset++] = (byte)((grpprl.length + 1)/2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
buf[++grpprlOffset] = (byte)((grpprl.length)/2);
|
|
||||||
grpprlOffset++;
|
|
||||||
}
|
|
||||||
System.arraycopy(grpprl, 0, buf, grpprlOffset, grpprl.length);
|
|
||||||
|
|
||||||
bxOffset += BX_SIZE;
|
|
||||||
fcOffset += FC_SIZE;
|
|
||||||
}
|
|
||||||
// put the last papx's end in
|
|
||||||
LittleEndian.putInt(buf, fcOffset, papx.getEnd() + fcMin);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ParagraphHeight getParagraphHeight(int index)
|
|
||||||
{
|
|
||||||
int pheOffset = 1 + (2 * LittleEndian.getUnsignedByte(_fkp, _offset + (((_crun + 1) * 4) + (index * 13))));
|
|
||||||
|
|
||||||
ParagraphHeight phe = new ParagraphHeight(_fkp, pheOffset);
|
|
||||||
|
|
||||||
return phe;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -53,127 +53,60 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hdf.model.hdftypes;
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* common data structure in a Word file. Contains an array of 4 byte ints in
|
* common data structure in a Word file. Contains an array of 4 byte ints in
|
||||||
* the front that relate to an array of abitrary data structures in the back.
|
* the front that relate to an array of abitrary data structures in the back.
|
||||||
*
|
*
|
||||||
|
* This class acts more like a pointer. In the sense that it doesn't store any
|
||||||
|
* data. It only provides convenience methods for accessing a particular
|
||||||
|
* PlexOfCps
|
||||||
*
|
*
|
||||||
* @author Ryan Ackley
|
* @author Ryan Ackley
|
||||||
*/
|
*/
|
||||||
public class PlexOfCps
|
public class PlexOfCps
|
||||||
{
|
{
|
||||||
private int _count;
|
private int _count;
|
||||||
private int _offset;
|
private int _offset;
|
||||||
private int _sizeOfStruct;
|
private int _sizeOfStruct;
|
||||||
private ArrayList _props;
|
|
||||||
|
|
||||||
|
|
||||||
public PlexOfCps(int sizeOfStruct)
|
/**
|
||||||
{
|
* Constructor
|
||||||
_props = new ArrayList();
|
*
|
||||||
_sizeOfStruct = sizeOfStruct;
|
* @param size The size in bytes of this PlexOfCps
|
||||||
}
|
* @param sizeOfStruct The size of the data structure type stored in
|
||||||
|
* this PlexOfCps.
|
||||||
/**
|
*/
|
||||||
* Constructor
|
public PlexOfCps(int size, int sizeOfStruct)
|
||||||
*
|
|
||||||
* @param size The size in bytes of this PlexOfCps
|
|
||||||
* @param sizeOfStruct The size of the data structure type stored in
|
|
||||||
* this PlexOfCps.
|
|
||||||
*/
|
|
||||||
public PlexOfCps(byte[] buf, int start, int size, int sizeOfStruct)
|
|
||||||
{
|
|
||||||
_count = (size - 4)/(4 + sizeOfStruct);
|
|
||||||
_sizeOfStruct = sizeOfStruct;
|
|
||||||
_props = new ArrayList(_count);
|
|
||||||
|
|
||||||
for (int x = 0; x < _count; x++)
|
|
||||||
{
|
{
|
||||||
_props.add(getProperty(x, buf, start));
|
_count = (size - 4)/(4 + sizeOfStruct);
|
||||||
|
_sizeOfStruct = sizeOfStruct;
|
||||||
}
|
}
|
||||||
}
|
public int getIntOffset(int index)
|
||||||
|
|
||||||
public PropertyNode getProperty(int index)
|
|
||||||
{
|
|
||||||
return (PropertyNode)_props.get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addProperty(PropertyNode node)
|
|
||||||
{
|
|
||||||
_props.add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] toByteArray()
|
|
||||||
{
|
|
||||||
int size = _props.size();
|
|
||||||
int cpBufSize = ((size + 1) * LittleEndian.INT_SIZE);
|
|
||||||
int structBufSize = + (_sizeOfStruct * size);
|
|
||||||
int bufSize = cpBufSize + structBufSize;
|
|
||||||
|
|
||||||
byte[] buf = new byte[bufSize];
|
|
||||||
|
|
||||||
PropertyNode node = null;
|
|
||||||
for (int x = 0; x < size; x++)
|
|
||||||
{
|
{
|
||||||
node = (PropertyNode)_props.get(x);
|
return index * 4;
|
||||||
|
}
|
||||||
// put the starting offset of the property into the plcf.
|
/**
|
||||||
LittleEndian.putInt(buf, (LittleEndian.INT_SIZE * x), node.getStart());
|
* returns the number of data structures in this PlexOfCps.
|
||||||
|
*
|
||||||
// put the struct into the plcf
|
* @return The number of data structures in this PlexOfCps
|
||||||
System.arraycopy(node.getBuf(), 0, buf, cpBufSize + (x * _sizeOfStruct),
|
*/
|
||||||
_sizeOfStruct);
|
public int length()
|
||||||
|
{
|
||||||
|
return _count;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns the offset, in bytes, from the beginning if this PlexOfCps to
|
||||||
|
* the data structure at index.
|
||||||
|
*
|
||||||
|
* @param index The index of the data structure.
|
||||||
|
*
|
||||||
|
* @return The offset, in bytes, from the beginning if this PlexOfCps to
|
||||||
|
* the data structure at index.
|
||||||
|
*/
|
||||||
|
public int getStructOffset(int index)
|
||||||
|
{
|
||||||
|
return (4 * (_count + 1)) + (_sizeOfStruct * index);
|
||||||
}
|
}
|
||||||
// put the ending offset of the last property into the plcf.
|
|
||||||
LittleEndian.putInt(buf, LittleEndian.INT_SIZE * size, node.getEnd());
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private PropertyNode getProperty(int index, byte[] buf, int offset)
|
|
||||||
{
|
|
||||||
int start = LittleEndian.getInt(buf, offset + getIntOffset(index));
|
|
||||||
int end = LittleEndian.getInt(buf, offset + getIntOffset(index+1));
|
|
||||||
|
|
||||||
byte[] struct = new byte[_sizeOfStruct];
|
|
||||||
System.arraycopy(buf, offset + getStructOffset(index), struct, 0, _sizeOfStruct);
|
|
||||||
|
|
||||||
return new PropertyNode(start, end, struct);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getIntOffset(int index)
|
|
||||||
{
|
|
||||||
return index * 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the number of data structures in this PlexOfCps.
|
|
||||||
*
|
|
||||||
* @return The number of data structures in this PlexOfCps
|
|
||||||
*/
|
|
||||||
public int length()
|
|
||||||
{
|
|
||||||
return _count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the offset, in bytes, from the beginning if this PlexOfCps to
|
|
||||||
* the data structure at index.
|
|
||||||
*
|
|
||||||
* @param index The index of the data structure.
|
|
||||||
*
|
|
||||||
* @return The offset, in bytes, from the beginning if this PlexOfCps to
|
|
||||||
* the data structure at index.
|
|
||||||
*/
|
|
||||||
private int getStructOffset(int index)
|
|
||||||
{
|
|
||||||
return (4 * (_count + 1)) + (_sizeOfStruct * index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -54,62 +54,61 @@
|
|||||||
package org.apache.poi.hdf.model.hdftypes;
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a lightweight node in the Trees used to store content
|
* Represents a lightweight node in the Trees used to store formatting
|
||||||
* properties.
|
* properties.
|
||||||
*
|
*
|
||||||
* @author Ryan Ackley
|
* @author Ryan Ackley
|
||||||
*/
|
*/
|
||||||
public class PropertyNode implements Comparable
|
public class PropertyNode implements Comparable
|
||||||
{
|
{
|
||||||
private byte[] _buf;
|
private byte[] _grpprl;
|
||||||
private int _cpStart;
|
private int _fcStart;
|
||||||
private int _cpEnd;
|
private int _fcEnd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fcStart The start of the text for this property.
|
* @param fcStart The start of the text for this property.
|
||||||
* @param fcEnd The end of the text for this property.
|
* @param fcEnd The end of the text for this property.
|
||||||
* @param grpprl The property description in compressed form.
|
* @param grpprl The property description in compressed form.
|
||||||
*/
|
*/
|
||||||
public PropertyNode(int fcStart, int fcEnd, byte[] buf)
|
public PropertyNode(int fcStart, int fcEnd, byte[] grpprl)
|
||||||
{
|
{
|
||||||
_cpStart = fcStart;
|
_fcStart = fcStart;
|
||||||
_cpEnd = fcEnd;
|
_fcEnd = fcEnd;
|
||||||
_buf = buf;
|
_grpprl = grpprl;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return The offset of this property's text.
|
* @return The offset of this property's text.
|
||||||
*/
|
*/
|
||||||
public int getStart()
|
public int getStart()
|
||||||
{
|
{
|
||||||
return _cpStart;
|
return _fcStart;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @retrun The offset of the end of this property's text.
|
* @retrun The offset of the end of this property's text.
|
||||||
*/
|
*/
|
||||||
public int getEnd()
|
public int getEnd()
|
||||||
{
|
{
|
||||||
return _cpEnd;
|
return _fcEnd;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return This property's property in copmpressed form.
|
* @return This property's property in copmpressed form.
|
||||||
*/
|
*/
|
||||||
public byte[] getBuf()
|
protected byte[] getGrpprl()
|
||||||
{
|
{
|
||||||
return _buf;
|
return _grpprl;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Used for sorting in collections.
|
* Used for sorting in collections.
|
||||||
*/
|
*/
|
||||||
public int compareTo(Object o)
|
public int compareTo(Object o)
|
||||||
{
|
{
|
||||||
int cpEnd = ((PropertyNode)o).getEnd();
|
int fcEnd = ((PropertyNode)o).getEnd();
|
||||||
if(_cpEnd == cpEnd)
|
if(_fcEnd == fcEnd)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(_cpEnd < cpEnd)
|
else if(_fcEnd < fcEnd)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
*
|
*
|
||||||
@ -56,10 +55,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.hdf.model.hdftypes;
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.util.BitField;
|
|
||||||
/**
|
/**
|
||||||
* Comment me
|
* Comment me
|
||||||
*
|
*
|
||||||
@ -72,44 +68,27 @@ public class StyleDescription implements HDFType
|
|||||||
private static int PARAGRAPH_STYLE = 1;
|
private static int PARAGRAPH_STYLE = 1;
|
||||||
private static int CHARACTER_STYLE = 2;
|
private static int CHARACTER_STYLE = 2;
|
||||||
|
|
||||||
private short _infoShort;
|
int _baseStyleIndex;
|
||||||
private static BitField _sti = new BitField(0xfff);
|
int _styleTypeCode;
|
||||||
private static BitField _fScratch = new BitField(0x1000);
|
int _numUPX;
|
||||||
private static BitField _fInvalHeight = new BitField(0x2000);
|
|
||||||
private static BitField _fHasUpe = new BitField(0x4000);
|
|
||||||
private static BitField _fMassCopy = new BitField(0x8000);
|
|
||||||
private short _infoShort2;
|
|
||||||
private static BitField _styleTypeCode = new BitField(0xf);
|
|
||||||
private static BitField _baseStyle = new BitField(0xfff0);
|
|
||||||
private static BitField _numUPX = new BitField(0xf);
|
|
||||||
private static BitField _nextStyle = new BitField(0xfff0);
|
|
||||||
private short _bchUpe;
|
|
||||||
private short _infoShort3;
|
|
||||||
private static BitField _fAutoRedef = new BitField(0x1);
|
|
||||||
private static BitField _fHidden = new BitField(0x2);
|
|
||||||
|
|
||||||
byte[] _papx;
|
byte[] _papx;
|
||||||
byte[] _chpx;
|
byte[] _chpx;
|
||||||
String _name;
|
ParagraphProperties _pap;
|
||||||
// ParagraphProperties _pap;
|
CharacterProperties _chp;
|
||||||
// CharacterProperties _chp;
|
|
||||||
|
|
||||||
public StyleDescription()
|
public StyleDescription()
|
||||||
{
|
{
|
||||||
// _pap = new ParagraphProperties();
|
_pap = new ParagraphProperties();
|
||||||
// _chp = new CharacterProperties();
|
_chp = new CharacterProperties();
|
||||||
}
|
}
|
||||||
public StyleDescription(byte[] std, int baseLength, int offset, boolean word9)
|
public StyleDescription(byte[] std, int baseLength, boolean word9)
|
||||||
{
|
{
|
||||||
int nameStart = offset + baseLength;
|
int infoShort = LittleEndian.getShort(std, 2);
|
||||||
_infoShort = LittleEndian.getShort(std, offset);
|
_styleTypeCode = (infoShort & 0xf);
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
_baseStyleIndex = (infoShort & 0xfff0) >> 4;
|
||||||
_infoShort2 = LittleEndian.getShort(std, offset);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
infoShort = LittleEndian.getShort(std, 4);
|
||||||
_bchUpe = LittleEndian.getShort(std, offset);
|
_numUPX = infoShort & 0xf;
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
_infoShort3 = LittleEndian.getShort(std, offset);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
|
|
||||||
//first byte(s) of variable length section of std is the length of the
|
//first byte(s) of variable length section of std is the length of the
|
||||||
//style name and aliases string
|
//style name and aliases string
|
||||||
@ -117,66 +96,52 @@ public class StyleDescription implements HDFType
|
|||||||
int multiplier = 1;
|
int multiplier = 1;
|
||||||
if(word9)
|
if(word9)
|
||||||
{
|
{
|
||||||
nameLength = LittleEndian.getShort(std, nameStart);
|
nameLength = LittleEndian.getShort(std, baseLength);
|
||||||
multiplier = 2;
|
multiplier = 2;
|
||||||
nameStart += LittleEndian.SHORT_SIZE;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nameLength = std[nameStart];
|
nameLength = std[baseLength];
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_name = new String(std, nameStart, nameLength * multiplier, "UTF-16LE");
|
|
||||||
}
|
|
||||||
catch (UnsupportedEncodingException ignore)
|
|
||||||
{
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
//2 bytes for length, length then null terminator.
|
//2 bytes for length, length then null terminator.
|
||||||
int grupxStart = multiplier + ((nameLength + 1) * multiplier) + nameStart;
|
int grupxStart = multiplier + ((nameLength + 1) * multiplier) + baseLength;
|
||||||
|
|
||||||
// the spec only refers to two possible upxs but it mentions
|
int offset = 0;
|
||||||
// that more may be added in the future
|
for(int x = 0; x < _numUPX; x++)
|
||||||
int add = 0;
|
|
||||||
int numUPX = _numUPX.getValue(_infoShort2);
|
|
||||||
for(int x = 0; x < numUPX; x++)
|
|
||||||
{
|
{
|
||||||
int upxSize = LittleEndian.getShort(std, grupxStart + add);
|
int upxSize = LittleEndian.getShort(std, grupxStart + offset);
|
||||||
if(_styleTypeCode.getValue(_infoShort2) == PARAGRAPH_STYLE)
|
if(_styleTypeCode == PARAGRAPH_STYLE)
|
||||||
{
|
{
|
||||||
if(x == 0)
|
if(x == 0)
|
||||||
{
|
{
|
||||||
_papx = new byte[upxSize];
|
_papx = new byte[upxSize];
|
||||||
System.arraycopy(std, grupxStart + add + 2, _papx, 0, upxSize);
|
System.arraycopy(std, grupxStart + offset + 2, _papx, 0, upxSize);
|
||||||
}
|
}
|
||||||
else if(x == 1)
|
else if(x == 1)
|
||||||
{
|
{
|
||||||
_chpx = new byte[upxSize];
|
_chpx = new byte[upxSize];
|
||||||
System.arraycopy(std, grupxStart + add + 2, _chpx, 0, upxSize);
|
System.arraycopy(std, grupxStart + offset + 2, _chpx, 0, upxSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(_styleTypeCode.getValue(_infoShort2) == CHARACTER_STYLE && x == 0)
|
else if(_styleTypeCode == CHARACTER_STYLE && x == 0)
|
||||||
{
|
{
|
||||||
_chpx = new byte[upxSize];
|
_chpx = new byte[upxSize];
|
||||||
System.arraycopy(std, grupxStart + add + 2, _chpx, 0, upxSize);
|
System.arraycopy(std, grupxStart + offset + 2, _chpx, 0, upxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the upx will always start on a word boundary.
|
|
||||||
if(upxSize % 2 == 1)
|
if(upxSize % 2 == 1)
|
||||||
{
|
{
|
||||||
++upxSize;
|
++upxSize;
|
||||||
}
|
}
|
||||||
add += 2 + upxSize;
|
offset += 2 + upxSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public int getBaseStyle()
|
public int getBaseStyle()
|
||||||
{
|
{
|
||||||
return _baseStyle.getValue(_infoShort2);
|
return _baseStyleIndex;
|
||||||
}
|
}
|
||||||
public byte[] getCHPX()
|
public byte[] getCHPX()
|
||||||
{
|
{
|
||||||
@ -186,83 +151,20 @@ public class StyleDescription implements HDFType
|
|||||||
{
|
{
|
||||||
return _papx;
|
return _papx;
|
||||||
}
|
}
|
||||||
// public ParagraphProperties getPAP()
|
public ParagraphProperties getPAP()
|
||||||
// {
|
|
||||||
// return _pap;
|
|
||||||
// }
|
|
||||||
// public CharacterProperties getCHP()
|
|
||||||
// {
|
|
||||||
// return _chp;
|
|
||||||
// }
|
|
||||||
// public void setPAP(ParagraphProperties pap)
|
|
||||||
// {
|
|
||||||
// _pap = pap;
|
|
||||||
// }
|
|
||||||
// public void setCHP(CharacterProperties chp)
|
|
||||||
// {
|
|
||||||
// _chp = chp;
|
|
||||||
// }
|
|
||||||
public byte[] toByteArray()
|
|
||||||
{
|
{
|
||||||
// size equals 8 bytes for known variables plus 2 bytes for name length plus
|
return _pap;
|
||||||
// name length * 2 plus 2 bytes for null plus upx's preceded by length
|
}
|
||||||
int size = 8 + 2 + ((_name.length() + 1) * 2);
|
public CharacterProperties getCHP()
|
||||||
|
{
|
||||||
//only worry about papx and chpx for upxs
|
return _chp;
|
||||||
if(_styleTypeCode.getValue(_infoShort2) == PARAGRAPH_STYLE)
|
}
|
||||||
{
|
public void setPAP(ParagraphProperties pap)
|
||||||
size += _papx.length + 2 + (_papx.length % 2);
|
{
|
||||||
size += _chpx.length + 2;
|
_pap = pap;
|
||||||
}
|
}
|
||||||
else if (_styleTypeCode.getValue(_infoShort2) == CHARACTER_STYLE)
|
public void setCHP(CharacterProperties chp)
|
||||||
{
|
{
|
||||||
size += _chpx.length + 2;
|
_chp = chp;
|
||||||
}
|
|
||||||
|
|
||||||
byte[] buf = new byte[size];
|
|
||||||
|
|
||||||
int offset = 0;
|
|
||||||
LittleEndian.putShort(buf, offset, _infoShort);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
LittleEndian.putShort(buf, offset, _infoShort2);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
LittleEndian.putShort(buf, offset, _bchUpe);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
LittleEndian.putShort(buf, offset, _infoShort3);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
|
|
||||||
char[] letters = _name.toCharArray();
|
|
||||||
LittleEndian.putShort(buf, offset, (short)letters.length);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
for (int x = 0; x < letters.length; x++)
|
|
||||||
{
|
|
||||||
LittleEndian.putShort(buf, offset, (short)letters[x]);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
}
|
|
||||||
// get past the null delimiter for the name.
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
|
|
||||||
//only worry about papx and chpx for upxs
|
|
||||||
if(_styleTypeCode.getValue(_infoShort2) == PARAGRAPH_STYLE)
|
|
||||||
{
|
|
||||||
LittleEndian.putShort(buf, offset, (short)_papx.length);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
System.arraycopy(_papx, 0, buf, offset, _papx.length);
|
|
||||||
offset += _papx.length + (_papx.length % 2);
|
|
||||||
|
|
||||||
LittleEndian.putShort(buf, offset, (short)_chpx.length);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
System.arraycopy(_chpx, 0, buf, offset, _chpx.length);
|
|
||||||
offset += _chpx.length;
|
|
||||||
}
|
|
||||||
else if (_styleTypeCode.getValue(_infoShort2) == CHARACTER_STYLE)
|
|
||||||
{
|
|
||||||
LittleEndian.putShort(buf, offset, (short)_chpx.length);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
System.arraycopy(_chpx, 0, buf, offset, _chpx.length);
|
|
||||||
offset += _chpx.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -66,7 +66,6 @@ public class TextPiece extends PropertyNode implements Comparable
|
|||||||
{
|
{
|
||||||
private boolean _usesUnicode;
|
private boolean _usesUnicode;
|
||||||
private int _length;
|
private int _length;
|
||||||
private PieceDescriptor _pd;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param start Offset in main document stream.
|
* @param start Offset in main document stream.
|
||||||
@ -74,11 +73,12 @@ public class TextPiece extends PropertyNode implements Comparable
|
|||||||
* does not necessarily refer to 1 byte.
|
* does not necessarily refer to 1 byte.
|
||||||
* @param unicode true if this text is unicode.
|
* @param unicode true if this text is unicode.
|
||||||
*/
|
*/
|
||||||
public TextPiece(int start, int end, byte[] text, PieceDescriptor pd)
|
public TextPiece(int start, int length, boolean unicode)
|
||||||
{
|
{
|
||||||
super(start, end, text);
|
super(start, start + length, null);
|
||||||
_usesUnicode = pd.isUnicode();
|
_usesUnicode = unicode;
|
||||||
_length = end - start;
|
_length = length;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return If this text piece uses unicode
|
* @return If this text piece uses unicode
|
||||||
@ -87,9 +87,5 @@ public class TextPiece extends PropertyNode implements Comparable
|
|||||||
{
|
{
|
||||||
return _usesUnicode;
|
return _usesUnicode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PieceDescriptor getPieceDescriptor()
|
|
||||||
{
|
|
||||||
return _pd;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user