Browse Source

Changed the way that text-align-last is calculated. Hopefully, this is it, now. Should fix a bug reported last week on fop-users.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@386379 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_92-beta
Jeremias Maerki 18 years ago
parent
commit
97a13831e8
2 changed files with 52 additions and 24 deletions
  1. 28
    22
      src/java/org/apache/fop/fo/FOPropertyMapping.java
  2. 24
    2
      test/fotree/testcases/text-align.fo

+ 28
- 22
src/java/org/apache/fop/fo/FOPropertyMapping.java View File

@@ -1688,33 +1688,39 @@ public class FOPropertyMapping implements Constants {

// text-align-last
m = new EnumProperty.Maker(PR_TEXT_ALIGN_LAST) {
public Property convertProperty(Property p,
PropertyList propertyList,
FObj fo) throws PropertyException {
int en = p.getEnum();
if (en == EN_RELATIVE) {
Property corresponding = propertyList.get(PR_TEXT_ALIGN);
if (corresponding == null) {
return p;
}
int correspondingValue = corresponding.getEnum();
if (correspondingValue == EN_JUSTIFY) {
return getEnumProperty(EN_START, "START");
} else if (correspondingValue == EN_END) {
return getEnumProperty(EN_END, "END");
} else if (correspondingValue == EN_START) {
return getEnumProperty(EN_START, "START");
} else if (correspondingValue == EN_CENTER) {
return getEnumProperty(EN_CENTER, "CENTER");
} else {
return p;
public Property get(int subpropId, PropertyList propertyList,
boolean bTryInherit, boolean bTryDefault) throws PropertyException {
Property p = super.get(subpropId, propertyList, bTryInherit, bTryDefault);
if (p != null && p.getEnum() == EN_RELATIVE) {
//The default may have been returned, so check inherited value
p = propertyList.getNearestSpecified(PR_TEXT_ALIGN_LAST);
if (p.getEnum() == EN_RELATIVE) {
return calcRelative(propertyList);
}
}
return p;
}

private Property calcRelative(PropertyList propertyList) throws PropertyException {
Property corresponding = propertyList.get(PR_TEXT_ALIGN);
if (corresponding == null) {
return null;
}
int correspondingValue = corresponding.getEnum();
if (correspondingValue == EN_JUSTIFY) {
return getEnumProperty(EN_START, "START");
} else if (correspondingValue == EN_END) {
return getEnumProperty(EN_END, "END");
} else if (correspondingValue == EN_START) {
return getEnumProperty(EN_START, "START");
} else if (correspondingValue == EN_CENTER) {
return getEnumProperty(EN_CENTER, "CENTER");
} else {
return p;
return null;
}
}
};
m.setInherited(true);
m.setInherited(false); //Actually it's "true" but the special PropertyMaker compensates
// Note: both 'end', 'right' and 'outside' are mapped to END
// both 'start', 'left' and 'inside' are mapped to START
m.addEnum("relative", getEnumProperty(EN_RELATIVE, "RELATIVE"));

+ 24
- 2
test/fotree/testcases/text-align.fo View File

@@ -24,14 +24,14 @@
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="xsl-region-body">
<!--fo:block text-align="justify">Hello World!
<fo:block text-align="justify">Hello World!
<test:assert property="text-align" expected="JUSTIFY"/>
<test:assert property="text-align-last" expected="START"/>
</fo:block>
<fo:block text-align="justify" text-align-last="relative">Hello World!
<test:assert property="text-align" expected="JUSTIFY"/>
<test:assert property="text-align-last" expected="START"/>
</fo:block-->
</fo:block>
<fo:block text-align="end">Hello World!
<test:assert property="text-align" expected="END"/>
<test:assert property="text-align-last" expected="END"/>
@@ -49,11 +49,33 @@
<test:assert property="text-align-last" expected="JUSTIFY"/>
</fo:block>
<fo:block text-align="justify" text-align-last="justify">
<!-- Checks inherited values -->
<fo:block>Hello World!
<test:assert property="text-align" expected="JUSTIFY"/>
<test:assert property="text-align-last" expected="JUSTIFY"/>
</fo:block>
</fo:block>
<fo:block text-align="end">
<fo:table table-layout="fixed" width="100%">
<fo:table-column number-columns-repeated="2" column-width="50%"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="center">center
<test:assert property="text-align" expected="CENTER"/>
<test:assert property="text-align-last" expected="CENTER"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="left">left
<test:assert property="text-align" expected="START"/>
<test:assert property="text-align-last" expected="START"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

Loading…
Cancel
Save