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/23 06:51:54 UTC
cvs commit: jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel CharacterProperties.java HWPFList.java Paragraph.java Range.java
sackley 2004/03/22 21:51:54
Modified: src/scratchpad/src/org/apache/poi/hwpf/usermodel
CharacterProperties.java HWPFList.java
Paragraph.java Range.java
Log:
Applied patches from Piers and my latest changes
Revision Changes Path
1.7 +2 -0 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterProperties.java
Index: CharacterProperties.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterProperties.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CharacterProperties.java 5 Mar 2004 13:07:55 -0000 1.6
+++ CharacterProperties.java 23 Mar 2004 05:51:54 -0000 1.7
@@ -420,6 +420,8 @@
cp.field_41_xstDispFldRMark = (byte[])field_41_xstDispFldRMark.clone();
cp.field_42_shd = (ShadingDescriptor)field_42_shd.clone();
+ cp._ico24 = _ico24;
+
return cp;
}
1.2 +25 -3 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/HWPFList.java
Index: HWPFList.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/HWPFList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HWPFList.java 15 Mar 2004 02:57:28 -0000 1.1
+++ HWPFList.java 23 Mar 2004 05:51:54 -0000 1.2
@@ -32,9 +32,13 @@
* org.apache.poi.hwpf.HWPFDocument#registerList(HWPFList) registerList} in
* {@link org.apache.poi.hwpf.HWPFDocument HWPFDocument}.
*
- * In Word, lists are not ranged entities. Lists only act as properties for
- * list entries. Once you register a list, you can add list entries to a
- * document that use the list.
+ * In Word, lists are not ranged entities, meaning you can't actually add one
+ * to the document. Lists only act as properties for list entries. Once you
+ * register a list, you can add list entries to a document that are a part of
+ * the list.
+ *
+ * The only benefit of this that I see, is that you can add a list entry
+ * anywhere in the document and continue numbering from the previous list.
*
* @author Ryan Ackley
*/
@@ -45,6 +49,12 @@
private boolean _registered;
private StyleSheet _styleSheet;
+ /**
+ *
+ * @param numbered true if the list should be numbered; false if it should be
+ * bulleted.
+ * @param styleSheet The document's stylesheet.
+ */
public HWPFList(boolean numbered, StyleSheet styleSheet)
{
_listData = new ListData((int)(Math.random() * (double)System.currentTimeMillis()), numbered);
@@ -52,6 +62,12 @@
_styleSheet = styleSheet;
}
+ /**
+ * Sets the character properties of the list numbers.
+ *
+ * @param level the level number that the properties should apply to.
+ * @param chp The character properties.
+ */
public void setLevelNumberProperties(int level, CharacterProperties chp)
{
ListLevel listLevel = _listData.getLevel(level);
@@ -62,6 +78,12 @@
listLevel.setNumberProperties(grpprl);
}
+ /**
+ * Sets the paragraph properties for a particular level of the list.
+ *
+ * @param level The level number.
+ * @param pap The paragraph properties
+ */
public void setLevelParagraphProperties(int level, ParagraphProperties pap)
{
ListLevel listLevel = _listData.getLevel(level);
1.6 +27 -27 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Paragraph.java 12 Mar 2004 12:34:35 -0000 1.5
+++ Paragraph.java 23 Mar 2004 05:51:54 -0000 1.6
@@ -184,7 +184,7 @@
public void setJustification(byte jc)
{
_props.setJc(jc);
- _papx.addSprm(SPRM_JC, jc);
+ _papx.updateSprm(SPRM_JC, jc);
}
public boolean keepOnPage()
@@ -196,7 +196,7 @@
{
byte keep = (byte)(fKeep ? 1 : 0);
_props.setFKeep(keep);
- _papx.addSprm(SPRM_FKEEP, keep);
+ _papx.updateSprm(SPRM_FKEEP, keep);
}
public boolean keepWithNext()
@@ -208,7 +208,7 @@
{
byte keepFollow = (byte)(fKeepFollow ? 1 : 0);
_props.setFKeepFollow(keepFollow);
- _papx.addSprm(SPRM_FKEEPFOLLOW, keepFollow);
+ _papx.updateSprm(SPRM_FKEEPFOLLOW, keepFollow);
}
public boolean pageBreakBefore()
@@ -220,7 +220,7 @@
{
byte pageBreak = (byte)(fPageBreak ? 1 : 0);
_props.setFPageBreakBefore(pageBreak);
- _papx.addSprm(SPRM_FPAGEBREAKBEFORE, pageBreak);
+ _papx.updateSprm(SPRM_FPAGEBREAKBEFORE, pageBreak);
}
public boolean isLineNotNumbered()
@@ -232,7 +232,7 @@
{
byte noLnn = (byte)(fNoLnn ? 1 : 0);
_props.setFNoLnn(noLnn);
- _papx.addSprm(SPRM_FNOLINENUMB, noLnn);
+ _papx.updateSprm(SPRM_FNOLINENUMB, noLnn);
}
public boolean isSideBySide()
@@ -244,7 +244,7 @@
{
byte sideBySide = (byte)(fSideBySide ? 1 : 0);
_props.setFSideBySide(sideBySide);
- _papx.addSprm(SPRM_FSIDEBYSIDE, sideBySide);
+ _papx.updateSprm(SPRM_FSIDEBYSIDE, sideBySide);
}
public boolean isAutoHyphenated()
@@ -256,7 +256,7 @@
{
byte auto = (byte)(!autoHyph ? 1 : 0);
_props.setFNoAutoHyph(auto);
- _papx.addSprm(SPRM_FNOAUTOHYPH, auto);
+ _papx.updateSprm(SPRM_FNOAUTOHYPH, auto);
}
public boolean isWidowControlled()
@@ -268,7 +268,7 @@
{
byte widow = (byte)(widowControl ? 1 : 0);
_props.setFWidowControl(widow);
- _papx.addSprm(SPRM_FWIDOWCONTROL, widow);
+ _papx.updateSprm(SPRM_FWIDOWCONTROL, widow);
}
public int getIndentFromRight()
@@ -279,7 +279,7 @@
public void setIndentFromRight(int dxaRight)
{
_props.setDxaRight(dxaRight);
- _papx.addSprm(SPRM_DXARIGHT, (short)dxaRight);
+ _papx.updateSprm(SPRM_DXARIGHT, (short)dxaRight);
}
public int getIndentFromLeft()
@@ -290,7 +290,7 @@
public void setIndentFromLeft(int dxaLeft)
{
_props.setDxaLeft(dxaLeft);
- _papx.addSprm(SPRM_DXALEFT, (short)dxaLeft);
+ _papx.updateSprm(SPRM_DXALEFT, (short)dxaLeft);
}
public int getFirstLineIndent()
@@ -301,7 +301,7 @@
public void setFirstLineIndent(int first)
{
_props.setDxaLeft1(first);
- _papx.addSprm(SPRM_DXALEFT1, (short)first);
+ _papx.updateSprm(SPRM_DXALEFT1, (short)first);
}
public LineSpacingDescriptor getLineSpacing()
@@ -312,7 +312,7 @@
public void setLineSpacing(LineSpacingDescriptor lspd)
{
_props.setLspd(lspd);
- _papx.addSprm(SPRM_DYALINE, lspd.toInt());
+ _papx.updateSprm(SPRM_DYALINE, lspd.toInt());
}
public int getSpacingBefore()
@@ -323,7 +323,7 @@
public void setSpacingBefore(int before)
{
_props.setDyaBefore(before);
- _papx.addSprm(SPRM_DYABEFORE, (short)before);
+ _papx.updateSprm(SPRM_DYABEFORE, (short)before);
}
public int getSpacingAfter()
@@ -334,7 +334,7 @@
public void setSpacingAfter(int after)
{
_props.setDyaAfter(after);
- _papx.addSprm(SPRM_DYAAFTER, (short)after);
+ _papx.updateSprm(SPRM_DYAAFTER, (short)after);
}
public boolean isKinsoku()
@@ -346,7 +346,7 @@
{
byte kin = (byte)(kinsoku ? 1 : 0);
_props.setFKinsoku(kin);
- _papx.addSprm(SPRM_FKINSOKU, kin);
+ _papx.updateSprm(SPRM_FKINSOKU, kin);
}
public boolean isWordWrapped()
@@ -358,7 +358,7 @@
{
byte wordWrap = (byte)(wrap ? 1 : 0);
_props.setFWordWrap(wordWrap);
- _papx.addSprm(SPRM_FWORDWRAP, wordWrap);
+ _papx.updateSprm(SPRM_FWORDWRAP, wordWrap);
}
public int getFontAlignment()
@@ -369,7 +369,7 @@
public void setFontAlignment(int align)
{
_props.setWAlignFont(align);
- _papx.addSprm(SPRM_WALIGNFONT, (short)align);
+ _papx.updateSprm(SPRM_WALIGNFONT, (short)align);
}
public boolean isVertical()
@@ -380,7 +380,7 @@
public void setVertical(boolean vertical)
{
_props.setFVertical(vertical);
- _papx.addSprm(SPRM_FRAMETEXTFLOW, getFrameTextFlow());
+ _papx.updateSprm(SPRM_FRAMETEXTFLOW, getFrameTextFlow());
}
public boolean isBackward()
@@ -391,7 +391,7 @@
public void setBackward(boolean bward)
{
_props.setFBackward(bward);
- _papx.addSprm(SPRM_FRAMETEXTFLOW, getFrameTextFlow());
+ _papx.updateSprm(SPRM_FRAMETEXTFLOW, getFrameTextFlow());
}
public BorderCode getTopBorder()
@@ -402,7 +402,7 @@
public void setTopBorder(BorderCode top)
{
_props.setBrcTop(top);
- _papx.addSprm(SPRM_BRCTOP, top.toInt());
+ _papx.updateSprm(SPRM_BRCTOP, top.toInt());
}
public BorderCode getLeftBorder()
@@ -413,7 +413,7 @@
public void setLeftBorder(BorderCode left)
{
_props.setBrcLeft(left);
- _papx.addSprm(SPRM_BRCLEFT, left.toInt());
+ _papx.updateSprm(SPRM_BRCLEFT, left.toInt());
}
public BorderCode getBottomBorder()
@@ -424,7 +424,7 @@
public void setBottomBorder(BorderCode bottom)
{
_props.setBrcBottom(bottom);
- _papx.addSprm(SPRM_BRCBOTTOM, bottom.toInt());
+ _papx.updateSprm(SPRM_BRCBOTTOM, bottom.toInt());
}
public BorderCode getRightBorder()
@@ -435,7 +435,7 @@
public void setRightBorder(BorderCode right)
{
_props.setBrcRight(right);
- _papx.addSprm(SPRM_BRCRIGHT, right.toInt());
+ _papx.updateSprm(SPRM_BRCRIGHT, right.toInt());
}
public BorderCode getBarBorder()
@@ -446,7 +446,7 @@
public void setBarBorder(BorderCode bar)
{
_props.setBrcBar(bar);
- _papx.addSprm(SPRM_BRCBAR, bar.toInt());
+ _papx.updateSprm(SPRM_BRCBAR, bar.toInt());
}
public ShadingDescriptor getShading()
@@ -457,7 +457,7 @@
public void setShading(ShadingDescriptor shd)
{
_props.setShd(shd);
- _papx.addSprm(SPRM_SHD, shd.toShort());
+ _papx.updateSprm(SPRM_SHD, shd.toShort());
}
public DropCapSpecifier getDropCap()
@@ -468,7 +468,7 @@
public void setDropCap(DropCapSpecifier dcs)
{
_props.setDcs(dcs);
- _papx.addSprm(SPRM_DCS, dcs.toShort());
+ _papx.updateSprm(SPRM_DCS, dcs.toShort());
}
void setTableRowEnd(TableProperties props)
@@ -481,7 +481,7 @@
private void setTableRowEnd(byte val)
{
_props.setFTtp(val);
- _papx.addSprm(SPRM_FTTP, val);
+ _papx.updateSprm(SPRM_FTTP, val);
}
public Object clone()
1.6 +33 -1 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Range.java 15 Mar 2004 02:57:38 -0000 1.5
+++ Range.java 23 Mar 2004 05:51:54 -0000 1.6
@@ -63,6 +63,10 @@
* It is possible to insert text and/or properties at the beginning or end of a
* range.
*
+ * Ranges are only valid if there hasn't been an insert in a prior Range since
+ * the Range's creation. Once an element (text, paragraph, etc.) has been
+ * inserted into a Range, subsequent Ranges become unstable.
+ *
* @author Ryan Ackley
*/
public class Range
@@ -161,6 +165,7 @@
_parent = new WeakReference(null);
}
+
/**
* Used to create Ranges that are children of other Ranges.
*
@@ -480,6 +485,33 @@
return getParagraph(numParagraphs() - 1);
}
+ public void delete()
+ {
+ initAll();
+
+ int numSections = _sections.size();
+ int numRuns = _characters.size();
+ int numParagraphs = _paragraphs.size();
+
+ for (int x = _charStart; x < numRuns; x++)
+ {
+ CHPX chpx = (CHPX)_characters.get(x);
+ chpx.adjustForDelete(_start, _end - _start);
+ }
+
+ for (int x = _parStart; x < numParagraphs; x++)
+ {
+ PAPX papx = (PAPX)_paragraphs.get(x);
+ papx.adjustForDelete(_start, _end - _start);
+ }
+
+ for (int x = _sectionStart; x < numSections; x++)
+ {
+ SEPX sepx = (SEPX)_sections.get(x);
+ sepx.adjustForDelete(_start, _end - _start);
+ }
+ }
+
/**
* Inserts a simple table into the beginning of this range. The number of
* columns is determined by the TableProperties passed into this function.
@@ -546,7 +578,7 @@
initCharacterRuns();
CHPX chpx = (CHPX)_characters.get(index + _charStart);
- int[] point = findRange(_paragraphs, _parStart, chpx.getStart(),
+ int[] point = findRange(_paragraphs, _parStart, Math.max(chpx.getStart(), _start),
chpx.getEnd());
PAPX papx = (PAPX)_paragraphs.get(point[0]);
short istd = papx.getIstd();
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org