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

(-)src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java (+13 lines)
Lines 38-43 Link Here
38
import org.apache.poi.xssf.usermodel.XSSFCell;
38
import org.apache.poi.xssf.usermodel.XSSFCell;
39
import org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook;
39
import org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook;
40
import org.apache.poi.xssf.usermodel.XSSFName;
40
import org.apache.poi.xssf.usermodel.XSSFName;
41
import org.apache.poi.xssf.usermodel.XSSFHyperlink;
41
import org.apache.poi.xssf.usermodel.XSSFRow;
42
import org.apache.poi.xssf.usermodel.XSSFRow;
42
import org.apache.poi.xssf.usermodel.XSSFSheet;
43
import org.apache.poi.xssf.usermodel.XSSFSheet;
43
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
44
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
Lines 299-302 Link Here
299
        throw new IllegalStateException("Unexpected shifted ptg class (" + ptg0.getClass().getName() + ")");
300
        throw new IllegalStateException("Unexpected shifted ptg class (" + ptg0.getClass().getName() + ")");
300
    }
301
    }
301
302
303
    public void updateHyperlinks(FormulaShifter shifter) {
304
        int sheetIndex = sheet.getWorkbook().getSheetIndex(sheet);
305
        List<XSSFHyperlink> hyperlinkList = sheet.getHyperlinkList();
306
307
        for(XSSFHyperlink hyperlink : hyperlinkList) {
308
            String cellRef = hyperlink.getCellRef();
309
            CellRangeAddress cra = CellRangeAddress.valueOf(cellRef);
310
            CellRangeAddress shiftedRange = shiftRange(shifter, cra, sheetIndex);
311
            hyperlink.getCTHyperlink().setRef(shiftedRange.formatAsString());
312
        }
313
    }
314
302
}
315
}
(-)src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (-2 / +32 lines)
Lines 117-122 Link Here
117
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPaneState;
117
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPaneState;
118
import org.openxmlformats.schemas.spreadsheetml.x2006.main.WorksheetDocument;
118
import org.openxmlformats.schemas.spreadsheetml.x2006.main.WorksheetDocument;
119
119
120
import javax.xml.namespace.QName;
121
import java.io.IOException;
122
import java.io.InputStream;
123
import java.io.OutputStream;
124
import java.util.*;
125
126
import static org.apache.poi.xssf.usermodel.helpers.XSSFPaswordHelper.setPassword;
127
import static org.apache.poi.xssf.usermodel.helpers.XSSFPaswordHelper.validatePassword;
128
120
/**
129
/**
121
 * High level representation of a SpreadsheetML worksheet.
130
 * High level representation of a SpreadsheetML worksheet.
122
 *
131
 *
Lines 658-666 Link Here
658
667
659
    public XSSFHyperlink getHyperlink(int row, int column) {
668
    public XSSFHyperlink getHyperlink(int row, int column) {
660
        String ref = new CellReference(row, column).formatAsString();
669
        String ref = new CellReference(row, column).formatAsString();
661
        for(XSSFHyperlink hyperlink : hyperlinks) {
670
        // BUG POI: 55904
662
            if(hyperlink.getCellRef().equals(ref)) {
671
        //        for(org.apache.poi.xssf.usermodel.XSSFHyperlink hyperlink : hyperlinks) {
672
        //            if(hyperlink.getCellRef().equals(ref)) {
673
        //                return hyperlink;
674
        //            }
675
        //        }
676
        for(org.apache.poi.xssf.usermodel.XSSFHyperlink hyperlink : hyperlinks) {
677
            String cellRef = hyperlink.getCellRef();
678
            if(cellRef.equals(ref)) {
663
                return hyperlink;
679
                return hyperlink;
680
            } else {
681
                // No suitable single-cell hyperlinks found, so multi-cell hyperlinks are scanned
682
                CellRangeAddress reference = CellRangeAddress.valueOf(hyperlink.getCellRef());
683
                if (row >= reference.getFirstRow()
684
                        && column >= reference.getFirstColumn()
685
                        && row <= reference.getLastRow()
686
                        && column <= reference.getLastColumn()) {
687
                    return hyperlink;
688
                }
664
            }
689
            }
665
        }
690
        }
666
        return null;
691
        return null;
Lines 2670-2675 Link Here
2670
        rowShifter.updateFormulas(shifter);
2695
        rowShifter.updateFormulas(shifter);
2671
        rowShifter.shiftMerged(startRow, endRow, n);
2696
        rowShifter.shiftMerged(startRow, endRow, n);
2672
        rowShifter.updateConditionalFormatting(shifter);
2697
        rowShifter.updateConditionalFormatting(shifter);
2698
        rowShifter.updateHyperlinks(shifter);
2673
2699
2674
        //rebuild the _rows map
2700
        //rebuild the _rows map
2675
        SortedMap<Integer, XSSFRow> map = new TreeMap<Integer, XSSFRow>();
2701
        SortedMap<Integer, XSSFRow> map = new TreeMap<Integer, XSSFRow>();
Lines 2679-2684 Link Here
2679
        _rows = map;
2705
        _rows = map;
2680
    }
2706
    }
2681
2707
2708
    public List<XSSFHyperlink> getHyperlinkList() {
2709
        return Collections.unmodifiableList(hyperlinks);
2710
    }
2711
2682
    private int shiftedRowNum(int startRow, int endRow, int n, int rownum) {
2712
    private int shiftedRowNum(int startRow, int endRow, int n, int rownum) {
2683
		// no change if before any affected row
2713
		// no change if before any affected row
2684
    	if(rownum < startRow && (n > 0 || (startRow - rownum) > n)) {
2714
    	if(rownum < startRow && (n > 0 || (startRow - rownum) > n)) {

Return to bug 55904