use of org.apache.poi.util.Internal in project poi by apache.
the class XSLFSlideShow method getSlideComments.
/**
* Returns all the comments for the given slide
*/
@Internal
public CTCommentList getSlideComments(CTSlideIdListEntry slide) throws IOException, XmlException {
PackageRelationshipCollection commentRels;
PackagePart slidePart = getSlidePart(slide);
try {
commentRels = slidePart.getRelationshipsByType(XSLFRelation.COMMENTS.getRelation());
} catch (InvalidFormatException e) {
throw new IllegalStateException(e);
}
if (commentRels.size() == 0) {
// No comments for this slide
return null;
}
if (commentRels.size() > 1) {
throw new IllegalStateException("Expecting 0 or 1 comments for a slide, but found " + commentRels.size());
}
try {
PackagePart cPart = slidePart.getRelatedPart(commentRels.getRelationship(0));
CmLstDocument commDoc = CmLstDocument.Factory.parse(cPart.getInputStream(), DEFAULT_XML_OPTIONS);
return commDoc.getCmLst();
} catch (InvalidFormatException e) {
throw new IllegalStateException(e);
}
}
use of org.apache.poi.util.Internal in project poi by apache.
the class HSLFSlideMaster method setSlideShow.
/**
* Assign SlideShow for this slide master.
*/
@Internal
@Override
protected void setSlideShow(HSLFSlideShow ss) {
super.setSlideShow(ss);
//after the slide show is assigned collect all available style records
assert (_txmaster == null);
_txmaster = new TxMasterStyleAtom[9];
TxMasterStyleAtom txdoc = getSlideShow().getDocumentRecord().getEnvironment().getTxMasterStyleAtom();
_txmaster[txdoc.getTextType()] = txdoc;
TxMasterStyleAtom[] txrec = ((MainMaster) getSheetContainer()).getTxMasterStyleAtoms();
for (int i = 0; i < txrec.length; i++) {
int txType = txrec[i].getTextType();
if (txType < _txmaster.length && _txmaster[txType] == null) {
_txmaster[txType] = txrec[i];
}
}
for (List<HSLFTextParagraph> paras : getTextParagraphs()) {
for (HSLFTextParagraph htp : paras) {
int txType = htp.getRunType();
if (txType >= _txmaster.length || _txmaster[txType] == null) {
throw new HSLFException("Master styles not initialized");
}
int level = htp.getIndentLevel();
List<TextPropCollection> charStyles = _txmaster[txType].getCharacterStyles();
List<TextPropCollection> paragraphStyles = _txmaster[txType].getParagraphStyles();
if (charStyles == null || paragraphStyles == null || charStyles.size() <= level || paragraphStyles.size() <= level) {
throw new HSLFException("Master styles not initialized");
}
htp.setMasterStyleReference(paragraphStyles.get(level));
for (HSLFTextRun htr : htp.getTextRuns()) {
htr.setMasterStyleReference(charStyles.get(level));
}
}
}
}
use of org.apache.poi.util.Internal in project poi by apache.
the class SheetUtil method getDefaultCharWidth.
/**
* Get default character width using the Workbook's default font
*
* @param wb the workbook to get the default character width from
* @return default character width in pixels
*/
@Internal
public static int getDefaultCharWidth(final Workbook wb) {
Font defaultFont = wb.getFontAt((short) 0);
AttributedString str = new AttributedString(String.valueOf(defaultChar));
copyAttributes(defaultFont, str, 0, 1);
TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext);
return (int) layout.getAdvance();
}
use of org.apache.poi.util.Internal in project poi by apache.
the class PAPX method getParagraphProperties.
@Deprecated
@Internal
public ParagraphProperties getParagraphProperties(StyleSheet ss) {
if (ss == null) {
// TODO Fix up for Word 6/95
return new ParagraphProperties();
}
short istd = getIstd();
ParagraphProperties baseStyle = ss.getParagraphStyle(istd);
ParagraphProperties props = ParagraphSprmUncompressor.uncompressPAP(baseStyle, getGrpprl(), 2);
return props;
}
use of org.apache.poi.util.Internal in project poi by apache.
the class XSSFRowShifter method updateRowFormulas.
/**
* Update the formulas in specified row using the formula shifting policy specified by shifter
*
* @param row the row to update the formulas on
* @param shifter the formula shifting policy
*/
@Internal
public void updateRowFormulas(Row row, FormulaShifter shifter) {
XSSFSheet sheet = (XSSFSheet) row.getSheet();
for (Cell c : row) {
XSSFCell cell = (XSSFCell) c;
CTCell ctCell = cell.getCTCell();
if (ctCell.isSetF()) {
CTCellFormula f = ctCell.getF();
String formula = f.getStringValue();
if (formula.length() > 0) {
String shiftedFormula = shiftFormula(row, formula, shifter);
if (shiftedFormula != null) {
f.setStringValue(shiftedFormula);
if (f.getT() == STCellFormulaType.SHARED) {
int si = (int) f.getSi();
CTCellFormula sf = sheet.getSharedFormula(si);
sf.setStringValue(shiftedFormula);
updateRefInCTCellFormula(row, shifter, sf);
}
}
}
//Range of cells which the formula applies to.
updateRefInCTCellFormula(row, shifter, f);
}
}
}
Aggregations