You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ma...@apache.org on 2021/02/01 14:59:47 UTC
svn commit: r1886103 [8/10] - in /poi/branches/log4j: ./ legal/ maven/ osgi/
sonar/ sonar/main/ src/examples/src/org/apache/poi/examples/hssf/usermodel/
src/integrationtest/ src/integrationtest/org/apache/poi/stress/
src/java/org/apache/poi/ src/java/o...
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Document.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Document.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Document.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Document.java Mon Feb 1 14:59:43 2021
@@ -22,7 +22,7 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
-import org.apache.poi.util.POILogger;
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* Master container for Document. There is one of these for every
@@ -161,10 +161,10 @@ public final class Document extends Posi
// (normally it's 2, or 3 if you have notes)
// Complain if it's not
if(slwtcount == 0) {
- LOG.log(POILogger.WARN, "No SlideListWithText's found - there should normally be at least one!");
+ LOG.atWarn().log("No SlideListWithText's found - there should normally be at least one!");
}
if(slwtcount > 3) {
- LOG.log(POILogger.WARN, "Found ", slwtcount, " SlideListWithTexts - normally there should only be three!");
+ LOG.atWarn().log("Found {} SlideListWithTexts - normally there should only be three!", box(slwtcount));
}
// Now grab all the SLWTs
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java Mon Feb 1 14:59:43 2021
@@ -22,7 +22,8 @@ import java.io.OutputStream;
import java.util.Arrays;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* This data represents an embedded object in the document.
@@ -102,17 +103,19 @@ public class ExEmbed extends RecordConta
private void findInterestingChildren() {
// First child should be the ExHyperlinkAtom
- if(_children[0] instanceof ExEmbedAtom) {
- embedAtom = (ExEmbedAtom)_children[0];
+ Record child = _children[0];
+ if(child instanceof ExEmbedAtom) {
+ embedAtom = (ExEmbedAtom) child;
} else {
- LOG.log(POILogger.ERROR, "First child record wasn't a ExEmbedAtom, was of type ", _children[0].getRecordType());
+ LOG.atError().log("First child record wasn't a ExEmbedAtom, was of type {}", box(child.getRecordType()));
}
// Second child should be the ExOleObjAtom
- if (_children[1] instanceof ExOleObjAtom) {
- oleObjAtom = (ExOleObjAtom)_children[1];
+ child = _children[1];
+ if (child instanceof ExOleObjAtom) {
+ oleObjAtom = (ExOleObjAtom) child;
} else {
- LOG.log(POILogger.ERROR, "Second child record wasn't a ExOleObjAtom, was of type ", _children[1].getRecordType());
+ LOG.atError().log("Second child record wasn't a ExOleObjAtom, was of type {}", box(child.getRecordType()));
}
for (int i = 2; i < _children.length; i++) {
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java Mon Feb 1 14:59:43 2021
@@ -21,7 +21,8 @@ import java.io.OutputStream;
import java.util.Arrays;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* This class represents the data of a link in the document.
@@ -115,18 +116,20 @@ public class ExHyperlink extends RecordC
private void findInterestingChildren() {
// First child should be the ExHyperlinkAtom
- if(_children[0] instanceof ExHyperlinkAtom) {
- linkAtom = (ExHyperlinkAtom)_children[0];
+ Record child = _children[0];
+ if(child instanceof ExHyperlinkAtom) {
+ linkAtom = (ExHyperlinkAtom) child;
} else {
- LOG.log(POILogger.ERROR, "First child record wasn't a ExHyperlinkAtom, was of type ", _children[0].getRecordType());
+ LOG.atError().log("First child record wasn't a ExHyperlinkAtom, was of type {}", box(child.getRecordType()));
}
for (int i = 1; i < _children.length; i++) {
- if (_children[i] instanceof CString){
- if ( linkDetailsA == null) linkDetailsA = (CString)_children[i];
- else linkDetailsB = (CString)_children[i];
+ child = _children[i];
+ if (child instanceof CString){
+ if ( linkDetailsA == null) linkDetailsA = (CString) child;
+ else linkDetailsB = (CString) child;
} else {
- LOG.log(POILogger.ERROR, "Record after ExHyperlinkAtom wasn't a CString, was of type ", _children[1].getRecordType());
+ LOG.atError().log("Record after ExHyperlinkAtom wasn't a CString, was of type {}", box(child.getRecordType()));
}
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExMCIMovie.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExMCIMovie.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExMCIMovie.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExMCIMovie.java Mon Feb 1 14:59:43 2021
@@ -22,7 +22,8 @@ import java.io.OutputStream;
import java.util.Arrays;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* A container record that specifies information about a movie stored externally.
@@ -69,10 +70,11 @@ public class ExMCIMovie extends RecordCo
private void findInterestingChildren() {
// First child should be the ExVideoContainer
- if (_children[0] instanceof ExVideoContainer) {
- exVideo = (ExVideoContainer) _children[0];
+ final Record child = _children[0];
+ if (child instanceof ExVideoContainer) {
+ exVideo = (ExVideoContainer) child;
} else {
- LOG.log(POILogger.ERROR, "First child record wasn't a ExVideoContainer, was of type ", _children[0].getRecordType());
+ LOG.atError().log("First child record wasn't a ExVideoContainer, was of type {}", box(child.getRecordType()));
}
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExVideoContainer.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExVideoContainer.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExVideoContainer.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/ExVideoContainer.java Mon Feb 1 14:59:43 2021
@@ -22,7 +22,8 @@ import java.io.OutputStream;
import java.util.Arrays;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* A container record that specifies information about external video data.
@@ -57,15 +58,17 @@ public final class ExVideoContainer exte
private void findInterestingChildren() {
// First child should be the ExMediaAtom
- if(_children[0] instanceof ExMediaAtom) {
- mediaAtom = (ExMediaAtom)_children[0];
+ Record child = _children[0];
+ if(child instanceof ExMediaAtom) {
+ mediaAtom = (ExMediaAtom) child;
} else {
- LOG.log(POILogger.ERROR, "First child record wasn't a ExMediaAtom, was of type ", _children[0].getRecordType());
+ LOG.atError().log("First child record wasn't a ExMediaAtom, was of type {}", box(child.getRecordType()));
}
- if(_children[1] instanceof CString) {
- pathAtom = (CString)_children[1];
+ child = _children[1];
+ if(child instanceof CString) {
+ pathAtom = (CString) child;
} else {
- LOG.log(POILogger.ERROR, "Second child record wasn't a CString, was of type ", _children[1].getRecordType());
+ LOG.atError().log("Second child record wasn't a CString, was of type {}", box(child.getRecordType()));
}
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java Mon Feb 1 14:59:43 2021
@@ -35,7 +35,6 @@ import org.apache.poi.common.usermodel.f
import org.apache.poi.hslf.usermodel.HSLFFontInfo;
import org.apache.poi.hslf.usermodel.HSLFFontInfoPredefined;
import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogger;
/**
* {@code FontCollection} ia a container that holds information
@@ -62,7 +61,7 @@ public final class FontCollection extend
HSLFFontInfo fi = addFont(fontHeader);
fi.addFacet(fed);
} else {
- LOG.log(POILogger.WARN, "Warning: FontCollection child wasn't a FontEntityAtom, was ", r.getClass().getSimpleName());
+ LOG.atWarn().log("FontCollection child wasn't a FontEntityAtom, was {}", r.getClass().getSimpleName());
}
}
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/HeadersFootersContainer.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/HeadersFootersContainer.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/HeadersFootersContainer.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/HeadersFootersContainer.java Mon Feb 1 14:59:43 2021
@@ -22,7 +22,8 @@ import java.io.OutputStream;
import java.util.Arrays;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* A container record that specifies information about the footers on a presentation slide.
@@ -89,11 +90,11 @@ public final class HeadersFootersContain
csFooter = cs;
break;
default:
- LOG.log(POILogger.WARN, "Unexpected CString.Options in HeadersFootersContainer: ", opts);
+ LOG.atWarn().log("Unexpected CString.Options in HeadersFootersContainer: {}", box(opts));
break;
}
} else {
- LOG.log(POILogger.WARN, "Unexpected record in HeadersFootersContainer: ", child);
+ LOG.atWarn().log("Unexpected record in HeadersFootersContainer: {}", child);
}
}
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/InteractiveInfo.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/InteractiveInfo.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/InteractiveInfo.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/InteractiveInfo.java Mon Feb 1 14:59:43 2021
@@ -21,7 +21,6 @@ import java.io.OutputStream;
import java.util.Arrays;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
/**
* This class represents the metadata of a link in a slide/notes/etc.
@@ -61,7 +60,7 @@ public class InteractiveInfo extends Rec
private void findInterestingChildren() {
// First child should be the InteractiveInfoAtom
if (_children == null || _children.length == 0 || !(_children[0] instanceof InteractiveInfoAtom)) {
- LOG.log(POILogger.WARN, "First child record wasn't a InteractiveInfoAtom - leaving this atom in an invalid state...");
+ LOG.atWarn().log("First child record wasn't a InteractiveInfoAtom - leaving this atom in an invalid state...");
return;
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java Mon Feb 1 14:59:43 2021
@@ -31,7 +31,6 @@ import org.apache.poi.hslf.model.textpro
import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
/**
* Specifies the Indent Level for the text
@@ -85,7 +84,7 @@ public final class MasterTextPropAtom ex
try {
read();
} catch (Exception e){
- LOG.log(POILogger.ERROR, "Failed to parse MasterTextPropAtom", e);
+ LOG.atError().withThrowable(e).log("Failed to parse MasterTextPropAtom");
}
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java Mon Feb 1 14:59:43 2021
@@ -48,7 +48,8 @@ import org.apache.poi.sl.usermodel.Shape
import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* These are actually wrappers onto Escher drawings. Make use of
@@ -201,7 +202,7 @@ public final class PPDrawing extends Rec
// Wind on
int size = r.getRecordSize();
if(size < 8) {
- LOG.log(POILogger.WARN, "Hit short DDF record at ", startPos, " - ", size);
+ LOG.atWarn().log("Hit short DDF record at {} - {}", box(startPos),box(size));
}
/*
@@ -211,7 +212,7 @@ public final class PPDrawing extends Rec
* Sometimes it is not so, see an example in bug #44770. Most likely reason is that one of ddf records calculates wrong size.
*/
if(size != escherBytes){
- LOG.log(POILogger.WARN, "Record length=", escherBytes, " but getRecordSize() returned ", r.getRecordSize(), "; record: ", r.getClass());
+ LOG.atWarn().log("Record length={} but getRecordSize() returned {}; record: {}", box(escherBytes),box(r.getRecordSize()),r.getClass());
size = escherBytes;
}
startPos += size;
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java Mon Feb 1 14:59:43 2021
@@ -35,7 +35,6 @@ import org.apache.poi.util.BitFieldFacto
import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
/**
* General holder for PersistPtrFullBlock and PersistPtrIncrementalBlock
@@ -176,8 +175,9 @@ public final class PersistPtrHolder exte
if (newPos == null) {
Integer id = me.getKey();
- LOG.log(POILogger.WARN, "Couldn't find the new location of the \"slide\" with id " + id + " that used to be at " + oldPos);
- LOG.log(POILogger.WARN, "Not updating the position of it, you probably won't be able to find it any more (if you ever could!)");
+ LOG.atWarn().log("Couldn't find the new location of the \"slide\" with id {} that used to " +
+ "be at {}. Not updating the position of it, you probably won't be able to find it any more " +
+ "(if you ever could!)", id, oldPos);
} else {
me.setValue(newPos);
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Record.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Record.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Record.java Mon Feb 1 14:59:43 2021
@@ -23,13 +23,15 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.record.RecordTypes.RecordConstructor;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* This abstract class represents a record in the PowerPoint document.
@@ -42,7 +44,7 @@ import org.apache.poi.util.POILogger;
public abstract class Record implements GenericRecord
{
// For logging
- protected static final POILogger LOG = POILogFactory.getLogger(Record.class);
+ protected static final Logger LOG = LogManager.getLogger(Record.class);
/**
* Is this record type an Atom record (only has data),
@@ -79,7 +81,7 @@ public abstract class Record implements
}
@Override
- public List<org.apache.poi.hslf.record.Record> getGenericChildren() {
+ public List<Record> getGenericChildren() {
Record[] recs = getChildRecords();
return (recs == null) ? null : Arrays.asList(recs);
}
@@ -107,7 +109,7 @@ public abstract class Record implements
* @param b The byte array to build from
* @param offset The offset to build at
*/
- public static org.apache.poi.hslf.record.Record buildRecordAtOffset(byte[] b, int offset) {
+ public static Record buildRecordAtOffset(byte[] b, int offset) {
long type = LittleEndian.getUShort(b,offset+2);
long rlen = LittleEndian.getUInt(b,offset+4);
@@ -122,7 +124,7 @@ public abstract class Record implements
* Default method for finding child records of a container record
*/
public static Record[] findChildRecords(byte[] b, int start, int len) {
- List<org.apache.poi.hslf.record.Record> children = new ArrayList<>(5);
+ List<Record> children = new ArrayList<>(5);
// Jump our little way along, creating records as we go
int pos = start;
@@ -149,7 +151,7 @@ public abstract class Record implements
}
// Turn the vector into an array, and return
- return children.toArray(new org.apache.poi.hslf.record.Record[0]);
+ return children.toArray(new Record[0]);
}
/**
@@ -161,7 +163,7 @@ public abstract class Record implements
* (not including the size of the header), this code assumes you're
* passing in corrected lengths
*/
- public static org.apache.poi.hslf.record.Record createRecordForType(long type, byte[] b, int start, int len) {
+ public static Record createRecordForType(long type, byte[] b, int start, int len) {
// We use the RecordTypes class to provide us with the right
// class to use for a given type
// A spot of reflection gets us the (byte[],int,int) constructor
@@ -183,7 +185,7 @@ public abstract class Record implements
// Handle case of a corrupt last record, whose claimed length
// would take us passed the end of the file
if(start + len > b.length ) {
- LOG.log(POILogger.WARN, "Warning: Skipping record of type " + type + " at position " + start + " which claims to be longer than the file! (" + len + " vs " + (b.length-start) + ")");
+ LOG.atWarn().log("Warning: Skipping record of type {} at position {} which claims to be longer than the file! ({} vs {})", type, box(start), box(len), box(b.length - start));
return null;
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Sound.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Sound.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Sound.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/Sound.java Mon Feb 1 14:59:43 2021
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
-import org.apache.poi.util.POILogger;
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* A container holding information about a sound. It contains:
@@ -65,17 +65,19 @@ public final class Sound extends RecordC
private void findInterestingChildren() {
// First child should be the ExHyperlinkAtom
- if(_children[0] instanceof CString) {
- _name = (CString)_children[0];
+ Record child = _children[0];
+ if(child instanceof CString) {
+ _name = (CString) child;
} else {
- LOG.log(POILogger.ERROR, "First child record wasn't a CString, was of type ", _children[0].getRecordType());
+ LOG.atError().log("First child record wasn't a CString, was of type {}", box(child.getRecordType()));
}
// Second child should be the ExOleObjAtom
- if (_children[1] instanceof CString) {
- _type = (CString)_children[1];
+ child = _children[1];
+ if (child instanceof CString) {
+ _type = (CString) child;
} else {
- LOG.log(POILogger.ERROR, "Second child record wasn't a CString, was of type ", _children[1].getRecordType());
+ LOG.atError().log("Second child record wasn't a CString, was of type {}", box(child.getRecordType()));
}
for (int i = 2; i < _children.length; i++) {
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java Mon Feb 1 14:59:43 2021
@@ -33,7 +33,8 @@ import org.apache.poi.util.GenericRecord
import org.apache.poi.util.HexDump;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
+
+import static org.apache.logging.log4j.util.Unbox.box;
/**
* A StyleTextPropAtom (type 4001). Holds basic character properties
@@ -251,7 +252,7 @@ public final class StyleTextPropAtom ext
}
if (rawContents.length > 0 && textHandled != (size+1)){
- LOG.log(POILogger.WARN, "Problem reading paragraph style runs: textHandled = ", textHandled, ", text.size+1 = ", (size+1));
+ LOG.atWarn().log("Problem reading paragraph style runs: textHandled = {}, text.size+1 = {}", box(textHandled),box(size + 1));
}
// Now do the character stylings
@@ -283,7 +284,7 @@ public final class StyleTextPropAtom ext
}
}
if (rawContents.length > 0 && textHandled != (size+1)){
- LOG.log(POILogger.WARN, "Problem reading character style runs: textHandled = ", textHandled, ", text.size+1 = ", (size+1));
+ LOG.atWarn().log("Problem reading character style runs: textHandled = {}, text.size+1 = {}", box(textHandled),box(size + 1));
}
// Handle anything left over
@@ -296,8 +297,7 @@ public final class StyleTextPropAtom ext
private int checkTextLength(int readLength, int handledSoFar, int overallSize) {
if (readLength + handledSoFar > overallSize + 1) {
- LOG.log(POILogger.WARN, "Style length of ", readLength, " at ", handledSoFar,
- " larger than stated size of ", overallSize, ", truncating");
+ LOG.atWarn().log("Style length of {} at {} larger than stated size of {}, truncating", box(readLength),box(handledSoFar),box(overallSize));
return overallSize + 1 - handledSoFar;
}
return readLength;
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java Mon Feb 1 14:59:43 2021
@@ -36,7 +36,6 @@ import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
import org.apache.poi.util.LittleEndianOutputStream;
-import org.apache.poi.util.POILogger;
/**
* Ruler of a text as it differs from the style's ruler settings.
@@ -98,7 +97,7 @@ public final class TextRulerAtom extends
// Get the record data.
read(leis);
} catch (IOException e){
- LOG.log(POILogger.ERROR, "Failed to parse TextRulerAtom: ", e.getMessage());
+ LOG.atError().withThrowable(e).log("Failed to parse TextRulerAtom");
}
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java Mon Feb 1 14:59:43 2021
@@ -26,6 +26,8 @@ import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.model.textproperties.TextPropCollection.TextPropType;
@@ -35,8 +37,6 @@ import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianOutputStream;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* TxMasterStyleAtom atom (4003).
@@ -53,7 +53,7 @@ import org.apache.poi.util.POILogger;
* </p>
*/
public final class TxMasterStyleAtom extends RecordAtom {
- private static final POILogger LOG = POILogFactory.getLogger(TxMasterStyleAtom.class);
+ private static final Logger LOG = LogManager.getLogger(TxMasterStyleAtom.class);
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000;
@@ -79,7 +79,7 @@ public final class TxMasterStyleAtom ext
try {
init();
} catch (Exception e){
- LOG.log(POILogger.WARN, "Exception when reading available styles", e);
+ LOG.atWarn().withThrowable(e).log("Exception when reading available styles");
}
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFAutoShape.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFAutoShape.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFAutoShape.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFAutoShape.java Mon Feb 1 14:59:43 2021
@@ -26,6 +26,8 @@ import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.Iterator;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.AbstractEscherOptRecord;
import org.apache.poi.ddf.EscherArrayProperty;
import org.apache.poi.ddf.EscherContainerRecord;
@@ -47,8 +49,6 @@ import org.apache.poi.ss.usermodel.Shape
import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* Represents an AutoShape.<p>
@@ -57,7 +57,7 @@ import org.apache.poi.util.POILogger;
* See {@link ShapeTypes}
*/
public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFShape,HSLFTextParagraph> {
- private static final POILogger LOG = POILogFactory.getLogger(HSLFAutoShape.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFAutoShape.class);
static final byte[] SEGMENTINFO_MOVETO = new byte[]{0x00, 0x40};
static final byte[] SEGMENTINFO_LINETO = new byte[]{0x00, (byte)0xAC};
@@ -218,11 +218,11 @@ public class HSLFAutoShape extends HSLFT
//sanity check
if(verticesProp == null) {
- LOG.log(POILogger.WARN, "Freeform is missing GEOMETRY__VERTICES ");
+ LOG.atWarn().log("Freeform is missing GEOMETRY__VERTICES ");
return super.getGeometry();
}
if(segmentsProp == null) {
- LOG.log(POILogger.WARN, "Freeform is missing GEOMETRY__SEGMENTINFO ");
+ LOG.atWarn().log("Freeform is missing GEOMETRY__SEGMENTINFO ");
return super.getGeometry();
}
@@ -236,7 +236,7 @@ public class HSLFAutoShape extends HSLFT
while (segIter.hasNext()) {
byte[] segElem = segIter.next();
- HSLFAutoShape.PathInfo pi = getPathInfo(segElem);
+ PathInfo pi = getPathInfo(segElem);
if (pi == null) {
continue;
}
@@ -368,7 +368,7 @@ public class HSLFAutoShape extends HSLFT
}
private static void handleEscapeInfo(Path pathCT, Path2D path2D, byte[] segElem, Iterator<byte[]> vertIter) {
- HSLFAutoShape.EscapeInfo ei = getEscapeInfo(segElem);
+ EscapeInfo ei = getEscapeInfo(segElem);
if (ei == null) {
return;
}
@@ -466,26 +466,26 @@ public class HSLFAutoShape extends HSLFT
return new Point2D.Double(xyPoints[0],xyPoints[1]);
}
- private static HSLFAutoShape.PathInfo getPathInfo(byte[] elem) {
+ private static PathInfo getPathInfo(byte[] elem) {
int elemUS = LittleEndian.getUShort(elem, 0);
int pathInfo = PATH_INFO.getValue(elemUS);
- return HSLFAutoShape.PathInfo.valueOf(pathInfo);
+ return PathInfo.valueOf(pathInfo);
}
- private static HSLFAutoShape.EscapeInfo getEscapeInfo(byte[] elem) {
+ private static EscapeInfo getEscapeInfo(byte[] elem) {
int elemUS = LittleEndian.getUShort(elem, 0);
int escInfo = ESCAPE_INFO.getValue(elemUS);
- return HSLFAutoShape.EscapeInfo.valueOf(escInfo);
+ return EscapeInfo.valueOf(escInfo);
}
private static AdjustPoint fillPoint(byte[] xyMaster, int[] xyPoints) {
if (xyMaster == null || xyPoints == null) {
- LOG.log(POILogger.WARN, "Master bytes or points not set - ignore point");
+ LOG.atWarn().log("Master bytes or points not set - ignore point");
return null;
}
if ((xyMaster.length != 4 && xyMaster.length != 8) || xyPoints.length != 2) {
- LOG.log(POILogger.WARN, "Invalid number of master bytes for a single point - ignore point");
+ LOG.atWarn().log("Invalid number of master bytes for a single point - ignore point");
return null;
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java Mon Feb 1 14:59:43 2021
@@ -24,6 +24,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.AbstractEscherOptRecord;
import org.apache.poi.ddf.EscherArrayProperty;
import org.apache.poi.ddf.EscherBSERecord;
@@ -41,19 +43,20 @@ import org.apache.poi.sl.usermodel.Paint
import org.apache.poi.sl.usermodel.PaintStyle.GradientPaint;
import org.apache.poi.sl.usermodel.PaintStyle.GradientPaint.GradientType;
import org.apache.poi.sl.usermodel.PaintStyle.TexturePaint;
+import org.apache.poi.sl.usermodel.PictureData;
import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
+import static org.apache.logging.log4j.util.Unbox.box;
+
/**
* Represents functionality provided by the 'Fill Effects' dialog in PowerPoint.
*/
@SuppressWarnings("WeakerAccess")
public final class HSLFFill {
- private static final POILogger LOG = POILogFactory.getLogger(HSLFFill.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFFill.class);
/**
* Fill with a solid color
@@ -263,7 +266,7 @@ public final class HSLFFill {
case FILL_PICTURE:
return getTexturePaint();
default:
- LOG.log(POILogger.WARN, "unsuported fill type: ", fillType);
+ LOG.atWarn().log("unsupported fill type: {}", box(fillType));
return null;
}
}
@@ -445,7 +448,7 @@ public final class HSLFFill {
EscherBSERecord getEscherBSERecord(int idx){
HSLFSheet sheet = shape.getSheet();
if(sheet == null) {
- LOG.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet");
+ LOG.atDebug().log("Fill has not yet been assigned to a sheet");
return null;
}
HSLFSlideShow ppt = sheet.getSlideShow();
@@ -453,7 +456,7 @@ public final class HSLFFill {
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
if(bstore == null) {
- LOG.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
+ LOG.atDebug().log("EscherContainerRecord.BSTORE_CONTAINER was not found ");
return null;
}
List<EscherRecord> lst = bstore.getChildRecords();
@@ -560,10 +563,10 @@ public final class HSLFFill {
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
- java.util.List<EscherRecord> lst = bstore.getChildRecords();
+ List<EscherRecord> lst = bstore.getChildRecords();
int idx = p.getPropertyValue();
if (idx == 0){
- LOG.log(POILogger.WARN, "no reference to picture data found ");
+ LOG.atWarn().log("no reference to picture data found ");
} else {
EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1);
for (HSLFPictureData pd : pict) {
@@ -579,7 +582,7 @@ public final class HSLFFill {
/**
* Assign picture used to fill the underlying shape.
*
- * @param data the picture data added to this ppt by {@link HSLFSlideShow#addPicture(byte[], org.apache.poi.sl.usermodel.PictureData.PictureType)} method.
+ * @param data the picture data added to this ppt by {@link HSLFSlideShow#addPicture(byte[], PictureData.PictureType)} method.
*/
public void setPictureData(HSLFPictureData data){
AbstractEscherOptRecord opt = shape.getEscherOptRecord();
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java Mon Feb 1 14:59:43 2021
@@ -25,6 +25,8 @@ import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.AbstractEscherOptRecord;
import org.apache.poi.ddf.EscherArrayProperty;
import org.apache.poi.ddf.EscherContainerRecord;
@@ -34,10 +36,10 @@ import org.apache.poi.sl.usermodel.Freef
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
+import static org.apache.logging.log4j.util.Unbox.box;
+
/**
* A "Freeform" shape.
*
@@ -47,7 +49,7 @@ import org.apache.poi.util.Units;
* </p>
*/
public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformShape<HSLFShape,HSLFTextParagraph> {
- private static final POILogger LOG = POILogFactory.getLogger(HSLFFreeformShape.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFFreeformShape.class);
enum ShapePath {
@@ -138,7 +140,7 @@ public final class HSLFFreeformShape ext
break;
case PathIterator.SEG_QUADTO:
//TODO: figure out how to convert SEG_QUADTO into SEG_CUBICTO
- LOG.log(POILogger.WARN, "SEG_QUADTO is not supported");
+ LOG.atWarn().log("SEG_QUADTO is not supported");
break;
case PathIterator.SEG_CLOSE:
pntInfo.add(pntInfo.get(0));
@@ -150,7 +152,7 @@ public final class HSLFFreeformShape ext
numPoints++;
break;
default:
- LOG.log(POILogger.WARN, "Ignoring invalid segment type ", type);
+ LOG.atWarn().log("Ignoring invalid segment type {}", box(type));
break;
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java Mon Feb 1 14:59:43 2021
@@ -22,6 +22,8 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.EscherChildAnchorRecord;
import org.apache.poi.ddf.EscherClientAnchorRecord;
import org.apache.poi.ddf.EscherContainerRecord;
@@ -33,8 +35,6 @@ import org.apache.poi.sl.usermodel.Pictu
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
/**
@@ -42,7 +42,7 @@ import org.apache.poi.util.Units;
*/
public class HSLFGroupShape extends HSLFShape
implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
- private static final POILogger LOG = POILogFactory.getLogger(HSLFGroupShape.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFGroupShape.class);
/**
* Create a new ShapeGroup. This constructor is used when a new shape is created.
@@ -207,7 +207,7 @@ implements HSLFShapeContainer, GroupShap
EscherClientAnchorRecord clientAnchor = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
int x1,y1,x2,y2;
if(clientAnchor == null){
- LOG.log(POILogger.INFO, "EscherClientAnchorRecord was not found for shape group. Searching for EscherChildAnchorRecord.");
+ LOG.atInfo().log("EscherClientAnchorRecord was not found for shape group. Searching for EscherChildAnchorRecord.");
EscherChildAnchorRecord rec = getEscherChild(EscherChildAnchorRecord.RECORD_ID);
x1 = rec.getDx1();
y1 = rec.getDy1();
@@ -230,7 +230,7 @@ implements HSLFShapeContainer, GroupShap
/**
* Return type of the shape.
- * In most cases shape group type is {@link org.apache.poi.sl.usermodel.ShapeType#NOT_PRIMITIVE}
+ * In most cases shape group type is {@link ShapeType#NOT_PRIMITIVE}
*
* @return type of the shape.
*/
@@ -289,7 +289,7 @@ implements HSLFShapeContainer, GroupShap
} else {
// Should we do anything special with these non
// Container records?
- LOG.log(POILogger.ERROR, "Shape contained non container escher record, was ", r.getClass().getName());
+ LOG.atError().log("Shape contained non container escher record, was {}", r.getClass().getName());
}
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFNotes.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFNotes.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFNotes.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFNotes.java Mon Feb 1 14:59:43 2021
@@ -20,12 +20,12 @@ package org.apache.poi.hslf.usermodel;
import java.util.ArrayList;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hslf.model.HeadersFooters;
import org.apache.poi.hslf.record.HeadersFootersContainer;
import org.apache.poi.sl.usermodel.Notes;
import org.apache.poi.sl.usermodel.Placeholder;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* This class represents a slide's notes in a PowerPoint Document. It
@@ -36,7 +36,7 @@ import org.apache.poi.util.POILogger;
*/
public final class HSLFNotes extends HSLFSheet implements Notes<HSLFShape,HSLFTextParagraph> {
- private static final POILogger LOG = POILogFactory.getLogger(HSLFNotes.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFNotes.class);
private final List<List<HSLFTextParagraph>> _paragraphs = new ArrayList<>();
@@ -57,7 +57,7 @@ public final class HSLFNotes extends HSL
}
if (_paragraphs.isEmpty()) {
- LOG.log(POILogger.WARN, "No text records found for notes sheet");
+ LOG.atWarn().log("No text records found for notes sheet");
}
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java Mon Feb 1 14:59:43 2021
@@ -25,18 +25,18 @@ import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hslf.record.ExOleObjStg;
import org.apache.poi.sl.usermodel.ObjectData;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* A class that represents object data embedded in a slide show.
*/
public class HSLFObjectData implements ObjectData, GenericRecord {
- private static final POILogger LOG = POILogFactory.getLogger(HSLFObjectData.class);
-
+ private static final Logger LOG = LogManager.getLogger(HSLFObjectData.class);
+
/**
* The record that contains the object data.
*/
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectShape.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectShape.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectShape.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectShape.java Mon Feb 1 14:59:43 2021
@@ -22,6 +22,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherPropertyTypes;
import org.apache.poi.ddf.EscherSpRecord;
@@ -38,15 +40,13 @@ import org.apache.poi.sl.usermodel.Objec
import org.apache.poi.sl.usermodel.ObjectMetaData.Application;
import org.apache.poi.sl.usermodel.ObjectShape;
import org.apache.poi.sl.usermodel.ShapeContainer;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* A shape representing embedded OLE object.
*/
public final class HSLFObjectShape extends HSLFPictureShape implements ObjectShape<HSLFShape,HSLFTextParagraph> {
- private static final POILogger LOG = POILogFactory.getLogger(HSLFObjectShape.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFObjectShape.class);
private ExEmbed _exEmbed;
@@ -104,7 +104,7 @@ public final class HSLFObjectShape exten
HSLFEscherClientDataRecord cldata = getClientData(true);
ExObjRefAtom uer = null;
- for (org.apache.poi.hslf.record.Record r : cldata.getHSLFChildRecords()) {
+ for (Record r : cldata.getHSLFChildRecords()) {
if (r.getRecordType() == RecordTypes.ExObjRefAtom.typeID) {
uer = (ExObjRefAtom)r;
break;
@@ -141,7 +141,7 @@ public final class HSLFObjectShape exten
}
}
if (data==null) {
- LOG.log(POILogger.WARN, "OLE data not found");
+ LOG.atWarn().log("OLE data not found");
}
return data;
@@ -171,7 +171,7 @@ public final class HSLFObjectShape exten
ExObjList lst = ppt.getDocumentRecord().getExObjList(create);
if(lst == null){
- LOG.log(POILogger.WARN, "ExObjList not found");
+ LOG.atWarn().log("ExObjList not found");
return null;
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java Mon Feb 1 14:59:43 2021
@@ -21,6 +21,8 @@ import java.awt.Insets;
import java.awt.geom.Rectangle2D;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.AbstractEscherOptRecord;
import org.apache.poi.ddf.EscherBSERecord;
import org.apache.poi.ddf.EscherComplexProperty;
@@ -34,17 +36,17 @@ import org.apache.poi.sl.draw.DrawPictur
import org.apache.poi.sl.usermodel.PictureShape;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.StringUtil;
import org.apache.poi.util.Units;
+import static org.apache.logging.log4j.util.Unbox.box;
+
/**
* Represents a picture in a PowerPoint document.
*/
public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HSLFShape,HSLFTextParagraph> {
- private static final POILogger LOG = POILogFactory.getLogger(HSLFPictureShape.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFPictureShape.class);
/**
* Create a new <code>Picture</code>
@@ -120,14 +122,14 @@ public class HSLFPictureShape extends HS
EscherBSERecord bse = getEscherBSERecord();
if (bse == null){
- LOG.log(POILogger.ERROR, "no reference to picture data found ");
+ LOG.atError().log("no reference to picture data found ");
} else {
for (HSLFPictureData pd : pict) {
if (pd.getOffset() == bse.getOffset()){
return pd;
}
}
- LOG.log(POILogger.ERROR, "no picture found for our BSE offset ", bse.getOffset());
+ LOG.atError().log("no picture found for our BSE offset {}", box(bse.getOffset()));
}
return null;
}
@@ -139,13 +141,13 @@ public class HSLFPictureShape extends HS
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
if(bstore == null) {
- LOG.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
+ LOG.atDebug().log("EscherContainerRecord.BSTORE_CONTAINER was not found ");
return null;
}
List<EscherRecord> lst = bstore.getChildRecords();
int idx = getPictureIndex();
if (idx == 0){
- LOG.log(POILogger.DEBUG, "picture index was not found, returning ");
+ LOG.atDebug().log("picture index was not found, returning ");
return null;
}
return (EscherBSERecord)lst.get(idx-1);
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java Mon Feb 1 14:59:43 2021
@@ -23,6 +23,8 @@ import java.awt.geom.Rectangle2D;
import java.util.Iterator;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.AbstractEscherOptRecord;
import org.apache.poi.ddf.EscherChildAnchorRecord;
import org.apache.poi.ddf.EscherClientAnchorRecord;
@@ -48,8 +50,6 @@ import org.apache.poi.sl.usermodel.Prese
import org.apache.poi.sl.usermodel.Shape;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.Removal;
import org.apache.poi.util.StringUtil;
import org.apache.poi.util.Units;
@@ -69,7 +69,7 @@ import org.apache.poi.util.Units;
* <p>
*/
public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
- private static final POILogger LOG = POILogFactory.getLogger(HSLFShape.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFShape.class);
/**
* Either EscherSpContainer or EscheSpgrContainer record
@@ -168,7 +168,7 @@ public abstract class HSLFShape implemen
y2 = childRec.getDy2();
} else {
if (useChildRec) {
- LOG.log(POILogger.WARN, "EscherSpRecord.FLAG_CHILD is set but EscherChildAnchorRecord was not found");
+ LOG.atWarn().log("EscherSpRecord.FLAG_CHILD is set but EscherChildAnchorRecord was not found");
}
EscherClientAnchorRecord clientRec = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
x1 = clientRec.getCol1();
@@ -715,7 +715,7 @@ public abstract class HSLFShape implemen
public <T extends Record> T getClientDataRecord(int recordType) {
List<? extends Record> records = getClientRecords();
- if (records != null) for (org.apache.poi.hslf.record.Record r : records) {
+ if (records != null) for (Record r : records) {
if (r.getRecordType() == recordType){
return (T)r;
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java Mon Feb 1 14:59:43 2021
@@ -19,6 +19,8 @@ package org.apache.poi.hslf.usermodel;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.AbstractEscherOptRecord;
import org.apache.poi.ddf.EscherClientDataRecord;
import org.apache.poi.ddf.EscherContainerRecord;
@@ -40,15 +42,13 @@ import org.apache.poi.hslf.record.Record
import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* Create a <code>Shape</code> object depending on its type
*/
public final class HSLFShapeFactory {
// For logging
- private static final POILogger LOG = POILogFactory.getLogger(HSLFShapeFactory.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFShapeFactory.class);
/**
* Create a new shape from the data provided.
@@ -112,7 +112,7 @@ public final class HSLFShapeFactory {
if (parent instanceof HSLFTable) {
EscherTextboxRecord etr = spContainer.getChildById(EscherTextboxRecord.RECORD_ID);
if (etr == null) {
- LOG.log(POILogger.WARN, "invalid ppt - add EscherTextboxRecord to cell");
+ LOG.atWarn().log("invalid ppt - add EscherTextboxRecord to cell");
etr = new EscherTextboxRecord();
etr.setRecordId(EscherTextboxRecord.RECORD_ID);
etr.setOptions((short)15);
@@ -153,14 +153,14 @@ public final class HSLFShapeFactory {
return new HSLFFreeformShape(spContainer, parent);
}
- LOG.log(POILogger.INFO, "Creating AutoShape for a NotPrimitive shape");
+ LOG.atInfo().log("Creating AutoShape for a NotPrimitive shape");
return new HSLFAutoShape(spContainer, parent);
}
@SuppressWarnings("unchecked")
protected static <T extends Record> T getClientDataRecord(EscherContainerRecord spContainer, int recordType) {
HSLFEscherClientDataRecord cldata = spContainer.getChildById(EscherClientDataRecord.RECORD_ID);
- if (cldata != null) for (org.apache.poi.hslf.record.Record r : cldata.getHSLFChildRecords()) {
+ if (cldata != null) for (Record r : cldata.getHSLFChildRecords()) {
if (r.getRecordType() == recordType) {
return (T)r;
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java Mon Feb 1 14:59:43 2021
@@ -19,6 +19,8 @@ package org.apache.poi.hslf.usermodel;
import java.awt.Color;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.AbstractEscherOptRecord;
import org.apache.poi.ddf.EscherChildAnchorRecord;
import org.apache.poi.ddf.EscherClientAnchorRecord;
@@ -49,8 +51,6 @@ import org.apache.poi.sl.usermodel.Strok
import org.apache.poi.sl.usermodel.StrokeStyle.LineCompound;
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
/**
@@ -58,7 +58,7 @@ import org.apache.poi.util.Units;
* This is the parent class for all primitive shapes like Line, Rectangle, etc.
*/
public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<HSLFShape,HSLFTextParagraph> {
- private static final POILogger LOG = POILogFactory.getLogger(HSLFSimpleShape.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFSimpleShape.class);
public static final double DEFAULT_LINE_WIDTH = 0.75;
@@ -322,7 +322,7 @@ public abstract class HSLFSimpleShape ex
@Override
public Guide getAdjustValue(String name) {
if (name == null || !name.matches("adj([1-9]|10)?")) {
- LOG.log(POILogger.INFO, "Adjust value '", name, "' not supported. Using default value.");
+ LOG.atInfo().log("Adjust value '{}' not supported. Using default value.", name);
return null;
}
@@ -384,7 +384,7 @@ public abstract class HSLFSimpleShape ex
if (name == null) {
name = (st != null) ? st.toString() : "<unknown>";
}
- LOG.log(POILogger.WARN, "No preset shape definition for shapeType: "+name);
+ LOG.atWarn().log("No preset shape definition for shapeType: {}", name);
}
return geom;
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java Mon Feb 1 14:59:43 2021
@@ -33,6 +33,8 @@ import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.POIDocument;
import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.common.usermodel.fonts.FontInfo;
@@ -61,10 +63,10 @@ import org.apache.poi.sl.usermodel.Slide
import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
+import static org.apache.logging.log4j.util.Unbox.box;
+
/**
* This class is a friendly wrapper on top of the more scary HSLFSlideShow.
*
@@ -79,7 +81,7 @@ public final class HSLFSlideShow extends
public static final String PP95_DOCUMENT = "PP40";
// For logging
- private static final POILogger LOG = POILogFactory.getLogger(HSLFSlideShow.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFSlideShow.class);
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 10_000_000;
@@ -94,7 +96,7 @@ public final class HSLFSlideShow extends
// Pointers to the most recent versions of the core records
// (Document, Notes, Slide etc)
- private org.apache.poi.hslf.record.Record[] _mostRecentCoreRecords;
+ private Record[] _mostRecentCoreRecords;
// Lookup between the PersitPtr "sheet" IDs, and the position
// in the mostRecentCoreRecords array
private Map<Integer,Integer> _sheetIdToCoreRecordsLookup;
@@ -125,7 +127,7 @@ public final class HSLFSlideShow extends
_hslfSlideShow = hslfSlideShow;
// Handle Parent-aware Records
- for (org.apache.poi.hslf.record.Record record : _hslfSlideShow.getRecords()) {
+ for (Record record : _hslfSlideShow.getRecords()) {
if(record instanceof RecordContainer){
RecordContainer.handleParentAwareRecords((RecordContainer)record);
}
@@ -187,7 +189,7 @@ public final class HSLFSlideShow extends
private void findMostRecentCoreRecords() {
// To start with, find the most recent in the byte offset domain
Map<Integer,Integer> mostRecentByBytes = new HashMap<>();
- for (org.apache.poi.hslf.record.Record record : _hslfSlideShow.getRecords()) {
+ for (Record record : _hslfSlideShow.getRecords()) {
if (record instanceof PersistPtrHolder) {
PersistPtrHolder pph = (PersistPtrHolder) record;
@@ -208,7 +210,7 @@ public final class HSLFSlideShow extends
// We now know how many unique special records we have, so init
// the array
- _mostRecentCoreRecords = new org.apache.poi.hslf.record.Record[mostRecentByBytes.size()];
+ _mostRecentCoreRecords = new Record[mostRecentByBytes.size()];
// We'll also want to be able to turn the slide IDs into a position
// in this array
@@ -225,7 +227,7 @@ public final class HSLFSlideShow extends
}
// Now convert the byte offsets back into record offsets
- for (org.apache.poi.hslf.record.Record record : _hslfSlideShow.getRecords()) {
+ for (Record record : _hslfSlideShow.getRecords()) {
if (!(record instanceof PositionDependentRecord)) {
continue;
}
@@ -253,7 +255,7 @@ public final class HSLFSlideShow extends
}
// Now look for the interesting records in there
- for (org.apache.poi.hslf.record.Record record : _mostRecentCoreRecords) {
+ for (Record record : _mostRecentCoreRecords) {
// Check there really is a record at this number
if (record != null) {
// Find the Document, and interesting things in it
@@ -272,7 +274,7 @@ public final class HSLFSlideShow extends
* For a given SlideAtomsSet, return the core record, based on the refID
* from the SlidePersistAtom
*/
- public org.apache.poi.hslf.record.Record getCoreRecordForSAS(SlideAtomsSet sas) {
+ public Record getCoreRecordForSAS(SlideAtomsSet sas) {
SlidePersistAtom spa = sas.getSlidePersistAtom();
int refID = spa.getRefID();
return getCoreRecordForRefID(refID);
@@ -285,13 +287,12 @@ public final class HSLFSlideShow extends
* @param refID
* the refID
*/
- public org.apache.poi.hslf.record.Record getCoreRecordForRefID(int refID) {
+ public Record getCoreRecordForRefID(int refID) {
Integer coreRecordId = _sheetIdToCoreRecordsLookup.get(refID);
if (coreRecordId != null) {
return _mostRecentCoreRecords[coreRecordId];
}
- LOG.log(POILogger.ERROR,
- "We tried to look up a reference to a core record, but there was no core ID for reference ID ", refID);
+ LOG.atError().log("We tried to look up a reference to a core record, but there was no core ID for reference ID {}", box(refID));
return null;
}
@@ -349,7 +350,7 @@ public final class HSLFSlideShow extends
}
for (SlideAtomsSet sas : masterSLWT.getSlideAtomsSets()) {
- org.apache.poi.hslf.record.Record r = getCoreRecordForSAS(sas);
+ Record r = getCoreRecordForSAS(sas);
int sheetNo = sas.getSlidePersistAtom().getSlideIdentifier();
if (r instanceof Slide) {
HSLFTitleMaster master = new HSLFTitleMaster((Slide)r, sheetNo);
@@ -375,20 +376,20 @@ public final class HSLFSlideShow extends
for (SlideAtomsSet notesSet : notesSLWT.getSlideAtomsSets()) {
idx++;
// Get the right core record
- org.apache.poi.hslf.record.Record r = getCoreRecordForSAS(notesSet);
+ Record r = getCoreRecordForSAS(notesSet);
SlidePersistAtom spa = notesSet.getSlidePersistAtom();
String loggerLoc = "A Notes SlideAtomSet at "+idx+" said its record was at refID "+spa.getRefID();
// we need to add null-records, otherwise the index references to other existing don't work anymore
if (r == null) {
- LOG.log(POILogger.WARN, loggerLoc+", but that record didn't exist - record ignored.");
+ LOG.atWarn().log("{}, but that record didn't exist - record ignored.", loggerLoc);
continue;
}
// Ensure it really is a notes record
if (!(r instanceof Notes)) {
- LOG.log(POILogger.ERROR, loggerLoc, ", but that was actually a ", r);
+ LOG.atError().log("{}, but that was actually a {}", loggerLoc, r);
continue;
}
@@ -416,14 +417,11 @@ public final class HSLFSlideShow extends
idx++;
// Get the right core record
SlidePersistAtom spa = sas.getSlidePersistAtom();
- org.apache.poi.hslf.record.Record r = getCoreRecordForSAS(sas);
+ Record r = getCoreRecordForSAS(sas);
// Ensure it really is a slide record
if (!(r instanceof Slide)) {
- LOG.log(POILogger.ERROR, "A Slide SlideAtomSet at ", idx,
- " said its record was at refID ",
- spa.getRefID(),
- ", but that was actually a ", r);
+ LOG.atError().log("A Slide SlideAtomSet at {} said its record was at refID {}, but that was actually a {}", box(idx),box(spa.getRefID()),r);
continue;
}
@@ -439,7 +437,7 @@ public final class HSLFSlideShow extends
if (notesPos != null && 0 <= notesPos && notesPos < _notes.size()) {
notes = _notes.get(notesPos);
} else {
- LOG.log(POILogger.ERROR, "Notes not found for noteId=", noteId);
+ LOG.atError().log("Notes not found for noteId={}", box(noteId));
}
}
@@ -499,7 +497,7 @@ public final class HSLFSlideShow extends
* Returns an array of the most recent version of all the interesting
* records
*/
- public org.apache.poi.hslf.record.Record[] getMostRecentCoreRecords() {
+ public Record[] getMostRecentCoreRecords() {
return _mostRecentCoreRecords;
}
@@ -618,13 +616,13 @@ public final class HSLFSlideShow extends
_slides.get(newSlideNumber - 1).setSlideNumber(newSlideNumber);
_slides.get(oldSlideNumber - 1).setSlideNumber(oldSlideNumber);
- ArrayList<org.apache.poi.hslf.record.Record> lst = new ArrayList<>();
+ ArrayList<Record> lst = new ArrayList<>();
for (SlideAtomsSet s : sas) {
lst.add(s.getSlidePersistAtom());
lst.addAll(Arrays.asList(s.getSlideRecords()));
}
- org.apache.poi.hslf.record.Record[] r = lst.toArray(new org.apache.poi.hslf.record.Record[0]);
+ Record[] r = lst.toArray(new Record[0]);
slwt.setChildRecord(r);
}
@@ -653,7 +651,7 @@ public final class HSLFSlideShow extends
}
SlideAtomsSet[] sas = slwt.getSlideAtomsSets();
- List<org.apache.poi.hslf.record.Record> records = new ArrayList<>();
+ List<Record> records = new ArrayList<>();
List<SlideAtomsSet> sa = new ArrayList<>(Arrays.asList(sas));
HSLFSlide removedSlide = _slides.remove(index);
@@ -673,7 +671,7 @@ public final class HSLFSlideShow extends
_documentRecord.removeSlideListWithText(slwt);
} else {
slwt.setSlideAtomsSets(sa.toArray(new SlideAtomsSet[0]));
- slwt.setChildRecord(records.toArray(new org.apache.poi.hslf.record.Record[0]));
+ slwt.setChildRecord(records.toArray(new Record[0]));
}
// if the removed slide had notes - remove references to them too
@@ -697,7 +695,7 @@ public final class HSLFSlideShow extends
if (!na.isEmpty()) {
nslwt.setSlideAtomsSets(na.toArray(new SlideAtomsSet[0]));
- nslwt.setChildRecord(records.toArray(new org.apache.poi.hslf.record.Record[0]));
+ nslwt.setChildRecord(records.toArray(new Record[0]));
}
}
if (na.isEmpty()) {
@@ -759,8 +757,7 @@ public final class HSLFSlideShow extends
// Add in to the list of Slides
_slides.add(slide);
- LOG.log(POILogger.INFO, "Added slide ", _slides.size(), " with ref ", sp.getRefID(),
- " and identifier ", sp.getSlideIdentifier());
+ LOG.atInfo().log("Added slide {} with ref {} and identifier {}", box(_slides.size()),box(sp.getRefID()),box(sp.getSlideIdentifier()));
// Add the core records for this new Slide to the record tree
Slide slideRecord = slide.getSlideRecord();
@@ -1049,7 +1046,7 @@ public final class HSLFSlideShow extends
ExEmbed exEmbed = new ExEmbed();
// remove unneccessary infos, so we don't need to specify the type
// of the ole object multiple times
- org.apache.poi.hslf.record.Record[] children = exEmbed.getChildRecords();
+ Record[] children = exEmbed.getChildRecords();
exEmbed.removeChild(children[2]);
exEmbed.removeChild(children[3]);
exEmbed.removeChild(children[4]);
@@ -1115,7 +1112,7 @@ public final class HSLFSlideShow extends
private int addPersistentObject(PositionDependentRecord slideRecord) {
slideRecord.setLastOnDiskOffset(HSLFSlideShowImpl.UNSET_OFFSET);
- _hslfSlideShow.appendRootLevelRecord((org.apache.poi.hslf.record.Record)slideRecord);
+ _hslfSlideShow.appendRootLevelRecord((Record)slideRecord);
// For position dependent records, hold where they were and now are
// As we go along, update, and hand over, to any Position Dependent
@@ -1145,7 +1142,7 @@ public final class HSLFSlideShow extends
int slideOffset = slideRecord.getLastOnDiskOffset();
slideRecord.setLastOnDiskOffset(slideOffset);
ptr.addSlideLookup(psrId, slideOffset);
- LOG.log(POILogger.INFO, "New slide/object ended up at ", slideOffset);
+ LOG.atInfo().log("New slide/object ended up at {}", box(slideOffset));
return psrId;
}
Modified: poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
URL: http://svn.apache.org/viewvc/poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java?rev=1886103&r1=1886102&r2=1886103&view=diff
==============================================================================
--- poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java (original)
+++ poi/branches/log4j/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java Mon Feb 1 14:59:43 2021
@@ -17,6 +17,7 @@
package org.apache.poi.hslf.usermodel;
+import static org.apache.logging.log4j.util.Unbox.box;
import static org.apache.poi.hslf.usermodel.HSLFSlideShow.POWERPOINT_DOCUMENT;
import static org.apache.poi.hslf.usermodel.HSLFSlideShow.PP95_DOCUMENT;
import static org.apache.poi.hslf.usermodel.HSLFSlideShow.PP97_DOCUMENT;
@@ -36,6 +37,8 @@ import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.POIDocument;
import org.apache.poi.hpsf.PropertySet;
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
@@ -60,15 +63,13 @@ import org.apache.poi.sl.usermodel.Pictu
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
/**
* This class contains the main functionality for the Powerpoint file
* "reader". It is only a very basic class for now
*/
public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
- private static final POILogger LOG = POILogFactory.getLogger(HSLFSlideShowImpl.class);
+ private static final Logger LOG = LogManager.getLogger(HSLFSlideShowImpl.class);
static final int UNSET_OFFSET = -1;
@@ -82,7 +83,7 @@ public final class HSLFSlideShowImpl ext
private byte[] _docstream;
// Low level contents
- private org.apache.poi.hslf.record.Record[] _records;
+ private Record[] _records;
// Raw Pictures contained in the pictures stream
private List<HSLFPictureData> _pictures;
@@ -246,7 +247,7 @@ public final class HSLFSlideShowImpl ext
_records = read(_docstream, (int) currentUser.getCurrentEditOffset());
}
- private org.apache.poi.hslf.record.Record[] read(byte[] docstream, int usrOffset) throws IOException {
+ private Record[] read(byte[] docstream, int usrOffset) throws IOException {
//sort found records by offset.
//(it is not necessary but SlideShow.findMostRecentCoreRecords() expects them sorted)
NavigableMap<Integer, Record> records = new TreeMap<>(); // offset -> record
@@ -256,7 +257,7 @@ public final class HSLFSlideShowImpl ext
for (Map.Entry<Integer, Record> entry : records.entrySet()) {
Integer offset = entry.getKey();
- org.apache.poi.hslf.record.Record record = entry.getValue();
+ Record record = entry.getValue();
Integer persistId = persistIds.get(offset);
if (record == null) {
// all plain records have been already added,
@@ -272,7 +273,7 @@ public final class HSLFSlideShowImpl ext
}
decryptData.close();
- return records.values().toArray(new org.apache.poi.hslf.record.Record[0]);
+ return records.values().toArray(new Record[0]);
}
private void initRecordOffsets(byte[] docstream, int usrOffset, NavigableMap<Integer, Record> recordMap, Map<Integer, Integer> offset2id) {
@@ -303,7 +304,7 @@ public final class HSLFSlideShowImpl ext
int type = LittleEndian.getUShort(docstream, usrOffset + 2);
int len = LittleEndian.getInt(docstream, usrOffset + 4);
if (ver_inst == 0 && type == 4085 && (len == 0x1C || len == 0x20)) {
- LOG.log(POILogger.WARN, "Repairing invalid user edit atom");
+ LOG.atWarn().log("Repairing invalid user edit atom");
usr.setLastUserEditAtomOffset(usrOffset);
} else {
throw new CorruptPowerPointFileException("Powerpoint document contains invalid user edit atom");
@@ -313,7 +314,7 @@ public final class HSLFSlideShowImpl ext
}
public DocumentEncryptionAtom getDocumentEncryptionAtom() {
- for (org.apache.poi.hslf.record.Record r : _records) {
+ for (Record r : _records) {
if (r instanceof DocumentEncryptionAtom) {
return (DocumentEncryptionAtom) r;
}
@@ -329,7 +330,7 @@ public final class HSLFSlideShowImpl ext
try {
currentUser = new CurrentUserAtom(getDirectory());
} catch (IOException ie) {
- LOG.log(POILogger.ERROR, "Error finding Current User Atom", ie);
+ LOG.atError().withThrowable(ie).log("Error finding Current User Atom");
currentUser = new CurrentUserAtom();
}
}
@@ -393,14 +394,13 @@ public final class HSLFSlideShowImpl ext
// If they type (including the bonus 0xF018) is 0, skip it
PictureType pt = PictureType.forNativeID(type - 0xF018);
if (pt == null) {
- LOG.log(POILogger.ERROR, "Problem reading picture: Invalid image type 0, on picture with length ", imgsize, ".\nYour document will probably become corrupted if you save it!");
- LOG.log(POILogger.ERROR, "position: ", pos);
+ LOG.atError().log("Problem reading picture: Invalid image type 0, on picture with length {}.\nYour document will probably become corrupted if you save it! Position: {}", box(imgsize),box(pos));
} else {
//The pictstream can be truncated halfway through a picture.
//This is not a problem if the pictstream contains extra pictures
//that are not used in any slide -- BUG-60305
if (pos + imgsize > pictstream.length) {
- LOG.log(POILogger.WARN, "\"Pictures\" stream may have ended early. In some circumstances, this is not a problem; " +
+ LOG.atWarn().log("\"Pictures\" stream may have ended early. In some circumstances, this is not a problem; " +
"in others, this could indicate a corrupt file");
break;
}
@@ -417,7 +417,7 @@ public final class HSLFSlideShowImpl ext
pict.setIndex(_pictures.size() + 1); // index is 1-based
_pictures.add(pict);
} catch (IllegalArgumentException e) {
- LOG.log(POILogger.ERROR, "Problem reading picture: ", e, "\nYour document will probably become corrupted if you save it!");
+ LOG.atError().withThrowable(e).log("Problem reading picture. Your document will probably become corrupted if you save it!");
}
}
@@ -464,7 +464,7 @@ public final class HSLFSlideShowImpl ext
UserEditAtom usr = null;
PersistPtrHolder ptr = null;
CountingOS cos = new CountingOS();
- for (org.apache.poi.hslf.record.Record record : _records) {
+ for (Record record : _records) {
// all top level records are position dependent
assert (record instanceof PositionDependentRecord);
PositionDependentRecord pdr = (PositionDependentRecord) record;
@@ -506,7 +506,7 @@ public final class HSLFSlideShowImpl ext
}
try (HSLFSlideShowEncrypted encData = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom())) {
- for (org.apache.poi.hslf.record.Record record : _records) {
+ for (Record record : _records) {
assert (record instanceof PositionDependentRecord);
// We've already figured out their new location, and
// told them that
@@ -718,7 +718,7 @@ public final class HSLFSlideShowImpl ext
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public synchronized int appendRootLevelRecord(Record newRecord) {
int addedAt = -1;
- org.apache.poi.hslf.record.Record[] r = new org.apache.poi.hslf.record.Record[_records.length + 1];
+ Record[] r = new Record[_records.length + 1];
boolean added = false;
for (int i = (_records.length - 1); i >= 0; i--) {
if (added) {
@@ -770,7 +770,7 @@ public final class HSLFSlideShowImpl ext
/**
* Returns an array of all the records found in the slideshow
*/
- public org.apache.poi.hslf.record.Record[] getRecords() {
+ public Record[] getRecords() {
return _records;
}
@@ -815,7 +815,7 @@ public final class HSLFSlideShowImpl ext
public HSLFObjectData[] getEmbeddedObjects() {
if (_objects == null) {
List<HSLFObjectData> objects = new ArrayList<>();
- for (org.apache.poi.hslf.record.Record r : _records) {
+ for (Record r : _records) {
if (r instanceof ExOleObjStg) {
objects.add(new HSLFObjectData((ExOleObjStg) r));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org