aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
authorPeter Herweg <pherweg@apache.org>2004-01-01 21:19:55 +0000
committerPeter Herweg <pherweg@apache.org>2004-01-01 21:19:55 +0000
commit03e94befcd2bbdd8ed02275bab2ee3ec28eddbd6 (patch)
tree4c5215987b858343383d9017a3865ef03afd29b5 /src/java/org
parent2d927b99dd009fd4c919464a7309dac408885be2 (diff)
downloadxmlgraphics-fop-03e94befcd2bbdd8ed02275bab2ee3ec28eddbd6.tar.gz
xmlgraphics-fop-03e94befcd2bbdd8ed02275bab2ee3ec28eddbd6.zip
added support for fo:basic-link
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197087 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/fo/FOInputHandler.java4
-rw-r--r--src/java/org/apache/fop/fo/FOTreeHandler.java5
-rw-r--r--src/java/org/apache/fop/fo/flow/BasicLink.java21
-rw-r--r--src/java/org/apache/fop/render/mif/MIFHandler.java5
-rw-r--r--src/java/org/apache/fop/render/rtf/RTFHandler.java37
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java16
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java4
7 files changed, 84 insertions, 8 deletions
diff --git a/src/java/org/apache/fop/fo/FOInputHandler.java b/src/java/org/apache/fop/fo/FOInputHandler.java
index 3e2000685..49c99bf06 100644
--- a/src/java/org/apache/fop/fo/FOInputHandler.java
+++ b/src/java/org/apache/fop/fo/FOInputHandler.java
@@ -55,6 +55,7 @@ import org.apache.avalon.framework.logger.AbstractLogEnabled;
// FOP
import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.Inline;
@@ -337,8 +338,9 @@ public abstract class FOInputHandler extends AbstractLogEnabled {
/**
* Process start of a Link.
+ * @param basicLink BasicLink that is ending
*/
- public abstract void startLink();
+ public abstract void startLink(BasicLink basicLink);
/**
* Process end of a Link.
diff --git a/src/java/org/apache/fop/fo/FOTreeHandler.java b/src/java/org/apache/fop/fo/FOTreeHandler.java
index d1dbab1d6..25ddc66a1 100644
--- a/src/java/org/apache/fop/fo/FOTreeHandler.java
+++ b/src/java/org/apache/fop/fo/FOTreeHandler.java
@@ -59,6 +59,7 @@ import org.xml.sax.SAXException;
// FOP
import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.InstreamForeignObject;
@@ -415,9 +416,9 @@ public class FOTreeHandler extends FOInputHandler {
}
/**
- * @see org.apache.fop.fo.FOInputHandler#startLink()
+ * @see org.apache.fop.fo.FOInputHandler#startLink(BasicLink basicLink)
*/
- public void startLink() {
+ public void startLink(BasicLink basicLink) {
}
/**
diff --git a/src/java/org/apache/fop/fo/flow/BasicLink.java b/src/java/org/apache/fop/fo/flow/BasicLink.java
index 4d237ebcd..ed5a847cc 100644
--- a/src/java/org/apache/fop/fo/flow/BasicLink.java
+++ b/src/java/org/apache/fop/fo/flow/BasicLink.java
@@ -50,7 +50,11 @@
*/
package org.apache.fop.fo.flow;
+// XML
+import org.xml.sax.Attributes;
+
// FOP
+import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOTreeVisitor;
import org.apache.fop.fo.properties.CommonAccessibility;
@@ -157,4 +161,21 @@ public class BasicLink extends Inline {
fotv.serveBasicLink(this);
}
+ /**
+ * @see org.apache.fop.fo.FObj#handleAttrs
+ */
+ public void handleAttrs(Attributes attlist) throws FOPException {
+ super.handleAttrs(attlist);
+
+ getFOTreeControl().getFOInputHandler().startLink(this);
+ }
+
+ /**
+ * @see org.apache.fop.fo.FONode#end
+ */
+ public void end() {
+ super.end();
+
+ getFOTreeControl().getFOInputHandler().endLink();
+ }
}
diff --git a/src/java/org/apache/fop/render/mif/MIFHandler.java b/src/java/org/apache/fop/render/mif/MIFHandler.java
index a7cf15117..63eab22a0 100644
--- a/src/java/org/apache/fop/render/mif/MIFHandler.java
+++ b/src/java/org/apache/fop/render/mif/MIFHandler.java
@@ -57,6 +57,7 @@ import java.io.OutputStream;
import org.apache.fop.apps.Document;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FOInputHandler;
+import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.InstreamForeignObject;
@@ -398,9 +399,9 @@ public class MIFHandler extends FOInputHandler {
}
/**
- * @see org.apache.fop.fo.FOInputHandler#startLink()
+ * @see org.apache.fop.fo.FOInputHandler#startLink(BasicLink basicLink)
*/
- public void startLink() {
+ public void startLink(BasicLink basicLink) {
}
/**
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java
index d1bf6e58f..f3122b332 100644
--- a/src/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -61,6 +61,7 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.EnumProperty;
import org.apache.fop.fo.FOInputHandler;
import org.apache.fop.datatypes.FixedLength;
+import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.Inline;
@@ -81,6 +82,7 @@ import org.apache.fop.fo.pagination.SimplePageMaster;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.Property;
import org.apache.fop.fo.LengthProperty;
+import org.apache.fop.fo.StringProperty;
import org.apache.fop.apps.Document;
import org.apache.fop.render.rtf.rtflib.rtfdoc.ITableAttributes;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfAfterContainer;
@@ -94,6 +96,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfHyperLink;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem.RtfListItemLabel;
@@ -730,15 +733,45 @@ public class RTFHandler extends FOInputHandler {
}
/**
- * @see org.apache.fop.fo.FOInputHandler#startLink()
+ * @see org.apache.fop.fo.FOInputHandler#startLink(BasicLink basicLink)
*/
- public void startLink() {
+ public void startLink(BasicLink basicLink) {
+ try {
+ IRtfTextrunContainer container
+ = (IRtfTextrunContainer)builderContext.getContainer(
+ IRtfTextrunContainer.class, true, this);
+
+ RtfTextrun textrun=container.getTextrun();
+
+ RtfHyperLink link=textrun.addHyperlink(new RtfAttributes());
+
+ StringProperty internal
+ = (StringProperty)basicLink.propertyList.get(Constants.PR_INTERNAL_DESTINATION);
+ StringProperty external
+ = (StringProperty)basicLink.propertyList.get(Constants.PR_EXTERNAL_DESTINATION);
+
+ if(external != null) {
+ link.setExternalURL(external.getString());
+ } else if(internal != null) {
+ link.setInternalURL(internal.getString());
+ }
+
+ builderContext.pushContainer(link);
+
+ } catch (IOException ioe) {
+ log.error("startLink:" + ioe.getMessage());
+ throw new Error(ioe.getMessage());
+ } catch (Exception e) {
+ log.error("startLink: " + e.getMessage());
+ throw new Error(e.getMessage());
+ }
}
/**
* @see org.apache.fop.fo.FOInputHandler#endLink()
*/
public void endLink() {
+ builderContext.popContainer();
}
/**
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java
index f1862ed3f..213c10d11 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java
@@ -68,7 +68,10 @@ import java.io.IOException;
*
* {\field {\*\fldinst HYPERLINK "http://www.test.de" }{\fldrslt Joe Smith}}
*/
-public class RtfHyperLink extends RtfContainer implements IRtfTextContainer {
+public class RtfHyperLink
+extends RtfContainer
+implements IRtfTextContainer,
+ IRtfTextrunContainer {
//////////////////////////////////////////////////
// @@ Members
@@ -99,6 +102,11 @@ public class RtfHyperLink extends RtfContainer implements IRtfTextContainer {
super ((RtfContainer) parent, writer, attr);
new RtfText (this, writer, str, attr);
}
+
+ public RtfHyperLink (RtfTextrun parent, Writer writer, RtfAttributes attr)
+ throws IOException {
+ super ((RtfContainer) parent, writer, attr);
+ }
//////////////////////////////////////////////////
@@ -240,4 +248,10 @@ public class RtfHyperLink extends RtfContainer implements IRtfTextContainer {
public boolean isEmpty () {
return false;
}
+
+ public RtfTextrun getTextrun()
+ throws IOException {
+ RtfTextrun textrun = RtfTextrun.getTextrun(this, writer, null);
+ return textrun;
+ }
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
index 161f29f52..378b98db2 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
@@ -172,6 +172,10 @@ public class RtfTextrun extends RtfContainer {
RtfPageNumber r = new RtfPageNumber(this, writer, attr);
}
+ public RtfHyperLink addHyperlink(RtfAttributes attr) throws IOException {
+ return new RtfHyperLink(this, writer, attr);
+ }
+
public RtfExternalGraphic newImage() throws IOException {
return new RtfExternalGraphic(this, writer);
}