View | Details | Raw Unified | Return to bug 44634
Collapse All | Expand All

(-)test/layoutengine/standard-testcases/basic-link_external-destination.xml (-2 / +2 lines)
Lines 38-44 Link Here
38
    </fo:root>
38
    </fo:root>
39
  </fo>
39
  </fo>
40
  <checks>
40
  <checks>
41
    <eval expected="http://xmlgraphics.apache.org/fop/" xpath="//flow/block[1]/lineArea/inlineparent/@external-link"/>
41
    <eval expected="http://xmlgraphics.apache.org/fop/" xpath="substring-before(substring-after(//flow/block[1]/lineArea/inlineparent/@external-link,'dest='),';')"/>
42
    <eval expected="http://xmlgraphics.apache.org/fop/" xpath="//flow/block[2]/lineArea/inlineparent/@external-link"/>
42
    <eval expected="http://xmlgraphics.apache.org/fop/" xpath="substring-before(substring-after(//flow/block[2]/lineArea/inlineparent/@external-link,'dest='),';')"/>
43
  </checks>
43
  </checks>
44
</testcase>
44
</testcase>
(-)src/java/org/apache/fop/pdf/PDFGoToRemote.java (-9 / +25 lines)
Lines 20-26 Link Here
20
package org.apache.fop.pdf;
20
package org.apache.fop.pdf;
21
21
22
/**
22
/**
23
 * class representing a /GoToR object.
23
 * Class representing a /GoToR object.
24
 */
24
 */
25
public class PDFGoToRemote extends PDFAction {
25
public class PDFGoToRemote extends PDFAction {
26
26
Lines 30-46 Link Here
30
    private PDFFileSpec pdfFileSpec;
30
    private PDFFileSpec pdfFileSpec;
31
    private int pageReference = 0;
31
    private int pageReference = 0;
32
    private String destination = null;
32
    private String destination = null;
33
    private boolean newWindow = false;
33
34
34
    /**
35
    /**
35
     * create an GoToR object.
36
     * Create an GoToR object.
36
     *
37
     *
37
     * @param pdfFileSpec the fileSpec associated with the action
38
     * @param pdfFileSpec the fileSpec associated with the action
39
     * @param newWindow boolean indicating whether the target should be
40
     *                  displayed in a new window
38
     */
41
     */
39
    public PDFGoToRemote(PDFFileSpec pdfFileSpec) {
42
    public PDFGoToRemote(PDFFileSpec pdfFileSpec, boolean newWindow) {
40
        /* generic creation of object */
43
        /* generic creation of object */
41
        super();
44
        super();
42
45
43
        this.pdfFileSpec = pdfFileSpec;
46
        this.pdfFileSpec = pdfFileSpec;
47
        this.newWindow = newWindow;
44
    }
48
    }
45
49
46
    /**
50
    /**
Lines 48-60 Link Here
48
     *
52
     *
49
     * @param pdfFileSpec the fileSpec associated with the action
53
     * @param pdfFileSpec the fileSpec associated with the action
50
     * @param page a page reference within the remote document
54
     * @param page a page reference within the remote document
55
     * @param newWindow boolean indicating whether the target should be
56
     *                  displayed in a new window
51
     */
57
     */
52
    public PDFGoToRemote(PDFFileSpec pdfFileSpec, int page) {
58
    public PDFGoToRemote(PDFFileSpec pdfFileSpec, int page, boolean newWindow) {
53
        /* generic creation of object */
59
        /* generic creation of object */
54
        super();
60
        super();
55
61
56
        this.pdfFileSpec = pdfFileSpec;
62
        this.pdfFileSpec = pdfFileSpec;
57
        this.pageReference = page;
63
        this.pageReference = page;
64
        this.newWindow = newWindow;
58
    }
65
    }
59
66
60
    /**
67
    /**
Lines 62-74 Link Here
62
     *
69
     *
63
     * @param pdfFileSpec the fileSpec associated with the action
70
     * @param pdfFileSpec the fileSpec associated with the action
64
     * @param dest a named destination within the remote document
71
     * @param dest a named destination within the remote document
72
     * @param newWindow boolean indicating whether the target should be
73
     *                  displayed in a new window
65
     */
74
     */
66
    public PDFGoToRemote(PDFFileSpec pdfFileSpec, String dest) {
75
    public PDFGoToRemote(PDFFileSpec pdfFileSpec, String dest, boolean newWindow) {
67
        /* generic creation of object */
76
        /* generic creation of object */
68
        super();
77
        super();
69
78
70
        this.pdfFileSpec = pdfFileSpec;
79
        this.pdfFileSpec = pdfFileSpec;
71
        this.destination = dest;
80
        this.destination = dest;
81
        this.newWindow = newWindow;
72
    }
82
    }
73
83
74
    /**
84
    /**
Lines 86-99 Link Here
86
    public String toPDFString() {
96
    public String toPDFString() {
87
        StringBuffer sb = new StringBuffer(64);
97
        StringBuffer sb = new StringBuffer(64);
88
        sb.append(getObjectID());
98
        sb.append(getObjectID());
89
        sb.append("<<\n/S /GoToR\n/F " + pdfFileSpec.referencePDF() + "\n");
99
        sb.append("<<\n/S /GoToR\n/F ");
100
        sb.append(pdfFileSpec.referencePDF());
101
        sb.append("\n");
90
102
91
        if (destination != null) {
103
        if (destination != null) {
92
            sb.append("/D (" + this.destination + ")");
104
            sb.append("/D (").append(this.destination).append(")");
93
        } else {
105
        } else {
94
            sb.append("/D [ " + this.pageReference + " /XYZ null null null ]");
106
            sb.append("/D [ ").append(this.pageReference).append(" /XYZ null null null ]");
95
        }
107
        }
96
108
109
        if (newWindow) {
110
            sb.append("/NewWindow true");
111
        }
112
97
        sb.append(" \n>>\nendobj\n");
113
        sb.append(" \n>>\nendobj\n");
98
114
99
        return sb.toString();
115
        return sb.toString();
Lines 142-148 Link Here
142
            }
158
            }
143
        }
159
        }
144
160
145
        return true;
161
        return (this.newWindow == remote.newWindow);
146
    }
162
    }
147
}
163
}
148
164
(-)src/java/org/apache/fop/fo/FOPropertyMapping.java (-5 / +6 lines)
Lines 258-264 Link Here
258
258
259
    /**
259
    /**
260
     * Return a (possibly cached) enum property based in the enum value.
260
     * Return a (possibly cached) enum property based in the enum value.
261
     * @param enum A enum value from Constants.java.
261
     * @param enumValue A enum value from Constants.java.
262
     * @param text the text value by which this enum property is known
262
     * @param text the text value by which this enum property is known
263
     * @return An EnumProperty instance.
263
     * @return An EnumProperty instance.
264
     */
264
     */
Lines 371-379 Link Here
371
                || ((id & Constants.PROPERTY_MASK) == 0)) {
371
                || ((id & Constants.PROPERTY_MASK) == 0)) {
372
            return (String) s_htPropIds.get(new Integer(id));
372
            return (String) s_htPropIds.get(new Integer(id));
373
        } else {
373
        } else {
374
            return (String) s_htPropIds.get(new Integer(
374
            return s_htPropIds.get(new Integer(id & Constants.PROPERTY_MASK))
375
                    id & Constants.PROPERTY_MASK)) + "." + s_htPropIds.get(
375
                    + "." + s_htPropIds.get(new Integer(id & Constants.COMPOUND_MASK));
376
                            new Integer(id & Constants.COMPOUND_MASK));
377
        }
376
        }
378
    }
377
    }
379
378
Lines 2019-2026 Link Here
2019
        addPropertyMaker("internal-destination", m);
2018
        addPropertyMaker("internal-destination", m);
2020
2019
2021
        // show-destination
2020
        // show-destination
2022
        m  = new ToBeImplementedProperty.Maker(PR_SHOW_DESTINATION);
2021
        m  = new EnumProperty.Maker(PR_SHOW_DESTINATION);
2023
        m.setInherited(false);
2022
        m.setInherited(false);
2023
        m.addEnum("new", getEnumProperty(EN_NEW, "NEW"));
2024
        m.addEnum("replace", getEnumProperty(EN_REPLACE, "REPLACE"));
2024
        m.setDefault("replace");
2025
        m.setDefault("replace");
2025
        addPropertyMaker("show-destination", m);
2026
        addPropertyMaker("show-destination", m);
2026
2027
(-)src/java/org/apache/fop/fo/flow/BasicLink.java (-21 / +36 lines)
Lines 27-45 Link Here
27
import org.apache.fop.fo.ValidationException;
27
import org.apache.fop.fo.ValidationException;
28
28
29
/**
29
/**
30
 * Class modelling the fo:basic-link object.
30
 * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_basic-link">
31
 * <code>fo:basic-link</code></a> object.
31
 *
32
 *
32
 * This class contains the logic to determine the link represented by this FO,
33
 * This class contains the logic to determine the link represented by this FO,
33
 * and whether that link is external (uses a URI) or internal (an id 
34
 * and whether that link is external (uses a URI) or internal (an id 
34
 * reference).
35
 * reference).
35
 */
36
 */
36
public class BasicLink extends Inline {
37
public class BasicLink extends Inline {
38
37
    // The value of properties relevant for fo:basic-link.
39
    // The value of properties relevant for fo:basic-link.
38
    // private ToBeImplementedProperty destinationPlacementOffset;
40
    // private ToBeImplementedProperty destinationPlacementOffset;
39
    private String externalDestination;
41
    private String externalDestination;
40
    // private ToBeImplementedProperty indicateDestination;
42
    // private ToBeImplementedProperty indicateDestination;
41
    private String internalDestination;
43
    private String internalDestination;
42
    // private ToBeImplementedProperty showDestination;
44
    private int showDestination;
43
    // private ToBeImplementedProperty targetProcessingContext;
45
    // private ToBeImplementedProperty targetProcessingContext;
44
    // private ToBeImplementedProperty targetPresentationContext;
46
    // private ToBeImplementedProperty targetPresentationContext;
45
    // private ToBeImplementedProperty targetStylesheet;
47
    // private ToBeImplementedProperty targetStylesheet;
Lines 51-72 Link Here
51
    private boolean blockOrInlineItemFound = false;
53
    private boolean blockOrInlineItemFound = false;
52
54
53
    /**
55
    /**
54
     * @param parent FONode that is the parent of this object
56
     * Construct a BasicLink instance with the given {@link FONode}
57
     * as its parent.
58
     * 
59
     * @param parent {@link FONode} that is the parent of this object
55
     */
60
     */
56
    public BasicLink(FONode parent) {
61
    public BasicLink(FONode parent) {
57
        super(parent);
62
        super(parent);
58
    }
63
    }
59
64
60
    /**
65
    /** {@inheritDoc} */
61
     * {@inheritDoc}
62
     */
63
    public void bind(PropertyList pList) throws FOPException {
66
    public void bind(PropertyList pList) throws FOPException {
64
        super.bind(pList);
67
        super.bind(pList);
65
        // destinationPlacementOffset = pList.get(PR_DESTINATION_PLACEMENT_OFFSET);
68
        // destinationPlacementOffset = pList.get(PR_DESTINATION_PLACEMENT_OFFSET);
66
        externalDestination = pList.get(PR_EXTERNAL_DESTINATION).getString();
69
        externalDestination = pList.get(PR_EXTERNAL_DESTINATION).getString();
67
        // indicateDestination = pList.get(PR_INDICATE_DESTINATION);
70
        // indicateDestination = pList.get(PR_INDICATE_DESTINATION);
68
        internalDestination = pList.get(PR_INTERNAL_DESTINATION).getString();
71
        internalDestination = pList.get(PR_INTERNAL_DESTINATION).getString();
69
        // showDestination = pList.get(PR_SHOW_DESTINATION);
72
        showDestination = pList.get(PR_SHOW_DESTINATION).getEnum();
70
        // targetProcessingContext = pList.get(PR_TARGET_PROCESSING_CONTEXT);
73
        // targetProcessingContext = pList.get(PR_TARGET_PROCESSING_CONTEXT);
71
        // targetPresentationContext = pList.get(PR_TARGET_PRESENTATION_CONTEXT);
74
        // targetPresentationContext = pList.get(PR_TARGET_PRESENTATION_CONTEXT);
72
        // targetStylesheet = pList.get(PR_TARGET_STYLESHEET);
75
        // targetStylesheet = pList.get(PR_TARGET_STYLESHEET);
Lines 81-106 Link Here
81
        }
84
        }
82
    }
85
    }
83
86
84
    /**
87
    /** {@inheritDoc} */
85
     * {@inheritDoc}
86
     */
87
    protected void startOfNode() throws FOPException {
88
    protected void startOfNode() throws FOPException {
88
        super.startOfNode();
89
        super.startOfNode();
89
        getFOEventHandler().startLink(this);
90
        getFOEventHandler().startLink(this);
90
    }
91
    }
91
92
92
    /**
93
    /** {@inheritDoc} */
93
     * {@inheritDoc}
94
     */
95
    protected void endOfNode() throws FOPException {
94
    protected void endOfNode() throws FOPException {
96
        super.endOfNode();
95
        super.endOfNode();
97
        getFOEventHandler().endLink();
96
        getFOEventHandler().endLink();
98
    }
97
    }
99
98
100
    /**
99
    /** {@inheritDoc} */
101
     * {@inheritDoc} String, String)
102
     * XSL Content Model: marker* (#PCDATA|%inline;|%block;)*
103
     */
104
    protected void validateChildNode(Locator loc, String nsURI, String localName) 
100
    protected void validateChildNode(Locator loc, String nsURI, String localName) 
105
        throws ValidationException {
101
        throws ValidationException {
106
        if (FO_URI.equals(nsURI) && localName.equals("marker")) {
102
        if (FO_URI.equals(nsURI) && localName.equals("marker")) {
Lines 115-147 Link Here
115
    }
111
    }
116
112
117
    /**
113
    /**
118
     * @return the "internal-destination" property.
114
     * Get the value of the <code>internal-destination</code> property.
115
     *
116
     * @return the "internal-destination" property
119
     */
117
     */
120
    public String getInternalDestination() {
118
    public String getInternalDestination() {
121
        return internalDestination;
119
        return internalDestination;
122
    }
120
    }
123
121
124
    /**
122
    /**
125
     * @return the "external-destination" property.
123
     * Get the value of the <code>external-destination</code> property.
124
     *
125
     * @return the "external-destination" property
126
     */
126
     */
127
    public String getExternalDestination() {
127
    public String getExternalDestination() {
128
        return externalDestination;
128
        return externalDestination;
129
    }
129
    }
130
130
131
    /**
131
    /**
132
     * @return whether or not this basic link has an internal destination or not
132
     * Convenience method to check if this instance has an internal destination.
133
     *
134
     * @return <code>true</code> if this basic link has an internal destination;
135
     *          <code>false</code> otherwise
133
     */
136
     */
134
    public boolean hasInternalDestination() {
137
    public boolean hasInternalDestination() {
135
        return internalDestination != null && internalDestination.length() > 0;
138
        return internalDestination != null && internalDestination.length() > 0;
136
    }
139
    }
137
140
138
    /**
141
    /**
139
     * @return whether or not this basic link has an external destination or not
142
     * Convenience method to check if this instance has an external destination
143
     *
144
     * @return <code>true</code> if this basic link has an external destination;
145
     *          <code>false</code> otherwise
140
     */
146
     */
141
    public boolean hasExternalDestination() {
147
    public boolean hasExternalDestination() {
142
        return externalDestination != null && externalDestination.length() > 0;
148
        return externalDestination != null && externalDestination.length() > 0;
143
    }
149
    }
144
150
151
    /**
152
     * Get the value of the <code>show-destination</code> property.
153
     *
154
     * @return the "show-destination" property
155
     */
156
    public int getShowDestination() {
157
        return this.showDestination;
158
    }
159
145
    /** {@inheritDoc} */
160
    /** {@inheritDoc} */
146
    public String getLocalName() {
161
    public String getLocalName() {
147
        return "basic-link";
162
        return "basic-link";
(-)src/java/org/apache/fop/pdf/PDFFactory.java (-12 / +16 lines)
Lines 737-743 Link Here
737
        List theCone;
737
        List theCone;
738
        PDFPattern myPattern;
738
        PDFPattern myPattern;
739
        //PDFColorSpace theColorSpace;
739
        //PDFColorSpace theColorSpace;
740
        double interpolation = (double)1.000;
740
        double interpolation = 1.000;
741
        List theFunctions = new ArrayList();
741
        List theFunctions = new ArrayList();
742
742
743
        int currentPosition;
743
        int currentPosition;
Lines 961-967 Link Here
961
    }
961
    }
962
962
963
    /**
963
    /**
964
     * make a link object
964
     * Make a {@link PDFLink} object
965
     *
965
     *
966
     * @param rect   the clickable rectangle
966
     * @param rect   the clickable rectangle
967
     * @param destination  the destination file
967
     * @param destination  the destination file
Lines 976-982 Link Here
976
        PDFLink link = new PDFLink(rect);
976
        PDFLink link = new PDFLink(rect);
977
977
978
        if (linkType == PDFLink.EXTERNAL) {
978
        if (linkType == PDFLink.EXTERNAL) {
979
            link.setAction(getExternalAction(destination));
979
            link.setAction(getExternalAction(destination, false));
980
        } else {
980
        } else {
981
            // linkType is internal
981
            // linkType is internal
982
            String goToReference = getGoToReference(destination, yoffset);
982
            String goToReference = getGoToReference(destination, yoffset);
Lines 999-1007 Link Here
999
     *
999
     *
1000
     * @param target The external target. This may be a PDF file name
1000
     * @param target The external target. This may be a PDF file name
1001
     * (optionally with internal page number or destination) or any type of URI.
1001
     * (optionally with internal page number or destination) or any type of URI.
1002
     * @param newWindow boolean indicating whether the target should be
1003
     *                  displayed in a new window
1002
     * @return the PDFAction thus created or found
1004
     * @return the PDFAction thus created or found
1003
     */
1005
     */
1004
    public PDFAction getExternalAction(String target) {
1006
    public PDFAction getExternalAction(String target, boolean newWindow) {
1005
        int index;
1007
        int index;
1006
        String targetLo = target.toLowerCase();
1008
        String targetLo = target.toLowerCase();
1007
        // HTTP URL?
1009
        // HTTP URL?
Lines 1009-1025 Link Here
1009
            return new PDFUri(target);
1011
            return new PDFUri(target);
1010
        // Bare PDF file name?
1012
        // Bare PDF file name?
1011
        } else if (targetLo.endsWith(".pdf")) {
1013
        } else if (targetLo.endsWith(".pdf")) {
1012
            return getGoToPDFAction(target, null, -1);
1014
            return getGoToPDFAction(target, null, -1, newWindow);
1013
        // PDF file + page?
1015
        // PDF file + page?
1014
        } else if ((index = targetLo.indexOf(".pdf#page=")) > 0) {
1016
        } else if ((index = targetLo.indexOf(".pdf#page=")) > 0) {
1015
            String filename = target.substring(0, index + 4);
1017
            String filename = target.substring(0, index + 4);
1016
            int page = Integer.parseInt(target.substring(index + 10));
1018
            int page = Integer.parseInt(target.substring(index + 10));
1017
            return getGoToPDFAction(filename, null, page);
1019
            return getGoToPDFAction(filename, null, page, newWindow);
1018
        // PDF file + destination?
1020
        // PDF file + destination?
1019
        } else if ((index = targetLo.indexOf(".pdf#dest=")) > 0) {
1021
        } else if ((index = targetLo.indexOf(".pdf#dest=")) > 0) {
1020
            String filename = target.substring(0, index + 4);
1022
            String filename = target.substring(0, index + 4);
1021
            String dest = target.substring(index + 10);
1023
            String dest = target.substring(index + 10);
1022
            return getGoToPDFAction(filename, dest, -1);
1024
            return getGoToPDFAction(filename, dest, -1, newWindow);
1023
        // None of the above? Default to URI:
1025
        // None of the above? Default to URI:
1024
        } else {
1026
        } else {
1025
            return new PDFUri(target);
1027
            return new PDFUri(target);
Lines 1069-1077 Link Here
1069
     * @param file the pdf file name
1071
     * @param file the pdf file name
1070
     * @param dest the remote name destination, may be null
1072
     * @param dest the remote name destination, may be null
1071
     * @param page the remote page number, -1 means not specified
1073
     * @param page the remote page number, -1 means not specified
1074
     * @param newWindow boolean indicating whether the target should be
1075
     *                  displayed in a new window
1072
     * @return the pdf goto remote object
1076
     * @return the pdf goto remote object
1073
     */
1077
     */
1074
    private PDFGoToRemote getGoToPDFAction(String file, String dest, int page) {
1078
    private PDFGoToRemote getGoToPDFAction(String file, String dest, int page, boolean newWindow) {
1075
        getDocument().getProfile().verifyActionAllowed();
1079
        getDocument().getProfile().verifyActionAllowed();
1076
        PDFFileSpec fileSpec = new PDFFileSpec(file);
1080
        PDFFileSpec fileSpec = new PDFFileSpec(file);
1077
        PDFFileSpec oldspec = getDocument().findFileSpec(fileSpec);
1081
        PDFFileSpec oldspec = getDocument().findFileSpec(fileSpec);
Lines 1083-1093 Link Here
1083
        PDFGoToRemote remote;
1087
        PDFGoToRemote remote;
1084
1088
1085
        if (dest == null && page == -1) {
1089
        if (dest == null && page == -1) {
1086
            remote = new PDFGoToRemote(fileSpec);
1090
            remote = new PDFGoToRemote(fileSpec, newWindow);
1087
        } else if (dest != null) {
1091
        } else if (dest != null) {
1088
            remote = new PDFGoToRemote(fileSpec, dest);
1092
            remote = new PDFGoToRemote(fileSpec, dest, newWindow);
1089
        } else {
1093
        } else {
1090
            remote = new PDFGoToRemote(fileSpec, page);
1094
            remote = new PDFGoToRemote(fileSpec, page, newWindow);
1091
        }
1095
        }
1092
        PDFGoToRemote oldremote = getDocument().findGoToRemote(remote);
1096
        PDFGoToRemote oldremote = getDocument().findGoToRemote(remote);
1093
        if (oldremote == null) {
1097
        if (oldremote == null) {
Lines 1458-1463 Link Here
1458
                try {
1462
                try {
1459
                    in = new java.net.URL(source.getSystemId()).openStream();
1463
                    in = new java.net.URL(source.getSystemId()).openStream();
1460
                } catch (MalformedURLException e) {
1464
                } catch (MalformedURLException e) {
1465
                    //TODO: why construct a new exception when it is not thrown?
1461
                    new FileNotFoundException(
1466
                    new FileNotFoundException(
1462
                            "File not found. URL could not be resolved: "
1467
                            "File not found. URL could not be resolved: "
1463
                                    + e.getMessage());
1468
                                    + e.getMessage());
Lines 1563-1569 Link Here
1563
    /**
1568
    /**
1564
     * Create a PDFICCStream
1569
     * Create a PDFICCStream
1565
     * @see PDFImageXObject
1570
     * @see PDFImageXObject
1566
     * @see org.apache.fop.image.JpegImage
1567
     * @see org.apache.fop.pdf.PDFDeviceColorSpace     
1571
     * @see org.apache.fop.pdf.PDFDeviceColorSpace     
1568
     * @return the new PDF ICC stream object
1572
     * @return the new PDF ICC stream object
1569
     */
1573
     */
(-)src/java/org/apache/fop/fo/Constants.java (-2 / +6 lines)
Lines 1092-1098 Link Here
1092
    /** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */
1092
    /** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */
1093
    int EN_SCALE_DOWN_TO_FIT = 187; 
1093
    int EN_SCALE_DOWN_TO_FIT = 187; 
1094
    /** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */
1094
    /** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */
1095
    int EN_SCALE_UP_TO_FIT = 188; 
1095
    int EN_SCALE_UP_TO_FIT = 188;
1096
    /** Enumeration constant -- for fo:basic-link show-destination */
1097
    int EN_REPLACE = 189;
1098
    /** Enumeration constant -- for fo:basic-link show-destination */
1099
    int EN_NEW = 190;
1096
    /** Number of enumeration constants defined */
1100
    /** Number of enumeration constants defined */
1097
    int ENUM_COUNT = 188;
1101
    int ENUM_COUNT = 190;
1098
}
1102
}
(-)src/java/org/apache/fop/area/Trait.java (-3 / +48 lines)
Lines 194-200 Link Here
194
    public static final Integer OVERLINE_COLOR = new Integer(35);
194
    public static final Integer OVERLINE_COLOR = new Integer(35);
195
    /** Trait for color of linethrough decorations when rendering inline parent. */
195
    /** Trait for color of linethrough decorations when rendering inline parent. */
196
    public static final Integer LINETHROUGH_COLOR = new Integer(36);
196
    public static final Integer LINETHROUGH_COLOR = new Integer(36);
197
    
197
198
    /** Maximum value used by trait keys */
198
    /** Maximum value used by trait keys */
199
    public static final int MAX_TRAIT_KEY = 36;
199
    public static final int MAX_TRAIT_KEY = 36;
200
    
200
    
Lines 226-232 Link Here
226
        // Create a hashmap mapping trait code to name for external representation
226
        // Create a hashmap mapping trait code to name for external representation
227
        //put(ID_LINK, new TraitInfo("id-link", String.class));
227
        //put(ID_LINK, new TraitInfo("id-link", String.class));
228
        put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class));
228
        put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class));
229
        put(EXTERNAL_LINK, new TraitInfo("external-link", String.class));
229
        put(EXTERNAL_LINK, new TraitInfo("external-link", ExternalLink.class));
230
        put(FONT,         new TraitInfo("font", FontTriplet.class));
230
        put(FONT,         new TraitInfo("font", FontTriplet.class));
231
        put(FONT_SIZE,    new TraitInfo("font-size", Integer.class));
231
        put(FONT_SIZE,    new TraitInfo("font-size", Integer.class));
232
        put(COLOR, new TraitInfo("color", Color.class));
232
        put(COLOR, new TraitInfo("color", Color.class));
Lines 277-283 Link Here
277
                new TraitInfo("is-reference-area", Boolean.class));
277
                new TraitInfo("is-reference-area", Boolean.class));
278
        put(IS_VIEWPORT_AREA,
278
        put(IS_VIEWPORT_AREA,
279
                new TraitInfo("is-viewport-area", Boolean.class));
279
                new TraitInfo("is-viewport-area", Boolean.class));
280
        
280
281
    }
281
    }
282
282
283
    /**
283
    /**
Lines 548-553 Link Here
548
    }
548
    }
549
549
550
    /**
550
    /**
551
     * External Link trait structure
552
     */
553
    public static class ExternalLink implements Serializable {
554
555
        private String destination;
556
        private boolean newWindow;
557
558
        /**
559
         * Constructs an ExternalLink object with the given destination
560
         *
561
         * @param destination   target of the link
562
         * @param newWindow     true if the target should be opened in a new window
563
         */
564
        public ExternalLink(String destination, boolean newWindow) {
565
            this.destination = destination;
566
            this.newWindow = newWindow;
567
        }
568
569
        /**
570
         * Get the target/destination of the link
571
         * @return  the destination of the link
572
         */
573
        public String getDestination() {
574
            return this.destination;
575
        }
576
577
        /**
578
         * Check if the target has to be displayed in a new window
579
         * @return  true if the target has to be displayed in a new window
580
         */
581
        public boolean newWindow() {
582
            return this.newWindow;
583
        }
584
585
        /** {@inheritDoc} */
586
        public String toString() {
587
            StringBuffer sb = new StringBuffer(32);
588
            sb.append(ExternalLink.class.getName());
589
            sb.append("[dest=").append(this.destination);
590
            sb.append(";newWindow=").append(newWindow).append("]");
591
            return sb.toString();
592
        }
593
    }
594
595
    /**
551
     * Background trait structure.
596
     * Background trait structure.
552
     * Used for storing back trait information which are related.
597
     * Used for storing back trait information which are related.
553
     */
598
     */
(-)src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java (-5 / +6 lines)
Lines 68-75 Link Here
68
     */
68
     */
69
    private static Log log = LogFactory.getLog(InlineLayoutManager.class);
69
    private static Log log = LogFactory.getLog(InlineLayoutManager.class);
70
70
71
    private InlineLevel fobj;
72
73
    private CommonMarginInline inlineProps = null;
71
    private CommonMarginInline inlineProps = null;
74
    private CommonBorderPaddingBackground borderProps = null;
72
    private CommonBorderPaddingBackground borderProps = null;
75
73
Lines 105-111 Link Here
105
    // The node should be FObjMixed
103
    // The node should be FObjMixed
106
    public InlineLayoutManager(InlineLevel node) {
104
    public InlineLayoutManager(InlineLevel node) {
107
        super(node);
105
        super(node);
108
        fobj = node;
109
    }
106
    }
110
    
107
    
111
    private Inline getInlineFO() {
108
    private Inline getInlineFO() {
Lines 114-119 Link Here
114
    
111
    
115
    /** {@inheritDoc} */
112
    /** {@inheritDoc} */
116
    public void initialize() {
113
    public void initialize() {
114
        InlineLevel fobj = (InlineLevel) this.fobj;
115
117
        int padding = 0;
116
        int padding = 0;
118
        FontInfo fi = fobj.getFOEventHandler().getFontInfo();
117
        FontInfo fi = fobj.getFOEventHandler().getFontInfo();
119
        FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
118
        FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
Lines 557-563 Link Here
557
        if (returnList instanceof BlockKnuthSequence) {
556
        if (returnList instanceof BlockKnuthSequence) {
558
            return;
557
            return;
559
        }
558
        }
560
        CommonBorderPaddingBackground borderAndPadding = fobj.getCommonBorderPaddingBackground();
559
        CommonBorderPaddingBackground borderAndPadding =
560
                ((InlineLevel)fobj).getCommonBorderPaddingBackground();
561
        if (borderAndPadding != null) {
561
        if (borderAndPadding != null) {
562
            int ipStart = borderAndPadding.getBorderStartWidth(false)
562
            int ipStart = borderAndPadding.getBorderStartWidth(false)
563
                         + borderAndPadding.getPaddingStart(false, this);
563
                         + borderAndPadding.getPaddingStart(false, this);
Lines 581-587 Link Here
581
        if (returnList instanceof BlockKnuthSequence) {
581
        if (returnList instanceof BlockKnuthSequence) {
582
            return;
582
            return;
583
        }
583
        }
584
        CommonBorderPaddingBackground borderAndPadding = fobj.getCommonBorderPaddingBackground();
584
        CommonBorderPaddingBackground borderAndPadding =
585
                ((InlineLevel)fobj).getCommonBorderPaddingBackground();
585
        if (borderAndPadding != null) {
586
        if (borderAndPadding != null) {
586
            int ipEnd = borderAndPadding.getBorderEndWidth(false)
587
            int ipEnd = borderAndPadding.getBorderEndWidth(false)
587
                        + borderAndPadding.getPaddingEnd(false, this);
588
                        + borderAndPadding.getPaddingEnd(false, this);
(-)src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java (-7 / +7 lines)
Lines 21-27 Link Here
21
21
22
import org.apache.fop.datatypes.URISpecification;
22
import org.apache.fop.datatypes.URISpecification;
23
import org.apache.fop.fo.flow.BasicLink;
23
import org.apache.fop.fo.flow.BasicLink;
24
import org.apache.fop.layoutmgr.LayoutManager;
24
import org.apache.fop.fo.Constants;
25
import org.apache.fop.layoutmgr.PageSequenceLayoutManager;
25
import org.apache.fop.layoutmgr.PageSequenceLayoutManager;
26
import org.apache.fop.area.inline.InlineArea;
26
import org.apache.fop.area.inline.InlineArea;
27
import org.apache.fop.area.Trait;
27
import org.apache.fop.area.Trait;
Lines 31-37 Link Here
31
 * LayoutManager for the fo:basic-link formatting object
31
 * LayoutManager for the fo:basic-link formatting object
32
 */
32
 */
33
public class BasicLinkLayoutManager extends InlineLayoutManager {
33
public class BasicLinkLayoutManager extends InlineLayoutManager {
34
    private BasicLink fobj;
35
34
36
    /**
35
    /**
37
     * Create an fo:basic-link layout manager.
36
     * Create an fo:basic-link layout manager.
Lines 40-62 Link Here
40
     */
39
     */
41
    public BasicLinkLayoutManager(BasicLink node) {
40
    public BasicLinkLayoutManager(BasicLink node) {
42
        super(node);
41
        super(node);
43
        fobj = node;
44
    }
42
    }
45
43
46
    /** {@inheritDoc} */
44
    /** {@inheritDoc} */
47
    protected InlineArea createArea(boolean bInlineParent) {
45
    protected InlineArea createArea(boolean bInlineParent) {
48
        InlineArea area = super.createArea(bInlineParent);
46
        InlineArea area = super.createArea(bInlineParent);
49
        setupBasicLinkArea(parentLM, area);
47
        setupBasicLinkArea(area);
50
        return area;
48
        return area;
51
    }
49
    }
52
50
53
    /*
51
    /*
54
     * Detect internal or external link and add it as an area trait
52
     * Detect internal or external link and add it as an area trait
55
     *
53
     *
56
     * @param parentLM the parent LayoutManager
57
     * @param area the basic-link's area
54
     * @param area the basic-link's area
58
     */
55
     */
59
    private void setupBasicLinkArea(LayoutManager parentLM, InlineArea area) {
56
    private void setupBasicLinkArea(InlineArea area) {
57
        BasicLink fobj = (BasicLink) this.fobj;
60
        // internal destinations take precedence:
58
        // internal destinations take precedence:
61
        if (fobj.hasInternalDestination()) {
59
        if (fobj.hasInternalDestination()) {
62
            String idref = fobj.getInternalDestination();
60
            String idref = fobj.getInternalDestination();
Lines 70-77 Link Here
70
            }
68
            }
71
        } else if (fobj.hasExternalDestination()) {
69
        } else if (fobj.hasExternalDestination()) {
72
            String url = URISpecification.getURL(fobj.getExternalDestination());
70
            String url = URISpecification.getURL(fobj.getExternalDestination());
71
            boolean newWindow = (fobj.getShowDestination() == Constants.EN_NEW);
73
            if (url.length() > 0) {
72
            if (url.length() > 0) {
74
                area.addTrait(Trait.EXTERNAL_LINK, url);
73
                area.addTrait(Trait.EXTERNAL_LINK,
74
                        new Trait.ExternalLink(url, newWindow));
75
            }
75
            }
76
        }
76
        }
77
    }
77
    }
(-)src/java/org/apache/fop/render/pdf/PDFRenderer.java (-9 / +12 lines)
Lines 1382-1395 Link Here
1382
1382
1383
        // no INTERNAL_LINK, look for EXTERNAL_LINK
1383
        // no INTERNAL_LINK, look for EXTERNAL_LINK
1384
        if (!linkTraitFound) {
1384
        if (!linkTraitFound) {
1385
            String extDest = (String) ip.getTrait(Trait.EXTERNAL_LINK);
1385
            Trait.ExternalLink extLink = (Trait.ExternalLink) ip.getTrait(Trait.EXTERNAL_LINK);
1386
            if (extLink != null) {
1387
                String extDest = extLink.getDestination();
1386
            if (extDest != null && extDest.length() > 0) {
1388
                if (extDest != null && extDest.length() > 0) {
1387
                linkTraitFound = true;
1389
                    linkTraitFound = true;
1388
                if (annotsAllowed) {
1390
                    if (annotsAllowed) {
1389
                    action = factory.getExternalAction(extDest);
1391
                        action = factory.getExternalAction(extDest, extLink.newWindow());
1390
                }
1392
                    }
1391
            }
1393
                }
1392
        }
1394
            }
1395
        }
1393
1396
1394
        // warn if link trait found but not allowed, else create link
1397
        // warn if link trait found but not allowed, else create link
1395
        if (linkTraitFound) {
1398
        if (linkTraitFound) {
Lines 1618-1624 Link Here
1618
     * Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced.
1621
     * Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced.
1619
     * @param uri URL of the bitmap
1622
     * @param uri URL of the bitmap
1620
     * @param pos Position of the bitmap
1623
     * @param pos Position of the bitmap
1621
     * @deprecated Use {@link @putImage(String, Rectangle2D, Map)} instead.
1624
     * @deprecated Use {@link #putImage(String, Rectangle2D, Map)} instead.
1622
     */
1625
     */
1623
    protected void putImage(String uri, Rectangle2D pos) {
1626
    protected void putImage(String uri, Rectangle2D pos) {
1624
        putImage(uri, pos, null);
1627
        putImage(uri, pos, null);

Return to bug 44634