whitespace (2 spaces or tabs to 4 spaces)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748489 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f2390589dc
commit
aeddbc05e4
@ -1,18 +1,18 @@
|
|||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
this work for additional information regarding copyright ownership.
|
this work for additional information regarding copyright ownership.
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
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 not use this file except in compliance with
|
||||||
the License. You may obtain a copy of the License at
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.hwpf.model;
|
package org.apache.poi.hwpf.model;
|
||||||
@ -37,83 +37,83 @@ import org.apache.poi.util.POILogger;
|
|||||||
@Internal
|
@Internal
|
||||||
public final class FontTable
|
public final class FontTable
|
||||||
{
|
{
|
||||||
private final static POILogger _logger = POILogFactory.getLogger(FontTable.class);
|
private final static POILogger _logger = POILogFactory.getLogger(FontTable.class);
|
||||||
private short _stringCount;// how many strings are included in the string table
|
private short _stringCount;// how many strings are included in the string table
|
||||||
private short _extraDataSz;// size in bytes of the extra data
|
private short _extraDataSz;// size in bytes of the extra data
|
||||||
|
|
||||||
// added extra facilitator members
|
// added extra facilitator members
|
||||||
private int lcbSttbfffn;// count of bytes in sttbfffn
|
private int lcbSttbfffn;// count of bytes in sttbfffn
|
||||||
private int fcSttbfffn;// table stream offset for sttbfffn
|
private int fcSttbfffn;// table stream offset for sttbfffn
|
||||||
|
|
||||||
// FFN structure containing strings of font names
|
// FFN structure containing strings of font names
|
||||||
private Ffn[] _fontNames = null;
|
private Ffn[] _fontNames = null;
|
||||||
|
|
||||||
|
|
||||||
public FontTable(byte[] buf, int offset, int lcbSttbfffn)
|
public FontTable(byte[] buf, int offset, int lcbSttbfffn)
|
||||||
{
|
|
||||||
this.lcbSttbfffn = lcbSttbfffn;
|
|
||||||
this.fcSttbfffn = offset;
|
|
||||||
|
|
||||||
_stringCount = LittleEndian.getShort(buf, offset);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
_extraDataSz = LittleEndian.getShort(buf, offset);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
|
|
||||||
_fontNames = new Ffn[_stringCount]; //Ffn corresponds to a Pascal style String in STTBF.
|
|
||||||
|
|
||||||
for(int i = 0;i<_stringCount; i++)
|
|
||||||
{
|
{
|
||||||
_fontNames[i] = new Ffn(buf,offset);
|
this.lcbSttbfffn = lcbSttbfffn;
|
||||||
offset += _fontNames[i].getSize();
|
this.fcSttbfffn = offset;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getStringCount()
|
_stringCount = LittleEndian.getShort(buf, offset);
|
||||||
{
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
return _stringCount;
|
_extraDataSz = LittleEndian.getShort(buf, offset);
|
||||||
}
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
|
|
||||||
public short getExtraDataSz()
|
_fontNames = new Ffn[_stringCount]; //Ffn corresponds to a Pascal style String in STTBF.
|
||||||
{
|
|
||||||
return _extraDataSz;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Ffn[] getFontNames()
|
for(int i = 0;i<_stringCount; i++)
|
||||||
{
|
{
|
||||||
return _fontNames;
|
_fontNames[i] = new Ffn(buf,offset);
|
||||||
}
|
offset += _fontNames[i].getSize();
|
||||||
|
}
|
||||||
public int getSize()
|
|
||||||
{
|
|
||||||
return lcbSttbfffn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMainFont(int chpFtc )
|
|
||||||
{
|
|
||||||
if(chpFtc >= _stringCount)
|
|
||||||
{
|
|
||||||
_logger.log(POILogger.INFO, "Mismatch in chpFtc with stringCount");
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return _fontNames[chpFtc].getMainFontName();
|
public short getStringCount()
|
||||||
}
|
|
||||||
|
|
||||||
public String getAltFont(int chpFtc )
|
|
||||||
{
|
|
||||||
if(chpFtc >= _stringCount)
|
|
||||||
{
|
{
|
||||||
_logger.log(POILogger.INFO, "Mismatch in chpFtc with stringCount");
|
return _stringCount;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return _fontNames[chpFtc].getAltFontName();
|
public short getExtraDataSz()
|
||||||
}
|
{
|
||||||
|
return _extraDataSz;
|
||||||
|
}
|
||||||
|
|
||||||
public void setStringCount(short stringCount)
|
public Ffn[] getFontNames()
|
||||||
{
|
{
|
||||||
this._stringCount = stringCount;
|
return _fontNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSize()
|
||||||
|
{
|
||||||
|
return lcbSttbfffn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMainFont(int chpFtc )
|
||||||
|
{
|
||||||
|
if(chpFtc >= _stringCount)
|
||||||
|
{
|
||||||
|
_logger.log(POILogger.INFO, "Mismatch in chpFtc with stringCount");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _fontNames[chpFtc].getMainFontName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAltFont(int chpFtc )
|
||||||
|
{
|
||||||
|
if(chpFtc >= _stringCount)
|
||||||
|
{
|
||||||
|
_logger.log(POILogger.INFO, "Mismatch in chpFtc with stringCount");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _fontNames[chpFtc].getAltFontName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStringCount(short stringCount)
|
||||||
|
{
|
||||||
|
this._stringCount = stringCount;
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void writeTo( HWPFFileSystem sys ) throws IOException
|
public void writeTo( HWPFFileSystem sys ) throws IOException
|
||||||
@ -124,40 +124,40 @@ public final class FontTable
|
|||||||
|
|
||||||
public void writeTo( HWPFOutputStream tableStream ) throws IOException
|
public void writeTo( HWPFOutputStream tableStream ) throws IOException
|
||||||
{
|
{
|
||||||
byte[] buf = new byte[LittleEndian.SHORT_SIZE];
|
byte[] buf = new byte[LittleEndian.SHORT_SIZE];
|
||||||
LittleEndian.putShort(buf, 0, _stringCount);
|
LittleEndian.putShort(buf, 0, _stringCount);
|
||||||
tableStream.write(buf);
|
tableStream.write(buf);
|
||||||
LittleEndian.putShort(buf, 0, _extraDataSz);
|
LittleEndian.putShort(buf, 0, _extraDataSz);
|
||||||
tableStream.write(buf);
|
tableStream.write(buf);
|
||||||
|
|
||||||
for(int i = 0; i < _fontNames.length; i++)
|
for(int i = 0; i < _fontNames.length; i++)
|
||||||
{
|
{
|
||||||
tableStream.write(_fontNames[i].toByteArray());
|
tableStream.write(_fontNames[i].toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (!(other instanceof FontTable)) return false;
|
if (!(other instanceof FontTable)) return false;
|
||||||
FontTable o = (FontTable)other;
|
FontTable o = (FontTable)other;
|
||||||
|
|
||||||
if (o._stringCount != this._stringCount
|
if (o._stringCount != this._stringCount
|
||||||
|| o._extraDataSz != this._extraDataSz
|
|| o._extraDataSz != this._extraDataSz
|
||||||
|| o._fontNames.length != this._fontNames.length
|
|| o._fontNames.length != this._fontNames.length
|
||||||
) return false;
|
) return false;
|
||||||
|
|
||||||
for (int i=0; i<o._fontNames.length; i++) {
|
for (int i=0; i<o._fontNames.length; i++) {
|
||||||
if (!o._fontNames[i].equals(this._fontNames[i])) return false;
|
if (!o._fontNames[i].equals(this._fontNames[i])) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
assert false : "hashCode not designed";
|
assert false : "hashCode not designed";
|
||||||
return 42; // any arbitrary constant will do
|
return 42; // any arbitrary constant will do
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
this work for additional information regarding copyright ownership.
|
this work for additional information regarding copyright ownership.
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
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 not use this file except in compliance with
|
||||||
the License. You may obtain a copy of the License at
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.hwpf.model;
|
package org.apache.poi.hwpf.model;
|
||||||
@ -29,8 +29,8 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
* DANGER - works in bytes!
|
* DANGER - works in bytes!
|
||||||
*
|
*
|
||||||
* Make sure you call getStart() / getEnd() when you want characters
|
* Make sure you call getStart() / getEnd() when you want characters
|
||||||
* (normal use), but getStartByte() / getEndByte() when you're
|
* (normal use), but getStartByte() / getEndByte() when you're
|
||||||
* reading in / writing out!
|
* reading in / writing out!
|
||||||
*
|
*
|
||||||
* @author Ryan Ackley
|
* @author Ryan Ackley
|
||||||
*/
|
*/
|
||||||
@ -38,16 +38,16 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
@SuppressWarnings( "deprecation" )
|
@SuppressWarnings( "deprecation" )
|
||||||
public final class PAPX extends BytePropertyNode<PAPX> {
|
public final class PAPX extends BytePropertyNode<PAPX> {
|
||||||
|
|
||||||
private ParagraphHeight _phe;
|
private ParagraphHeight _phe;
|
||||||
|
|
||||||
public PAPX(int fcStart, int fcEnd, CharIndexTranslator translator, byte[] papx, ParagraphHeight phe, byte[] dataStream)
|
public PAPX(int fcStart, int fcEnd, CharIndexTranslator translator, byte[] papx, ParagraphHeight phe, byte[] dataStream)
|
||||||
{
|
{
|
||||||
super(fcStart, fcEnd, translator, new SprmBuffer(papx, 2));
|
super(fcStart, fcEnd, translator, new SprmBuffer(papx, 2));
|
||||||
_phe = phe;
|
_phe = phe;
|
||||||
SprmBuffer buf = findHuge(new SprmBuffer(papx, 2), dataStream);
|
SprmBuffer buf = findHuge(new SprmBuffer(papx, 2), dataStream);
|
||||||
if(buf != null)
|
if(buf != null)
|
||||||
_buf = buf;
|
_buf = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PAPX( int charStart, int charEnd, byte[] papx, ParagraphHeight phe,
|
public PAPX( int charStart, int charEnd, byte[] papx, ParagraphHeight phe,
|
||||||
byte[] dataStream )
|
byte[] dataStream )
|
||||||
@ -60,14 +60,14 @@ public final class PAPX extends BytePropertyNode<PAPX> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PAPX(int fcStart, int fcEnd, CharIndexTranslator translator, SprmBuffer buf, byte[] dataStream)
|
public PAPX(int fcStart, int fcEnd, CharIndexTranslator translator, SprmBuffer buf, byte[] dataStream)
|
||||||
{
|
{
|
||||||
super(fcStart, fcEnd, translator, buf);
|
super(fcStart, fcEnd, translator, buf);
|
||||||
_phe = new ParagraphHeight();
|
_phe = new ParagraphHeight();
|
||||||
buf = findHuge(buf, dataStream);
|
buf = findHuge(buf, dataStream);
|
||||||
if(buf != null)
|
if(buf != null)
|
||||||
_buf = buf;
|
_buf = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PAPX( int charStart, int charEnd, SprmBuffer buf )
|
public PAPX( int charStart, int charEnd, SprmBuffer buf )
|
||||||
{
|
{
|
||||||
@ -75,105 +75,105 @@ public final class PAPX extends BytePropertyNode<PAPX> {
|
|||||||
_phe = new ParagraphHeight();
|
_phe = new ParagraphHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SprmBuffer findHuge(SprmBuffer buf, byte[] datastream)
|
private SprmBuffer findHuge(SprmBuffer buf, byte[] datastream)
|
||||||
{
|
|
||||||
byte[] grpprl = buf.toByteArray();
|
|
||||||
if(grpprl.length==8 && datastream!=null) // then check for sprmPHugePapx
|
|
||||||
{
|
{
|
||||||
SprmOperation sprm = new SprmOperation(grpprl, 2);
|
byte[] grpprl = buf.toByteArray();
|
||||||
if ((sprm.getOperation()==0x45 || sprm.getOperation()==0x46)
|
if(grpprl.length==8 && datastream!=null) // then check for sprmPHugePapx
|
||||||
&& sprm.getSizeCode() == 3)
|
|
||||||
{
|
|
||||||
int hugeGrpprlOffset = sprm.getOperand();
|
|
||||||
if(hugeGrpprlOffset+1 < datastream.length)
|
|
||||||
{
|
{
|
||||||
int grpprlSize = LittleEndian.getShort(datastream, hugeGrpprlOffset);
|
SprmOperation sprm = new SprmOperation(grpprl, 2);
|
||||||
if( hugeGrpprlOffset+grpprlSize < datastream.length)
|
if ((sprm.getOperation()==0x45 || sprm.getOperation()==0x46)
|
||||||
{
|
&& sprm.getSizeCode() == 3)
|
||||||
byte[] hugeGrpprl = new byte[grpprlSize + 2];
|
{
|
||||||
// copy original istd into huge Grpprl
|
int hugeGrpprlOffset = sprm.getOperand();
|
||||||
hugeGrpprl[0] = grpprl[0]; hugeGrpprl[1] = grpprl[1];
|
if(hugeGrpprlOffset+1 < datastream.length)
|
||||||
// copy Grpprl from dataStream
|
{
|
||||||
System.arraycopy(datastream, hugeGrpprlOffset + 2, hugeGrpprl, 2,
|
int grpprlSize = LittleEndian.getShort(datastream, hugeGrpprlOffset);
|
||||||
grpprlSize);
|
if( hugeGrpprlOffset+grpprlSize < datastream.length)
|
||||||
return new SprmBuffer(hugeGrpprl, 2);
|
{
|
||||||
}
|
byte[] hugeGrpprl = new byte[grpprlSize + 2];
|
||||||
|
// copy original istd into huge Grpprl
|
||||||
|
hugeGrpprl[0] = grpprl[0]; hugeGrpprl[1] = grpprl[1];
|
||||||
|
// copy Grpprl from dataStream
|
||||||
|
System.arraycopy(datastream, hugeGrpprlOffset + 2, hugeGrpprl, 2,
|
||||||
|
grpprlSize);
|
||||||
|
return new SprmBuffer(hugeGrpprl, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ParagraphHeight getParagraphHeight()
|
public ParagraphHeight getParagraphHeight()
|
||||||
{
|
{
|
||||||
return _phe;
|
return _phe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getGrpprl()
|
public byte[] getGrpprl()
|
||||||
{
|
{
|
||||||
if (_buf == null)
|
if (_buf == null)
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
|
|
||||||
return ((SprmBuffer)_buf).toByteArray();
|
return ((SprmBuffer)_buf).toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getIstd()
|
public short getIstd()
|
||||||
{
|
{
|
||||||
if ( _buf == null )
|
if ( _buf == null )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
byte[] buf = getGrpprl();
|
||||||
|
if (buf.length == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (buf.length == 1)
|
||||||
|
{
|
||||||
|
return LittleEndian.getUByte(buf, 0);
|
||||||
|
}
|
||||||
|
return LittleEndian.getShort(buf);
|
||||||
|
}
|
||||||
|
|
||||||
byte[] buf = getGrpprl();
|
public SprmBuffer getSprmBuf()
|
||||||
if (buf.length == 0)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return (SprmBuffer)_buf;
|
||||||
}
|
}
|
||||||
if (buf.length == 1)
|
|
||||||
|
@Deprecated
|
||||||
|
@Internal
|
||||||
|
public ParagraphProperties getParagraphProperties(StyleSheet ss)
|
||||||
{
|
{
|
||||||
return LittleEndian.getUByte(buf, 0);
|
if(ss == null) {
|
||||||
|
// TODO Fix up for Word 6/95
|
||||||
|
return new ParagraphProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
short istd = getIstd();
|
||||||
|
ParagraphProperties baseStyle = ss.getParagraphStyle(istd);
|
||||||
|
ParagraphProperties props = ParagraphSprmUncompressor.uncompressPAP(baseStyle, getGrpprl(), 2);
|
||||||
|
return props;
|
||||||
}
|
}
|
||||||
return LittleEndian.getShort(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SprmBuffer getSprmBuf()
|
@Override
|
||||||
{
|
public boolean equals(Object o)
|
||||||
return (SprmBuffer)_buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@Internal
|
|
||||||
public ParagraphProperties getParagraphProperties(StyleSheet ss)
|
|
||||||
{
|
|
||||||
if(ss == null) {
|
|
||||||
// TODO Fix up for Word 6/95
|
|
||||||
return new ParagraphProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
short istd = getIstd();
|
|
||||||
ParagraphProperties baseStyle = ss.getParagraphStyle(istd);
|
|
||||||
ParagraphProperties props = ParagraphSprmUncompressor.uncompressPAP(baseStyle, getGrpprl(), 2);
|
|
||||||
return props;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o)
|
|
||||||
{
|
|
||||||
if (super.equals(o))
|
|
||||||
{
|
{
|
||||||
return _phe.equals(((PAPX)o)._phe);
|
if (super.equals(o))
|
||||||
|
{
|
||||||
|
return _phe.equals(((PAPX)o)._phe);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
assert false : "hashCode not designed";
|
assert false : "hashCode not designed";
|
||||||
return 42; // any arbitrary constant will do
|
return 42; // any arbitrary constant will do
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "PAPX from " + getStart() + " to " + getEnd() + " (in bytes "
|
return "PAPX from " + getStart() + " to " + getEnd() + " (in bytes "
|
||||||
+ getStartBytes() + " to " + getEndBytes() + ")";
|
+ getStartBytes() + " to " + getEndBytes() + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
this work for additional information regarding copyright ownership.
|
this work for additional information regarding copyright ownership.
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
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 not use this file except in compliance with
|
||||||
the License. You may obtain a copy of the License at
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.hwpf.model;
|
package org.apache.poi.hwpf.model;
|
||||||
@ -35,34 +35,34 @@ import org.apache.poi.util.POILogger;
|
|||||||
@Internal
|
@Internal
|
||||||
public class SectionTable
|
public class SectionTable
|
||||||
{
|
{
|
||||||
private final static POILogger _logger = POILogFactory.getLogger(SectionTable.class);
|
private final static POILogger _logger = POILogFactory.getLogger(SectionTable.class);
|
||||||
private static final int SED_SIZE = 12;
|
private static final int SED_SIZE = 12;
|
||||||
|
|
||||||
protected List<SEPX> _sections = new ArrayList<SEPX>();
|
protected List<SEPX> _sections = new ArrayList<SEPX>();
|
||||||
protected List<TextPiece> _text;
|
protected List<TextPiece> _text;
|
||||||
|
|
||||||
/** So we can know if things are unicode or not */
|
/** So we can know if things are unicode or not */
|
||||||
//private TextPieceTable tpt;
|
//private TextPieceTable tpt;
|
||||||
|
|
||||||
public SectionTable()
|
public SectionTable()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public SectionTable(byte[] documentStream, byte[] tableStream, int offset,
|
|
||||||
int size, int fcMin,
|
|
||||||
TextPieceTable tpt, int mainLength)
|
|
||||||
{
|
|
||||||
PlexOfCps sedPlex = new PlexOfCps(tableStream, offset, size, SED_SIZE);
|
|
||||||
//this.tpt = tpt;
|
|
||||||
this._text = tpt.getTextPieces();
|
|
||||||
|
|
||||||
int length = sedPlex.length();
|
|
||||||
|
|
||||||
for (int x = 0; x < length; x++)
|
|
||||||
{
|
{
|
||||||
GenericPropertyNode node = sedPlex.getProperty(x);
|
}
|
||||||
SectionDescriptor sed = new SectionDescriptor(node.getBytes(), 0);
|
|
||||||
|
|
||||||
|
public SectionTable(
|
||||||
|
byte[] documentStream, byte[] tableStream,
|
||||||
|
int offset, int size, int fcMin, TextPieceTable tpt, int mainLength)
|
||||||
|
{
|
||||||
|
PlexOfCps sedPlex = new PlexOfCps(tableStream, offset, size, SED_SIZE);
|
||||||
|
//this.tpt = tpt;
|
||||||
|
this._text = tpt.getTextPieces();
|
||||||
|
|
||||||
|
int length = sedPlex.length();
|
||||||
|
|
||||||
|
for (int x = 0; x < length; x++)
|
||||||
|
{
|
||||||
|
GenericPropertyNode node = sedPlex.getProperty(x);
|
||||||
|
SectionDescriptor sed = new SectionDescriptor(node.getBytes(), 0);
|
||||||
|
|
||||||
int fileOffset = sed.getFc();
|
int fileOffset = sed.getFc();
|
||||||
// int startAt = CPtoFC(node.getStart());
|
// int startAt = CPtoFC(node.getStart());
|
||||||
@ -70,41 +70,41 @@ public class SectionTable
|
|||||||
int startAt = node.getStart();
|
int startAt = node.getStart();
|
||||||
int endAt = node.getEnd();
|
int endAt = node.getEnd();
|
||||||
|
|
||||||
// check for the optimization
|
// check for the optimization
|
||||||
if (fileOffset == 0xffffffff)
|
if (fileOffset == 0xffffffff)
|
||||||
{
|
{
|
||||||
_sections.add(new SEPX(sed, startAt, endAt, new byte[0]));
|
_sections.add(new SEPX(sed, startAt, endAt, new byte[0]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The first short at the offset is the size of the grpprl.
|
// The first short at the offset is the size of the grpprl.
|
||||||
int sepxSize = LittleEndian.getShort(documentStream, fileOffset);
|
int sepxSize = LittleEndian.getShort(documentStream, fileOffset);
|
||||||
byte[] buf = new byte[sepxSize];
|
byte[] buf = new byte[sepxSize];
|
||||||
fileOffset += LittleEndian.SHORT_SIZE;
|
fileOffset += LittleEndian.SHORT_SIZE;
|
||||||
System.arraycopy(documentStream, fileOffset, buf, 0, buf.length);
|
System.arraycopy(documentStream, fileOffset, buf, 0, buf.length);
|
||||||
_sections.add(new SEPX(sed, startAt, endAt, buf));
|
_sections.add(new SEPX(sed, startAt, endAt, buf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some files seem to lie about their unicode status, which
|
// Some files seem to lie about their unicode status, which
|
||||||
// is very very pesky. Try to work around these, but this
|
// is very very pesky. Try to work around these, but this
|
||||||
// is getting on for black magic...
|
// is getting on for black magic...
|
||||||
int mainEndsAt = mainLength;
|
int mainEndsAt = mainLength;
|
||||||
boolean matchAt = false;
|
boolean matchAt = false;
|
||||||
boolean matchHalf = false;
|
boolean matchHalf = false;
|
||||||
for(int i=0; i<_sections.size(); i++) {
|
for (int i=0; i<_sections.size(); i++) {
|
||||||
SEPX s = _sections.get(i);
|
SEPX s = _sections.get(i);
|
||||||
if(s.getEnd() == mainEndsAt) {
|
if (s.getEnd() == mainEndsAt) {
|
||||||
matchAt = true;
|
matchAt = true;
|
||||||
} else if(s.getEnd() == mainEndsAt || s.getEnd() == mainEndsAt-1) {
|
} else if(s.getEnd() == mainEndsAt || s.getEnd() == mainEndsAt-1) {
|
||||||
matchHalf = true;
|
matchHalf = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(! matchAt && matchHalf) {
|
if(! matchAt && matchHalf) {
|
||||||
_logger.log(POILogger.WARN, "Your document seemed to be mostly unicode, but the section definition was in bytes! Trying anyway, but things may well go wrong!");
|
_logger.log(POILogger.WARN, "Your document seemed to be mostly unicode, but the section definition was in bytes! Trying anyway, but things may well go wrong!");
|
||||||
for(int i=0; i<_sections.size(); i++) {
|
for(int i=0; i<_sections.size(); i++) {
|
||||||
SEPX s = _sections.get(i);
|
SEPX s = _sections.get(i);
|
||||||
GenericPropertyNode node = sedPlex.getProperty(i);
|
GenericPropertyNode node = sedPlex.getProperty(i);
|
||||||
|
|
||||||
// s.setStart( CPtoFC(node.getStart()) );
|
// s.setStart( CPtoFC(node.getStart()) );
|
||||||
// s.setEnd( CPtoFC(node.getEnd()) );
|
// s.setEnd( CPtoFC(node.getEnd()) );
|
||||||
@ -112,33 +112,33 @@ public class SectionTable
|
|||||||
int endAt = node.getEnd();
|
int endAt = node.getEnd();
|
||||||
s.setStart( startAt );
|
s.setStart( startAt );
|
||||||
s.setEnd( endAt );
|
s.setEnd( endAt );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort( _sections, PropertyNode.StartComparator.instance );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void adjustForInsert(int listIndex, int length)
|
||||||
|
{
|
||||||
|
int size = _sections.size();
|
||||||
|
SEPX sepx = _sections.get(listIndex);
|
||||||
|
sepx.setEnd(sepx.getEnd() + length);
|
||||||
|
|
||||||
|
for (int x = listIndex + 1; x < size; x++)
|
||||||
|
{
|
||||||
|
sepx = _sections.get(x);
|
||||||
|
sepx.setStart(sepx.getStart() + length);
|
||||||
|
sepx.setEnd(sepx.getEnd() + length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort( _sections, PropertyNode.StartComparator.instance );
|
// goss version of CPtoFC - this takes into account non-contiguous textpieces
|
||||||
}
|
// that we have come across in real world documents. Tests against the example
|
||||||
|
// code in HWPFDocument show no variation to Ryan's version of the code in
|
||||||
public void adjustForInsert(int listIndex, int length)
|
// normal use, but this version works with our non-contiguous test case.
|
||||||
{
|
// So far unable to get this test case to be written out as well due to
|
||||||
int size = _sections.size();
|
// other issues. - piers
|
||||||
SEPX sepx = _sections.get(listIndex);
|
//
|
||||||
sepx.setEnd(sepx.getEnd() + length);
|
|
||||||
|
|
||||||
for (int x = listIndex + 1; x < size; x++)
|
|
||||||
{
|
|
||||||
sepx = _sections.get(x);
|
|
||||||
sepx.setStart(sepx.getStart() + length);
|
|
||||||
sepx.setEnd(sepx.getEnd() + length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// goss version of CPtoFC - this takes into account non-contiguous textpieces
|
|
||||||
// that we have come across in real world documents. Tests against the example
|
|
||||||
// code in HWPFDocument show no variation to Ryan's version of the code in
|
|
||||||
// normal use, but this version works with our non-contiguous test case.
|
|
||||||
// So far unable to get this test case to be written out as well due to
|
|
||||||
// other issues. - piers
|
|
||||||
//
|
|
||||||
// i'm commenting this out, because it just doesn't work with non-contiguous
|
// i'm commenting this out, because it just doesn't work with non-contiguous
|
||||||
// textpieces :( Usual (as for PAPX and CHPX) call to TextPiecesTable does.
|
// textpieces :( Usual (as for PAPX and CHPX) call to TextPiecesTable does.
|
||||||
// private int CPtoFC(int CP)
|
// private int CPtoFC(int CP)
|
||||||
@ -160,10 +160,10 @@ public class SectionTable
|
|||||||
// return FC;
|
// return FC;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public List<SEPX> getSections()
|
public List<SEPX> getSections()
|
||||||
{
|
{
|
||||||
return _sections;
|
return _sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void writeTo( HWPFFileSystem sys, int fcMin ) throws IOException
|
public void writeTo( HWPFFileSystem sys, int fcMin ) throws IOException
|
||||||
@ -174,36 +174,37 @@ public class SectionTable
|
|||||||
writeTo( docStream, tableStream );
|
writeTo( docStream, tableStream );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo( HWPFOutputStream wordDocumentStream,
|
public void writeTo(
|
||||||
|
HWPFOutputStream wordDocumentStream,
|
||||||
HWPFOutputStream tableStream ) throws IOException
|
HWPFOutputStream tableStream ) throws IOException
|
||||||
{
|
{
|
||||||
|
|
||||||
int offset = wordDocumentStream.getOffset();
|
int offset = wordDocumentStream.getOffset();
|
||||||
int len = _sections.size();
|
int len = _sections.size();
|
||||||
PlexOfCps plex = new PlexOfCps(SED_SIZE);
|
PlexOfCps plex = new PlexOfCps(SED_SIZE);
|
||||||
|
|
||||||
for (int x = 0; x < len; x++)
|
for (int x = 0; x < len; x++)
|
||||||
{
|
{
|
||||||
SEPX sepx = _sections.get(x);
|
SEPX sepx = _sections.get(x);
|
||||||
byte[] grpprl = sepx.getGrpprl();
|
byte[] grpprl = sepx.getGrpprl();
|
||||||
|
|
||||||
// write the sepx to the document stream. starts with a 2 byte size
|
// write the sepx to the document stream. starts with a 2 byte size
|
||||||
// followed by the grpprl
|
// followed by the grpprl
|
||||||
byte[] shortBuf = new byte[2];
|
byte[] shortBuf = new byte[2];
|
||||||
LittleEndian.putShort(shortBuf, 0, (short)grpprl.length);
|
LittleEndian.putShort(shortBuf, 0, (short)grpprl.length);
|
||||||
|
|
||||||
wordDocumentStream.write(shortBuf);
|
wordDocumentStream.write(shortBuf);
|
||||||
wordDocumentStream.write(grpprl);
|
wordDocumentStream.write(grpprl);
|
||||||
|
|
||||||
// set the fc in the section descriptor
|
// set the fc in the section descriptor
|
||||||
SectionDescriptor sed = sepx.getSectionDescriptor();
|
SectionDescriptor sed = sepx.getSectionDescriptor();
|
||||||
sed.setFc(offset);
|
sed.setFc(offset);
|
||||||
|
|
||||||
// add the section descriptor bytes to the PlexOfCps.
|
// add the section descriptor bytes to the PlexOfCps.
|
||||||
|
|
||||||
/* original line */
|
/* original line */
|
||||||
GenericPropertyNode property = new GenericPropertyNode(
|
GenericPropertyNode property = new GenericPropertyNode(
|
||||||
sepx.getStart(), sepx.getEnd(), sed.toByteArray() );
|
sepx.getStart(), sepx.getEnd(), sed.toByteArray() );
|
||||||
/*
|
/*
|
||||||
* Line using Ryan's FCtoCP() conversion method - unable to observe
|
* Line using Ryan's FCtoCP() conversion method - unable to observe
|
||||||
* any effect on our testcases when using this code - piers
|
* any effect on our testcases when using this code - piers
|
||||||
@ -217,10 +218,10 @@ public class SectionTable
|
|||||||
// tpt.getCharIndex( sepx.getStartBytes() ),
|
// tpt.getCharIndex( sepx.getStartBytes() ),
|
||||||
// tpt.getCharIndex( sepx.getEndBytes() ), sed.toByteArray() );
|
// tpt.getCharIndex( sepx.getEndBytes() ), sed.toByteArray() );
|
||||||
|
|
||||||
plex.addProperty(property);
|
plex.addProperty(property);
|
||||||
|
|
||||||
offset = wordDocumentStream.getOffset();
|
offset = wordDocumentStream.getOffset();
|
||||||
|
}
|
||||||
|
tableStream.write(plex.toByteArray());
|
||||||
}
|
}
|
||||||
tableStream.write(plex.toByteArray());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
this work for additional information regarding copyright ownership.
|
this work for additional information regarding copyright ownership.
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
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 not use this file except in compliance with
|
||||||
the License. You may obtain a copy of the License at
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.hwpf.sprm;
|
package org.apache.poi.hwpf.sprm;
|
||||||
@ -28,209 +28,209 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
@Internal
|
@Internal
|
||||||
public final class SectionSprmCompressor
|
public final class SectionSprmCompressor
|
||||||
{
|
{
|
||||||
private final static SectionProperties DEFAULT_SEP = new SectionProperties();
|
private final static SectionProperties DEFAULT_SEP = new SectionProperties();
|
||||||
public SectionSprmCompressor()
|
public SectionSprmCompressor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public static byte[] compressSectionProperty(SectionProperties newSEP)
|
public static byte[] compressSectionProperty(SectionProperties newSEP)
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
List<byte[]> sprmList = new ArrayList<byte[]>();
|
List<byte[]> sprmList = new ArrayList<byte[]>();
|
||||||
|
|
||||||
if (newSEP.getCnsPgn() != DEFAULT_SEP.getCnsPgn())
|
if (newSEP.getCnsPgn() != DEFAULT_SEP.getCnsPgn())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x3000, newSEP.getCnsPgn(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x3000, newSEP.getCnsPgn(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getIHeadingPgn() != DEFAULT_SEP.getIHeadingPgn())
|
if (newSEP.getIHeadingPgn() != DEFAULT_SEP.getIHeadingPgn())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x3001, newSEP.getIHeadingPgn(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x3001, newSEP.getIHeadingPgn(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (!Arrays.equals(newSEP.getOlstAnm(), DEFAULT_SEP.getOlstAnm()))
|
if (!Arrays.equals(newSEP.getOlstAnm(), DEFAULT_SEP.getOlstAnm()))
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0xD202, 0, newSEP.getOlstAnm(), sprmList);
|
size += SprmUtils.addSprm((short)0xD202, 0, newSEP.getOlstAnm(), sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getFEvenlySpaced() != DEFAULT_SEP.getFEvenlySpaced())
|
if (newSEP.getFEvenlySpaced() != DEFAULT_SEP.getFEvenlySpaced())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x3005, newSEP.getFEvenlySpaced() ? 1 : 0, null, sprmList);
|
size += SprmUtils.addSprm((short)0x3005, newSEP.getFEvenlySpaced() ? 1 : 0, null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getFUnlocked() != DEFAULT_SEP.getFUnlocked())
|
if (newSEP.getFUnlocked() != DEFAULT_SEP.getFUnlocked())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x3006, newSEP.getFUnlocked() ? 1 :0, null, sprmList);
|
size += SprmUtils.addSprm((short)0x3006, newSEP.getFUnlocked() ? 1 :0, null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDmBinFirst() != DEFAULT_SEP.getDmBinFirst())
|
if (newSEP.getDmBinFirst() != DEFAULT_SEP.getDmBinFirst())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x5007, newSEP.getDmBinFirst(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x5007, newSEP.getDmBinFirst(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDmBinOther() != DEFAULT_SEP.getDmBinOther())
|
if (newSEP.getDmBinOther() != DEFAULT_SEP.getDmBinOther())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x5008, newSEP.getDmBinOther(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x5008, newSEP.getDmBinOther(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getBkc() != DEFAULT_SEP.getBkc())
|
if (newSEP.getBkc() != DEFAULT_SEP.getBkc())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x3009, newSEP.getBkc(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x3009, newSEP.getBkc(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getFTitlePage() != DEFAULT_SEP.getFTitlePage())
|
if (newSEP.getFTitlePage() != DEFAULT_SEP.getFTitlePage())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x300A, newSEP.getFTitlePage() ? 1 : 0, null, sprmList);
|
size += SprmUtils.addSprm((short)0x300A, newSEP.getFTitlePage() ? 1 : 0, null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getCcolM1() != DEFAULT_SEP.getCcolM1())
|
if (newSEP.getCcolM1() != DEFAULT_SEP.getCcolM1())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x500B, newSEP.getCcolM1(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x500B, newSEP.getCcolM1(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDxaColumns() != DEFAULT_SEP.getDxaColumns())
|
if (newSEP.getDxaColumns() != DEFAULT_SEP.getDxaColumns())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x900C, newSEP.getDxaColumns(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x900C, newSEP.getDxaColumns(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getFAutoPgn() != DEFAULT_SEP.getFAutoPgn())
|
if (newSEP.getFAutoPgn() != DEFAULT_SEP.getFAutoPgn())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x300D, newSEP.getFAutoPgn() ? 1 : 0, null, sprmList);
|
size += SprmUtils.addSprm((short)0x300D, newSEP.getFAutoPgn() ? 1 : 0, null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getNfcPgn() != DEFAULT_SEP.getNfcPgn())
|
if (newSEP.getNfcPgn() != DEFAULT_SEP.getNfcPgn())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x300E, newSEP.getNfcPgn(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x300E, newSEP.getNfcPgn(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDyaPgn() != DEFAULT_SEP.getDyaPgn())
|
if (newSEP.getDyaPgn() != DEFAULT_SEP.getDyaPgn())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0xB00F, newSEP.getDyaPgn(), null, sprmList);
|
size += SprmUtils.addSprm((short)0xB00F, newSEP.getDyaPgn(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDxaPgn() != DEFAULT_SEP.getDxaPgn())
|
if (newSEP.getDxaPgn() != DEFAULT_SEP.getDxaPgn())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0xB010, newSEP.getDxaPgn(), null, sprmList);
|
size += SprmUtils.addSprm((short)0xB010, newSEP.getDxaPgn(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getFPgnRestart() != DEFAULT_SEP.getFPgnRestart())
|
if (newSEP.getFPgnRestart() != DEFAULT_SEP.getFPgnRestart())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x3011, newSEP.getFPgnRestart() ? 1 : 0, null, sprmList);
|
size += SprmUtils.addSprm((short)0x3011, newSEP.getFPgnRestart() ? 1 : 0, null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getFEndNote() != DEFAULT_SEP.getFEndNote())
|
if (newSEP.getFEndNote() != DEFAULT_SEP.getFEndNote())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x3012, newSEP.getFEndNote() ? 1 : 0, null, sprmList);
|
size += SprmUtils.addSprm((short)0x3012, newSEP.getFEndNote() ? 1 : 0, null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getLnc() != DEFAULT_SEP.getLnc())
|
if (newSEP.getLnc() != DEFAULT_SEP.getLnc())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x3013, newSEP.getLnc(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x3013, newSEP.getLnc(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getGrpfIhdt() != DEFAULT_SEP.getGrpfIhdt())
|
if (newSEP.getGrpfIhdt() != DEFAULT_SEP.getGrpfIhdt())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x3014, newSEP.getGrpfIhdt(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x3014, newSEP.getGrpfIhdt(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getNLnnMod() != DEFAULT_SEP.getNLnnMod())
|
if (newSEP.getNLnnMod() != DEFAULT_SEP.getNLnnMod())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x5015, newSEP.getNLnnMod(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x5015, newSEP.getNLnnMod(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDxaLnn() != DEFAULT_SEP.getDxaLnn())
|
if (newSEP.getDxaLnn() != DEFAULT_SEP.getDxaLnn())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x9016, newSEP.getDxaLnn(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x9016, newSEP.getDxaLnn(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDyaHdrTop() != DEFAULT_SEP.getDyaHdrTop())
|
if (newSEP.getDyaHdrTop() != DEFAULT_SEP.getDyaHdrTop())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0xB017, newSEP.getDyaHdrTop(), null, sprmList);
|
size += SprmUtils.addSprm((short)0xB017, newSEP.getDyaHdrTop(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDyaHdrBottom() != DEFAULT_SEP.getDyaHdrBottom())
|
if (newSEP.getDyaHdrBottom() != DEFAULT_SEP.getDyaHdrBottom())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0xB018, newSEP.getDyaHdrBottom(), null, sprmList);
|
size += SprmUtils.addSprm((short)0xB018, newSEP.getDyaHdrBottom(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getFLBetween() != DEFAULT_SEP.getFLBetween())
|
if (newSEP.getFLBetween() != DEFAULT_SEP.getFLBetween())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x3019, newSEP.getFLBetween() ? 1 : 0, null, sprmList);
|
size += SprmUtils.addSprm((short)0x3019, newSEP.getFLBetween() ? 1 : 0, null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getVjc() != DEFAULT_SEP.getVjc())
|
if (newSEP.getVjc() != DEFAULT_SEP.getVjc())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x301A, newSEP.getVjc(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x301A, newSEP.getVjc(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getLnnMin() != DEFAULT_SEP.getLnnMin())
|
if (newSEP.getLnnMin() != DEFAULT_SEP.getLnnMin())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x501B, newSEP.getLnnMin(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x501B, newSEP.getLnnMin(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getPgnStart() != DEFAULT_SEP.getPgnStart())
|
if (newSEP.getPgnStart() != DEFAULT_SEP.getPgnStart())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x501C, newSEP.getPgnStart(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x501C, newSEP.getPgnStart(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDmOrientPage() != DEFAULT_SEP.getDmOrientPage())
|
if (newSEP.getDmOrientPage() != DEFAULT_SEP.getDmOrientPage())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x301D, newSEP.getDmOrientPage() ? 1 : 0, null, sprmList);
|
size += SprmUtils.addSprm((short)0x301D, newSEP.getDmOrientPage() ? 1 : 0, null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getXaPage() != DEFAULT_SEP.getXaPage())
|
if (newSEP.getXaPage() != DEFAULT_SEP.getXaPage())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0xB01F, newSEP.getXaPage(), null, sprmList);
|
size += SprmUtils.addSprm((short)0xB01F, newSEP.getXaPage(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getYaPage() != DEFAULT_SEP.getYaPage())
|
if (newSEP.getYaPage() != DEFAULT_SEP.getYaPage())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0xB020, newSEP.getYaPage(), null, sprmList);
|
size += SprmUtils.addSprm((short)0xB020, newSEP.getYaPage(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDxaLeft() != DEFAULT_SEP.getDxaLeft())
|
if (newSEP.getDxaLeft() != DEFAULT_SEP.getDxaLeft())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0xB021, newSEP.getDxaLeft(), null, sprmList);
|
size += SprmUtils.addSprm((short)0xB021, newSEP.getDxaLeft(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDxaRight() != DEFAULT_SEP.getDxaRight())
|
if (newSEP.getDxaRight() != DEFAULT_SEP.getDxaRight())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0xB022, newSEP.getDxaRight(), null, sprmList);
|
size += SprmUtils.addSprm((short)0xB022, newSEP.getDxaRight(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDyaTop() != DEFAULT_SEP.getDyaTop())
|
if (newSEP.getDyaTop() != DEFAULT_SEP.getDyaTop())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x9023, newSEP.getDyaTop(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x9023, newSEP.getDyaTop(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDyaBottom() != DEFAULT_SEP.getDyaBottom())
|
if (newSEP.getDyaBottom() != DEFAULT_SEP.getDyaBottom())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x9024, newSEP.getDyaBottom(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x9024, newSEP.getDyaBottom(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDzaGutter() != DEFAULT_SEP.getDzaGutter())
|
if (newSEP.getDzaGutter() != DEFAULT_SEP.getDzaGutter())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0xB025, newSEP.getDzaGutter(), null, sprmList);
|
size += SprmUtils.addSprm((short)0xB025, newSEP.getDzaGutter(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDmPaperReq() != DEFAULT_SEP.getDmPaperReq())
|
if (newSEP.getDmPaperReq() != DEFAULT_SEP.getDmPaperReq())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x5026, newSEP.getDmPaperReq(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x5026, newSEP.getDmPaperReq(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getFPropMark() != DEFAULT_SEP.getFPropMark() ||
|
if (newSEP.getFPropMark() != DEFAULT_SEP.getFPropMark() ||
|
||||||
newSEP.getIbstPropRMark() != DEFAULT_SEP.getIbstPropRMark() ||
|
newSEP.getIbstPropRMark() != DEFAULT_SEP.getIbstPropRMark() ||
|
||||||
!newSEP.getDttmPropRMark().equals(DEFAULT_SEP.getDttmPropRMark()))
|
!newSEP.getDttmPropRMark().equals(DEFAULT_SEP.getDttmPropRMark()))
|
||||||
{
|
{
|
||||||
byte[] buf = new byte[7];
|
byte[] buf = new byte[7];
|
||||||
buf[0] = (byte)(newSEP.getFPropMark() ? 1 : 0);
|
buf[0] = (byte)(newSEP.getFPropMark() ? 1 : 0);
|
||||||
int offset = LittleEndian.BYTE_SIZE;
|
int offset = LittleEndian.BYTE_SIZE;
|
||||||
LittleEndian.putShort(buf, 0, (short)newSEP.getIbstPropRMark());
|
LittleEndian.putShort(buf, 0, (short)newSEP.getIbstPropRMark());
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
newSEP.getDttmPropRMark().serialize(buf, offset);
|
newSEP.getDttmPropRMark().serialize(buf, offset);
|
||||||
size += SprmUtils.addSprm((short)0xD227, -1, buf, sprmList);
|
size += SprmUtils.addSprm((short)0xD227, -1, buf, sprmList);
|
||||||
}
|
}
|
||||||
if (!newSEP.getBrcTop().equals( DEFAULT_SEP.getBrcTop()))
|
if (!newSEP.getBrcTop().equals( DEFAULT_SEP.getBrcTop()))
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x702B, newSEP.getBrcTop().toInt(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x702B, newSEP.getBrcTop().toInt(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (!newSEP.getBrcLeft().equals(DEFAULT_SEP.getBrcLeft()))
|
if (!newSEP.getBrcLeft().equals(DEFAULT_SEP.getBrcLeft()))
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x702C, newSEP.getBrcLeft().toInt(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x702C, newSEP.getBrcLeft().toInt(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (!newSEP.getBrcBottom().equals(DEFAULT_SEP.getBrcBottom()))
|
if (!newSEP.getBrcBottom().equals(DEFAULT_SEP.getBrcBottom()))
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x702D, newSEP.getBrcBottom().toInt(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x702D, newSEP.getBrcBottom().toInt(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (!newSEP.getBrcRight().equals(DEFAULT_SEP.getBrcRight()))
|
if (!newSEP.getBrcRight().equals(DEFAULT_SEP.getBrcRight()))
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x702E, newSEP.getBrcRight().toInt(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x702E, newSEP.getBrcRight().toInt(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getPgbProp() != DEFAULT_SEP.getPgbProp())
|
if (newSEP.getPgbProp() != DEFAULT_SEP.getPgbProp())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x522F, newSEP.getPgbProp(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x522F, newSEP.getPgbProp(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDxtCharSpace() != DEFAULT_SEP.getDxtCharSpace())
|
if (newSEP.getDxtCharSpace() != DEFAULT_SEP.getDxtCharSpace())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x7030, newSEP.getDxtCharSpace(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x7030, newSEP.getDxtCharSpace(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getDyaLinePitch() != DEFAULT_SEP.getDyaLinePitch())
|
if (newSEP.getDyaLinePitch() != DEFAULT_SEP.getDyaLinePitch())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x9031, newSEP.getDyaLinePitch(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x9031, newSEP.getDyaLinePitch(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getClm() != DEFAULT_SEP.getClm())
|
if (newSEP.getClm() != DEFAULT_SEP.getClm())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x5032, newSEP.getClm(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x5032, newSEP.getClm(), null, sprmList);
|
||||||
}
|
}
|
||||||
if (newSEP.getWTextFlow() != DEFAULT_SEP.getWTextFlow())
|
if (newSEP.getWTextFlow() != DEFAULT_SEP.getWTextFlow())
|
||||||
{
|
{
|
||||||
size += SprmUtils.addSprm((short)0x5033, newSEP.getWTextFlow(), null, sprmList);
|
size += SprmUtils.addSprm((short)0x5033, newSEP.getWTextFlow(), null, sprmList);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SprmUtils.getGrpprl(sprmList, size);
|
return SprmUtils.getGrpprl(sprmList, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,31 +26,31 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
@Internal
|
@Internal
|
||||||
public final class SprmUtils
|
public final class SprmUtils
|
||||||
{
|
{
|
||||||
public SprmUtils()
|
public SprmUtils()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] shortArrayToByteArray(short[] convert)
|
|
||||||
{
|
|
||||||
byte[] buf = new byte[convert.length * LittleEndian.SHORT_SIZE];
|
|
||||||
|
|
||||||
for (int x = 0; x < convert.length; x++)
|
|
||||||
{
|
{
|
||||||
LittleEndian.putShort(buf, x * LittleEndian.SHORT_SIZE, convert[x]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf;
|
public static byte[] shortArrayToByteArray(short[] convert)
|
||||||
}
|
{
|
||||||
|
byte[] buf = new byte[convert.length * LittleEndian.SHORT_SIZE];
|
||||||
|
|
||||||
public static int addSpecialSprm(short instruction, byte[] varParam, List<byte[]> list)
|
for (int x = 0; x < convert.length; x++)
|
||||||
{
|
{
|
||||||
byte[] sprm = new byte[varParam.length + 4];
|
LittleEndian.putShort(buf, x * LittleEndian.SHORT_SIZE, convert[x]);
|
||||||
System.arraycopy(varParam, 0, sprm, 4, varParam.length);
|
}
|
||||||
LittleEndian.putShort(sprm, 0, instruction);
|
|
||||||
LittleEndian.putShort(sprm, 2, (short)(varParam.length + 1));
|
return buf;
|
||||||
list.add(sprm);
|
}
|
||||||
return sprm.length;
|
|
||||||
}
|
public static int addSpecialSprm(short instruction, byte[] varParam, List<byte[]> list)
|
||||||
|
{
|
||||||
|
byte[] sprm = new byte[varParam.length + 4];
|
||||||
|
System.arraycopy(varParam, 0, sprm, 4, varParam.length);
|
||||||
|
LittleEndian.putShort(sprm, 0, instruction);
|
||||||
|
LittleEndian.putShort(sprm, 2, (short)(varParam.length + 1));
|
||||||
|
list.add(sprm);
|
||||||
|
return sprm.length;
|
||||||
|
}
|
||||||
|
|
||||||
public static int addSprm( short instruction, boolean param,
|
public static int addSprm( short instruction, boolean param,
|
||||||
List<byte[]> list )
|
List<byte[]> list )
|
||||||
@ -58,74 +58,74 @@ public final class SprmUtils
|
|||||||
return addSprm( instruction, param ? 1 : 0, null, list );
|
return addSprm( instruction, param ? 1 : 0, null, list );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int addSprm(short instruction, int param, byte[] varParam, List<byte[]> list)
|
public static int addSprm(short instruction, int param, byte[] varParam, List<byte[]> list)
|
||||||
{
|
|
||||||
int type = (instruction & 0xe000) >> 13;
|
|
||||||
|
|
||||||
byte[] sprm = null;
|
|
||||||
switch(type)
|
|
||||||
{
|
{
|
||||||
case 0:
|
int type = (instruction & 0xe000) >> 13;
|
||||||
case 1:
|
|
||||||
sprm = new byte[3];
|
|
||||||
sprm[2] = (byte)param;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
sprm = new byte[4];
|
|
||||||
LittleEndian.putShort(sprm, 2, (short)param);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
sprm = new byte[6];
|
|
||||||
LittleEndian.putInt(sprm, 2, param);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
sprm = new byte[4];
|
|
||||||
LittleEndian.putShort(sprm, 2, (short)param);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
sprm = new byte[3 + varParam.length];
|
|
||||||
sprm[2] = (byte)varParam.length;
|
|
||||||
System.arraycopy(varParam, 0, sprm, 3, varParam.length);
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
sprm = new byte[5];
|
|
||||||
// this is a three byte int so it has to be handled special
|
|
||||||
byte[] temp = new byte[4];
|
|
||||||
LittleEndian.putInt(temp, 0, param);
|
|
||||||
System.arraycopy(temp, 0, sprm, 2, 3);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//should never happen
|
|
||||||
throw new RuntimeException("Invalid sprm type");
|
|
||||||
}
|
|
||||||
LittleEndian.putShort(sprm, 0, instruction);
|
|
||||||
list.add(sprm);
|
|
||||||
return sprm.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] getGrpprl(List<byte[]> sprmList, int size)
|
byte[] sprm = null;
|
||||||
{
|
switch(type)
|
||||||
// spit out the final grpprl
|
{
|
||||||
byte[] grpprl = new byte[size];
|
case 0:
|
||||||
int listSize = sprmList.size() - 1;
|
case 1:
|
||||||
int index = 0;
|
sprm = new byte[3];
|
||||||
for (; listSize >= 0; listSize--)
|
sprm[2] = (byte)param;
|
||||||
{
|
break;
|
||||||
byte[] sprm = sprmList.remove(0);
|
case 2:
|
||||||
System.arraycopy(sprm, 0, grpprl, index, sprm.length);
|
sprm = new byte[4];
|
||||||
index += sprm.length;
|
LittleEndian.putShort(sprm, 2, (short)param);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
sprm = new byte[6];
|
||||||
|
LittleEndian.putInt(sprm, 2, param);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
sprm = new byte[4];
|
||||||
|
LittleEndian.putShort(sprm, 2, (short)param);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
sprm = new byte[3 + varParam.length];
|
||||||
|
sprm[2] = (byte)varParam.length;
|
||||||
|
System.arraycopy(varParam, 0, sprm, 3, varParam.length);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
sprm = new byte[5];
|
||||||
|
// this is a three byte int so it has to be handled special
|
||||||
|
byte[] temp = new byte[4];
|
||||||
|
LittleEndian.putInt(temp, 0, param);
|
||||||
|
System.arraycopy(temp, 0, sprm, 2, 3);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//should never happen
|
||||||
|
throw new RuntimeException("Invalid sprm type");
|
||||||
|
}
|
||||||
|
LittleEndian.putShort(sprm, 0, instruction);
|
||||||
|
list.add(sprm);
|
||||||
|
return sprm.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return grpprl;
|
public static byte[] getGrpprl(List<byte[]> sprmList, int size)
|
||||||
|
{
|
||||||
|
// spit out the final grpprl
|
||||||
|
byte[] grpprl = new byte[size];
|
||||||
|
int listSize = sprmList.size() - 1;
|
||||||
|
int index = 0;
|
||||||
|
for (; listSize >= 0; listSize--)
|
||||||
|
{
|
||||||
|
byte[] sprm = sprmList.remove(0);
|
||||||
|
System.arraycopy(sprm, 0, grpprl, index, sprm.length);
|
||||||
|
index += sprm.length;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
return grpprl;
|
||||||
|
|
||||||
public static int convertBrcToInt(short[] brc)
|
}
|
||||||
{
|
|
||||||
byte[] buf = new byte[4];
|
public static int convertBrcToInt(short[] brc)
|
||||||
LittleEndian.putShort(buf, 0, brc[0]);
|
{
|
||||||
LittleEndian.putShort(buf, LittleEndian.SHORT_SIZE, brc[1]);
|
byte[] buf = new byte[4];
|
||||||
return LittleEndian.getInt(buf);
|
LittleEndian.putShort(buf, 0, brc[0]);
|
||||||
}
|
LittleEndian.putShort(buf, LittleEndian.SHORT_SIZE, brc[1]);
|
||||||
|
return LittleEndian.getInt(buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user