sonar fixes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1706648 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2015-10-04 00:35:30 +00:00
parent 6d5e892986
commit 012cfb107c
13 changed files with 132 additions and 110 deletions

View File

@ -150,6 +150,7 @@ public class Section
* @exception UnsupportedEncodingException if the section's codepage is not * @exception UnsupportedEncodingException if the section's codepage is not
* supported. * supported.
*/ */
@SuppressWarnings("unchecked")
public Section(final byte[] src, final int offset) public Section(final byte[] src, final int offset)
throws UnsupportedEncodingException throws UnsupportedEncodingException
{ {
@ -332,19 +333,25 @@ public class Section
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj) {
return true; return true;
if (obj == null) }
if (obj == null) {
return false; return false;
if (getClass() != obj.getClass()) }
if (getClass() != obj.getClass()) {
return false; return false;
}
PropertyListEntry other = (PropertyListEntry) obj; PropertyListEntry other = (PropertyListEntry) obj;
if (id != other.id) if (id != other.id) {
return false; return false;
if (length != other.length) }
if (length != other.length) {
return false; return false;
if (offset != other.offset) }
if (offset != other.offset) {
return false; return false;
}
return true; return true;
} }

View File

@ -80,7 +80,11 @@ public abstract class BlockStore {
protected class ChainLoopDetector { protected class ChainLoopDetector {
private boolean[] used_blocks; private boolean[] used_blocks;
protected ChainLoopDetector(long rawSize) { protected ChainLoopDetector(long rawSize) {
int numBlocks = (int)Math.ceil( ((double)rawSize) / getBlockStoreBlockSize() ); int blkSize = getBlockStoreBlockSize();
int numBlocks = (int)(rawSize / blkSize);
if ((rawSize % blkSize) != 0) {
numBlocks++;
}
used_blocks = new boolean[numBlocks]; used_blocks = new boolean[numBlocks];
} }
protected void claim(int offset) { protected void claim(int offset) {

View File

@ -119,8 +119,13 @@ public final class NPropertyTable extends PropertyTableBase {
*/ */
public int countBlocks() public int countBlocks()
{ {
int size = _properties.size() * POIFSConstants.PROPERTY_SIZE; long rawSize = _properties.size() * POIFSConstants.PROPERTY_SIZE;
return (int)Math.ceil( ((double)size) / _bigBigBlockSize.getBigBlockSize()); int blkSize = _bigBigBlockSize.getBigBlockSize();
int numBlocks = (int)(rawSize / blkSize);
if ((rawSize % blkSize) != 0) {
numBlocks++;
}
return numBlocks;
} }
/** /**

View File

@ -265,9 +265,10 @@ public final class BATBlock extends BigBlock {
public static BATBlockAndIndex getBATBlockAndIndex(final int offset, public static BATBlockAndIndex getBATBlockAndIndex(final int offset,
final HeaderBlock header, final List<BATBlock> bats) { final HeaderBlock header, final List<BATBlock> bats) {
POIFSBigBlockSize bigBlockSize = header.getBigBlockSize(); POIFSBigBlockSize bigBlockSize = header.getBigBlockSize();
int entriesPerBlock = bigBlockSize.getBATEntriesPerBlock();
int whichBAT = (int)Math.floor(offset / bigBlockSize.getBATEntriesPerBlock()); int whichBAT = offset / entriesPerBlock;
int index = offset % bigBlockSize.getBATEntriesPerBlock(); int index = offset % entriesPerBlock;
return new BATBlockAndIndex( index, bats.get(whichBAT) ); return new BATBlockAndIndex( index, bats.get(whichBAT) );
} }
@ -279,10 +280,11 @@ public final class BATBlock extends BigBlock {
public static BATBlockAndIndex getSBATBlockAndIndex(final int offset, public static BATBlockAndIndex getSBATBlockAndIndex(final int offset,
final HeaderBlock header, final List<BATBlock> sbats) { final HeaderBlock header, final List<BATBlock> sbats) {
POIFSBigBlockSize bigBlockSize = header.getBigBlockSize(); POIFSBigBlockSize bigBlockSize = header.getBigBlockSize();
int entriesPerBlock = bigBlockSize.getBATEntriesPerBlock();
// SBATs are so much easier, as they're chained streams // SBATs are so much easier, as they're chained streams
int whichSBAT = (int)Math.floor(offset / bigBlockSize.getBATEntriesPerBlock()); int whichSBAT = offset / entriesPerBlock;
int index = offset % bigBlockSize.getBATEntriesPerBlock(); int index = offset % entriesPerBlock;
return new BATBlockAndIndex( index, sbats.get(whichSBAT) ); return new BATBlockAndIndex( index, sbats.get(whichSBAT) );
} }

View File

@ -115,7 +115,7 @@ public abstract class AggregateFunction extends MultiOperandNumericFunction {
double n = (N - 1) * dn + 1; double n = (N - 1) * dn + 1;
if (n == 1d) { if (n == 1d) {
result = StatsLib.kthSmallest(ds, 1); result = StatsLib.kthSmallest(ds, 1);
} else if (n == N) { } else if (Double.compare(n, N) == 0) {
result = StatsLib.kthLargest(ds, 1); result = StatsLib.kthLargest(ds, 1);
} else { } else {
int k = (int) n; int k = (int) n;

View File

@ -366,7 +366,7 @@ public abstract class NumericFunction implements Function {
double d1 = NumericFunction.singleOperandEvaluate(arg1, srcRowIndex, srcColumnIndex); double d1 = NumericFunction.singleOperandEvaluate(arg1, srcRowIndex, srcColumnIndex);
double logE = Math.log(d0); double logE = Math.log(d0);
double base = d1; double base = d1;
if (base == Math.E) { if (Double.compare(base, Math.E) == 0) {
result = logE; result = logE;
} else { } else {
result = logE / Math.log(base); result = logE / Math.log(base);

View File

@ -24,6 +24,8 @@ import java.util.regex.Pattern;
import org.apache.poi.ss.format.SimpleFraction; import org.apache.poi.ss.format.SimpleFraction;
import org.apache.poi.ss.formula.eval.NotImplementedException; import org.apache.poi.ss.formula.eval.NotImplementedException;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
/** /**
* <p>Format class that handles Excel style fractions, such as "# #/#" and "#/###"</p> * <p>Format class that handles Excel style fractions, such as "# #/#" and "#/###"</p>
@ -39,7 +41,8 @@ import org.apache.poi.ss.formula.eval.NotImplementedException;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class FractionFormat extends Format { public class FractionFormat extends Format {
private final static Pattern DENOM_FORMAT_PATTERN = Pattern.compile("(?:(#+)|(\\d+))"); private static final POILogger LOGGER = POILogFactory.getLogger(FractionFormat.class);
private static final Pattern DENOM_FORMAT_PATTERN = Pattern.compile("(?:(#+)|(\\d+))");
//this was chosen to match the earlier limitation of max denom power //this was chosen to match the earlier limitation of max denom power
//it can be expanded to get closer to Excel's calculations //it can be expanded to get closer to Excel's calculations
@ -47,7 +50,7 @@ public class FractionFormat extends Format {
//but as of this writing, the numerators and denominators //but as of this writing, the numerators and denominators
//with formats of that nature on very small values were quite //with formats of that nature on very small values were quite
//far from Excel's calculations //far from Excel's calculations
private final static int MAX_DENOM_POW = 4; private static final int MAX_DENOM_POW = 4;
//there are two options: //there are two options:
//a) an exact denominator is specified in the formatString //a) an exact denominator is specified in the formatString
@ -133,7 +136,7 @@ public class FractionFormat extends Format {
fract = SimpleFraction.buildFractionMaxDenominator(decPart, maxDenom); fract = SimpleFraction.buildFractionMaxDenominator(decPart, maxDenom);
} }
} catch (RuntimeException e){ } catch (RuntimeException e){
e.printStackTrace(); LOGGER.log(POILogger.WARN, "Can't format fraction", e);
return Double.toString(doubleValue); return Double.toString(doubleValue);
} }

View File

@ -237,7 +237,7 @@ public class ImageUtils {
if (isHSSF) { if (isHSSF) {
w *= 1 - anchor.getDx1()/1024d; w *= 1 - anchor.getDx1()/1024d;
} else { } else {
w -= anchor.getDx1()/EMU_PER_PIXEL; w -= anchor.getDx1()/(double)EMU_PER_PIXEL;
} }
while(col2 < anchor.getCol2()){ while(col2 < anchor.getCol2()){
@ -247,7 +247,7 @@ public class ImageUtils {
if (isHSSF) { if (isHSSF) {
w += sheet.getColumnWidthInPixels(col2) * anchor.getDx2()/1024d; w += sheet.getColumnWidthInPixels(col2) * anchor.getDx2()/1024d;
} else { } else {
w += anchor.getDx2()/EMU_PER_PIXEL; w += anchor.getDx2()/(double)EMU_PER_PIXEL;
} }
double h = 0; double h = 0;
@ -257,7 +257,7 @@ public class ImageUtils {
if (isHSSF) { if (isHSSF) {
h *= 1 - anchor.getDy1()/256d; h *= 1 - anchor.getDy1()/256d;
} else { } else {
h -= anchor.getDy1()/EMU_PER_PIXEL; h -= anchor.getDy1()/(double)EMU_PER_PIXEL;
} }
while(row2 < anchor.getRow2()){ while(row2 < anchor.getRow2()){
@ -267,10 +267,13 @@ public class ImageUtils {
if (isHSSF) { if (isHSSF) {
h += getRowHeightInPixels(sheet,row2) * anchor.getDy2()/256; h += getRowHeightInPixels(sheet,row2) * anchor.getDy2()/256;
} else { } else {
h += anchor.getDy2()/EMU_PER_PIXEL; h += anchor.getDy2()/(double)EMU_PER_PIXEL;
} }
return new Dimension((int)w*EMU_PER_PIXEL, (int)h*EMU_PER_PIXEL); w *= EMU_PER_PIXEL;
h *= EMU_PER_PIXEL;
return new Dimension((int)Math.rint(w), (int)Math.rint(h));
} }

View File

@ -343,21 +343,21 @@ public class HexDump {
* @return string of 8 (zero padded) uppercase hex chars and prefixed with '0x' * @return string of 8 (zero padded) uppercase hex chars and prefixed with '0x'
*/ */
public static String intToHex(int value) { public static String intToHex(int value) {
return xpad(value & 0xFFFFFFFF, 8, "0x"); return xpad(value & 0xFFFFFFFFL, 8, "0x");
} }
/** /**
* @return string of 4 (zero padded) uppercase hex chars and prefixed with '0x' * @return string of 4 (zero padded) uppercase hex chars and prefixed with '0x'
*/ */
public static String shortToHex(int value) { public static String shortToHex(int value) {
return xpad(value & 0xFFFF, 4, "0x"); return xpad(value & 0xFFFFL, 4, "0x");
} }
/** /**
* @return string of 2 (zero padded) uppercase hex chars and prefixed with '0x' * @return string of 2 (zero padded) uppercase hex chars and prefixed with '0x'
*/ */
public static String byteToHex(int value) { public static String byteToHex(int value) {
return xpad(value & 0xFF, 2, "0x"); return xpad(value & 0xFFL, 2, "0x");
} }
private static String xpad(long value, int pad, String prefix) { private static String xpad(long value, int pad, String prefix) {

View File

@ -559,20 +559,18 @@ public final class PackagePropertiesPart extends PackagePart implements
* @throws InvalidFormatException * @throws InvalidFormatException
* Throws if the date format isnot valid. * Throws if the date format isnot valid.
*/ */
private Nullable<Date> setDateValue(String s) throws InvalidFormatException { private Nullable<Date> setDateValue(String dateStr) throws InvalidFormatException {
if (s == null || s.equals("")) { if (dateStr == null || dateStr.equals("")) {
return new Nullable<Date>(); return new Nullable<Date>();
} }
if (!s.endsWith("Z")) { String dateTzStr = dateStr.endsWith("Z") ? dateStr : (dateStr + "Z");
s += "Z";
}
SimpleDateFormat df = new SimpleDateFormat(DEFAULT_DATEFORMAT, Locale.ROOT); SimpleDateFormat df = new SimpleDateFormat(DEFAULT_DATEFORMAT, Locale.ROOT);
df.setTimeZone(LocaleUtil.TIMEZONE_UTC); df.setTimeZone(LocaleUtil.TIMEZONE_UTC);
Date d = df.parse(s, new ParsePosition(0)); Date d = df.parse(dateTzStr, new ParsePosition(0));
if (d == null) { if (d == null) {
df = new SimpleDateFormat(ALTERNATIVE_DATEFORMAT, Locale.ROOT); df = new SimpleDateFormat(ALTERNATIVE_DATEFORMAT, Locale.ROOT);
df.setTimeZone(LocaleUtil.TIMEZONE_UTC); df.setTimeZone(LocaleUtil.TIMEZONE_UTC);
d = df.parse(s, new ParsePosition(0)); d = df.parse(dateTzStr, new ParsePosition(0));
} }
if (d == null) { if (d == null) {
throw new InvalidFormatException("Date not well formated"); throw new InvalidFormatException("Date not well formated");

View File

@ -6,7 +6,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
@ -46,90 +46,90 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument;
/** /**
* Experimental class to do low level processing of pptx files. * Experimental class to do low level processing of pptx files.
* *
* Most users should use the higher level {@link XMLSlideShow} instead. * Most users should use the higher level {@link XMLSlideShow} instead.
* *
* If you are using these low level classes, then you * If you are using these low level classes, then you
* will almost certainly need to refer to the OOXML * will almost certainly need to refer to the OOXML
* specifications from * specifications from
* http://www.ecma-international.org/publications/standards/Ecma-376.htm * http://www.ecma-international.org/publications/standards/Ecma-376.htm
* *
* WARNING - APIs expected to change rapidly * WARNING - APIs expected to change rapidly
*/ */
public class XSLFSlideShow extends POIXMLDocument { public class XSLFSlideShow extends POIXMLDocument {
private PresentationDocument presentationDoc; private PresentationDocument presentationDoc;
/** /**
* The embedded OLE2 files in the OPC package * The embedded OLE2 files in the OPC package
*/ */
private List<PackagePart> embedds; private List<PackagePart> embedds;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public XSLFSlideShow(OPCPackage container) throws OpenXML4JException, IOException, XmlException { public XSLFSlideShow(OPCPackage container) throws OpenXML4JException, IOException, XmlException {
super(container); super(container);
if(getCorePart().getContentType().equals(XSLFRelation.THEME_MANAGER.getContentType())) { if(getCorePart().getContentType().equals(XSLFRelation.THEME_MANAGER.getContentType())) {
rebase(getPackage()); rebase(getPackage());
} }
presentationDoc = presentationDoc =
PresentationDocument.Factory.parse(getCorePart().getInputStream()); PresentationDocument.Factory.parse(getCorePart().getInputStream());
embedds = new LinkedList<PackagePart>();
for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdArray()) {
PackagePart corePart = getCorePart();
PackagePart slidePart = corePart.getRelatedPart(
corePart.getRelationship(ctSlide.getId2()));
for(PackageRelationship rel : slidePart.getRelationshipsByType(OLE_OBJECT_REL_TYPE)) embedds = new LinkedList<PackagePart>();
embedds.add(slidePart.getRelatedPart(rel)); // TODO: Add this reference to each slide as well for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdArray()) {
PackagePart corePart = getCorePart();
PackagePart slidePart = corePart.getRelatedPart(corePart.getRelationship(ctSlide.getId2()));
for(PackageRelationship rel : slidePart.getRelationshipsByType(PACK_OBJECT_REL_TYPE)) for(PackageRelationship rel : slidePart.getRelationshipsByType(OLE_OBJECT_REL_TYPE)) {
embedds.add(slidePart.getRelatedPart(rel)); // TODO: Add this reference to each slide as well
embedds.add(slidePart.getRelatedPart(rel));
}
for (PackageRelationship rel : slidePart.getRelationshipsByType(PACK_OBJECT_REL_TYPE)) {
embedds.add(slidePart.getRelatedPart(rel));
}
} }
} }
public XSLFSlideShow(String file) throws OpenXML4JException, IOException, XmlException { public XSLFSlideShow(String file) throws OpenXML4JException, IOException, XmlException {
this(openPackage(file)); this(openPackage(file));
} }
/** /**
* Returns the low level presentation base object * Returns the low level presentation base object
*/ */
@Internal @Internal
public CTPresentation getPresentation() { public CTPresentation getPresentation() {
return presentationDoc.getPresentation(); return presentationDoc.getPresentation();
} }
/** /**
* Returns the references from the presentation to its * Returns the references from the presentation to its
* slides. * slides.
* You'll need these to figure out the slide ordering, * You'll need these to figure out the slide ordering,
* and to get at the actual slides themselves * and to get at the actual slides themselves
*/ */
@Internal @Internal
public CTSlideIdList getSlideReferences() { public CTSlideIdList getSlideReferences() {
if(! getPresentation().isSetSldIdLst()) { if(! getPresentation().isSetSldIdLst()) {
getPresentation().setSldIdLst( getPresentation().setSldIdLst(CTSlideIdList.Factory.newInstance());
CTSlideIdList.Factory.newInstance() }
); return getPresentation().getSldIdLst();
}
return getPresentation().getSldIdLst();
} }
/** /**
* Returns the references from the presentation to its * Returns the references from the presentation to its
* slide masters. * slide masters.
* You'll need these to get at the actual slide * You'll need these to get at the actual slide
* masters themselves * masters themselves
*/ */
@Internal @Internal
public CTSlideMasterIdList getSlideMasterReferences() { public CTSlideMasterIdList getSlideMasterReferences() {
return getPresentation().getSldMasterIdLst(); return getPresentation().getSldMasterIdLst();
} }
public PackagePart getSlideMasterPart(CTSlideMasterIdListEntry master) throws IOException, XmlException { public PackagePart getSlideMasterPart(CTSlideMasterIdListEntry master) throws IOException, XmlException {
try { try {
PackagePart corePart = getCorePart(); PackagePart corePart = getCorePart();
return corePart.getRelatedPart( return corePart.getRelatedPart(
corePart.getRelationship(master.getId2()) corePart.getRelationship(master.getId2())
); );
@ -141,7 +141,7 @@ public class XSLFSlideShow extends POIXMLDocument {
* Returns the low level slide master object from * Returns the low level slide master object from
* the supplied slide master reference * the supplied slide master reference
*/ */
@Internal @Internal
public CTSlideMaster getSlideMaster(CTSlideMasterIdListEntry master) throws IOException, XmlException { public CTSlideMaster getSlideMaster(CTSlideMasterIdListEntry master) throws IOException, XmlException {
PackagePart masterPart = getSlideMasterPart(master); PackagePart masterPart = getSlideMasterPart(master);
SldMasterDocument masterDoc = SldMasterDocument masterDoc =
@ -151,10 +151,8 @@ public class XSLFSlideShow extends POIXMLDocument {
public PackagePart getSlidePart(CTSlideIdListEntry slide) throws IOException, XmlException { public PackagePart getSlidePart(CTSlideIdListEntry slide) throws IOException, XmlException {
try { try {
PackagePart corePart = getCorePart(); PackagePart corePart = getCorePart();
return corePart.getRelatedPart( return corePart.getRelatedPart(corePart.getRelationship(slide.getId2()));
corePart.getRelationship(slide.getId2())
);
} catch(InvalidFormatException e) { } catch(InvalidFormatException e) {
throw new XmlException(e); throw new XmlException(e);
} }
@ -163,7 +161,7 @@ public class XSLFSlideShow extends POIXMLDocument {
* Returns the low level slide object from * Returns the low level slide object from
* the supplied slide reference * the supplied slide reference
*/ */
@Internal @Internal
public CTSlide getSlide(CTSlideIdListEntry slide) throws IOException, XmlException { public CTSlide getSlide(CTSlideIdListEntry slide) throws IOException, XmlException {
PackagePart slidePart = getSlidePart(slide); PackagePart slidePart = getSlidePart(slide);
SldDocument slideDoc = SldDocument slideDoc =
@ -178,13 +176,13 @@ public class XSLFSlideShow extends POIXMLDocument {
public PackagePart getNodesPart(CTSlideIdListEntry parentSlide) throws IOException, XmlException { public PackagePart getNodesPart(CTSlideIdListEntry parentSlide) throws IOException, XmlException {
PackageRelationshipCollection notes; PackageRelationshipCollection notes;
PackagePart slidePart = getSlidePart(parentSlide); PackagePart slidePart = getSlidePart(parentSlide);
try { try {
notes = slidePart.getRelationshipsByType(XSLFRelation.NOTES.getRelation()); notes = slidePart.getRelationshipsByType(XSLFRelation.NOTES.getRelation());
} catch(InvalidFormatException e) { } catch(InvalidFormatException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
if(notes.size() == 0) { if(notes.size() == 0) {
// No notes for this slide // No notes for this slide
return null; return null;
@ -192,9 +190,9 @@ public class XSLFSlideShow extends POIXMLDocument {
if(notes.size() > 1) { if(notes.size() > 1) {
throw new IllegalStateException("Expecting 0 or 1 notes for a slide, but found " + notes.size()); throw new IllegalStateException("Expecting 0 or 1 notes for a slide, but found " + notes.size());
} }
try { try {
return slidePart.getRelatedPart(notes.getRelationship(0)); return slidePart.getRelatedPart(notes.getRelationship(0));
} catch(InvalidFormatException e) { } catch(InvalidFormatException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
@ -203,32 +201,32 @@ public class XSLFSlideShow extends POIXMLDocument {
* Returns the low level notes object for the given * Returns the low level notes object for the given
* slide, as found from the supplied slide reference * slide, as found from the supplied slide reference
*/ */
@Internal @Internal
public CTNotesSlide getNotes(CTSlideIdListEntry slide) throws IOException, XmlException { public CTNotesSlide getNotes(CTSlideIdListEntry slide) throws IOException, XmlException {
PackagePart notesPart = getNodesPart(slide); PackagePart notesPart = getNodesPart(slide);
if(notesPart == null) if(notesPart == null)
return null; return null;
NotesDocument notesDoc = NotesDocument notesDoc =
NotesDocument.Factory.parse(notesPart.getInputStream()); NotesDocument.Factory.parse(notesPart.getInputStream());
return notesDoc.getNotes(); return notesDoc.getNotes();
} }
/** /**
* Returns all the comments for the given slide * Returns all the comments for the given slide
*/ */
@Internal @Internal
public CTCommentList getSlideComments(CTSlideIdListEntry slide) throws IOException, XmlException { public CTCommentList getSlideComments(CTSlideIdListEntry slide) throws IOException, XmlException {
PackageRelationshipCollection commentRels; PackageRelationshipCollection commentRels;
PackagePart slidePart = getSlidePart(slide); PackagePart slidePart = getSlidePart(slide);
try { try {
commentRels = slidePart.getRelationshipsByType(XSLFRelation.COMMENTS.getRelation()); commentRels = slidePart.getRelationshipsByType(XSLFRelation.COMMENTS.getRelation());
} catch(InvalidFormatException e) { } catch(InvalidFormatException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
if(commentRels.size() == 0) { if(commentRels.size() == 0) {
// No comments for this slide // No comments for this slide
return null; return null;
@ -236,12 +234,12 @@ public class XSLFSlideShow extends POIXMLDocument {
if(commentRels.size() > 1) { if(commentRels.size() > 1) {
throw new IllegalStateException("Expecting 0 or 1 comments for a slide, but found " + commentRels.size()); throw new IllegalStateException("Expecting 0 or 1 comments for a slide, but found " + commentRels.size());
} }
try { try {
PackagePart cPart = slidePart.getRelatedPart( PackagePart cPart = slidePart.getRelatedPart(
commentRels.getRelationship(0) commentRels.getRelationship(0)
); );
CmLstDocument commDoc = CmLstDocument commDoc =
CmLstDocument.Factory.parse(cPart.getInputStream()); CmLstDocument.Factory.parse(cPart.getInputStream());
return commDoc.getCmLst(); return commDoc.getCmLst();
} catch(InvalidFormatException e) { } catch(InvalidFormatException e) {
@ -249,12 +247,12 @@ public class XSLFSlideShow extends POIXMLDocument {
} }
} }
/** /**
* Get the document's embedded files. * Get the document's embedded files.
*/ */
@Override @Override
public List<PackagePart> getAllEmbedds() throws OpenXML4JException { public List<PackagePart> getAllEmbedds() throws OpenXML4JException {
return embedds; return embedds;
} }
} }

View File

@ -915,21 +915,23 @@ public abstract class AbstractWordConverter
Element currentBlock, Range textRange, int currentTableLevel, Element currentBlock, Range textRange, int currentTableLevel,
String hyperlink ); String hyperlink );
protected void processImage( Element currentBlock, boolean inlined, protected void processImage( Element currentBlock, boolean inlined, Picture picture ) {
Picture picture )
{
PicturesManager fileManager = getPicturesManager(); PicturesManager fileManager = getPicturesManager();
if ( fileManager != null ) if ( fileManager != null ) {
{ final float aspectRatioX = picture.getHorizontalScalingFactor();
final int aspectRatioX = picture.getHorizontalScalingFactor(); final float aspectRatioY = picture.getVerticalScalingFactor();
final int aspectRatioY = picture.getVerticalScalingFactor();
final float imageWidth = aspectRatioX > 0 ? picture.getDxaGoal() float imageWidth = picture.getDxaGoal();
* aspectRatioX / 1000 / AbstractWordUtils.TWIPS_PER_INCH if (aspectRatioX > 0) {
: picture.getDxaGoal() / AbstractWordUtils.TWIPS_PER_INCH; imageWidth *= aspectRatioX / 1000f;
final float imageHeight = aspectRatioY > 0 ? picture.getDyaGoal() }
* aspectRatioY / 1000 / AbstractWordUtils.TWIPS_PER_INCH imageWidth /= AbstractWordUtils.TWIPS_PER_INCH;
: picture.getDyaGoal() / AbstractWordUtils.TWIPS_PER_INCH;
float imageHeight = picture.getDyaGoal();
if (aspectRatioY > 0) {
imageHeight *= aspectRatioY / 1000f;
}
imageHeight /= AbstractWordUtils.TWIPS_PER_INCH;
String url = fileManager.savePicture( picture.getContent(), String url = fileManager.savePicture( picture.getContent(),
picture.suggestPictureType(), picture.suggestPictureType(),

View File

@ -381,7 +381,7 @@ public final class CharacterSprmUncompressor extends SprmUncompressor
//byte cInc = (byte)(((byte)(param & 0xfe00) >>> 4) >> 1); //byte cInc = (byte)(((byte)(param & 0xfe00) >>> 4) >> 1);
byte cInc = (byte) ((operand & 0xff00) >>> 8); byte cInc = (byte) ((operand & 0xff00) >>> 8);
cInc = (byte) (cInc >>> 1); cInc >>>= 1;
if (cInc != 0) if (cInc != 0)
{ {
newCHP.setHps (Math.max (newCHP.getHps () + (cInc * 2), 2)); newCHP.setHps (Math.max (newCHP.getHps () + (cInc * 2), 2));