ASF Bugzilla – Attachment 32636 Details for
Bug 57796
[PATCH] Support hyperlink extraction when rendering slides
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Adds a link attribute that can be attached to text fragments
poi-xslf-hyperlink.patch.txt (text/plain), 4.15 KB, created by
Vittal Aithal
on 2015-04-07 10:38:55 UTC
(
hide
)
Description:
Adds a link attribute that can be attached to text fragments
Filename:
MIME Type:
Creator:
Vittal Aithal
Created:
2015-04-07 10:38:55 UTC
Size:
4.15 KB
patch
obsolete
>diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/TextFragment.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/TextFragment.java >index 1114b89..83df8a3 100644 >--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/TextFragment.java >+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/TextFragment.java >@@ -25,6 +25,8 @@ import java.text.AttributedCharacterIterator; > import java.text.AttributedString; > import java.text.CharacterIterator; > >+import org.apache.poi.xslf.usermodel.XlinkAttribute; >+ > /** > * a renderable text fragment > */ >diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java >index e0b383a..7b804f5 100644 >--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java >+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java >@@ -57,6 +57,10 @@ import org.openxmlformats.schemas.drawingml.x2006.main.STTextAutonumberScheme; > import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder; > import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType; > >+import java.net.URI; >+import org.apache.poi.xslf.usermodel.XSLFHyperlink; >+import org.apache.poi.xslf.usermodel.XlinkAttribute; >+ > /** > * Represents a paragraph of text within the containing text body. > * The paragraph is the highest level text separation mechanism. >@@ -841,6 +845,16 @@ public class XSLFTextParagraph implements Iterable<XSLFTextRun>{ > > string.addAttribute(TextAttribute.FOREGROUND, run.getFontColor(), startIndex, endIndex); > >+ // check if there is a hyperlink associated with this text run and, if so, >+ // add it as an attribute to the string >+ XSLFHyperlink link = run.getHyperlink(); >+ if(link != null){ >+ URI uri = link.getTargetURI(); >+ if(uri != null){ >+ string.addAttribute(XlinkAttribute.HREF, uri.toString(), startIndex, endIndex); >+ } >+ } >+ > // user can pass an custom object to convert fonts > String fontFamily = run.getFontFamily(); > @SuppressWarnings("unchecked") >diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XlinkAttribute.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XlinkAttribute.java >new file mode 100644 >index 0000000..c26c265 >--- /dev/null >+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XlinkAttribute.java >@@ -0,0 +1,45 @@ >+/* ==================================================================== >+ 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. >+==================================================================== */ >+package org.apache.poi.xslf.usermodel; >+ >+import java.io.InvalidObjectException; >+import java.text.AttributedCharacterIterator; >+ >+/** >+ * Defines an attribute used for storing the hyperlink associated with >+ * some renderable text. >+ * >+ */ >+public final class XlinkAttribute extends AttributedCharacterIterator.Attribute >+{ >+ >+ /** A key for the href attribute */ >+ public static final XlinkAttribute HREF = new XlinkAttribute("href"); >+ >+ protected XlinkAttribute(String name) >+ { >+ super(name); >+ } >+ >+ protected Object readResolve() >+ throws InvalidObjectException >+ { >+ if (this.getName().equals("href")) >+ return HREF; >+ throw new InvalidObjectException("Can't resolve Attribute: " + getName()); >+ } >+}
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 Raw
Actions:
View
Attachments on
bug 57796
: 32636