use of org.apache.poi.util.Internal in project poi by apache.
the class POIDocument method replaceDirectory.
/**
* Replaces the attached directory, e.g. if this document is written
* to a new POIFSFileSystem
*
* @param newDirectory the new directory
* @return the old/previous directory
*/
@Internal
protected DirectoryNode replaceDirectory(DirectoryNode newDirectory) {
DirectoryNode dn = directory;
directory = newDirectory;
return dn;
}
use of org.apache.poi.util.Internal in project poi by apache.
the class Paragraph method newParagraph.
@Internal
public static Paragraph newParagraph(Range parent, PAPX papx) {
HWPFDocumentCore doc = parent._doc;
ListTables listTables = doc.getListTables();
StyleSheet styleSheet = doc.getStyleSheet();
ParagraphProperties properties = new ParagraphProperties();
properties.setIstd(papx.getIstd());
properties = newParagraph_applyStyleProperties(styleSheet, papx, properties);
properties = ParagraphSprmUncompressor.uncompressPAP(properties, papx.getGrpprl(), 2);
if (properties.getIlfo() != 0 && listTables != null) {
LFO lfo = null;
try {
lfo = listTables.getLfo(properties.getIlfo());
} catch (NoSuchElementException exc) {
log.log(POILogger.WARN, "Paragraph refers to LFO #", properties.getIlfo(), " that does not exists");
}
if (lfo != null) {
final ListLevel listLevel = listTables.getLevel(lfo.getLsid(), properties.getIlvl());
if (listLevel != null && listLevel.getGrpprlPapx() != null) {
properties = ParagraphSprmUncompressor.uncompressPAP(properties, listLevel.getGrpprlPapx(), 0);
// reapply style and local PAPX properties
properties = newParagraph_applyStyleProperties(styleSheet, papx, properties);
properties = ParagraphSprmUncompressor.uncompressPAP(properties, papx.getGrpprl(), 2);
}
}
}
if (properties.getIlfo() > 0)
return new ListEntry(papx, properties, parent);
return new Paragraph(papx, properties, parent);
}
use of org.apache.poi.util.Internal in project poi by apache.
the class XSLFColor method setColor.
/**
* Sets the solid color
*
* @param color solid color
*/
@Internal
protected void setColor(Color color) {
if (!(_xmlObject instanceof CTSolidColorFillProperties)) {
LOGGER.log(POILogger.ERROR, "XSLFColor.setColor currently only supports CTSolidColorFillProperties");
return;
}
CTSolidColorFillProperties fill = (CTSolidColorFillProperties) _xmlObject;
if (fill.isSetSrgbClr()) {
fill.unsetSrgbClr();
}
if (fill.isSetScrgbClr()) {
fill.unsetScrgbClr();
}
if (fill.isSetHslClr()) {
fill.unsetHslClr();
}
if (fill.isSetPrstClr()) {
fill.unsetPrstClr();
}
if (fill.isSetSchemeClr()) {
fill.unsetSchemeClr();
}
if (fill.isSetSysClr()) {
fill.unsetSysClr();
}
float[] rgbaf = color.getRGBComponents(null);
boolean addAlpha = (rgbaf.length == 4 && rgbaf[3] < 1f);
CTPositiveFixedPercentage alphaPct;
// see office open xml part 4 - 5.1.2.2.30 and 5.1.2.2.32
if (isInt(rgbaf[0]) && isInt(rgbaf[1]) && isInt(rgbaf[2])) {
// sRGB has a gamma of 2.2
CTSRgbColor rgb = fill.addNewSrgbClr();
byte[] rgbBytes = { (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue() };
rgb.setVal(rgbBytes);
alphaPct = (addAlpha) ? rgb.addNewAlpha() : null;
} else {
CTScRgbColor rgb = fill.addNewScrgbClr();
rgb.setR(DrawPaint.srgb2lin(rgbaf[0]));
rgb.setG(DrawPaint.srgb2lin(rgbaf[1]));
rgb.setB(DrawPaint.srgb2lin(rgbaf[2]));
alphaPct = (addAlpha) ? rgb.addNewAlpha() : null;
}
// alpha (%)
if (alphaPct != null) {
alphaPct.setVal((int) (100000 * rgbaf[3]));
}
}
Aggregations