poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1875863 - in /poi/trunk/src: examples/src/org/apache/poi/xssf/usermodel/examples/ java/org/apache/poi/sl/extractor/ java/org/apache/poi/sl/usermodel/ java/org/apache/poi/ss/util/ ooxml/java/org/apache/poi/poifs/crypt/dsig/ ooxml/java/org/a...
Date Sun, 29 Mar 2020 22:37:24 GMT
Author: kiwiwings
Date: Sun Mar 29 22:37:23 2020
New Revision: 1875863

URL: http://svn.apache.org/viewvc?rev=1875863&view=rev
Log:
Sonar Fixes
- name clashes with constants
- missing break in switch statements

Modified:
    poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarAndLineChart.java
    poi/trunk/src/java/org/apache/poi/sl/extractor/SlideShowExtractor.java
    poi/trunk/src/java/org/apache/poi/sl/usermodel/Insets2D.java
    poi/trunk/src/java/org/apache/poi/ss/util/NormalisedDecimal.java
    poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureMarshalDefaultListener.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationWorkbook.java
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/TableWidthType.java
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java

Modified: poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarAndLineChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarAndLineChart.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarAndLineChart.java
(original)
+++ poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarAndLineChart.java
Sun Mar 29 22:37:23 2020
@@ -62,10 +62,13 @@ import org.apache.poi.xssf.usermodel.XSS
 // additional title formatting from https://stackoverflow.com/questions/50418856
 // and legend positioning from https://stackoverflow.com/questions/49615379
 // this would probably be an answer for https://stackoverflow.com/questions/36447925 too
-public class BarAndLineChart {
+public final class BarAndLineChart {
+
     private static final int NUM_OF_ROWS = 7;
     private static final Random RNG = new Random();
 
+    private BarAndLineChart() {}
+
     public static void main(String[] args) throws Exception {
         try (XSSFWorkbook wb = new XSSFWorkbook()) {
             XSSFSheet sheet = wb.createSheet("Sheet1");

Modified: poi/trunk/src/java/org/apache/poi/sl/extractor/SlideShowExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/extractor/SlideShowExtractor.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/extractor/SlideShowExtractor.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/extractor/SlideShowExtractor.java Sun Mar 29 22:37:23
2020
@@ -313,14 +313,14 @@ public class SlideShowExtractor<
 
     public List<? extends ObjectShape<S,P>> getOLEShapes() {
         final List<ObjectShape<S,P>> oleShapes = new ArrayList<>();
-        
+
         for (final Slide<S,P> slide : slideshow.getSlides()) {
             addOLEShapes(oleShapes, slide);
         }
-        
+
         return oleShapes;
     }
-    
+
     @SuppressWarnings("unchecked")
     private void addOLEShapes(final List<ObjectShape<S,P>> oleShapes, ShapeContainer<S,P>
container) {
         for (Shape<S,P> shape : container) {
@@ -368,8 +368,10 @@ public class SlideShowExtractor<
         switch (tr.getTextCap()) {
             case ALL:
                 txt = txt.toUpperCase(LocaleUtil.getUserLocale());
+                break;
             case SMALL:
                 txt = txt.toLowerCase(LocaleUtil.getUserLocale());
+                break;
         }
 
         return txt;

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/Insets2D.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Insets2D.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Insets2D.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Insets2D.java Sun Mar 29 22:37:23 2020
@@ -17,11 +17,13 @@
 
 package org.apache.poi.sl.usermodel;
 
+import org.apache.poi.common.Duplicatable;
+
 /**
  * This is a replacement for {@link java.awt.Insets} which works on doubles
  * instead of ints
  */
-public final class Insets2D implements Cloneable {
+public final class Insets2D implements Duplicatable {
 
     /**
      * The inset from the top.
@@ -50,10 +52,10 @@ public final class Insets2D implements C
      * to yield a new location for the Right edge.
      */
     public double right;
-    
+
     /**
-     * Creates and initializes a new <code>Insets</code> object with the 
-     * specified top, left, bottom, and right insets. 
+     * Creates and initializes a new <code>Insets</code> object with the
+     * specified top, left, bottom, and right insets.
      * @param       top   the inset from the top.
      * @param       left   the inset from the left.
      * @param       bottom   the inset from the bottom.
@@ -83,9 +85,9 @@ public final class Insets2D implements C
     }
 
     /**
-     * Checks whether two insets objects are equal. Two instances 
+     * Checks whether two insets objects are equal. Two instances
      * of <code>Insets</code> are equal if the four integer values
-     * of the fields <code>top</code>, <code>left</code>, 
+     * of the fields <code>top</code>, <code>left</code>,
      * <code>bottom</code>, and <code>right</code> are all equal.
      * @return      <code>true</code> if the two insets are equal;
      *                          otherwise <code>false</code>.
@@ -115,12 +117,12 @@ public final class Insets2D implements C
     }
 
     /**
-     * Returns a string representation of this <code>Insets</code> object. 
-     * This method is intended to be used only for debugging purposes, and 
-     * the content and format of the returned string may vary between 
-     * implementations. The returned string may be empty but may not be 
+     * Returns a string representation of this <code>Insets</code> object.
+     * This method is intended to be used only for debugging purposes, and
+     * the content and format of the returned string may vary between
+     * implementations. The returned string may be empty but may not be
      * <code>null</code>.
-     * 
+     *
      * @return  a string representation of this <code>Insets</code> object.
      */
     public String toString() {
@@ -132,9 +134,9 @@ public final class Insets2D implements C
      * @return     a copy of this <code>Insets2D</code> object.
      */
     @Override
-    public Insets2D clone() {
+    public Insets2D copy() {
         return new Insets2D(top, left, bottom, right);
     }
-    
+
 
 }

Modified: poi/trunk/src/java/org/apache/poi/ss/util/NormalisedDecimal.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/NormalisedDecimal.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/NormalisedDecimal.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/NormalisedDecimal.java Sun Mar 29 22:37:23 2020
@@ -72,7 +72,7 @@ final class NormalisedDecimal {
 	private static final long MAX_REP_WHOLE_PART = 0x38D7EA4C68000L;
 
 
-
+	@SuppressWarnings("java:S128")
 	public static NormalisedDecimal create(BigInteger frac, int binaryExponent) {
 		// estimate pow2&pow10 first, perform optional mulShift, then normalize
 		int pow10;
@@ -167,7 +167,7 @@ final class NormalisedDecimal {
 	 * Convert to an equivalent {@link ExpandedDouble} representation (binary frac and exponent).
 	 * The resulting transformed object is easily converted to a 64 bit IEEE double:
 	 * <ul>
-	 * <li>bits 2-53 of the {@link #getSignificand()} become the 52 bit 'fraction'.</li>
+	 * <li>bits 2-53 of the {@link #composeFrac()} become the 52 bit 'fraction'.</li>
 	 * <li>{@link #getBinaryExponent()} is biased by 1023 to give the 'exponent'.</li>
 	 * </ul>
 	 * The sign bit must be obtained from somewhere else.
@@ -184,21 +184,7 @@ final class NormalisedDecimal {
 	 * @return the significand as a fixed point number (with 24 fraction bits and 47-50 whole
bits)
 	 */
 	BigInteger composeFrac() {
-		long wp = _wholePart;
-		int fp = _fractionalPart;
-		return new BigInteger(new byte[] {
-				(byte) (wp >> 56), // N.B. assuming sign bit is zero
-				(byte) (wp >> 48),
-				(byte) (wp >> 40),
-				(byte) (wp >> 32),
-				(byte) (wp >> 24),
-				(byte) (wp >> 16),
-				(byte) (wp >>  8),
-				(byte) (wp >>  0),
-				(byte) (fp >> 16),
-				(byte) (fp >> 8),
-				(byte) (fp >> 0),
-		});
+		return BigInteger.valueOf(_wholePart).shiftLeft(24).or(BigInteger.valueOf(_fractionalPart
& 0x00FFFFFF));
 	}
 
 	public String getSignificantDecimalDigits() {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureMarshalDefaultListener.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureMarshalDefaultListener.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureMarshalDefaultListener.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureMarshalDefaultListener.java
Sun Mar 29 22:37:23 2020
@@ -42,8 +42,8 @@ import org.w3c.dom.traversal.NodeIterato
  * e.g. to register id attributes or set prefixes for registered namespaces
  */
 public class SignatureMarshalDefaultListener implements SignatureMarshalListener {
+    private static final String OBJECT_TAG = "Object";
     private final Set<String> IGNORE_NS = new HashSet<>(Arrays.asList(null, XML_NS,
XML_DIGSIG_NS));
-    private final String OBJECT_TAG = "Object";
 
     @Override
     public void handleElement(SignatureInfo signatureInfo, Document doc, EventTarget target,
EventListener parentListener) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java Sun
Mar 29 22:37:23 2020
@@ -18,6 +18,8 @@
 package org.apache.poi.xddf.usermodel.text;
 
 import java.util.Locale;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
 
 import org.apache.poi.util.Beta;
 import org.apache.poi.util.Internal;
@@ -36,6 +38,7 @@ import org.apache.poi.xddf.usermodel.XDD
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont;
 
+@SuppressWarnings("unused")
 @Beta
 public class XDDFRunProperties {
     private CTTextCharacterProperties props;
@@ -55,95 +58,43 @@ public class XDDFRunProperties {
     }
 
     public void setBaseline(Integer value) {
-        if (value == null) {
-            if (props.isSetBaseline()) {
-                props.unsetBaseline();
-            }
-        } else {
-            props.setBaseline(value);
-        }
+        update(props::isSetBaseline, props::unsetBaseline, props::setBaseline, value);
     }
 
     public void setDirty(Boolean dirty) {
-        if (dirty == null) {
-            if (props.isSetDirty()) {
-                props.unsetDirty();
-            }
-        } else {
-            props.setDirty(dirty);
-        }
+        update(props::isSetDirty, props::unsetDirty, props::setDirty, dirty);
     }
 
     public void setSpellError(Boolean error) {
-        if (error == null) {
-            if (props.isSetErr()) {
-                props.unsetErr();
-            }
-        } else {
-            props.setErr(error);
-        }
+        update(props::isSetErr, props::unsetErr, props::setErr, error);
     }
 
     public void setNoProof(Boolean noproof) {
-        if (noproof == null) {
-            if (props.isSetNoProof()) {
-                props.unsetNoProof();
-            }
-        } else {
-            props.setNoProof(noproof);
-        }
+        update(props::isSetNoProof, props::unsetNoProof, props::setNoProof, noproof);
     }
 
     public void setNormalizeHeights(Boolean normalize) {
-        if (normalize == null) {
-            if (props.isSetNormalizeH()) {
-                props.unsetNormalizeH();
-            }
-        } else {
-            props.setNormalizeH(normalize);
-        }
+        update(props::isSetNormalizeH, props::unsetNormalizeH, props::setNormalizeH, normalize);
     }
 
     public void setKumimoji(Boolean kumimoji) {
-        if (kumimoji == null) {
-            if (props.isSetKumimoji()) {
-                props.unsetKumimoji();
-            }
-        } else {
-            props.setKumimoji(kumimoji);
-        }
+        update(props::isSetKumimoji, props::unsetKumimoji, props::setKumimoji, kumimoji);
     }
 
     public void setBold(Boolean bold) {
-        if (bold == null) {
-            if (props.isSetB()) {
-                props.unsetB();
-            }
-        } else {
-            props.setB(bold);
-        }
+        update(props::isSetB, props::unsetB, props::setB, bold);
     }
 
     public void setItalic(Boolean italic) {
-        if (italic == null) {
-            if (props.isSetI()) {
-                props.unsetI();
-            }
-        } else {
-            props.setI(italic);
-        }
+        update(props::isSetI, props::unsetI, props::setI, italic);
     }
 
     public void setFontSize(Double size) {
-        if (size == null) {
-            if (props.isSetSz()) {
-                props.unsetSz();
-            }
-        } else if (size < 1 || 400 < size) {
+        if (size != null && (size < 1 || 400 < size)) {
             throw new IllegalArgumentException("Minimum inclusive = 1. Maximum inclusive
= 400.");
-        } else {
-            props.setSz((int)(100 * size));
         }
+
+        update(props::isSetSz, props::unsetSz, props::setSz, size == null ? null : (int)(100
* size));
     }
 
     public void setFillProperties(XDDFFillProperties properties) {
@@ -184,27 +135,19 @@ public class XDDFRunProperties {
     }
 
     public void setCharacterKerning(Double kerning) {
-        if (kerning == null) {
-            if (props.isSetKern()) {
-                props.unsetKern();
-            }
-        } else if (kerning < 0 || 4000 < kerning) {
+        if (kerning != null && (kerning < 0 || 4000 < kerning)) {
             throw new IllegalArgumentException("Minimum inclusive = 0. Maximum inclusive
= 4000.");
-        } else {
-            props.setKern((int) (100 * kerning));
         }
+
+        update(props::isSetKern, props::unsetKern, props::setKern, kerning == null ? null
: (int)(100 * kerning));
     }
 
     public void setCharacterSpacing(Double spacing) {
-        if (spacing == null) {
-            if (props.isSetSpc()) {
-                props.unsetSpc();
-            }
-        } else if (spacing < -4000 || 4000 < spacing) {
+        if (spacing != null && (spacing < -4000 || 4000 < spacing)) {
             throw new IllegalArgumentException("Minimum inclusive = -4000. Maximum inclusive
= 4000.");
-        } else {
-            props.setSpc((int) (100 * spacing));
         }
+
+        update(props::isSetSpc, props::unsetSpc, props::setSpc, spacing == null ? null :
(int)(100 * spacing));
     }
 
     public void setFonts(XDDFFont[] fonts) {
@@ -212,139 +155,59 @@ public class XDDFRunProperties {
             CTTextFont xml = font.getXmlObject();
             switch (font.getGroup()) {
             case COMPLEX_SCRIPT:
-                if (xml == null) {
-                    if (props.isSetCs()) {
-                        props.unsetCs();
-                    }
-                } else {
-                    props.setCs(xml);
-                }
+                update(props::isSetCs, props::unsetCs, props::setCs, xml);
+                break;
             case EAST_ASIAN:
-                if (xml == null) {
-                    if (props.isSetEa()) {
-                        props.unsetEa();
-                    }
-                } else {
-                    props.setEa(xml);
-                }
+                update(props::isSetEa, props::unsetEa, props::setEa, xml);
+                break;
             case LATIN:
-                if (xml == null) {
-                    if (props.isSetLatin()) {
-                        props.unsetLatin();
-                    }
-                } else {
-                    props.setLatin(xml);
-                }
+                update(props::isSetLatin, props::unsetLatin, props::setLatin, xml);
+                break;
             case SYMBOL:
-                if (xml == null) {
-                    if (props.isSetSym()) {
-                        props.unsetSym();
-                    }
-                } else {
-                    props.setSym(xml);
-                }
+                update(props::isSetSym, props::unsetSym, props::setSym, xml);
+                break;
             }
         }
     }
 
     public void setUnderline(UnderlineType underline) {
-        if (underline == null) {
-            if (props.isSetU()) {
-                props.unsetU();
-            }
-        } else {
-            props.setU(underline.underlying);
-        }
+        update(props::isSetU, props::unsetU, props::setU, underline == null ? null : underline.underlying);
     }
 
     public void setStrikeThrough(StrikeType strike) {
-        if (strike == null) {
-            if (props.isSetStrike()) {
-                props.unsetStrike();
-            }
-        } else {
-            props.setStrike(strike.underlying);
-        }
+        update(props::isSetStrike, props::unsetStrike, props::setStrike, strike == null ?
null : strike.underlying);
     }
 
     public void setCapitals(CapsType caps) {
-        if (caps == null) {
-            if (props.isSetCap()) {
-                props.unsetCap();
-            }
-        } else {
-            props.setCap(caps.underlying);
-        }
+        update(props::isSetCap, props::unsetCap, props::setCap, caps == null ? null : caps.underlying);
     }
 
     public void setHyperlink(XDDFHyperlink link) {
-        if (link == null) {
-            if (props.isSetHlinkClick()) {
-                props.unsetHlinkClick();
-            }
-        } else {
-            props.setHlinkClick(link.getXmlObject());
-        }
+        update(props::isSetHlinkClick, props::unsetHlinkClick, props::setHlinkClick, link
== null ? null : link.getXmlObject());
     }
 
     public void setMouseOver(XDDFHyperlink link) {
-        if (link == null) {
-            if (props.isSetHlinkMouseOver()) {
-                props.unsetHlinkMouseOver();
-            }
-        } else {
-            props.setHlinkMouseOver(link.getXmlObject());
-        }
+        update(props::isSetHlinkMouseOver, props::unsetHlinkMouseOver, props::setHlinkMouseOver,
link == null ? null : link.getXmlObject());
     }
 
     public void setLanguage(Locale lang) {
-        if (lang == null) {
-            if (props.isSetLang()) {
-                props.unsetLang();
-            }
-        } else {
-            props.setLang(lang.toLanguageTag());
-        }
+        update(props::isSetLang, props::unsetLang, props::setLang, lang == null ? null :
lang.toLanguageTag());
     }
 
     public void setAlternativeLanguage(Locale lang) {
-        if (lang == null) {
-            if (props.isSetAltLang()) {
-                props.unsetAltLang();
-            }
-        } else {
-            props.setAltLang(lang.toLanguageTag());
-        }
+        update(props::isSetAltLang, props::unsetAltLang, props::setAltLang, lang == null
? null : lang.toLanguageTag());
     }
 
     public void setHighlight(XDDFColor color) {
-        if (color == null) {
-            if (props.isSetHighlight()) {
-                props.unsetHighlight();
-            }
-        } else {
-            props.setHighlight(color.getColorContainer());
-        }
+        update(props::isSetHighlight, props::unsetHighlight, props::setHighlight, color ==
null ? null : color.getColorContainer());
     }
 
     public void setLineProperties(XDDFLineProperties properties) {
-        if (properties == null) {
-            if (props.isSetLn()) {
-                props.unsetLn();
-            }
-        } else {
-            props.setLn(properties.getXmlObject());
-        }
+        update(props::isSetLn, props::unsetLn, props::setLn, properties == null ? null :
properties.getXmlObject());
     }
 
     public void setBookmark(String bookmark) {
-        if (bookmark == null) {
-            if (props.isSetBmk()) {
-                props.unsetBmk();
-            }
-        } else {
-            props.setBmk(bookmark);
-        }
+        update(props::isSetBmk, props::unsetBmk, props::setBmk, bookmark);
     }
 
     public XDDFExtensionList getExtensionList() {
@@ -356,13 +219,7 @@ public class XDDFRunProperties {
     }
 
     public void setExtensionList(XDDFExtensionList list) {
-        if (list == null) {
-            if (props.isSetExtLst()) {
-                props.unsetExtLst();
-            }
-        } else {
-            props.setExtLst(list.getXmlObject());
-        }
+        update(props::isSetExtLst, props::unsetExtLst, props::setExtLst, list == null ? null
: list.getXmlObject());
     }
 
     public XDDFEffectContainer getEffectContainer() {
@@ -374,13 +231,7 @@ public class XDDFRunProperties {
     }
 
     public void setEffectContainer(XDDFEffectContainer container) {
-        if (container == null) {
-            if (props.isSetEffectDag()) {
-                props.unsetEffectDag();
-            }
-        } else {
-            props.setEffectDag(container.getXmlObject());
-        }
+        update(props::isSetEffectDag, props::unsetEffectDag, props::setEffectDag, container
== null ? null : container.getXmlObject());
     }
 
     public XDDFEffectList getEffectList() {
@@ -392,12 +243,14 @@ public class XDDFRunProperties {
     }
 
     public void setEffectList(XDDFEffectList list) {
-        if (list == null) {
-            if (props.isSetEffectLst()) {
-                props.unsetEffectLst();
-            }
-        } else {
-            props.setEffectLst(list.getXmlObject());
+        update(props::isSetEffectLst, props::unsetEffectLst, props::setEffectLst, list ==
null ? null : list.getXmlObject());
+    }
+
+    private static <T> void update(Supplier<Boolean> isSet, Runnable unset, Consumer<T>
setter, T val) {
+        if (val != null) {
+            setter.accept(val);
+        } else if (isSet.get()) {
+            unset.run();
         }
     }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationWorkbook.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationWorkbook.java Sun
Mar 29 22:37:23 2020
@@ -22,42 +22,42 @@ import org.apache.poi.ss.formula.Evaluat
 import org.apache.poi.ss.formula.FormulaParser;
 import org.apache.poi.ss.formula.FormulaType;
 import org.apache.poi.ss.formula.ptg.Ptg;
-import org.apache.poi.xssf.usermodel.BaseXSSFEvaluationWorkbook;
 import org.apache.poi.util.Internal;
+import org.apache.poi.xssf.usermodel.BaseXSSFEvaluationWorkbook;
 
 /**
  * SXSSF wrapper around the SXSSF and XSSF workbooks
  */
 @Internal
 public final class SXSSFEvaluationWorkbook extends BaseXSSFEvaluationWorkbook {
-    private final SXSSFWorkbook _uBook;
-    
+    private final SXSSFWorkbook _sxssfBook;
+
     public static SXSSFEvaluationWorkbook create(SXSSFWorkbook book) {
         if (book == null) {
             return null;
         }
         return new SXSSFEvaluationWorkbook(book);
     }
-    
+
     private SXSSFEvaluationWorkbook(SXSSFWorkbook book) {
         super(book.getXSSFWorkbook());
-        _uBook = book;
+        _sxssfBook = book;
     }
 
     @Override
     public int getSheetIndex(EvaluationSheet evalSheet) {
         SXSSFSheet sheet = ((SXSSFEvaluationSheet)evalSheet).getSXSSFSheet();
-        return _uBook.getSheetIndex(sheet);
+        return _sxssfBook.getSheetIndex(sheet);
     }
 
     @Override
     public EvaluationSheet getSheet(int sheetIndex) {
-        return new SXSSFEvaluationSheet(_uBook.getSheetAt(sheetIndex));
+        return new SXSSFEvaluationSheet(_sxssfBook.getSheetAt(sheetIndex));
     }
 
     @Override
     public Ptg[] getFormulaTokens(EvaluationCell evalCell) {
         SXSSFCell cell = ((SXSSFEvaluationCell)evalCell).getSXSSFCell();
-        return FormulaParser.parse(cell.getCellFormula(), this, FormulaType.CELL, _uBook.getSheetIndex(cell.getSheet()));
+        return FormulaParser.parse(cell.getCellFormula(), this, FormulaType.CELL, _sxssfBook.getSheetIndex(cell.getSheet()));
     }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/TableWidthType.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/TableWidthType.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/TableWidthType.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/TableWidthType.java Sun Mar 29
22:37:23 2020
@@ -29,7 +29,7 @@ public enum TableWidthType {
     AUTO(STTblWidth.AUTO), /* Width is determined by content. */
     DXA(STTblWidth.DXA),   /* Width is an integer number of 20ths of a point (twips) */
     NIL(STTblWidth.NIL),   /* No width value set */
-    PCT(STTblWidth.PCT);   /* Width is a percentage, e.g. "33.3%" or 50 times percentage
value, rounded to an integer, */ 
+    PCT(STTblWidth.PCT);   /* Width is a percentage, e.g. "33.3%" or 50 times percentage
value, rounded to an integer, */
                            /* e.g. 2500 for 50% */
 
     private Enum type = STTblWidth.NIL;
@@ -37,11 +37,7 @@ public enum TableWidthType {
     TableWidthType(STTblWidth.Enum type) {
         this.type = type;
     }
-    
-    protected STTblWidth.Enum getSTWidthType() {
-        return this.type;
-    }
-    
+
     /**
      * Get the underlying STTblWidth enum value.
      *

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java Sun Mar 29 22:37:23
2020
@@ -1294,7 +1294,7 @@ public class XWPFTable implements IBodyE
     protected static void setWidthType(TableWidthType widthType, CTTblWidth ctWidth) {
         TableWidthType currentType = getWidthType(ctWidth);
         if (!currentType.equals(widthType)) {
-            STTblWidth.Enum stWidthType = widthType.getSTWidthType();
+            STTblWidth.Enum stWidthType = widthType.getStWidthType();
             ctWidth.setType(stWidthType);
             switch (stWidthType.intValue()) {
             case STTblWidth.INT_PCT:

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java Sun
Mar 29 22:37:23 2020
@@ -521,7 +521,7 @@ public class HemfPlusBrush {
         private EmfPlusWrapMode wrapMode;
         private Rectangle2D rect = new Rectangle2D.Double();
         private Color startColor, endColor;
-        private AffineTransform transform;
+        private AffineTransform blendTransform;
         private float[] positions;
         private Color[] blendColors;
         private float[] positionsV;
@@ -556,7 +556,7 @@ public class HemfPlusBrush {
             size += 4*LittleEndianConsts.INT_SIZE;
 
             if (TRANSFORM.isSet(dataFlags)) {
-                size += readXForm(leis, (transform = new AffineTransform()));
+                size += readXForm(leis, (blendTransform = new AffineTransform()));
             }
 
             if (isPreset() && (isBlendH() || isBlendV())) {
@@ -575,7 +575,7 @@ public class HemfPlusBrush {
             HemfDrawProperties prop = ctx.getProperties();
             prop.setBrushStyle(HwmfBrushStyle.BS_LINEAR_GRADIENT);
             prop.setBrushRect(rect);
-            prop.setBrushTransform(transform);
+            prop.setBrushTransform(blendTransform);
 
             // Preset colors and BlendH/V are mutual exclusive
             if (isPreset()) {
@@ -613,7 +613,7 @@ public class HemfPlusBrush {
             m.put("rect", () -> rect);
             m.put("startColor", () -> startColor);
             m.put("endColor", () -> endColor);
-            m.put("transform", () -> transform);
+            m.put("blendTransform", () -> blendTransform);
             m.put("positions", () -> positions);
             m.put("blendColors", () -> blendColors);
             m.put("positionsV", () -> positionsV);
@@ -694,7 +694,7 @@ public class HemfPlusBrush {
         private Color[] surroundingColor;
         private EmfPlusPath boundaryPath;
         private Point2D[] boundaryPoints;
-        private AffineTransform transform;
+        private AffineTransform blendTransform;
         private float[] positions;
         private Color[] blendColors;
         private float[] blendFactorsH;
@@ -761,7 +761,7 @@ public class HemfPlusBrush {
             // the path gradient brush. This field MUST be present if the BrushDataTransform
flag is set in the
             // BrushDataFlags field of the EmfPlusPathGradientBrushData object.
             if (TRANSFORM.isSet(dataFlags)) {
-                size += readXForm(leis, (transform = new AffineTransform()));
+                size += readXForm(leis, (blendTransform = new AffineTransform()));
             }
 
             // An optional blend pattern for the path gradient brush. If this field is present,
it MUST contain either
@@ -825,7 +825,7 @@ public class HemfPlusBrush {
             m.put("surroundingColor", () -> surroundingColor);
             m.put("boundaryPath", () -> boundaryPath);
             m.put("boundaryPoints", () -> boundaryPoints);
-            m.put("transform", () -> transform);
+            m.put("blendTransform", () -> blendTransform);
             m.put("positions", () -> positions);
             m.put("blendColors", () -> blendColors);
             m.put("blendFactorsH", () -> blendFactorsH);
@@ -839,7 +839,7 @@ public class HemfPlusBrush {
     public static class EmfPlusTextureBrushData implements EmfPlusBrushData {
         private int dataFlags;
         private EmfPlusWrapMode wrapMode;
-        private AffineTransform transform;
+        private AffineTransform brushTransform;
         private EmfPlusImage image;
 
         @Override
@@ -855,7 +855,7 @@ public class HemfPlusBrush {
             int size = 2*LittleEndianConsts.INT_SIZE;
 
             if (TRANSFORM.isSet(dataFlags)) {
-                size += readXForm(leis, (transform = new AffineTransform()));
+                size += readXForm(leis, (brushTransform = new AffineTransform()));
             }
 
             if (dataSize > size) {
@@ -871,7 +871,7 @@ public class HemfPlusBrush {
             image.applyObject(ctx, null);
             prop.setBrushBitmap(prop.getEmfPlusImage());
             prop.setBrushStyle(HwmfBrushStyle.BS_PATTERN);
-            prop.setBrushTransform(transform);
+            prop.setBrushTransform(brushTransform);
         }
 
         @Override
@@ -894,7 +894,7 @@ public class HemfPlusBrush {
             return GenericRecordUtil.getGenericProperties(
                 "dataFlags", () -> dataFlags,
                 "wrapMode", () -> wrapMode,
-                "transform", () -> transform,
+                "brushTransform", () -> brushTransform,
                 "image", () -> image
             );
         }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java Sun Mar 29
22:37:23 2020
@@ -45,15 +45,15 @@ public final class TextRulerAtom extends
 
     //arbitrarily selected; may need to increase
     private static final int MAX_RECORD_LENGTH = 100_000;
-    
+
     private static final BitField DEFAULT_TAB_SIZE = getInstance(0x0001);
     private static final BitField C_LEVELS = getInstance(0x0002);
     private static final BitField TAB_STOPS = getInstance(0x0004);
-    private static final BitField[] LEFT_MARGIN = {
+    private static final BitField[] LEFT_MARGIN_LVL_MASK = {
         getInstance(0x0008), getInstance(0x0010), getInstance(0x0020),
         getInstance(0x0040), getInstance(0x0080),
     };
-    private static final BitField[] INDENT = {
+    private static final BitField[] INDENT_LVL_MASK = {
         getInstance(0x0100), getInstance(0x0200), getInstance(0x0400),
         getInstance(0x0800), getInstance(0x1000),
     };
@@ -87,9 +87,9 @@ public final class TextRulerAtom extends
      * @param start the start offset into the byte array.
      * @param len the length of the slice in the byte array.
      */
-    protected TextRulerAtom(final byte[] source, final int start, final int len) {
+    TextRulerAtom(final byte[] source, final int start, final int len) {
         final LittleEndianByteArrayInputStream leis = new LittleEndianByteArrayInputStream(source,
start, Math.min(len, MAX_RECORD_LENGTH));
-        
+
 
         try {
             // Get the header.
@@ -128,8 +128,8 @@ public final class TextRulerAtom extends
         mask |= writeIf(lbos, defaultTabSize, DEFAULT_TAB_SIZE);
         mask |= writeIf(lbos, tabStops, TAB_STOPS);
         for (int i=0; i<5; i++) {
-            mask |= writeIf(lbos, leftMargin[i], LEFT_MARGIN[i]);
-            mask |= writeIf(lbos, indent[i], INDENT[i]);
+            mask |= writeIf(lbos, leftMargin[i], LEFT_MARGIN_LVL_MASK[i]);
+            mask |= writeIf(lbos, indent[i], INDENT_LVL_MASK[i]);
         }
         LittleEndian.putInt(_header, 4, bos.size()+4);
         out.write(_header);
@@ -146,7 +146,8 @@ public final class TextRulerAtom extends
         }
         return bit.setBoolean(0, isSet);
     }
-    
+
+    @SuppressWarnings("SameParameterValue")
     private static int writeIf(final LittleEndianOutputStream lbos, List<HSLFTabStop>
value, BitField bit) {
         boolean isSet = false;
         if (value != null && !value.isEmpty()) {
@@ -155,7 +156,7 @@ public final class TextRulerAtom extends
         }
         return bit.setBoolean(0, isSet);
     }
-    
+
     /**
      * Read the record bytes and initialize the internal variables
      */
@@ -167,15 +168,15 @@ public final class TextRulerAtom extends
             tabStops.addAll(HSLFTabStopPropCollection.readTabStops(leis));
         }
         for (int i=0; i<5; i++) {
-            leftMargin[i] = readIf(leis, mask, LEFT_MARGIN[i]);
-            indent[i] = readIf(leis, mask, INDENT[i]);
+            leftMargin[i] = readIf(leis, mask, LEFT_MARGIN_LVL_MASK[i]);
+            indent[i] = readIf(leis, mask, INDENT_LVL_MASK[i]);
         }
     }
 
     private static Integer readIf(final LittleEndianByteArrayInputStream leis, final int
mask, final BitField bit) {
         return (bit.isSet(mask)) ? (int)leis.readShort() : null;
-    }    
-    
+    }
+
     /**
      * Default distance between tab stops, in master coordinates (576 dpi).
      */

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java?rev=1875863&r1=1875862&r2=1875863&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java Sun Mar 29 22:37:23
2020
@@ -297,7 +297,7 @@ public class HwmfGraphics {
      * Applies the object table entry
      *
      * @param index the index of the object table entry (0-based)
-     * 
+     *
      * @throws IndexOutOfBoundsException if the index is out of range
      * @throws NoSuchElementException if the entry was deleted before
      */
@@ -308,10 +308,10 @@ public class HwmfGraphics {
         }
         ote.applyObject(this);
     }
-    
+
     /**
      * Unsets (deletes) the object table entry for further usage
-     * 
+     *
      * When a META_DELETEOBJECT record (section 2.3.4.7) is received that specifies this
      * object's particular index, the object's resources are released, the binding to its
      * WMF Object Table index is ended, and the index value is returned to the pool of
@@ -319,7 +319,7 @@ public class HwmfGraphics {
      * created by another Object Record Type record.
      *
      * @param index the index (0-based)
-     * 
+     *
      * @throws IndexOutOfBoundsException if the index is out of range
      */
     public void unsetObjectTableEntry(int index) {
@@ -331,7 +331,7 @@ public class HwmfGraphics {
         objectTable.remove(index);
         objectIndexes.clear(index);
     }
-    
+
     /**
      * Saves the current properties to the stack
      */
@@ -343,7 +343,7 @@ public class HwmfGraphics {
         propStack.add(p);
         prop = newProperties(p);
     }
-    
+
     /**
      * Restores the properties from the stack
      *
@@ -444,11 +444,11 @@ public class HwmfGraphics {
         if (font == null || text == null || text.length == 0) {
             return;
         }
-        
+
         double fontH = getFontHeight(font);
         // TODO: another approx. ...
         double fontW = fontH/1.8;
-        
+
         Charset charset;
         if (isUnicode) {
             charset = Charsets.UTF_16LE;
@@ -552,6 +552,7 @@ public class HwmfGraphics {
         switch (valign) {
             case TOP:
                 tx.translate(0, layout.getAscent());
+                break;
             default:
             case BASELINE:
                 break;
@@ -617,7 +618,7 @@ public class HwmfGraphics {
         }
         as.addAttribute(TextAttribute.WEIGHT, awtFW);
     }
-    
+
     private double getFontHeight(HwmfFont font) {
         // see HwmfFont#height for details
         double fontHeight = font.getHeight();
@@ -626,9 +627,9 @@ public class HwmfGraphics {
         } else if (fontHeight < 0) {
             return -fontHeight;
         } else {
-            // TODO: fix font height calculation 
+            // TODO: fix font height calculation
             // the height is given as font size + ascent + descent
-            // as an approximation we reduce the height by a static factor 
+            // as an approximation we reduce the height by a static factor
             return fontHeight*3/4;
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message