ASF Bugzilla – Attachment 33669 Details for
Bug 55904
[PATCH] Cell getHyperlink returns null when the link is drag copied in excel
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Cumulative patch for Hyperlinks issues
hyperlinks-cumulative_patch.patch (text/plain), 4.27 KB, created by
Luca Martini
on 2016-03-14 10:46:51 UTC
(
hide
)
Description:
Cumulative patch for Hyperlinks issues
Filename:
MIME Type:
Creator:
Luca Martini
Created:
2016-03-14 10:46:51 UTC
Size:
4.27 KB
patch
obsolete
>Index: src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java (revision 229158) >+++ src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java (revision 229161) >@@ -38,6 +38,7 @@ > import org.apache.poi.xssf.usermodel.XSSFCell; > import org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook; > import org.apache.poi.xssf.usermodel.XSSFName; >+import org.apache.poi.xssf.usermodel.XSSFHyperlink; > import org.apache.poi.xssf.usermodel.XSSFRow; > import org.apache.poi.xssf.usermodel.XSSFSheet; > import org.apache.poi.xssf.usermodel.XSSFWorkbook; >@@ -299,4 +300,16 @@ > throw new IllegalStateException("Unexpected shifted ptg class (" + ptg0.getClass().getName() + ")"); > } > >+ public void updateHyperlinks(FormulaShifter shifter) { >+ int sheetIndex = sheet.getWorkbook().getSheetIndex(sheet); >+ List<XSSFHyperlink> hyperlinkList = sheet.getHyperlinkList(); >+ >+ for(XSSFHyperlink hyperlink : hyperlinkList) { >+ String cellRef = hyperlink.getCellRef(); >+ CellRangeAddress cra = CellRangeAddress.valueOf(cellRef); >+ CellRangeAddress shiftedRange = shiftRange(shifter, cra, sheetIndex); >+ hyperlink.getCTHyperlink().setRef(shiftedRange.formatAsString()); >+ } >+ } >+ > } >Index: src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (revision 229158) >+++ src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (revision 229161) >@@ -117,6 +117,15 @@ > import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPaneState; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.WorksheetDocument; > >+import javax.xml.namespace.QName; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.OutputStream; >+import java.util.*; >+ >+import static org.apache.poi.xssf.usermodel.helpers.XSSFPaswordHelper.setPassword; >+import static org.apache.poi.xssf.usermodel.helpers.XSSFPaswordHelper.validatePassword; >+ > /** > * High level representation of a SpreadsheetML worksheet. > * >@@ -658,9 +667,25 @@ > > public XSSFHyperlink getHyperlink(int row, int column) { > String ref = new CellReference(row, column).formatAsString(); >- for(XSSFHyperlink hyperlink : hyperlinks) { >- if(hyperlink.getCellRef().equals(ref)) { >+ // BUG POI: 55904 >+ // for(org.apache.poi.xssf.usermodel.XSSFHyperlink hyperlink : hyperlinks) { >+ // if(hyperlink.getCellRef().equals(ref)) { >+ // return hyperlink; >+ // } >+ // } >+ for(org.apache.poi.xssf.usermodel.XSSFHyperlink hyperlink : hyperlinks) { >+ String cellRef = hyperlink.getCellRef(); >+ if(cellRef.equals(ref)) { > return hyperlink; >+ } else { >+ // No suitable single-cell hyperlinks found, so multi-cell hyperlinks are scanned >+ CellRangeAddress reference = CellRangeAddress.valueOf(hyperlink.getCellRef()); >+ if (row >= reference.getFirstRow() >+ && column >= reference.getFirstColumn() >+ && row <= reference.getLastRow() >+ && column <= reference.getLastColumn()) { >+ return hyperlink; >+ } > } > } > return null; >@@ -2670,6 +2695,7 @@ > rowShifter.updateFormulas(shifter); > rowShifter.shiftMerged(startRow, endRow, n); > rowShifter.updateConditionalFormatting(shifter); >+ rowShifter.updateHyperlinks(shifter); > > //rebuild the _rows map > SortedMap<Integer, XSSFRow> map = new TreeMap<Integer, XSSFRow>(); >@@ -2679,6 +2705,10 @@ > _rows = map; > } > >+ public List<XSSFHyperlink> getHyperlinkList() { >+ return Collections.unmodifiableList(hyperlinks); >+ } >+ > private int shiftedRowNum(int startRow, int endRow, int n, int rownum) { > // no change if before any affected row > if(rownum < startRow && (n > 0 || (startRow - rownum) > n)) {
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 55904
:
31623
|
33479
|
33669
|
34232
|
34233
|
34234