ASF Bugzilla – Attachment 33999 Details for
Bug 59775
[PATCH] XSSFHyperlink has wrong type if it contains a location (CTHyperlink#getLocation)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed solution for XSSFHyperlink
fix_XSSFHyperlink_constructor.patch (text/plain), 4.04 KB, created by
Guillermo Alvarez
on 2016-07-01 09:04:03 UTC
(
hide
)
Description:
Proposed solution for XSSFHyperlink
Filename:
MIME Type:
Creator:
Guillermo Alvarez
Created:
2016-07-01 09:04:03 UTC
Size:
4.04 KB
patch
obsolete
>From d2a4ce944a6be1360d3f6fcd59c8e4950801df55 Mon Sep 17 00:00:00 2001 >From: Guillermo Alvarez <guillermo@vaadin.com> >Date: Fri, 1 Jul 2016 11:51:24 +0300 >Subject: [PATCH] Improve type detection in XSSFHyperlink with location > >--- > .../apache/poi/xssf/usermodel/XSSFHyperlink.java | 71 +++++++++++----------- > 1 file changed, 36 insertions(+), 35 deletions(-) > >diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java >index 4b70d50..4e527b0 100644 >--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java >+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java >@@ -55,44 +55,45 @@ public class XSSFHyperlink implements Hyperlink { > * @param hyperlinkRel the relationship in the underlying OPC package which stores the actual link's address > */ > protected XSSFHyperlink(CTHyperlink ctHyperlink, PackageRelationship hyperlinkRel) { >- _ctHyperlink = ctHyperlink; >- _externalRel = hyperlinkRel; >- >- // Figure out the Hyperlink type and distination >- >- // If it has a location, it's internal >- if (ctHyperlink.getLocation() != null) { >- _type = Hyperlink.LINK_DOCUMENT; >- _location = ctHyperlink.getLocation(); >- } else { >- // Otherwise it's somehow external, check >- // the relation to see how >- if (_externalRel == null) { >- if (ctHyperlink.getId() != null) { >- throw new IllegalStateException("The hyperlink for cell " + ctHyperlink.getRef() + >- " references relation " + ctHyperlink.getId() + ", but that didn't exist!"); >- } >- // hyperlink is internal and is not related to other parts >- _type = Hyperlink.LINK_DOCUMENT; >- } else { >- URI target = _externalRel.getTargetURI(); >- _location = target.toString(); >- >- // Try to figure out the type >+ _ctHyperlink = ctHyperlink; >+ _externalRel = hyperlinkRel; >+ >+ // Figure out the Hyperlink type and distination >+ >+ if (_externalRel == null) { >+ // If it has a location, it's internal >+ if (ctHyperlink.getLocation() != null) { >+ _type = Hyperlink.LINK_DOCUMENT; >+ _location = ctHyperlink.getLocation(); >+ } else if (ctHyperlink.getId() != null) { >+ throw new IllegalStateException("The hyperlink for cell " >+ + ctHyperlink.getRef() + " references relation " >+ + ctHyperlink.getId() + ", but that didn't exist!"); >+ } else { >+ // hyperlink is internal and is not related to other parts >+ _type = Hyperlink.LINK_DOCUMENT; >+ } >+ } else { >+ URI target = _externalRel.getTargetURI(); >+ _location = target.toString(); >+ if (ctHyperlink.getLocation() != null) { >+ // URI fragment >+ _location += "#" + ctHyperlink.getLocation(); >+ } >+ >+ // Try to figure out the type > if (_location.startsWith("http://") || _location.startsWith("https://") >- || _location.startsWith("ftp://")) { >- _type = Hyperlink.LINK_URL; >- } else if (_location.startsWith("mailto:")) { >- _type = Hyperlink.LINK_EMAIL; >- } else { >- _type = Hyperlink.LINK_FILE; >- } >- } >+ || _location.startsWith("ftp://")) { >+ _type = Hyperlink.LINK_URL; >+ } else if (_location.startsWith("mailto:")) { >+ _type = Hyperlink.LINK_EMAIL; >+ } else { >+ _type = Hyperlink.LINK_FILE; >+ } >+ } > >+ } > >- } >- } >- > /** > * Create a new XSSFHyperlink. This method is for Internal use only. > * XSSFHyperlinks can be created by XSSFCreationHelper. >-- >2.0.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 59775
:
33998
| 33999