import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.apache.poi.hwpf.model.StyleDescription;
-
import org.apache.poi.POIDocument;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.HWPFDocumentCore;
import org.apache.poi.hwpf.model.FieldsDocumentPart;
import org.apache.poi.hwpf.model.FileInformationBlock;
import org.apache.poi.hwpf.model.GenericPropertyNode;
+import org.apache.poi.hwpf.model.ListFormatOverride;
+import org.apache.poi.hwpf.model.ListLevel;
+import org.apache.poi.hwpf.model.ListTables;
import org.apache.poi.hwpf.model.PAPFormattedDiskPage;
import org.apache.poi.hwpf.model.PAPX;
import org.apache.poi.hwpf.model.PlexOfCps;
+import org.apache.poi.hwpf.model.StyleDescription;
import org.apache.poi.hwpf.model.StyleSheet;
import org.apache.poi.hwpf.model.TextPiece;
import org.apache.poi.hwpf.sprm.SprmIterator;
import org.apache.poi.hwpf.usermodel.Field;
import org.apache.poi.hwpf.usermodel.OfficeDrawing;
import org.apache.poi.hwpf.usermodel.Paragraph;
+import org.apache.poi.hwpf.usermodel.ParagraphProperties;
import org.apache.poi.hwpf.usermodel.Picture;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.poifs.common.POIFSConstants;
{
SprmIterator sprmIt = new SprmIterator(
papx.getGrpprl(), 2 );
- while ( sprmIt.hasNext() )
- {
- SprmOperation sprm = sprmIt.next();
- System.out.println( "*** " + sprm.toString() );
- }
+ dumpSprms( sprmIt, "*** " );
}
}
if ( papx != null && withSprms )
{
SprmIterator sprmIt = new SprmIterator( papx.getGrpprl(), 2 );
- while ( sprmIt.hasNext() )
- {
- SprmOperation sprm = sprmIt.next();
- System.out.println( "*** " + sprm.toString() );
- }
+ dumpSprms( sprmIt, "*** " );
}
}
}
+ Method newParagraph = Paragraph.class.getDeclaredMethod(
+ "newParagraph", Range.class, PAPX.class );
+ newParagraph.setAccessible( true );
+ java.lang.reflect.Field _props = Paragraph.class
+ .getDeclaredField( "_props" );
+ _props.setAccessible( true );
+
for ( PAPX papx : _doc.getParagraphTable().getParagraphs() )
{
System.out.println( papx );
if ( withProperties )
- System.out.println( papx.getParagraphProperties( _doc
- .getStyleSheet() ) );
+ {
+ Paragraph paragraph = (Paragraph) newParagraph.invoke( null,
+ _doc.getOverallRange(), papx );
+ System.out.println( _props.get( paragraph ) );
+ }
if ( true )
{
SprmIterator sprmIt = new SprmIterator( papx.getGrpprl(), 2 );
- while ( sprmIt.hasNext() )
- {
- SprmOperation sprm = sprmIt.next();
- System.out.println( "\t" + sprm.toString() );
- }
+ dumpSprms( sprmIt, "\t" );
}
}
}
SprmIterator sprmIt = new SprmIterator(
papx.getGrpprl(), 2 );
- while ( sprmIt.hasNext() )
- {
- SprmOperation sprm = sprmIt.next();
- System.out.println( "** " + sprm.toString() );
- }
+ dumpSprms( sprmIt, "** " );
}
}
if ( !hasAssotiatedPapx )
}
}
+ protected void dumpSprms( SprmIterator sprmIt, String linePrefix )
+ {
+ while ( sprmIt.hasNext() )
+ {
+ SprmOperation sprm = sprmIt.next();
+ System.out.println( linePrefix + sprm.toString() );
+ }
+ }
+
public void dumpParagraphsDom( boolean withText )
{
Range range = _doc.getOverallRange();
return;
}
HWPFDocument hwpfDocument = (HWPFDocument) _doc;
+ ListTables listTables = hwpfDocument.getListTables();
+
for ( int s = 0; s < hwpfDocument.getStyleSheet().numStyles(); s++ )
{
StyleDescription styleDescription = hwpfDocument.getStyleSheet()
System.out.println( "=== Style #" + s + " '"
+ styleDescription.getName() + "' ===" );
System.out.println( styleDescription );
- System.out.println( "PAP:" + styleDescription.getPAP() );
- System.out.println( "CHP:" + styleDescription.getCHP() );
+
+ ParagraphProperties paragraph = styleDescription.getPAP();
+ System.out.println( "PAP: " + paragraph );
+ if ( paragraph != null )
+ {
+ dumpParagraphLevels( listTables, paragraph );
+ }
+ System.out.println( "CHP: " + styleDescription.getCHP() );
+ }
+ }
+
+ protected void dumpParagraphLevels( ListTables listTables,
+ ParagraphProperties paragraph )
+ {
+ if ( paragraph.getIlfo() != 0 )
+ {
+ final ListFormatOverride listFormatOverride = listTables
+ .getOverride( paragraph.getIlfo() );
+
+ System.out.println( "PAP's LFO: " + listFormatOverride );
+
+ final ListLevel listLevel = listTables.getLevel(
+ listFormatOverride.getLsid(), paragraph.getIlvl() );
+
+ System.out.println( "PAP's ListLevel: " + listLevel );
+ if ( listLevel.getGrpprlPapx() != null )
+ {
+ System.out.println( "PAP's ListLevel PAPX:" );
+ dumpSprms( new SprmIterator( listLevel.getGrpprlPapx(), 0 ),
+ "* " );
+ }
+
+ if ( listLevel.getGrpprlPapx() != null )
+ {
+ System.out.println( "PAP's ListLevel CHPX:" );
+ dumpSprms( new SprmIterator( listLevel.getGrpprlChpx(), 0 ),
+ "* " );
+ }
}
}
--- /dev/null
+/* ====================================================================
+ 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.util.Internal;
+
+import org.apache.poi.hwpf.model.types.LFOAbstractType;
+
+/**
+ * "The LFO structure specifies the LSTF element that corresponds to a list that
+ * contains a paragraph. An LFO can also specify formatting information that
+ * overrides the LSTF element to which it corresponds." -- [MS-DOC] -- v20110315
+ * Word (.doc) Binary File Format
+ *
+ * @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
+ */
+@Internal
+class LFO extends LFOAbstractType
+{
+
+ public LFO()
+ {
+ }
+
+ public LFO( byte[] std, int offset )
+ {
+ fillFields( std, offset );
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ LFO other = (LFO) obj;
+ if ( field_1_lsid != other.field_1_lsid )
+ return false;
+ if ( field_2_reserved1 != other.field_2_reserved1 )
+ return false;
+ if ( field_3_reserved2 != other.field_3_reserved2 )
+ return false;
+ if ( field_4_clfolvl != other.field_4_clfolvl )
+ return false;
+ if ( field_5_ibstFltAutoNum != other.field_5_ibstFltAutoNum )
+ return false;
+ if ( field_6_grfhic != other.field_6_grfhic )
+ return false;
+ if ( field_7_reserved3 != other.field_7_reserved3 )
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + field_1_lsid;
+ result = prime * result + field_2_reserved1;
+ result = prime * result + field_3_reserved2;
+ result = prime * result + field_4_clfolvl;
+ result = prime * result + field_5_ibstFltAutoNum;
+ result = prime * result + field_6_grfhic;
+ result = prime * result + field_7_reserved3;
+ return result;
+ }
+}
package org.apache.poi.hwpf.model;
-import org.apache.poi.hwpf.model.types.LFOAbstractType;
import org.apache.poi.util.Internal;
@Internal
-public final class ListFormatOverride extends LFOAbstractType
+public final class ListFormatOverride
{
+
private ListFormatOverrideLevel[] _levelOverrides;
+ private LFO _lfo;
+
public ListFormatOverride( byte[] buf, int offset )
{
- fillFields( buf, offset );
-
- _levelOverrides = new ListFormatOverrideLevel[getClfolvl()];
+ _lfo = new LFO( buf, offset );
+ _levelOverrides = new ListFormatOverrideLevel[_lfo.getClfolvl()];
}
public ListFormatOverride( int lsid )
{
- setLsid( lsid );
+ _lfo = new LFO();
+ _lfo.setLsid( lsid );
_levelOverrides = new ListFormatOverrideLevel[0];
}
return _levelOverrides;
}
+ public int getLsid()
+ {
+ return _lfo.getLsid();
+ }
+
public ListFormatOverrideLevel getOverrideLevel( int level )
{
public int numOverrides()
{
- return getClfolvl();
+ return _lfo.getClfolvl();
+ }
+
+ public void setLsid( int lsid )
+ {
+ _lfo.setLsid( lsid );
}
public void setOverride( int index, ListFormatOverrideLevel lfolvl )
public byte[] toByteArray()
{
- byte[] bs = new byte[getSize()];
- serialize( bs, 0 );
- return bs;
+ return _lfo.serialize();
}
}
* See page 170 for details.
*/
@Internal
-public final class ListLevel
+public final class ListLevel
{
-// private int _iStartAt;
-// private byte _nfc;
-// private byte _info;
-// /* */private static BitField _jc;
-// /* */private static BitField _fLegal;
-// /* */private static BitField _fNoRestart;
-// /* */private static BitField _fPrev;
-// /* */private static BitField _fPrevSpace;
-// /* */private static BitField _fWord6;
-// private byte[] _rgbxchNums;
-// private byte _ixchFollow;
-// private int _dxaSpace;
-// private int _dxaIndent;
-// private int _cbGrpprlChpx;
-// private int _cbGrpprlPapx;
-// private short _reserved;
- private LVLF _lvlf;
- private byte[] _grpprlPapx;
private byte[] _grpprlChpx;
+ private byte[] _grpprlPapx;
+ private LVLF _lvlf;
private char[] _numberText = null;
public ListLevel( final byte[] buf, final int originalOffset )
{
int offset = originalOffset;
- _lvlf = new LVLF(buf, offset);
+ _lvlf = new LVLF( buf, offset );
offset += LVLF.getSize();
_grpprlPapx = new byte[_lvlf.getCbGrpprlPapx()];
_grpprlPapx = new byte[0];
_grpprlChpx = new byte[0];
_numberText = new char[0];
-
+
if ( numbered )
{
_lvlf.getRgbxchNums()[0] = 1;
return _lvlf.getJc();
}
+ public byte[] getGrpprlChpx()
+ {
+ return _grpprlChpx;
+ }
+
+ public byte[] getGrpprlPapx()
+ {
+ return _grpprlPapx;
+ }
+
public byte[] getLevelProperties()
{
return _grpprlPapx;
return buf;
}
+ @Override
+ public String toString()
+ {
+ return "ListLevel: " + ( "\n" + _lvlf ).replaceAll( "\n", "\n " )
+ + "\n"
+ + ( "PAPX's grpprl: " + Arrays.toString( _grpprlPapx ) + "\n" )
+ + ( "CHPX's grpprl: " + Arrays.toString( _grpprlChpx ) + "\n" );
+ }
}
return (SprmBuffer)_buf;
}
+ @Deprecated
+ @Internal
public ParagraphProperties getParagraphProperties(StyleSheet ss)
{
if(ss == null) {
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
-import org.apache.poi.hwpf.sprm.SprmIterator;
-
import org.apache.poi.hwpf.usermodel.CharacterProperties;
import org.apache.poi.hwpf.usermodel.ParagraphProperties;
import org.apache.poi.util.Internal;
UPX[] _upxs;
String _name;
+ @Deprecated
ParagraphProperties _pap;
+ @Deprecated
CharacterProperties _chp;
public StyleDescription()
return null;
}
}
+ @Deprecated
public ParagraphProperties getPAP()
{
return _pap;
}
+ @Deprecated
public CharacterProperties getCHP()
{
return _chp;
}
+ @Deprecated
void setPAP(ParagraphProperties pap)
{
_pap = pap;
}
+ @Deprecated
void setCHP(CharacterProperties chp)
{
_chp = chp;
private static final int SEP_TYPE = 4;
private static final int TAP_TYPE = 5;
+ @Deprecated
+ private final static ParagraphProperties NIL_PAP = new ParagraphProperties();
+ @Deprecated
+ private final static CharacterProperties NIL_CHP = new CharacterProperties();
- private final static ParagraphProperties NIL_PAP = new ParagraphProperties();
- private final static CharacterProperties NIL_CHP = new CharacterProperties();
+ private final static byte[] NIL_CHPX = new byte[] {};
+ private final static byte[] NIL_PAPX = new byte[] {0, 0};
/**
* Size of the STSHI structure
* @param istd The index of the StyleDescription to create the
* ParagraphProperties from (and also place the finished PAP in)
*/
+ @Deprecated
private void createPap(int istd)
{
StyleDescription sd = _styleDescriptions[istd];
* @param istd The index of the StyleDescription to create the
* CharacterProperties object from.
*/
+ @Deprecated
private void createChp(int istd)
{
StyleDescription sd = _styleDescriptions[istd];
return _styleDescriptions.length;
}
- /**
- * Gets the StyleDescription at index x.
- *
- * @param x the index of the desired StyleDescription.
- */
- public StyleDescription getStyleDescription(int x)
- {
- return _styleDescriptions[x];
- }
-
- public CharacterProperties getCharacterStyle(int x)
- {
- if (x == NIL_STYLE)
+ /**
+ * Gets the StyleDescription at index x.
+ *
+ * @param styleIndex
+ * the index of the desired StyleDescription.
+ */
+ public StyleDescription getStyleDescription( int styleIndex )
{
- return NIL_CHP;
+ return _styleDescriptions[styleIndex];
}
- if (x>=_styleDescriptions.length) {
- return NIL_CHP;
- }
+ @Deprecated
+ public CharacterProperties getCharacterStyle( int styleIndex )
+ {
+ if ( styleIndex == NIL_STYLE )
+ {
+ return NIL_CHP;
+ }
- return (_styleDescriptions[x] != null ? _styleDescriptions[x].getCHP() : NIL_CHP);
- }
+ if ( styleIndex >= _styleDescriptions.length )
+ {
+ return NIL_CHP;
+ }
- public ParagraphProperties getParagraphStyle(int x)
- {
- if (x == NIL_STYLE) {
- return NIL_PAP;
+ return ( _styleDescriptions[styleIndex] != null ? _styleDescriptions[styleIndex]
+ .getCHP() : NIL_CHP );
}
- if (x >= _styleDescriptions.length) {
- return NIL_PAP;
- }
+ @Deprecated
+ public ParagraphProperties getParagraphStyle( int styleIndex )
+ {
+ if ( styleIndex == NIL_STYLE )
+ {
+ return NIL_PAP;
+ }
+
+ if ( styleIndex >= _styleDescriptions.length )
+ {
+ return NIL_PAP;
+ }
+
+ if ( _styleDescriptions[styleIndex] == null )
+ {
+ return NIL_PAP;
+ }
+
+ if ( _styleDescriptions[styleIndex].getPAP() == null )
+ {
+ return NIL_PAP;
+ }
- if (_styleDescriptions[x]==null) {
- return NIL_PAP;
+ return _styleDescriptions[styleIndex].getPAP();
}
- if (_styleDescriptions[x].getPAP()==null) {
- return NIL_PAP;
+ public byte[] getCHPX( int styleIndex )
+ {
+ if ( styleIndex == NIL_STYLE )
+ {
+ return NIL_CHPX;
+ }
+
+ if ( styleIndex >= _styleDescriptions.length )
+ {
+ return NIL_CHPX;
+ }
+
+ if ( _styleDescriptions[styleIndex] == null )
+ {
+ return NIL_CHPX;
+ }
+
+ if ( _styleDescriptions[styleIndex].getCHPX() == null )
+ {
+ return NIL_CHPX;
+ }
+
+ return _styleDescriptions[styleIndex].getCHPX();
}
- return _styleDescriptions[x].getPAP();
- }
+ public byte[] getPAPX( int styleIndex )
+ {
+ if ( styleIndex == NIL_STYLE )
+ {
+ return NIL_PAPX;
+ }
+
+ if ( styleIndex >= _styleDescriptions.length )
+ {
+ return NIL_PAPX;
+ }
+
+ if ( _styleDescriptions[styleIndex] == null )
+ {
+ return NIL_PAPX;
+ }
+
+ if ( _styleDescriptions[styleIndex].getPAPX() == null )
+ {
+ return NIL_PAPX;
+ }
+
+ return _styleDescriptions[styleIndex].getPAPX();
+ }
}
import org.apache.poi.util.LittleEndian;\r
\r
/**\r
- * List Format Override (LFO).\r
+ * List Format Override (LFO). <p>Class and fields descriptions are quoted from\r
+ Microsoft Office Word 97-2007 Binary File Format\r
+ \r
* <p>\r
- * Class and fields descriptions are quoted from Microsoft Office Word 97-2007\r
- * Binary File Format\r
- * \r
- * NOTE: This source is automatically generated please do not modify this file.\r
- * Either subclass or remove the record in src/types/definitions.\r
- * \r
- * @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary\r
- * File Format Specification [*.doc]\r
+ * NOTE: This source is automatically generated please do not modify this file. Either subclass or\r
+ * remove the record in src/types/definitions.\r
+ * <p>\r
+ * This class is internal. It content or properties may change without notice \r
+ * due to changes in our knowledge of internal Microsoft Word binary structures.\r
+\r
+ * @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format\r
+ Specification [*.doc]\r
+ \r
*/\r
@Internal\r
public abstract class LFOAbstractType\r
protected byte field_4_clfolvl;\r
protected byte field_5_ibstFltAutoNum;\r
protected byte field_6_grfhic;\r
- /**/private static BitField fHtmlChecked = new BitField( 0x01 );\r
- /**/private static BitField fHtmlUnsupported = new BitField( 0x02 );\r
- /**/private static BitField fHtmlListTextNotSharpDot = new BitField( 0x04 );\r
- /**/private static BitField fHtmlNotPeriod = new BitField( 0x08 );\r
- /**/private static BitField fHtmlFirstLineMismatch = new BitField( 0x10 );\r
- /**/private static BitField fHtmlTabLeftIndentMismatch = new BitField(\r
- 0x20 );\r
- /**/private static BitField fHtmlHangingIndentBeneathNumber = new BitField(\r
- 0x40 );\r
- /**/private static BitField fHtmlBuiltInBullet = new BitField( 0x80 );\r
+ /**/private static final BitField fHtmlChecked = new BitField(0x01);\r
+ /**/private static final BitField fHtmlUnsupported = new BitField(0x02);\r
+ /**/private static final BitField fHtmlListTextNotSharpDot = new BitField(0x04);\r
+ /**/private static final BitField fHtmlNotPeriod = new BitField(0x08);\r
+ /**/private static final BitField fHtmlFirstLineMismatch = new BitField(0x10);\r
+ /**/private static final BitField fHtmlTabLeftIndentMismatch = new BitField(0x20);\r
+ /**/private static final BitField fHtmlHangingIndentBeneathNumber = new BitField(0x40);\r
+ /**/private static final BitField fHtmlBuiltInBullet = new BitField(0x80);\r
protected byte field_7_reserved3;\r
\r
protected LFOAbstractType()\r
\r
protected void fillFields( byte[] data, int offset )\r
{\r
- field_1_lsid = LittleEndian.getInt( data, 0x0 + offset );\r
- field_2_reserved1 = LittleEndian.getInt( data, 0x4 + offset );\r
- field_3_reserved2 = LittleEndian.getInt( data, 0x8 + offset );\r
- field_4_clfolvl = data[0xc + offset];\r
- field_5_ibstFltAutoNum = data[0xd + offset];\r
- field_6_grfhic = data[0xe + offset];\r
- field_7_reserved3 = data[0xf + offset];\r
+ field_1_lsid = LittleEndian.getInt( data, 0x0 + offset );\r
+ field_2_reserved1 = LittleEndian.getInt( data, 0x4 + offset );\r
+ field_3_reserved2 = LittleEndian.getInt( data, 0x8 + offset );\r
+ field_4_clfolvl = data[ 0xc + offset ];\r
+ field_5_ibstFltAutoNum = data[ 0xd + offset ];\r
+ field_6_grfhic = data[ 0xe + offset ];\r
+ field_7_reserved3 = data[ 0xf + offset ];\r
}\r
\r
public void serialize( byte[] data, int offset )\r
LittleEndian.putInt( data, 0x0 + offset, field_1_lsid );\r
LittleEndian.putInt( data, 0x4 + offset, field_2_reserved1 );\r
LittleEndian.putInt( data, 0x8 + offset, field_3_reserved2 );\r
- data[0xc + offset] = field_4_clfolvl;\r
- data[0xd + offset] = field_5_ibstFltAutoNum;\r
- data[0xe + offset] = field_6_grfhic;\r
- data[0xf + offset] = field_7_reserved3;\r
+ data[ 0xc + offset ] = field_4_clfolvl;\r
+ data[ 0xd + offset ] = field_5_ibstFltAutoNum;\r
+ data[ 0xe + offset ] = field_6_grfhic;\r
+ data[ 0xf + offset ] = field_7_reserved3;\r
+ }\r
+\r
+ public byte[] serialize()\r
+ {\r
+ final byte[] result = new byte[ getSize() ];\r
+ serialize( result, 0 );\r
+ return result;\r
}\r
\r
/**\r
public String toString()\r
{\r
StringBuilder builder = new StringBuilder();\r
- builder.append( "[LFO]\n" );\r
- builder.append( " .lsid = " );\r
- builder.append( " (" ).append( getLsid() ).append( " )\n" );\r
- builder.append( " .reserved1 = " );\r
- builder.append( " (" ).append( getReserved1() ).append( " )\n" );\r
- builder.append( " .reserved2 = " );\r
- builder.append( " (" ).append( getReserved2() ).append( " )\n" );\r
- builder.append( " .clfolvl = " );\r
- builder.append( " (" ).append( getClfolvl() ).append( " )\n" );\r
- builder.append( " .ibstFltAutoNum = " );\r
- builder.append( " (" ).append( getIbstFltAutoNum() ).append( " )\n" );\r
- builder.append( " .grfhic = " );\r
- builder.append( " (" ).append( getGrfhic() ).append( " )\n" );\r
- builder.append( " .fHtmlChecked = " )\r
- .append( isFHtmlChecked() ).append( '\n' );\r
- builder.append( " .fHtmlUnsupported = " )\r
- .append( isFHtmlUnsupported() ).append( '\n' );\r
- builder.append( " .fHtmlListTextNotSharpDot = " )\r
- .append( isFHtmlListTextNotSharpDot() ).append( '\n' );\r
- builder.append( " .fHtmlNotPeriod = " )\r
- .append( isFHtmlNotPeriod() ).append( '\n' );\r
- builder.append( " .fHtmlFirstLineMismatch = " )\r
- .append( isFHtmlFirstLineMismatch() ).append( '\n' );\r
- builder.append( " .fHtmlTabLeftIndentMismatch = " )\r
- .append( isFHtmlTabLeftIndentMismatch() ).append( '\n' );\r
- builder.append( " .fHtmlHangingIndentBeneathNumber = " )\r
- .append( isFHtmlHangingIndentBeneathNumber() ).append( '\n' );\r
- builder.append( " .fHtmlBuiltInBullet = " )\r
- .append( isFHtmlBuiltInBullet() ).append( '\n' );\r
- builder.append( " .reserved3 = " );\r
- builder.append( " (" ).append( getReserved3() ).append( " )\n" );\r
-\r
- builder.append( "[/LFO]\n" );\r
+ builder.append("[LFO]\n");\r
+ builder.append(" .lsid = ");\r
+ builder.append(" (").append(getLsid()).append(" )\n");\r
+ builder.append(" .reserved1 = ");\r
+ builder.append(" (").append(getReserved1()).append(" )\n");\r
+ builder.append(" .reserved2 = ");\r
+ builder.append(" (").append(getReserved2()).append(" )\n");\r
+ builder.append(" .clfolvl = ");\r
+ builder.append(" (").append(getClfolvl()).append(" )\n");\r
+ builder.append(" .ibstFltAutoNum = ");\r
+ builder.append(" (").append(getIbstFltAutoNum()).append(" )\n");\r
+ builder.append(" .grfhic = ");\r
+ builder.append(" (").append(getGrfhic()).append(" )\n");\r
+ builder.append(" .fHtmlChecked = ").append(isFHtmlChecked()).append('\n');\r
+ builder.append(" .fHtmlUnsupported = ").append(isFHtmlUnsupported()).append('\n');\r
+ builder.append(" .fHtmlListTextNotSharpDot = ").append(isFHtmlListTextNotSharpDot()).append('\n');\r
+ builder.append(" .fHtmlNotPeriod = ").append(isFHtmlNotPeriod()).append('\n');\r
+ builder.append(" .fHtmlFirstLineMismatch = ").append(isFHtmlFirstLineMismatch()).append('\n');\r
+ builder.append(" .fHtmlTabLeftIndentMismatch = ").append(isFHtmlTabLeftIndentMismatch()).append('\n');\r
+ builder.append(" .fHtmlHangingIndentBeneathNumber = ").append(isFHtmlHangingIndentBeneathNumber()).append('\n');\r
+ builder.append(" .fHtmlBuiltInBullet = ").append(isFHtmlBuiltInBullet()).append('\n');\r
+ builder.append(" .reserved3 = ");\r
+ builder.append(" (").append(getReserved3()).append(" )\n");\r
+\r
+ builder.append("[/LFO]\n");\r
return builder.toString();\r
}\r
\r
/**\r
* List ID of corresponding LSTF (see LSTF).\r
*/\r
+ @Internal\r
public int getLsid()\r
{\r
return field_1_lsid;\r
/**\r
* List ID of corresponding LSTF (see LSTF).\r
*/\r
+ @Internal\r
public void setLsid( int field_1_lsid )\r
{\r
this.field_1_lsid = field_1_lsid;\r
/**\r
* Reserved.\r
*/\r
+ @Internal\r
public int getReserved1()\r
{\r
return field_2_reserved1;\r
/**\r
* Reserved.\r
*/\r
+ @Internal\r
public void setReserved1( int field_2_reserved1 )\r
{\r
this.field_2_reserved1 = field_2_reserved1;\r
/**\r
* Reserved.\r
*/\r
+ @Internal\r
public int getReserved2()\r
{\r
return field_3_reserved2;\r
/**\r
* Reserved.\r
*/\r
+ @Internal\r
public void setReserved2( int field_3_reserved2 )\r
{\r
this.field_3_reserved2 = field_3_reserved2;\r
/**\r
* Count of levels whose format is overridden (see LFOLVL).\r
*/\r
+ @Internal\r
public byte getClfolvl()\r
{\r
return field_4_clfolvl;\r
/**\r
* Count of levels whose format is overridden (see LFOLVL).\r
*/\r
+ @Internal\r
public void setClfolvl( byte field_4_clfolvl )\r
{\r
this.field_4_clfolvl = field_4_clfolvl;\r
/**\r
* Used for AUTONUM field emulation.\r
*/\r
+ @Internal\r
public byte getIbstFltAutoNum()\r
{\r
return field_5_ibstFltAutoNum;\r
/**\r
* Used for AUTONUM field emulation.\r
*/\r
+ @Internal\r
public void setIbstFltAutoNum( byte field_5_ibstFltAutoNum )\r
{\r
this.field_5_ibstFltAutoNum = field_5_ibstFltAutoNum;\r
/**\r
* HTML compatibility flags.\r
*/\r
+ @Internal\r
public byte getGrfhic()\r
{\r
return field_6_grfhic;\r
/**\r
* HTML compatibility flags.\r
*/\r
+ @Internal\r
public void setGrfhic( byte field_6_grfhic )\r
{\r
this.field_6_grfhic = field_6_grfhic;\r
/**\r
* Reserved.\r
*/\r
+ @Internal\r
public byte getReserved3()\r
{\r
return field_7_reserved3;\r
/**\r
* Reserved.\r
*/\r
+ @Internal\r
public void setReserved3( byte field_7_reserved3 )\r
{\r
this.field_7_reserved3 = field_7_reserved3;\r
}\r
\r
/**\r
- * Sets the fHtmlChecked field value. Checked\r
+ * Sets the fHtmlChecked field value.\r
+ * Checked\r
*/\r
+ @Internal\r
public void setFHtmlChecked( boolean value )\r
{\r
- field_6_grfhic = (byte) fHtmlChecked.setBoolean( field_6_grfhic, value );\r
+ field_6_grfhic = (byte)fHtmlChecked.setBoolean(field_6_grfhic, value);\r
}\r
\r
/**\r
* Checked\r
- * \r
- * @return the fHtmlChecked field value.\r
+ * @return the fHtmlChecked field value.\r
*/\r
+ @Internal\r
public boolean isFHtmlChecked()\r
{\r
- return fHtmlChecked.isSet( field_6_grfhic );\r
+ return fHtmlChecked.isSet(field_6_grfhic);\r
}\r
\r
/**\r
- * Sets the fHtmlUnsupported field value. The numbering sequence or format\r
- * is unsupported (includes tab & size)\r
+ * Sets the fHtmlUnsupported field value.\r
+ * The numbering sequence or format is unsupported (includes tab & size)\r
*/\r
+ @Internal\r
public void setFHtmlUnsupported( boolean value )\r
{\r
- field_6_grfhic = (byte) fHtmlUnsupported.setBoolean( field_6_grfhic,\r
- value );\r
+ field_6_grfhic = (byte)fHtmlUnsupported.setBoolean(field_6_grfhic, value);\r
}\r
\r
/**\r
* The numbering sequence or format is unsupported (includes tab & size)\r
- * \r
- * @return the fHtmlUnsupported field value.\r
+ * @return the fHtmlUnsupported field value.\r
*/\r
+ @Internal\r
public boolean isFHtmlUnsupported()\r
{\r
- return fHtmlUnsupported.isSet( field_6_grfhic );\r
+ return fHtmlUnsupported.isSet(field_6_grfhic);\r
}\r
\r
/**\r
- * Sets the fHtmlListTextNotSharpDot field value. The list text is not "#."\r
+ * Sets the fHtmlListTextNotSharpDot field value.\r
+ * The list text is not "#."\r
*/\r
+ @Internal\r
public void setFHtmlListTextNotSharpDot( boolean value )\r
{\r
- field_6_grfhic = (byte) fHtmlListTextNotSharpDot.setBoolean(\r
- field_6_grfhic, value );\r
+ field_6_grfhic = (byte)fHtmlListTextNotSharpDot.setBoolean(field_6_grfhic, value);\r
}\r
\r
/**\r
* The list text is not "#."\r
- * \r
- * @return the fHtmlListTextNotSharpDot field value.\r
+ * @return the fHtmlListTextNotSharpDot field value.\r
*/\r
+ @Internal\r
public boolean isFHtmlListTextNotSharpDot()\r
{\r
- return fHtmlListTextNotSharpDot.isSet( field_6_grfhic );\r
+ return fHtmlListTextNotSharpDot.isSet(field_6_grfhic);\r
}\r
\r
/**\r
- * Sets the fHtmlNotPeriod field value. Something other than a period is\r
- * used\r
+ * Sets the fHtmlNotPeriod field value.\r
+ * Something other than a period is used\r
*/\r
+ @Internal\r
public void setFHtmlNotPeriod( boolean value )\r
{\r
- field_6_grfhic = (byte) fHtmlNotPeriod.setBoolean( field_6_grfhic,\r
- value );\r
+ field_6_grfhic = (byte)fHtmlNotPeriod.setBoolean(field_6_grfhic, value);\r
}\r
\r
/**\r
* Something other than a period is used\r
- * \r
- * @return the fHtmlNotPeriod field value.\r
+ * @return the fHtmlNotPeriod field value.\r
*/\r
+ @Internal\r
public boolean isFHtmlNotPeriod()\r
{\r
- return fHtmlNotPeriod.isSet( field_6_grfhic );\r
+ return fHtmlNotPeriod.isSet(field_6_grfhic);\r
}\r
\r
/**\r
- * Sets the fHtmlFirstLineMismatch field value. First line indent mismatch\r
+ * Sets the fHtmlFirstLineMismatch field value.\r
+ * First line indent mismatch\r
*/\r
+ @Internal\r
public void setFHtmlFirstLineMismatch( boolean value )\r
{\r
- field_6_grfhic = (byte) fHtmlFirstLineMismatch.setBoolean(\r
- field_6_grfhic, value );\r
+ field_6_grfhic = (byte)fHtmlFirstLineMismatch.setBoolean(field_6_grfhic, value);\r
}\r
\r
/**\r
* First line indent mismatch\r
- * \r
- * @return the fHtmlFirstLineMismatch field value.\r
+ * @return the fHtmlFirstLineMismatch field value.\r
*/\r
+ @Internal\r
public boolean isFHtmlFirstLineMismatch()\r
{\r
- return fHtmlFirstLineMismatch.isSet( field_6_grfhic );\r
+ return fHtmlFirstLineMismatch.isSet(field_6_grfhic);\r
}\r
\r
/**\r
- * Sets the fHtmlTabLeftIndentMismatch field value. The list tab and the\r
- * dxaLeft don't match (need table?)\r
+ * Sets the fHtmlTabLeftIndentMismatch field value.\r
+ * The list tab and the dxaLeft don't match (need table?)\r
*/\r
+ @Internal\r
public void setFHtmlTabLeftIndentMismatch( boolean value )\r
{\r
- field_6_grfhic = (byte) fHtmlTabLeftIndentMismatch.setBoolean(\r
- field_6_grfhic, value );\r
+ field_6_grfhic = (byte)fHtmlTabLeftIndentMismatch.setBoolean(field_6_grfhic, value);\r
}\r
\r
/**\r
* The list tab and the dxaLeft don't match (need table?)\r
- * \r
- * @return the fHtmlTabLeftIndentMismatch field value.\r
+ * @return the fHtmlTabLeftIndentMismatch field value.\r
*/\r
+ @Internal\r
public boolean isFHtmlTabLeftIndentMismatch()\r
{\r
- return fHtmlTabLeftIndentMismatch.isSet( field_6_grfhic );\r
+ return fHtmlTabLeftIndentMismatch.isSet(field_6_grfhic);\r
}\r
\r
/**\r
- * Sets the fHtmlHangingIndentBeneathNumber field value. The hanging indent\r
- * falls beneath the number (need plain text)\r
+ * Sets the fHtmlHangingIndentBeneathNumber field value.\r
+ * The hanging indent falls beneath the number (need plain text)\r
*/\r
+ @Internal\r
public void setFHtmlHangingIndentBeneathNumber( boolean value )\r
{\r
- field_6_grfhic = (byte) fHtmlHangingIndentBeneathNumber.setBoolean(\r
- field_6_grfhic, value );\r
+ field_6_grfhic = (byte)fHtmlHangingIndentBeneathNumber.setBoolean(field_6_grfhic, value);\r
}\r
\r
/**\r
* The hanging indent falls beneath the number (need plain text)\r
- * \r
- * @return the fHtmlHangingIndentBeneathNumber field value.\r
+ * @return the fHtmlHangingIndentBeneathNumber field value.\r
*/\r
+ @Internal\r
public boolean isFHtmlHangingIndentBeneathNumber()\r
{\r
- return fHtmlHangingIndentBeneathNumber.isSet( field_6_grfhic );\r
+ return fHtmlHangingIndentBeneathNumber.isSet(field_6_grfhic);\r
}\r
\r
/**\r
- * Sets the fHtmlBuiltInBullet field value. A built-in HTML bullet\r
+ * Sets the fHtmlBuiltInBullet field value.\r
+ * A built-in HTML bullet\r
*/\r
+ @Internal\r
public void setFHtmlBuiltInBullet( boolean value )\r
{\r
- field_6_grfhic = (byte) fHtmlBuiltInBullet.setBoolean( field_6_grfhic,\r
- value );\r
+ field_6_grfhic = (byte)fHtmlBuiltInBullet.setBoolean(field_6_grfhic, value);\r
}\r
\r
/**\r
* A built-in HTML bullet\r
- * \r
- * @return the fHtmlBuiltInBullet field value.\r
+ * @return the fHtmlBuiltInBullet field value.\r
*/\r
+ @Internal\r
public boolean isFHtmlBuiltInBullet()\r
{\r
- return fHtmlBuiltInBullet.isSet( field_6_grfhic );\r
+ return fHtmlBuiltInBullet.isSet(field_6_grfhic);\r
}\r
\r
-} // END OF CLASS\r
+} // END OF CLASS\r
import org.apache.poi.hwpf.model.ListLevel;
import org.apache.poi.hwpf.model.ListTables;
import org.apache.poi.hwpf.model.PAPX;
+import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
ListLevel _level;
ListFormatOverrideLevel _overrideLevel;
+ @Internal
+ ListEntry( PAPX papx, ParagraphProperties properties, Range parent )
+ {
+ super( papx, properties, parent );
+
+ final ListTables tables = parent._doc.getListTables();
+ if ( tables != null && _props.getIlfo() < tables.getOverrideCount() )
+ {
+ ListFormatOverride override = tables.getOverride( _props.getIlfo() );
+ _overrideLevel = override.getOverrideLevel( _props.getIlvl() );
+ _level = tables.getLevel( override.getLsid(), _props.getIlvl() );
+ }
+ else
+ {
+ log.log( POILogger.WARN,
+ "No ListTables found for ListEntry - document probably partly corrupt, "
+ + "and you may experience problems" );
+ }
+ }
+
+ @Deprecated
ListEntry(PAPX papx, Range parent, ListTables tables)
{
super(papx, parent);
}
}
+ @Deprecated
public int type()
{
return TYPE_LISTENTRY;
package org.apache.poi.hwpf.usermodel;
+import org.apache.poi.hwpf.HWPFDocumentCore;
+
+import org.apache.poi.hwpf.model.ListFormatOverride;
+import org.apache.poi.hwpf.model.ListLevel;
+import org.apache.poi.hwpf.model.ListTables;
import org.apache.poi.hwpf.model.PAPX;
+import org.apache.poi.hwpf.model.StyleSheet;
+import org.apache.poi.hwpf.sprm.ParagraphSprmUncompressor;
import org.apache.poi.hwpf.sprm.SprmBuffer;
import org.apache.poi.hwpf.sprm.TableSprmCompressor;
+import org.apache.poi.util.Internal;
public class Paragraph extends Range implements Cloneable {
public final static short SPRM_JC = 0x2403;
public final static short SPRM_USEPGSUSETTINGS = 0x2447;
public final static short SPRM_FADJUSTRIGHT = 0x2448;
+ @Internal
+ static Paragraph newParagraph( Range parent, PAPX papx )
+ {
+ HWPFDocumentCore doc = parent._doc;
+ ListTables listTables = doc.getListTables();
+ StyleSheet styleSheet = doc.getStyleSheet();
+
+ ParagraphProperties properties = new ParagraphProperties();
+ properties.setIstd( papx.getIstd() );
+
+ if ( styleSheet != null )
+ {
+ int style = papx.getIstd();
+ byte[] grpprl = styleSheet.getPAPX( style );
+ properties = ParagraphSprmUncompressor.uncompressPAP( properties,
+ grpprl, 2 );
+ }
+
+ properties = ParagraphSprmUncompressor.uncompressPAP( properties,
+ papx.getGrpprl(), 2 );
+
+ if ( properties.getIlfo() != 0 && listTables != null )
+ {
+ final ListFormatOverride listFormatOverride = listTables
+ .getOverride( properties.getIlfo() );
+ final ListLevel listLevel = listTables.getLevel(
+ listFormatOverride.getLsid(), properties.getIlvl() );
+
+ if ( listLevel.getGrpprlPapx() != null )
+ {
+ properties = ParagraphSprmUncompressor.uncompressPAP(
+ properties, listLevel.getGrpprlPapx(), 0 );
+ // reapply PAPX properties
+ properties = ParagraphSprmUncompressor.uncompressPAP(
+ properties, papx.getGrpprl(), 2 );
+ }
+ }
+
+ if ( properties.getIlfo() > 0 )
+ return new ListEntry( papx, properties, parent );
+
+ return new Paragraph( papx, properties, parent );
+ }
protected short _istd;
protected ParagraphProperties _props;
protected SprmBuffer _papx;
+ @Deprecated
protected Paragraph( int startIdxInclusive, int endIdxExclusive,
Table parent )
{
_istd = papx.getIstd();
}
- protected Paragraph(PAPX papx, Range parent)
- {
- super(Math.max(parent._start, papx.getStart()), Math.min(parent._end, papx.getEnd()), parent);
- _props = papx.getParagraphProperties(_doc.getStyleSheet());
- _papx = papx.getSprmBuf();
- _istd = papx.getIstd();
- }
+ @Deprecated
+ protected Paragraph( PAPX papx, Range parent )
+ {
+ super( Math.max( parent._start, papx.getStart() ), Math.min(
+ parent._end, papx.getEnd() ), parent );
+ _props = papx.getParagraphProperties( _doc.getStyleSheet() );
+ _papx = papx.getSprmBuf();
+ _istd = papx.getIstd();
+ }
- protected Paragraph(PAPX papx, Range parent, int start)
- {
- super(Math.max(parent._start, start), Math.min(parent._end, papx.getEnd()), parent);
- _props = papx.getParagraphProperties(_doc.getStyleSheet());
- _papx = papx.getSprmBuf();
- _istd = papx.getIstd();
- }
+ @Deprecated
+ protected Paragraph( PAPX papx, Range parent, int start )
+ {
+ super( Math.max( parent._start, start ), Math.min( parent._end,
+ papx.getEnd() ), parent );
+ _props = papx.getParagraphProperties( _doc.getStyleSheet() );
+ _papx = papx.getSprmBuf();
+ _istd = papx.getIstd();
+ }
+
+ @Internal
+ Paragraph( PAPX papx, ParagraphProperties properties, Range parent )
+ {
+ super( Math.max( parent._start, papx.getStart() ), Math.min(
+ parent._end, papx.getEnd() ), parent );
+ _props = properties;
+ _papx = papx.getSprmBuf();
+ _istd = papx.getIstd();
+ }
- public short getStyleIndex()
+public short getStyleIndex()
{
return _istd;
}
+ @Deprecated
public int type()
{
return TYPE_PARAGRAPH;
private POILogger logger = POILogFactory.getLogger( Range.class );
+ @Deprecated
public static final int TYPE_PARAGRAPH = 0;
+ @Deprecated
public static final int TYPE_CHARACTER = 1;
+ @Deprecated
public static final int TYPE_SECTION = 2;
+ @Deprecated
public static final int TYPE_TEXT = 3;
+ @Deprecated
public static final int TYPE_LISTENTRY = 4;
+ @Deprecated
public static final int TYPE_TABLE = 5;
+ @Deprecated
public static final int TYPE_UNDEFINED = 6;
/** Needed so inserts and deletes will ripple up through containing Ranges */
+ "; " + _parEnd + ")" );
PAPX papx = _paragraphs.get(index + _parStart);
-
- ParagraphProperties props = papx.getParagraphProperties(_doc.getStyleSheet());
- Paragraph pap = null;
- if (props.getIlfo() > 0) {
- pap = new ListEntry(papx, this, _doc.getListTables());
- } else {
- if (((index + _parStart)==0) && papx.getStart()>0) {
- pap = new Paragraph(papx, this, 0);
- } else {
- pap = new Paragraph(papx, this);
- }
- }
-
- return pap;
+ return Paragraph.newParagraph( this, papx );
}
/**
*
* @return A TYPE constant.
*/
+ @Deprecated
public int type() {
return TYPE_UNDEFINED;
}
if ( r._parStart != 0 )
{
- Paragraph previous = new Paragraph(
- _paragraphs.get( r._parStart - 1 ), this );
+ Paragraph previous = Paragraph.newParagraph( this,
+ _paragraphs.get( r._parStart - 1 ) );
if ( previous.isInTable() && //
previous.getTableLevel() == tableLevel //
&& previous._sectionEnd >= r._sectionStart )
int limit = _paragraphs.size();
for ( ; tableEndInclusive < limit - 1; tableEndInclusive++ )
{
- Paragraph next = new Paragraph(
- _paragraphs.get( tableEndInclusive + 1 ), overallRange );
+ Paragraph next = Paragraph.newParagraph( overallRange,
+ _paragraphs.get( tableEndInclusive + 1 ) );
if ( !next.isInTable() || next.getTableLevel() < tableLevel )
break;
}