public void setBaselineOffset(int baselineOffset) {
this.baselineOffset = baselineOffset;
}
+
+ @Override
+ int getVirtualOffset() {
+ return getOffset();
+ }
+
+ @Override
+ int getVirtualBPD() {
+ /* Word and space areas don't have a properly set bpd; return this area's bpd instead. */
+ return getBPD();
+ }
}
--- /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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.area.inline;
+
+import org.apache.fop.area.Area;
+
+/**
+ * An inline area produced by an fo:basic-link element. This class implements a different
+ * behavior to what is prescribed by the XSL-FO 1.1 Recommendation. With the standard
+ * behavior, there is no easy way to make a link cover e.g. a whole image.
+ *
+ * <p>See following bug report at W3C's:
+ * http://www.w3.org/Bugs/Public/show_bug.cgi?id=11672</p>
+ */
+public class BasicLinkArea extends InlineParent {
+
+ private static final long serialVersionUID = 5183753430412208151L;
+
+ @Override
+ public void setParentArea(Area parentArea) {
+ super.setParentArea(parentArea);
+ /*
+ * Perform necessary modifications to make this area encompass all of its children
+ * elements, so as to have a useful active area. We assume that this method is
+ * called after all of the children areas have been added to this area.
+ */
+ /* Make this area start at its beforest child. */
+ setOffset(getOffset() + minChildOffset);
+ /* Update children offsets accordingly. */
+ for (InlineArea inline : inlines) {
+ inline.setOffset(inline.getOffset() - minChildOffset);
+ }
+ setBPD(getVirtualBPD());
+ }
+
+}
storedIPDVariation += ipdVariation;
}
}
+
+ /**
+ * Returns the offset that this area would have if its offset and size were taking
+ * children areas into account. The bpd of an inline area is taken from its nominal
+ * font and doesn't depend on the bpds of its children elements. However, in the case
+ * of a basic-link element we want the active area to cover all of the children
+ * elements.
+ *
+ * @return the offset that this area would have if the before-edge of its
+ * content-rectangle were coinciding with the <q>beforest</q> before-edge of its
+ * children allocation-rectangles.
+ * @see #getVirtualBPD()
+ * @see BasicLinkArea
+ */
+ int getVirtualOffset() {
+ return getOffset();
+ }
+
+ /**
+ * Returns the block-progression-dimension that this area would have if it were taking
+ * its children elements into account. See {@linkplain #getVirtualOffset()}.
+ *
+ * @return the bpd
+ */
+ int getVirtualBPD() {
+ return getBPD();
+ }
}
/** Controls whether the IPD is automatically adjusted based on the area's children. */
protected transient boolean autoSize;
- /**
- * Create a new inline parent to add areas to.
- */
- public InlineParent() {
- }
+ /** The offset of the <q>beforest</q> child area of this area. */
+ protected int minChildOffset;
/**
- * Override generic Area method.
- *
- * @param childArea the child area to add
+ * The offset of the <q>afterest</q> child area of this area. Offset from the
+ * before-edge of this area's content-rectangle and the after-edge of the child area's
+ * allocation-rectangle.
*/
+ private int maxAfterEdge;
+
@Override
- public void addChildArea(Area childArea) {
+ public void addChildArea(Area c) {
+ assert c instanceof InlineArea;
if (inlines.size() == 0) {
autoSize = (getIPD() == 0);
}
- if (childArea instanceof InlineArea) {
- InlineArea inlineChildArea = (InlineArea) childArea;
- inlines.add(inlineChildArea);
- // set the parent area for the child area
- inlineChildArea.setParentArea(this);
- if (autoSize) {
- increaseIPD(inlineChildArea.getAllocIPD());
- }
+ InlineArea childArea = (InlineArea) c;
+ inlines.add(childArea);
+ // set the parent area for the child area
+ childArea.setParentArea(this);
+ if (autoSize) {
+ increaseIPD(childArea.getAllocIPD());
}
+ int childOffset = childArea.getVirtualOffset();
+ minChildOffset = Math.min(minChildOffset, childOffset);
+ maxAfterEdge = Math.max(maxAfterEdge, childOffset + childArea.getVirtualBPD());
+ }
+
+ @Override
+ int getVirtualOffset() {
+ return getOffset() + minChildOffset;
+ }
+
+ @Override
+ int getVirtualBPD() {
+ return maxAfterEdge - minChildOffset;
}
/**
return hasUnresolvedAreas;
}
+
}
import org.apache.fop.area.LinkResolver;
import org.apache.fop.area.Trait;
+import org.apache.fop.area.inline.BasicLinkArea;
import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.InlineParent;
import org.apache.fop.datatypes.URISpecification;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.BasicLink;
}
}
}
+
+ @Override
+ protected InlineParent createInlineParent() {
+ return new BasicLinkArea();
+ }
+
}
/**
* Create and initialize an <code>InlineArea</code>
*
- * @param hasInlineParent true if the parent is an inline
+ * @param isInline true if the parent is an inline
* @return the area
*/
- protected InlineArea createArea(boolean hasInlineParent) {
+ protected InlineArea createArea(boolean isInline) {
InlineArea area;
- if (hasInlineParent) {
- area = new InlineParent();
+ if (isInline) {
+ area = createInlineParent();
area.setOffset(0);
} else {
area = new InlineBlockParent();
return area;
}
+ protected InlineParent createInlineParent() {
+ return new InlineParent();
+ }
+
/** {@inheritDoc} */
@Override
protected void setTraits(boolean isNotFirst, boolean isNotLast) {
documents. Example: the fix of marks layering will be such a case when it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Layout" dev="VH" type="fix" fixex-bug="50763">
+ Implemented non-standard behavior for basic-link areas, such that they take into account the
+ heights of their descendants areas.
+ </action>
<action context="Layout" dev="VH" type="fix">
Bugfix: keep-together does not apply to fo:table-cell.
</action>
<!-- $Id$ -->
<!--DOCTYPE disabled-testcases SYSTEM "disabled-testcases.dtd"-->
<disabled-testcases>
- <testcase>
- <name>External link around an SVG not properly sized</name>
- <file>basic-link_external-destination_2.xml</file>
- <description>The bpd trait of the inlineparent area for the basic-link
- is not sized correctly if it wraps an image that is higher than the
- nominal line.</description>
- </testcase>
<testcase>
<name>Auto-height block-containers produce fences</name>
<file>block-container_space-before_space-after_3.xml</file>
</fo:root>
</fo>
<checks>
- <eval expected="192000" xpath="//inlineparent[@prod-id='link']/viewport/@ipd"/>
- <eval expected="192000" xpath="//inlineparent[@prod-id='link']/viewport/@bpd"/>
-
- <eval expected="192000" xpath="//inlineparent[@prod-id='link']/@ipd"/>
- <eval expected="192000" xpath="//inlineparent[@prod-id='link']/@bpd"/>
+ <eval expected="144000" xpath="//inlineparent[@prod-id='link']/@ipd"/>
+ <eval expected="144000" xpath="//inlineparent[@prod-id='link']/@bpd"/>
+ <eval expected="0" xpath="//inlineparent[@prod-id='link']/@offset"/>
+
+ <eval expected="144000" xpath="//inlineparent[@prod-id='link']/viewport/@ipd"/>
+ <eval expected="144000" xpath="//inlineparent[@prod-id='link']/viewport/@bpd"/>
+ <eval expected="0" xpath="//inlineparent[@prod-id='link']/viewport/@offset"/>
</checks>
</testcase>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- $Id$ -->
+<testcase>
+ <info>
+ <p>
+ This test checks the height of an fo:basic-link wrapping a bigger element.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page"
+ page-height="420pt" page-width="320pt" margin="10pt">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="page">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In in <fo:basic-link
+ id="link" color="blue"
+ external-destination="url(http://xmlgraphics.apache.org/fop/)"><fo:inline id="inline"
+ font-size="24pt" baseline-shift="12pt">egestas</fo:inline></fo:basic-link> nisi.
+ Etiam at ante eget velit placerat ullamcorper.</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <eval expected="84048" xpath="//inlineparent[@prod-id='link']/@ipd"/>
+ <eval expected="22200" xpath="//inlineparent[@prod-id='link']/@bpd"/>
+ <eval expected="0" xpath="//inlineparent[@prod-id='link']/@offset"/>
+
+ <eval expected="84048" xpath="//inlineparent[@prod-id='link']/inlineparent/@ipd"/>
+ <eval expected="22200" xpath="//inlineparent[@prod-id='link']/inlineparent/@bpd"/>
+ <eval expected="0" xpath="//inlineparent[@prod-id='link']/inlineparent/@offset"/>
+ </checks>
+</testcase>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- $Id$ -->
+<testcase>
+ <info>
+ <p>
+ This test checks the height of an fo:basic-link with baseline-shift.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page"
+ page-height="420pt" page-width="320pt" margin="10pt">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="page">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block font-size="40pt">Lorem ipsum dolor <fo:basic-link id="link" color="blue"
+ font-size="12pt" external-destination="url(http://xmlgraphics.apache.org/fop/)"
+ baseline-shift="-5pt">sit <fo:inline baseline-shift="5pt">amet,</fo:inline> <fo:inline
+ font-size="24pt" baseline-shift="-10pt">consectetur</fo:inline>
+ adipiscing</fo:basic-link>elit.</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <!-- First line -->
+ <eval expected="28584" xpath="//lineArea[2]//inlineparent[@prod-id='link']/@bpd"/>
+ <eval expected="20104" xpath="//lineArea[2]//inlineparent[@prod-id='link']/@offset"/>
+
+ <eval expected="11100" xpath="//lineArea[2]//inlineparent[@prod-id='link']/text[1]/@bpd"/>
+ <eval expected="5000" xpath="//lineArea[2]//inlineparent[@prod-id='link']/text[1]/@offset"/>
+
+ <eval expected="11100" xpath="//lineArea[2]//inlineparent[@prod-id='link']/inlineparent[1]/@bpd"/>
+ <eval expected="0" xpath="//lineArea[2]//inlineparent[@prod-id='link']/inlineparent[1]/@offset"/>
+
+ <eval expected="22200" xpath="//lineArea[2]//inlineparent[@prod-id='link']/inlineparent[2]/@bpd"/>
+ <eval expected="6384" xpath="//lineArea[2]//inlineparent[@prod-id='link']/inlineparent[2]/@offset"/>
+
+ <!-- Second line -->
+ <eval expected="11100" xpath="//lineArea[3]//inlineparent[@prod-id='link']/@bpd"/>
+ <eval expected="25104" xpath="//lineArea[3]//inlineparent[@prod-id='link']/@offset"/>
+ </checks>
+</testcase>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- $Id$ -->
+<testcase>
+ <info>
+ <p>
+ This test checks the height of an fo:basic-link having several child elements wrapped into a
+ single fo:inline element.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page"
+ page-height="420pt" page-width="320pt" margin="10pt">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="page">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>Lorem ipsum dolor sit amet, consectetur adipiscing elit. <fo:basic-link
+ id="link" color="blue"
+ external-destination="url(http://xmlgraphics.apache.org/fop/)"><fo:inline>In
+ <fo:inline baseline-shift="12pt">in</fo:inline> <fo:inline font-size="24pt"
+ baseline-shift="-20pt">egestas</fo:inline> nisi</fo:inline></fo:basic-link>. Etiam
+ at ante eget velit placerat ullamcorper.</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <eval expected="45584" xpath="//inlineparent[@prod-id='link']/@bpd"/>
+ <eval expected="0" xpath="//inlineparent[@prod-id='link']/@offset"/>
+
+ <eval expected="11100" xpath="//inlineparent[@prod-id='link']/inlineparent/@bpd"/>
+ <eval expected="12000" xpath="//inlineparent[@prod-id='link']/inlineparent/@offset"/>
+
+ <eval expected="11100" xpath="//inlineparent[@prod-id='link']/inlineparent/text[1]/@bpd"/>
+ <eval expected="0" xpath="//inlineparent[@prod-id='link']/inlineparent/text[1]/@offset"/>
+
+ <eval expected="11100" xpath="//inlineparent[@prod-id='link']/inlineparent/inlineparent[1]/@bpd"/>
+ <eval expected="-12000" xpath="//inlineparent[@prod-id='link']/inlineparent/inlineparent[1]/@offset"/>
+
+ <eval expected="22200" xpath="//inlineparent[@prod-id='link']/inlineparent/inlineparent[2]/@bpd"/>
+ <eval expected="11384" xpath="//inlineparent[@prod-id='link']/inlineparent/inlineparent[2]/@offset"/>
+ </checks>
+</testcase>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- $Id$ -->
+<testcase>
+ <info>
+ <p>
+ This test checks the height of an fo:basic-link having several child elements.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page"
+ page-height="420pt" page-width="320pt" margin="10pt">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="page">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>Lorem ipsum dolor sit amet, consectetur adipiscing elit. <fo:basic-link
+ id="link" color="blue"
+ external-destination="url(http://xmlgraphics.apache.org/fop/)">In <fo:inline
+ baseline-shift="12pt">in</fo:inline> <fo:inline font-size="24pt"
+ baseline-shift="-20pt">egestas</fo:inline> nisi</fo:basic-link>. Etiam at ante eget
+ velit placerat ullamcorper.</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <eval expected="45584" xpath="//inlineparent[@prod-id='link']/@bpd"/>
+ <eval expected="0" xpath="//inlineparent[@prod-id='link']/@offset"/>
+
+ <eval expected="11100" xpath="//inlineparent[@prod-id='link']/text[1]/@bpd"/>
+ <eval expected="12000" xpath="//inlineparent[@prod-id='link']/text[1]/@offset"/>
+
+ <eval expected="11100" xpath="//inlineparent[@prod-id='link']/inlineparent[1]/@bpd"/>
+ <eval expected="0" xpath="//inlineparent[@prod-id='link']/inlineparent[1]/@offset"/>
+
+ <eval expected="22200" xpath="//inlineparent[@prod-id='link']/inlineparent[2]/@bpd"/>
+ <eval expected="23384" xpath="//inlineparent[@prod-id='link']/inlineparent[2]/@offset"/>
+ </checks>
+</testcase>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- $Id$ -->
+<testcase>
+ <info>
+ <p>
+ This test checks the height of an fo:basic-link spanning over several lines.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page"
+ page-height="420pt" page-width="320pt" margin="10pt">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="page">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer quis neque
+ vitae lectus condimentum. <fo:basic-link id="link" color="blue"
+ external-destination="url(http://xmlgraphics.apache.org/fop/)">In <fo:inline
+ baseline-shift="12pt">in</fo:inline> <fo:inline font-size="24pt"
+ baseline-shift="-20pt">egestas</fo:inline> nisi</fo:basic-link>. Etiam at ante eget
+ velit placerat ullamcorper.</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <!-- First line -->
+ <eval expected="23100" xpath="//lineArea[2]//inlineparent[@prod-id='link']/@bpd"/>
+ <eval expected="0" xpath="//lineArea[2]//inlineparent[@prod-id='link']/@offset"/>
+
+ <eval expected="11100" xpath="//lineArea[2]//inlineparent[@prod-id='link']/text[1]/@bpd"/>
+ <eval expected="12000" xpath="//lineArea[2]//inlineparent[@prod-id='link']/text[1]/@offset"/>
+
+ <eval expected="11100" xpath="//lineArea[2]//inlineparent[@prod-id='link']/inlineparent/@bpd"/>
+ <eval expected="0" xpath="//lineArea[2]//inlineparent[@prod-id='link']/inlineparent/@offset"/>
+
+ <!-- Second line -->
+ <eval expected="33584" xpath="//lineArea[3]//inlineparent[@prod-id='link']/@bpd"/>
+ <eval expected="0" xpath="//lineArea[3]//inlineparent[@prod-id='link']/@offset"/>
+
+ <eval expected="22200" xpath="//lineArea[3]//inlineparent[@prod-id='link']/inlineparent/@bpd"/>
+ <eval expected="11384" xpath="//lineArea[3]//inlineparent[@prod-id='link']/inlineparent/@offset"/>
+
+ <eval expected="11100" xpath="//lineArea[3]//inlineparent[@prod-id='link']/text[1]/@bpd"/>
+ <eval expected="0" xpath="//lineArea[3]//inlineparent[@prod-id='link']/text[1]/@offset"/>
+
+ </checks>
+</testcase>