mirror of https://github.com/apache/poi.git
add tabs handling and additional SPRMs; update ShadingDescription definition (in fact, replace)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1173157 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4d6d815908
commit
6b3ddfb24d
|
@ -226,7 +226,6 @@ public class LittleEndian implements LittleEndianConsts {
|
|||
data[i++] = (byte)((value >>> 24) & 0xFF);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put an int value into beginning of a byte array
|
||||
*
|
||||
|
@ -237,6 +236,32 @@ public class LittleEndian implements LittleEndianConsts {
|
|||
putInt(data, 0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* put an unsigned int value into a byte array
|
||||
*
|
||||
* @param data the byte array
|
||||
* @param offset a starting offset into the byte array
|
||||
* @param value the int (32-bit) value
|
||||
*
|
||||
* @exception ArrayIndexOutOfBoundsException may be thrown
|
||||
*/
|
||||
public static void putUInt(byte[] data, int offset, long value) {
|
||||
int i = offset;
|
||||
data[i++] = (byte)((value >>> 0) & 0xFF);
|
||||
data[i++] = (byte)((value >>> 8) & 0xFF);
|
||||
data[i++] = (byte)((value >>> 16) & 0xFF);
|
||||
data[i++] = (byte)((value >>> 24) & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* put an unsigned int value into beginning of a byte array
|
||||
*
|
||||
*@param data the byte array
|
||||
*@param value the int (32-bit) value
|
||||
*/
|
||||
public static void putUInt(byte[] data, long value) {
|
||||
putUInt(data, 0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* put a long value into a byte array
|
||||
|
|
|
@ -27,6 +27,48 @@ import org.apache.poi.util.LittleEndian;
|
|||
@Internal
|
||||
public class Colorref implements Cloneable
|
||||
{
|
||||
public static Colorref valueOfIco( int ico )
|
||||
{
|
||||
|
||||
switch ( ico )
|
||||
{
|
||||
case 1:
|
||||
return new Colorref( 0x00000000 );
|
||||
case 2:
|
||||
return new Colorref( 0x00FF0000 );
|
||||
case 3:
|
||||
return new Colorref( 0x00FFFF00 );
|
||||
case 4:
|
||||
return new Colorref( 0x0000FF00 );
|
||||
case 5:
|
||||
return new Colorref( 0x00FF00FF );
|
||||
case 6:
|
||||
return new Colorref( 0x000000FF );
|
||||
case 7:
|
||||
return new Colorref( 0x0000FFFF );
|
||||
case 8:
|
||||
return new Colorref( 0x00FFFFFF );
|
||||
case 9:
|
||||
return new Colorref( 0x008B0000 );
|
||||
case 10:
|
||||
return new Colorref( 0x008B8B00 );
|
||||
case 11:
|
||||
return new Colorref( 0x00006400 );
|
||||
case 12:
|
||||
return new Colorref( 0x008B008B );
|
||||
case 13:
|
||||
return new Colorref( 0x0000008B );
|
||||
case 14:
|
||||
return new Colorref( 0x0000CCFF );
|
||||
case 15:
|
||||
return new Colorref( 0x00A9A9A9 );
|
||||
case 16:
|
||||
return new Colorref( 0x00C0C0C0 );
|
||||
default:
|
||||
return new Colorref( 0x00000000 );
|
||||
}
|
||||
}
|
||||
|
||||
private int value;
|
||||
|
||||
public Colorref()
|
||||
|
@ -81,6 +123,11 @@ public class Colorref implements Cloneable
|
|||
return value == -1;
|
||||
}
|
||||
|
||||
public void serialize( byte[] data, int offset )
|
||||
{
|
||||
LittleEndian.putInt( data, offset, this.value );
|
||||
}
|
||||
|
||||
public void setValue( int value )
|
||||
{
|
||||
this.value = value;
|
||||
|
@ -93,7 +140,7 @@ public class Colorref implements Cloneable
|
|||
"Structure state (EMPTY) is not good for serialization" );
|
||||
|
||||
byte[] bs = new byte[4];
|
||||
LittleEndian.putInt( bs, 0, this.value );
|
||||
serialize( bs, 0 );
|
||||
return bs;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
package org.apache.poi.hwpf.model;
|
||||
|
||||
import org.apache.poi.hwpf.model.types.TBDAbstractType;
|
||||
import org.apache.poi.hwpf.usermodel.ParagraphProperties;
|
||||
|
||||
/**
|
||||
* Tab descriptor. Part of {@link ParagraphProperties}.
|
||||
*
|
||||
* @author vlsergey
|
||||
*/
|
||||
public class TabDescriptor extends TBDAbstractType
|
||||
{
|
||||
|
||||
public TabDescriptor()
|
||||
{
|
||||
}
|
||||
|
||||
public TabDescriptor( byte[] bytes, int offset )
|
||||
{
|
||||
fillFields( bytes, offset );
|
||||
}
|
||||
|
||||
public byte[] toByteArray()
|
||||
{
|
||||
byte[] buf = new byte[getSize()];
|
||||
serialize( buf, 0 );
|
||||
return buf;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,163 @@
|
|||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
package org.apache.poi.hwpf.model.types;
|
||||
|
||||
|
||||
import org.apache.poi.util.BitField;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
* The SHD80 is a substructure of the CHP and PAP, and TC for Word 97. <p>Class
|
||||
and fields descriptions are quoted from
|
||||
Microsoft Office Word 97-2007 Binary File Format
|
||||
|
||||
* <p>
|
||||
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
|
||||
* remove the record in src/types/definitions.
|
||||
* <p>
|
||||
* This class is internal. It content or properties may change without notice
|
||||
* due to changes in our knowledge of internal Microsoft Word binary structures.
|
||||
|
||||
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format
|
||||
Specification [*.doc]
|
||||
|
||||
*/
|
||||
@Internal
|
||||
public abstract class SHD80AbstractType
|
||||
{
|
||||
|
||||
protected short field_1_value;
|
||||
/**/private static BitField icoFore = new BitField(0x001F);
|
||||
/**/private static BitField icoBack = new BitField(0x03E0);
|
||||
/**/private static BitField ipat = new BitField(0xFC00);
|
||||
|
||||
protected SHD80AbstractType()
|
||||
{
|
||||
}
|
||||
|
||||
protected void fillFields( byte[] data, int offset )
|
||||
{
|
||||
field_1_value = LittleEndian.getShort(data, 0x0 + offset);
|
||||
}
|
||||
|
||||
public void serialize( byte[] data, int offset )
|
||||
{
|
||||
LittleEndian.putShort(data, 0x0 + offset, (short)field_1_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Size of record
|
||||
*/
|
||||
public static int getSize()
|
||||
{
|
||||
return 0 + 2;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("[SHD80]\n");
|
||||
builder.append(" .value = ");
|
||||
builder.append(" (").append(getValue()).append(" )\n");
|
||||
builder.append(" .icoFore = ").append(getIcoFore()).append('\n');
|
||||
builder.append(" .icoBack = ").append(getIcoBack()).append('\n');
|
||||
builder.append(" .ipat = ").append(getIpat()).append('\n');
|
||||
|
||||
builder.append("[/SHD80]\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value field for the SHD80 record.
|
||||
*/
|
||||
@Internal
|
||||
public short getValue()
|
||||
{
|
||||
return field_1_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value field for the SHD80 record.
|
||||
*/
|
||||
@Internal
|
||||
public void setValue( short field_1_value )
|
||||
{
|
||||
this.field_1_value = field_1_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icoFore field value.
|
||||
* Foreground color
|
||||
*/
|
||||
@Internal
|
||||
public void setIcoFore( byte value )
|
||||
{
|
||||
field_1_value = (short)icoFore.setValue(field_1_value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Foreground color
|
||||
* @return the icoFore field value.
|
||||
*/
|
||||
@Internal
|
||||
public byte getIcoFore()
|
||||
{
|
||||
return ( byte )icoFore.getValue(field_1_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icoBack field value.
|
||||
* Background color
|
||||
*/
|
||||
@Internal
|
||||
public void setIcoBack( byte value )
|
||||
{
|
||||
field_1_value = (short)icoBack.setValue(field_1_value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Background color
|
||||
* @return the icoBack field value.
|
||||
*/
|
||||
@Internal
|
||||
public byte getIcoBack()
|
||||
{
|
||||
return ( byte )icoBack.getValue(field_1_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ipat field value.
|
||||
* Shading pattern
|
||||
*/
|
||||
@Internal
|
||||
public void setIpat( byte value )
|
||||
{
|
||||
field_1_value = (short)ipat.setValue(field_1_value, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shading pattern
|
||||
* @return the ipat field value.
|
||||
*/
|
||||
@Internal
|
||||
public byte getIpat()
|
||||
{
|
||||
return ( byte )ipat.getValue(field_1_value);
|
||||
}
|
||||
|
||||
} // END OF CLASS
|
|
@ -0,0 +1,145 @@
|
|||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
package org.apache.poi.hwpf.model.types;
|
||||
|
||||
|
||||
import org.apache.poi.hwpf.model.Colorref;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
* The SHD is a substructure of the CHP, PAP, and TC for Word 2000. <p>Class
|
||||
and
|
||||
fields descriptions are quoted from Microsoft Office Word 97-2007 Binary File Format
|
||||
|
||||
* <p>
|
||||
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
|
||||
* remove the record in src/types/definitions.
|
||||
* <p>
|
||||
* This class is internal. It content or properties may change without notice
|
||||
* due to changes in our knowledge of internal Microsoft Word binary structures.
|
||||
|
||||
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format
|
||||
Specification [*.doc]
|
||||
|
||||
*/
|
||||
@Internal
|
||||
public abstract class SHDAbstractType
|
||||
{
|
||||
|
||||
protected Colorref field_1_cvFore;
|
||||
protected Colorref field_2_cvBack;
|
||||
protected int field_3_ipat;
|
||||
|
||||
protected SHDAbstractType()
|
||||
{
|
||||
this.field_1_cvFore = new Colorref();
|
||||
this.field_2_cvBack = new Colorref();
|
||||
}
|
||||
|
||||
protected void fillFields( byte[] data, int offset )
|
||||
{
|
||||
field_1_cvFore = new Colorref(data, 0x0 + offset);
|
||||
field_2_cvBack = new Colorref(data, 0x4 + offset);
|
||||
field_3_ipat = LittleEndian.getShort(data, 0x8 + offset);
|
||||
}
|
||||
|
||||
public void serialize( byte[] data, int offset )
|
||||
{
|
||||
field_1_cvFore.serialize(data, 0x0 + offset);
|
||||
field_2_cvBack.serialize(data, 0x4 + offset);
|
||||
LittleEndian.putShort(data, 0x8 + offset, (short)field_3_ipat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Size of record
|
||||
*/
|
||||
public static int getSize()
|
||||
{
|
||||
return 0 + 4 + 4 + 2;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("[SHD]\n");
|
||||
builder.append(" .cvFore = ");
|
||||
builder.append(" (").append(getCvFore()).append(" )\n");
|
||||
builder.append(" .cvBack = ");
|
||||
builder.append(" (").append(getCvBack()).append(" )\n");
|
||||
builder.append(" .ipat = ");
|
||||
builder.append(" (").append(getIpat()).append(" )\n");
|
||||
|
||||
builder.append("[/SHD]\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 24-bit foreground color.
|
||||
*/
|
||||
@Internal
|
||||
public Colorref getCvFore()
|
||||
{
|
||||
return field_1_cvFore;
|
||||
}
|
||||
|
||||
/**
|
||||
* 24-bit foreground color.
|
||||
*/
|
||||
@Internal
|
||||
public void setCvFore( Colorref field_1_cvFore )
|
||||
{
|
||||
this.field_1_cvFore = field_1_cvFore;
|
||||
}
|
||||
|
||||
/**
|
||||
* 24-bit background color.
|
||||
*/
|
||||
@Internal
|
||||
public Colorref getCvBack()
|
||||
{
|
||||
return field_2_cvBack;
|
||||
}
|
||||
|
||||
/**
|
||||
* 24-bit background color.
|
||||
*/
|
||||
@Internal
|
||||
public void setCvBack( Colorref field_2_cvBack )
|
||||
{
|
||||
this.field_2_cvBack = field_2_cvBack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shading pattern.
|
||||
*/
|
||||
@Internal
|
||||
public int getIpat()
|
||||
{
|
||||
return field_3_ipat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shading pattern.
|
||||
*/
|
||||
@Internal
|
||||
public void setIpat( int field_3_ipat )
|
||||
{
|
||||
this.field_3_ipat = field_3_ipat;
|
||||
}
|
||||
|
||||
} // END OF CLASS
|
File diff suppressed because it is too large
Load Diff
|
@ -254,11 +254,6 @@ public final class ParagraphSprmCompressor
|
|||
// sprmPDcs
|
||||
size += SprmUtils.addSprm((short)0x442C, newPAP.getDcs().toShort(), null, sprmList);
|
||||
}
|
||||
if (newPAP.getShd() != null && !newPAP.getShd().equals(oldPAP.getShd()))
|
||||
{
|
||||
// sprmPShd80
|
||||
size += SprmUtils.addSprm((short)0x442D, newPAP.getShd().toShort(), null, sprmList);
|
||||
}
|
||||
if (newPAP.getDyaFromText() != oldPAP.getDyaFromText())
|
||||
{
|
||||
// sprmPDyaFromText
|
||||
|
@ -375,6 +370,13 @@ public final class ParagraphSprmCompressor
|
|||
size += SprmUtils.addSprm((short)0x244c, newPAP.getFTtpEmbedded(), sprmList);
|
||||
}
|
||||
|
||||
if (newPAP.getShd() != null && !newPAP.getShd().equals(oldPAP.getShd()))
|
||||
{
|
||||
// size += SprmUtils.addSprm((short)0x442D, newPAP.getShd().toShort(), null, sprmList);
|
||||
// sprmPShd -- 0xc64d
|
||||
size += SprmUtils.addSprm( (short) 0xc64d, 0, newPAP.getShd().serialize(), sprmList );
|
||||
}
|
||||
|
||||
// Page 55 of public specification begins
|
||||
if (newPAP.getItap() != oldPAP.getItap())
|
||||
{
|
||||
|
@ -382,6 +384,14 @@ public final class ParagraphSprmCompressor
|
|||
size += SprmUtils.addSprm((short)0x6649, newPAP.getItap(), null, sprmList);
|
||||
}
|
||||
|
||||
if ( newPAP.getRsid() != oldPAP.getRsid() )
|
||||
{
|
||||
// sprmPRsid
|
||||
byte[] value = new byte[4];
|
||||
LittleEndian.putUInt( value, newPAP.getRsid() );
|
||||
size += SprmUtils.addSprm( (short) 0x6467, 0, value, sprmList );
|
||||
}
|
||||
|
||||
return SprmUtils.getGrpprl(sprmList, size);
|
||||
|
||||
}
|
||||
|
|
|
@ -23,12 +23,14 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.hwpf.model.TabDescriptor;
|
||||
import org.apache.poi.hwpf.usermodel.BorderCode;
|
||||
import org.apache.poi.hwpf.usermodel.DateAndTime;
|
||||
import org.apache.poi.hwpf.usermodel.DropCapSpecifier;
|
||||
import org.apache.poi.hwpf.usermodel.LineSpacingDescriptor;
|
||||
import org.apache.poi.hwpf.usermodel.ParagraphProperties;
|
||||
import org.apache.poi.hwpf.usermodel.ShadingDescriptor;
|
||||
import org.apache.poi.hwpf.usermodel.ShadingDescriptor80;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
|
@ -285,7 +287,8 @@ public final class ParagraphSprmUncompressor
|
|||
newPAP.setDcs (new DropCapSpecifier((short)sprm.getOperand()));
|
||||
break;
|
||||
case 0x2d:
|
||||
newPAP.setShd (new ShadingDescriptor((short)sprm.getOperand()));
|
||||
newPAP.setShd( new ShadingDescriptor80( (short) sprm.getOperand() )
|
||||
.toShadingDescriptor() );
|
||||
break;
|
||||
case 0x2e:
|
||||
newPAP.setDyaFromText (sprm.getOperand());
|
||||
|
@ -412,6 +415,20 @@ public final class ParagraphSprmUncompressor
|
|||
// sprmPFInnerTtp -- 0x244c
|
||||
newPAP.setFTtpEmbedded( sprm.getOperand() != 0);
|
||||
break;
|
||||
case 0x4d:
|
||||
// sprmPShd -- 0xc64d
|
||||
ShadingDescriptor shadingDescriptor = new ShadingDescriptor(
|
||||
sprm.getGrpprl(), 3 );
|
||||
newPAP.setShading( shadingDescriptor );
|
||||
break;
|
||||
case 0x5d:
|
||||
// sprmPDxaRight -- 0x845d
|
||||
newPAP.setDxaRight( sprm.getOperand() );
|
||||
break;
|
||||
case 0x5e:
|
||||
// sprmPDxaLeft -- 0x845e
|
||||
newPAP.setDxaLeft( sprm.getOperand() );
|
||||
break;
|
||||
case 0x60:
|
||||
// sprmPDxaLeft1 -- 0x8460
|
||||
newPAP.setDxaLeft1( sprm.getOperand() );
|
||||
|
@ -420,6 +437,10 @@ public final class ParagraphSprmUncompressor
|
|||
// sprmPJc
|
||||
newPAP.setJustificationLogical((byte) sprm.getOperand());
|
||||
break;
|
||||
case 0x67:
|
||||
// sprmPRsid -- 0x6467
|
||||
newPAP.setRsid( sprm.getOperand() );
|
||||
break;
|
||||
default:
|
||||
logger.log( POILogger.DEBUG, "Unknown PAP sprm ignored: " + sprm );
|
||||
break;
|
||||
|
@ -432,12 +453,12 @@ public final class ParagraphSprmUncompressor
|
|||
int offset = sprm.getGrpprlOffset();
|
||||
int delSize = grpprl[offset++];
|
||||
int[] tabPositions = pap.getRgdxaTab();
|
||||
byte[] tabDescriptors = pap.getRgtbd();
|
||||
TabDescriptor[] tabDescriptors = pap.getRgtbd();
|
||||
|
||||
Map<Integer, Byte> tabMap = new HashMap<Integer, Byte>();
|
||||
Map<Integer, TabDescriptor> tabMap = new HashMap<Integer, TabDescriptor>();
|
||||
for (int x = 0; x < tabPositions.length; x++)
|
||||
{
|
||||
tabMap.put(Integer.valueOf(tabPositions[x]), Byte.valueOf(tabDescriptors[x]));
|
||||
tabMap.put(Integer.valueOf(tabPositions[x]), tabDescriptors[x]);
|
||||
}
|
||||
|
||||
for (int x = 0; x < delSize; x++)
|
||||
|
@ -451,13 +472,13 @@ public final class ParagraphSprmUncompressor
|
|||
for (int x = 0; x < addSize; x++)
|
||||
{
|
||||
Integer key = Integer.valueOf(LittleEndian.getShort(grpprl, offset));
|
||||
Byte val = Byte.valueOf(grpprl[start + ((LittleEndian.SHORT_SIZE * addSize) + x)]);
|
||||
TabDescriptor val = new TabDescriptor( grpprl, start + ((TabDescriptor.getSize() * addSize) + x) );
|
||||
tabMap.put(key, val);
|
||||
offset += LittleEndian.SHORT_SIZE;
|
||||
}
|
||||
|
||||
tabPositions = new int[tabMap.size()];
|
||||
tabDescriptors = new byte[tabPositions.length];
|
||||
tabDescriptors = new TabDescriptor[tabPositions.length];
|
||||
|
||||
List<Integer> list = new ArrayList<Integer>(tabMap.keySet());
|
||||
Collections.sort(list);
|
||||
|
@ -466,7 +487,10 @@ public final class ParagraphSprmUncompressor
|
|||
{
|
||||
Integer key = list.get(x);
|
||||
tabPositions[x] = key.intValue();
|
||||
tabDescriptors[x] = tabMap.get(key).byteValue();
|
||||
if (tabMap.containsKey( key ))
|
||||
tabDescriptors[x] = tabMap.get(key);
|
||||
else
|
||||
tabDescriptors[x] = new TabDescriptor();
|
||||
}
|
||||
|
||||
pap.setRgdxaTab(tabPositions);
|
||||
|
|
|
@ -55,7 +55,8 @@ public class Paragraph extends Range implements Cloneable {
|
|||
public final static short SPRM_FNOAUTOHYPH = 0x242A;
|
||||
public final static short SPRM_WHEIGHTABS = 0x442B;
|
||||
public final static short SPRM_DCS = 0x442C;
|
||||
public final static short SPRM_SHD = 0x442D;
|
||||
public final static short SPRM_SHD80 = 0x442D;
|
||||
public final static short SPRM_SHD = (short)0xC64D;
|
||||
public final static short SPRM_DYAFROMTEXT = (short)0x842E;
|
||||
public final static short SPRM_DXAFROMTEXT = (short)0x842F;
|
||||
public final static short SPRM_FLOCKED = 0x2430;
|
||||
|
@ -422,7 +423,8 @@ public class Paragraph extends Range implements Cloneable {
|
|||
public void setShading(ShadingDescriptor shd)
|
||||
{
|
||||
_props.setShd(shd);
|
||||
_papx.updateSprm(SPRM_SHD, shd.toShort());
|
||||
//TODO: remove old one
|
||||
_papx.addSprm( SPRM_SHD, shd.serialize() );
|
||||
}
|
||||
|
||||
public DropCapSpecifier getDropCap()
|
||||
|
@ -478,6 +480,28 @@ public class Paragraph extends Range implements Cloneable {
|
|||
_papx.updateSprm(SPRM_FTTP, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns number of tabs stops defined for paragraph. Must be >= 0 and <=
|
||||
* 64.
|
||||
*
|
||||
* @return number of tabs stops defined for paragraph. Must be >= 0 and <=
|
||||
* 64
|
||||
*/
|
||||
public int getTabStopsNumber()
|
||||
{
|
||||
return _props.getItbdMac();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of positions of itbdMac tab stops
|
||||
*
|
||||
* @return array of positions of itbdMac tab stops
|
||||
*/
|
||||
public int[] getTabStopsPositions()
|
||||
{
|
||||
return _props.getRgdxaTab();
|
||||
}
|
||||
|
||||
/**
|
||||
* clone the ParagraphProperties object associated with this Paragraph so
|
||||
* that you can apply the same properties to another paragraph.
|
||||
|
|
|
@ -17,19 +17,16 @@
|
|||
|
||||
package org.apache.poi.hwpf.usermodel;
|
||||
|
||||
import org.apache.poi.util.BitField;
|
||||
import org.apache.poi.util.BitFieldFactory;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.hwpf.model.types.SHDAbstractType;
|
||||
|
||||
public final class ShadingDescriptor
|
||||
implements Cloneable
|
||||
/**
|
||||
* The SHD is a substructure of the CHP, PAP, and TC for Word 2000.
|
||||
*
|
||||
* @author vlsergey
|
||||
*/
|
||||
public final class ShadingDescriptor extends SHDAbstractType implements
|
||||
Cloneable
|
||||
{
|
||||
public static final int SIZE = 2;
|
||||
|
||||
private short _info;
|
||||
private final static BitField _icoFore = BitFieldFactory.getInstance(0x1f);
|
||||
private final static BitField _icoBack = BitFieldFactory.getInstance(0x3e0);
|
||||
private final static BitField _ipat = BitFieldFactory.getInstance(0xfc00);
|
||||
|
||||
public ShadingDescriptor()
|
||||
{
|
||||
|
@ -37,33 +34,25 @@ public final class ShadingDescriptor
|
|||
|
||||
public ShadingDescriptor( byte[] buf, int offset )
|
||||
{
|
||||
this(LittleEndian.getShort(buf, offset));
|
||||
super();
|
||||
fillFields( buf, offset );
|
||||
}
|
||||
|
||||
public ShadingDescriptor(short info)
|
||||
public ShadingDescriptor clone() throws CloneNotSupportedException
|
||||
{
|
||||
_info = info;
|
||||
}
|
||||
|
||||
public short toShort()
|
||||
{
|
||||
return _info;
|
||||
}
|
||||
|
||||
public void serialize(byte[] buf, int offset)
|
||||
{
|
||||
LittleEndian.putShort(buf, offset, _info);
|
||||
}
|
||||
|
||||
public Object clone()
|
||||
throws CloneNotSupportedException
|
||||
{
|
||||
return super.clone();
|
||||
return (ShadingDescriptor) super.clone();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return _info == 0;
|
||||
return field_3_ipat == 0;
|
||||
}
|
||||
|
||||
public byte[] serialize()
|
||||
{
|
||||
byte[] result = new byte[getSize()];
|
||||
serialize( result, 0 );
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,8 +61,8 @@ public final class ShadingDescriptor
|
|||
if ( isEmpty() )
|
||||
return "[SHD] EMPTY";
|
||||
|
||||
return "[SHD] (cvFore: " + _icoFore.getShortValue( _info )
|
||||
+ "; cvBack: " + _icoBack.getShortValue( _info ) + "; iPat: "
|
||||
+ _ipat.getShortValue( _info ) + ")";
|
||||
return "[SHD] (cvFore: " + getCvFore() + "; cvBack: " + getCvBack()
|
||||
+ "; iPat: " + getIpat() + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.hwpf.usermodel;
|
||||
|
||||
import org.apache.poi.hwpf.model.Colorref;
|
||||
|
||||
import org.apache.poi.hwpf.model.types.SHD80AbstractType;
|
||||
|
||||
/**
|
||||
* The SHD80 is a substructure of the CHP and PAP, and TC for Word 97.
|
||||
*/
|
||||
public final class ShadingDescriptor80 extends SHD80AbstractType implements
|
||||
Cloneable
|
||||
{
|
||||
|
||||
public ShadingDescriptor80()
|
||||
{
|
||||
}
|
||||
|
||||
public ShadingDescriptor80( byte[] buf, int offset )
|
||||
{
|
||||
super();
|
||||
fillFields( buf, offset );
|
||||
}
|
||||
|
||||
public ShadingDescriptor80( short value )
|
||||
{
|
||||
super();
|
||||
field_1_value = value;
|
||||
}
|
||||
|
||||
public ShadingDescriptor80 clone() throws CloneNotSupportedException
|
||||
{
|
||||
return (ShadingDescriptor80) super.clone();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return field_1_value == 0;
|
||||
}
|
||||
|
||||
public byte[] serialize()
|
||||
{
|
||||
byte[] result = new byte[getSize()];
|
||||
serialize( result, 0 );
|
||||
return result;
|
||||
}
|
||||
|
||||
public ShadingDescriptor toShadingDescriptor()
|
||||
{
|
||||
ShadingDescriptor result = new ShadingDescriptor();
|
||||
result.setCvFore( Colorref.valueOfIco( getIcoFore() ) );
|
||||
result.setCvBack( Colorref.valueOfIco( getIcoBack() ) );
|
||||
result.setIpat( getIpat() );
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if ( isEmpty() )
|
||||
return "[SHD80] EMPTY";
|
||||
|
||||
return "[SHD80] (icoFore: " + getIcoFore() + "; icoBack: "
|
||||
+ getIcoBack() + "; iPat: " + getIpat() + ")";
|
||||
}
|
||||
|
||||
}
|
|
@ -132,8 +132,6 @@
|
|||
|
||||
<field type="byte" size="1" name="jc"/>
|
||||
|
||||
<field type="boolean" size="1" name="fNoAllowOverlap"/>
|
||||
|
||||
<field type="BorderCode" size="4" name="brcTop"/>
|
||||
<field type="BorderCode" size="4" name="brcLeft"/>
|
||||
<field type="BorderCode" size="4" name="brcBottom"/>
|
||||
|
@ -141,17 +139,22 @@
|
|||
<field type="BorderCode" size="4" name="brcBetween"/>
|
||||
<field type="BorderCode" size="4" name="brcBar"/>
|
||||
|
||||
<field type="ShadingDescriptor" size="2" name="shd"/>
|
||||
<field type="ShadingDescriptor" size="10" name="shd"/>
|
||||
<field type="byte[]" size="84" name="anld"/>
|
||||
<field type="byte[]" size="12" name="phe"/>
|
||||
<field type="boolean" size="1" name="fPropRMark"/>
|
||||
<field type="int" size="2" name="ibstPropRMark"/>
|
||||
<field type="DateAndTime" size="4" name="dttmPropRMark"/>
|
||||
|
||||
<field type="int" size="2" name="itbdMac"/>
|
||||
<field type="int[]" size="128" name="rgdxaTab"/>
|
||||
<field type="byte[]" size="128" name="rgtbd"/>
|
||||
<field type="int" size="2" name="itbdMac" description="Number of tabs stops defined for paragraph. Must be >= 0 and <= 64."/>
|
||||
<field type="int[]" size="128" name="rgdxaTab" description="Array of positions of itbdMac tab stops. itbdMax==64"/>
|
||||
<field type="TabDescriptor[]" size="64" name="rgtbd" description="Array of itbdMac tab descriptors"/>
|
||||
|
||||
<field type="byte[]" size="128" name="numrm"/>
|
||||
<field type="byte[]" size="4" name="ptap"/>
|
||||
|
||||
<field type="boolean" size="1" name="fNoAllowOverlap" description="When 1, absolutely positioned paragraph cannot overlap with another paragraph"/>
|
||||
<field type="long" size="4" name="ipgp" description="HTML DIV ID for this paragraph"/>
|
||||
<field type="long" size="4" name="rsid" description="Save ID for last time this PAP was revised"/>
|
||||
</fields>
|
||||
</record>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
====================================================================
|
||||
-->
|
||||
<record fromfile="true" name="SHD80" package="org.apache.poi.hwpf.model.types">
|
||||
<suffix>AbstractType</suffix>
|
||||
<description>The SHD80 is a substructure of the CHP and PAP, and TC for Word 97. <p>Class
|
||||
and fields descriptions are quoted from
|
||||
Microsoft Office Word 97-2007 Binary File Format
|
||||
</description>
|
||||
<author>Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format
|
||||
Specification [*.doc]
|
||||
</author>
|
||||
<fields>
|
||||
<field type="short" size="2" name="value">
|
||||
<bit number="1" mask="0x001F" name="icoFore" description="Foreground color" />
|
||||
<bit number="2" mask="0x03E0" name="icoBack" description="Background color" />
|
||||
<bit number="3" mask="0xFC00" name="ipat" description="Shading pattern"/>
|
||||
</field>
|
||||
</fields>
|
||||
</record>
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
====================================================================
|
||||
-->
|
||||
<record fromfile="true" name="SHD" package="org.apache.poi.hwpf.model.types">
|
||||
<suffix>AbstractType</suffix>
|
||||
<description>The SHD is a substructure of the CHP, PAP, and TC for Word 2000. <p>Class
|
||||
and
|
||||
fields descriptions are quoted from Microsoft Office Word 97-2007 Binary File Format
|
||||
</description>
|
||||
<author>Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format
|
||||
Specification [*.doc]
|
||||
</author>
|
||||
<fields>
|
||||
<field type="Colorref" size="4" name="cvFore" description="24-bit foreground color"/>
|
||||
<field type="Colorref" size="4" name="cvBack" description="24-bit background color"/>
|
||||
<field type="int" size="2" name="ipat" description="Shading pattern"/>
|
||||
</fields>
|
||||
</record>
|
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
====================================================================
|
||||
-->
|
||||
<record fromfile="true" name="TBD" package="org.apache.poi.hwpf.model.types">
|
||||
<suffix>AbstractType</suffix>
|
||||
<description>The TBD is a substructure of the PAP. <p>Class and fields descriptions are quoted from
|
||||
Microsoft Office Word 97-2007 Binary File Format
|
||||
</description>
|
||||
<author>Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format
|
||||
Specification [*.doc]
|
||||
</author>
|
||||
<fields>
|
||||
<field type="byte" size="1" name="value" >
|
||||
<bit number="0" mask="0x07" name="jc" description="Justification code">
|
||||
<const type="byte" value="0" name="LEFT"/>
|
||||
<const type="byte" value="1" name="CENTERED"/>
|
||||
<const type="byte" value="2" name="RIGHT"/>
|
||||
<const type="byte" value="3" name="DECIMAL"/>
|
||||
<const type="byte" value="4" name="BAR"/>
|
||||
</bit>
|
||||
<bit number="0" mask="0x38" name="tlc" description="Tab leader code">
|
||||
<const type="byte" value="0" name="NONE"/>
|
||||
<const type="byte" value="1" name="DOTTED"/>
|
||||
<const type="byte" value="2" name="HYPENATED"/>
|
||||
<const type="byte" value="3" name="SINGLELINE"/>
|
||||
<const type="byte" value="4" name="HEAVYLINE"/>
|
||||
<const type="byte" value="5" name="MIDDLEDOT"/>
|
||||
</bit>
|
||||
<bit number="3" mask="0xc0" name="reserved" />
|
||||
</field>
|
||||
</fields>
|
||||
</record>
|
Loading…
Reference in New Issue