You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by sa...@apache.org on 2004/03/10 05:18:56 UTC

cvs commit: jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel CharacterRun.java ListEntry.java Paragraph.java ParagraphProperties.java Range.java TableRow.java

sackley     2004/03/09 20:18:56

  Modified:    src/scratchpad/src/org/apache/poi/hwpf/usermodel
                        CharacterRun.java ListEntry.java Paragraph.java
                        ParagraphProperties.java Range.java TableRow.java
  Log:
  patch from piers and other minor changes
  
  Revision  Changes    Path
  1.5       +6 -0      jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java
  
  Index: CharacterRun.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CharacterRun.java	5 Mar 2004 13:07:55 -0000	1.4
  +++ CharacterRun.java	10 Mar 2004 04:18:56 -0000	1.5
  @@ -447,6 +447,12 @@
       _chpx.addSprm(SPRM_HIGHLIGHT, color);
     }
   
  +  public int getFontNameIndex()
  +  {
  +    return _props.getFtcAscii();
  +  }
  +
  +
     /**
     * Get the ico24 field for the CHP record.
     */
  
  
  
  1.3       +6 -6      jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/ListEntry.java
  
  Index: ListEntry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/ListEntry.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ListEntry.java	5 Mar 2004 13:07:55 -0000	1.2
  +++ ListEntry.java	10 Mar 2004 04:18:56 -0000	1.3
  @@ -4,6 +4,7 @@
   import org.apache.poi.hwpf.model.ListFormatOverrideLevel;
   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.sprm.SprmBuffer;
   
  @@ -13,13 +14,12 @@
     ListLevel _level;
     ListFormatOverrideLevel _overrideLevel;
   
  -  ListEntry(int start, int end, ListTables tables,
  -                   ParagraphProperties pap, SprmBuffer sprmBuf, Range parent)
  +  ListEntry(PAPX papx, Range parent, ListTables tables)
     {
  -    super(start, end, pap, sprmBuf, parent);
  -    ListFormatOverride override = tables.getOverride(pap.getIlfo());
  -    _overrideLevel = override.getOverrideLevel(pap.getIlvl());
  -    _level = tables.getLevel(override.getLsid(), pap.getIlvl());
  +    super(papx, parent);
  +    ListFormatOverride override = tables.getOverride(_props.getIlfo());
  +    _overrideLevel = override.getOverrideLevel(_props.getIlvl());
  +    _level = tables.getLevel(override.getLsid(), _props.getIlvl());
     }
   
     public int type()
  
  
  
  1.4       +13 -6     jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Paragraph.java
  
  Index: Paragraph.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Paragraph.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Paragraph.java	5 Mar 2004 13:07:55 -0000	1.3
  +++ Paragraph.java	10 Mar 2004 04:18:56 -0000	1.4
  @@ -125,8 +125,8 @@
     public final static short SPRM_FADJUSTRIGHT = 0x2448;
   
   
  -  private short _istd;
  -  private ParagraphProperties _props;
  +  protected short _istd;
  +  protected ParagraphProperties _props;
     protected SprmBuffer _papx;
   
     protected Paragraph(int startIdx, int endIdx, Table parent)
  @@ -135,13 +135,20 @@
       PAPX papx = (PAPX)_paragraphs.get(_parEnd - 1);
       _props = papx.getParagraphProperties(_doc.getStyleSheet());
       _papx = papx.getSprmBuf();
  +    _istd = papx.getIstd();
     }
   
  -  public Paragraph(int start, int end, ParagraphProperties pap, SprmBuffer papx, Range parent)
  +  protected Paragraph(PAPX papx, Range parent)
     {
  -    super(start, end, parent);
  -    _props = pap;
  -    _papx = papx;
  +    super(papx.getStart(), papx.getEnd(), parent);
  +    _props = papx.getParagraphProperties(_doc.getStyleSheet());
  +    _papx = papx.getSprmBuf();
  +    _istd = papx.getIstd();
  +  }
  +
  +  public short getStyleIndex()
  +  {
  +    return _istd;
     }
   
     public int type()
  
  
  
  1.4       +0 -60     jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/ParagraphProperties.java
  
  Index: ParagraphProperties.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/ParagraphProperties.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ParagraphProperties.java	2 Mar 2004 06:19:41 -0000	1.3
  +++ ParagraphProperties.java	10 Mar 2004 04:18:56 -0000	1.4
  @@ -63,66 +63,6 @@
     extends PAPAbstractType
       implements Cloneable
   {
  -  public final static short SPRM_JC = 0x2403;
  -  public final static short SPRM_FSIDEBYSIDE = 0x2404;
  -  public final static short SPRM_FKEEP = 0x2405;
  -  public final static short SPRM_FKEEPFOLLOW = 0x2406;
  -  public final static short SPRM_FPAGEBREAKBEFORE = 0x2407;
  -  public final static short SPRM_BRCL = 0x2408;
  -  public final static short SPRM_BRCP = 0x2409;
  -  public final static short SPRM_ILVL = 0x260A;
  -  public final static short SPRM_ILFO = 0x460B;
  -  public final static short SPRM_FNOLINENUMB = 0x240C;
  -  public final static short SPRM_CHGTABSPAPX = (short)0xC60D;
  -  public final static short SPRM_DXARIGHT = (short)0x840E;
  -  public final static short SPRM_DXALEFT = (short)0x840F;
  -  public final static short SPRM_DXALEFT1 = (short)0x8411;
  -  public final static short SPRM_DYALINE = 0x6412;
  -  public final static short SPRM_DYABEFORE = (short)0xA413;
  -  public final static short SPRM_DYAAFTER = (short)0xA414;
  -  public final static short SPRM_CHGTABS = (short)0xC615;
  -  public final static short SPRM_FINTABLE = 0x2416;
  -  public final static short SPRM_FTTP = 0x2417;
  -  public final static short SPRM_DXAABS = (short)0x8418;
  -  public final static short SPRM_DYAABS = (short)0x8419;
  -  public final static short SPRM_DXAWIDTH = (short)0x841A;
  -  public final static short SPRM_PC = 0x261B;
  -  public final static short SPRM_WR = 0x2423;
  -  public final static short SPRM_BRCTOP = 0x6424;
  -  public final static short SPRM_BRCLEFT = 0x6425;
  -  public final static short SPRM_BRCBOTTOM = 0x6426;
  -  public final static short SPRM_BRCRIGHT = 0x6427;
  -  public final static short SPRM_BRCBAR = 0x6629;
  -  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_DYAFROMTEXT = (short)0x842E;
  -  public final static short SPRM_DXAFROMTEXT = (short)0x842F;
  -  public final static short SPRM_FLOCKED = 0x2430;
  -  public final static short SPRM_FWIDOWCONTROL = 0x2431;
  -  public final static short SPRM_RULER = (short)0xC632;
  -  public final static short SPRM_FKINSOKU = 0x2433;
  -  public final static short SPRM_FWORDWRAP = 0x2434;
  -  public final static short SPRM_FOVERFLOWPUNCT = 0x2435;
  -  public final static short SPRM_FTOPLINEPUNCT = 0x2436;
  -  public final static short SPRM_AUTOSPACEDE = 0x2437;
  -  public final static short SPRM_AUTOSPACEDN = 0x2438;
  -  public final static short SPRM_WALIGNFONT = 0x4439;
  -  public final static short SPRM_FRAMETEXTFLOW = 0x443A;
  -  public final static short SPRM_ANLD = (short)0xC63E;
  -  public final static short SPRM_PROPRMARK = (short)0xC63F;
  -  public final static short SPRM_OUTLVL = 0x2640;
  -  public final static short SPRM_FBIDI = 0x2441;
  -  public final static short SPRM_FNUMRMLNS = 0x2443;
  -  public final static short SPRM_CRLF = 0x2444;
  -  public final static short SPRM_NUMRM = (short)0xC645;
  -  public final static short SPRM_USEPGSUSETTINGS = 0x2447;
  -  public final static short SPRM_FADJUSTRIGHT = 0x2448;
  -
  -
  -  private StyleDescription _baseStyle;
  -  private SprmBuffer _papx;
   
     public ParagraphProperties()
     {
  
  
  
  1.3       +41 -4     jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
  
  Index: Range.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Range.java	5 Mar 2004 13:07:55 -0000	1.2
  +++ Range.java	10 Mar 2004 04:18:56 -0000	1.3
  @@ -426,13 +426,11 @@
       Paragraph pap = null;
       if (props.getIlfo() > 0)
       {
  -      pap = new ListEntry(papx.getStart(), papx.getEnd(), _doc.getListTables(),
  -                          props, papx.getSprmBuf(), this);
  +      pap = new ListEntry(papx, this, _doc.getListTables());
       }
       else
       {
  -      pap = new Paragraph(papx.getStart(), papx.getEnd(), props,
  -                          papx.getSprmBuf(), this);
  +      pap = new Paragraph(papx, this);
       }
   
       return pap;
  @@ -441,6 +439,45 @@
     public int type()
     {
       return TYPE_UNDEFINED;
  +  }
  +
  +  public Table getTable(Paragraph paragraph)
  +  {
  +    if (!paragraph.isInTable())
  +    {
  +      throw new IllegalArgumentException("This paragraph doesn't belong to a table");
  +    }
  +
  +    Range r = (Range)paragraph;
  +    if (r._parent.get() != this)
  +    {
  +      throw new IllegalArgumentException("This paragraph is not a child of this range");
  +    }
  +
  +    r.initAll();
  +    int tableEnd = r._parEnd;
  +
  +    if (r._parStart != 0 && ((Paragraph)r._paragraphs.get(r._parStart - 1)).isInTable())
  +    {
  +      throw new IllegalArgumentException("This paragraph is not the first one in the table");
  +    }
  +
  +    int limit = r._paragraphs.size();
  +    for (; tableEnd < limit; tableEnd++)
  +    {
  +      if (!((Paragraph)r._paragraphs.get(tableEnd)).isInTable())
  +      {
  +        break;
  +      }
  +    }
  +
  +    initAll();
  +    if (tableEnd > _parEnd)
  +    {
  +      throw new ArrayIndexOutOfBoundsException("The table's bounds fall outside of this Range");
  +    }
  +
  +    return new Table(r._parStart, tableEnd, r._doc.getRange(), 1);
     }
   
     private void initAll()
  
  
  
  1.2       +5 -5      jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java
  
  Index: TableRow.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TableRow.java	2 Mar 2004 06:22:29 -0000	1.1
  +++ TableRow.java	10 Mar 2004 04:18:56 -0000	1.2
  @@ -50,7 +50,7 @@
     public void setRowJustification(int jc)
     {
       _tprops.setJc(jc);
  -    _papx.addSprm(SPRM_TJC, (short)jc);
  +    _papx.updateSprm(SPRM_TJC, (short)jc);
     }
   
     public int getGapHalf()
  @@ -61,7 +61,7 @@
     public void setGapHalf(int dxaGapHalf)
     {
       _tprops.setDxaGapHalf(dxaGapHalf);
  -    _papx.addSprm(SPRM_DXAGAPHALF, (short)dxaGapHalf);
  +    _papx.updateSprm(SPRM_DXAGAPHALF, (short)dxaGapHalf);
     }
   
     public int getRowHeight()
  @@ -72,7 +72,7 @@
     public void setRowHeight(int dyaRowHeight)
     {
       _tprops.setDyaRowHeight(dyaRowHeight);
  -    _papx.addSprm(SPRM_DYAROWHEIGHT, (short)dyaRowHeight);
  +    _papx.updateSprm(SPRM_DYAROWHEIGHT, (short)dyaRowHeight);
     }
   
     public boolean cantSplit()
  @@ -83,7 +83,7 @@
     public void setCantSplit(boolean cantSplit)
     {
       _tprops.setFCantSplit(cantSplit);
  -    _papx.addSprm(SPRM_FCANTSPLIT, (byte)(cantSplit ? 1 : 0));
  +    _papx.updateSprm(SPRM_FCANTSPLIT, (byte)(cantSplit ? 1 : 0));
     }
   
     public boolean isTableHeader()
  @@ -94,7 +94,7 @@
     public void setTableHeader(boolean tableHeader)
     {
       _tprops.setFTableHeader(tableHeader);
  -    _papx.addSprm(SPRM_FTABLEHEADER, (byte)(tableHeader ? 1 : 0));
  +    _papx.updateSprm(SPRM_FTABLEHEADER, (byte)(tableHeader ? 1 : 0));
     }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org