diff options
author | Karen Lease <klease@apache.org> | 2001-02-01 21:38:11 +0000 |
---|---|---|
committer | Karen Lease <klease@apache.org> | 2001-02-01 21:38:11 +0000 |
commit | 6e8ca8d59734101b63cf933f2d12f482f5ae371b (patch) | |
tree | 6354d5a37b21d8786031df4825abbb709a8386e0 /src/org/apache/fop/layout/BlockArea.java | |
parent | e6e8945040db1c9bcff0aea35775190c3944b718 (diff) | |
download | xmlgraphics-fop-6e8ca8d59734101b63cf933f2d12f482f5ae371b.tar.gz xmlgraphics-fop-6e8ca8d59734101b63cf933f2d12f482f5ae371b.zip |
Commit more text decoration support from Christain Geisert (finally)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194007 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/layout/BlockArea.java')
-rw-r--r-- | src/org/apache/fop/layout/BlockArea.java | 259 |
1 files changed, 130 insertions, 129 deletions
diff --git a/src/org/apache/fop/layout/BlockArea.java b/src/org/apache/fop/layout/BlockArea.java index 4defdde76..30744ef71 100644 --- a/src/org/apache/fop/layout/BlockArea.java +++ b/src/org/apache/fop/layout/BlockArea.java @@ -74,16 +74,16 @@ import org.apache.fop.messaging.MessageHandler; */ public class BlockArea extends Area { - /* relative to area container */ - protected int startIndent; - protected int endIndent; + /* relative to area container */ + protected int startIndent; + protected int endIndent; /* first line startIndent modifier */ - protected int textIndent; + protected int textIndent; - protected int lineHeight; + protected int lineHeight; - protected int halfLeading; + protected int halfLeading; /* text-align of all but the last line */ @@ -152,145 +152,145 @@ public class BlockArea extends Area { } } - // font-variant support : addText is a wrapper for addRealText - // added by Eric SCHAEFFER - public int addText(FontState fontState, float red, float green, - float blue, int wrapOption, LinkSet ls, - int whiteSpaceCollapse, char data[], int start, int end, - boolean ul) { - if (fontState.getFontVariant() == FontVariant.SMALL_CAPS) { - FontState smallCapsFontState; - try { - int smallCapsFontHeight = (int) (((double) fontState.getFontSize()) * 0.8d); - smallCapsFontState = new FontState( - fontState.getFontInfo(), - fontState.getFontFamily(), - fontState.getFontStyle(), - fontState.getFontWeight(), - smallCapsFontHeight, - FontVariant.NORMAL); - } catch (FOPException ex) { - smallCapsFontState = fontState; - MessageHandler.errorln("Error creating small-caps FontState: " + ex.getMessage()); - } - - // parse text for upper/lower case and call addRealText - char c; - boolean isLowerCase; - int caseStart; - FontState fontStateToUse; - for (int i = start; i < end; ) { - caseStart = i; - c = data[i]; - isLowerCase = (java.lang.Character.isLetter(c) && java.lang.Character.isLowerCase(c)); - while (isLowerCase == (java.lang.Character.isLetter(c) && java.lang.Character.isLowerCase(c))) { - if (isLowerCase) { - data[i] = java.lang.Character.toUpperCase(c); - } - i++; - if (i == end) - break; - c = data[i]; - } - if (isLowerCase) { - fontStateToUse = smallCapsFontState; - } else { - fontStateToUse = fontState; - } - int index = this.addRealText(fontStateToUse, red, green, blue, wrapOption, ls, - whiteSpaceCollapse, data, caseStart, i, ul); - if (index != -1) { - return index; - } - } - - return -1; - } - - // font-variant normal - return this.addRealText(fontState, red, green, blue, wrapOption, ls, - whiteSpaceCollapse, data, start, end, ul); - } - - protected int addRealText(FontState fontState, float red, float green, - float blue, int wrapOption, LinkSet ls, - int whiteSpaceCollapse, char data[], int start, int end, - boolean ul) { - int ts, te; - char[] ca; - - ts = start; - te = end; - ca = data; + // font-variant support : addText is a wrapper for addRealText + // added by Eric SCHAEFFER + public int addText(FontState fontState, float red, float green, + float blue, int wrapOption, LinkSet ls, + int whiteSpaceCollapse, char data[], int start, int end, + TextState textState) { + if (fontState.getFontVariant() == FontVariant.SMALL_CAPS) { + FontState smallCapsFontState; + try { + int smallCapsFontHeight = (int) (((double) fontState.getFontSize()) * 0.8d); + smallCapsFontState = new FontState( + fontState.getFontInfo(), + fontState.getFontFamily(), + fontState.getFontStyle(), + fontState.getFontWeight(), + smallCapsFontHeight, + FontVariant.NORMAL); + } catch (FOPException ex) { + smallCapsFontState = fontState; + MessageHandler.errorln("Error creating small-caps FontState: " + ex.getMessage()); + } + + // parse text for upper/lower case and call addRealText + char c; + boolean isLowerCase; + int caseStart; + FontState fontStateToUse; + for (int i = start; i < end; ) { + caseStart = i; + c = data[i]; + isLowerCase = (java.lang.Character.isLetter(c) && java.lang.Character.isLowerCase(c)); + while (isLowerCase == (java.lang.Character.isLetter(c) && java.lang.Character.isLowerCase(c))) { + if (isLowerCase) { + data[i] = java.lang.Character.toUpperCase(c); + } + i++; + if (i == end) + break; + c = data[i]; + } + if (isLowerCase) { + fontStateToUse = smallCapsFontState; + } else { + fontStateToUse = fontState; + } + int index = this.addRealText(fontStateToUse, red, green, blue, wrapOption, ls, + whiteSpaceCollapse, data, caseStart, i, textState); + if (index != -1) { + return index; + } + } + + return -1; + } - if (currentHeight + currentLineArea.getHeight() > maxHeight) { - return start; - } + // font-variant normal + return this.addRealText(fontState, red, green, blue, wrapOption, ls, + whiteSpaceCollapse, data, start, end, textState); + } - this.currentLineArea.changeFont(fontState); - this.currentLineArea.changeColor(red, green, blue); - this.currentLineArea.changeWrapOption(wrapOption); - this.currentLineArea.changeWhiteSpaceCollapse(whiteSpaceCollapse); - this.currentLineArea.changeHyphenation(language, country, hyphenate, - hyphenationChar, hyphenationPushCharacterCount, - hyphenationRemainCharacterCount); - if (ls != null) { - this.currentLinkSet = ls; - ls.setYOffset(currentHeight); - } + protected int addRealText(FontState fontState, float red, float green, + float blue, int wrapOption, LinkSet ls, + int whiteSpaceCollapse, char data[], int start, int end, + TextState textState) { + int ts, te; + char[] ca; - ts = this.currentLineArea.addText(ca, ts, te, ls, ul); - this.hasLines = true; + ts = start; + te = end; + ca = data; - while (ts != -1) { - this.currentLineArea.align(this.align); - this.addLineArea(this.currentLineArea); + if (currentHeight + currentLineArea.getHeight() > maxHeight) { + return start; + } - this.currentLineArea = - new LineArea(fontState, lineHeight, halfLeading, - allocationWidth, startIndent, endIndent, - currentLineArea); - if (currentHeight + currentLineArea.getHeight() > - this.maxHeight) { - return ts; - } - this.currentLineArea.changeFont(fontState); - this.currentLineArea.changeColor(red, green, blue); - this.currentLineArea.changeWrapOption(wrapOption); - this.currentLineArea.changeWhiteSpaceCollapse( - whiteSpaceCollapse); - this.currentLineArea.changeHyphenation(language, country, hyphenate, - hyphenationChar, hyphenationPushCharacterCount, - hyphenationRemainCharacterCount); - if (ls != null) { - ls.setYOffset(currentHeight); - } + this.currentLineArea.changeFont(fontState); + this.currentLineArea.changeColor(red, green, blue); + this.currentLineArea.changeWrapOption(wrapOption); + this.currentLineArea.changeWhiteSpaceCollapse(whiteSpaceCollapse); + this.currentLineArea.changeHyphenation(language, country, hyphenate, + hyphenationChar, hyphenationPushCharacterCount, + hyphenationRemainCharacterCount); + if (ls != null) { + this.currentLinkSet = ls; + ls.setYOffset(currentHeight); + } - ts = this.currentLineArea.addText(ca, ts, te, ls, ul); - } - return -1; - } + ts = this.currentLineArea.addText(ca, ts, te, ls, textState); + this.hasLines = true; + + while (ts != -1) { + this.currentLineArea.align(this.align); + this.addLineArea(this.currentLineArea); + + this.currentLineArea = + new LineArea(fontState, lineHeight, halfLeading, + allocationWidth, startIndent, endIndent, + currentLineArea); + if (currentHeight + currentLineArea.getHeight() > + this.maxHeight) { + return ts; + } + this.currentLineArea.changeFont(fontState); + this.currentLineArea.changeColor(red, green, blue); + this.currentLineArea.changeWrapOption(wrapOption); + this.currentLineArea.changeWhiteSpaceCollapse( + whiteSpaceCollapse); + this.currentLineArea.changeHyphenation(language, country, hyphenate, + hyphenationChar, hyphenationPushCharacterCount, + hyphenationRemainCharacterCount); + if (ls != null) { + ls.setYOffset(currentHeight); + } + + ts = this.currentLineArea.addText(ca, ts, te, ls, textState); + } + return -1; + } - /** + /** * adds a leader to current line area of containing block area * the actual leader area is created in the line area * * @return int +1 for success and -1 for none */ - public int addLeader(FontState fontState, float red, float green, - float blue, int leaderPattern, int leaderLengthMinimum, - int leaderLengthOptimum, int leaderLengthMaximum, - int ruleThickness, int ruleStyle, int leaderPatternWidth, - int leaderAlignment) { + public int addLeader(FontState fontState, float red, float green, + float blue, int leaderPattern, int leaderLengthMinimum, + int leaderLengthOptimum, int leaderLengthMaximum, + int ruleThickness, int ruleStyle, int leaderPatternWidth, + int leaderAlignment) { //this should start a new page - if (currentHeight + currentLineArea.getHeight() > maxHeight) { - return -1; - } + if (currentHeight + currentLineArea.getHeight() > maxHeight) { + return -1; + } - this.currentLineArea.changeFont(fontState); - this.currentLineArea.changeColor(red, green, blue); + this.currentLineArea.changeFont(fontState); + this.currentLineArea.changeColor(red, green, blue); //check whether leader fits into the (rest of the) line //using length.optimum to determine where to break the line as defined @@ -393,6 +393,7 @@ public class BlockArea extends Area { return endIndent; } +// KL: I think we should just return startIndent here! public int getStartIndent() { return startIndent + paddingLeft + borderWidthLeft; } |