@Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("[HYPERLINK RECORD]\n"); buffer.append(" .range = ").append(_range.formatAsString()).append("\n"); buffer.append(" .guid = ").append(_guid.formatAsString()).append("\n"); buffer.append(" .linkOpts= ").append(HexDump.intToHex(_linkOpts)).append("\n"); buffer.append(" .label = ").append(getLabel()).append("\n"); if ((_linkOpts & HLINK_TARGET_FRAME) != 0) { buffer.append(" .targetFrame= ").append(getTargetFrame()).append("\n"); } if((_linkOpts & HLINK_URL) != 0 && _moniker != null) { buffer.append(" .moniker = ").append(_moniker.formatAsString()).append("\n"); } if ((_linkOpts & HLINK_PLACE) != 0) { buffer.append(" .textMark= ").append(getTextMark()).append("\n"); } buffer.append(" .address = ").append(getAddress()).append("\n"); buffer.append("[/HYPERLINK RECORD]\n"); return buffer.toString(); }
/** * Get a Hyperlink in this sheet anchored at row, column * * @param row The index of the row of the hyperlink, zero-based * @param column the index of the column of the hyperlink, zero-based * @return hyperlink if there is a hyperlink anchored at row, column; otherwise returns null */ @Override public HSSFHyperlink getHyperlink(int row, int column) { for (RecordBase rec : _sheet.getRecords()) { if (rec instanceof HyperlinkRecord) { HyperlinkRecord link = (HyperlinkRecord) rec; if (link.getFirstColumn() == column && link.getFirstRow() == row) { return new HSSFHyperlink(link); } } } return null; }
/** * Construct a new hyperlink * * This method is internal to be used only by * {@link HSSFCreationHelper#createHyperlink(HyperlinkType)}. * * @param type the type of hyperlink to create */ @Internal(since="3.15 beta 3") protected HSSFHyperlink( HyperlinkType type ) { this.link_type = type; record = new HyperlinkRecord(); switch(type){ case URL: case EMAIL: record.newUrlLink(); break; case FILE: record.newFileLink(); break; case DOCUMENT: record.newDocumentLink(); break; default: throw new IllegalArgumentException("Invalid type: " + type); } }
private static HyperlinkType getType(HyperlinkRecord record) { HyperlinkType link_type; // Figure out the type if (record.isFileLink()) { link_type = HyperlinkType.FILE; } else if(record.isDocumentLink()) { link_type = HyperlinkType.DOCUMENT; } else { if(record.getAddress() != null && record.getAddress().startsWith("mailto:")) { link_type = HyperlinkType.EMAIL; } else { link_type = HyperlinkType.URL; } } return link_type; }
HyperlinkRecord link = (HyperlinkRecord) record; Point point = new Point(link.getFirstColumn(), link.getFirstRow()); Cell cell = currentSheet.get(point); if (cell != null) { String address = link.getAddress(); if (address != null) { addCell(record, new LinkedCell(cell, address));
/** * Return text label for this hyperlink * * @return text to display */ public String getLabel() { return cleanString(_label); }
/** * Sets text label for this hyperlink * * @param label text label for this hyperlink */ public void setLabel(String label) { _label = appendNullTerm(label); } public String getTargetFrame() {
/** * Return the row of the first cell that contains the hyperlink * * @return the 0-based row of the cell that contains the hyperlink */ @Override public int getFirstRow(){ return record.getFirstRow(); }
/** * Hyperlink address. Depending on the hyperlink type it can be URL, e-mail, path to a file, etc. * * @return the address of this hyperlink */ @Override public String getAddress(){ return record.getAddress(); } public String getTextMark(){
/** * Return the column of the first cell that contains the hyperlink * * @return the 0-based column of the first cell that contains the hyperlink */ @Override public int getFirstColumn(){ return record.getFirstColumn(); }
@Override public HyperlinkRecord clone() { HyperlinkRecord rec = new HyperlinkRecord(); rec._range = _range.copy(); rec._guid = _guid; rec._linkOpts = _linkOpts; rec._fileOpts = _fileOpts; rec._label = _label; rec._address = _address; rec._moniker = _moniker; rec._shortFilename = _shortFilename; rec._targetFrame = _targetFrame; rec._textMark = _textMark; rec._uninterpretedTail = _uninterpretedTail; return rec; } }
protected HSSFHyperlink(Hyperlink other) { if (other instanceof HSSFHyperlink) { HSSFHyperlink hlink = (HSSFHyperlink) other; record = hlink.record.clone(); link_type = getType(record); } else { link_type = other.getType(); record = new HyperlinkRecord(); setFirstRow(other.getFirstRow()); setFirstColumn(other.getFirstColumn()); setLastRow(other.getLastRow()); setLastColumn(other.getLastColumn()); } }
/** * Return text label for this hyperlink * * @return text to display */ @Override public String getLabel(){ return record.getLabel(); }
/** * Return the row of the last cell that contains the hyperlink * * @return the 0-based row of the last cell that contains the hyperlink */ @Override public int getLastRow(){ return record.getLastRow(); }
/** * Return the column of the last cell that contains the hyperlink * * @return the 0-based column of the last cell that contains the hyperlink */ @Override public int getLastColumn(){ return record.getLastColumn(); }
public String getShortFilename(){ return record.getShortFilename(); } /**
HyperlinkRecord link = (HyperlinkRecord) record; Point point = new Point(link.getFirstColumn(), link.getFirstRow()); Cell cell = currentSheet.get(point); if (cell != null) { String address = link.getAddress(); if (address != null) { addCell(record, new LinkedCell(cell, address));
private static HyperlinkType getType(HyperlinkRecord record) { HyperlinkType link_type; // Figure out the type if (record.isFileLink()) { link_type = HyperlinkType.FILE; } else if(record.isDocumentLink()) { link_type = HyperlinkType.DOCUMENT; } else { if(record.getAddress() != null && record.getAddress().startsWith("mailto:")) { link_type = HyperlinkType.EMAIL; } else { link_type = HyperlinkType.URL; } } return link_type; }
public String getTextMark() { return cleanString(_textMark); } public void setTextMark(String textMark) {
public void setShortFilename(String shortFilename) { _shortFilename = appendNullTerm(shortFilename); }