From commits-return-11887-archive-asf-public=cust-asf.ponee.io@poi.apache.org Fri Dec 14 01:44:46 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 5212E180609 for ; Fri, 14 Dec 2018 01:44:44 +0100 (CET) Received: (qmail 25548 invoked by uid 500); 14 Dec 2018 00:44:43 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 25520 invoked by uid 99); 14 Dec 2018 00:44:43 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Dec 2018 00:44:43 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 9C5DD3A2214 for ; Fri, 14 Dec 2018 00:44:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1848906 [1/3] - in /poi/branches/hemf: ./ src/examples/src/org/apache/poi/xslf/usermodel/ src/examples/src/org/apache/poi/xwpf/usermodel/examples/ src/integrationtest/org/apache/poi/ src/integrationtest/org/apache/poi/stress/ src/java/org/... Date: Fri, 14 Dec 2018 00:44:41 -0000 To: commits@poi.apache.org From: kiwiwings@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20181214004442.9C5DD3A2214@svn01-us-west.apache.org> Author: kiwiwings Date: Fri Dec 14 00:44:40 2018 New Revision: 1848906 URL: http://svn.apache.org/viewvc?rev=1848906&view=rev Log: merge trunk Added: poi/branches/hemf/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java - copied unchanged from r1848905, poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/ChartFromScratch.java - copied unchanged from r1848905, poi/trunk/src/examples/src/org/apache/poi/xwpf/usermodel/examples/ChartFromScratch.java poi/branches/hemf/src/java/org/apache/poi/ss/formula/SheetRangeAndWorkbookIndexFormatter.java - copied unchanged from r1848905, poi/trunk/src/java/org/apache/poi/ss/formula/SheetRangeAndWorkbookIndexFormatter.java poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBackground.java - copied unchanged from r1848905, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBackground.java poi/branches/hemf/src/testcases/org/apache/poi/poifs/filesystem/TestFileMagic.java - copied unchanged from r1848905, poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileMagic.java poi/branches/hemf/src/testcases/org/apache/poi/ss/formula/SheetRangeAndWorkbookIndexFormatterTest.java - copied unchanged from r1848905, poi/trunk/src/testcases/org/apache/poi/ss/formula/SheetRangeAndWorkbookIndexFormatterTest.java poi/branches/hemf/test-data/document/60316.docx - copied unchanged from r1848905, poi/trunk/test-data/document/60316.docx poi/branches/hemf/test-data/document/60316b.dotx - copied unchanged from r1848905, poi/trunk/test-data/document/60316b.dotx poi/branches/hemf/test-data/slideshow/customGeo.ppt - copied unchanged from r1848905, poi/trunk/test-data/slideshow/customGeo.ppt poi/branches/hemf/test-data/slideshow/customGeo.pptx - copied unchanged from r1848905, poi/trunk/test-data/slideshow/customGeo.pptx poi/branches/hemf/test-data/slideshow/keyframes.pptx - copied unchanged from r1848905, poi/trunk/test-data/slideshow/keyframes.pptx poi/branches/hemf/test-data/slideshow/pp40only.ppt - copied unchanged from r1848905, poi/trunk/test-data/slideshow/pp40only.ppt Removed: poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java Modified: poi/branches/hemf/ (props changed) poi/branches/hemf/build.xml poi/branches/hemf/doap_POI.rdf poi/branches/hemf/src/integrationtest/org/apache/poi/TestAllFiles.java poi/branches/hemf/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java poi/branches/hemf/src/java/org/apache/poi/ddf/EscherProperties.java poi/branches/hemf/src/java/org/apache/poi/hpsf/VariantSupport.java poi/branches/hemf/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java poi/branches/hemf/src/java/org/apache/poi/hssf/model/InternalWorkbook.java poi/branches/hemf/src/java/org/apache/poi/hssf/record/RecordInputStream.java poi/branches/hemf/src/java/org/apache/poi/hssf/record/SSTRecord.java poi/branches/hemf/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java poi/branches/hemf/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java poi/branches/hemf/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java poi/branches/hemf/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptor.java poi/branches/hemf/src/java/org/apache/poi/poifs/filesystem/FileMagic.java poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawBackground.java poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawPaint.java poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawTableShape.java poi/branches/hemf/src/java/org/apache/poi/sl/draw/PathGradientPaint.java poi/branches/hemf/src/java/org/apache/poi/sl/draw/geom/Context.java poi/branches/hemf/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java poi/branches/hemf/src/java/org/apache/poi/sl/usermodel/FreeformShape.java poi/branches/hemf/src/java/org/apache/poi/ss/formula/SheetNameFormatter.java poi/branches/hemf/src/java/org/apache/poi/ss/formula/functions/MatrixFunction.java poi/branches/hemf/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java poi/branches/hemf/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java poi/branches/hemf/src/java/org/apache/poi/util/RecordFormatException.java poi/branches/hemf/src/java/org/apache/poi/util/StringUtil.java poi/branches/hemf/src/java/org/apache/poi/util/Units.java poi/branches/hemf/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java poi/branches/hemf/src/ooxml/java/org/apache/poi/ooxml/extractor/CommandLineTextExtractor.java poi/branches/hemf/src/ooxml/java/org/apache/poi/ooxml/util/POIXMLConstants.java poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java poi/branches/hemf/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureOutputStream.java poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFDrawing.java poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java poi/branches/hemf/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFChart.java poi/branches/hemf/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java poi/branches/hemf/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java poi/branches/hemf/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xddf/usermodel/TestNecessaryOOXMLClasses.java poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xdgf/extractor/TestXDGFVisioExtractor.java poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/XSSFTestDataSamples.java poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFAutoShape.java poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/model/AllHSLFModelTests.java poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/AllHSLFUserModelTests.java poi/branches/hemf/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java poi/branches/hemf/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java Propchange: poi/branches/hemf/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Dec 14 00:44:40 2018 @@ -1,6 +1,7 @@ /poi/branches/common_sl:1661320-1691849 /poi/branches/excelant:1069732-1073692 /poi/branches/gsoc2012:1341450-1371650 +/poi/branches/hemf:1843341 /poi/branches/hssf_cryptoapi:1753906-1762715 /poi/branches/ss_border_property_template:1747847-1748074 /poi/branches/xml_signature:1617139-1628347 Modified: poi/branches/hemf/build.xml URL: http://svn.apache.org/viewvc/poi/branches/hemf/build.xml?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/build.xml (original) +++ poi/branches/hemf/build.xml Fri Dec 14 00:44:40 2018 @@ -60,6 +60,10 @@ under the License. + + + + - - - - - - - - - - @@ -1180,6 +1173,59 @@ under the License. + + + + + + + + + + + sun/java2d/pipe/AAShapePipe.renderTiles(Lsun/java2d/SunGraphics2D;Ljava/awt/Shape;Lsun/java2d/pipe/AATileGenerator;[I)V + sun/java2d/pipe/AlphaPaintPipe.renderPathTile(Ljava/lang/Object;[BIIIIII)V + java/awt/TexturePaintContext.getRaster(IIII)Ljava/awt/image/Raster; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1219,39 +1265,23 @@ under the License. - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + @@ -1306,6 +1336,7 @@ under the License. + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -1500,45 +1514,23 @@ under the License. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -1559,72 +1551,35 @@ under the License. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1650,34 +1605,16 @@ under the License. unless="integration.test.notRequired" xmlns:jacoco="antlib:org.jacoco.ant"> - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + @@ -1739,33 +1676,16 @@ under the License. - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + @@ -1791,6 +1711,9 @@ under the License. + + + @@ -1828,7 +1751,7 @@ under the License. - + POI API Documentation]]> @@ -2113,6 +2036,7 @@ under the License. sonar/*/src/**, compile-lib/**, ooxml-lib/**, + ooxml-testlib/**, scripts/**, TEST*, *.ipr, @@ -2303,7 +2227,10 @@ under the License. - + + @@ -2453,7 +2380,7 @@ under the License. - + Modified: poi/branches/hemf/doap_POI.rdf URL: http://svn.apache.org/viewvc/poi/branches/hemf/doap_POI.rdf?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/doap_POI.rdf (original) +++ poi/branches/hemf/doap_POI.rdf Fri Dec 14 00:44:40 2018 @@ -37,6 +37,13 @@ + Apache POI 4.0.1 + 2018-12-03 + 4.0.1 + + + + Apache POI 4.0.0 2018-09-07 4.0.0 Modified: poi/branches/hemf/src/integrationtest/org/apache/poi/TestAllFiles.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/integrationtest/org/apache/poi/TestAllFiles.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/integrationtest/org/apache/poi/TestAllFiles.java (original) +++ poi/branches/hemf/src/integrationtest/org/apache/poi/TestAllFiles.java Fri Dec 14 00:44:40 2018 @@ -289,6 +289,7 @@ public class TestAllFiles { "document/Bug50955.doc", "document/57843.doc", "slideshow/PPT95.ppt", + "slideshow/pp40only.ppt", "slideshow/Divino_Revelado.pptx", "openxml4j/OPCCompliance_CoreProperties_DCTermsNamespaceLimitedUseFAIL.docx", "openxml4j/OPCCompliance_CoreProperties_DoNotUseCompatibilityMarkupFAIL.docx", Modified: poi/branches/hemf/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java (original) +++ poi/branches/hemf/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java Fri Dec 14 00:44:40 2018 @@ -35,7 +35,6 @@ import java.util.Iterator; import java.util.Locale; import java.util.Set; -import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import org.apache.poi.EncryptedDocumentException; @@ -148,7 +147,7 @@ public class XSSFFileHandler extends Spr } private void exportToXML(XSSFWorkbook wb) throws SAXException, - ParserConfigurationException, TransformerException { + TransformerException { for (XSSFMap map : wb.getCustomXMLMappings()) { XSSFExportToXml exporter = new XSSFExportToXml(map); @@ -165,7 +164,6 @@ public class XSSFFileHandler extends Spr // zip-bomb EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/54764.xlsx"); EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/54764-2.xlsx"); - EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/54764.xlsx"); EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/poc-xmlbomb.xlsx"); EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/poc-xmlbomb-empty.xlsx"); // strict OOXML @@ -185,18 +183,19 @@ public class XSSFFileHandler extends Spr public void handleAdditional(File file) throws Exception { // redirect stdout as the examples often write lots of text PrintStream oldOut = System.out; + String testFile = file.getParentFile().getName() + "/" + file.getName(); try { System.setOut(new NullPrintStream()); FromHowTo.main(new String[]{file.getAbsolutePath()}); XLSX2CSV.main(new String[]{file.getAbsolutePath()}); assertFalse("Expected Extraction to fail for file " + file + " and handler " + this + ", but did not fail!", - EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())); + EXPECTED_ADDITIONAL_FAILURES.contains(testFile)); } catch (OLE2NotOfficeXmlFileException e) { // we have some files that are not actually OOXML and thus cannot be tested here } catch (IllegalArgumentException | InvalidFormatException | POIXMLException | IOException e) { - if(!EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())) { + if(!EXPECTED_ADDITIONAL_FAILURES.contains(testFile)) { throw e; } } finally { Modified: poi/branches/hemf/src/java/org/apache/poi/ddf/EscherProperties.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/ddf/EscherProperties.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/ddf/EscherProperties.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/ddf/EscherProperties.java Fri Dec 14 00:44:40 2018 @@ -26,6 +26,7 @@ import java.util.Map; * * @author Glen Stampoultzis (glens at apache.org) */ +@SuppressWarnings("WeakerAccess") public final class EscherProperties { // Property constants @@ -117,6 +118,15 @@ public final class EscherProperties { public static final short GEOMETRY__ADJUST8VALUE = 334; public static final short GEOMETRY__ADJUST9VALUE = 335; public static final short GEOMETRY__ADJUST10VALUE = 336; + public static final short GEOMETRY__PCONNECTIONSITES = 337; + public static final short GEOMETRY__PCONNECTIONSITESDIR = 338; + public static final short GEOMETRY__XLIMO = 339; + public static final short GEOMETRY__YLIMO = 340; + public static final short GEOMETRY__PADJUSTHANDLES = 341; + public static final short GEOMETRY__PGUIDES = 342; + public static final short GEOMETRY__PINSCRIBE = 343; + public static final short GEOMETRY__CXK = 344; + public static final short GEOMETRY__PFRAGMENTS = 345; public static final short GEOMETRY__SHADOWok = 378; public static final short GEOMETRY__3DOK = 379; public static final short GEOMETRY__LINEOK = 380; @@ -333,6 +343,9 @@ public final class EscherProperties { private static final Map properties = initProps(); + private EscherProperties() { + } + private static Map initProps() { Map m = new HashMap<>(); addProp(m, TRANSFORM__ROTATION, "transform.rotation"); @@ -423,6 +436,15 @@ public final class EscherProperties { addProp(m, GEOMETRY__ADJUST8VALUE, "geometry.adjust8value"); addProp(m, GEOMETRY__ADJUST9VALUE, "geometry.adjust9value"); addProp(m, GEOMETRY__ADJUST10VALUE, "geometry.adjust10value"); + addProp(m, GEOMETRY__PCONNECTIONSITES, "geometry.pConnectionSites"); + addProp(m, GEOMETRY__PCONNECTIONSITESDIR, "geometry.pConnectionSitesDir"); + addProp(m, GEOMETRY__XLIMO, "geometry.xLimo"); + addProp(m, GEOMETRY__YLIMO, "geometry.yLimo"); + addProp(m, GEOMETRY__PADJUSTHANDLES, "geometry.pAdjustHandles"); + addProp(m, GEOMETRY__PGUIDES, "geometry.pGuides"); + addProp(m, GEOMETRY__PINSCRIBE, "geometry.pInscribe"); + addProp(m, GEOMETRY__CXK, "geometry.cxk"); + addProp(m, GEOMETRY__PFRAGMENTS, "geometry.pFragments"); addProp(m, GEOMETRY__SHADOWok, "geometry.shadowOK"); addProp(m, GEOMETRY__3DOK, "geometry.3dok"); addProp(m, GEOMETRY__LINEOK, "geometry.lineok"); @@ -641,20 +663,20 @@ public final class EscherProperties { } private static void addProp(Map m, int s, String propName) { - m.put(Short.valueOf((short) s), new EscherPropertyMetaData(propName)); + m.put((short) s, new EscherPropertyMetaData(propName)); } private static void addProp(Map m, int s, String propName, byte type) { - m.put(Short.valueOf((short) s), new EscherPropertyMetaData(propName, type)); + m.put((short) s, new EscherPropertyMetaData(propName, type)); } public static String getPropertyName(short propertyId) { - EscherPropertyMetaData o = properties.get(Short.valueOf(propertyId)); + EscherPropertyMetaData o = properties.get(propertyId); return o == null ? "unknown" : o.getDescription(); } public static byte getPropertyType(short propertyId) { - EscherPropertyMetaData escherPropertyMetaData = properties.get(Short.valueOf(propertyId)); + EscherPropertyMetaData escherPropertyMetaData = properties.get(propertyId); return escherPropertyMetaData == null ? 0 : escherPropertyMetaData.getType(); } } Modified: poi/branches/hemf/src/java/org/apache/poi/hpsf/VariantSupport.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/hpsf/VariantSupport.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/hpsf/VariantSupport.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/hpsf/VariantSupport.java Fri Dec 14 00:44:40 2018 @@ -36,7 +36,7 @@ import org.apache.poi.util.POILogger; * Supports reading and writing of variant data.

* * FIXME (3): Reading and writing should be made more - * uniform than it is now. The following items should be resolved:

+ * uniform than it is now. The following items should be resolved: * *

    * Modified: poi/branches/hemf/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java Fri Dec 14 00:44:40 2018 @@ -33,8 +33,11 @@ import org.apache.poi.hpsf.SummaryInform * The methods {@link #getSummaryInformationProperties} and {@link * #getDocumentSummaryInformationProperties} return singleton {@link * PropertyIDMap}s. An application that wants to extend these maps - * should treat them as unmodifiable, copy them and modifiy the + * should treat them as unmodifiable, copy them and modify the * copies. + * + * Trying to modify the map directly will cause exceptions + * {@link UnsupportedOperationException} to be thrown. */ public class PropertyIDMap implements Map { @@ -490,11 +493,13 @@ public class PropertyIDMap implements Ma @Override public String put(Long key, String value) { + //noinspection ConstantConditions return idMap.put(key, value); } @Override public String remove(Object key) { + //noinspection ConstantConditions return idMap.remove(key); } Modified: poi/branches/hemf/src/java/org/apache/poi/hssf/model/InternalWorkbook.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/hssf/model/InternalWorkbook.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/hssf/model/InternalWorkbook.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/hssf/model/InternalWorkbook.java Fri Dec 14 00:44:40 2018 @@ -2276,6 +2276,8 @@ public final class InternalWorkbook { /** * Only for internal calls - code based on this is not supported ... + * + * @return The list of records. */ @Internal public WorkbookRecordList getWorkbookRecordList() { Modified: poi/branches/hemf/src/java/org/apache/poi/hssf/record/RecordInputStream.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/hssf/record/RecordInputStream.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/hssf/record/RecordInputStream.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/hssf/record/RecordInputStream.java Fri Dec 14 00:44:40 2018 @@ -33,8 +33,9 @@ import org.apache.poi.util.LittleEndianI import org.apache.poi.util.RecordFormatException; /** - * Title: Record Input Stream

    - * Description: Wraps a stream and provides helper methods for the construction of records.

    + * Title: Record Input Stream + * + * Description: Wraps a stream and provides helper methods for the construction of records. */ public final class RecordInputStream implements LittleEndianInput { @@ -142,6 +143,15 @@ public final class RecordInputStream imp _nextSid = readNextSid(); } + static LittleEndianInput getLEI(InputStream is) { + if (is instanceof LittleEndianInput) { + // accessing directly is an optimisation + return (LittleEndianInput) is; + } + // less optimal, but should work OK just the same. Often occurs in junit tests. + return new LittleEndianInputStream(is); + } + /** * @return the number of bytes available in the current BIFF record * @see #remaining() @@ -295,12 +305,9 @@ public final class RecordInputStream imp return _dataInput.readUShort(); } - /** - * - * @return a double - might return NaN - */ @Override public double readDouble() { + // YK: Excel doesn't write NaN but instead converts the cell type into {@link CellType#ERROR}. return Double.longBitsToDouble(readLong()); } Modified: poi/branches/hemf/src/java/org/apache/poi/hssf/record/SSTRecord.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/hssf/record/SSTRecord.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/hssf/record/SSTRecord.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/hssf/record/SSTRecord.java Fri Dec 14 00:44:40 2018 @@ -161,7 +161,7 @@ public final class SSTRecord extends Con *

    * The data consists of sets of string data. This string data is * arranged as follows: - *

    + *

    *

          * short  string_length;   // length of string data
          * byte   string_flag;     // flag specifying special string
    @@ -176,9 +176,9 @@ public final class SSTRecord extends Con
          * byte[] extension;       // optional extension (length of array
          *                         // is extend_length)
          * 
    - *

    + *

    * The string_flag is bit mapped as follows: - *

    + *

    * * * @@ -232,7 +232,7 @@ public final class SSTRecord extends Con * associated data. The UnicodeString class can handle the byte[] * vs short[] nature of the actual string data * - * @param in the RecordInputstream to read the record from + * @param in the RecordInputStream to read the record from */ public SSTRecord(RecordInputStream in) { // this method is ALWAYS called after construction -- using Modified: poi/branches/hemf/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java Fri Dec 14 00:44:40 2018 @@ -77,7 +77,7 @@ public final class SharedFormulaRecord e public String toString() { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); buffer.append("[SHARED FORMULA (").append(HexDump.intToHex(sid)).append("]\n"); buffer.append(" .range = ").append(getRange()).append("\n"); @@ -99,6 +99,10 @@ public final class SharedFormulaRecord e } /** + * Convert formula into an array of {@link Ptg} tokens. + * + * @param formula The record to break into tokens, cannot be null + * * @return the equivalent {@link Ptg} array that the formula would have, were it not shared. */ public Ptg[] getFormulaTokens(FormulaRecord formula) { Modified: poi/branches/hemf/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java Fri Dec 14 00:44:40 2018 @@ -42,6 +42,8 @@ public abstract class SharedValueRecordB /** * reads only the range (1 {@link CellRangeAddress8Bit}) from the stream + * + * @param in The interface for reading the record data. */ public SharedValueRecordBase(LittleEndianInput in) { _range = new CellRangeAddress8Bit(in); @@ -99,14 +101,12 @@ public abstract class SharedValueRecordB && r.getLastColumn() >= colIx; } /** - * @return {@code true} if (rowIx, colIx) describes the first cell in this shared value - * object's range - * * @param rowIx the row index * @param colIx the column index - * - * @return {@code true} if its the first cell in this shared value object range - * + * + * @return {@code true} if (rowIx, colIx) describes the first cell in this shared value + * object's range + * * @see #getRange() */ public final boolean isFirstCell(int rowIx, int colIx) { Modified: poi/branches/hemf/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java Fri Dec 14 00:44:40 2018 @@ -99,6 +99,13 @@ public abstract class ChunkedCipherOutpu return initCipherForBlock(cipher, block, lastChunk); } + // helper method to break a recursion loop introduced because of an IBMJCE bug, i.e. not resetting on Cipher.doFinal() + @Internal + protected Cipher initCipherForBlockNoFlush(Cipher existing, int block, boolean lastChunk) + throws IOException, GeneralSecurityException { + return initCipherForBlock(cipher, block, lastChunk); + } + protected abstract Cipher initCipherForBlock(Cipher existing, int block, boolean lastChunk) throws IOException, GeneralSecurityException; @@ -212,13 +219,30 @@ public abstract class ChunkedCipherOutpu * @throws IllegalBlockSizeException * @throws ShortBufferException */ - protected int invokeCipher(int posInChunk, boolean doFinal) throws GeneralSecurityException { + protected int invokeCipher(int posInChunk, boolean doFinal) throws GeneralSecurityException, IOException { byte plain[] = (plainByteFlags.isEmpty()) ? null : chunk.clone(); int ciLen = (doFinal) ? cipher.doFinal(chunk, 0, posInChunk, chunk) : cipher.update(chunk, 0, posInChunk, chunk); + if (doFinal && "IBMJCE".equals(cipher.getProvider().getName()) && "RC4".equals(cipher.getAlgorithm())) { + // workaround for IBMs cipher not resetting on doFinal + + int index = (int)(pos >> chunkBits); + boolean lastChunk; + if (posInChunk==0) { + index--; + posInChunk = chunk.length; + lastChunk = false; + } else { + // pad the last chunk + lastChunk = true; + } + + cipher = initCipherForBlockNoFlush(cipher, index, lastChunk); + } + if (plain != null) { int i = plainByteFlags.nextSetBit(0); while (i >= 0 && i < posInChunk) { Modified: poi/branches/hemf/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptor.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptor.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptor.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptor.java Fri Dec 14 00:44:40 2018 @@ -207,9 +207,15 @@ public class CryptoAPIEncryptor extends protected Cipher initCipherForBlock(Cipher cipher, int block, boolean lastChunk) throws IOException, GeneralSecurityException { flush(); + return initCipherForBlockNoFlush(cipher, block, lastChunk); + } + + @Override + protected Cipher initCipherForBlockNoFlush(Cipher existing, int block, boolean lastChunk) + throws GeneralSecurityException { EncryptionInfo ei = getEncryptionInfo(); SecretKey sk = getSecretKey(); - return CryptoAPIDecryptor.initCipherForBlock(cipher, block, ei, sk, Cipher.ENCRYPT_MODE); + return CryptoAPIDecryptor.initCipherForBlock(existing, block, ei, sk, Cipher.ENCRYPT_MODE); } @Override Modified: poi/branches/hemf/src/java/org/apache/poi/poifs/filesystem/FileMagic.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/poifs/filesystem/FileMagic.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/poifs/filesystem/FileMagic.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/poifs/filesystem/FileMagic.java Fri Dec 14 00:44:40 2018 @@ -78,7 +78,7 @@ public enum FileMagic { /** PDF document */ PDF("%PDF"), /** Some different HTML documents */ - HTML(" Modified: poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawBackground.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawBackground.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawBackground.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawBackground.java Fri Dec 14 00:44:40 2018 @@ -17,6 +17,8 @@ package org.apache.poi.sl.draw; +import static org.apache.poi.sl.draw.DrawPaint.fillPaintWorkaround; + import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Paint; @@ -59,10 +61,10 @@ public class DrawBackground extends Draw if(fill != null) { graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, anchor); graphics.setPaint(fill); - graphics.fill(anchor2); + fillPaintWorkaround(graphics, anchor2); } } - + protected Background getShape() { return (Background)shape; } Modified: poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java Fri Dec 14 00:44:40 2018 @@ -17,43 +17,11 @@ package org.apache.poi.sl.draw; -import java.awt.Graphics2D; -import java.awt.geom.AffineTransform; -import java.awt.geom.Path2D; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.apache.poi.sl.draw.geom.Outline; -import org.apache.poi.sl.draw.geom.Path; -import org.apache.poi.sl.usermodel.*; +import org.apache.poi.sl.usermodel.FreeformShape; +@SuppressWarnings("WeakerAccess") public class DrawFreeformShape extends DrawAutoShape { public DrawFreeformShape(FreeformShape shape) { super(shape); } - - protected Collection computeOutlines(Graphics2D graphics) { - List lst = new ArrayList<>(); - FreeformShape fsh = (FreeformShape) getShape(); - Path2D sh = fsh.getPath(); - - AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM); - if (tx == null) { - tx = new AffineTransform(); - } - - java.awt.Shape canvasShape = tx.createTransformedShape(sh); - - FillStyle fs = fsh.getFillStyle(); - StrokeStyle ss = fsh.getStrokeStyle(); - Path path = new Path(fs != null, ss != null); - lst.add(new Outline(canvasShape, path)); - return lst; - } - - @Override - protected TextShape> getShape() { - return (TextShape>)shape; - } } Modified: poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawPaint.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawPaint.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawPaint.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawPaint.java Fri Dec 14 00:44:40 2018 @@ -23,13 +23,17 @@ import java.awt.Graphics2D; import java.awt.LinearGradientPaint; import java.awt.Paint; import java.awt.RadialGradientPaint; +import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; +import java.util.Map; import java.util.Objects; +import java.util.TreeMap; +import java.util.function.BiFunction; import org.apache.poi.sl.usermodel.AbstractColorStyle; import org.apache.poi.sl.usermodel.ColorStyle; @@ -197,28 +201,17 @@ public class DrawPaint { @Override public int getShade() { - int shade = orig.getShade(); - switch (modifier) { - case DARKEN: - return Math.min(100000, Math.max(0,shade)+40000); - case DARKEN_LESS: - return Math.min(100000, Math.max(0,shade)+20000); - default: - return shade; - } + return scale(orig.getShade(), PaintModifier.DARKEN_LESS, PaintModifier.DARKEN); } @Override public int getTint() { - int tint = orig.getTint(); - switch (modifier) { - case LIGHTEN: - return Math.min(100000, Math.max(0,tint)+40000); - case LIGHTEN_LESS: - return Math.min(100000, Math.max(0,tint)+20000); - default: - return tint; - } + return scale(orig.getTint(), PaintModifier.LIGHTEN_LESS, PaintModifier.LIGHTEN); + } + + private int scale(int value, PaintModifier lessModifier, PaintModifier moreModifier) { + int delta = (modifier == lessModifier ? 20000 : (modifier == moreModifier ? 40000 : 0)); + return Math.min(100000, Math.max(0,value)+delta); } }; @@ -300,7 +293,7 @@ public class DrawPaint { Color result = color.getColor(); double alpha = getAlpha(result, color); - double hsl[] = RGB2HSL(result); // values are in the range [0..100] (usually ...) + double[] hsl = RGB2HSL(result); // values are in the range [0..100] (usually ...) applyHslModOff(hsl, 0, color.getHueMod(), color.getHueOff()); applyHslModOff(hsl, 1, color.getSatMod(), color.getSatOff()); applyHslModOff(hsl, 2, color.getLumMod(), color.getLumOff()); @@ -344,7 +337,7 @@ public class DrawPaint { * @param mod the modulation adjustment * @param off the offset adjustment */ - private static void applyHslModOff(double hsl[], int hslPart, int mod, int off) { + private static void applyHslModOff(double[] hsl, int hslPart, int mod, int off) { if (mod == -1) { mod = 100000; } @@ -363,7 +356,7 @@ public class DrawPaint { * * For a shade, the equation is luminance * %tint. */ - private static void applyShade(double hsl[], ColorStyle fc) { + private static void applyShade(double[] hsl, ColorStyle fc) { int shade = fc.getShade(); if (shade == -1) { return; @@ -380,7 +373,7 @@ public class DrawPaint { * For a tint, the equation is luminance * %tint + (1-%tint). * (Note that 1-%tint is equal to the lumOff value in DrawingML.) */ - private static void applyTint(double hsl[], ColorStyle fc) { + private static void applyTint(double[] hsl, ColorStyle fc) { int tint = fc.getTint(); if (tint == -1) { return; @@ -403,70 +396,63 @@ public class DrawPaint { } Rectangle2D anchor = DrawShape.getAnchor(graphics, shape); - final double h = anchor.getHeight(), w = anchor.getWidth(), x = anchor.getX(), y = anchor.getY(); AffineTransform at = AffineTransform.getRotateInstance(Math.toRadians(angle), anchor.getCenterX(), anchor.getCenterY()); - double diagonal = Math.sqrt(h * h + w * w); - Point2D p1 = new Point2D.Double(x + w / 2 - diagonal / 2, y + h / 2); - p1 = at.transform(p1, null); - - Point2D p2 = new Point2D.Double(x + w, y + h / 2); - p2 = at.transform(p2, null); + double diagonal = Math.sqrt(Math.pow(anchor.getWidth(),2) + Math.pow(anchor.getHeight(),2)); + final Point2D p1 = at.transform(new Point2D.Double(anchor.getCenterX() - diagonal / 2, anchor.getCenterY()), null); + final Point2D p2 = at.transform(new Point2D.Double(anchor.getMaxX(), anchor.getCenterY()), null); // snapToAnchor(p1, anchor); // snapToAnchor(p2, anchor); - if (p1.equals(p2)) { - // gradient paint on the same point throws an exception ... and doesn't make sense - return null; - } - - float[] fractions = fill.getGradientFractions(); - Color[] colors = new Color[fractions.length]; - - int i = 0; - for (ColorStyle fc : fill.getGradientColors()) { - // if fc is null, use transparent color to get color of background - colors[i++] = (fc == null) ? TRANSPARENT : applyColorTransform(fc); - } - - return new LinearGradientPaint(p1, p2, fractions, colors); + // gradient paint on the same point throws an exception ... and doesn't make sense + return (p1.equals(p2)) ? null : safeFractions((f,c)->new LinearGradientPaint(p1,p2,f,c), fill); } + @SuppressWarnings("WeakerAccess") protected Paint createRadialGradientPaint(GradientPaint fill, Graphics2D graphics) { Rectangle2D anchor = DrawShape.getAnchor(graphics, shape); - Point2D pCenter = new Point2D.Double(anchor.getX() + anchor.getWidth()/2, - anchor.getY() + anchor.getHeight()/2); + final Point2D pCenter = new Point2D.Double(anchor.getCenterX(), anchor.getCenterY()); - float radius = (float)Math.max(anchor.getWidth(), anchor.getHeight()); + final float radius = (float)Math.max(anchor.getWidth(), anchor.getHeight()); - float[] fractions = fill.getGradientFractions(); - Color[] colors = new Color[fractions.length]; - - int i=0; - for (ColorStyle fc : fill.getGradientColors()) { - colors[i++] = applyColorTransform(fc); - } - - return new RadialGradientPaint(pCenter, radius, fractions, colors); + return safeFractions((f,c)->new RadialGradientPaint(pCenter,radius,f,c), fill); } @SuppressWarnings({"WeakerAccess", "unused"}) protected Paint createPathGradientPaint(GradientPaint fill, Graphics2D graphics) { // currently we ignore an eventually center setting + return safeFractions(PathGradientPaint::new, fill); + } + + private Paint safeFractions(BiFunction init, GradientPaint fill) { float[] fractions = fill.getGradientFractions(); - Color[] colors = new Color[fractions.length]; + final ColorStyle[] styles = fill.getGradientColors(); + + // need to remap the fractions, because Java doesn't like repeating fraction values + Map m = new TreeMap<>(); + for (int i = 0; i me : m.entrySet()) { + fractions[i] = me.getKey(); + colors[i] = me.getValue(); + i++; } - return new PathGradientPaint(colors, fractions); + return init.apply(fractions, colors); } /** @@ -620,4 +606,19 @@ public class DrawPaint { return (float)(1.055d * Math.pow(linRGB / 100000d, 1.0d/2.4d) - 0.055d); } } + + + static void fillPaintWorkaround(Graphics2D graphics, Shape shape) { + // the ibm jdk has a rendering/JIT bug, which throws an AIOOBE in + // TexturePaintContext$Int.setRaster(TexturePaintContext.java:476) + // this usually doesn't happen while debugging, because JIT doesn't jump in then. + try { + graphics.fill(shape); + } catch (ArrayIndexOutOfBoundsException e) { + LOG.log(POILogger.WARN, "IBM JDK failed with TexturePaintContext AIOOBE - try adding the following to the VM parameter:\n" + + "-Xjit:exclude={sun/java2d/pipe/AlphaPaintPipe.renderPathTile(Ljava/lang/Object;[BIIIIII)V} and " + + "search for 'JIT Problem Determination for IBM SDK using -Xjit' (http://www-01.ibm.com/support/docview.wss?uid=swg21294023) " + + "for how to add/determine further excludes", e); + } + } } Modified: poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java Fri Dec 14 00:44:40 2018 @@ -17,6 +17,8 @@ package org.apache.poi.sl.draw; +import static org.apache.poi.sl.draw.DrawPaint.fillPaintWorkaround; + import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; @@ -87,7 +89,7 @@ public class DrawSimpleShape extends Dra graphics.setPaint(fillMod); java.awt.Shape s = o.getOutline(); graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s); - graphics.fill(s); + fillPaintWorkaround(graphics, s); } } } @@ -327,7 +329,7 @@ public class DrawSimpleShape extends Dra graphics.setPaint(shadowColor); if(fill != null && p.isFilled()){ - graphics.fill(s); + fillPaintWorkaround(graphics, s); } else if (line != null && p.isStroked()) { graphics.draw(s); } @@ -410,14 +412,20 @@ public class DrawSimpleShape extends Dra } for (Path p : geom) { - double w = p.getW(), h = p.getH(), scaleX = Units.toPoints(1), scaleY = scaleX; + double w = p.getW(), h = p.getH(), scaleX, scaleY; if (w == -1) { w = Units.toEMU(anchor.getWidth()); + scaleX = Units.toPoints(1); + } else if (anchor.getWidth() == 0) { + scaleX = 1; } else { scaleX = anchor.getWidth() / w; } if (h == -1) { h = Units.toEMU(anchor.getHeight()); + scaleY = Units.toPoints(1); + } else if (anchor.getHeight() == 0) { + scaleY = 1; } else { scaleY = anchor.getHeight() / h; } Modified: poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawTableShape.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawTableShape.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawTableShape.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/sl/draw/DrawTableShape.java Fri Dec 14 00:44:40 2018 @@ -17,6 +17,8 @@ package org.apache.poi.sl.draw; +import static org.apache.poi.sl.draw.DrawPaint.fillPaintWorkaround; + import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; @@ -83,8 +85,8 @@ public class DrawTableShape extends Draw Paint fillPaint = drawPaint.getPaint(graphics, tc.getFillStyle().getPaint()); graphics.setPaint(fillPaint); Rectangle2D cellAnc = tc.getAnchor(); - graphics.fill(cellAnc); - + fillPaintWorkaround(graphics, cellAnc); + for (BorderEdge edge : BorderEdge.values()) { StrokeStyle stroke = tc.getBorderStyle(edge); if (stroke == null) { Modified: poi/branches/hemf/src/java/org/apache/poi/sl/draw/PathGradientPaint.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/sl/draw/PathGradientPaint.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/sl/draw/PathGradientPaint.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/sl/draw/PathGradientPaint.java Fri Dec 14 00:44:40 2018 @@ -23,21 +23,24 @@ import java.awt.MultipleGradientPaint.Cy import java.awt.geom.*; import java.awt.image.*; +import org.apache.poi.util.Internal; + +@Internal class PathGradientPaint implements Paint { // http://asserttrue.blogspot.de/2010/01/how-to-iimplement-custom-paint-in-50.html - protected final Color colors[]; - protected final float fractions[]; - protected final int capStyle; - protected final int joinStyle; - protected final int transparency; + private final Color[] colors; + private final float[] fractions; + private final int capStyle; + private final int joinStyle; + private final int transparency; - public PathGradientPaint(Color colors[], float fractions[]) { - this(colors,fractions,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND); + PathGradientPaint(float[] fractions, Color[] colors) { + this(fractions,colors,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND); } - public PathGradientPaint(Color colors[], float fractions[], int capStyle, int joinStyle) { + private PathGradientPaint(float[] fractions, Color[] colors, int capStyle, int joinStyle) { this.colors = colors.clone(); this.fractions = fractions.clone(); this.capStyle = capStyle; @@ -66,26 +69,26 @@ class PathGradientPaint implements Paint } class PathGradientContext implements PaintContext { - protected final Rectangle deviceBounds; - protected final Rectangle2D userBounds; + final Rectangle deviceBounds; + final Rectangle2D userBounds; protected final AffineTransform xform; - protected final RenderingHints hints; + final RenderingHints hints; /** * for POI: the shape will be only known when the subclasses determines the concrete implementation * in the draw/-content method, so we need to postpone the setting/creation as long as possible **/ protected final Shape shape; - protected final PaintContext pCtx; - protected final int gradientSteps; + final PaintContext pCtx; + final int gradientSteps; WritableRaster raster; - public PathGradientContext( - ColorModel cm - , Rectangle deviceBounds - , Rectangle2D userBounds - , AffineTransform xform - , RenderingHints hints + PathGradientContext( + ColorModel cm + , Rectangle deviceBounds + , Rectangle2D userBounds + , AffineTransform xform + , RenderingHints hints ) { shape = (Shape)hints.get(Drawable.GRADIENT_SHAPE); if (shape == null) { @@ -139,7 +142,7 @@ class PathGradientPaint implements Paint return childRaster; } - protected int getGradientSteps(Shape gradientShape) { + int getGradientSteps(Shape gradientShape) { Rectangle rect = gradientShape.getBounds(); int lower = 1; int upper = (int)(Math.max(rect.getWidth(),rect.getHeight())/2.0); @@ -158,7 +161,7 @@ class PathGradientPaint implements Paint - protected void createRaster() { + void createRaster() { ColorModel cm = getColorModel(); raster = cm.createCompatibleWritableRaster((int)deviceBounds.getWidth(), (int)deviceBounds.getHeight()); BufferedImage img = new BufferedImage(cm, raster, false, null); @@ -168,7 +171,7 @@ class PathGradientPaint implements Paint graphics.transform(xform); Raster img2 = pCtx.getRaster(0, 0, gradientSteps, 1); - int rgb[] = new int[cm.getNumComponents()]; + int[] rgb = new int[cm.getNumComponents()]; for (int i = gradientSteps-1; i>=0; i--) { img2.getPixel(i, 0, rgb); Modified: poi/branches/hemf/src/java/org/apache/poi/sl/draw/geom/Context.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/sl/draw/geom/Context.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/sl/draw/geom/Context.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/sl/draw/geom/Context.java Fri Dec 14 00:44:40 2018 @@ -22,11 +22,18 @@ package org.apache.poi.sl.draw.geom; import java.awt.geom.Rectangle2D; import java.util.HashMap; import java.util.Map; +import java.util.regex.Pattern; public class Context { - final Map _ctx = new HashMap<>(); - final IAdjustableShape _props; - final Rectangle2D _anchor; + private static final Pattern DOUBLE_PATTERN = Pattern.compile( + "[\\x00-\\x20]*[+-]?(NaN|Infinity|((((\\p{Digit}+)(\\.)?((\\p{Digit}+)?)" + + "([eE][+-]?(\\p{Digit}+))?)|(\\.(\\p{Digit}+)([eE][+-]?(\\p{Digit}+))?)|" + + "(((0[xX](\\p{XDigit}+)(\\.)?)|(0[xX](\\p{XDigit}+)?(\\.)(\\p{XDigit}+)))" + + "[pP][+-]?(\\p{Digit}+)))[fFdD]?))[\\x00-\\x20]*"); + + private final Map _ctx = new HashMap<>(); + private final IAdjustableShape _props; + private final Rectangle2D _anchor; public Context(CustomGeometry geom, Rectangle2D anchor, IAdjustableShape props){ _props = props; @@ -39,23 +46,22 @@ public class Context { } } - public Rectangle2D getShapeAnchor(){ + Rectangle2D getShapeAnchor(){ return _anchor; } - public Guide getAdjustValue(String name){ + Guide getAdjustValue(String name){ // ignore HSLF props for now ... the results with default value are usually better - see #59004 return (_props.getClass().getName().contains("hslf")) ? null : _props.getAdjustValue(name); } public double getValue(String key){ - if(key.matches("(\\+|-)?\\d+")){ + if(DOUBLE_PATTERN.matcher(key).matches()){ return Double.parseDouble(key); } - Double val = _ctx.get(key); // BuiltInGuide throws IllegalArgumentException if key is not defined - return (val != null) ? val : evaluate(BuiltInGuide.valueOf("_"+key)); + return _ctx.containsKey(key) ? _ctx.get(key) : evaluate(BuiltInGuide.valueOf("_"+key)); } public double evaluate(Formula fmla){ Modified: poi/branches/hemf/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java Fri Dec 14 00:44:40 2018 @@ -27,12 +27,12 @@ import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.stream.EventFilter; -import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.events.StartElement; import javax.xml.stream.events.XMLEvent; +import javax.xml.transform.stream.StreamSource; import org.apache.poi.sl.draw.binding.CTCustomGeometry2D; import org.apache.poi.util.POILogFactory; @@ -61,27 +61,30 @@ public class PresetGeometries extends Li }; XMLInputFactory staxFactory = StaxHelper.newXMLInputFactory(); - XMLEventReader staxReader = staxFactory.createXMLEventReader(is); - XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter); - // ignore StartElement: - /* XMLEvent evDoc = */ staxFiltRd.nextEvent(); - // JAXB: - JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE); - Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); - - long cntElem = 0; - while (staxFiltRd.peek() != null) { - StartElement evRoot = (StartElement)staxFiltRd.peek(); - String name = evRoot.getName().getLocalPart(); - JAXBElement el = unmarshaller.unmarshal(staxReader, CTCustomGeometry2D.class); - CTCustomGeometry2D cus = el.getValue(); - cntElem++; - - if(containsKey(name)) { - LOG.log(POILogger.WARN, "Duplicate definition of " + name); + XMLStreamReader streamReader = staxFactory.createXMLStreamReader(new StreamSource(is)); + try { + // ignore StartElement: + streamReader.nextTag(); + + // JAXB: + JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + + long cntElem = 0; + while (streamReader.hasNext() && streamReader.nextTag() == XMLStreamConstants.START_ELEMENT) { + String name = streamReader.getLocalName(); + JAXBElement el = unmarshaller.unmarshal(streamReader, CTCustomGeometry2D.class); + CTCustomGeometry2D cus = el.getValue(); + cntElem++; + + if (containsKey(name)) { + LOG.log(POILogger.WARN, "Duplicate definition of " + name); + } + put(name, new CustomGeometry(cus)); } - put(name, new CustomGeometry(cus)); - } + } finally { + streamReader.close(); + } } /** Modified: poi/branches/hemf/src/java/org/apache/poi/sl/usermodel/FreeformShape.java URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/sl/usermodel/FreeformShape.java?rev=1848906&r1=1848905&r2=1848906&view=diff ============================================================================== --- poi/branches/hemf/src/java/org/apache/poi/sl/usermodel/FreeformShape.java (original) +++ poi/branches/hemf/src/java/org/apache/poi/sl/usermodel/FreeformShape.java Fri Dec 14 00:44:40 2018 @@ -24,16 +24,15 @@ public interface FreeformShape< P extends TextParagraph > extends AutoShape { /** - * Gets the shape path. - *

    - * The path is translated in the shape's coordinate system, i.e. - * freeform.getPath().getBounds2D() equals to freeform.getAnchor() - * (small discrepancies are possible due to rounding errors) - *

    + * Gets the shape path.

    + * + * The path is translated in the shape's coordinate system, i.e. + * freeform.getPath2D().getBounds2D() equals to freeform.getAnchor() + * (small discrepancies are possible due to rounding errors) * * @return the path */ - Path2D.Double getPath(); + Path2D getPath(); /** * Set the shape path @@ -41,5 +40,5 @@ public interface FreeformShape< * @param path shape outline * @return the number of points written */ - int setPath(Path2D.Double path); + int setPath(Path2D path); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org

    Bit number