// additional title formatting from https://stackoverflow.com/questions/50418856
// and legend positioning from https://stackoverflow.com/questions/49615379
// this would probably be an answer for https://stackoverflow.com/questions/36447925 too
-public class BarAndLineChart {
+public final class BarAndLineChart {
+
private static final int NUM_OF_ROWS = 7;
private static final Random RNG = new Random();
+ private BarAndLineChart() {}
+
public static void main(String[] args) throws Exception {
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet = wb.createSheet("Sheet1");
public List<? extends ObjectShape<S,P>> getOLEShapes() {
final List<ObjectShape<S,P>> oleShapes = new ArrayList<>();
-
+
for (final Slide<S,P> slide : slideshow.getSlides()) {
addOLEShapes(oleShapes, slide);
}
-
+
return oleShapes;
}
-
+
@SuppressWarnings("unchecked")
private void addOLEShapes(final List<ObjectShape<S,P>> oleShapes, ShapeContainer<S,P> container) {
for (Shape<S,P> shape : container) {
switch (tr.getTextCap()) {
case ALL:
txt = txt.toUpperCase(LocaleUtil.getUserLocale());
+ break;
case SMALL:
txt = txt.toLowerCase(LocaleUtil.getUserLocale());
+ break;
}
return txt;
package org.apache.poi.sl.usermodel;
+import org.apache.poi.common.Duplicatable;
+
/**
* This is a replacement for {@link java.awt.Insets} which works on doubles
* instead of ints
*/
-public final class Insets2D implements Cloneable {
+public final class Insets2D implements Duplicatable {
/**
* The inset from the top.
* to yield a new location for the Right edge.
*/
public double right;
-
+
/**
- * Creates and initializes a new <code>Insets</code> object with the
- * specified top, left, bottom, and right insets.
+ * Creates and initializes a new <code>Insets</code> object with the
+ * specified top, left, bottom, and right insets.
* @param top the inset from the top.
* @param left the inset from the left.
* @param bottom the inset from the bottom.
}
/**
- * Checks whether two insets objects are equal. Two instances
+ * Checks whether two insets objects are equal. Two instances
* of <code>Insets</code> are equal if the four integer values
- * of the fields <code>top</code>, <code>left</code>,
+ * of the fields <code>top</code>, <code>left</code>,
* <code>bottom</code>, and <code>right</code> are all equal.
* @return <code>true</code> if the two insets are equal;
* otherwise <code>false</code>.
}
/**
- * Returns a string representation of this <code>Insets</code> object.
- * This method is intended to be used only for debugging purposes, and
- * the content and format of the returned string may vary between
- * implementations. The returned string may be empty but may not be
+ * Returns a string representation of this <code>Insets</code> object.
+ * This method is intended to be used only for debugging purposes, and
+ * the content and format of the returned string may vary between
+ * implementations. The returned string may be empty but may not be
* <code>null</code>.
- *
+ *
* @return a string representation of this <code>Insets</code> object.
*/
public String toString() {
* @return a copy of this <code>Insets2D</code> object.
*/
@Override
- public Insets2D clone() {
+ public Insets2D copy() {
return new Insets2D(top, left, bottom, right);
}
-
+
}
private static final long MAX_REP_WHOLE_PART = 0x38D7EA4C68000L;
-
+ @SuppressWarnings("java:S128")
public static NormalisedDecimal create(BigInteger frac, int binaryExponent) {
// estimate pow2&pow10 first, perform optional mulShift, then normalize
int pow10;
* Convert to an equivalent {@link ExpandedDouble} representation (binary frac and exponent).
* The resulting transformed object is easily converted to a 64 bit IEEE double:
* <ul>
- * <li>bits 2-53 of the {@link #getSignificand()} become the 52 bit 'fraction'.</li>
+ * <li>bits 2-53 of the {@link #composeFrac()} become the 52 bit 'fraction'.</li>
* <li>{@link #getBinaryExponent()} is biased by 1023 to give the 'exponent'.</li>
* </ul>
* The sign bit must be obtained from somewhere else.
* @return the significand as a fixed point number (with 24 fraction bits and 47-50 whole bits)
*/
BigInteger composeFrac() {
- long wp = _wholePart;
- int fp = _fractionalPart;
- return new BigInteger(new byte[] {
- (byte) (wp >> 56), // N.B. assuming sign bit is zero
- (byte) (wp >> 48),
- (byte) (wp >> 40),
- (byte) (wp >> 32),
- (byte) (wp >> 24),
- (byte) (wp >> 16),
- (byte) (wp >> 8),
- (byte) (wp >> 0),
- (byte) (fp >> 16),
- (byte) (fp >> 8),
- (byte) (fp >> 0),
- });
+ return BigInteger.valueOf(_wholePart).shiftLeft(24).or(BigInteger.valueOf(_fractionalPart & 0x00FFFFFF));
}
public String getSignificantDecimalDigits() {
* e.g. to register id attributes or set prefixes for registered namespaces
*/
public class SignatureMarshalDefaultListener implements SignatureMarshalListener {
+ private static final String OBJECT_TAG = "Object";
private final Set<String> IGNORE_NS = new HashSet<>(Arrays.asList(null, XML_NS, XML_DIGSIG_NS));
- private final String OBJECT_TAG = "Object";
@Override
public void handleElement(SignatureInfo signatureInfo, Document doc, EventTarget target, EventListener parentListener) {
package org.apache.poi.xddf.usermodel.text;
import java.util.Locale;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont;
+@SuppressWarnings("unused")
@Beta
public class XDDFRunProperties {
private CTTextCharacterProperties props;
}
public void setBaseline(Integer value) {
- if (value == null) {
- if (props.isSetBaseline()) {
- props.unsetBaseline();
- }
- } else {
- props.setBaseline(value);
- }
+ update(props::isSetBaseline, props::unsetBaseline, props::setBaseline, value);
}
public void setDirty(Boolean dirty) {
- if (dirty == null) {
- if (props.isSetDirty()) {
- props.unsetDirty();
- }
- } else {
- props.setDirty(dirty);
- }
+ update(props::isSetDirty, props::unsetDirty, props::setDirty, dirty);
}
public void setSpellError(Boolean error) {
- if (error == null) {
- if (props.isSetErr()) {
- props.unsetErr();
- }
- } else {
- props.setErr(error);
- }
+ update(props::isSetErr, props::unsetErr, props::setErr, error);
}
public void setNoProof(Boolean noproof) {
- if (noproof == null) {
- if (props.isSetNoProof()) {
- props.unsetNoProof();
- }
- } else {
- props.setNoProof(noproof);
- }
+ update(props::isSetNoProof, props::unsetNoProof, props::setNoProof, noproof);
}
public void setNormalizeHeights(Boolean normalize) {
- if (normalize == null) {
- if (props.isSetNormalizeH()) {
- props.unsetNormalizeH();
- }
- } else {
- props.setNormalizeH(normalize);
- }
+ update(props::isSetNormalizeH, props::unsetNormalizeH, props::setNormalizeH, normalize);
}
public void setKumimoji(Boolean kumimoji) {
- if (kumimoji == null) {
- if (props.isSetKumimoji()) {
- props.unsetKumimoji();
- }
- } else {
- props.setKumimoji(kumimoji);
- }
+ update(props::isSetKumimoji, props::unsetKumimoji, props::setKumimoji, kumimoji);
}
public void setBold(Boolean bold) {
- if (bold == null) {
- if (props.isSetB()) {
- props.unsetB();
- }
- } else {
- props.setB(bold);
- }
+ update(props::isSetB, props::unsetB, props::setB, bold);
}
public void setItalic(Boolean italic) {
- if (italic == null) {
- if (props.isSetI()) {
- props.unsetI();
- }
- } else {
- props.setI(italic);
- }
+ update(props::isSetI, props::unsetI, props::setI, italic);
}
public void setFontSize(Double size) {
- if (size == null) {
- if (props.isSetSz()) {
- props.unsetSz();
- }
- } else if (size < 1 || 400 < size) {
+ if (size != null && (size < 1 || 400 < size)) {
throw new IllegalArgumentException("Minimum inclusive = 1. Maximum inclusive = 400.");
- } else {
- props.setSz((int)(100 * size));
}
+
+ update(props::isSetSz, props::unsetSz, props::setSz, size == null ? null : (int)(100 * size));
}
public void setFillProperties(XDDFFillProperties properties) {
}
public void setCharacterKerning(Double kerning) {
- if (kerning == null) {
- if (props.isSetKern()) {
- props.unsetKern();
- }
- } else if (kerning < 0 || 4000 < kerning) {
+ if (kerning != null && (kerning < 0 || 4000 < kerning)) {
throw new IllegalArgumentException("Minimum inclusive = 0. Maximum inclusive = 4000.");
- } else {
- props.setKern((int) (100 * kerning));
}
+
+ update(props::isSetKern, props::unsetKern, props::setKern, kerning == null ? null : (int)(100 * kerning));
}
public void setCharacterSpacing(Double spacing) {
- if (spacing == null) {
- if (props.isSetSpc()) {
- props.unsetSpc();
- }
- } else if (spacing < -4000 || 4000 < spacing) {
+ if (spacing != null && (spacing < -4000 || 4000 < spacing)) {
throw new IllegalArgumentException("Minimum inclusive = -4000. Maximum inclusive = 4000.");
- } else {
- props.setSpc((int) (100 * spacing));
}
+
+ update(props::isSetSpc, props::unsetSpc, props::setSpc, spacing == null ? null : (int)(100 * spacing));
}
public void setFonts(XDDFFont[] fonts) {
CTTextFont xml = font.getXmlObject();
switch (font.getGroup()) {
case COMPLEX_SCRIPT:
- if (xml == null) {
- if (props.isSetCs()) {
- props.unsetCs();
- }
- } else {
- props.setCs(xml);
- }
+ update(props::isSetCs, props::unsetCs, props::setCs, xml);
+ break;
case EAST_ASIAN:
- if (xml == null) {
- if (props.isSetEa()) {
- props.unsetEa();
- }
- } else {
- props.setEa(xml);
- }
+ update(props::isSetEa, props::unsetEa, props::setEa, xml);
+ break;
case LATIN:
- if (xml == null) {
- if (props.isSetLatin()) {
- props.unsetLatin();
- }
- } else {
- props.setLatin(xml);
- }
+ update(props::isSetLatin, props::unsetLatin, props::setLatin, xml);
+ break;
case SYMBOL:
- if (xml == null) {
- if (props.isSetSym()) {
- props.unsetSym();
- }
- } else {
- props.setSym(xml);
- }
+ update(props::isSetSym, props::unsetSym, props::setSym, xml);
+ break;
}
}
}
public void setUnderline(UnderlineType underline) {
- if (underline == null) {
- if (props.isSetU()) {
- props.unsetU();
- }
- } else {
- props.setU(underline.underlying);
- }
+ update(props::isSetU, props::unsetU, props::setU, underline == null ? null : underline.underlying);
}
public void setStrikeThrough(StrikeType strike) {
- if (strike == null) {
- if (props.isSetStrike()) {
- props.unsetStrike();
- }
- } else {
- props.setStrike(strike.underlying);
- }
+ update(props::isSetStrike, props::unsetStrike, props::setStrike, strike == null ? null : strike.underlying);
}
public void setCapitals(CapsType caps) {
- if (caps == null) {
- if (props.isSetCap()) {
- props.unsetCap();
- }
- } else {
- props.setCap(caps.underlying);
- }
+ update(props::isSetCap, props::unsetCap, props::setCap, caps == null ? null : caps.underlying);
}
public void setHyperlink(XDDFHyperlink link) {
- if (link == null) {
- if (props.isSetHlinkClick()) {
- props.unsetHlinkClick();
- }
- } else {
- props.setHlinkClick(link.getXmlObject());
- }
+ update(props::isSetHlinkClick, props::unsetHlinkClick, props::setHlinkClick, link == null ? null : link.getXmlObject());
}
public void setMouseOver(XDDFHyperlink link) {
- if (link == null) {
- if (props.isSetHlinkMouseOver()) {
- props.unsetHlinkMouseOver();
- }
- } else {
- props.setHlinkMouseOver(link.getXmlObject());
- }
+ update(props::isSetHlinkMouseOver, props::unsetHlinkMouseOver, props::setHlinkMouseOver, link == null ? null : link.getXmlObject());
}
public void setLanguage(Locale lang) {
- if (lang == null) {
- if (props.isSetLang()) {
- props.unsetLang();
- }
- } else {
- props.setLang(lang.toLanguageTag());
- }
+ update(props::isSetLang, props::unsetLang, props::setLang, lang == null ? null : lang.toLanguageTag());
}
public void setAlternativeLanguage(Locale lang) {
- if (lang == null) {
- if (props.isSetAltLang()) {
- props.unsetAltLang();
- }
- } else {
- props.setAltLang(lang.toLanguageTag());
- }
+ update(props::isSetAltLang, props::unsetAltLang, props::setAltLang, lang == null ? null : lang.toLanguageTag());
}
public void setHighlight(XDDFColor color) {
- if (color == null) {
- if (props.isSetHighlight()) {
- props.unsetHighlight();
- }
- } else {
- props.setHighlight(color.getColorContainer());
- }
+ update(props::isSetHighlight, props::unsetHighlight, props::setHighlight, color == null ? null : color.getColorContainer());
}
public void setLineProperties(XDDFLineProperties properties) {
- if (properties == null) {
- if (props.isSetLn()) {
- props.unsetLn();
- }
- } else {
- props.setLn(properties.getXmlObject());
- }
+ update(props::isSetLn, props::unsetLn, props::setLn, properties == null ? null : properties.getXmlObject());
}
public void setBookmark(String bookmark) {
- if (bookmark == null) {
- if (props.isSetBmk()) {
- props.unsetBmk();
- }
- } else {
- props.setBmk(bookmark);
- }
+ update(props::isSetBmk, props::unsetBmk, props::setBmk, bookmark);
}
public XDDFExtensionList getExtensionList() {
}
public void setExtensionList(XDDFExtensionList list) {
- if (list == null) {
- if (props.isSetExtLst()) {
- props.unsetExtLst();
- }
- } else {
- props.setExtLst(list.getXmlObject());
- }
+ update(props::isSetExtLst, props::unsetExtLst, props::setExtLst, list == null ? null : list.getXmlObject());
}
public XDDFEffectContainer getEffectContainer() {
}
public void setEffectContainer(XDDFEffectContainer container) {
- if (container == null) {
- if (props.isSetEffectDag()) {
- props.unsetEffectDag();
- }
- } else {
- props.setEffectDag(container.getXmlObject());
- }
+ update(props::isSetEffectDag, props::unsetEffectDag, props::setEffectDag, container == null ? null : container.getXmlObject());
}
public XDDFEffectList getEffectList() {
}
public void setEffectList(XDDFEffectList list) {
- if (list == null) {
- if (props.isSetEffectLst()) {
- props.unsetEffectLst();
- }
- } else {
- props.setEffectLst(list.getXmlObject());
+ update(props::isSetEffectLst, props::unsetEffectLst, props::setEffectLst, list == null ? null : list.getXmlObject());
+ }
+
+ private static <T> void update(Supplier<Boolean> isSet, Runnable unset, Consumer<T> setter, T val) {
+ if (val != null) {
+ setter.accept(val);
+ } else if (isSet.get()) {
+ unset.run();
}
}
}
import org.apache.poi.ss.formula.FormulaParser;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.ptg.Ptg;
-import org.apache.poi.xssf.usermodel.BaseXSSFEvaluationWorkbook;
import org.apache.poi.util.Internal;
+import org.apache.poi.xssf.usermodel.BaseXSSFEvaluationWorkbook;
/**
* SXSSF wrapper around the SXSSF and XSSF workbooks
*/
@Internal
public final class SXSSFEvaluationWorkbook extends BaseXSSFEvaluationWorkbook {
- private final SXSSFWorkbook _uBook;
-
+ private final SXSSFWorkbook _sxssfBook;
+
public static SXSSFEvaluationWorkbook create(SXSSFWorkbook book) {
if (book == null) {
return null;
}
return new SXSSFEvaluationWorkbook(book);
}
-
+
private SXSSFEvaluationWorkbook(SXSSFWorkbook book) {
super(book.getXSSFWorkbook());
- _uBook = book;
+ _sxssfBook = book;
}
@Override
public int getSheetIndex(EvaluationSheet evalSheet) {
SXSSFSheet sheet = ((SXSSFEvaluationSheet)evalSheet).getSXSSFSheet();
- return _uBook.getSheetIndex(sheet);
+ return _sxssfBook.getSheetIndex(sheet);
}
@Override
public EvaluationSheet getSheet(int sheetIndex) {
- return new SXSSFEvaluationSheet(_uBook.getSheetAt(sheetIndex));
+ return new SXSSFEvaluationSheet(_sxssfBook.getSheetAt(sheetIndex));
}
@Override
public Ptg[] getFormulaTokens(EvaluationCell evalCell) {
SXSSFCell cell = ((SXSSFEvaluationCell)evalCell).getSXSSFCell();
- return FormulaParser.parse(cell.getCellFormula(), this, FormulaType.CELL, _uBook.getSheetIndex(cell.getSheet()));
+ return FormulaParser.parse(cell.getCellFormula(), this, FormulaType.CELL, _sxssfBook.getSheetIndex(cell.getSheet()));
}
}
AUTO(STTblWidth.AUTO), /* Width is determined by content. */
DXA(STTblWidth.DXA), /* Width is an integer number of 20ths of a point (twips) */
NIL(STTblWidth.NIL), /* No width value set */
- PCT(STTblWidth.PCT); /* Width is a percentage, e.g. "33.3%" or 50 times percentage value, rounded to an integer, */
+ PCT(STTblWidth.PCT); /* Width is a percentage, e.g. "33.3%" or 50 times percentage value, rounded to an integer, */
/* e.g. 2500 for 50% */
private Enum type = STTblWidth.NIL;
TableWidthType(STTblWidth.Enum type) {
this.type = type;
}
-
- protected STTblWidth.Enum getSTWidthType() {
- return this.type;
- }
-
+
/**
* Get the underlying STTblWidth enum value.
*
protected static void setWidthType(TableWidthType widthType, CTTblWidth ctWidth) {
TableWidthType currentType = getWidthType(ctWidth);
if (!currentType.equals(widthType)) {
- STTblWidth.Enum stWidthType = widthType.getSTWidthType();
+ STTblWidth.Enum stWidthType = widthType.getStWidthType();
ctWidth.setType(stWidthType);
switch (stWidthType.intValue()) {
case STTblWidth.INT_PCT:
private EmfPlusWrapMode wrapMode;
private Rectangle2D rect = new Rectangle2D.Double();
private Color startColor, endColor;
- private AffineTransform transform;
+ private AffineTransform blendTransform;
private float[] positions;
private Color[] blendColors;
private float[] positionsV;
size += 4*LittleEndianConsts.INT_SIZE;
if (TRANSFORM.isSet(dataFlags)) {
- size += readXForm(leis, (transform = new AffineTransform()));
+ size += readXForm(leis, (blendTransform = new AffineTransform()));
}
if (isPreset() && (isBlendH() || isBlendV())) {
HemfDrawProperties prop = ctx.getProperties();
prop.setBrushStyle(HwmfBrushStyle.BS_LINEAR_GRADIENT);
prop.setBrushRect(rect);
- prop.setBrushTransform(transform);
+ prop.setBrushTransform(blendTransform);
// Preset colors and BlendH/V are mutual exclusive
if (isPreset()) {
m.put("rect", () -> rect);
m.put("startColor", () -> startColor);
m.put("endColor", () -> endColor);
- m.put("transform", () -> transform);
+ m.put("blendTransform", () -> blendTransform);
m.put("positions", () -> positions);
m.put("blendColors", () -> blendColors);
m.put("positionsV", () -> positionsV);
private Color[] surroundingColor;
private EmfPlusPath boundaryPath;
private Point2D[] boundaryPoints;
- private AffineTransform transform;
+ private AffineTransform blendTransform;
private float[] positions;
private Color[] blendColors;
private float[] blendFactorsH;
// the path gradient brush. This field MUST be present if the BrushDataTransform flag is set in the
// BrushDataFlags field of the EmfPlusPathGradientBrushData object.
if (TRANSFORM.isSet(dataFlags)) {
- size += readXForm(leis, (transform = new AffineTransform()));
+ size += readXForm(leis, (blendTransform = new AffineTransform()));
}
// An optional blend pattern for the path gradient brush. If this field is present, it MUST contain either
m.put("surroundingColor", () -> surroundingColor);
m.put("boundaryPath", () -> boundaryPath);
m.put("boundaryPoints", () -> boundaryPoints);
- m.put("transform", () -> transform);
+ m.put("blendTransform", () -> blendTransform);
m.put("positions", () -> positions);
m.put("blendColors", () -> blendColors);
m.put("blendFactorsH", () -> blendFactorsH);
public static class EmfPlusTextureBrushData implements EmfPlusBrushData {
private int dataFlags;
private EmfPlusWrapMode wrapMode;
- private AffineTransform transform;
+ private AffineTransform brushTransform;
private EmfPlusImage image;
@Override
int size = 2*LittleEndianConsts.INT_SIZE;
if (TRANSFORM.isSet(dataFlags)) {
- size += readXForm(leis, (transform = new AffineTransform()));
+ size += readXForm(leis, (brushTransform = new AffineTransform()));
}
if (dataSize > size) {
image.applyObject(ctx, null);
prop.setBrushBitmap(prop.getEmfPlusImage());
prop.setBrushStyle(HwmfBrushStyle.BS_PATTERN);
- prop.setBrushTransform(transform);
+ prop.setBrushTransform(brushTransform);
}
@Override
return GenericRecordUtil.getGenericProperties(
"dataFlags", () -> dataFlags,
"wrapMode", () -> wrapMode,
- "transform", () -> transform,
+ "brushTransform", () -> brushTransform,
"image", () -> image
);
}
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000;
-
+
private static final BitField DEFAULT_TAB_SIZE = getInstance(0x0001);
private static final BitField C_LEVELS = getInstance(0x0002);
private static final BitField TAB_STOPS = getInstance(0x0004);
- private static final BitField[] LEFT_MARGIN = {
+ private static final BitField[] LEFT_MARGIN_LVL_MASK = {
getInstance(0x0008), getInstance(0x0010), getInstance(0x0020),
getInstance(0x0040), getInstance(0x0080),
};
- private static final BitField[] INDENT = {
+ private static final BitField[] INDENT_LVL_MASK = {
getInstance(0x0100), getInstance(0x0200), getInstance(0x0400),
getInstance(0x0800), getInstance(0x1000),
};
* @param start the start offset into the byte array.
* @param len the length of the slice in the byte array.
*/
- protected TextRulerAtom(final byte[] source, final int start, final int len) {
+ TextRulerAtom(final byte[] source, final int start, final int len) {
final LittleEndianByteArrayInputStream leis = new LittleEndianByteArrayInputStream(source, start, Math.min(len, MAX_RECORD_LENGTH));
-
+
try {
// Get the header.
mask |= writeIf(lbos, defaultTabSize, DEFAULT_TAB_SIZE);
mask |= writeIf(lbos, tabStops, TAB_STOPS);
for (int i=0; i<5; i++) {
- mask |= writeIf(lbos, leftMargin[i], LEFT_MARGIN[i]);
- mask |= writeIf(lbos, indent[i], INDENT[i]);
+ mask |= writeIf(lbos, leftMargin[i], LEFT_MARGIN_LVL_MASK[i]);
+ mask |= writeIf(lbos, indent[i], INDENT_LVL_MASK[i]);
}
LittleEndian.putInt(_header, 4, bos.size()+4);
out.write(_header);
}
return bit.setBoolean(0, isSet);
}
-
+
+ @SuppressWarnings("SameParameterValue")
private static int writeIf(final LittleEndianOutputStream lbos, List<HSLFTabStop> value, BitField bit) {
boolean isSet = false;
if (value != null && !value.isEmpty()) {
}
return bit.setBoolean(0, isSet);
}
-
+
/**
* Read the record bytes and initialize the internal variables
*/
tabStops.addAll(HSLFTabStopPropCollection.readTabStops(leis));
}
for (int i=0; i<5; i++) {
- leftMargin[i] = readIf(leis, mask, LEFT_MARGIN[i]);
- indent[i] = readIf(leis, mask, INDENT[i]);
+ leftMargin[i] = readIf(leis, mask, LEFT_MARGIN_LVL_MASK[i]);
+ indent[i] = readIf(leis, mask, INDENT_LVL_MASK[i]);
}
}
private static Integer readIf(final LittleEndianByteArrayInputStream leis, final int mask, final BitField bit) {
return (bit.isSet(mask)) ? (int)leis.readShort() : null;
- }
-
+ }
+
/**
* Default distance between tab stops, in master coordinates (576 dpi).
*/
* Applies the object table entry
*
* @param index the index of the object table entry (0-based)
- *
+ *
* @throws IndexOutOfBoundsException if the index is out of range
* @throws NoSuchElementException if the entry was deleted before
*/
}
ote.applyObject(this);
}
-
+
/**
* Unsets (deletes) the object table entry for further usage
- *
+ *
* When a META_DELETEOBJECT record (section 2.3.4.7) is received that specifies this
* object's particular index, the object's resources are released, the binding to its
* WMF Object Table index is ended, and the index value is returned to the pool of
* created by another Object Record Type record.
*
* @param index the index (0-based)
- *
+ *
* @throws IndexOutOfBoundsException if the index is out of range
*/
public void unsetObjectTableEntry(int index) {
objectTable.remove(index);
objectIndexes.clear(index);
}
-
+
/**
* Saves the current properties to the stack
*/
propStack.add(p);
prop = newProperties(p);
}
-
+
/**
* Restores the properties from the stack
*
if (font == null || text == null || text.length == 0) {
return;
}
-
+
double fontH = getFontHeight(font);
// TODO: another approx. ...
double fontW = fontH/1.8;
-
+
Charset charset;
if (isUnicode) {
charset = Charsets.UTF_16LE;
switch (valign) {
case TOP:
tx.translate(0, layout.getAscent());
+ break;
default:
case BASELINE:
break;
}
as.addAttribute(TextAttribute.WEIGHT, awtFW);
}
-
+
private double getFontHeight(HwmfFont font) {
// see HwmfFont#height for details
double fontHeight = font.getHeight();
} else if (fontHeight < 0) {
return -fontHeight;
} else {
- // TODO: fix font height calculation
+ // TODO: fix font height calculation
// the height is given as font size + ascent + descent
- // as an approximation we reduce the height by a static factor
+ // as an approximation we reduce the height by a static factor
return fontHeight*3/4;
}
}